3D PLM Enterprise Architecture |
User Interface - Commands |
Managing Multi-SelectionRetrieving existing objects from mouse click or trap selection |
Use Case |
AbstractThis article details the multi-selection in a state command class. |
The goal of this article is to show and explain the several ways to select a set of objects in a CATStateCommand command. The selection is possible by using a CATPathElementAgent object. This object is a CATDialogAgent whose the behaviors to enable the multi selection are the following:
Accepts indication or multi-selection with a polygon trap without an user interface.
Accepts indication or multi-selection, with the help of an user interface. The end user can select the selection mode. Triggered as soon as a selection is performed.
Accepts indication or multi-selection, with the help of an user interface. The end user can select the selection mode. Triggered as soon as the end user validates the selection.
Accepts indication or multi-selection, with the help of an user interface. Triggered as soon as a selection is performed unless the end user toggle to the CATDlgEngMultiAcquisitionCtrl behavior thanks to the user interface.
This use case shows the usage of the last three behaviors.
[Top]
The Numeric command is a use case of the CAADialogEngine.edu framework that illustrates the DialogEngine framework capabilities.
[Top]
The CAADegAnalysisNumericCmd is a state dialog command which uses three CATPathElementAgent: One for each behavior to test. Its UML statechart diagram [1] is the following:
![]() |
The dialog is as follows:
Select the Numeric command in the Mathematical Analysis toolbar of the
"CAA V5: Geometrical Analysis" workbench. The active state becomes stChoiceBehaviorState.
The "Agent Behavior Choice" dialog box appears: [Fig.2]
![]() |
If the end user clicks Ok, the current state becomes:
StMultiAcquisitionSelModesState
, if the first radio button is
selectedStMultiAcquisitionStateCtrl
, if the second radio button is
selectedStMultiAcquisitionStateUserCtrl
, if the last radio button is
selectedIf the end user clicks the Cancel button or closes the "Agent Behavior Choice" dialog box, the active state becomes the NULL state. The command is canceled.
The end user has chosen the first behavior, CATDlgEngMultiAcquisitionSelModes
,
so the active state is StMultiAcquisitionStateSelModes
. The
"Tools Palette" toolbar appears with a set of selection modes as
follows:
After the selection, the current state becomes StEndChoiceState
.
The end user has chosen the second behavior, CATDlgEndMultiAcquisitionCtrl
,
so the active state is StMultiAcquisitionCtrlState
. The "Tools
Palette" toolbar appears as follows:
![]() |
The Tools Palette contains:
Notice that you can always also use the Search command to fill the CATPathElementAgent.
otherwise the count of selected elements is displayed
In using the Ctrl key, you can de-select an element already selected or add a new element in the current selection.
The end user has chosen the third and last behavior, CATDlgEngMultiAcquisitionUserCtrl
,
so the active state is StMultiAcquisitionUserCtrlState
. The
"Tools Palette" toolbar appears as follows:
![]() |
Tools Palette contains:
Notice that you have always the possibility to use the Search command to fill the CATPathElementAgent
CATDlgEndMultiAcquisitionCtrl
behavior otherwise the agent
is valuated after the first multi-selection or indication. If the end user pushes the "Control Mode" button the "Selection" editor, the "List Of Selected Item" and "Finish" buttons are available.
The active state is StEndChoiceState
.
The end user has finished the selection. The count by type of selected elements
are displayed in the "Count of Selected Element" dialog box:
![]() |
![]() |
If the end user clicks the Close button, the Numeric command is canceled.
[Top]
See the section entitled "How to Launch the CAAGeometry Use Case" in the "The CAAGeometry Sample" use case for a detailed description of how this use case should be launched.
Then, in the window where you run the mkrun command, do not type the module name on the command line, but type CNEXT instead. When the application is ready, do the following:
[Top]
The Numeric command is made of three classes:
located in the CAADegGeoCommands.m module of the CAADialogEngine.edu framework:
Windows | InstallRootDirectory\CAADialogEngine.edu\CAADegGeoCommands.m\ |
Unix | InstallRootDirectory/CAADialogEngine.edu/CAADegGeoCommands.m/ |
where InstallRootDirectory
is the directory where the CAA CD-ROM
is installed.
[Top]
There is five logical steps:
[Top]
The state command class derives from CATStateCommand.
class CAADegCreateNumericCmd : public CATStateCommand { ... private : CATPathElementAgent * _daMultiAcquisitionSelModes ; CATPathElementAgent * _daMultiAcquisitionCtrl ; CATPathElementAgent * _daMultiAcquisitionUserCtrl ; ... |
A pointer for each selection agent is declared as a private data member. Selection agents are instances of the CATPathElementAgent class.
_daMultiAcquisitionSelModes
will be used for the CATDlgEngMultiAcquisitionSelModes
behavior,
_daMultiAcquisitionCtrl
for the CATDlgEngMultiAcquisitionCtrl
behavior
and CATDlgEngMultiAcquisitionUserCtrl
behavior.
[Top]
The selection agents are instantiated in the command BuildGraph
method.
For the _daMultiAcquisitionSelModes
agent,
void CAADegCreateNumericCmd::BuildGraph() { ... _daMultiAcquisitionSelModes = new CATPathElementAgent("PathEltMultiAcquisitionSelModes"); _daMultiAcquisitionSelModes ->SetBehavior( CATDlgEngWithPSOHSO |CATDlgEngWithPrevaluation CATDlgEngMultiAcquisitionSelModes ); _daMultiAcquisitionSelModes ->AddElementType(IID_CAAISysPoint); _daMultiAcquisitionSelModes ->AddElementType(IID_CAAISysLine); _daMultiAcquisitionSelModes ->AddElementType(IID_CAAISysEllipse); _daMultiAcquisitionSelModes ->AddElementType(IID_CAAISysCircle); _daMultiAcquisitionSelModes ->AddElementType(IID_CAAISysPlane); ... |
The character string PathEltMultiAcquisitionSelModes
defined as
the argument of the CATPathElementAgent constructor is the selection
agent identifier. This identifier can be used to assign undo/redo prompts
replacing the Undo and Redo items in the Edit menu. To affect a specific
behavior to the CATPathElementAgent object, use the SetBehavior
method.
The CATDlgEngWithPSOHSO
and CATDlgEngWithPrevaluation
styles enables to pre-highlight the available elements and to highlight the
selected elements. The CATDlgEngMultiAcquisitionSelModes
indicates
a multi-selection. At last, thanks to the AddElementType
method,
the selection agent is valued only when an object that implements one of these
five interfaces is selected. The selection agent remains impassive when any
object that doesn't implement this interface is selected.
For the _daMultiAcquisitionCtrl
agent, only the behavior
changes:
... _daMultiAcquisitionCtrl = new CATPathElementAgent("PathEltMultiAcquisitionCtrl"); _daMultiAcquisitionCtrl->SetBehavior( CATDlgEngWithPSOHSO | CATDlgEngWithPrevaluation CATDlgEngMultiAcquisitionCtrl ); _daMultiAcquisitionCtrl->AddElementType(IID_CAAISysPoint); _daMultiAcquisitionCtrl->AddElementType(IID_CAAISysLine); _daMultiAcquisitionCtrl->AddElementType(IID_CAAISysEllipse); _daMultiAcquisitionCtrl->AddElementType(IID_CAAISysCircle); _daMultiAcquisitionCtrl->AddElementType(IID_CAAISysPlane); ... |
And for the _daMultiAcquisitionUserCtrl
agent :
... _daMultiAcquisitionUserCtrl = new CATPathElementAgent("PathEltMultiAcquisitionUserCtrl"); _daMultiAcquisitionUserCtrl ->SetBehavior( CATDlgEngWithPSOHSO | CATDlgEngWithPrevaluation CATDlgEngMultiAcquisitionUserCtrl ); _daMultiAcquisitionUserCtrl ->AddElementType(IID_CAAISysPoint); _daMultiAcquisitionUserCtrl ->AddElementType(IID_CAAISysLine); _daMultiAcquisitionUserCtrl ->AddElementType(IID_CAAISysEllipse); _daMultiAcquisitionUserCtrl ->AddElementType(IID_CAAISysCircle); _daMultiAcquisitionUserCtrl ->AddElementType(IID_CAAISysPlane); ... |
[Top]
After the agent's creation, the states are created and the agents are associated with them.
... CATDialogState *stMultiAcquisitionSelModesState = AddDialogState("stMultiAcquisitionSelModesStateId"); stMultiAcquisitionSelModesStateId->AddDialogAgent(_daMultiAcquisitionSelModes); ... CATDialogState *stMultiAcquisitionCtrlState = AddDialogState("stMultiAcquisitionCtrlStateId"); stMultiAcquisitionCtrlState->AddDialogAgent(_daMultiAcquisitionCtrl); ... CATDialogState *stMultiAcquisitionUserCtrlState = AddDialogState("stMultiAcquisitionUserCtrlStateId"); stMultiAcquisitionUserCtrlState->AddDialogAgent(_daMultiAcquisitionUserCtrl); ... |
The AddDialogState
method creates a new dialog state and adds it
to the states managed by the dialog command. The AddDialogAgent
method adds the selection agent to the state. stMultiAcquisitionSelModesStateId,
stMultiAcquisitionCtrlStateId
and stMultiAcquisitionUserCtrlStateId
are identifiers used to set a prompt displayed in the status bar when the state
is active.
At last, the transitions are created:
... CATDialogTransition *pTransition32 = AddTransition ( stMultiAcquisitionSelModesState, stEndState, IsOutputSetCondition(_daMultiAcquisitionSelModes), Action((ActionMethod) & CAADegAnalysisNumericCmd::DisplaySelectedElement,NULL,NULL,(void*)1) ) ; ... CATDialogTransition *pTransition42 = AddTransition ( stMultiAcquisitionCtrlState, stEndState, IsOutputSetCondition(_daMultiAcquisitionCtrl), Action((ActionMethod) & CAADegAnalysisNumericCmd::DisplaySelectedElement,NULL,NULL,(void*)2) ) ; ... CATDialogTransition *pTransition52 = AddTransition ( stMultiAcquisitionUserCtrlState, stEndState, IsOutputSetCondition(_daMultiAcquisitionUserCtrl), Action((ActionMethod) & CAADegAnalysisNumericCmd::DisplaySelectedElement,NULL,NULL,(void*)3) ) ; ... |
In the DisplaySelectedElement
Action method, executed
when the transitions, defined in the previous step, are triggered. iData
is the value set in the transition.
CATBoolean CAADegAnalysisNumericCmd::DisplaySelectedElement(void * iData) { int CaseAgent = (int ) iData ; ... CATSO * pSO = NULL ; if ( 1 == CaseAgent ) pSO = _daMultiAcquisitionSelModes->GetListOfValues(); if ( 2 == CaseAgent ) pSO = _daMultiAcquisitionCtrl->GetListOfValues(); if ( 3 == CaseAgent ) pSO = _daMultiAcquisitionUserCtrl->GetListOfValues(); if ( NULL != pSO ) { int lg = pSO->GetSize(); for ( int i=0 ; i < lg ; i++) { CATPathElement * pPath = (CATPathElement*) (*pSO)[i] ; ... } |
To retrieve the selected element use the GetListOfValues
method
on the current agent. The list is a CATSO object.
[Top]
A pointer to each selection agent was created in the command BuildGraph
method as a data member to be accessed and used in different methods. It
should be released when it becomes useless. This can be done in the command
destructor, as shown here. This could also be done in the Cancel
method called just before the destructor.
CAADegCreateNumericCmd::~CAADegCreateNumericCmd() { ... if ( NULL != _daMultiAcquisitionSelModes ) { _daMultiAcquisitionSelModes -> RequestDelayedDestruction() ; _daMultiAcquisitionSelModes = NULL ; } if ( NULL != _daMultiAcquisitionCtrl ) { _daMultiAcquisitionCtrl -> RequestDelayedDestruction() ; _daMultiAcquisitionCtrl = NULL ; } if ( NULL != _daMultiAcquisitionUserCtrl ) { _daMultiAcquisitionUserCtrl -> RequestDelayedDestruction() ; _daMultiAcquisitionUserCtrl = NULL ; } ... |
[Top]
This use case shows how to use a CATPathElementAgent to have multi-selection in a CATStateCommand.
[Top]
[1] | Describing State Dialog Commands Using UML |
[Top] |
Version: 1 [Sep 2002] | Document created |
Version: 2 [Nov 2002] | Document updated for new selection modes |
Version: 3 [May 2003] | Document updated for new behaviors and Tools Palette introduction |
[Top] |
Copyright © 2002, Dassault Systèmes. All rights reserved.