NIS_InteractiveObject Class Reference

#include <NIS_InteractiveObject.hxx>

Inheritance diagram for NIS_InteractiveObject:
Inheritance graph
[legend]

Public Member Functions

 NIS_InteractiveObject ()
virtual ~NIS_InteractiveObject ()
Standard_Integer ID () const
NIS_Drawer::DrawType DrawType () const
const Handle_NIS_Drawer & SetDrawer (const Handle_NIS_Drawer &theDrawer)
const Handle_NIS_Drawer & GetDrawer () const
virtual Handle_NIS_Drawer DefaultDrawer () const =0
const Bnd_B3fGetBox ()
Standard_Boolean IsTransparent () const
Standard_Boolean IsHidden () const
Standard_Boolean IsDisplayed () const
Standard_Boolean IsDynHilighted () const
Standard_Boolean IsSelectable () const
void SetSelectable (const Standard_Boolean isSel=Standard_True) const
Standard_Real Transparency () const
void SetTransparency (const Standard_Real theValue=0.6)
void UnsetTransparency ()
virtual Standard_Real Intersect (const gp_Ax1 &theAxis, const Standard_Real theOver) const =0
virtual Standard_Boolean Intersect (const Bnd_B3f &theBox, const gp_Trsf &theTrf, const Standard_Boolean isFull) const
void SetAttribute (void *theAttributePtr)
void * GetAttribute () const

Protected Member Functions

void setDrawerUpdate () const
virtual void computeBox ()=0
Standard_Boolean isUpdateBox () const
void setIsUpdateBox (const Standard_Boolean isUpdate)

Protected Attributes

Bnd_B3f myBox
void * myAttributePtr

Detailed Description

Abstract base type for presentable and selectable object in NIS architecture.

InteractiveObject_class

An InteractiveObject has the attributes:

Because the class is abstract, it does not define any color, material and other visual aspect - all relevant aspects should be defined in derived classes.
Every InteractiveObject type should have an associated NIS_Drawer type; a new instance of this associated drawer is returned by the virtual method DefaultDrawer(). The drawer is responsible for the correct calculation of the presentation in every possible state (normal, hilighted, etc.); usually the associated drawer instance contains all relevant visual aspects.

Association with a Drawer instance is performed by method SetDrawer. This method should not be called by any custom code, it is used internally by NIS algorithms (in NIS_InteractiveContext::Display() for instance). If you develop your own InteractiveObject type, you will need to call SetDrawer whenever you change the visual aspect, for example:

 void MyIOClass::SetColor (const Quantity_Color&  theColor);
 {
   Handle(MyIOClassDrawer) aDrawer = new MyIOClassDrawer;
 // copy the current visual aspects and other attributes to the new Drawer
   aDrawer->Assign (GetDrawer());
 // replace the Drawer
   aDrawer->myColor = theColor;
   SetDrawer (aDrawer);
 // optional: redraws the changed InteractiveObject in the views
   GetDrawer()->GetContext()->UpdateViews();
 }

An instance of this class can have an associated value (Attribute) that is stored as a pointer. It can accommodate an integer/float/boolean value or a pointer to some structure. This attribute is NOT automatically destroyed with the InteractiveObject.


Constructor & Destructor Documentation

NIS_InteractiveObject::NIS_InteractiveObject (  )  [inline]

Empty constructor. Creates an object that is not attached to drawer.

virtual NIS_InteractiveObject::~NIS_InteractiveObject (  )  [virtual]

Destructor.


Member Function Documentation

virtual void NIS_InteractiveObject::computeBox (  )  [protected, pure virtual]

Create a 3D bounding box of the object.

Implemented in NIS_Surface, and NIS_Triangulated.

virtual Handle_NIS_Drawer NIS_InteractiveObject::DefaultDrawer (  )  const [pure virtual]

Create a default drawer instance.

Implemented in NIS_Surface, and NIS_Triangulated.

NIS_Drawer::DrawType NIS_InteractiveObject::DrawType (  )  const [inline]

Query the type of presentation.

void* NIS_InteractiveObject::GetAttribute (  )  const [inline]

Query the associated custom (arbitrary) attribute pointer.

const Bnd_B3f& NIS_InteractiveObject::GetBox (  ) 

Query a 3D bounding box of the object.

