0027953: Foundation Classes - eliminate global variables from OSD_Path
[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>
825aa485 23#include <Graphic3d_WorldViewProjState.hxx>
f751596e 24
25#include <SelectMgr_BaseFrustum.hxx>
26#include <SelectMgr_RectangularFrustum.hxx>
27#include <SelectMgr_TriangularFrustumSet.hxx>
28#include <SelectBasics_SelectingVolumeManager.hxx>
29
30//! This class is used to switch between active selecting volumes depending
31//! on selection type chosen by the user
32class SelectMgr_SelectingVolumeManager : public SelectBasics_SelectingVolumeManager
33{
34public:
35
36 //! Creates instances of all available selecting volume types
37 Standard_EXPORT SelectMgr_SelectingVolumeManager (Standard_Boolean theToAllocateFrustums = Standard_True);
38
be5c3602 39 virtual ~SelectMgr_SelectingVolumeManager() {};
f751596e 40
3bf9a45f 41 //! IMPORTANT: Scaling makes sense only for frustum built on a single point!
42 //! Note that this method does not perform any checks on type of the frustum.
43 //!
28ee613b 44 //! Returns a copy of the frustum resized according to the scale factor given
3bf9a45f 45 //! and transforms it using the matrix given.
46 //! There are no default parameters, but in case if:
47 //! - transformation only is needed: @theScaleFactor must be initialized as any negative value;
48 //! - scale only is needed: @theTrsf must be set to gp_Identity.
099f3513 49 //! Builder is an optional argument that represents corresponding settings for re-constructing transformed
50 //! frustum from scratch. Can be null if reconstruction is not expected furthermore.
3bf9a45f 51 Standard_EXPORT virtual SelectMgr_SelectingVolumeManager ScaleAndTransform (const Standard_Integer theScaleFactor,
099f3513 52 const gp_GTrsf& theTrsf,
53 const Handle(SelectMgr_FrustumBuilder)& theBuilder = NULL) const;
28ee613b 54
7ab15952 55 Standard_EXPORT virtual Standard_Integer GetActiveSelectionType() const Standard_OVERRIDE;
f751596e 56
57 Standard_EXPORT void SetActiveSelectionType (const SelectionType& theType);
58
3fe9ce0e 59 //! Returns current camera definition.
60 const Handle(Graphic3d_Camera)& Camera() const { return mySelectingVolumes[Frustum]->Camera(); }
61
f751596e 62 //! Updates camera projection and orientation matrices in all selecting volumes
63 Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera) theCamera);
64
65 //! Updates camera projection and orientation matrices in all selecting volumes
66 Standard_EXPORT void SetCamera (const Graphic3d_Mat4d& theProjection,
825aa485 67 const Graphic3d_Mat4d& theWorldView,
68 const Standard_Boolean theIsOrthographic,
69 const Graphic3d_WorldViewProjState& theWVPState = Graphic3d_WorldViewProjState());
70
71 //! @return current projection transformation common for all selecting volumes
72 Standard_EXPORT const Graphic3d_Mat4d& ProjectionMatrix() const;
73
74 //! @return current world view transformation common for all selecting volumes
75 Standard_EXPORT const Graphic3d_Mat4d& WorldViewMatrix() const;
76
099f3513 77 Standard_EXPORT void WindowSize (Standard_Integer& theWidth, Standard_Integer& theHeight) const;
91d96372 78
825aa485 79 //! @return current camera world view projection transformation state common for all selecting volumes
80 Standard_EXPORT const Graphic3d_WorldViewProjState& WorldViewProjState() const;
f751596e 81
82 //! Updates viewport in all selecting volumes
83 Standard_EXPORT void SetViewport (const Standard_Real theX,
84 const Standard_Real theY,
85 const Standard_Real theWidth,
86 const Standard_Real theHeight);
87
88 //! Updates pixel tolerance in all selecting volumes
3bf9a45f 89 Standard_EXPORT void SetPixelTolerance (const Standard_Integer theTolerance);
f751596e 90
91 //! Updates window size in all selecting volumes
92 Standard_EXPORT void SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight);
93
94
95 //! Builds rectangular selecting frustum for point selection
96 Standard_EXPORT void BuildSelectingVolume (const gp_Pnt2d& thePoint);
97
98 //! Builds rectangular selecting frustum for box selection
99 Standard_EXPORT void BuildSelectingVolume (const gp_Pnt2d& theMinPt,
100 const gp_Pnt2d& theMaxPt);
101
102 //! Builds set of triangular selecting frustums for polyline selection
103 Standard_EXPORT void BuildSelectingVolume (const TColgp_Array1OfPnt2d& thePoints);
104
105
106 //! SAT intersection test between defined volume and given axis-aligned box
3bf9a45f 107 Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
108 const SelectMgr_Vec3& theBoxMax,
7ab15952 109 Standard_Real& theDepth) Standard_OVERRIDE;
f751596e 110
111 //! Returns true if selecting volume is overlapped by axis-aligned bounding box
112 //! with minimum corner at point theMinPt and maximum at point theMaxPt
2157d6ac 113 Standard_EXPORT virtual Standard_Boolean Overlaps (const SelectMgr_Vec3& theBoxMin,
114 const SelectMgr_Vec3& theBoxMax,
115 Standard_Boolean* theInside = NULL) Standard_OVERRIDE;
f751596e 116
117 //! Intersection test between defined volume and given point
3bf9a45f 118 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt,
7ab15952 119 Standard_Real& theDepth) Standard_OVERRIDE;
f751596e 120
3bf9a45f 121 //! Intersection test between defined volume and given point
122 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt) Standard_OVERRIDE;
123
f751596e 124 //! SAT intersection test between defined volume and given ordered set of points,
125 //! representing line segments. The test may be considered of interior part or
126 //! boundary line defined by segments depending on given sensitivity type
7ab15952 127 Standard_EXPORT virtual Standard_Boolean Overlaps (const Handle(TColgp_HArray1OfPnt)& theArrayOfPts,
128 Standard_Integer theSensType,
114b7bf1 129 Standard_Real& theDepth) Standard_OVERRIDE;
130
131 //! SAT intersection test between defined volume and given ordered set of points,
132 //! representing line segments. The test may be considered of interior part or
133 //! boundary line defined by segments depending on given sensitivity type
134 Standard_EXPORT virtual Standard_Boolean Overlaps (const TColgp_Array1OfPnt& theArrayOfPts,
135 Standard_Integer theSensType,
7ab15952 136 Standard_Real& theDepth) Standard_OVERRIDE;
f751596e 137
138 //! Checks if line segment overlaps selecting frustum
3bf9a45f 139 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
140 const gp_Pnt& thePnt2,
7ab15952 141 Standard_Real& theDepth) Standard_OVERRIDE;
f751596e 142
143 //! SAT intersection test between defined volume and given triangle. The test may
144 //! be considered of interior part or boundary line defined by triangle vertices
145 //! depending on given sensitivity type
3bf9a45f 146 Standard_EXPORT virtual Standard_Boolean Overlaps (const gp_Pnt& thePnt1,
147 const gp_Pnt& thePnt2,
148 const gp_Pnt& thePnt3,
7ab15952 149 Standard_Integer theSensType,
150 Standard_Real& theDepth) Standard_OVERRIDE;
f751596e 151
152
153 //! Measures distance between 3d projection of user-picked
154 //! screen point and given point theCOG
7ab15952 155 Standard_EXPORT virtual Standard_Real DistToGeometryCenter (const gp_Pnt& theCOG) Standard_OVERRIDE;
f751596e 156
949c9b7f 157 //! Calculates the point on a view ray that was detected during the run of selection algo by given depth.
158 //! Throws exception if active selection type is not Point.
3bf9a45f 159 Standard_EXPORT virtual gp_Pnt DetectedPoint (const Standard_Real theDepth) const Standard_OVERRIDE;
f751596e 160
161 //! Checks if the point of sensitive in which selection was detected belongs
162 //! to the region defined by clipping planes
7ab15952 163 Standard_EXPORT virtual Standard_Boolean IsClipped (const Graphic3d_SequenceOfHClipPlane& thePlanes,
164 const Standard_Real& theDepth);
f751596e 165
2157d6ac 166 //! Is used for rectangular selection only
167 //! If theIsToAllow is false, only fully included sensitives will be detected, otherwise the algorithm will
168 //! mark both included and overlapped entities as matched
169 Standard_EXPORT virtual void AllowOverlapDetection (const Standard_Boolean theIsToAllow);
170
171 Standard_EXPORT virtual Standard_Boolean IsOverlapAllowed() const Standard_OVERRIDE;
172
e9312c0f 173 //! Valid for point selection only!
174 //! Computes depth range for global (defined for the whole view) clipping planes.
3202bf1e 175 Standard_EXPORT void SetViewClipping (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes);
176
177 //! Set if view clipping plane is enabled or not.
178 //! @return previous flag value
179 Standard_EXPORT Standard_Boolean SetViewClippingEnabled (const Standard_Boolean theToEnable);
e9312c0f 180
3bf9a45f 181 //! A set of helper functions that return rectangular selecting frustum data
182 Standard_EXPORT const gp_Pnt* GetVertices() const;
183
21a8e275 184 //! Valid only for point and rectangular selection.
185 //! Returns projection of 2d mouse picked point or projection
186 //! of center of 2d rectangle (for point and rectangular selection
187 //! correspondingly) onto near view frustum plane
188 Standard_EXPORT virtual gp_Pnt GetNearPickedPnt() const Standard_OVERRIDE;
189
190 //! Valid only for point and rectangular selection.
191 //! Returns projection of 2d mouse picked point or projection
192 //! of center of 2d rectangle (for point and rectangular selection
193 //! correspondingly) onto far view frustum plane
194 Standard_EXPORT virtual gp_Pnt GetFarPickedPnt() const Standard_OVERRIDE;
3bf9a45f 195
f751596e 196private:
197 enum { Frustum, FrustumSet, VolumeTypesNb }; //!< Defines the amount of available selecting volumes
198
099f3513 199 Handle(SelectMgr_BaseFrustum) mySelectingVolumes[VolumeTypesNb]; //!< Array of selecting volumes
200 Standard_Boolean myToAllowOverlap; //!< Defines if partially overlapped entities will me detected or not
f751596e 201};
202
099f3513 203#endif