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