user manual
Chapter 5: Creating an iTool 93
iTool Developer’s Guide Creating a New iTool Class
name should be the same as the iTool’s class name — in this case,
FirstExampleTool.
Like many iTools,
FirstExampleTool is created as a subclass of the
IDLitToolbase class. iTools that subclass from IDLitToolbase inherit all of the
standard iTool functionality, as described in “Subclassing from the IDLitToolbase
Class” on page 91.
Note
This example is intended to demonstrate how simple it can be to create a new iTool
class definition. While the class definition for an iTool with significant extra
functionality will likely define additional structure fields, and may inherit from
other iTool classes, the basic principles are the same.
Creating an Init Method
The iTool class Init method handles any initialization required by the iTool object,
and should do the following:
• define the Init function method, using the keyword inheritance mechanism to
handle “extra” keywords
• call the Init methods of any superclasses, using the keyword inheritance
mechanism to pass “extra” keywords
• register visualizations, operations, manipulators, and file readers/writers
available in the new iTool but not registered by any superclasses
• perform other initialization steps as necessary
• return the value 1 if the initialization steps are successful, or 0 otherwise
Definition of the Init Function
Begin by defining the argument and keyword list for your Init method. The argument
and keyword list defines positional parameters (arguments) accepted by your method,
defines any keywords that will be handled directly by your method, and specifies that
keywords not explicitly handled by your method will be passed through to other
routines called by your method via IDL’s keyword inheritance mechanism. The Init
method for a tool generally looks something like this:
FUNCTION
MyTool
::Init,
MYKEYWORD1
= mykeyword1, $
MYKEYWORD2
= mykeyword2, ..., _REF_EXTRA = _extra
where MyTool is the name of your tool class and the MYKEYWORD parameters are
keywords handled explicitly by your Init function.