0026147: Visualization - restore the ability to pick only fully included objects...
[occt.git] / src / SelectMgr / SelectMgr_SelectingVolumeManager.hxx
CommitLineData
f751596e 1// Created on: 2014-05-22
2// Created by: Varvara POSKONINA
3// Copyright (c) 2005-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _SelectMgr_SelectingVolumeManager_HeaderFile
17#define _SelectMgr_SelectingVolumeManager_HeaderFile
18
19#include <NCollection_Handle.hxx>
20
21#include <Graphic3d_Camera.hxx>
22#include <Graphic3d_SequenceOfHClipPlane.hxx>
23
24#include <SelectMgr_BaseFrustum.hxx>
25#include <SelectMgr_RectangularFrustum.hxx>
26#include <SelectMgr_TriangularFrustumSet.hxx>
27#include <SelectBasics_SelectingVolumeManager.hxx>
28
29//! This class is used to switch between active selecting volumes depending
30//! on selection type chosen by the user
31class SelectMgr_SelectingVolumeManager : public SelectBasics_SelectingVolumeManager
32{
33public:
34
35 //! Creates instances of all available selecting volume types
36 Standard_EXPORT SelectMgr_SelectingVolumeManager (Standard_Boolean theToAllocateFrustums = Standard_True);
37
38 Standard_EXPORT virtual ~SelectMgr_SelectingVolumeManager() {};
39
40 //! Returns a copy of active frustum transformed according to the matrix given
41 Standard_EXPORT virtual SelectMgr_SelectingVolumeManager Transform (const gp_Trsf& theTrsf);
42
28ee613b 43 //! IMPORTANT: Makes sense only for point selection!
44 //! Returns a copy of the frustum resized according to the scale factor given
45 Standard_EXPORT virtual SelectMgr_SelectingVolumeManager Scale (const Standard_Real theScaleFactor);
46
7ab15952 47 Standard_EXPORT virtual Standard_Integer GetActiveSelectionType() const Standard_OVERRIDE;
f751596e 48
49 Standard_EXPORT void SetActiveSelectionType (const SelectionType& theType);
50
51 //! Updates camera projection and orientation matrices in all selecting volumes
52 Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera) theCamera);
53
54 //! Updates camera projection and orientation matrices in all selecting volumes
55 Standard_EXPORT void SetCamera (const Graphic3d_Mat4d& theProjection,
56 const Graphic3d_Mat4d& theOrientation,
57 const Standard_Boolean theIsOrthographic);
58
59 //! Updates viewport in all selecting volumes
60 Standard_EXPORT void SetViewport (const Standard_Real theX,
61 const Standard_Real theY,
62 const Standard_Real theWidth,
63 const Standard_Real theHeight);
64
65 //! Updates pixel tolerance in all selecting volumes
66 Standard_EXPORT void SetPixelTolerance (const Standard_Real theTolerance);
67
68 //! Updates window size in all selecting volumes
69 Standard_EXPORT void SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight);
70
71
72 //! Builds rectangular selecting frustum for point selection
73 Standard_EXPORT void BuildSelectingVolume (const gp_Pnt2d& thePoint);
74
75 //! Builds rectangular selecting frustum for box selection
76 Standard_EXPORT void BuildSelectingVolume (const gp_Pnt2d& theMinPt,
77 const gp_Pnt2d& theMaxPt);
78
79 //! Builds set of triangular selecting frustums for polyline selection
80 Standard_EXPORT void BuildSelectingVolume (const TColgp_Array1OfPnt2d& thePoints);
81
82
83 //! SAT intersection test between defined volume and given axis-aligned box
7ab15952 84 Standard_EXPORT virtual Standard_Boolean Overlaps (const BVH_Box<Standard_Real, 3>& theBndBox,
85 Standard_Real& theDepth) Standard_OVERRIDE;
f751596e 86
87 //! Returns true if selecting volume is overlapped by axis-aligned bounding box
88 //! with minimum corner at point theMinPt and maximum at point theMaxPt
2157d6ac 89 Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
90 const SelectMgr_Vec3& theBoxMax,
91 Standard_Boolean* theInside = NULL) Standard_OVERRIDE;
f751596e 92
93 //! Intersection test between defined volume and given point
7ab15952 94 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePt,
95 Standard_Real& theDepth) Standard_OVERRIDE;
f751596e 96
97 //! SAT intersection test between defined volume and given ordered set of points,
98 //! representing line segments. The test may be considered of interior part or
99 //! boundary line defined by segments depending on given sensitivity type
7ab15952 100 Standard_EXPORT virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
101 Standard_Integer theSensType,
102 Standard_Real& theDepth) Standard_OVERRIDE;
f751596e 103
104 //! Checks if line segment overlaps selecting frustum
7ab15952 105 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1,
106 const gp_Pnt& thePt2,
107 Standard_Real& theDepth) Standard_OVERRIDE;
f751596e 108
109 //! SAT intersection test between defined volume and given triangle. The test may
110 //! be considered of interior part or boundary line defined by triangle vertices
111 //! depending on given sensitivity type
7ab15952 112 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePt1,
113 const gp_Pnt& thePt2,
114 const gp_Pnt& thePt3,
115 Standard_Integer theSensType,
116 Standard_Real& theDepth) Standard_OVERRIDE;
f751596e 117
118
119 //! Measures distance between 3d projection of user-picked
120 //! screen point and given point theCOG
7ab15952 121 Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) Standard_OVERRIDE;
f751596e 122
123 //! Calculates the point on a view ray that was detected during the run of selection algo by given depth. Is valid for point
124 //! selection only
125 Standard_EXPORT virtual NCollection_Vec3<Standard_Real> DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
126
127 //! Checks if the point of sensitive in which selection was detected belongs
128 //! to the region defined by clipping planes
7ab15952 129 Standard_EXPORT virtual Standard_Boolean IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes,
130 const Standard_Real& theDepth);
f751596e 131
2157d6ac 132 //! Is used for rectangular selection only
133 //! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the algorithm will
134 //! mark both included and overlapped entities as matched
135 Standard_EXPORT virtual void AllowOverlapDetection (const Standard_Boolean theIsToAllow);
136
137 Standard_EXPORT virtual Standard_Boolean IsOverlapAllowed() const Standard_OVERRIDE;
138
f751596e 139private:
140 enum { Frustum, FrustumSet, VolumeTypesNb }; //!< Defines the amount of available selecting volumes
141
142 NCollection_Handle<SelectMgr_BaseFrustum> mySelectingVolumes[VolumeTypesNb]; //!< Array of selecting volumes
2157d6ac 143 Standard_Boolean myToAllowOverlap; //!< Defines if partially overlapped entities will me detected or not
f751596e 144};
145
146#endif