ITT Rule IDL Version 7.0 User Manual Page 111

  • Download
  • Add to my manuals
  • Print
  • Page
    / 430
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 110
Chapter 5: Creating an iTool 111
iTool Developer’s Guide Example: Simple iTool
IF (N_ELEMENTS(data) GT 0) THEN BEGIN
oData = OBJ_NEW('IDLitDataIDLImagePixels')
result = oData->SetData(data, _EXTRA = _extra)
oParmSet->Add, oData, PARAMETER_NAME = 'ImagePixels'
; Create a default grayscale ramp.
ramp = BINDGEN(256)
oPalette = OBJ_NEW('IDLitDataIDLPalette', $
TRANSPOSE([[ramp], [ramp], [ramp]]), $
NAME = 'Palette')
oParmSet->Add, oPalette, PARAMETER_NAME = 'PALETTE'
ENDIF
ENDIF
ITREGISTER, 'Example 1 Tool', 'example1tool'
identifier = IDLITSYS_CREATETOOL('Example 1 Tool',$
VISUALIZATION_TYPE = ['Image-Contour'], $
INITIAL_DATA = oParmSet, _EXTRA = _extra, $
TITLE = 'First Example iTool')
END
Launch Routine Discussion
Our iTool launch routine accepts a single data argument. We also specify that our
launch routine should accept the IDENTIFIER keyword; we will use the variable
specified as the value of this keyword (if any) to return the iTool identifier of the new
iTool we create.
First, we check the number of non-keyword arguments that were supplied using the
N_PARAMS function. If an argument was supplied, we create an IDLitParameterSet
object to hold the data.
Next, we check to make sure the supplied data argument is not empty using the
N_ELEMENTS function. If the supplied argument contains data, we create an
IDLitDataIDLImagePixels object to contain the image data and add the object to our
parameter set object, assigning the parameter name
'ImagePixels'.
Note
In the interest of brevity, we do very little data verification in this example. We
could, for example, verify that the data argument contains a two-dimensional array
of a specified type.
Page view 110
1 2 ... 106 107 108 109 110 111 112 113 114 115 116 ... 429 430

Comments to this Manuals

No comments