
160 Chapter 7: Creating an Operation
Creating a New Data-Centric Operation iTool Developer’s Guide
our ExampleDataOp operation works on image data, this means the operation has the
effect of producing the negative image.
FUNCTION ExampleDataOp::Execute, data
; If byte data then offsets are 0 and 255, otherwise
; use data minimum and maximum.
offsetMax = (SIZE(data, /TYPE) eq 1) ? 255b : MAX(data)
offsetMin = (SIZE(data, /TYPE) eq 1) ? 0b : MIN(data)
data = offsetMax - TEMPORARY(data) + offsetMin
RETURN, 1
END
Discussion
When our
ExampleDataOp operation is invoked by a user, the iTool system
automatically checks to see which items are selected in the visualization window. For
each selection, the iTool system extracts any data of type IDLIMAGE and passes that
data to the Execute method as an IDL array. Our Execute method then finds the
minimum and maximum values, and inverts the data values.
Creating a DoExecuteUI Method
Suppose we want to collect some information from the user before executing our
operation. If the operation class sets the SHOW_EXECUTION_UI property, the
iTool system will call the DoExecuteUI method before calling the Execute method.
The DoExecuteUI method is responsible for displaying a user interface that collects
the appropriate information and storing that information in properties of the operation
object.
Note
iTools provided with IDL that need to collect user input in this manner use the
UI service mechanism, described in Chapter 11, “iTool User Interface
Architecture”. While it is possible for the DoExecuteUI method to perform all the
necessary functions directly, using a UI service is the preferred method.
Two predefined user interface services are provided for use in DoExecuteUI
methods:
• The PropertySheet UI service displays the operation’s property sheet before
execution.