ITT Rule IDL Version 7.0 User Manual Page 249

  • Download
  • Add to my manuals
  • Print
  • Page
    / 430
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 248
Chapter 9: Creating a File Reader 249
iTool Developer’s Guide Example: TIFF File Reader
Init Method
FUNCTION example1_readtiff::Init, _REF_EXTRA = _extra
; Call the superclass Init method
IF (self->IDLitReader::Init(["tiff", "tif"],$
NAME="Tiff Files", $
DESCRIPTION="TIFF File format", $
_EXTRA = _extra) NE 1) THEN $
RETURN, 0
; Initialize the instance data field
self._index = 0
; Register the index property
self->RegisterProperty, 'IMAGE_INDEX', /INTEGER, $
Description='Index of the image to read from the TIFF file.'
RETURN,1
END
Discussion
The first item in our class definition file is the Init method. The Init method’s
function signature is defined first, using the class name example1_readtiff. The
_REF_EXTRA keyword inheritance mechanism allows any keywords specified in a
call to the Init method to be passed through to routines that are called within the Init
method even if we do not know the names of those keywords in advance.
Next, we call the Init method of the superclass. In this case, we are creating a subclass
of the IDLitReader class; this provides us with all of the standard iTool file reader
functionality automatically. Any “extra” keywords specified in the call to our Init
method are passed to the IDLitReader::Init method via the keyword inheritance
mechanism.
We specify a list of accepted filename extensions (
tiff and tif, in this case) via the
Extensions argument. We specify a value for the NAME property of the reader object
(this is displayed in the system preferences dialog) and include a description of the
reader via the DESCRIPTION keyword. Finally, we use the _EXTRA keyword
inheritance mechanism to pass through any keywords provided when the Init method
is called.
Our TIFF reader object has a single instance data field: _index, which is used to store
the index number of the image to read from a multi-image TIFF file. We initialize
this instance data field to 0, and register the IMAGE_INDEX property to provide
access to this field via the property sheet interface.
Page view 248
1 2 ... 244 245 246 247 248 249 250 251 252 253 254 ... 429 430

Comments to this Manuals

No comments