0024377: [Regression-like] OCC 6.7.0 beta contaminates log with more unnecessary...
[occt.git] / src / OpenGl / OpenGl_View.hxx
CommitLineData
b311480e 1// Created on: 2011-09-20
2// Created by: Sergey ZERCHANINOV
3// Copyright (c) 2011-2012 OPEN CASCADE SAS
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_View_Header
21#define _OpenGl_View_Header
22
23#include <MMgt_TShared.hxx>
24#include <Standard_DefineHandle.hxx>
25
26#include <TColStd_Array2OfReal.hxx>
27#include <NCollection_List.hxx>
28
29#include <Quantity_NameOfColor.hxx>
30#include <Aspect_FillMethod.hxx>
31#include <Aspect_GradientFillMethod.hxx>
32#include <Aspect_TypeOfTriedronPosition.hxx>
33#include <Aspect_CLayer2d.hxx>
34
35#include <InterfaceGraphic_Graphic3d.hxx>
36#include <InterfaceGraphic_Visual3d.hxx>
37
38#include <Graphic3d_CView.hxx>
39#include <Graphic3d_CGraduatedTrihedron.hxx>
4269bd1b 40#include <Graphic3d_SetOfHClipPlane.hxx>
2166f0fa
SK
41#include <Visual3d_TypeOfSurfaceDetail.hxx>
42
43#include <OpenGl_telem_view.hxx>
59f45b7c 44#include <OpenGl_LayerList.hxx>
2166f0fa 45#include <OpenGl_Light.hxx>
2166f0fa 46
bf75be98 47#include <Handle_OpenGl_Context.hxx>
392ac980 48#include <Handle_OpenGl_GraphicDriver.hxx>
fd4a6963 49#include <Handle_OpenGl_Display.hxx>
2166f0fa
SK
50#include <Handle_OpenGl_Workspace.hxx>
51#include <Handle_OpenGl_View.hxx>
bf75be98 52#include <Handle_OpenGl_Texture.hxx>
2166f0fa
SK
53
54struct OPENGL_BG_TEXTURE
55{
56 Tuint TexId;
57 Tint Width;
58 Tint Height;
59 Aspect_FillMethod Style;
60};
61
62struct OPENGL_BG_GRADIENT
63{
64 TEL_COLOUR color1;
65 TEL_COLOUR color2;
66 Aspect_GradientFillMethod type;
67};
68
69struct OPENGL_EXTRA_REP
70{
71 Tfloat vrp[3];
72 Tfloat vpn[3];
73 Tfloat vup[3];
74 TEL_VIEW_MAPPING map;
75 Tfloat scaleFactors[3];
76};
77
2166f0fa
SK
78struct OPENGL_ZCLIP
79{
80 struct {
81 Standard_Boolean IsOn;
82 Standard_ShortReal Limit; /* in the range [0., 1.] */
83 } Back;
84 struct {
85 Standard_Boolean IsOn;
86 Standard_ShortReal Limit; /* in the range [0., 1.] */
87 } Front;
88};
89
90struct OPENGL_FOG
91{
92 Standard_Boolean IsOn;
93 Standard_ShortReal Front; /* in the range [0., 1.] */
94 Standard_ShortReal Back; /* in the range [0., 1.] */
95 TEL_COLOUR Color;
96};
97
a174a3c5 98class OpenGl_GraduatedTrihedron;
2166f0fa 99class OpenGl_Structure;
a174a3c5 100class OpenGl_Trihedron;
101class Handle(OpenGl_PrinterContext);
392ac980 102class OpenGl_StateCounter;
2166f0fa
SK
103
104class OpenGl_View : public MMgt_TShared
105{
106 public:
392ac980 107 OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext, OpenGl_StateCounter* theCounter);
2166f0fa
SK
108 virtual ~OpenGl_View ();
109
bf75be98 110 void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
111
112 void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
113 const Handle(Graphic3d_TextureEnv)& theTexture);
e276548b 114 void SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail AMode);
2166f0fa
SK
115 void SetBackfacing (const Standard_Integer AMode);
116 void SetLights (const CALL_DEF_VIEWCONTEXT &AContext);
117 void SetAntiAliasing (const Standard_Boolean AMode) { myAntiAliasing = AMode; }
4269bd1b 118 void SetClipPlanes (const Graphic3d_SetOfHClipPlane &thePlanes) { myClipPlanes = thePlanes; }
2166f0fa
SK
119 void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext);
120
bf75be98 121 void SetClipLimit (const Graphic3d_CView& theCView);
fd4a6963 122 void SetMapping (const Handle(OpenGl_Display)& theGlDisplay, const Graphic3d_CView& theCView);
bf75be98 123 void SetOrientation (const Graphic3d_CView& theCView);
2166f0fa 124
bf75be98 125 void SetFog (const Graphic3d_CView& theCView, const Standard_Boolean theFlag);
2166f0fa 126
a174a3c5 127 void TriedronDisplay (const Handle(OpenGl_Context)& theCtx,
128 const Aspect_TypeOfTriedronPosition thePosition,
129 const Quantity_NameOfColor theColor,
130 const Standard_Real theScale,
131 const Standard_Boolean theAsWireframe);
132 void TriedronErase (const Handle(OpenGl_Context)& theCtx);
2166f0fa 133
a174a3c5 134 void GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
135 const Graphic3d_CGraduatedTrihedron& theCubic);
136 void GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx);
2166f0fa
SK
137
138 Standard_Boolean ProjectObjectToRaster (const Standard_Integer w, const Standard_Integer h,
139 const Standard_ShortReal x, const Standard_ShortReal y, const Standard_ShortReal z,
140 Standard_ShortReal &xr, Standard_ShortReal &yr);
141 Standard_Boolean ProjectRasterToObject (const Standard_Integer w, const Standard_Integer h,
142 const Standard_Integer xr, const Standard_Integer yr,
143 Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z);
144 Standard_Boolean ProjectRasterToObjectWithRay (const Standard_Integer w, const Standard_Integer h,
145 const Standard_Integer xr, const Standard_Integer yr,
146 Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z,
147 Standard_ShortReal &dx, Standard_ShortReal &dy, Standard_ShortReal &dz);
148 void GetMatrices (TColStd_Array2OfReal& theMatOrient,
149 TColStd_Array2OfReal& theMatMapping,
150 const Standard_Boolean theIsCustom) const;
151
152 Standard_Real Height () const { return (myExtra.map.window.xmax - myExtra.map.window.xmin); }
153 Standard_Real Width () const { return (myExtra.map.window.ymax - myExtra.map.window.ymin); }
154
155 Standard_Integer Backfacing () const { return myBackfacing; }
156
30f0ad28 157 const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence (const Handle(OpenGl_Context)& theCtx,
158 const TEL_TRANSFORM_PERSISTENCE *theTransPers);
159 void EndTransformPersistence (const Handle(OpenGl_Context)& theCtx);
2166f0fa 160
59f45b7c 161 //! Add structure to display list with specified priority.
162 //! The structure will be added to associated with it z layer.
163 //! If the z layer is not presented in the view, the structure will
164 //! be displayed in default bottom-level z layer.
165 void DisplayStructure (const OpenGl_Structure *theStructure,
166 const Standard_Integer thePriority);
167
168 //! Erase structure from display list.
169 void EraseStructure (const OpenGl_Structure *theStructure);
170
171 //! Insert a new top-level z layer with ID <theLayerId>
172 void AddZLayer (const Standard_Integer theLayerId);
173
174 //! Remove a z layer with ID <theLayerId>
175 void RemoveZLayer (const Standard_Integer theLayerId);
176
177 //! Display structure in z layer with ID <theNewLayerId>
178 //! If the layer with ID <theNewLayerId> is not presented in the view,
179 //! the structure will be displayed in default bottom-level layer.
180 void ChangeZLayer (const OpenGl_Structure *theStructure,
181 const Standard_Integer theNewLayerId);
2166f0fa
SK
182
183 void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle);
184 void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
185 void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType);
186 void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
187
a174a3c5 188 void Render (const Handle(OpenGl_PrinterContext)& thePrintContext,
189 const Handle(OpenGl_Workspace)& theWorkspace,
190 const Graphic3d_CView& theCView,
191 const Aspect_CLayer2d& theCUnderLayer,
192 const Aspect_CLayer2d& theCOverLayer);
2166f0fa 193
e276548b 194
195 void DrawBackground (const Handle(OpenGl_Workspace)& theWorkspace);
196
197 //! Returns list of OpenGL Z-layers.
198 const OpenGl_LayerList& LayerList() const { return myZLayers; }
199
200 //! Returns list of openGL light sources.
201 const OpenGl_ListOfLight& LightList() const { return myLights; }
202
203 //! Returns OpenGL environment map.
204 const Handle(OpenGl_Texture)& TextureEnv() const { return myTextureEnv; }
205
206 //! Returns visualization mode for objects in the view.
207 Visual3d_TypeOfSurfaceDetail SurfaceDetail() const { return mySurfaceDetail; }
208
209#ifdef HAVE_OPENCL
210 //! Returns modification state for ray-tracing.
211 Standard_Size ModificationState() const { return myModificationState; }
212#endif
213
a174a3c5 214public:
215
216 DEFINE_STANDARD_RTTI(OpenGl_View) // Type definition
2166f0fa
SK
217
218 protected:
219
220 void RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace);
a174a3c5 221 void RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintContext,
a174a3c5 222 const Graphic3d_CView& theCView,
223 const Aspect_CLayer2d& theCLayer);
2166f0fa 224
bf75be98 225 Handle(OpenGl_Texture) myTextureEnv;
2166f0fa
SK
226 Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail
227 Standard_Integer myBackfacing; //WSBackfacing
228
229 OPENGL_BG_TEXTURE myBgTexture; //WSBgTexture
230 OPENGL_BG_GRADIENT myBgGradient; //WSBgGradient
231
232 //{ myViewRep
233 Tmatrix3 myOrientationMatrix;
234 Tmatrix3 myMappingMatrix;
235
236 //Tint shield_indicator;
237 //TEL_COLOUR shield_colour;
238 //Tint border_indicator;
239 //TEL_COLOUR border_colour;
240 //Tint active_status;
241
242 OPENGL_ZCLIP myZClip;
2166f0fa
SK
243 OPENGL_EXTRA_REP myExtra;
244 //}
245
4269bd1b 246 Graphic3d_SetOfHClipPlane myClipPlanes;
247
2166f0fa 248 OPENGL_FOG myFog;
a174a3c5 249 OpenGl_Trihedron* myTrihedron;
250 OpenGl_GraduatedTrihedron* myGraduatedTrihedron;
2166f0fa
SK
251
252 //View_LABViewContext
253 int myVisualization;
254 int myIntShadingMethod;
255
256 //View_LABLight
257 OpenGl_ListOfLight myLights;
258
259 //View_LABPlane
260 //View_LABAliasing
261 Standard_Boolean myAntiAliasing;
262
263 //View_LABDepthCueing - fixed index used
264
59f45b7c 265 OpenGl_LayerList myZLayers;
2166f0fa 266
2166f0fa
SK
267 const TEL_TRANSFORM_PERSISTENCE *myTransPers;
268 Standard_Boolean myIsTransPers;
269
392ac980 270 OpenGl_StateCounter* myStateCounter;
271
272 Standard_Size myCurrOrientationState; // <-- delete it after merge with new camera
273 Standard_Size myCurrViewMappingState; // <-- delete it after merge with new camera
274 Standard_Size myCurrLightSourceState;
275
276 typedef std::pair<Standard_Size, Standard_Size> StateInfo;
277
278 StateInfo myLastOrientationState;
279 StateInfo myLastViewMappingState;
280 StateInfo myLastLightSourceState;
30f0ad28 281
e276548b 282#ifdef HAVE_OPENCL
283 Standard_Size myModificationState;
284#endif
285
2166f0fa 286 public:
1c35b92f 287 DEFINE_STANDARD_ALLOC
2166f0fa
SK
288};
289
290#endif //_OpenGl_View_Header