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

141 lines
4.0 KiB
C++

#include "StdAfx.h"
////////////////////////////////////////////////////////////////////////////////
// functions prototypes
////////////////////////////////////////////////////////////////////////////////
CKERROR CreateSaveSelectionSetProto(CKBehaviorPrototype **pproto);
int SaveSelectionSetBB(const CKBehaviorContext& behcontext);
CKERROR SaveSelectionSetBBCallBack(const CKBehaviorContext& behcontext);
////////////////////////////////////////////////////////////////////////////////
// enums
////////////////////////////////////////////////////////////////////////////////
enum INS
{
eINS_IN,
};
enum OUTS
{
eOUTS_SUCCESS,
eOUTS_FAILED,
};
enum PINS
{
ePINS_NAME,
};
enum POUTS
{
ePOUTS_GROUP,
};
enum PSETTINGS
{
//ePSETTINGS_TARGETBYNAME, //use group instead of name
};
////////////////////////////////////////////////////////////////////////////////
// behavior
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
CKObjectDeclaration* FillBehaviorSaveSelectionSet()
{
CKObjectDeclaration *od = CreateCKObjectDeclaration(NAME_SAVESELECTIONSET);
od->SetDescription("Save a Selection Set.");
/* rem:
<SPAN CLASS=in>On : </SPAN>Activates the Progression Bar.<BR>
<SPAN CLASS=in>Off : </SPAN>Deactivates the Progression Bar.<BR>
<SPAN CLASS=in>Pause/Resume : </SPAN>Pause/Resume the Progression Bar.<BR>
<BR>
<SPAN CLASS=out>Exit On : </SPAN>This output is activated after entering by 'On'.<BR>
<SPAN CLASS=out>Exit Off : </SPAN>This output is activated after entering by 'Off'.<BR>
<SPAN CLASS=out>Exit Off : </SPAN>This output is activated after entering by 'Pause/Resume'.<BR>
<BR>
<SPAN CLASS=setting>Size Mode : </SPAN> - <BR>
<SPAN CLASS=setting>Orientation : </SPAN> - <BR>
<BR>
*/
/* Note:
Activate the "on" entry each time the target of the behavior is modified.
*/
od->SetType( CKDLL_BEHAVIORPROTOTYPE);
od->SetGuid(BBGUID_SAVESELECTIONSET);
od->SetAuthorGuid(VIRTOOLS_GUID);
od->SetAuthorName("Virtools");
od->SetVersion(0x00010000);
od->SetCreationFunction(CreateSaveSelectionSetProto);
od->SetCompatibleClassId(CKCID_BEOBJECT);
od->SetCategory("Selection Set");
return od;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
CKERROR CreateSaveSelectionSetProto(CKBehaviorPrototype **pproto)
{
CKBehaviorPrototype *proto = CreateCKBehaviorPrototype(NAME_SAVESELECTIONSET);
if(!proto) return CKERR_OUTOFMEMORY;
proto->DeclareInput("Save");
proto->DeclareOutput("Success");
proto->DeclareOutput("Failed");
proto->DeclareInParameter(STR_SELECTIONSET, CKPGUID_SELECTIONSET,0);
proto->DeclareOutParameter("Group",CKPGUID_GROUP,0);
//proto->DeclareSetting(STR_BYNAME,CKPGUID_BOOL,FALSE);
proto->SetFunction(SaveSelectionSetBB);
proto->SetBehaviorCallbackFct(TargetableSelectionSetBBCallBack);
proto->SetBehaviorFlags(BBFLAGS);
*pproto = proto;
return CK_OK;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
int SaveSelectionSetBB(const CKBehaviorContext& behcontext)
{
#ifdef VIRTOOLS_RUNTIME_VERSION
CKBehavior* beh = behcontext.Behavior;
if(beh->IsInputActive(eINS_IN))
{
beh->ActivateOutput(eOUTS_FAILED);
}
return CKBR_OK;
#else
CKBehavior* beh = behcontext.Behavior;
SelectionSetManager* setmgr = (SelectionSetManager*)behcontext.Context->GetManagerByGuid(SELECTIONSETMANAGER_GUID);
if(beh->IsInputActive(eINS_IN))
{
//BOOL byname=FALSE;
CKGroup* set = 0;
if (set = GetSetTarget())//(beh,setmgr,byname))
{
if (setmgr->SaveSelectionSet(set,FALSE))
beh->ActivateOutput(eOUTS_SUCCESS);
else
beh->ActivateOutput(eOUTS_FAILED);
}
else
beh->ActivateOutput(eOUTS_FAILED);
beh->SetOutputParameterObject(ePOUTS_GROUP,set);
}
return CKBR_OK;
#endif
}