Object Examples
We have included a number of examples of object-oriented programming as part of the IDL distribution. Many of the examples used in this volume are included —sometimes in expanded form — in the examples/doc/objects subdirectory of the IDL distribution. By default, this directory is part of IDL's path; if you have not changed your path, you will be able to run the examples as described here. See "!PATH" (IDL Reference Guide) for information on IDL's path.
Also see the iTool Programming for additional examples of creating custom objects including file reader and writers, manipulators, and operators that can be used within a custom iTool.
Creating Composite Classes or Subclasses
IDL includes a rich set of basic objects that an be used for creating visualizations. You may find that you are using a certain combination of these objects again and again within your applications for a particular purpose. If this is the case, you might want to consider defining a composite object class that encapsulates the combination of those subcomponents.
IDL includes several such composite classes, such as the IDLgrColorbar and IDLgrLegend object. You will find the IDL code for these objects in the lib directory of your IDL distribution.
Example Code
Another example can be found in the idlexshow3__define.pro in the examples/doc/utilities subdirectory. In this case, an image, surface, and contour representation are combined into a single object called the IDLexShow3 object. To see this object being used in an application, run the show3_track routine, defined in the file show3_track.pro in the examples/doc/objects directory.
The program show3_track.pro creates the following visualization:
You may also find that you want to customize one or more of the classes available in Object Graphics. For instance, you may want to create a specialized image object that can handle 16-bit palettes.
Example Code
An example that creates a specialized image object that can handle 16-bit palettes is provided in idlexpalimage__define.pro in the examples/doc/utilities subdirectory of the IDL distribution. Run the example procedure by entering idlexpalimage__define at the IDL command prompt or view the file in an IDL Editor window by entering .EDIT idlexpalimage__define.pro.
