Graphics class architecture

The 2D and 3D graphics classes descend from MDrawable. MDrawable specifies the minimal protocol for drawing, printing, and streaming a 2D or 3D graphic. As shown in Figure 3, MGraphic and MGraphic3D derive from MDrawable. Functionality that is specific to 2D graphics is provided in MGraphic, and functionality that is specific to 3D graphics is provided in MGraphic3D.


Figure 4 shows the class relationships for MGraphic. The relationships are similar for MGraphic3D. All MGraphic and MGraphic3D derived classes use a drawing port (TGrafPort) to render the graphic; own an attribute bundle (TGrafBundle or TGrafBundle3D); and know the transformation matrix for a graphic (TGrafMatrix or TGrafMatrix3D).


All MGraphic and MGraphic3D derived classes know how to draw themselves. The graphics provide the geometry, attribute, and transformation information to the drawing port when the Draw function of the graphic is called.

The 2D and 3D graphics classes whose names specify a geometry (TLine, TCurve, TEllipse, and so on) are derived from MGraphic and MGraphic3D. As shown in Figure 5, a 2-D graphics class has a geometry class that provides the shape for the graphic. A graphics class has public functions specific to that graphic that allow interaction with its referenced geometry.


You can create your own MDrawable, MGraphic, or MGraphic3D derived class to create complex graphics such as an automobile or human figure. Because a complex graphic is actually a combination of the geometry classes, the drawing port can render it because it knows all of the geometry classes.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker