Open CASCADE Technology 6.6.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes
NIS_Drawer Class Reference

#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

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.

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.
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.

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 
) [protected, virtual]

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 
) [protected, virtual]

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 [protected, virtual]
virtual void NIS_Drawer::Draw ( const Handle_NIS_InteractiveObject &  ,
const DrawType  theType,
const NIS_DrawList theDrawList 
) [protected, pure 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 [inline, protected]
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 
) [protected, virtual]

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  theType1,
const DrawType  theType2,
const DrawType  theType3,
const DrawType  theType4 
) 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
void NIS_Drawer::SetUpdated ( const DrawType  theType) const

Mark all draw lists for update

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


The documentation for this class was generated from the following file:
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines