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

SelectMgr_ViewerSelector Class Reference

A framework to define finding, sorting the sensitive primitives in a view. Services are also provided to define the return of the owners of those primitives selected. The primitives are sorted by criteria such as priority of the primitive or its depth in the view relative to that of other primitives. Note that in 3D, the inheriting framework StdSelect_ViewerSelector3d is only to be used if you do not want to use the services provided by AIS. Two tools are available to find and select objects found at a given position in the view. If you want to select the owners of all the objects detected at point x,y,z you use the Init - More - Next - Picked loop. If, on the other hand, you want to select only one object detected at that point, you use the Init - More - OnePicked loop. In this iteration, More is used to see if an object was picked and OnePicked, to get the object closest to the pick position. Viewer selectors are driven by SelectMgr_SelectionManager, and manipulate the SelectMgr_Selection objects given to them by the selection manager. More...

#include <SelectMgr_ViewerSelector.hxx>

Inheritance diagram for SelectMgr_ViewerSelector:
Inheritance graph
[legend]

Public Member Functions

void Clear ()
 Empties all the tables, removes all selections... More...
 
Standard_Real Sensitivity () const
 returns the Sensitivity of picking More...
 
void SortResult ()
 Sorts the detected entites by priority and distance. to be redefined if other criterion are used... More...
 
void Init ()
 Begins an iteration scanning for the owners detected at a position in the view. More...
 
Standard_Boolean More ()
 Continues the interation scanning for the owners detected at a position in the view, or. More...
 
void Next ()
 Returns the next owner found in the iteration. This is a scan for the owners detected at a position in the view. More...
 
Handle_SelectMgr_EntityOwner Picked () const
 Returns the current selected entity detected by the selector;. More...
 
Handle_SelectMgr_EntityOwner OnePicked ()
 Returns the picked element with the highest priority, and which is the closest to the last successful mouse position. More...
 
void SetPickClosest (const Standard_Boolean preferClosest)
 Set preference of selecting one object for OnePicked() method: More...
 
Standard_Integer NbPicked () const
 Returns the number of owners found at a position in the view by the Init - More - Next - Picked iteration. More...
 
Handle_SelectMgr_EntityOwner Picked (const Standard_Integer aRank) const
 Returns the entity which is at rank <aRank> in the list of stored ones. More...
 
Standard_Boolean Contains (const Handle< SelectMgr_SelectableObject > &theObject) const
 
Standard_Boolean Modes (const Handle< SelectMgr_SelectableObject > &theSelectableObject, TColStd_ListOfInteger &theModeList, const SelectMgr_StateOfSelection theWantedState=SelectMgr_SOS_Any) const
 Returns the list of selection modes ModeList found in this selector for the selectable object aSelectableObject. Returns true if aSelectableObject is referenced inside this selector; returns false if the object is not present in this selector. More...
 
Standard_Boolean IsActive (const Handle< SelectMgr_SelectableObject > &theSelectableObject, const Standard_Integer theMode) const
 Returns true if the selectable object aSelectableObject having the selection mode aMode is active in this selector. More...
 
Standard_Boolean IsInside (const Handle< SelectMgr_SelectableObject > &theSelectableObject, const Standard_Integer theMode) const
 Returns true if the selectable object aSelectableObject having the selection mode aMode is in this selector. More...
 
SelectMgr_StateOfSelection Status (const Handle< SelectMgr_Selection > &theSelection) const
 Returns the selection status Status of the selection aSelection. More...
 
TCollection_AsciiString Status (const Handle< SelectMgr_SelectableObject > &theSelectableObject) const
 
NCollection_List< Handle
< SelectBasics_EntityOwner > > 
ActiveOwners () const
 Returns the list of active entity owners. More...
 
void AddSelectableObject (const Handle< SelectMgr_SelectableObject > &theObject)
 Adds new object to the map of selectable objects. More...
 
void AddSelectionToObject (const Handle< SelectMgr_SelectableObject > &theObject, const Handle< SelectMgr_Selection > &theSelection)
 Adds new selection to the object and builds its BVH tree. More...
 
void RemoveSelectableObject (const Handle< SelectMgr_SelectableObject > &theObject)
 Removes selectable object from map of selectable ones. More...
 
void RemoveSelectionOfObject (const Handle< SelectMgr_SelectableObject > &theObject, const Handle< SelectMgr_Selection > &theSelection)
 Removes selection of the object and marks its BVH tree for rebuild. More...
 
