user manual

Chapter 5: Creating an iTool 99
iTool Developer’s Guide Creating a New iTool Class
specifies the file writer.bmp located in the home/mydir directory as the icon to
use on the toolbar.
self->RegisterFileReader, 'myWriter', 'myFileWriter', $
ICON = '/home/mydir/writer.bmp'
See “Registering a File Writer” on page 269 for additional details. See Predefined
iTool File Writers” on page 255 for a list of file writers included in the iTool system
as installed with IDL.
Example Init Method
The following example code shows a very simple Init method for an iTool named
FirstExampleTool. This function should be included in a file named
FirstExampleTool__define.pro.
FUNCTION FirstExampleTool::Init, _REF_EXTRA = _extra
; Call the Init method of the super class.
IF (self->IDLitToolbase::Init(NAME='FirstExampleTool', $
DESCRIPTION = 'Example Tool Class', _EXTRA = _extra) EQ 0) THEN
$
RETURN, 0
; Register a visualization
self->RegisterVisualization, 'Image', 'IDLitVisImage', $
ICON = 'image'
; Register an operation
self->RegisterOperation, 'Byte Scale', 'IDLitOpBytScl', $
IDENTIFIER = 'Operations/Byte Scale'
RETURN, 1
END
Discussion
The
FirstExampleTool is based on the IDLitToolbase class (discussed in
“Subclassing from the IDLitToolbase Class” on page 91). As a result, all of the
standard iTool operations, manipulators, file readers and writers are already present.
The
FirstExampleTool Init method needs to do only three things:
1. Call the Init method of the superclass, IDLitToolbase, using the _EXTRA
keyword inheritance mechanism to pass through any keywords provided when
the
FirstExampleTool Init method is called.