Open CASCADE Technology 7.8.0
Public Member Functions | Static Public Member Functions
IVtkOCC_ViewerSelector Class Reference

Class that implements OCCT selection algorithm. More...

#include <IVtkOCC_ViewerSelector.hxx>

Inheritance diagram for IVtkOCC_ViewerSelector:
Inheritance graph
[legend]

Public Member Functions

 IVtkOCC_ViewerSelector ()
 
virtual ~IVtkOCC_ViewerSelector ()
 
void Pick (const Standard_Integer theXPix, const Standard_Integer theYPix, const IVtk_IView::Handle &theView)
 Implements point picking.
 
void Pick (const Standard_Integer theXMin, const Standard_Integer theYMin, const Standard_Integer theXMax, const Standard_Integer theYMax, const IVtk_IView::Handle &theView)
 Picking by rectangle.
 
void Pick (double **thePoly, const int theNbPoints, const IVtk_IView::Handle &theView)
 Implements point picking.
 
void Activate (const Handle< SelectMgr_Selection > &theSelection)
 Activates the given selection.
 
void Deactivate (const Handle< SelectMgr_Selection > &theSelection)
 Deactivate the given selection.
 
- Public Member Functions inherited from SelectMgr_ViewerSelector
 SelectMgr_ViewerSelector ()
 Constructs an empty selector object.
 
Standard_Integer CustomPixelTolerance () const
 Returns custom pixel tolerance value.
 
void SetPixelTolerance (const Standard_Integer theTolerance)
 Sets the pixel tolerance <theTolerance>.
 
Standard_Real Sensitivity () const
 Returns the largest sensitivity of picking.
 
Standard_Integer PixelTolerance () const
 Returns the largest pixel tolerance.
 
virtual void SortResult () const
 Sorts the detected entities by priority and distance.
 
Handle< SelectMgr_EntityOwnerOnePicked () const
 Returns the picked element with the highest priority, and which is the closest to the last successful mouse position.
 
bool ToPickClosest () const
 Return the flag determining precedence of picked depth (distance from eye to entity) over entity priority in sorted results; TRUE by default. When flag is TRUE, priority will be considered only if entities have the same depth within the tolerance. When flag is FALSE, entities with higher priority will be in front regardless of their depth (like x-ray).
 
void SetPickClosest (bool theToPreferClosest)
 Set flag determining precedence of picked depth over entity priority in sorted results.
 
SelectMgr_TypeOfDepthTolerance DepthToleranceType () const
 Return the type of tolerance for considering two entities having a similar depth (distance from eye to entity); SelectMgr_TypeOfDepthTolerance_SensitivityFactor by default.
 
Standard_Real DepthTolerance () const
 Return the tolerance for considering two entities having a similar depth (distance from eye to entity).
 
void SetDepthTolerance (SelectMgr_TypeOfDepthTolerance theType, Standard_Real theTolerance)
 Set the tolerance for considering two entities having a similar depth (distance from eye to entity).
 
Standard_Integer NbPicked () const
 Returns the number of detected owners.
 
void ClearPicked ()
 Clears picking results.
 
void Clear ()
 Empties all the tables, removes all selections...
 
Handle< SelectMgr_EntityOwnerPicked (const Standard_Integer theRank) const
 Returns the entity Owner for the object picked at specified position.
 
const SelectMgr_SortCriterionPickedData (const Standard_Integer theRank) const
 Returns the Entity for the object picked at specified position.
 
const Handle< Select3D_SensitiveEntity > & PickedEntity (const Standard_Integer theRank) const
 Returns the Entity for the object picked at specified position.
 
gp_Pnt PickedPoint (const Standard_Integer theRank) const
 Returns the 3D point (intersection of picking axis with the object nearest to eye) for the object picked at specified position.
 
Standard_Boolean RemovePicked (const Handle< SelectMgr_SelectableObject > &theObject)
 Remove picked entities associated with specified object.
 
Standard_Boolean Contains (const Handle< SelectMgr_SelectableObject > &theObject) const
 
const Handle< Select3D_BVHBuilder3dEntitySetBuilder ()
 Returns the default builder used to construct BVH of entity set.
 
void SetEntitySetBuilder (const Handle< Select3D_BVHBuilder3d > &theBuilder)
 Sets the default builder used to construct BVH of entity set. The new builder will be also assigned for already defined objects, but computed BVH trees will not be invalidated.
 
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.
 
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.
 
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.
 
SelectMgr_StateOfSelection Status (const Handle< SelectMgr_Selection > &theSelection) const
 Returns the selection status Status of the selection aSelection.
 
TCollection_AsciiString Status (const Handle< SelectMgr_SelectableObject > &theSelectableObject) const
 
void ActiveOwners (NCollection_List< Handle< SelectMgr_EntityOwner > > &theOwners) const
 Returns the list of active entity owners.
 
void AddSelectableObject (const Handle< SelectMgr_SelectableObject > &theObject)
 Adds new object to the map of selectable objects.
 
