Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 2011-09-20 |
2 | // Created by: Sergey ZERCHANINOV | |
1981cb22 | 3 | // Copyright (c) 2011-2013 OPEN CASCADE SAS |
b311480e | 4 | // |
5 | // The content of this file is subject to the Open CASCADE Technology Public | |
6 | // License Version 6.5 (the "License"). You may not use the content of this file | |
7 | // except in compliance with the License. Please obtain a copy of the License | |
8 | // at http://www.opencascade.org and read it completely before using this file. | |
9 | // | |
10 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its | |
11 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. | |
12 | // | |
13 | // The Original Code and all software distributed under the License is | |
14 | // distributed on an "AS IS" basis, without warranty of any kind, and the | |
15 | // Initial Developer hereby disclaims all such warranties, including without | |
16 | // limitation, any warranties of merchantability, fitness for a particular | |
17 | // purpose or non-infringement. Please see the License for the specific terms | |
18 | // and conditions governing the rights and limitations under the License. | |
19 | ||
2166f0fa SK |
20 | #ifndef _OpenGl_Workspace_Header |
21 | #define _OpenGl_Workspace_Header | |
22 | ||
23 | #include <Handle_OpenGl_Workspace.hxx> | |
24 | #include <OpenGl_Window.hxx> | |
25 | ||
26 | #include <TColStd_Array2OfReal.hxx> | |
27 | #include <Quantity_Color.hxx> | |
bf75be98 | 28 | #include <Graphic3d_CView.hxx> |
2166f0fa | 29 | #include <Graphic3d_TypeOfComposition.hxx> |
bf75be98 | 30 | #include <Graphic3d_TypeOfTexture.hxx> |
31 | #include <Graphic3d_PtrFrameBuffer.hxx> | |
32 | #include <Graphic3d_BufferType.hxx> | |
33 | #include <Handle_Graphic3d_TextureParams.hxx> | |
2166f0fa | 34 | |
2166f0fa SK |
35 | #include <Aspect_CLayer2d.hxx> |
36 | #include <Aspect_Handle.hxx> | |
37 | #include <Aspect_PrintAlgo.hxx> | |
2166f0fa SK |
38 | |
39 | #include <InterfaceGraphic_Graphic3d.hxx> | |
40 | #include <InterfaceGraphic_Visual3d.hxx> | |
41 | ||
1981cb22 | 42 | #include <NCollection_Sequence.hxx> |
43 | ||
2166f0fa SK |
44 | #include <OpenGl_tsm.hxx> |
45 | ||
bf75be98 | 46 | #include <OpenGl_AspectFace.hxx> |
2166f0fa SK |
47 | #include <OpenGl_Display.hxx> |
48 | #include <OpenGl_Matrix.hxx> | |
49 | #include <OpenGl_NamedStatus.hxx> | |
a174a3c5 | 50 | #include <OpenGl_PrinterContext.hxx> |
2166f0fa SK |
51 | #include <OpenGl_TextParam.hxx> |
52 | ||
53 | #include <Handle_OpenGl_View.hxx> | |
bf75be98 | 54 | #include <Handle_OpenGl_Texture.hxx> |
2166f0fa SK |
55 | |
56 | class OpenGl_AspectLine; | |
2166f0fa SK |
57 | class OpenGl_AspectMarker; |
58 | class OpenGl_AspectText; | |
59 | class OpenGl_FrameBuffer; | |
60 | class OpenGl_Structure; | |
692613e5 | 61 | class Image_PixMap; |
2166f0fa SK |
62 | |
63 | //! Reprepsents window with GL context. | |
64 | //! Provides methods to render primitives and maintan GL state. | |
65 | class OpenGl_Workspace : public OpenGl_Window | |
66 | { | |
67 | public: | |
68 | ||
69 | //! Main constructor - prepare GL context for specified window. | |
70 | OpenGl_Workspace (const Handle(OpenGl_Display)& theDisplay, | |
71 | const CALL_DEF_WINDOW& theCWindow, | |
5e27df78 | 72 | Aspect_RenderingContext theGContext, |
73 | const Handle(OpenGl_Context)& theShareCtx); | |
2166f0fa SK |
74 | |
75 | //! Destructor | |
76 | virtual ~OpenGl_Workspace(); | |
77 | ||
78 | void SetActiveView (const Handle(OpenGl_View)& theView) { myView = theView; } | |
79 | const Handle(OpenGl_View)& ActiveView () const { return myView; } | |
80 | ||
81 | //! Redraw the window. | |
82 | void Redraw (const Graphic3d_CView& theCView, | |
83 | const Aspect_CLayer2d& theCUnderLayer, | |
84 | const Aspect_CLayer2d& theCOverLayer); | |
85 | ||
298f9ad7 | 86 | //! Deprecated. Simply calls Redraw(). |
2166f0fa SK |
87 | void Update (const Graphic3d_CView& theCView, |
88 | const Aspect_CLayer2d& theCUnderLayer, | |
89 | const Aspect_CLayer2d& theCOverLayer) | |
90 | { | |
298f9ad7 | 91 | Redraw (theCView, theCUnderLayer, theCOverLayer); |
2166f0fa SK |
92 | } |
93 | ||
94 | //! Special method to perform printing. | |
95 | //! System-specific and currently only Win platform implemented. | |
a174a3c5 | 96 | Standard_Boolean Print (const Handle(OpenGl_PrinterContext)& thePrintContext, |
97 | const Graphic3d_CView& theCView, | |
bf75be98 | 98 | const Aspect_CLayer2d& theCUnderLayer, |
2166f0fa SK |
99 | const Aspect_CLayer2d& theCOverLayer, |
100 | const Aspect_Handle theHPrintDC, | |
101 | const Standard_Boolean theToShowBackground, | |
102 | const Standard_CString theFileName, | |
103 | const Aspect_PrintAlgo thePrintAlgorithm, | |
104 | const Standard_Real theScaleFactor); | |
105 | ||
a174a3c5 | 106 | const Handle(OpenGl_PrinterContext)& PrinterContext() const |
107 | { | |
108 | return myPrintContext; | |
109 | } | |
110 | ||
2166f0fa SK |
111 | void DisplayCallback (const Graphic3d_CView& theCView, int theReason); |
112 | ||
113 | // szvgl: defined in OpenGl_Workspace_1.cxx | |
114 | void BeginAnimation (const Standard_Boolean theUseDegeneration, | |
bf75be98 | 115 | const Standard_Boolean theUpdateAM); |
2166f0fa SK |
116 | void EndAnimation(); |
117 | void EraseAnimation(); | |
118 | ||
1981cb22 | 119 | Standard_Boolean SetImmediateModeDrawToFront (const Standard_Boolean theDrawToFrontBuffer); |
2166f0fa SK |
120 | Standard_Boolean BeginAddMode(); |
121 | void EndAddMode(); | |
122 | void ClearImmediatMode (const Graphic3d_CView& theCView, | |
123 | const Standard_Boolean theToFlush); | |
124 | void RedrawImmediatMode(); | |
125 | Standard_Boolean BeginImmediatMode (const Graphic3d_CView& theCView, | |
126 | const Standard_Boolean theUseDepthTest, | |
127 | const Standard_Boolean theRetainMode); | |
128 | void EndImmediatMode(); | |
2166f0fa | 129 | void DrawStructure (const OpenGl_Structure* theStructure); |
2166f0fa SK |
130 | |
131 | Graphic3d_PtrFrameBuffer FBOCreate (const Standard_Integer theWidth, const Standard_Integer theHeight); | |
132 | void FBORelease (Graphic3d_PtrFrameBuffer theFBOPtr); | |
692613e5 | 133 | Standard_Boolean BufferDump (OpenGl_FrameBuffer* theFBOPtr, |
134 | Image_PixMap& theImage, | |
135 | const Graphic3d_BufferType& theBufferType); | |
2166f0fa | 136 | |
2166f0fa SK |
137 | void UseTransparency (const Standard_Boolean theFlag); |
138 | Standard_Boolean& UseZBuffer() { return myUseZBuffer; } | |
139 | Standard_Boolean& UseDepthTest() { return myUseDepthTest; } | |
140 | Standard_Boolean& UseGLLight() { return myUseGLLight; } | |
141 | ||
142 | //// RELATED TO STATUS //// | |
143 | ||
144 | Standard_Integer NamedStatus; | |
145 | ||
146 | Standard_Integer DegenerateModel; | |
147 | Standard_ShortReal SkipRatio; | |
148 | ||
149 | const TEL_COLOUR* HighlightColor; | |
150 | ||
151 | const OpenGl_Matrix* SetViewMatrix (const OpenGl_Matrix* ); | |
152 | const OpenGl_Matrix* SetStructureMatrix (const OpenGl_Matrix* ); | |
153 | ||
154 | const OpenGl_AspectLine* SetAspectLine (const OpenGl_AspectLine* theAspect); | |
155 | const OpenGl_AspectFace* SetAspectFace (const OpenGl_AspectFace* theAspect); | |
156 | const OpenGl_AspectMarker* SetAspectMarker (const OpenGl_AspectMarker* theAspect); | |
157 | const OpenGl_AspectText* SetAspectText (const OpenGl_AspectText* theAspect); | |
158 | ||
159 | void SetTextParam (const OpenGl_TextParam* theParam) { TextParam_set = theParam; } | |
160 | ||
3946774d | 161 | //// THESE METHODS ARE EXPORTED AS THEY PROVIDE STATE INFO TO USERDRAW |
162 | Standard_EXPORT const OpenGl_AspectLine* AspectLine (const Standard_Boolean theWithApply); | |
163 | Standard_EXPORT const OpenGl_AspectFace* AspectFace (const Standard_Boolean theWithApply); | |
164 | Standard_EXPORT const OpenGl_AspectMarker* AspectMarker (const Standard_Boolean theWithApply); | |
165 | Standard_EXPORT const OpenGl_AspectText* AspectText (const Standard_Boolean theWithApply); | |
a174a3c5 | 166 | inline const OpenGl_TextParam* AspectTextParams() const |
167 | { | |
168 | return TextParam_applied; | |
169 | } | |
2166f0fa | 170 | |
34a44cbd | 171 | //! Clear the applied aspect state. |
172 | void ResetAppliedAspect(); | |
173 | ||
bf75be98 | 174 | Standard_EXPORT Handle(OpenGl_Texture) DisableTexture(); |
175 | Standard_EXPORT Handle(OpenGl_Texture) EnableTexture (const Handle(OpenGl_Texture)& theTexture, | |
176 | const Handle(Graphic3d_TextureParams)& theParams = NULL); | |
177 | ||
2166f0fa SK |
178 | protected: |
179 | ||
1981cb22 | 180 | void CopyBuffers (const Standard_Boolean theFrontToBack); |
2166f0fa SK |
181 | |
182 | virtual Standard_Boolean Activate(); | |
183 | ||
184 | // TEMPORARY!!! | |
bf75be98 | 185 | void Redraw1 (const Graphic3d_CView& theCView, |
186 | const Aspect_CLayer2d& theCUnderLayer, | |
2166f0fa SK |
187 | const Aspect_CLayer2d& theCOverLayer, |
188 | const int theToSwap); | |
189 | ||
bf75be98 | 190 | void UpdateMaterial (const int flag); |
2166f0fa | 191 | |
bf75be98 | 192 | void setTextureParams (Handle(OpenGl_Texture)& theTexture, |
193 | const Handle(Graphic3d_TextureParams)& theParams); | |
2166f0fa | 194 | |
bf75be98 | 195 | protected: //! @name protected fields |
2166f0fa | 196 | |
a174a3c5 | 197 | Handle(OpenGl_PrinterContext) myPrintContext; |
bf75be98 | 198 | Handle(OpenGl_View) myView; // WSViews - now just one view is supported |
bf75be98 | 199 | Standard_Boolean myIsTransientOpen; // transientOpen |
1981cb22 | 200 | Standard_Boolean myRetainMode; |
201 | Standard_Boolean myTransientDrawToFront; //!< optimization flag for immediate mode (to render directly to the front buffer) | |
202 | ||
203 | NCollection_Sequence<const OpenGl_Structure*> myTransientList; | |
2166f0fa | 204 | |
bf75be98 | 205 | Standard_Boolean myUseTransparency; |
206 | Standard_Boolean myUseZBuffer; | |
207 | Standard_Boolean myUseDepthTest; | |
208 | Standard_Boolean myUseGLLight; | |
209 | Standard_Boolean myBackBufferRestored; | |
2166f0fa | 210 | |
bf75be98 | 211 | protected: //! @name fields related to status |
212 | ||
213 | Handle(OpenGl_Texture) myTextureBound; //!< currently bound texture (managed by OpenGl_AspectFace and OpenGl_View environment texture) | |
2166f0fa SK |
214 | const OpenGl_AspectLine *AspectLine_set, *AspectLine_applied; |
215 | const OpenGl_AspectFace *AspectFace_set, *AspectFace_applied; | |
216 | const OpenGl_AspectMarker *AspectMarker_set, *AspectMarker_applied; | |
217 | const OpenGl_AspectText *AspectText_set, *AspectText_applied; | |
218 | ||
219 | const OpenGl_TextParam *TextParam_set, *TextParam_applied; | |
220 | ||
221 | const OpenGl_Matrix* ViewMatrix_applied; | |
222 | const OpenGl_Matrix* StructureMatrix_applied; | |
223 | ||
224 | const TEL_POFFSET_PARAM* PolygonOffset_applied; | |
225 | ||
bf75be98 | 226 | OpenGl_AspectFace myAspectFaceHl; // Hiddenline aspect |
227 | ||
228 | public: //! @name type definition | |
2166f0fa | 229 | |
bf75be98 | 230 | DEFINE_STANDARD_RTTI(OpenGl_Workspace) |
1c35b92f | 231 | DEFINE_STANDARD_ALLOC |
2166f0fa SK |
232 | |
233 | }; | |
234 | ||
bf75be98 | 235 | #endif // _OpenGl_Workspace_Header |