Open CASCADE Technology
6.9.0
|
#include <NIS_InteractiveObject.hxx>
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 Standard_Boolean setUpdated=Standard_True) |
const Handle< NIS_Drawer > & | GetDrawer () const |
virtual NIS_Drawer * | DefaultDrawer (NIS_Drawer *theDrv) const =0 |
const Bnd_B3f & | GetBox () |
Standard_Boolean | IsTransparent () const |
Standard_Boolean | IsHidden () const |
Standard_Boolean | IsDisplayed () const |
Standard_Boolean | IsDynHilighted () const |
virtual Standard_Boolean | IsSelectable () const |
virtual void | SetSelectable (const Standard_Boolean isSel=Standard_True) const |
Standard_ShortReal | Transparency () const |
void | SetTransparency (const Standard_Real theValue=0.6) |
void | UnsetTransparency () |
virtual void | Clone (const Handle< NCollection_BaseAllocator > &theAll, Handle< NIS_InteractiveObject > &theDest) const |
void | CloneWithID (const Handle< NCollection_BaseAllocator > &, Handle< NIS_InteractiveObject > &) |
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 |
virtual Standard_Boolean | Intersect (const NCollection_List< gp_XY > &thePolygon, const gp_Trsf &theTrf, const Standard_Boolean isFull) const |
void | SetAttribute (void *theAttributePtr) |
void * | GetAttribute () 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 | setDrawerUpdate () const |
virtual void | computeBox ()=0 |
Standard_Boolean | isUpdateBox () const |
void | setIsUpdateBox (const Standard_Boolean isUpdate) |
Protected Attributes | |
Bnd_B3f | myBox |
void * | myAttributePtr |
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 and their Drawers.
<> Drawers for NIS_InteractiveObject>Every InteractiveObject type should have an associated NIS_Drawer type; a new instance of this associated drawer must be 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:
Please keep in mind that with this scheme you should not store the color in MyIOClass type, because it is already stored in its Drawer.
<> Interactive selection>Interactive selection is made in class NIS_InteractiveContext, methods selectObjects(). These methods call the virtual API of interactive object, that consists of 3 methods:
All data used in the scope of NIS_InteractiveObject subtype should be either its explicit fields or pointers to memory managed by a special NIS_Allocator instance that belongs to NIS_InteractiveContext. This is strictly required because NIS_InteractiveContext should completely manage all its objects, meaning that it destroys/reallocates them automatically. To support that, the virtual method Clone() should be correctly defined for every interactive object subtype. Supposing that MyIOClass inherits MyBaseIOBase :
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.
|
inline |
Empty constructor. Creates an object that is not attached to drawer.
|
virtual |
Destructor.
|
virtual |
Create a copy of theObject except its ID.
theAll | Allocator where the Dest should store its private data. |
theDest | [in-out] The target object where the data are copied. |
Reimplemented in NIS_Triangulated, and NIS_Surface.
void NIS_InteractiveObject::CloneWithID | ( | const Handle< NCollection_BaseAllocator > & | , |
Handle< NIS_InteractiveObject > & | |||
) |
The same as Clone() but also copies the ID.
|
protectedpure virtual |
Create a 3D bounding box of the object.
Implemented in NIS_Triangulated, and NIS_Surface.
|
pure virtual |
Create a default drawer instance. In the upper-level call (in subclass) it is always called with NULL parameter. Then it should call the same method of the superclass (except for NIS_InteractiveObject superclass type) with the created Drawer instance as parameter.
Implemented in NIS_Triangulated, and NIS_Surface.
|
inline |
Query the type of presentation.
|
inline |
Query the associated custom (arbitrary) attribute pointer.
const Bnd_B3f& NIS_InteractiveObject::GetBox | ( | ) |
Query a 3D bounding box of the object.
|
inline |
Query the current drawer.
|
inline |
Query the ID of the Object in its Context.
|
pure virtual |
Intersect the InteractiveObject geometry with a line/ray.
theAxis | The line or ray in 3D space. |
theOver | Half-thickness of the selecting line. |
Implemented in NIS_Triangulated, and NIS_Surface.
|
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:
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. |
Reimplemented in NIS_Triangulated, and NIS_Surface.
|
virtual |
Intersect the InteractiveObject geometry with a selection polygon. 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 polygon.
thePolygon | the list of vertices of a free-form closed polygon without self-intersections. The last point should not coincide with the first point of the list. Any two neighbor points should not be confused. |
theTrf | Position/Orientation of the polygon. It coincides with theTrfInv that is passed to NIS_InteractiveContext::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. |
Reimplemented in NIS_Triangulated, and NIS_Surface.
|
inline |
Query the Displayed state - opposite to IsHidden().
|
inline |
Query the Dynamic Hilight state
|
inline |
Query the Hidden state
|
virtual |
Query if the Object is selectable.
|
inline |
Query the Transparent state.
|
inlineprotected |
|
inline |
Set the pointer to custom (arbitrary) data associated with the Object.
const Handle< NIS_Drawer >& NIS_InteractiveObject::SetDrawer | ( | const Handle< NIS_Drawer > & | theDrawer, |
const Standard_Boolean | setUpdated = Standard_True |
||
) |
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.
|
inlineprotected |
|
inlineprotected |
|
virtual |
Set or change the selectable state of the Object.
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.
|
inline |
Query the Transparency factor.
|
inline |
Present the Object as opaque (Normal draw type).
|
protected |
|
protected |