void AddSelectionToObject (const Handle< SelectMgr_SelectableObject > &theObject, const Handle< SelectMgr_Selection > &theSelection)
 Adds new selection to the object and builds its BVH tree.
 
void MoveSelectableObject (const Handle< SelectMgr_SelectableObject > &theObject)
 Moves existing object from set of not transform persistence objects to set of transform persistence objects (or vice versa).
 
void RemoveSelectableObject (const Handle< SelectMgr_SelectableObject > &theObject)
 Removes selectable object from map of selectable ones.
 
void RemoveSelectionOfObject (const Handle< SelectMgr_SelectableObject > &theObject, const Handle< SelectMgr_Selection > &theSelection)
 Removes selection of the object and marks its BVH tree for rebuild.
 
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.
 
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.
 
SelectMgr_SelectingVolumeManagerGetManager ()
 Returns instance of selecting volume manager of the viewer selector.
 
const SelectMgr_SelectableObjectSetSelectableObjects () const
 Return map of selectable objects.
 
void ResetSelectionActivationStatus ()
 Marks all added sensitive entities of all objects as non-selectable.
 
void AllowOverlapDetection (const Standard_Boolean theIsToAllow)
 Is used for rectangular selection only If theIsToAllow is false, only fully included sensitives will be detected, otherwise the algorithm will mark both included and overlapped entities as matched.
 
void Pick (const Standard_Integer theXPix, const Standard_Integer theYPix, const Handle< V3d_View > &theView)
 Picks the sensitive entity at the pixel coordinates of the mouse <theXPix> and <theYPix>. The selector looks for touched areas and owners.
 
void Pick (const Standard_Integer theXPMin, const Standard_Integer theYPMin, const Standard_Integer theXPMax, const Standard_Integer theYPMax, const Handle< V3d_View > &theView)
 Picks the sensitive entity according to the minimum and maximum pixel values <theXPMin>, <theYPMin>, <theXPMax> and <theYPMax> defining a 2D area for selection in the 3D view aView.
 
void Pick (const TColgp_Array1OfPnt2d &thePolyline, const Handle< V3d_View > &theView)
 pick action - input pixel values for polyline selection for selection.
 
void Pick (const gp_Ax1 &theAxis, const Handle< V3d_View > &theView)
 Picks the sensitive entity according to the input axis. This is geometric intersection 3D objects by axis (camera parameters are ignored and objects with transform persistance are skipped).
 
Standard_Boolean ToPixMap (Image_PixMap &theImage, const Handle< V3d_View > &theView, const StdSelect_TypeOfSelectionImage theType, const Standard_Integer thePickedIndex=1)
 Dump of detection results into image. This method performs axis picking for each pixel in the image and generates a color depending on picking results and selection image type.
 
void DisplaySensitive (const Handle< V3d_View > &theView)
 Displays sensitives in view <theView>.
 
void ClearSensitive (const Handle< V3d_View > &theView)
 
void DisplaySensitive (const Handle< SelectMgr_Selection > &theSel, const gp_Trsf &theTrsf, const Handle< V3d_View > &theView, const Standard_Boolean theToClearOthers=Standard_True)
 
void DumpJson (Standard_OStream &theOStream, Standard_Integer theDepth=-1) const
 Dumps the content of me into the stream.
 
void SetToPrebuildBVH (Standard_Boolean theToPrebuild, Standard_Integer theThreadsNum=-1)
 Enables/disables building BVH for sensitives in separate threads.
 
void QueueBVHBuild (const Handle< Select3D_SensitiveEntity > &theEntity)
 Queues a sensitive entity to build its BVH.
 
void WaitForBVHBuild ()
 Waits BVH threads finished building.
 
Standard_Boolean ToPrebuildBVH () const
 Returns TRUE if building BVH for sensitives in separate threads is enabled.
 
- Public Member Functions inherited from Standard_Transient
 Standard_Transient ()
 Empty constructor.
 
 Standard_Transient (const Standard_Transient &)
 Copy constructor – does nothing.
 
Standard_Transientoperator= (const Standard_Transient &)
 Assignment operator, needed to avoid copying reference counter.
 
virtual ~Standard_Transient ()
 Destructor must be virtual.
 
virtual const opencascade::handle< Standard_Type > & DynamicType () const
 Returns a type descriptor about this object.
 
Standard_Boolean IsInstance (const opencascade::handle< Standard_Type > &theType) const
 Returns a true value if this is an instance of Type.
 
Standard_Boolean IsInstance (const Standard_CString theTypeName) const
 Returns a true value if this is an instance of TypeName.
 
