|
iTool Programming: Creating a Manipulator |
|
The following example creates a custom manipulator that allows you to interactively change the palette applied to a single-plane image. After activating the manipulator by selecting the Color Table tool icon on the toolbar, position the cursor over the image and with the mouse button held down, move the mouse to the right or left to change the palette.
| Example Code The class definition code for this example iTool is included in the file example3tool__define.pro in the examples/doc/itools subdirectory of the IDL distribution. Enter example3tool at the IDL prompt to create an instance of the iTool. Open the file in any text editor or enter.edit example3tool at the IDLDE prompt to open the .pro file in the IDL editor. |
A segment of the tool created in this example is shown in the following figure.
![]() |
This example creates three files:
example3_manippalette__define.pro) – defines the characteristics and actions of the manipulator in response to mouse and keyboard events. See Color Table Manipulator Class Definition
example3tool__define.pro) – defines this tool's inheritance of the IDLitToolImage tool and registers the custom manipulator. See Custom Tool Class Definition for the Color Table Manipulator.
example3tool.pro) – accepts and initializes any image arguments by creating the necessary data and adding it to the tool's parameter set. The launch routine registers the tool using ITREGISTER and then creates an instance of the tool using IDLITSYS_CREATETOOL function. See Tool Launch Routine for Custom Color Table Manipulator. Once you have created and compiled the necessary files, see Running the Color Table Manipulator Example for instructions on how to recreate the display shown in the previous figure.
Define the color table manipulator (example3_manippalette__define.pro). This class definition file initializes the manipulator, creates a cursor, and defines the manipulator actions in response to mouse and keyboard events.
| Example Code The class definition code for this example manipulator is included in the file example3_manippalette__define.pro in the examples/doc/itools subdirectory of the IDL distribution. Enterat the IDL prompt to create an instance of the iTool. Open the file in any text editor or enter at the IDLDE prompt to open the manipulator .pro file in the IDL editor. |
Create the class definition for the tool containing the custom manipulator (example3tool__define.pro). This example inherits the IDLitToolImage class functionality. In the tool initialization, register the custom manipulator. The DESCRIPTION string appears in the status area when the manipulator is activated.
| Example Code The class definition code for this example tool is included in the file example3tool__define.pro in the examples/doc/itools subdirectory of the IDL distribution. Enterat the IDL prompt to create an instance of the iTool. Open the file in any text editor or enter at the IDLDE prompt to open the .pro file in the IDL editor. |
Create a launch routine (example3tool.pro) for the tool containing the custom color table manipulator. Create an IDLImagePixels type of IDLitData object if the user initializes the tool with a data argument.
| Example Code The class definition code for this example manipulator is included in the file example3_manippalette__define.pro in the examples/doc/itools subdirectory of the IDL distribution. Enterat the IDL prompt to create an instance of the iTool. Open the file in any text editor or enter at the IDLDE prompt to open the .pro file in the IDL editor. |
Save and compile all of the files. Enter the following at the command line to reproduce the display shown in Example: Color Table Manipulator.
ctboneFile = FILEPATH('ctbone157.jpg', $
SUBDIRECTORY = ['examples', 'data'])
READ_JPEG, ctboneFile, ctboneImg
; Launch the example tool with the input data.
example3tool, ctboneImg
Select the Color Table tool on the toolbar and move the cursor over the image. Hold down the left-mouse button and drag the cursor to the right and left to scroll through the available color tables. You can also use the right and left arrow keys to modify the color table value.
IDL Online Help (March 06, 2007)