3D PLM Enterprise Architecture |
User Interface - Frame |
The CAA Command ModelUnderstanding commands and how they work |
Technical Article |
AbstractThis article introduces the commands as the key objects allowing for CAA application interactivity. |
The high-level interactivity proposed by CAA requires that the basic interactive mechanisms be processed efficiently and consistently. These interactive mechanisms make it possible to:
The last two items illustrate a part of the Model View Controller (MVC) paradigm. CAA offers an object that provides these mechanisms as its behavior: the CAA command. It is the key object to make up the CAA User Interface Model interactive.
[Top]
A CAA command is an instance of a class deriving from the CATCommand class and that supports these interactive mechanisms:
[Top]
CAA commands fall into the following categories:
These dialog commands are available to the end user through menu items in the menu bar, icons or combos in toolbars, or menu items in objects' contextual menus. They are triggered thanks to a command starter that stands for the command behind the push item in the menu bar or push button featuring an icon in a toolbar. This command starter is associated with a command header that holds the command class name and the shared library or DLL containing the command executable code. As soon as the end user clicks the push item or icon, the link is made with the corresponding command starter that requests the command header to load the appropriate shared library or DLL and instantiates the command class.
These are commands that are run from their beginning to their end from a single user interaction, with no means to stop them. Their dialog is limited to selecting the push item or the icon in a toolbar that represent them, and can display a confirmation dialog before proceeding.
These are commands that appear to the end user as a dialog box. The dialog box is the command itself, rather than being part of another command. The dialog sequence is limited to entering parameter values, or selecting options, and clicking push buttons such as OK, Apply, or Cancel.
These are commands modeled as state machines. They can have several states. Each state lets the end user select objects, enter parameters, or choose options. Transitions depend on conditions set on what the end user selects, enters, or chooses. If these conditions are met, transitions trigger actions when skipping to the next state to progress to the command completion. Dialog boxes can be used to allow for parameter or option input.
[Top]
At run time, most of the CAA commands make a tree structure. Each command is
usually created with a parent command (or father command), either passed as a
parameter in the command class constructor, or using the CATCommand base class
constructor, or possibly set or reset using the CATCommand SetFather
method. This parent has itself a parent, and so on up to the root of the tree
named the command selector, a specific command that manages the availability and
life cycle of dialog commands. Commands created without a parent, that is with a
NULL parent, have automatically the command selector as parent. The figure below
is a view of a CAA session as its command tree structure.
This figure shows that:
GetApplicationDocument
method of the CATApplicationFrame
class [5].The dialog command seen by the end user and that is currently running is named the active command. It is said to have the focus, one command being active at a given instant. The command selector manages the focus and gives it to, or takes it from, the dialog commands that the end user selects.
The command tree structure is used to convey end user intents from the object that detects the event up to the object that is able to process it. This is devoted to the Send/Receive notification protocol. For example, in a dialog box, the OK push button is a command created as a child of the dialog box itself, or as one of its subcommands, such as an invisible frame that groups the OK, Apply, and Cancel push buttons. By setting a callback on the push button, the dialog box expects to catch the end user intent when the end user will click OK. The method executed when such an event occurs is a member function of the dialog box class, declared as part of the callback.
The object selected by the end user can be something else than a command. For example, in a viewer, an object representation is usually selected. In this case, a manipulator, that is another form of a command, is associated with the representation.
[Top]
The command selector manages the focus between the commands. It receives the notifications sent by commands below it to react to end user interactions that climb up along the command tree structure and that were not caught and processed by another command. It sends these notifications to the active command. To enable this management, a dialog command has a running (or start) mode. It can be set as:
Cancel
method. Use CATCommandModeExclusive
to set a command as exclusiveCATCommandModeShared
to set a command as
shared.CATCommandModeUndefined
to set a command
as undefined. Note that a state dialog command cannot be set as undefined.Exclusive: The active command is run in the exclusive mode. No other command exists on the command stack. | |
Shared: The active command is run in the shared mode. Other commands can be deactivated on the command stack If any, they are all shared commands, except the lower command that may be exclusive. |
A dialog command known by the command selector, that is created either as
exclusive or shared, is managed by the command selector using the three methods Activate
,
Desactivate
, and Cancel
. As a general rule, these
methods do the following:
Activate
is called when the dialog command takes the focus,
if it is set as an exclusive or shared command. This happens in three cases:Activate
can be used to create temporary objects that are
needed from the beginning, either because they help the end user to perform
the command, such as the outline of the created object, or a rubber band that
follows the mouse, both known as interactive objects and added to the set of
interactive objects (ISO), or construction objects that can be helpful.
Desactivate
is called when a shared command takes the focus
from the active command. The active command becomes inactive, is frozen in
its current state and put in the command stack. When the shared command will
complete, the frozen command will be reactivated from its current state
using the Activate
method. Desactivate
should hide
temporary objects created by Activate
, or by the action
methods, such as a dialog box, or temporary interactive objects that should
be removed from the ISO. Some objects should be deleted, such as the rubber
band, that will never be restored as it were since it follows the mouse.Cancel
is called when the command completes if it is a state
dialog command, or when an exclusive command takes the focus and requests
the command to be deleted. When the command completes, the focus is given to
the default command (usually Select). Cancel
must delete or
release temporary objects created by the command, possibly after having
removed them from the ISO.The following table shows a summary of when these methods are called, and what they should contain, depending on the command type and running mode.
Command Type | Possible Running Modes | Activate | Desactivate | Cancel |
---|---|---|---|---|
One shot | Exclusive | Called when the end user selects the command. Should contain the body of the command and should request the command destruction (*) when the job completes | Called when a shared command takes the focus. Should never
be called if Activate includes a request to delete the
command, since in this case, the command completes before the end user can
select another command. Otherwise, should hide its temporary objects. |
Called when an exclusive command takes the focus. Never
called if Activate includes a request to delete the command.
Otherwise, should do a clean up of the command temporary objects ans
request the command destruction (*) |
Undefined | Never called | Never called | Never called | |
Dialog box | Exclusive or Shared | Called when the end user selects the command or when the command takes the focus again after being put on the command stack by a shared command. Shows the dialog box by default. The dialog box creation should be made in the constructor. | Called when a shared command takes the focus. Hides the dialog box by default | Called when an exclusive command takes the focus. Hides the dialog box box by default. Should request its destruction (*) |
State dialog command | Exclusive or Shared | Called as soon as the end user selects the command or when the command takes the focus again after being put on the command stack by a shared command. Should not contain the body of the command, since this is the role of the BuildGraph method, but can contain the creation of interactive objects that can be useful to the command. | Called when a shared command takes the focus. Should hide its temporary objects, such as dialog boxes, and delete interactive objects | Called when an exclusive command takes the focus, or when the command completes. The command is automatically deleted |
* Requesting a command destruction is made using
the RequestDelayedDestruction
method.
[Top]
The CAA commands are key objects to provide interactivity. They can have the one-shot, dialog boxes, or state dialog command type, depending from their base class. They can run in exclusive, shared, or undefined mode depending on their type.
Most of them build a tree structure at run time, used to convey notifications
emanating from end user interactions, up to the appropriate command, that is the
command able to perform the end user intent. The command at the top of the tree
structure, named the command selector, sends orphan notifications to the active
command and manages the command focus thanks to the Activate
, Desactivate
,
and Cancel
methods that each command should override.
[Top]
Version: 1 [Nov 2001] | Document created |
[Top] |
Copyright © 2001, Dassault Systèmes. All rights reserved.