const Handle_NIS_Drawer& NIS_InteractiveObject::GetDrawer (  )  const [inline]

Query the current drawer.

Standard_Integer NIS_InteractiveObject::ID (  )  const [inline]

Query the ID of the Object in its Context.

virtual Standard_Boolean NIS_InteractiveObject::Intersect ( const Bnd_B3f theBox,
const gp_Trsf theTrf,
const Standard_Boolean  isFull 
) const [virtual]

Intersect the InteractiveObject geometry with an oriented box. The default implementation (in this abstract class) always returns True, signalling that every object pre-selected by its bounding box is automatically selected. The specializations should define a more correct behaviour.
The algorithm should transform the InteractiveObject geometry using the parameter theTrf and then reject it with box theBox, like:

    gp_Pnt aPnt = ..... // aPnt is part of our geometry.
    if (!theBox.IsOut (aPnt.Transformed(theTrf)))
      return Standard_True;
Parameters:
theBox 3D box of selection
theTrf Position/Orientation of the box. It coincides with theTrfInv that is passed to NIS_InteractiveObject::selectObjects().
isFull True if full inclusion is required (full inside the tested box) for the positive result, False - if only partial inclusion give a result.
Returns:
True if the InteractiveObject geometry intersects the box or is inside it

Reimplemented in NIS_Surface, and NIS_Triangulated.

virtual Standard_Real NIS_InteractiveObject::Intersect ( const gp_Ax1 theAxis,
const Standard_Real  theOver 
) const [pure virtual]

Intersect the InteractiveObject geometry with a line/ray.

Parameters:
theAxis The line or ray in 3D space.
theOver Half-thickness of the selecting line.
Returns:
If the return value is more than 0.1*RealLast() then no intersection is detected. Otherwise returns the coordinate of thePnt on the ray. May be negative.

Implemented in NIS_Surface, and NIS_Triangulated.

Standard_Boolean NIS_InteractiveObject::IsDisplayed (  )  const [inline]

Query the Displayed state - opposite to IsHidden().

Standard_Boolean NIS_InteractiveObject::IsDynHilighted (  )  const [inline]

Query the Dynamic Hilight state

Standard_Boolean NIS_InteractiveObject::IsHidden (  )  const [inline]

Query the Hidden state

Standard_Boolean NIS_InteractiveObject::IsSelectable (  )  const

Query if the Object is selectable.

Standard_Boolean NIS_InteractiveObject::IsTransparent (  )  const [inline]

Query the Transparent state.

Standard_Boolean NIS_InteractiveObject::isUpdateBox (  )  const [inline, protected]
void NIS_InteractiveObject::SetAttribute ( void *  theAttributePtr  )  [inline]

Set the pointer to custom (arbitrary) data associated with the Object.

const Handle_NIS_Drawer& NIS_InteractiveObject::SetDrawer ( const Handle_NIS_Drawer &  theDrawer  ) 

Replace the drawer. This method must not be called for Object that has not yet been added to a Context (thus has empty drawer).
It is possible to have unassigned myDrawer or a DefaultDrawer as the parameter value (but not both). The Context where we work is taken from theDrawer first, then (if NULL) -- from myDrawer.
This method matches theDrawer with the available Drawers in the Context and adds if no match is found.

Returns:
Reference to the finally stored or found Drawer instance inside the Context.
void NIS_InteractiveObject::setDrawerUpdate (  )  const [inline, protected]
void NIS_InteractiveObject::setIsUpdateBox ( const Standard_Boolean  isUpdate  )  [inline, protected]
void NIS_InteractiveObject::SetSelectable ( const Standard_Boolean  isSel = Standard_True  )  const

Set or change the selectable state of the Object.

Parameters:
isSel True (default) - the Object will be selectable, False - it will be ignored by selection/hilighting algorithms.
void NIS_InteractiveObject::SetTransparency ( const Standard_Real  theValue = 0.6  ) 

Set the Transparency factor.

Reimplemented in NIS_Surface.

Standard_Real NIS_InteractiveObject::Transparency (  )  const [inline]

Query the Transparency factor.

void NIS_InteractiveObject::UnsetTransparency (  )  [inline]

Present the Object as opaque (Normal draw type).


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
Generated on Thu Mar 3 10:59:55 2011 for Open CASCADE Technology by  doxygen 1.6.3