A SERVICE OF

logo

174 Chapter 7: Creating an Operation
Creating a New Generalized Operation iTool Developer’s Guide
END
Discussion
The ExampleOp operation DoAction method does the following things:
1. Checks the validity of the iTool object passed to the DoAction method.
2. Retrieves the list of selected objects from the iTool object.
3. Filters out any selected objects that are not IDLitVisSurface objects.
4. Calls the superclass DoAction method to create an IDLitCommandSet object.
5. Calls the RecordInitialValues method to record the relevant values in the
command set object before the operation is performed.
6. Loops through the list of IDLitVisSurface objects and increments the STYLE
property of each by 1.
7. Calls the RecordFinalValues method to record the relevant values in the
command set object after the operation has been performed.
8. Returns the command set object.
Creating a RecordInitialValues Method
The operation class RecordInitialValues method is responsible for recording the
appropriate “before” values from the specified objects in the provided
IDLitCommandSet object. The values recorded depend entirely on the operation
being performed.
Example RecordInitialValues Method
The following example code shows a simple RecordInitialValues method for the
ExampleOp operation. An IDLitCommand object is created for each of the target
objects, and the value of the STYLE property of each object is recorded as an Item in
the command object.
FUNCTION ExampleOp::RecordInitialValues, oCmdSet, oTargets, idProp
; Loop through the target objects and record the value of the
; STYLE property.
FOR i = 0, N_ELEMENTS(oTargets)-1 DO BEGIN
; Create a command object to store the values.
oCmd = OBJ_NEW('IDLitCommand', $
TARGET_IDENTIFIER = oTargets[i]->GetFullIdentifier())
; Get the value of the STYLE property