1 // Created on: 2011-09-20
2 // Created by: Sergey ZERCHANINOV
3 // Copyright (c) 2011-2012 OPEN CASCADE SAS
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.
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.
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.
20 #ifndef _OpenGl_View_Header
21 #define _OpenGl_View_Header
23 #include <MMgt_TShared.hxx>
24 #include <Standard_DefineHandle.hxx>
26 #include <TColStd_Array2OfReal.hxx>
27 #include <NCollection_List.hxx>
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>
35 #include <InterfaceGraphic_Graphic3d.hxx>
36 #include <InterfaceGraphic_Visual3d.hxx>
38 #include <Graphic3d_CView.hxx>
39 #include <Graphic3d_CGraduatedTrihedron.hxx>
40 #include <Graphic3d_SetOfHClipPlane.hxx>
41 #include <Visual3d_TypeOfSurfaceDetail.hxx>
43 #include <OpenGl_telem_view.hxx>
44 #include <OpenGl_LayerList.hxx>
45 #include <OpenGl_Light.hxx>
47 #include <Handle_OpenGl_Context.hxx>
48 #include <Handle_OpenGl_Display.hxx>
49 #include <Handle_OpenGl_Workspace.hxx>
50 #include <Handle_OpenGl_View.hxx>
51 #include <Handle_OpenGl_Texture.hxx>
53 struct OPENGL_BG_TEXTURE
58 Aspect_FillMethod Style;
61 struct OPENGL_BG_GRADIENT
65 Aspect_GradientFillMethod type;
68 struct OPENGL_EXTRA_REP
74 Tfloat scaleFactors[3];
80 Standard_Boolean IsOn;
81 Standard_ShortReal Limit; /* in the range [0., 1.] */
84 Standard_Boolean IsOn;
85 Standard_ShortReal Limit; /* in the range [0., 1.] */
91 Standard_Boolean IsOn;
92 Standard_ShortReal Front; /* in the range [0., 1.] */
93 Standard_ShortReal Back; /* in the range [0., 1.] */
97 class OpenGl_GraduatedTrihedron;
98 class OpenGl_Structure;
99 class OpenGl_Trihedron;
100 class Handle(OpenGl_PrinterContext);
102 class OpenGl_View : public MMgt_TShared
105 OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext);
106 virtual ~OpenGl_View ();
108 void ReleaseGlResources (const Handle(OpenGl_Context)& theCtx);
110 void SetTextureEnv (const Handle(OpenGl_Context)& theCtx,
111 const Handle(Graphic3d_TextureEnv)& theTexture);
112 void SetSurfaceDetail (const Visual3d_TypeOfSurfaceDetail AMode) { mySurfaceDetail = AMode; }
113 void SetBackfacing (const Standard_Integer AMode);
114 void SetLights (const CALL_DEF_VIEWCONTEXT &AContext);
115 void SetAntiAliasing (const Standard_Boolean AMode) { myAntiAliasing = AMode; }
116 void SetClipPlanes (const Graphic3d_SetOfHClipPlane &thePlanes) { myClipPlanes = thePlanes; }
117 void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext);
119 void SetClipLimit (const Graphic3d_CView& theCView);
120 void SetMapping (const Handle(OpenGl_Display)& theGlDisplay, const Graphic3d_CView& theCView);
121 void SetOrientation (const Graphic3d_CView& theCView);
123 void SetFog (const Graphic3d_CView& theCView, const Standard_Boolean theFlag);
125 void TriedronDisplay (const Handle(OpenGl_Context)& theCtx,
126 const Aspect_TypeOfTriedronPosition thePosition,
127 const Quantity_NameOfColor theColor,
128 const Standard_Real theScale,
129 const Standard_Boolean theAsWireframe);
130 void TriedronErase (const Handle(OpenGl_Context)& theCtx);
132 void GraduatedTrihedronDisplay (const Handle(OpenGl_Context)& theCtx,
133 const Graphic3d_CGraduatedTrihedron& theCubic);
134 void GraduatedTrihedronErase (const Handle(OpenGl_Context)& theCtx);
136 Standard_Boolean ProjectObjectToRaster (const Standard_Integer w, const Standard_Integer h,
137 const Standard_ShortReal x, const Standard_ShortReal y, const Standard_ShortReal z,
138 Standard_ShortReal &xr, Standard_ShortReal &yr);
139 Standard_Boolean ProjectRasterToObject (const Standard_Integer w, const Standard_Integer h,
140 const Standard_Integer xr, const Standard_Integer yr,
141 Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z);
142 Standard_Boolean ProjectRasterToObjectWithRay (const Standard_Integer w, const Standard_Integer h,
143 const Standard_Integer xr, const Standard_Integer yr,
144 Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z,
145 Standard_ShortReal &dx, Standard_ShortReal &dy, Standard_ShortReal &dz);
146 void GetMatrices (TColStd_Array2OfReal& theMatOrient,
147 TColStd_Array2OfReal& theMatMapping,
148 const Standard_Boolean theIsCustom) const;
150 Standard_Real Height () const { return (myExtra.map.window.xmax - myExtra.map.window.xmin); }
151 Standard_Real Width () const { return (myExtra.map.window.ymax - myExtra.map.window.ymin); }
153 Standard_Integer Backfacing () const { return myBackfacing; }
155 const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence (const Handle(OpenGl_Context)& theCtx,
156 const TEL_TRANSFORM_PERSISTENCE *theTransPers);
157 void EndTransformPersistence (const Handle(OpenGl_Context)& theCtx);
159 //! Add structure to display list with specified priority.
160 //! The structure will be added to associated with it z layer.
161 //! If the z layer is not presented in the view, the structure will
162 //! be displayed in default bottom-level z layer.
163 void DisplayStructure (const OpenGl_Structure *theStructure,
164 const Standard_Integer thePriority);
166 //! Erase structure from display list.
167 void EraseStructure (const OpenGl_Structure *theStructure);
169 //! Insert a new top-level z layer with ID <theLayerId>
170 void AddZLayer (const Standard_Integer theLayerId);
172 //! Remove a z layer with ID <theLayerId>
173 void RemoveZLayer (const Standard_Integer theLayerId);
175 //! Display structure in z layer with ID <theNewLayerId>
176 //! If the layer with ID <theNewLayerId> is not presented in the view,
177 //! the structure will be displayed in default bottom-level layer.
178 void ChangeZLayer (const OpenGl_Structure *theStructure,
179 const Standard_Integer theNewLayerId);
181 void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle);
182 void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
183 void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType);
184 void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
186 void Render (const Handle(OpenGl_PrinterContext)& thePrintContext,
187 const Handle(OpenGl_Workspace)& theWorkspace,
188 const Graphic3d_CView& theCView,
189 const Aspect_CLayer2d& theCUnderLayer,
190 const Aspect_CLayer2d& theCOverLayer);
194 DEFINE_STANDARD_RTTI(OpenGl_View) // Type definition
198 void RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace);
199 void RedrawLayer2d (const Handle(OpenGl_PrinterContext)& thePrintContext,
200 const Graphic3d_CView& theCView,
201 const Aspect_CLayer2d& theCLayer);
203 Handle(OpenGl_Texture) myTextureEnv;
204 Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail
205 Standard_Integer myBackfacing; //WSBackfacing
207 OPENGL_BG_TEXTURE myBgTexture; //WSBgTexture
208 OPENGL_BG_GRADIENT myBgGradient; //WSBgGradient
211 Tmatrix3 myOrientationMatrix;
212 Tmatrix3 myMappingMatrix;
214 //Tint shield_indicator;
215 //TEL_COLOUR shield_colour;
216 //Tint border_indicator;
217 //TEL_COLOUR border_colour;
218 //Tint active_status;
220 OPENGL_ZCLIP myZClip;
221 OPENGL_EXTRA_REP myExtra;
224 Graphic3d_SetOfHClipPlane myClipPlanes;
227 OpenGl_Trihedron* myTrihedron;
228 OpenGl_GraduatedTrihedron* myGraduatedTrihedron;
230 //View_LABViewContext
232 int myIntShadingMethod;
235 OpenGl_ListOfLight myLights;
239 Standard_Boolean myAntiAliasing;
241 //View_LABDepthCueing - fixed index used
243 OpenGl_LayerList myZLayers;
245 const TEL_TRANSFORM_PERSISTENCE *myTransPers;
246 Standard_Boolean myIsTransPers;
248 //! Modification flags.
249 Standard_Boolean myOrientationChanged;
250 Standard_Boolean myViewMappingChanged;
251 Standard_Boolean myLightSourcesChanged;
254 DEFINE_STANDARD_ALLOC
257 #endif //_OpenGl_View_Header