user manual

172 Chapter 7: Creating an Operation
Creating a New Generalized Operation iTool Developers Guide
Discussion
Since our operation does not have any instance data of its own, the Cleanup method
simply calls the superclass Cleanup method.
Creating a DoAction Method
The operation class DoAction method is called by the iTool system when an
operation is requested by the user. (Note that data-centric operations do not need to
implement the DoAction method because it is implemented by the
IDLitDataOperation class itself.) The DoAction method is responsible for the
following:
determining which objects the operation should be applied to (generally, but
not always, the objects that are selected when the operation is invoked)
retrieving the data from the selected objects
creating an IDLitCommandSet object that will contain undo/redo data
saving the state of the selected objects before the actions associated with the
operation are performed in the command set object
performing the requested actions on the selected objects
saving the state of the selected objects after the actions associated with the
operation are performed in the command set object
returning the command set object
Note
If your operation changes the values of its own registered properties (as the result of
user interaction with a dialog or other interface element called by DoUIService, for
example), be sure to call the RecordInitialValues and RecordFinalValues methods.
This ensures that changes made through the dialog are placed in the undo-redo
transaction buffer.
Example DoAction Method
The following example code shows a simple DoAction method for the ExampleOp
operation. This operation retrieves the STYLE property of any selected
IDLitVisSurface objects and increments its value by 1. Repeated invocations of this
operation would cause the selected surfaces to loop through the seven available
surface styles.
FUNCTION ExampleOp::DoAction, oTool