0031221: Visualization - selection filter in context
[occt.git] / src / SelectMgr / SelectMgr_BaseFrustum.cxx
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#include <SelectMgr_BaseFrustum.hxx>
17
0904aa63 18#include <Message.hxx>
19
20#include <Standard_Dump.hxx>
21
92efcf78 22IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum,Standard_Transient)
23
f751596e 24//=======================================================================
25// function : SelectMgr_SelectingVolume
26// purpose : Creates new selecting volume with pixel toletance set to 2,
27// orthographic camera and empty frustum builder
28//=======================================================================
29SelectMgr_BaseFrustum::SelectMgr_BaseFrustum()
30: myPixelTolerance (2),
31 myIsOrthographic (Standard_True)
32{
33 myBuilder = new SelectMgr_FrustumBuilder();
34}
35
36//=======================================================================
37// function : SetCamera
38// purpose : Passes camera projection and orientation matrices to builder
39//=======================================================================
40void SelectMgr_BaseFrustum::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
41{
3fe9ce0e 42 myCamera = theCamera;
825aa485 43 myBuilder->SetWorldViewMatrix (theCamera->OrientationMatrix());
44 myBuilder->SetProjectionMatrix (theCamera->ProjectionMatrix());
45 myBuilder->SetWorldViewProjState (theCamera->WorldViewProjState());
f751596e 46 myIsOrthographic = theCamera->IsOrthographic();
47 myBuilder->InvalidateViewport();
48}
49
50//=======================================================================
51// function : SetCamera
52// purpose : Passes camera projection and orientation matrices to builder
53//=======================================================================
54void SelectMgr_BaseFrustum::SetCamera (const Graphic3d_Mat4d& theProjection,
825aa485 55 const Graphic3d_Mat4d& theWorldView,
dde68833 56 const Standard_Boolean theIsOrthographic,
825aa485 57 const Graphic3d_WorldViewProjState& theWVPState)
f751596e 58{
3fe9ce0e 59 myCamera.Nullify();
825aa485 60 myBuilder->SetWorldViewMatrix (theWorldView);
61 myBuilder->SetProjectionMatrix (theProjection);
62 myBuilder->SetWorldViewProjState (theWVPState);
f751596e 63 myIsOrthographic = theIsOrthographic;
64}
65
66//=======================================================================
825aa485 67// function : ProjectionMatrix
68// purpose : Returns current camera projection transformation common for
69// all selecting volumes
70//=======================================================================
71const Graphic3d_Mat4d& SelectMgr_BaseFrustum::ProjectionMatrix() const
72{
73 return myBuilder->ProjectionMatrix();
74}
75
76//=======================================================================
77// function : WorldViewMatrix
78// purpose : Returns current camera world view transformation common for
79// all selecting volumes
80//=======================================================================
81const Graphic3d_Mat4d& SelectMgr_BaseFrustum::WorldViewMatrix() const
82{
83 return myBuilder->WorldViewMatrix();
84}
85
86//=======================================================================
87// function : WorldViewProjState
88// purpose : Returns current camera world view projection transformation
89// state
90//=======================================================================
91const Graphic3d_WorldViewProjState& SelectMgr_BaseFrustum::WorldViewProjState() const
92{
93 return myBuilder->WorldViewProjState();
94}
95
96//=======================================================================
f751596e 97// function : SetViewport
98// purpose : Passes viewport parameters to builder
99//=======================================================================
100void SelectMgr_BaseFrustum::SetViewport (const Standard_Real theX,
101 const Standard_Real theY,
102 const Standard_Real theWidth,
103 const Standard_Real theHeight)
104{
105 myBuilder->SetViewport (theX, theY, theWidth, theHeight);
106}
107
108//=======================================================================
109// function : SetPixelTolerance
110// purpose :
111//=======================================================================
3bf9a45f 112void SelectMgr_BaseFrustum::SetPixelTolerance (const Standard_Integer theTol)
f751596e 113{
114 myPixelTolerance = theTol;
115}
116
117//=======================================================================
118// function : SetWindowSize
119// purpose :
120//=======================================================================
121void SelectMgr_BaseFrustum::SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight)
122{
123 myBuilder->SetWindowSize (theWidth, theHeight);
124}
125
91d96372 126//=======================================================================
127// function : WindowSize
128// purpose :
129//=======================================================================
130void SelectMgr_BaseFrustum::WindowSize (Standard_Integer& theWidth,
099f3513 131 Standard_Integer& theHeight) const
91d96372 132{
133 myBuilder->WindowSize (theWidth, theHeight);
134}
135
f751596e 136//=======================================================================
137// function : SetBuilder
138// purpose :
139//=======================================================================
bf3977c9 140void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder)
f751596e 141{
142 myBuilder.Nullify();
143 myBuilder = theBuilder;
144}
145
146//=======================================================================
147// function : Overlaps
148// purpose : SAT intersection test between defined volume and
149// given axis-aligned box
150//=======================================================================
3bf9a45f 151Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
152 const SelectMgr_Vec3& /*theBoxMax*/,
d7fa57a7 153 const SelectMgr_ViewClipRange& /*theClipRange*/,
4a056d20 154 SelectBasics_PickResult& /*thePickResult*/) const
f751596e 155{
156 return Standard_False;
157}
158
159//=======================================================================
160// function : Overlaps
161// purpose : Intersection test between defined volume and given point
162//=======================================================================
2157d6ac 163Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const SelectMgr_Vec3& /*theBoxMin*/,
164 const SelectMgr_Vec3& /*theBoxMax*/,
4a056d20 165 Standard_Boolean* /*theInside*/) const
f751596e 166{
167 return Standard_False;
168}
169
170//=======================================================================
171// function : Overlaps
172// purpose : Intersection test between defined volume and given point
173//=======================================================================
3bf9a45f 174Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/,
d7fa57a7 175 const SelectMgr_ViewClipRange& /*theClipRange*/,
4a056d20 176 SelectBasics_PickResult& ) const
f751596e 177{
178 return Standard_False;
179}
180
3bf9a45f 181//=======================================================================
182// function : Overlaps
183// purpose : Intersection test between defined volume and given point
184//=======================================================================
4a056d20 185Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt*/) const
3bf9a45f 186{
187 return Standard_False;
188}
189
f751596e 190//=======================================================================
191// function : Overlaps
192// purpose : SAT intersection test between defined volume and given
193// ordered set of points, representing line segments. The test
194// may be considered of interior part or boundary line defined
195// by segments depending on given sensitivity type
196//=======================================================================
114b7bf1 197Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const TColgp_Array1OfPnt& /*theArrayOfPnts*/,
7ab15952 198 Select3D_TypeOfSensitivity /*theSensType*/,
d7fa57a7 199 const SelectMgr_ViewClipRange& /*theClipRange*/,
4a056d20 200 SelectBasics_PickResult& ) const
f751596e 201{
202 return Standard_False;
203}
204
205//=======================================================================
206// function : Overlaps
207// purpose : SAT intersection test between defined volume and given
208// triangle. The test may be considered of interior part or
209// boundary line defined by triangle vertices depending on
210// given sensitivity type
211//=======================================================================
7ab15952 212Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePt1*/,
213 const gp_Pnt& /*thePt2*/,
214 const gp_Pnt& /*thePt3*/,
215 Select3D_TypeOfSensitivity /*theSensType*/,
d7fa57a7 216 const SelectMgr_ViewClipRange& /*theClipRange*/,
4a056d20 217 SelectBasics_PickResult& ) const
f751596e 218{
219 return Standard_False;
220}
221
222//=======================================================================
223// function : Overlaps
224// purpose : Checks if line segment overlaps selecting volume
225//=======================================================================
3bf9a45f 226Standard_Boolean SelectMgr_BaseFrustum::Overlaps (const gp_Pnt& /*thePnt1*/,
227 const gp_Pnt& /*thePnt2*/,
d7fa57a7 228 const SelectMgr_ViewClipRange& /*theClipRange*/,
4a056d20 229 SelectBasics_PickResult& ) const
f751596e 230{
231 return Standard_False;
232}
233
234//=======================================================================
235// function : DistToGeometryCenter
236// purpose : Measures distance between 3d projection of user-picked
237// screen point and given point theCOG
238//=======================================================================
4a056d20 239Standard_Real SelectMgr_BaseFrustum::DistToGeometryCenter (const gp_Pnt& /*theCOG*/) const
f751596e 240{
241 return DBL_MAX;
242}
243
e9312c0f 244//=======================================================================
245// function : DetectedPoint
246// purpose :
247//=======================================================================
3bf9a45f 248gp_Pnt SelectMgr_BaseFrustum::DetectedPoint (const Standard_Real /*theDepth*/) const
f751596e 249{
3bf9a45f 250 return gp_Pnt (RealLast(), RealLast(), RealLast());
f751596e 251}
0904aa63 252
253//=======================================================================
254//function : DumpJson
255//purpose :
256//=======================================================================
bc73b006 257void SelectMgr_BaseFrustum::DumpJson (Standard_OStream& theOStream, Standard_Integer) const
0904aa63 258{
bc73b006 259 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
0904aa63 260
bc73b006 261 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPixelTolerance)
262 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsOrthographic)
263 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myBuilder)
264 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCamera)
0904aa63 265}