The worldDraw() function is the primary mechanism for a drawable to display itself. From this callback the drawable uses the AcGiSubEntityTraits and AcGiWorldGeometry interfaces to tell the AcGi implementation how this drawable should be represented in all active viewports. For information that is specific to certain viewports, the viewportDraw() callback is provided (see The viewportDraw() Function).
The AcDbEntity::subWorldDraw() function takes a pointer to an AcGiWorldDraw object. AcGiWorldDraw is a container class for the AcGi geometry and traits objects. Specifically, AcGiWorldDraw contains two other objects:
The AcGiWorldGeometry object can be accessed from within subWorldDraw() by using the AcGiWorldDraw::geometry() function, and the AcGiSubEntityTraits object can be accessed by using the AcGiWorldDraw::subEntityTraits() function.
The AcGiWorldGeometry object writes vectors to AutoCAD's display using its set of drawing primitives. A primitive is the lowest-level instruction used to draw graphical entities. The world geometry object has the following functions for drawing primitives in world coordinates, which are inherited from AcGiGeometry:
The draw method allows you to specify another drawable to be used as a part of your geometry. This might be another entity or an in-memory drawable. AcGi uses the same setAttributes(), worldDraw(), and viewportDraw() logic on this object as it uses on your object.
The AcGiSubEntityTraits object sets graphical attribute values using its set of traits functions:
Objects passed through draw() should live as long as the corresponding “graphics model.” If you wish to reuse worldDraw(), then you should delegate your object through it instead of using draw(). For example, the following code sample will produce an error:
MyCustomObject::subWorldDraw(AcGiWorldDraw* draw) { AcDbCircle circle; draw->geometry().draw(&circle); }
Instead, use either
MyCustomObject::subWorldDraw(AcGiWorldDraw* draw) { AcDbCircle circle; circle.worldDraw(draw); }
or perhaps
MyCustomObject::subWorldDraw(AcGiWorldDraw* draw) { //m_circle is a member of MyCustomObject draw->geometry().draw(&m_circle); }