0023722: stack overflow during reading IGES in Test Harness
[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>
40#include <Visual3d_TypeOfSurfaceDetail.hxx>
41
42#include <OpenGl_telem_view.hxx>
59f45b7c 43#include <OpenGl_LayerList.hxx>
2166f0fa 44#include <OpenGl_Light.hxx>
2166f0fa 45
bf75be98 46#include <Handle_OpenGl_Context.hxx>
2166f0fa
SK
47#include <Handle_OpenGl_Trihedron.hxx>
48#include <Handle_OpenGl_GraduatedTrihedron.hxx>
49#include <Handle_OpenGl_Workspace.hxx>
50#include <Handle_OpenGl_View.hxx>
bf75be98 51#include <Handle_OpenGl_Texture.hxx>
2166f0fa
SK
52
53struct OPENGL_BG_TEXTURE
54{
55 Tuint TexId;
56 Tint Width;
57 Tint Height;
58 Aspect_FillMethod Style;
59};
60
61struct OPENGL_BG_GRADIENT
62{
63 TEL_COLOUR color1;
64 TEL_COLOUR color2;
65 Aspect_GradientFillMethod type;
66};
67
68struct OPENGL_EXTRA_REP
69{
70 Tfloat vrp[3];
71 Tfloat vpn[3];
72 Tfloat vup[3];
73 TEL_VIEW_MAPPING map;
74 Tfloat scaleFactors[3];
75};
76
77struct OPENGL_CLIP_REP
78{
79 Standard_Real equation[4];
1c35b92f 80 DEFINE_STANDARD_ALLOC
2166f0fa
SK
81};
82
83struct OPENGL_ZCLIP
84{
85 struct {
86 Standard_Boolean IsOn;
87 Standard_ShortReal Limit; /* in the range [0., 1.] */
88 } Back;
89 struct {
90 Standard_Boolean IsOn;
91 Standard_ShortReal Limit; /* in the range [0., 1.] */
92 } Front;
93};
94
95struct OPENGL_FOG
96{
97 Standard_Boolean IsOn;
98 Standard_ShortReal Front; /* in the range [0., 1.] */
99 Standard_ShortReal Back; /* in the range [0., 1.] */
100 TEL_COLOUR Color;
101};
102
103class OpenGl_Structure;
104
105class OpenGl_View : public MMgt_TShared
106{
107 public:
108 OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext);
109 virtual ~OpenGl_View ();
110
bf75be98 111 void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
112
113 void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
114 const Handle(Graphic3d_TextureEnv)& theTexture);
2166f0fa
SK
115 void SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail AMode) { mySurfaceDetail = AMode; }
116 void SetBackfacing (const Standard_Integer AMode);
117 void SetLights (const CALL_DEF_VIEWCONTEXT &AContext);
118 void SetAntiAliasing (const Standard_Boolean AMode) { myAntiAliasing = AMode; }
119 void SetClippingPlanes (const CALL_DEF_VIEWCONTEXT &AContext);
120 void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext);
121
bf75be98 122 void SetClipLimit (const Graphic3d_CView& theCView);
123 void SetMapping (const Graphic3d_CView& theCView);
124 void SetOrientation (const Graphic3d_CView& theCView);
2166f0fa 125
bf75be98 126 void SetFog (const Graphic3d_CView& theCView, const Standard_Boolean theFlag);
2166f0fa
SK
127
128 void TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition, const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe);
129 void TriedronErase ();
130
131 void GraduatedTrihedronDisplay (const Graphic3d_CGraduatedTrihedron &ACubic);
132 void GraduatedTrihedronErase ();
133
134 Standard_Boolean ProjectObjectToRaster (const Standard_Integer w, const Standard_Integer h,
135 const Standard_ShortReal x, const Standard_ShortReal y, const Standard_ShortReal z,
136 Standard_ShortReal &xr, Standard_ShortReal &yr);
137 Standard_Boolean ProjectRasterToObject (const Standard_Integer w, const Standard_Integer h,
138 const Standard_Integer xr, const Standard_Integer yr,
139 Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z);
140 Standard_Boolean ProjectRasterToObjectWithRay (const Standard_Integer w, const Standard_Integer h,
141 const Standard_Integer xr, const Standard_Integer yr,
142 Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z,
143 Standard_ShortReal &dx, Standard_ShortReal &dy, Standard_ShortReal &dz);
144 void GetMatrices (TColStd_Array2OfReal& theMatOrient,
145 TColStd_Array2OfReal& theMatMapping,
146 const Standard_Boolean theIsCustom) const;
147
148 Standard_Real Height () const { return (myExtra.map.window.xmax - myExtra.map.window.xmin); }
149 Standard_Real Width () const { return (myExtra.map.window.ymax - myExtra.map.window.ymin); }
150
151 Standard_Integer Backfacing () const { return myBackfacing; }
152
153 const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence ( const TEL_TRANSFORM_PERSISTENCE *ATransPers );
154 void EndTransformPersistence ();
155
59f45b7c 156 //! Add structure to display list with specified priority.
157 //! The structure will be added to associated with it z layer.
158 //! If the z layer is not presented in the view, the structure will
159 //! be displayed in default bottom-level z layer.
160 void DisplayStructure (const OpenGl_Structure *theStructure,
161 const Standard_Integer thePriority);
162
163 //! Erase structure from display list.
164 void EraseStructure (const OpenGl_Structure *theStructure);
165
166 //! Insert a new top-level z layer with ID <theLayerId>
167 void AddZLayer (const Standard_Integer theLayerId);
168
169 //! Remove a z layer with ID <theLayerId>
170 void RemoveZLayer (const Standard_Integer theLayerId);
171
172 //! Display structure in z layer with ID <theNewLayerId>
173 //! If the layer with ID <theNewLayerId> is not presented in the view,
174 //! the structure will be displayed in default bottom-level layer.
175 void ChangeZLayer (const OpenGl_Structure *theStructure,
176 const Standard_Integer theNewLayerId);
2166f0fa
SK
177
178 void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle);
179 void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
180 void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType);
181 void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
182
183 void Render (const Handle(OpenGl_Workspace) &AWorkspace,
184 const Graphic3d_CView& ACView,
185 const Aspect_CLayer2d& ACUnderLayer,
186 const Aspect_CLayer2d& ACOverLayer);
187
188 // Type definition
189 //
190 DEFINE_STANDARD_RTTI(OpenGl_View)
191
192 protected:
193
194 void RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace);
195 void RedrawLayer2d (const Handle(OpenGl_Workspace) &AWorkspace, const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACLayer);
196
bf75be98 197 Handle(OpenGl_Texture) myTextureEnv;
2166f0fa
SK
198 Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail
199 Standard_Integer myBackfacing; //WSBackfacing
200
201 OPENGL_BG_TEXTURE myBgTexture; //WSBgTexture
202 OPENGL_BG_GRADIENT myBgGradient; //WSBgGradient
203
204 //{ myViewRep
205 Tmatrix3 myOrientationMatrix;
206 Tmatrix3 myMappingMatrix;
207
208 //Tint shield_indicator;
209 //TEL_COLOUR shield_colour;
210 //Tint border_indicator;
211 //TEL_COLOUR border_colour;
212 //Tint active_status;
213
214 OPENGL_ZCLIP myZClip;
215 NCollection_List<OPENGL_CLIP_REP> myClippingPlanes;
216
217 OPENGL_EXTRA_REP myExtra;
218 //}
219
220 OPENGL_FOG myFog;
221 Handle(OpenGl_Trihedron) myTrihedron;
222 Handle(OpenGl_GraduatedTrihedron) myGraduatedTrihedron;
223
224 //View_LABViewContext
225 int myVisualization;
226 int myIntShadingMethod;
227
228 //View_LABLight
229 OpenGl_ListOfLight myLights;
230
231 //View_LABPlane
232 //View_LABAliasing
233 Standard_Boolean myAntiAliasing;
234
235 //View_LABDepthCueing - fixed index used
236
59f45b7c 237 OpenGl_LayerList myZLayers;
2166f0fa
SK
238
239 int myAnimationListIndex;
240 Standard_Boolean myAnimationListReady;
241
242 const TEL_TRANSFORM_PERSISTENCE *myTransPers;
243 Standard_Boolean myIsTransPers;
244
245 Standard_Boolean myResetFLIST;
246
247 public:
1c35b92f 248 DEFINE_STANDARD_ALLOC
2166f0fa
SK
249};
250
251#endif //_OpenGl_View_Header