The ability to substitute custom classes, yet maintain the integrity of the entire system is the power found in frameworks. When you create and use the graphics classes without extending them, you get the power and convenience of the underlying framework implementations without any effort on your part. When you extend and create your own derived classes, however, you need to understand how the graphics classes fall into major groupings defined by the abstract base classes and the concrete geometry classes, and the dependencies that exist with these groupings. Figure 9 shows the major groupings and their dependency relationships. Classes at the base of the arrow line depend on the class or classes to which the arrows point. For example. MDrawable depends on TGrafPort.
MDrawable: An abstract base class from which the 2-D and 3-D graphics classes descend. MDrawable has a pure virtual Draw function that depends on a TGrafPort parameter.
TGrafPort: An abstract base class that provides device-independent drawing protocols. The drawing port receives the drawing information from the MDrawable::Draw call and channels that information to its dependent TGrafDevice.
The TGrafPort has a Draw call of its own to which you can pass geometry, attribute bundle, and transformation information. This information is then channelled to the TGrafDevice.
TGrafDevice: An abstract base class that provides graphical imaging services for a particular device such as a printer, display monitor, or offscreen buffer. The information on which TGrafDevice depends is received from the TGrafPort. The TGrafDevice has Render functions for every geometry. Any other information required that is not provided by the TGrafPort is supplied to the TGrafDevice by the TGrafState.
TAttributeState and TAttribute3DState: Abstract base classes that define drawing attributes for graphics.
TGrafMatrix and TGrafMatrix3D: Base classes that provide transformation matrices to move, rotate, and translate graphics and geometries.
2-D and 3-D geometry classes: Concrete geometric shapes.
TGrafState: An abstract base class that defines the default graphic attributes, scene attributes, transformations, and clipping region provided by the drawing port.