void RebuildObjectsTree (const Standard_Boolean theIsForce=Standard_False)
 Marks BVH of selectable objects for rebuild. Parameter theIsForce set as true guarantees that 1st level BVH for the viewer selector will be rebuilt during this call. More...
 
void RebuildSensitivesTree (const Handle< SelectMgr_SelectableObject > &theObject, const Standard_Boolean theIsForce=Standard_False)
 Marks BVH of sensitive entities of particular selectable object for rebuild. Parameter theIsForce set as true guarantees that 2nd level BVH for the object given will be rebuilt during this call. More...
 
void InitDetected ()
 Initializes internal iterator for stored detected sensitive entities. More...
 
void NextDetected ()
 Makes a step along the map of detected sensitive entities and their owners. More...
 
Standard_Boolean MoreDetected ()
 Returns true if iterator of map of detected sensitive entities has reached its end. More...
 
const Handle
< SelectBasics_SensitiveEntity > & 
DetectedEntity () const
 Returns sensitive entity that was detected during the previous run of selection algorithm. More...
 
SelectMgr_SelectingVolumeManagerGetManager ()
 Returns instance of selecting volume manager of the viewer selector. More...
 
- Public Member Functions inherited from MMgt_TShared
virtual void Delete () const
 Memory deallocator for transient classes. More...
 
- 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 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

 SelectMgr_ViewerSelector ()
 
void TraverseSensitives ()
 Traverses BVH containing all added selectable objects and finds candidates for further search of overlap. More...
 
virtual Standard_Boolean HasDepthClipping (const Handle< SelectMgr_EntityOwner > &theOwner) const
 Returns True if the owner provides clipping by depth for its sensitives. Override this method to tell the selector to use the DepthClipping method for the owner. Default implementation returns False for every owner. More...
 
void traverseObject (const Handle< SelectMgr_SelectableObject > &theObject)
 Internal function that checks if there is possible overlap between some entity of selectable object theObject and current selecting volume. More...
 
void checkOverlap (const Handle< SelectBasics_SensitiveEntity > &theEntity, const Standard_Integer theEntityIdx, SelectMgr_SelectingVolumeManager &theMgr)
 Internal function that checks if a particular sensitive entity theEntity overlaps current selecting volume precisely. More...
 
void resetSelectionActivationStatus ()
 Marks all added sensitive entities of all objects as non-selectable. More...
 
Standard_Boolean isToScaleFrustum (const Handle< SelectBasics_SensitiveEntity > &theEntity)
 Checks if the entity given requires to scale current selecting frustum. More...
 
SelectMgr_SelectingVolumeManager scaleAndTransform (const Standard_Real theScale, const gp_Trsf &theTrsf)
 Applies given scale and transformation matrices to the default selecting volume manager. More...
 

Protected Attributes

Standard_Boolean preferclosest
 
Standard_Real mytolerance
 
Standard_Boolean myToUpdateTolerance
 
SelectMgr_IndexedDataMapOfOwnerCriterion mystored
 
SelectMgr_SelectingVolumeManager mySelectingVolumeMgr
 
NCollection_Handle
< SelectMgr_SelectableObjectSet
mySelectableObjects
 
SelectMgr_ToleranceMap myTolerances
 

Detailed Description

A framework to define finding, sorting the sensitive primitives in a view. Services are also provided to define the return of the owners of those primitives selected. The primitives are sorted by criteria such as priority of the primitive or its depth in the view relative to that of other primitives. Note that in 3D, the inheriting framework StdSelect_ViewerSelector3d is only to be used if you do not want to use the services provided by AIS. Two tools are available to find and select objects found at a given position in the view. If you want to select the owners of all the objects detected at point x,y,z you use the Init - More - Next - Picked loop. If, on the other hand, you want to select only one object detected at that point, you use the Init - More - OnePicked loop. In this iteration, More is used to see if an object was picked and OnePicked, to get the object closest to the pick position. Viewer selectors are driven by SelectMgr_SelectionManager, and manipulate the SelectMgr_Selection objects given to them by the selection manager.

Tolerances are applied to the entities in the following way:

  1. tolerance value stored in mytolerance will be used to calculate initial selecting frustum, which will be applied for intersection testing during BVH traverse;
  2. if tolerance of sensitive entity is less than mytolerance, the frustum for intersection detection will be resized according to its sensitivity.

