1 // Created on: 2014-05-22
2 // Created by: Varvara POSKONINA
3 // Copyright (c) 2005-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #include <SelectMgr_BaseFrustum.hxx>
18 #include <Message.hxx>
19 #include <SelectMgr_FrustumBuilder.hxx>
20 #include <Standard_Dump.hxx>
22 IMPLEMENT_STANDARD_RTTIEXT(SelectMgr_BaseFrustum, SelectMgr_BaseIntersector)
24 //=======================================================================
25 // function : SelectMgr_BaseFrustum
27 //=======================================================================
28 SelectMgr_BaseFrustum::SelectMgr_BaseFrustum()
29 : myPixelTolerance (2),
30 myIsOrthographic (Standard_True)
32 myBuilder = new SelectMgr_FrustumBuilder();
35 //=======================================================================
36 // function : SetCamera
37 // purpose : Passes camera projection and orientation matrices to builder
38 //=======================================================================
39 void SelectMgr_BaseFrustum::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
42 myBuilder->SetWorldViewMatrix (theCamera->OrientationMatrix());
43 myBuilder->SetProjectionMatrix (theCamera->ProjectionMatrix(), theCamera->IsZeroToOneDepth());
44 myBuilder->SetWorldViewProjState (theCamera->WorldViewProjState());
45 myIsOrthographic = theCamera->IsOrthographic();
46 myBuilder->InvalidateViewport();
49 //=======================================================================
50 // function : SetCamera
51 // purpose : Passes camera projection and orientation matrices to builder
52 //=======================================================================
53 void SelectMgr_BaseFrustum::SetCamera (const Graphic3d_Mat4d& theProjection,
54 const Graphic3d_Mat4d& theWorldView,
55 const Standard_Boolean theIsOrthographic,
56 const Graphic3d_WorldViewProjState& theWVPState)
59 myBuilder->SetWorldViewMatrix (theWorldView);
60 myBuilder->SetProjectionMatrix (theProjection, false);
61 myBuilder->SetWorldViewProjState (theWVPState);
62 myIsOrthographic = theIsOrthographic;
65 //=======================================================================
66 // function : ProjectionMatrix
67 // purpose : Returns current camera projection transformation common for
68 // all selecting volumes
69 //=======================================================================
70 const Graphic3d_Mat4d& SelectMgr_BaseFrustum::ProjectionMatrix() const
72 return myBuilder->ProjectionMatrix();
75 //=======================================================================
76 // function : WorldViewMatrix
77 // purpose : Returns current camera world view transformation common for
78 // all selecting volumes
79 //=======================================================================
80 const Graphic3d_Mat4d& SelectMgr_BaseFrustum::WorldViewMatrix() const
82 return myBuilder->WorldViewMatrix();
85 //=======================================================================
86 // function : WorldViewProjState
87 // purpose : Returns current camera world view projection transformation
89 //=======================================================================
90 const Graphic3d_WorldViewProjState& SelectMgr_BaseFrustum::WorldViewProjState() const
92 return myBuilder->WorldViewProjState();
95 //=======================================================================
96 // function : SetViewport
97 // purpose : Passes viewport parameters to builder
98 //=======================================================================
99 void SelectMgr_BaseFrustum::SetViewport (const Standard_Real theX,
100 const Standard_Real theY,
101 const Standard_Real theWidth,
102 const Standard_Real theHeight)
104 myBuilder->SetViewport (theX, theY, theWidth, theHeight);
107 //=======================================================================
108 // function : SetPixelTolerance
110 //=======================================================================
111 void SelectMgr_BaseFrustum::SetPixelTolerance (const Standard_Integer theTol)
113 myPixelTolerance = theTol;
116 //=======================================================================
117 // function : SetWindowSize
119 //=======================================================================
120 void SelectMgr_BaseFrustum::SetWindowSize (const Standard_Integer theWidth, const Standard_Integer theHeight)
122 myBuilder->SetWindowSize (theWidth, theHeight);
125 //=======================================================================
126 // function : WindowSize
128 //=======================================================================
129 void SelectMgr_BaseFrustum::WindowSize (Standard_Integer& theWidth,
130 Standard_Integer& theHeight) const
132 myBuilder->WindowSize (theWidth, theHeight);
135 //=======================================================================
136 // function : SetBuilder
138 //=======================================================================
139 void SelectMgr_BaseFrustum::SetBuilder (const Handle(SelectMgr_FrustumBuilder)& theBuilder)
142 myBuilder = theBuilder;
145 //=======================================================================
146 //function : DumpJson
148 //=======================================================================
149 void SelectMgr_BaseFrustum::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
151 OCCT_DUMP_CLASS_BEGIN (theOStream, SelectMgr_BaseFrustum)
152 OCCT_DUMP_BASE_CLASS (theOStream, theDepth, SelectMgr_BaseIntersector)
154 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myPixelTolerance)
155 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsOrthographic)
156 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myBuilder)
157 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, myCamera)