next up previous contents
Next: Matrix4 Up: Display objects Previous: DisplayDevice   Contents



Files: Displayable.h, Displayable.C
Derived from: \bf ColorUser, \bf Pickable
Global instance (if any): none
Used in optional component: Part of main VMD code


The Displayable base class is the parent class for all items which need to be drawn to a DisplayDevice. For example, the set of axes which appear in the corner of the VMD display screen are maintained as a Displayable, and each Molecule is one as well. The Scene (section 24.7) object maintains a list of all the Displayable's that are to be drawn to the screen. Each Displayable consists of the following components: The Displayable class is the fundamental building block for all items which want to draw something to the screen. Consequently, it is a rather complicated beast.


Enumerations, lists or character name arrays

TransMethod is a public enumeration which is used to indicate the method of use of the objects transformation matrix. It is one of the following:

Internal data structures

Virtual member functions

Method of use

A Displayable must either be registered with a parent (i.e. be a child of some parent), or it must be registered with a Scene (in which case it cannot be the child of any other Displayable). To create a new class derived from Displayable, you need to provide two constructors, one taking a Scene pointer, one a Displayable pointer.

Once created, then in the derived-class-provided prepare routine, the display list of for the Displayable must be set up. If this display list will never change during the program, it can be done just once in the constructor and no prepare is necessary. The display list is created by using DispCmd objects.

The display list for each Displayble must be given to a Scene, regardless of whether it is child or parent or both. It is these display lists which are given to the DisplayDevice to be rendered. The Scene keeps a list of registered Displayable's as well so that it can prepare them for drawing. When a parent is prepared for drawing, it also prepares all its children, so only top-level parents need to be registered with the Scene.

Since this class is derived from Pickable and ColorUser, there are several virtual functions which may need to be supplied in order for the derived Displayable to be picked by the pointers, or to have access to the color database. See the descriptions of these objects for more info.

One note about the display lists: the reason they are done in the current scheme is that the CAVE requires the use of shared memory to hold the information for the rendering processes to draw, while a separate update process keeps track of updating the information in shared memory. Since the shared memory cannot have pointers to non-shared memory locations, the display lists are designed to ONLY hold integer and floating-point data. When drawing in the CAVE, a special CaveScene supplies shared memory blocks for the Displayable's to use for their display lists.

Suggestions for future changes/additions

Right now every item is redrawn each time through the VMD event loop. However, there are times when nothing changes, and no redraw is necessary. The prepare routine might be modified to have it return TRUE if a redraw is needed, so that if none of the current Displayable's need a redraw, that extra work is avoided.

Also, this class is kind of a mess, but most of it is necessary ...

next up previous contents
Next: Matrix4 Up: Display objects Previous: DisplayDevice   Contents