
Chapter 5: Creating an iTool 101
iTool Developer’s Guide Registering a New Tool Class
Registering a New Tool Class
Before an instance of a new iTool can be created, the tool’s class definition must be
registered with the iTool system. Registering an iTool class with the system links the
class definition file containing the actual IDL code that initializes an iTool object
with a simple string that names the iTool. Since you use the name string in code that
creates instances of individual tools, a change to the name of the class definition file
requires only a change to the code that registers the iTool class.
iTool classes are registered using the ITREGISTER procedure. In most cases, the call
to the ITREGISTER procedure will be included in an iTool’s launch routine, but the
call can take place in any code at any time. If multiple iTool launch routines create
instances of the same iTool class, however, you may find it more convenient to
register the iTool in a single routine, called only once. This removes the need to call
the registration routine in each launch routine individually.
Note
If only a small number of routines will create instances of a given iTool, you may
find it more convenient to register the iTool class within the tool launch routine.
Using ITREGISTER
Use the ITREGISTER routine to register the class definition:
ITREGISTER, '
Tool Name
', '
Tool_Class_Name
'
where Tool Name is a string you will use to create instances of the tool, and
Tool_Class_Name is a string that specifies the name of the class file that contains the
tool’s definition.
Note
The file
Tool_Class_Name
__define.pro must exist somewhere in IDL’s path
for the tool definition to be successfully registered.
If a given iTool class has already been registered when the ITREGISTER routine is
called, the class will not be registered a second time. The registration can be
performed at any time in an IDL session before you attempt to create an instance of
the iTool.
See “ITREGISTER” (IDL Reference Guide) for details.