1 // Created on: 2013-10-02
2 // Created by: Denis BOGOLEPOV
3 // Copyright (c) 2013-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 #ifndef _OpenGl_State_HeaderFile
17 #define _OpenGl_State_HeaderFile
19 #include <InterfaceGraphic_tgl_all.hxx>
21 #include <OpenGl_Element.hxx>
22 #include <OpenGl_Light.hxx>
24 #include <NCollection_List.hxx>
26 //! Defines interface for OpenGL state.
27 class OpenGl_StateInterface
31 //! Creates new OCCT state.
32 OpenGl_StateInterface();
34 //! Returns current state index.
35 Standard_Size Index() const;
37 //! Updates current state.
40 //! Reverts current state.
45 Standard_Size myIndex; //!< Current state index
46 Standard_Size myNextIndex; //!< Next state index
47 NCollection_List<Standard_Size> myStateStack; //!< Stack of previous states.
51 //! Defines state of OCCT projection transformation.
52 class OpenGl_ProjectionState : public OpenGl_StateInterface
56 //! Creates uninitialized projection state.
57 OpenGl_ProjectionState();
59 //! Sets new projection matrix.
60 void Set (const Tmatrix3* theProjectionMatrix);
62 //! Returns current projection matrix.
63 const Tmatrix3& ProjectionMatrix() const;
65 //! Returns inverse of current projection matrix.
66 const Tmatrix3& ProjectionMatrixInverse() const;
70 Tmatrix3 myProjectionMatrix; //!< OCCT projection matrix
71 mutable Tmatrix3 myProjectionMatrixInverse; //!< Inverse of OCCT projection matrix
72 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
76 //! Defines state of OCCT model-world transformation.
77 class OpenGl_ModelWorldState : public OpenGl_StateInterface
81 //! Creates uninitialized model-world state.
82 OpenGl_ModelWorldState();
84 //! Sets new model-world matrix.
85 void Set (const Tmatrix3* theModelWorldMatrix);
87 //! Returns current model-world matrix.
88 const Tmatrix3& ModelWorldMatrix() const;
90 //! Returns inverse of current model-world matrix.
91 const Tmatrix3& ModelWorldMatrixInverse() const;
95 Tmatrix3 myModelWorldMatrix; //!< OCCT model-world matrix
96 mutable Tmatrix3 myModelWorldMatrixInverse; //!< Inverse of OCCT model-world matrix
97 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
101 //! Defines state of OCCT world-view transformation.
102 class OpenGl_WorldViewState : public OpenGl_StateInterface
106 //! Creates uninitialized world-view state.
107 OpenGl_WorldViewState();
109 //! Sets new world-view matrix.
110 void Set (const Tmatrix3* theWorldViewMatrix);
112 //! Returns current world-view matrix.
113 const Tmatrix3& WorldViewMatrix() const;
115 //! Returns inverse of current world-view matrix.
116 const Tmatrix3& WorldViewMatrixInverse() const;
120 Tmatrix3 myWorldViewMatrix; //!< OCCT world-view matrix
121 mutable Tmatrix3 myWorldViewMatrixInverse; //!< Inverse of OCCT world-view matrix
122 bool myInverseNeedUpdate; //!< Is inversed matrix outdated?
126 //! Defines state of OCCT light sources.
127 class OpenGl_LightSourceState : public OpenGl_StateInterface
131 //! Creates uninitialized state of light sources.
132 OpenGl_LightSourceState();
134 //! Sets new light sources.
135 void Set (const OpenGl_ListOfLight* theLightSources);
137 //! Returns current list of light sources.
138 const OpenGl_ListOfLight* LightSources() const;
142 const OpenGl_ListOfLight* myLightSources; //!< List of OCCT light sources
146 //! Defines generic state of OCCT material properties.
147 class OpenGl_MaterialState : public OpenGl_StateInterface
151 //! Creates new material state.
152 OpenGl_MaterialState (const OpenGl_Element* theAspect = NULL);
154 //! Sets new material aspect.
155 void Set (const OpenGl_Element* theAspect);
157 //! Returns material aspect.
158 const OpenGl_Element* Aspect() const;
162 const OpenGl_Element* myAspect; //!< OCCT material aspect
166 //! Defines generic state of OCCT clipping state.
167 class OpenGl_ClippingState : public OpenGl_StateInterface
171 //! Creates new clipping state.
172 OpenGl_ClippingState();
176 #endif // _OpenGl_State_HeaderFile