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