0024530: TKMesh - remove unused package IntPoly
[occt.git] / src / OpenGl / OpenGl_View.hxx
CommitLineData
b311480e 1// Created on: 2011-09-20
2// Created by: Sergey ZERCHANINOV
973c2be1 3// Copyright (c) 2011-2014 OPEN CASCADE SAS
b311480e 4//
973c2be1 5// This file is part of Open CASCADE Technology software library.
b311480e 6//
973c2be1 7// This library is free software; you can redistribute it and / or modify it
8// under the terms of the GNU Lesser General Public 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.
b311480e 12//
973c2be1 13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
b311480e 15
2166f0fa
SK
16#ifndef _OpenGl_View_Header
17#define _OpenGl_View_Header
18
19#include <MMgt_TShared.hxx>
20#include <Standard_DefineHandle.hxx>
21
22#include <TColStd_Array2OfReal.hxx>
23#include <NCollection_List.hxx>
24
25#include <Quantity_NameOfColor.hxx>
26#include <Aspect_FillMethod.hxx>
27#include <Aspect_GradientFillMethod.hxx>
28#include <Aspect_TypeOfTriedronPosition.hxx>
29#include <Aspect_CLayer2d.hxx>
30
31#include <InterfaceGraphic_Graphic3d.hxx>
32#include <InterfaceGraphic_Visual3d.hxx>
33
34#include <Graphic3d_CView.hxx>
35#include <Graphic3d_CGraduatedTrihedron.hxx>
51b10cd4 36#include <Graphic3d_SequenceOfHClipPlane.hxx>
2166f0fa
SK
37#include <Visual3d_TypeOfSurfaceDetail.hxx>
38
59f45b7c 39#include <OpenGl_LayerList.hxx>
2166f0fa 40#include <OpenGl_Light.hxx>
2166f0fa 41
bf75be98 42#include <Handle_OpenGl_Context.hxx>
392ac980 43#include <Handle_OpenGl_GraphicDriver.hxx>
fd4a6963 44#include <Handle_OpenGl_Display.hxx>
2166f0fa
SK
45#include <Handle_OpenGl_Workspace.hxx>
46#include <Handle_OpenGl_View.hxx>
bf75be98 47#include <Handle_OpenGl_Texture.hxx>
2166f0fa
SK
48
49struct OPENGL_BG_TEXTURE
50{
51 Tuint TexId;
52 Tint Width;
53 Tint Height;
54 Aspect_FillMethod Style;
55};
56
57struct OPENGL_BG_GRADIENT
58{
59 TEL_COLOUR color1;
60 TEL_COLOUR color2;
61 Aspect_GradientFillMethod type;
62};
63
2166f0fa
SK
64struct OPENGL_ZCLIP
65{
66 struct {
67 Standard_Boolean IsOn;
68 Standard_ShortReal Limit; /* in the range [0., 1.] */
69 } Back;
70 struct {
71 Standard_Boolean IsOn;
72 Standard_ShortReal Limit; /* in the range [0., 1.] */
73 } Front;
74};
75
76struct OPENGL_FOG
77{
78 Standard_Boolean IsOn;
79 Standard_ShortReal Front; /* in the range [0., 1.] */
80 Standard_ShortReal Back; /* in the range [0., 1.] */
81 TEL_COLOUR Color;
82};
83
b5ac8292 84struct OpenGl_Matrix;
a174a3c5 85class OpenGl_GraduatedTrihedron;
2166f0fa 86class OpenGl_Structure;
a174a3c5 87class OpenGl_Trihedron;
88class Handle(OpenGl_PrinterContext);
392ac980 89class OpenGl_StateCounter;
2166f0fa
SK
90
91class OpenGl_View : public MMgt_TShared
92{
93 public:
392ac980 94 OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext, OpenGl_StateCounter* theCounter);
2166f0fa
SK
95 virtual ~OpenGl_View ();
96
bf75be98 97 void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
98
99 void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
100 const Handle(Graphic3d_TextureEnv)& theTexture);
e276548b 101 void SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail AMode);
2166f0fa
SK
102 void SetBackfacing (const Standard_Integer AMode);
103 void SetLights (const CALL_DEF_VIEWCONTEXT &AContext);
104 void SetAntiAliasing (const Standard_Boolean AMode) { myAntiAliasing = AMode; }
51b10cd4 105 void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane &thePlanes) { myClipPlanes = thePlanes; }
2166f0fa
SK
106 void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext);
107
b5ac8292 108 void SetCamera (const Handle(Graphic3d_Camera)& theCamera) { myCamera = theCamera; }
109
bf75be98 110 void SetClipLimit (const Graphic3d_CView& theCView);
2166f0fa 111
bf75be98 112 void SetFog (const Graphic3d_CView& theCView, const Standard_Boolean theFlag);
2166f0fa 113
a174a3c5 114 void TriedronDisplay (const Handle(OpenGl_Context)& theCtx,
115 const Aspect_TypeOfTriedronPosition thePosition,
116 const Quantity_NameOfColor theColor,
117 const Standard_Real theScale,
118 const Standard_Boolean theAsWireframe);
119 void TriedronErase (const Handle(OpenGl_Context)& theCtx);
2166f0fa 120
a174a3c5 121 void GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
122 const Graphic3d_CGraduatedTrihedron& theCubic);
123 void GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx);
2166f0fa 124
b5ac8292 125 Standard_Real Height () const { return myCamera->ViewDimensions().X(); }
126 Standard_Real Width () const { return myCamera->ViewDimensions().Y(); }
2166f0fa
SK
127
128 Standard_Integer Backfacing () const { return myBackfacing; }
129
30f0ad28 130 const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence (const Handle(OpenGl_Context)& theCtx,
131 const TEL_TRANSFORM_PERSISTENCE *theTransPers);
132 void EndTransformPersistence (const Handle(OpenGl_Context)& theCtx);
2166f0fa 133
59f45b7c 134 //! Add structure to display list with specified priority.
135 //! The structure will be added to associated with it z layer.
136 //! If the z layer is not presented in the view, the structure will
137 //! be displayed in default bottom-level z layer.
138 void DisplayStructure (const OpenGl_Structure *theStructure,
139 const Standard_Integer thePriority);
140
141 //! Erase structure from display list.
142 void EraseStructure (const OpenGl_Structure *theStructure);
143
144 //! Insert a new top-level z layer with ID <theLayerId>
145 void AddZLayer (const Standard_Integer theLayerId);
146
147 //! Remove a z layer with ID <theLayerId>
148 void RemoveZLayer (const Standard_Integer theLayerId);
149
150 //! Display structure in z layer with ID <theNewLayerId>
151 //! If the layer with ID <theNewLayerId> is not presented in the view,
152 //! the structure will be displayed in default bottom-level layer.
153 void ChangeZLayer (const OpenGl_Structure *theStructure,
154 const Standard_Integer theNewLayerId);
2166f0fa
SK
155
156 void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle);
157 void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
158 void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType);
159 void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
160
a174a3c5 161 void Render (const Handle(OpenGl_PrinterContext)& thePrintContext,
162 const Handle(OpenGl_Workspace)& theWorkspace,
163 const Graphic3d_CView& theCView,
164 const Aspect_CLayer2d& theCUnderLayer,
165 const Aspect_CLayer2d& theCOverLayer);
2166f0fa 166
e276548b 167
168 void DrawBackground (const Handle(OpenGl_Workspace)& theWorkspace);
169
170 //! Returns list of OpenGL Z-layers.
171 const OpenGl_LayerList& LayerList() const { return myZLayers; }
172
173 //! Returns list of openGL light sources.
174 const OpenGl_ListOfLight& LightList() const { return myLights; }
175
176 //! Returns OpenGL environment map.
177 const Handle(OpenGl_Texture)& TextureEnv() const { return myTextureEnv; }
178
179 //! Returns visualization mode for objects in the view.
180 Visual3d_TypeOfSurfaceDetail SurfaceDetail() const { return mySurfaceDetail; }
181
b5ac8292 182 void GetMatrices (TColStd_Array2OfReal& theMatOrient,
183 TColStd_Array2OfReal& theMatMapping) const;
184
e276548b 185#ifdef HAVE_OPENCL
186 //! Returns modification state for ray-tracing.
187 Standard_Size ModificationState() const { return myModificationState; }
188#endif
189
a174a3c5 190public:
191
192 DEFINE_STANDARD_RTTI(OpenGl_View) // Type definition
2166f0fa
SK
193
194 protected:
195
196 void RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace);
a174a3c5 197 void RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintContext,
a174a3c5 198 const Graphic3d_CView& theCView,
199 const Aspect_CLayer2d& theCLayer);
2166f0fa 200
b5ac8292 201 //! Redraw contents of model scene: clipping planes,
202 //! lights, structures. The peculiar properties of "scene" is that
203 //! it requires empty Z-Buffer and uses projection and orientation
204 //! matrices supplied by 3d view.
205 //! @param thePrintCtx [in] printer context which facilitates tiled printing.
206 //! @param theWorkspace [in] rendering workspace.
207 //! @param theCView [in] view data.
208 //! @param theProjection [in] view projection matrix.
209 //! @param theOrientation [in] view orientation matrix.
210 void RedrawScene (const Handle(OpenGl_PrinterContext)& thePrintContext,
211 const Handle(OpenGl_Workspace)& theWorkspace,
212 const OpenGl_Matrix* theProjection,
213 const OpenGl_Matrix* theOrientation);
214
bf75be98 215 Handle(OpenGl_Texture) myTextureEnv;
2166f0fa
SK
216 Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail
217 Standard_Integer myBackfacing; //WSBackfacing
218
219 OPENGL_BG_TEXTURE myBgTexture; //WSBgTexture
220 OPENGL_BG_GRADIENT myBgGradient; //WSBgGradient
221
2166f0fa 222 OPENGL_ZCLIP myZClip;
2166f0fa 223
51b10cd4 224 Graphic3d_SequenceOfHClipPlane myClipPlanes;
4269bd1b 225
b5ac8292 226 Handle(Graphic3d_Camera) myCamera;
227
2166f0fa 228 OPENGL_FOG myFog;
a174a3c5 229 OpenGl_Trihedron* myTrihedron;
230 OpenGl_GraduatedTrihedron* myGraduatedTrihedron;
2166f0fa
SK
231
232 //View_LABViewContext
233 int myVisualization;
234 int myIntShadingMethod;
235
236 //View_LABLight
237 OpenGl_ListOfLight myLights;
238
239 //View_LABPlane
240 //View_LABAliasing
241 Standard_Boolean myAntiAliasing;
242
243 //View_LABDepthCueing - fixed index used
244
59f45b7c 245 OpenGl_LayerList myZLayers;
2166f0fa 246
2166f0fa
SK
247 const TEL_TRANSFORM_PERSISTENCE *myTransPers;
248 Standard_Boolean myIsTransPers;
249
b5ac8292 250 //! Modification state
251 Standard_Size myProjectionState;
252 Standard_Size myModelViewState;
392ac980 253 OpenGl_StateCounter* myStateCounter;
254
392ac980 255 Standard_Size myCurrLightSourceState;
256
257 typedef std::pair<Standard_Size, Standard_Size> StateInfo;
258
259 StateInfo myLastOrientationState;
260 StateInfo myLastViewMappingState;
261 StateInfo myLastLightSourceState;
30f0ad28 262
e276548b 263#ifdef HAVE_OPENCL
264 Standard_Size myModificationState;
265#endif
266
2166f0fa 267 public:
1c35b92f 268 DEFINE_STANDARD_ALLOC
2166f0fa
SK
269};
270
271#endif //_OpenGl_View_Header