Standard_Boolean IsKind (const opencascade::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.
 
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.
 
Standard_TransientThis () const
 Returns non-const pointer to this object (like const_cast). For protection against creating handle to objects allocated in stack or call from constructor, it will raise exception Standard_ProgramError if reference counter is zero.
 
Standard_Integer GetRefCount () const noexcept
 Get the reference counter of this object.
 
void IncrementRefCounter () noexcept
 Increments the reference counter of this object.
 
Standard_Integer DecrementRefCounter () noexcept
 Decrements the reference counter of this object; returns the decremented value.
 
virtual void Delete () const
 Memory deallocator for transient classes.
 

Static Public Member Functions

static Handle< Graphic3d_CameraConvertVtkToOccCamera (const IVtk_IView::Handle &theView)
 Converts VTK camera defiened for input view to OCC camera.
 
- Static Public Member Functions inherited from Standard_Transient
static constexpr const charget_type_name ()
 Returns a type descriptor about this object.
 
static const opencascade::handle< Standard_Type > & get_type_descriptor ()
 Returns type descriptor of Standard_Transient class.
 

Additional Inherited Members

- Public Types inherited from Standard_Transient
typedef void base_type
 Returns a type descriptor about this object.
 
- Protected Member Functions inherited from SelectMgr_ViewerSelector
void TraverseSensitives (const Standard_Integer theViewId=-1)
 Traverses BVH containing all added selectable objects and finds candidates for further search of overlap.
 
void traverseObject (const Handle< SelectMgr_SelectableObject > &theObject, const SelectMgr_SelectingVolumeManager &theMgr, const Handle< Graphic3d_Camera > &theCamera, const Graphic3d_Mat4d &theProjectionMat, const Graphic3d_Mat4d &theWorldViewMat, const Graphic3d_Vec2i &theWinSize)
 Internal function that checks if there is possible overlap between some entity of selectable object theObject and current selecting volume.
 
void checkOverlap (const Handle< Select3D_SensitiveEntity > &theEntity, const gp_GTrsf &theInversedTrsf, SelectMgr_SelectingVolumeManager &theMgr)
 Internal function that checks if a particular sensitive entity theEntity overlaps current selecting volume precisely.
 
void updateZLayers (const Handle< V3d_View > &theView)
 Update z-layers order map.
 
- Protected Attributes inherited from SelectMgr_ViewerSelector
Standard_Real myDepthTolerance
 
SelectMgr_TypeOfDepthTolerance myDepthTolType
 
Standard_Boolean myToPreferClosest
 
SelectMgr_IndexedDataMapOfOwnerCriterion mystored
 
SelectMgr_SelectingVolumeManager mySelectingVolumeMgr
 
SelectMgr_SelectableObjectSet mySelectableObjects
 
SelectMgr_ToleranceMap myTolerances
 
NCollection_DataMap< Graphic3d_ZLayerId, Standard_IntegermyZLayerOrderMap
 
Handle< Select3D_BVHBuilder3dmyEntitySetBuilder
 
gp_Pnt myCameraEye
 
gp_Dir myCameraDir
 
Standard_Real myCameraScale
 
Standard_Boolean myToPrebuildBVH
 
Handle< SelectMgr_BVHThreadPoolmyBVHThreadPool
 
TColStd_Array1OfInteger myIndexes
 
Standard_Boolean myIsSorted
 
Standard_Boolean myIsLeftChildQueuedFirst
 
SelectMgr_MapOfObjectSensitives myMapOfObjectSensitives
 
Graphic3d_SequenceOfStructure myStructs
 list of debug presentations
 

Detailed Description

Class that implements OCCT selection algorithm.

Inspired by StdSelect_ViewerSelector3d class from OCCT 6.5.1

Constructor & Destructor Documentation

◆ IVtkOCC_ViewerSelector()

IVtkOCC_ViewerSelector::IVtkOCC_ViewerSelector ( )

◆ ~IVtkOCC_ViewerSelector()

virtual IVtkOCC_ViewerSelector::~IVtkOCC_ViewerSelector ( )
virtual

Member Function Documentation

◆ Activate()

void IVtkOCC_ViewerSelector::Activate ( const Handle< SelectMgr_Selection > &  theSelection)

Activates the given selection.

◆ ConvertVtkToOccCamera()

static Handle< Graphic3d_Camera > IVtkOCC_ViewerSelector::ConvertVtkToOccCamera ( const IVtk_IView::Handle theView)
static

Converts VTK camera defiened for input view to OCC camera.

◆ Deactivate()

void IVtkOCC_ViewerSelector::Deactivate ( const Handle< SelectMgr_Selection > &  theSelection)

Deactivate the given selection.

◆ Pick() [1/3]

void IVtkOCC_ViewerSelector::Pick ( const Standard_Integer  theXMin,
const Standard_Integer  theYMin,
const Standard_Integer  theXMax,
const Standard_Integer  theYMax,
const IVtk_IView::Handle theView 
)

Picking by rectangle.

Parameters
[in]theXMin,theYMin,theXMax,theYMaxRectangle coords
[in]theViewICamera interface to calculate projections

◆ Pick() [2/3]

void IVtkOCC_ViewerSelector::Pick ( const Standard_Integer  theXPix,
const Standard_Integer  theYPix,
const IVtk_IView::Handle theView 
)

Implements point picking.

Parameters
[in]theXPix,theYPixDisplay coordinates of the point
[in]theViewICamera interface to update the projection parameters.

◆ Pick() [3/3]

void IVtkOCC_ViewerSelector::Pick ( double **  thePoly,
const int  theNbPoints,
const IVtk_IView::Handle theView 
)

Implements point picking.


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