All Object Graphics applications require at least two basic building blocks. These include:

  • A destination object - the device (such as a window, memory buffer, file, clipboard, or printer) to which the visualization is to be rendered.
  • A view object - the viewport rectangle (within the destination) within which the rendering is to appear (as well as how data should be projected into that rectangle).

For example:

; Create a destination object, in this case a window:
oWindow = OBJ_NEW('IDLgrWindow')
; Create a viewport that fills the entire window:
oView = OBJ_NEW('IDLgrView')
; Draw the view within the window:
OWindow->Draw, oView

By themselves, a window and a single view are not particularly enlightening, but you will find that these two types of objects are utilized by all Object Graphics applications. To change an attribute of an object, you do not have to create a new instance of that object. Instead, use the SetProperty method on the original object to modify the value of the attribute.

For example, to change the color of the view to gray:

; Set the color property of the view:
OView->SetProperty, COLOR=[60,60,60]
; Redraw:
OWindow->Draw, oView

If more than one view is to be drawn to the destination, then an additional object is required:

  • A scene object - a container of views

For example:

; Create a scene and add our original view to it:
OScene = OBJ_NEW(’IDLgrScene’)
oScene->Add, oView
; Modify our original view so that it covers
; the upper left quadrant of the window.
OView->SetProperty, LOCATION=[0.0,0.5], DIMENSIONS=[0.5,0.5], $
   UNITS=3
; Create and add a second red view that covers
; the right half of the window.
OView2 = OBJ_NEW(’IDLgrView’, LOCATION=[0.5,0.0], $
   DIMENSIONS=[0.5,1.0], UNITS=3,COLOR=[255,0,0])
OScene->Add, oView2
; Now draw the scene, rather than the view, to the window:
OWindow->Draw, oScene

In the examples so far, the views have been empty canvases. For data visualization applications, these views will need some graphical content. To draw visual representations within the views, two additional types of objects are required:

  • A model object - a transformation node
  • A visualization graphic object - a graphical representation of data (such as an axis, plot line, or surface mesh). For more information, see Visualization Objects.

For example, to include a text label within a view:

; Create a model and add it to the original view:
oModel = OBJ_NEW('IDLgrModel')
oView->Add, oModel
; Create a text object and add it to the model:
oText = OBJ_NEW('IDLgrText','Hello World',ALIGNMENT=0.5)
oModel->Add, oText
; Redraw the scene:
OWindow->Draw, oScene

Notice that the scene, views, model, and text are all combined together into a self-contained hierarchy. It is the overall hierarchy that is drawn to the destination object.

The transformation associated with the model can be modified to impact the text it contains. For example:

; Rotate by 90 degrees about the Z-axis:
oModel->Rotate, [0,0,1], 90
; Redraw:
OWindow->Draw, oScene

When the objects are no longer required, they need to be destroyed. Destination objects must be destroyed separately, but the graphic hierarchies can be destroyed in full by destroying the root of the hierarchy. For example:

OBJ_DESTROY, oWindow
OBJ_DESTROY, oScene

In this example, the destruction of the scene will cause the destruction of all of its children (including the views, model, and text).