Constructor & Destructor Documentation

SelectMgr_ViewerSelector::SelectMgr_ViewerSelector ( )
protected

Member Function Documentation

NCollection_List<Handle< SelectBasics_EntityOwner > > SelectMgr_ViewerSelector::ActiveOwners ( ) const

Returns the list of active entity owners.

void SelectMgr_ViewerSelector::AddSelectableObject ( const Handle< SelectMgr_SelectableObject > &  theObject)

Adds new object to the map of selectable objects.

void SelectMgr_ViewerSelector::AddSelectionToObject ( const Handle< SelectMgr_SelectableObject > &  theObject,
const Handle< SelectMgr_Selection > &  theSelection 
)

Adds new selection to the object and builds its BVH tree.

void SelectMgr_ViewerSelector::checkOverlap ( const Handle< SelectBasics_SensitiveEntity > &  theEntity,
const Standard_Integer  theEntityIdx,
SelectMgr_SelectingVolumeManager theMgr 
)
protected

Internal function that checks if a particular sensitive entity theEntity overlaps current selecting volume precisely.

void SelectMgr_ViewerSelector::Clear ( )

Empties all the tables, removes all selections...

Standard_Boolean SelectMgr_ViewerSelector::Contains ( const Handle< SelectMgr_SelectableObject > &  theObject) const
const Handle< SelectBasics_SensitiveEntity >& SelectMgr_ViewerSelector::DetectedEntity ( ) const

Returns sensitive entity that was detected during the previous run of selection algorithm.

SelectMgr_SelectingVolumeManager& SelectMgr_ViewerSelector::GetManager ( )

Returns instance of selecting volume manager of the viewer selector.

virtual Standard_Boolean SelectMgr_ViewerSelector::HasDepthClipping ( const Handle< SelectMgr_EntityOwner > &  theOwner) const
protectedvirtual

Returns True if the owner provides clipping by depth for its sensitives. Override this method to tell the selector to use the DepthClipping method for the owner. Default implementation returns False for every owner.

Parameters
theOwner[in] the onwer to check.
Returns
True if owner provides depth limits for sensitive clipping.

Reimplemented in StdSelect_ViewerSelector3d.

void SelectMgr_ViewerSelector::Init ( )

Begins an iteration scanning for the owners detected at a position in the view.

void SelectMgr_ViewerSelector::InitDetected ( )

Initializes internal iterator for stored detected sensitive entities.

Standard_Boolean SelectMgr_ViewerSelector::IsActive ( const Handle< SelectMgr_SelectableObject > &  theSelectableObject,
const Standard_Integer  theMode 
) const

Returns true if the selectable object aSelectableObject having the selection mode aMode is active in this selector.

Standard_Boolean SelectMgr_ViewerSelector::IsInside ( const Handle< SelectMgr_SelectableObject > &  theSelectableObject,
const Standard_Integer  theMode 
) const

Returns true if the selectable object aSelectableObject having the selection mode aMode is in this selector.

Standard_Boolean SelectMgr_ViewerSelector::isToScaleFrustum ( const Handle< SelectBasics_SensitiveEntity > &  theEntity)
protected

Checks if the entity given requires to scale current selecting frustum.

Standard_Boolean SelectMgr_ViewerSelector::Modes ( const Handle< SelectMgr_SelectableObject > &  theSelectableObject,
TColStd_ListOfInteger theModeList,
const SelectMgr_StateOfSelection  theWantedState = SelectMgr_SOS_Any 
) const

Returns the list of selection modes ModeList found in this selector for the selectable object aSelectableObject. Returns true if aSelectableObject is referenced inside this selector; returns false if the object is not present in this selector.

Standard_Boolean SelectMgr_ViewerSelector::More ( )

Continues the interation scanning for the owners detected at a position in the view, or.

  • continues the iteration scanning for the owner closest to the position in the view.
Standard_Boolean SelectMgr_ViewerSelector::MoreDetected ( )

Returns true if iterator of map of detected sensitive entities has reached its end.

Standard_Integer SelectMgr_ViewerSelector::NbPicked ( ) const

Returns the number of owners found at a position in the view by the Init - More - Next - Picked iteration.

void SelectMgr_ViewerSelector::Next ( )

