deargui-vpl/ref/virtools/Samples/Behaviors/SelectionSetManager/Set_BBs.cpp

123 lines
3.1 KiB
C++

#include "StdAfx.h"
////////////////////////////////////////////////////////////////////////////////
// tool to get beh target
////////////////////////////////////////////////////////////////////////////////
/*
CKGroup* GetSetTarget(CKBehavior* beh,SelectionSetManager* setmgr,BOOL& oByName)
{
beh->GetLocalParameterValue(0,&oByName);
//get target by name
if (oByName)
{
char* name = (char*)beh->GetInputParameterReadDataPtr(0);
if (name && strlen(name)>0)
{
SelectionSetArray sets;
setmgr->GetSelectionSets(sets);
SelectionSetIT it1 = sets.Begin();
SelectionSetIT it2 = sets.End();
while (it1!=it2)
{
CKGroup* setGrp = *it1++;
CKSTRING setName = setGrp->GetName();
if (setName && stricmp(setName,name)==0)
return setGrp;
}
}
}
else
{
CKGroup* grp = (CKGroup*)beh->GetInputParameterObject(0);
if (setmgr->CheckIsSelectionSet(grp))
return grp;
}
return 0;
}
*/
////////////////////////////////////////////////////////////////////////////////
// behavior callback
////////////////////////////////////////////////////////////////////////////////
/*
CKERROR TargetableSelectionSetBBCallBack(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
switch( behcontext.CallbackMessage )
{
case CKM_BEHAVIORLOAD:
case CKM_BEHAVIORSETTINGSEDITED:
{
//change pin type according to setting
CKParameterIn* pin = beh->GetInputParameter(0);
BOOL byname=FALSE;
beh->GetLocalParameterValue(0,&byname);
BOOL change = FALSE;
if (byname && pin->GetGUID()==CKPGUID_SELECTIONSET)
{
pin->SetName(STR_SELECTIONSETNAME);
pin->SetGUID(CKPGUID_STRING);
change = TRUE;
beh->EnableOutputParameter(0,TRUE);
}
else if (!byname && pin->GetGUID()==CKPGUID_STRING)
{
pin->SetName(STR_SELECTIONSET);
pin->SetGUID(CKPGUID_SELECTIONSET);
change = TRUE;
beh->EnableOutputParameter(0,FALSE);
}
if (change)
{
CKParameter* psource = pin->GetDirectSource();
if (psource)//if source, update source type & name if possible & value
{
SelectionSetManager* setmgr = (SelectionSetManager*)behcontext.Context->GetManagerByGuid(SELECTIONSETMANAGER_GUID);
//update direct source name if names are identical
char* psourceName = psource->GetName();
if (psourceName)
{
if (stricmp(psourceName,pin->GetName())!=0)
psource->SetName(pin->GetName());
}
//get source value
CKGroup* set = 0;
if (psource->GetGUID()==CKPGUID_STRING)
{
char* setName = (char*)psource->GetReadDataPtr();
set = setmgr->GetSelectionSetByName(setName);
}
else if (psource->GetGUID()==CKPGUID_GROUP)
{
set = (CKGroup*)psource->GetValueObject();
}
if (!CKIsChildClassOf(set,CKCID_GROUP))
set = 0;
//update source guid
psource->SetGUID(pin->GetGUID());
//update source value
if (psource->GetGUID()==CKPGUID_STRING)
{
if (set)
psource->SetValue(set->GetName());
}
else if (psource->GetGUID()==CKPGUID_GROUP)
{
if (set)
{
CK_ID id = set->GetID();
psource->SetValue(&id);
}
}
}
}
}
break;
}
return CKBR_OK;
}
*/