/*
*******************************************************************
* Function: GetCIS()
*
* Description : Updates the configuration controllers CIS by the database
* Parameters : CGBLCISID idCIS,r : given CIS_ID
* Returns : CGBLCOError
*
*******************************************************************
*/
CGBLCOError
IGBLCIAccessInterface::GetCIS(CGBLCISID idCIS)
{

	CGBLSMStorageManager *storageManager = static_cast<CGBLSMStorageManager *>(context->GetManagerByGuid(GBLSMStorageManagerGUID));
	IGBLSMConfigurationAccess* smCIS = storageManager->GetConfigurationInterface();

	int flags  = 0 ;
	XString name,value,defaultValue,description,type;


	// create temp array for ci-id's : 
	CKDataArray * resultArray = static_cast<CKDataArray*>(context->CreateObject( CKCID_DATAARRAY, "IGBLSMConfigurationAccess::CISids", CK_OBJECTCREATION_DYNAMIC ));
	context->GetCurrentLevel()->AddObject( resultArray );

	CGBLCOError returnValue 	= smCIS->RetrieveCIList(resultArray,idCIS);

	if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
	{
		for (int i = 0 ; i < resultArray->GetRowCount(); i++ )
		{
			int idCI = 0;
			resultArray->GetElementValue(i,0,&idCI);
			CGBLCIID ciID(idCI);
			returnValue = smCIS->RetrieveCI(&flags,&type,&value,&name,&description,&defaultValue,ciID);
			if (returnValue == CGBLCOError::EGBLCOErrorType::GBLCO_OK)
			{

				CKParameterLocal *tmpCI = context->CreateCKParameterLocal("_temp",CKPGUID_STRING,TRUE);
				tmpCI->SetStringValue( name.Str() );
				//update the CI : 
				CGBLCI *currentCI = searchCI(tmpCI);
				if (currentCI)
				{
                    currentCI->realValue->SetStringValue(value.Str());
					currentCI->defaultValue->SetStringValue(defaultValue.Str());

				}
			}
		}
	}
	context->GetCurrentLevel()->RemoveObject(resultArray);
	context->DestroyObject(resultArray);
	return returnValue;
}
示例#2
0
/*
*******************************************************************
* Function: CreateWidgetInfo()
*
* Description :	CreateWidgetInfo returns an handy info about an parameter type an a
						given string value of this parameter.
                        
* Parameters :	CKContext* context, r : the virtools context.
						CKParameterType parameterType, r : the type to test.
						XString stringValue,r : the string value of the given type.

* Returns : WidgetInfo
*******************************************************************
*/
vtTools::Structs::WidgetInfo* 
vtTools::ParameterTools::
CreateWidgetInfo(CKContext* context,
				 CKParameterType parameterType,
				 XString stringValue)
{
	using namespace vtTools::Structs;
	using namespace vtTools::Enums;
	using namespace vtTools::ParameterTools;


	CKParameterManager *pm = static_cast<CKParameterManager *>(context->GetParameterManager());

	CKGUID guid =pm->ParameterTypeToGuid(parameterType);

	WidgetInfo* result = new WidgetInfo();

	result->parameterInfo  =  GetParameterInfo(context,parameterType);

	CKParameterLocal *localCopy = context->CreateCKParameterLocal("buffer",guid,TRUE);

	localCopy->SetStringValue(stringValue.Str());


	switch(result->parameterInfo.superType) {

		//////////////////////////////////////////////////////////////////////////	color  //////////////////////////////////////////////////////////////////////////
		case vtCOLOUR:
			{
				WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
				VxColor realValue;
				localCopy->GetValue(&realValue);

				DWORD32 dColor = realValue.GetRGBA();

				int r = ColorGetRed(dColor);
				int g = ColorGetGreen(dColor);
				int b = ColorGetBlue(dColor);
				int a = ColorGetAlpha(dColor);

				item->value << r << "," << g << "," << b << "," << a;

				item->widgetType = EVT_WIDGET_COLOR_SELECTION;
				result->items.PushBack(item);
				break;
			}
		//////////////////////////////////////////////////////////////////////////	integer //////////////////////////////////////////////////////////////////////////
		case vtFLOAT:
			{
				WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
				float realValue;
				localCopy->GetValue(&realValue);
				item->value << realValue;
				item->widgetType = EVT_WIDGET_EDIT_TEXT;
				result->items.PushBack(item);
				break;
			}
		//////////////////////////////////////////////////////////////////////////	integer //////////////////////////////////////////////////////////////////////////
		case vtINTEGER:
			{
				WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
				int realValue;
				localCopy->GetValue(&realValue);
				item->value << realValue;
				item->widgetType = EVT_WIDGET_EDIT_TEXT;
				result->items.PushBack(item);
				break;
			}
		//////////////////////////////////////////////////////////////////////////	bool //////////////////////////////////////////////////////////////////////////
		case vtBOOL:
			{
				WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
				CKBOOL realValue;
				localCopy->GetValue(&realValue);
				item->value << realValue;
				item->widgetType = EVT_WIDGET_CHECK_BUTTON;
				result->items.PushBack(item);
				break;
			}

		//////////////////////////////////////////////////////////////////////////	string or file //////////////////////////////////////////////////////////////////////////
		case vtFile :
			{
				WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
				item->value = stringValue;
				item->widgetType = EVT_WIDGET_FILE_SELECTION;
				result->items.PushBack(item);
				break;
			}
		case vtSTRING:
			{
				WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
				item->value = stringValue;
				item->widgetType = EVT_WIDGET_EDIT_TEXT;
				result->items.PushBack(item);
				break;
			}
		//////////////////////////////////////////////////////////////////////////	box	//////////////////////////////////////////////////////////////////////////
		case vtBOX:
		{
			for (int i = 0 ; i < 6 ; i ++ )
				{
				WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();

				VxBbox realValue;
				localCopy->GetValue(&realValue);
				item->widgetType = EVT_WIDGET_EDIT_TEXT;
				switch(i) 
					{
					case 0:
						item->value << realValue.v[i];
						item->label = "min x: ";
						break;
					case 1:
						item->value << realValue.v[i];
						item->label = "min y: ";
						break;
					case 2:
						item->value << realValue.v[i];
						item->label = "min z: ";
						break;
					case 3:
						item->value << realValue.v[i];
						item->label = "max x: ";
						break;
					case 4:
						item->value << realValue.v[i];
						item->label = "max y: ";
						break;
					case 5:
						item->value << realValue.v[i];
						item->label = "max z: ";
						break;
					}
				result->items.PushBack(item);
				}
			break;
			}
		//////////////////////////////////////////////////////////////////////////	rectangle	//////////////////////////////////////////////////////////////////////////
		case vtRECTANGLE:
			{
				for (int i = 0 ; i < 4 ; i ++ )
				{
					WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();

					VxRect realValue;
					localCopy->GetValue(&realValue);
					item->widgetType = EVT_WIDGET_EDIT_TEXT;
					switch(i) 
						{
							case 0:
								item->value << realValue.left;
								item->label = "Left: ";
								break;
							case 1:
								item->value << realValue.top;
								item->label = "Top: ";
								break;
							case 2:
								item->value << realValue.right;
								item->label = "Right: ";
								break;
							case 3:
								item->value << realValue.bottom;
								item->label = "Bottom: ";
								break;
						}
					result->items.PushBack(item);
				}
				break;
			}
		//////////////////////////////////////////////////////////////////////////	vector 2	//////////////////////////////////////////////////////////////////////////
		case vtVECTOR2D:
			{
				for (int i = 0 ; i < 2 ; i ++ )
				{

					WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
					Vx2DVector VectorValue;
					localCopy->GetValue(&VectorValue);
					item->value << VectorValue[i];
					item->widgetType = EVT_WIDGET_EDIT_TEXT;
					switch(i) 
					{
						case 0:
							item->label = "x: ";
							break;
						case 1:
							item->label = "y: ";
					}
					result->items.PushBack(item);
				}
				break;
			}
		//////////////////////////////////////////////////////////////////////////	vector 3	//////////////////////////////////////////////////////////////////////////
		case vtVECTOR:
			{
				for (int i = 0 ; i < 3 ; i ++ )
				{

					WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
					VxVector VectorValue;
					localCopy->GetValue(&VectorValue);
					item->value << VectorValue[i];
					item->widgetType = EVT_WIDGET_EDIT_TEXT;

					switch(i) 
					{
						case 0:
							item->label = "x";
							break;
						case 1:
							item->label = "y";
							break;
						case 2:
							item->label = "z";
							break;
						}
					result->items.PushBack(item);
					}
				break;
			}
		//////////////////////////////////////////////////////////////////////////	vector4	//////////////////////////////////////////////////////////////////////////
		case vtQUATERNION:
			{

				for (int i = 0 ; i < 4 ; i ++ )
				{

					WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
					VxQuaternion realValue;
					localCopy->GetValue(&realValue);
					item->value << realValue[i];
					item->widgetType = EVT_WIDGET_EDIT_TEXT;
					switch(i) 
					{
						case 0:
							item->label = "x: ";
							break;
						case 1:
							item->label = "y: ";
							break;
						case 2:
							item->label = "z: ";
							break;
						case 3:
							item->label = "w: ";
							break;
					}
					result->items.PushBack(item);
				}
				break;
			}
		//////////////////////////////////////////////////////////////////////////	enumeration //////////////////////////////////////////////////////////////////////////
		case vtENUMERATION:
			{

				CKEnumStruct *enumStruct = pm->GetEnumDescByType(parameterType);
				if ( enumStruct )
				{
					for (int i = 0 ; i < enumStruct->GetNumEnums() ; i ++ )
					{
						WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
						item->value = enumStruct->GetEnumDescription(i);
						item->widgetType = EVT_WIDGET_COMBO_BOX;
						result->items.PushBack(item);
					}
				}
			break;
			}
		//////////////////////////////////////////////////////////////////////////	flags	 //////////////////////////////////////////////////////////////////////////
		case vtFLAGS:
			{
				CKFlagsStruct*flagStruct = pm->GetFlagsDescByType(parameterType);
				if ( flagStruct )
				{
					for (int i = 0 ; i < flagStruct->GetNumFlags() ; i ++ )
					{
						WidgetInfo::WidgetInfoItem *item = new WidgetInfo::WidgetInfoItem();
						item->value = flagStruct->GetFlagDescription(i);
						item->widgetType = EVT_WIDGET_CHECK_BUTTON;
						result->items.PushBack(item);
					}
				}
				break;
			}
	}
	return result;
}