1 // Created on: 2015-06-30
2 // Created by: Anton POLETAEV
3 // Copyright (c) 2015 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 #ifndef _Graphic3d_WorldViewProjState_HeaderFile
17 #define _Graphic3d_WorldViewProjState_HeaderFile
19 #include <Standard_Transient.hxx>
20 #include <Standard_TypeDef.hxx>
22 //! Helper class for keeping reference on world-view-projection state.
23 //! Helpful for synchronizing state of WVP dependent data structures.
24 class Graphic3d_WorldViewProjState
28 //! Default constructor.
29 Graphic3d_WorldViewProjState()
34 //! Constructor for custom projector type.
35 //! @param theProjectionState [in] the projection state.
36 //! @param theWorldViewState [in] the world view state.
37 //! @param theCamera [in] the pointer to the class supplying projection and
38 //! world view matrices (camera).
39 Graphic3d_WorldViewProjState (const Standard_Size theProjectionState,
40 const Standard_Size theWorldViewState,
41 const Standard_Transient* theCamera = NULL)
43 Initialize (theProjectionState, theWorldViewState, theCamera);
48 //! Check state validity.
49 //! @return true if state is set.
50 Standard_Boolean IsValid()
55 //! Invalidate world view projection state.
58 myIsValid = Standard_False;
60 myProjectionState = 0;
64 //! Initialize world view projection state.
65 void Initialize (const Standard_Size theProjectionState,
66 const Standard_Size theWorldViewState,
67 const Standard_Transient* theCamera = NULL)
69 myIsValid = Standard_True;
70 myCamera = const_cast<Standard_Transient*> (theCamera);
71 myProjectionState = theProjectionState;
72 myWorldViewState = theWorldViewState;
75 //! Initialize world view projection state.
76 void Initialize (const Standard_Transient* theCamera = NULL)
78 myIsValid = Standard_True;
79 myCamera = const_cast<Standard_Transient*> (theCamera);
80 myProjectionState = 0;
86 //! @return projection state counter.
87 Standard_Size& ProjectionState()
89 return myProjectionState;
92 //! @return world view state counter.
93 Standard_Size& WorldViewState()
95 return myWorldViewState;
100 //! Compare projection with other state.
101 //! @return true when the projection of the given camera state differs from this one.
102 Standard_Boolean IsProjectionChanged (const Graphic3d_WorldViewProjState& theState)
104 return myIsValid != theState.myIsValid
105 || myCamera != theState.myCamera
106 || myProjectionState != theState.myProjectionState;
109 //! Compare world view transformation with other state.
110 //! @return true when the orientation of the given camera state differs from this one.
111 Standard_Boolean IsWorldViewChanged (const Graphic3d_WorldViewProjState& theState)
113 return myIsValid != theState.myIsValid
114 || myCamera != theState.myCamera
115 || myWorldViewState != theState.myWorldViewState;
118 //! Compare with other world view projection state.
119 //! @return true when the projection of the given camera state differs from this one.
120 Standard_Boolean IsChanged (const Graphic3d_WorldViewProjState& theState)
122 return *this != theState;
127 //! Compare with other world view projection state.
128 //! @return true if the other projection state is different to this one.
129 bool operator != (const Graphic3d_WorldViewProjState& theOther) const
131 return !(*this == theOther);
134 //! Compare with other world view projection state.
135 //! @return true if the other projection state is equal to this one.
136 bool operator == (const Graphic3d_WorldViewProjState& theOther) const
138 return myIsValid == theOther.myIsValid
139 && myCamera == theOther.myCamera
140 && myProjectionState == theOther.myProjectionState
141 && myWorldViewState == theOther.myWorldViewState;
144 //! Copy world view projection state.
145 void operator = (const Graphic3d_WorldViewProjState& theOther)
147 myIsValid = theOther.myIsValid;
148 myCamera = theOther.myCamera;
149 myProjectionState = theOther.myProjectionState;
150 myWorldViewState = theOther.myWorldViewState;
155 Standard_Boolean myIsValid;
156 Standard_Transient* myCamera;
157 Standard_Size myProjectionState;
158 Standard_Size myWorldViewState;