For example, in the wagon shown in Figure 129
, the body consists of four panels and rests on four wheels. When the wagon moves, the wheels move with it, but the wheels also rotate. To translate the body while translating and rotating the wheels, the wagon body is one group and the wheels another group. Since one set of wheels is drawn behind the wagon body away from the viewer's eye and the other set is drawn in front of the body toward the viewer's eye, the wheels are divided into two groups. When the wagon body and wheel groups are adopted into the top-level group, the wheel group that draws away from the viewer's eye is adopted first, followed by the wagon body, followed by the wheel group towards the viewer's eye so that the drawing occurs correctly.
When the TGraphicGroup::Draw function is called, it recursively calls the Draw function for each group or graphic below it in the hierarchy. Each Draw function creates an iterator that traverses one level of the group. Because the draw functions are called recursively, this results in a top-down and depth-first iteration. When a graphic is encountered during the traversal, that graphic and its attribute bundle are sent to the drawing port. The traversal continues until all of the graphics in the group hierarchy have been drawn.
A more complex version of this wagon is created in the code example for this chapter. You might want to refer to the code as you read the discussions below.
[Contents]
[Previous]
[Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.