Open CASCADE Technology
6.9.0
|
#include <NIS_Drawer.hxx>
Public Types | |
enum | DrawType { Draw_Normal = 0, Draw_Top = 1, Draw_Transparent = 2, Draw_Hilighted = 3, Draw_DynHilighted = 4 } |
Public Member Functions | |
NIS_Drawer () | |
virtual | ~NIS_Drawer () |
NIS_InteractiveContext * | GetContext () const |
virtual void | Assign (const Handle< NIS_Drawer > &theOther) |
virtual const Bnd_B3f & | GetBox (const NIS_View *pView=0L) const |
void | SetUpdated (const DrawType theType) const |
void | SetUpdated (const DrawType theType1, const DrawType theType2) const |
void | SetUpdated (const DrawType theType1, const DrawType theType2, const DrawType theType3) const |
void | SetUpdated (const DrawType theType1, const DrawType theType2, const DrawType theType3, const DrawType theType4) const |
void | SetDynamicHilighted (const Standard_Boolean isHilighted, const Handle< NIS_InteractiveObject > &theObj, const Handle< NIS_View > &theView=0L) |
virtual Standard_Integer | HashCode (const Standard_Integer theN) const |
virtual Standard_Boolean | IsEqual (const Handle< NIS_Drawer > &theOth) const |
TColStd_MapIteratorOfPackedMapOfInteger | ObjectIterator () const |
NCollection_List< NIS_DrawList * > | GetLists () const |
Public Member Functions inherited from Standard_Transient | |
Standard_Transient () | |
Empty constructor. More... | |
Standard_Transient (const Standard_Transient &) | |
Copy constructor – does nothing. More... | |
Standard_Transient & | operator= (const Standard_Transient &) |
Assignment operator, needed to avoid copying reference counter. More... | |
virtual | ~Standard_Transient () |
Destructor must be virtual. More... | |
virtual void | Delete () const |
Memory deallocator for transient classes. More... | |
virtual const Handle_Standard_Type & | DynamicType () const |
Returns a type information object about this object. More... | |
Standard_Boolean | IsInstance (const Handle_Standard_Type &theType) const |
Returns a true value if this is an instance of Type. More... | |
Standard_Boolean | IsInstance (const Standard_CString theTypeName) const |
Returns a true value if this is an instance of TypeName. More... | |
Standard_Boolean | IsKind (const Handle_Standard_Type &theType) const |
Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More... | |
Standard_Boolean | IsKind (const Standard_CString theTypeName) const |
Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More... | |
virtual Handle_Standard_Transient | This () const |
Returns a Handle which references this object. Must never be called to objects created in stack. More... | |
Standard_Integer | GetRefCount () const |
Get the reference counter of this object. More... | |
Protected Member Functions | |
void | UpdateExListId (const Handle< NIS_View > &theView) const |
virtual void | BeforeDraw (const DrawType theType, const NIS_DrawList &theDrawList) |
virtual void | AfterDraw (const DrawType theType, const NIS_DrawList &theDrawList) |
virtual void | Draw (const Handle< NIS_InteractiveObject > &, const DrawType theType, const NIS_DrawList &theDrawList)=0 |
virtual void | redraw (const DrawType theType, const Handle< NIS_View > &theView) |
void | addObject (const NIS_InteractiveObject *theObj, const Standard_Boolean isShareList, const Standard_Boolean isUpVws) |
void | removeObject (const NIS_InteractiveObject *theObj, const Standard_Boolean isUpVws) |
virtual NIS_DrawList * | createDefaultList (const Handle< NIS_View > &) const |
Standard_Integer | NObjects () const |
Get the number of interactive objects in this drawer. More... | |
Protected Attributes | |
NCollection_List< NIS_DrawList * > | myLists |
Standard_ShortReal | myTransparency |
Standard_Integer | myIniId |
ID of the initializing InteractiveObject. It is never changed, can be used to compute hash code of the Drawer instance. More... | |
Standard_Integer | myObjPerDrawer |
Maximal range of IDs of objects in one drawer. Limits the size of draw lists. Can be initialized only in constructor (default 1024). It is strictly prohibited to change this value outside the constructor. More... | |
Abstract Drawer type. Drawer provides the immediate OpenGL drawing for every NIS_InteractiveObject maneged by the given Drawer instance. Each Drawer instance has reciprocal link with a number of NIS_InteractiveObject instances of the same (corresponding to Drawer) type. The idea is to group the drawing for all referred interactive objects using the same pre- and post-treatment like color setting, matrix, polygon offset, line thickness and what not.
<> Visual properties of Drawer>Normally visual properties of any NIS_InteractiveObject are stored in its Drawer instance, but not in an object. For example, if an interactive object has method SetColor() then the color is stored in the corresponding Drawer rather than in the interactive object itself. This scheme avoid useless duplication when a lot of objects have similar properties like color. Please see
There are 3 virtual methods to implement OpenGL drawing in this API. They define the drawing cycle that consists of filling the internal OpenGL draw list with commands. This drawing cycle is triggered when the corresponding internal instance of NIS_DrawList has 'IsUpdated' flag (you can set this flag by means of public methods NIS_Drawer::SetUpdated()).
Each of these methods receives NIS_DrawList and DrawType, both identify the OpenGL draw list that should be filled with commands. Based on DrawType you will be able to define different presentation - the most important case is how hilighted (selected) interactive object is presented.
For advanced purposes you also can redefine the virtual method redraw(), it is dedicated to higher-level management of draw lists and ordering of their update when necessary.
<> Distinction of Drawer instances>Every Drawer should define which interactive objects it may manage and which - may not. The same idea could be shaped alternatively: every interactive object should understand to what Drawer it can attach itself. This question is answerd by special virtual method IsEqual() that compares two Drawers of the same type. Two instances of Drawer are equal if they have the same set of visual properties that are implemented in BeforeDraw(). The method IsEqual() is the core of Drawer architecture and it must be implemented very carefully for any new type. Particularly, for any derived class the method IsEqual() should first call the same method of its superclass.
For the optimal efficiency of OpenGL drawing it is better to keep the size of draw list (i.e., the number of interactive objects in a Drawer instance) not too small and not too big. The latter limitation is entered by the protected field myObjPerDrawer. It is used in method IsEqual() of the base Drawer class: two Drawers are not equal if they are initialized on objects that have too different IDs – even if all visual properties of these two Drawer instances coincide.
<> Cloning Drawer instances>It is possible to clone a Drawer instance with the viryual method Assign(). This method copies all visual properties and other important data from the Drawer provided as parameter. Method Clone() also should be very carefully implemented for any new Drawer type, to make sure that all necessary data fields and structures are properly copied.
enum NIS_Drawer::DrawType |
|
inline |
Empty constructor.
|
virtual |
Destructor.
|
protected |
|
protectedvirtual |
Called after execution of Draw(), once per group of interactive objects.
Reimplemented in NIS_SurfaceDrawer, and NIS_TriangulatedDrawer.
|
virtual |
Copy the relevant information from another instance of Drawer. raises exception if theOther has incompatible type (test IsKind).
Reimplemented in NIS_SurfaceDrawer, and NIS_TriangulatedDrawer.
|
protectedvirtual |
Called before execution of Draw(), once per group of interactive objects.
Reimplemented in NIS_SurfaceDrawer, and NIS_TriangulatedDrawer.
|
protectedvirtual |
|
protectedpure virtual |
Main function: display the given interactive object in the given view.
Implemented in NIS_SurfaceDrawer, and NIS_TriangulatedDrawer.
Create a3D bounding box of drawn objects.
pView | In not NULL, only objects visible in this view are taken. |
|
inline |
Query the Interactive Context.
|
inline |
Query associated draw lists.
|
virtual |
Hash value, for Map interface.
|
virtual |
Matching two instances, for Map interface.
Reimplemented in NIS_SurfaceDrawer, and NIS_TriangulatedDrawer.
|
inlineprotected |
Get the number of interactive objects in this drawer.
|
inline |
Obtain the iterator of IDs of associated objects.
|
protectedvirtual |
Reimplemented in NIS_SurfaceDrawer.
|
protected |
void NIS_Drawer::SetDynamicHilighted | ( | const Standard_Boolean | isHilighted, |
const Handle< NIS_InteractiveObject > & | theObj, | ||
const Handle< NIS_View > & | theView = 0L |
||
) |
Switch on/off the dynamic hilight of the given object in the given view.
isHilighted | True if the object should be hilighted, False - if not hilighted |
theObj | Object instance that should be hilighted or unhilighted. |
theView | View where the status of object must be changed. If NULL, the object is hilighted/unhilighted in all views. |
void NIS_Drawer::SetUpdated | ( | const DrawType | theType | ) | const |
Mark all draw lists for update
void NIS_Drawer::SetUpdated | ( | const DrawType | theType1, |
const DrawType | theType2, | ||
const DrawType | theType3 | ||
) | const |
void NIS_Drawer::SetUpdated | ( | const DrawType | theType1, |
const DrawType | theType2, | ||
const DrawType | theType3, | ||
const DrawType | theType4 | ||
) | const |
Called to add draw list IDs to ex-list Ids of view. These draw lists are eventually released in the callback function, before anything is displayed
|
protected |
ID of the initializing InteractiveObject. It is never changed, can be used to compute hash code of the Drawer instance.
|
protected |
|
protected |
Maximal range of IDs of objects in one drawer. Limits the size of draw lists. Can be initialized only in constructor (default 1024). It is strictly prohibited to change this value outside the constructor.
|
protected |