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:
oWindow = OBJ_NEW('IDLgrWindow')
oView = OBJ_NEW('IDLgrView')
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:
OView->SetProperty, COLOR=[60,60,60]
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:
OScene = OBJ_NEW(’IDLgrScene’)
oScene->Add, oView
OView->SetProperty, LOCATION=[0.0,0.5], DIMENSIONS=[0.5,0.5], $
UNITS=3
OView2 = OBJ_NEW(’IDLgrView’, LOCATION=[0.5,0.0], $
DIMENSIONS=[0.5,1.0], UNITS=3,COLOR=[255,0,0])
OScene->Add, oView2
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:
oModel = OBJ_NEW('IDLgrModel')
oView->Add, oModel
oText = OBJ_NEW('IDLgrText','Hello World',ALIGNMENT=0.5)
oModel->Add, oText
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:
oModel->Rotate, [0,0,1], 90
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).