Returns the next owner found in the iteration. This is a scan for the owners detected at a position in the view.

void SelectMgr_ViewerSelector::NextDetected ( )

Makes a step along the map of detected sensitive entities and their owners.

Handle_SelectMgr_EntityOwner SelectMgr_ViewerSelector::OnePicked ( )

Returns the picked element with the highest priority, and which is the closest to the last successful mouse position.

Handle_SelectMgr_EntityOwner SelectMgr_ViewerSelector::Picked ( ) const

Returns the current selected entity detected by the selector;.

Handle_SelectMgr_EntityOwner SelectMgr_ViewerSelector::Picked ( const Standard_Integer  aRank) const

Returns the entity which is at rank <aRank> in the list of stored ones.

void SelectMgr_ViewerSelector::RebuildObjectsTree ( const Standard_Boolean  theIsForce = Standard_False)

Marks BVH of selectable objects for rebuild. Parameter theIsForce set as true guarantees that 1st level BVH for the viewer selector will be rebuilt during this call.

void SelectMgr_ViewerSelector::RebuildSensitivesTree ( const Handle< SelectMgr_SelectableObject > &  theObject,
const Standard_Boolean  theIsForce = Standard_False 
)

Marks BVH of sensitive entities of particular selectable object for rebuild. Parameter theIsForce set as true guarantees that 2nd level BVH for the object given will be rebuilt during this call.

void SelectMgr_ViewerSelector::RemoveSelectableObject ( const Handle< SelectMgr_SelectableObject > &  theObject)

Removes selectable object from map of selectable ones.

void SelectMgr_ViewerSelector::RemoveSelectionOfObject ( const Handle< SelectMgr_SelectableObject > &  theObject,
const Handle< SelectMgr_Selection > &  theSelection 
)

Removes selection of the object and marks its BVH tree for rebuild.

void SelectMgr_ViewerSelector::resetSelectionActivationStatus ( )
protected

Marks all added sensitive entities of all objects as non-selectable.

SelectMgr_SelectingVolumeManager SelectMgr_ViewerSelector::scaleAndTransform ( const Standard_Real  theScale,
const gp_Trsf theTrsf 
)
protected

Applies given scale and transformation matrices to the default selecting volume manager.

Standard_Real SelectMgr_ViewerSelector::Sensitivity ( ) const

returns the Sensitivity of picking

void SelectMgr_ViewerSelector::SetPickClosest ( const Standard_Boolean  preferClosest)

Set preference of selecting one object for OnePicked() method:

  • If True, objects with less depth (distance fron the view plane) are preferred regardless of priority (priority is used then to choose among objects with similar depth),
  • If False, objects with higher priority are preferred regardless of the depth which is used to choose among objects of the same priority.
void SelectMgr_ViewerSelector::SortResult ( )

Sorts the detected entites by priority and distance. to be redefined if other criterion are used...

SelectMgr_StateOfSelection SelectMgr_ViewerSelector::Status ( const Handle< SelectMgr_Selection > &  theSelection) const

Returns the selection status Status of the selection aSelection.

TCollection_AsciiString SelectMgr_ViewerSelector::Status ( const Handle< SelectMgr_SelectableObject > &  theSelectableObject) const
void SelectMgr_ViewerSelector::traverseObject ( const Handle< SelectMgr_SelectableObject > &  theObject)
protected

Internal function that checks if there is possible overlap between some entity of selectable object theObject and current selecting volume.

void SelectMgr_ViewerSelector::TraverseSensitives ( )
protected

Traverses BVH containing all added selectable objects and finds candidates for further search of overlap.

Field Documentation

NCollection_Handle<SelectMgr_SelectableObjectSet> SelectMgr_ViewerSelector::mySelectableObjects
mutableprotected
SelectMgr_SelectingVolumeManager SelectMgr_ViewerSelector::mySelectingVolumeMgr
protected
SelectMgr_IndexedDataMapOfOwnerCriterion SelectMgr_ViewerSelector::mystored
protected
Standard_Real SelectMgr_ViewerSelector::mytolerance
protected
SelectMgr_ToleranceMap SelectMgr_ViewerSelector::myTolerances
protected
Standard_Boolean SelectMgr_ViewerSelector::myToUpdateTolerance
protected
Standard_Boolean SelectMgr_ViewerSelector::preferclosest
protected

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