30f0ad28 |
1 | // Created on: 2013-10-02 |
2 | // Created by: Denis BOGOLEPOV |
d5f74e42 |
3 | // Copyright (c) 2013-2014 OPEN CASCADE SAS |
30f0ad28 |
4 | // |
973c2be1 |
5 | // This file is part of Open CASCADE Technology software library. |
30f0ad28 |
6 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
30f0ad28 |
12 | // |
973c2be1 |
13 | // Alternatively, this file may be used under the terms of Open CASCADE |
14 | // commercial license or contractual agreement. |
30f0ad28 |
15 | |
16 | #ifndef _OpenGl_State_HeaderFile |
17 | #define _OpenGl_State_HeaderFile |
18 | |
30f0ad28 |
19 | #include <InterfaceGraphic_tgl_all.hxx> |
e135a155 |
20 | #include <NCollection_List.hxx> |
30f0ad28 |
21 | #include <OpenGl_Element.hxx> |
22 | #include <OpenGl_Light.hxx> |
c827ea3a |
23 | #include <OpenGl_Vec.hxx> |
ca102800 |
24 | |
30f0ad28 |
25 | //! Defines interface for OpenGL state. |
26 | class OpenGl_StateInterface |
27 | { |
28 | public: |
29 | |
8cf06aa2 |
30 | //! Creates new state. |
30f0ad28 |
31 | OpenGl_StateInterface(); |
32 | |
33 | //! Returns current state index. |
8cf06aa2 |
34 | Standard_Size Index() const { return myIndex; } |
30f0ad28 |
35 | |
8cf06aa2 |
36 | //! Increment current state. |
37 | void Update() { ++myIndex; } |
30f0ad28 |
38 | |
39 | protected: |
40 | |
8cf06aa2 |
41 | Standard_Size myIndex; //!< current state index |
30f0ad28 |
42 | |
43 | }; |
44 | |
45 | //! Defines state of OCCT projection transformation. |
46 | class OpenGl_ProjectionState : public OpenGl_StateInterface |
47 | { |
48 | public: |
49 | |
50 | //! Creates uninitialized projection state. |
51 | OpenGl_ProjectionState(); |
52 | |
53 | //! Sets new projection matrix. |
c827ea3a |
54 | void Set (const OpenGl_Mat4& theProjectionMatrix); |
30f0ad28 |
55 | |
56 | //! Returns current projection matrix. |
c827ea3a |
57 | const OpenGl_Mat4& ProjectionMatrix() const; |
30f0ad28 |
58 | |
59 | //! Returns inverse of current projection matrix. |
c827ea3a |
60 | const OpenGl_Mat4& ProjectionMatrixInverse() const; |
30f0ad28 |
61 | |
62 | private: |
63 | |
c827ea3a |
64 | OpenGl_Mat4 myProjectionMatrix; //!< OCCT projection matrix |
65 | mutable OpenGl_Mat4 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix |
66 | bool myInverseNeedUpdate; //!< Is inversed matrix outdated? |
30f0ad28 |
67 | |
68 | }; |
69 | |
70 | //! Defines state of OCCT model-world transformation. |
71 | class OpenGl_ModelWorldState : public OpenGl_StateInterface |
72 | { |
73 | public: |
74 | |
75 | //! Creates uninitialized model-world state. |
76 | OpenGl_ModelWorldState(); |
77 | |
78 | //! Sets new model-world matrix. |
c827ea3a |
79 | void Set (const OpenGl_Mat4& theModelWorldMatrix); |
30f0ad28 |
80 | |
81 | //! Returns current model-world matrix. |
c827ea3a |
82 | const OpenGl_Mat4& ModelWorldMatrix() const; |
30f0ad28 |
83 | |
84 | //! Returns inverse of current model-world matrix. |
c827ea3a |
85 | const OpenGl_Mat4& ModelWorldMatrixInverse() const; |
30f0ad28 |
86 | |
87 | private: |
88 | |
c827ea3a |
89 | OpenGl_Mat4 myModelWorldMatrix; //!< OCCT model-world matrix |
90 | mutable OpenGl_Mat4 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix |
91 | bool myInverseNeedUpdate; //!< Is inversed matrix outdated? |
30f0ad28 |
92 | |
93 | }; |
94 | |
95 | //! Defines state of OCCT world-view transformation. |
96 | class OpenGl_WorldViewState : public OpenGl_StateInterface |
97 | { |
98 | public: |
99 | |
100 | //! Creates uninitialized world-view state. |
101 | OpenGl_WorldViewState(); |
e135a155 |
102 | |
30f0ad28 |
103 | //! Sets new world-view matrix. |
c827ea3a |
104 | void Set (const OpenGl_Mat4& theWorldViewMatrix); |
30f0ad28 |
105 | |
106 | //! Returns current world-view matrix. |
c827ea3a |
107 | const OpenGl_Mat4& WorldViewMatrix() const; |
30f0ad28 |
108 | |
109 | //! Returns inverse of current world-view matrix. |
c827ea3a |
110 | const OpenGl_Mat4& WorldViewMatrixInverse() const; |
30f0ad28 |
111 | |
112 | private: |
113 | |
c827ea3a |
114 | OpenGl_Mat4 myWorldViewMatrix; //!< OCCT world-view matrix |
115 | mutable OpenGl_Mat4 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix |
116 | bool myInverseNeedUpdate; //!< Is inversed matrix outdated? |
30f0ad28 |
117 | |
118 | }; |
119 | |
120 | //! Defines state of OCCT light sources. |
121 | class OpenGl_LightSourceState : public OpenGl_StateInterface |
122 | { |
123 | public: |
124 | |
125 | //! Creates uninitialized state of light sources. |
126 | OpenGl_LightSourceState(); |
127 | |
128 | //! Sets new light sources. |
129 | void Set (const OpenGl_ListOfLight* theLightSources); |
130 | |
131 | //! Returns current list of light sources. |
132 | const OpenGl_ListOfLight* LightSources() const; |
133 | |
134 | private: |
135 | |
136 | const OpenGl_ListOfLight* myLightSources; //!< List of OCCT light sources |
137 | |
138 | }; |
139 | |
140 | //! Defines generic state of OCCT material properties. |
141 | class OpenGl_MaterialState : public OpenGl_StateInterface |
142 | { |
143 | public: |
144 | |
145 | //! Creates new material state. |
146 | OpenGl_MaterialState (const OpenGl_Element* theAspect = NULL); |
e135a155 |
147 | |
30f0ad28 |
148 | //! Sets new material aspect. |
149 | void Set (const OpenGl_Element* theAspect); |
150 | |
151 | //! Returns material aspect. |
152 | const OpenGl_Element* Aspect() const; |
153 | |
154 | private: |
155 | |
156 | const OpenGl_Element* myAspect; //!< OCCT material aspect |
157 | |
158 | }; |
159 | |
160 | //! Defines generic state of OCCT clipping state. |
8cf06aa2 |
161 | class OpenGl_ClippingState |
30f0ad28 |
162 | { |
163 | public: |
164 | |
165 | //! Creates new clipping state. |
166 | OpenGl_ClippingState(); |
167 | |
8cf06aa2 |
168 | //! Returns current state index. |
169 | Standard_Size Index() const { return myIndex; } |
170 | |
171 | //! Updates current state. |
172 | void Update(); |
173 | |
174 | //! Reverts current state. |
175 | void Revert(); |
176 | |
177 | protected: |
178 | |
179 | Standard_Size myIndex; //!< Current state index |
180 | Standard_Size myNextIndex; //!< Next state index |
181 | NCollection_List<Standard_Size> myStateStack; //!< Stack of previous states |
182 | |
30f0ad28 |
183 | }; |
184 | |
185 | #endif // _OpenGl_State_HeaderFile |