Open CASCADE Technology  6.9.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

NIS_Drawer Class Referenceabstract

#include <NIS_Drawer.hxx>

Inheritance diagram for NIS_Drawer:
Inheritance graph
[legend]

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_InteractiveContextGetContext () const
 
virtual void Assign (const Handle< NIS_Drawer > &theOther)
 
virtual const Bnd_B3fGetBox (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_Transientoperator= (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_DrawListcreateDefaultList (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...
 

Detailed Description

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

See Also
nis_interactiveobject_drawer to learn how this mechanism works from the side of NIS_InteractiveObject.
<> Drawing

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.

Member Enumeration Documentation

Enumerator
Draw_Normal 
Draw_Top 
Draw_Transparent 
Draw_Hilighted 
Draw_DynHilighted 

Constructor & Destructor Documentation

NIS_Drawer::NIS_Drawer ( )
inline

Empty constructor.

virtual NIS_Drawer::~NIS_Drawer ( )
virtual

Destructor.

Member Function Documentation

void NIS_Drawer::addObject ( const NIS_InteractiveObject theObj,
const Standard_Boolean  isShareList,
const Standard_Boolean  isUpVws 
)
protected
virtual void NIS_Drawer::AfterDraw ( const DrawType  theType,
const NIS_DrawList theDrawList 
)
protectedvirtual

Called after execution of Draw(), once per group of interactive objects.

Reimplemented in NIS_SurfaceDrawer, and NIS_TriangulatedDrawer.

virtual void NIS_Drawer::Assign ( const Handle< NIS_Drawer > &  theOther)
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.

virtual void NIS_Drawer::BeforeDraw ( const DrawType  theType,
const NIS_DrawList theDrawList 
)
protectedvirtual

Called before execution of Draw(), once per group of interactive objects.

Reimplemented in NIS_SurfaceDrawer, and NIS_TriangulatedDrawer.

virtual NIS_DrawList* NIS_Drawer::createDefaultList ( const Handle< NIS_View > &  ) const
protectedvirtual
virtual void NIS_Drawer::Draw ( const Handle< NIS_InteractiveObject > &  ,
const DrawType  theType,
const NIS_DrawList theDrawList 
)
protectedpure virtual

Main function: display the given interactive object in the given view.

Implemented in NIS_SurfaceDrawer, and NIS_TriangulatedDrawer.

virtual const Bnd_B3f& NIS_Drawer::GetBox ( const NIS_View pView = 0L) const
virtual

Create a3D bounding box of drawn objects.

Parameters
pViewIn not NULL, only objects visible in this view are taken.
NIS_InteractiveContext* NIS_Drawer::GetContext ( ) const
inline

Query the Interactive Context.

NCollection_List<NIS_DrawList *> NIS_Drawer::GetLists ( ) const
inline

Query associated draw lists.

virtual Standard_Integer NIS_Drawer::HashCode ( const Standard_Integer  theN) const
virtual

Hash value, for Map interface.

virtual Standard_Boolean NIS_Drawer::IsEqual ( const Handle< NIS_Drawer > &  theOth) const
virtual

Matching two instances, for Map interface.

Reimplemented in NIS_SurfaceDrawer, and NIS_TriangulatedDrawer.

Standard_Integer NIS_Drawer::NObjects ( ) const
inlineprotected

Get the number of interactive objects in this drawer.

TColStd_MapIteratorOfPackedMapOfInteger NIS_Drawer::ObjectIterator ( ) const
inline

Obtain the iterator of IDs of associated objects.

virtual void NIS_Drawer::redraw ( const DrawType  theType,
const Handle< NIS_View > &  theView 
)
protectedvirtual

Reimplemented in NIS_SurfaceDrawer.

void NIS_Drawer::removeObject ( const NIS_InteractiveObject theObj,
const Standard_Boolean  isUpVws 
)
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.

Parameters
isHilightedTrue if the object should be hilighted, False - if not hilighted
theObjObject instance that should be hilighted or unhilighted.
theViewView 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
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
void NIS_Drawer::UpdateExListId ( const Handle< NIS_View > &  theView) const
protected

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

Field Documentation

Standard_Integer NIS_Drawer::myIniId
protected

ID of the initializing InteractiveObject. It is never changed, can be used to compute hash code of the Drawer instance.

NCollection_List<NIS_DrawList*> NIS_Drawer::myLists
protected
Standard_Integer NIS_Drawer::myObjPerDrawer
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.

Standard_ShortReal NIS_Drawer::myTransparency
protected

The documentation for this class was generated from the following file: