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

123 lines
3.7 KiB
C++

#include "StdAfx.h"
////////////////////////////////////////////////////////////////////////////////
// functions prototypes
////////////////////////////////////////////////////////////////////////////////
CKERROR CreateDeleteSelectionSetProto(CKBehaviorPrototype **pproto);
int DeleteSelectionSetBB(const CKBehaviorContext& behcontext);
CKERROR DeleteSelectionSetBBCallBack(const CKBehaviorContext& behcontext);
////////////////////////////////////////////////////////////////////////////////
// enums
////////////////////////////////////////////////////////////////////////////////
enum INS
{
eINS_IN,
};
enum OUTS
{
eOUTS_SUCCESS,
eOUTS_FAILED,
};
enum PINS
{
ePINS_NAME,
};
enum PSETTINGS
{
//ePSETTINGS_TARGETBYNAME, //use group instead of name
};
////////////////////////////////////////////////////////////////////////////////
// behavior
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
CKObjectDeclaration* FillBehaviorDeleteSelectionSet()
{
CKObjectDeclaration *od = CreateCKObjectDeclaration(NAME_DELETESELECTIONSET);
od->SetDescription("Delete 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_DELETESELECTIONSET);
od->SetAuthorGuid(VIRTOOLS_GUID);
od->SetAuthorName("Virtools");
od->SetVersion(0x00010000);
od->SetCreationFunction(CreateDeleteSelectionSetProto);
od->SetCompatibleClassId(CKCID_BEOBJECT);
od->SetCategory("Selection Set");
return od;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
CKERROR CreateDeleteSelectionSetProto(CKBehaviorPrototype **pproto)
{
CKBehaviorPrototype *proto = CreateCKBehaviorPrototype(NAME_DELETESELECTIONSET);
if(!proto) return CKERR_OUTOFMEMORY;
proto->DeclareInput("Delete");
proto->DeclareOutput("Success");
proto->DeclareOutput("Failed");
proto->DeclareInParameter(STR_SELECTIONSET, CKPGUID_SELECTIONSET,0);
//proto->DeclareSetting(STR_BYNAME,CKPGUID_BOOL,FALSE);
proto->SetFunction(DeleteSelectionSetBB);
proto->SetBehaviorCallbackFct(TargetableSelectionSetBBCallBack);
proto->SetBehaviorFlags(BBFLAGS);
*pproto = proto;
return CK_OK;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
int DeleteSelectionSetBB(const CKBehaviorContext& behcontext)
{
CKBehavior* beh = behcontext.Behavior;
SelectionSetManager* setmgr = (SelectionSetManager*)behcontext.Context->GetManagerByGuid(SELECTIONSETMANAGER_GUID);
if(beh->IsInputActive(eINS_IN))
{
//BOOL byname=FALSE;
if (CKGroup* set = GetSetTarget())//(beh,setmgr,byname)
{
SelectionSetArray list(1);
list.PushBack(set);
if (setmgr->UnloadSets(list,TRUE))
beh->ActivateOutput(eOUTS_SUCCESS);
else
beh->ActivateOutput(eOUTS_FAILED);
}
else
beh->ActivateOutput(eOUTS_FAILED);
}
return CKBR_OK;
}