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.
21 #ifndef _OpenGl_View_Header
22 #define _OpenGl_View_Header
24 #include <MMgt_TShared.hxx>
25 #include <Standard_DefineHandle.hxx>
27 #include <TColStd_Array2OfReal.hxx>
28 #include <NCollection_List.hxx>
30 #include <Quantity_NameOfColor.hxx>
31 #include <Aspect_FillMethod.hxx>
32 #include <Aspect_GradientFillMethod.hxx>
33 #include <Aspect_TypeOfTriedronPosition.hxx>
34 #include <Aspect_CLayer2d.hxx>
36 #include <InterfaceGraphic_Graphic3d.hxx>
37 #include <InterfaceGraphic_Visual3d.hxx>
39 #include <Graphic3d_CView.hxx>
40 #include <Graphic3d_CGraduatedTrihedron.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_Trihedron.hxx>
48 #include <Handle_OpenGl_GraduatedTrihedron.hxx>
49 #include <Handle_OpenGl_Workspace.hxx>
50 #include <Handle_OpenGl_View.hxx>
52 struct OPENGL_BG_TEXTURE
57 Aspect_FillMethod Style;
60 struct OPENGL_BG_GRADIENT
64 Aspect_GradientFillMethod type;
67 struct OPENGL_EXTRA_REP
73 Tfloat scaleFactors[3];
76 struct OPENGL_CLIP_REP
78 Standard_Real equation[4];
85 Standard_Boolean IsOn;
86 Standard_ShortReal Limit; /* in the range [0., 1.] */
89 Standard_Boolean IsOn;
90 Standard_ShortReal Limit; /* in the range [0., 1.] */
96 Standard_Boolean IsOn;
97 Standard_ShortReal Front; /* in the range [0., 1.] */
98 Standard_ShortReal Back; /* in the range [0., 1.] */
102 class OpenGl_Structure;
104 class OpenGl_View : public MMgt_TShared
107 OpenGl_View (const CALL_DEF_VIEWCONTEXT &AContext);
108 virtual ~OpenGl_View ();
110 void SetTextureEnv (const Standard_Integer AId) { myTextureEnv = AId; }
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; }
115 void SetClippingPlanes (const CALL_DEF_VIEWCONTEXT &AContext);
116 void SetVisualisation (const CALL_DEF_VIEWCONTEXT &AContext);
118 void SetClipLimit (const CALL_DEF_VIEW &ACView);
119 void SetMapping (const CALL_DEF_VIEW &ACView);
120 void SetOrientation (const CALL_DEF_VIEW &ACView);
122 void SetFog (const CALL_DEF_VIEW &ACView, const Standard_Boolean AFlag);
124 void TriedronDisplay (const Aspect_TypeOfTriedronPosition APosition, const Quantity_NameOfColor AColor, const Standard_Real AScale, const Standard_Boolean AsWireframe);
125 void TriedronErase ();
127 void GraduatedTrihedronDisplay (const Graphic3d_CGraduatedTrihedron &ACubic);
128 void GraduatedTrihedronErase ();
130 Standard_Boolean ProjectObjectToRaster (const Standard_Integer w, const Standard_Integer h,
131 const Standard_ShortReal x, const Standard_ShortReal y, const Standard_ShortReal z,
132 Standard_ShortReal &xr, Standard_ShortReal &yr);
133 Standard_Boolean ProjectRasterToObject (const Standard_Integer w, const Standard_Integer h,
134 const Standard_Integer xr, const Standard_Integer yr,
135 Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z);
136 Standard_Boolean ProjectRasterToObjectWithRay (const Standard_Integer w, const Standard_Integer h,
137 const Standard_Integer xr, const Standard_Integer yr,
138 Standard_ShortReal &x, Standard_ShortReal &y, Standard_ShortReal &z,
139 Standard_ShortReal &dx, Standard_ShortReal &dy, Standard_ShortReal &dz);
140 void GetMatrices (TColStd_Array2OfReal& theMatOrient,
141 TColStd_Array2OfReal& theMatMapping,
142 const Standard_Boolean theIsCustom) const;
144 Standard_Real Height () const { return (myExtra.map.window.xmax - myExtra.map.window.xmin); }
145 Standard_Real Width () const { return (myExtra.map.window.ymax - myExtra.map.window.ymin); }
147 Standard_Integer Backfacing () const { return myBackfacing; }
149 const TEL_TRANSFORM_PERSISTENCE * BeginTransformPersistence ( const TEL_TRANSFORM_PERSISTENCE *ATransPers );
150 void EndTransformPersistence ();
152 //! Add structure to display list with specified priority.
153 //! The structure will be added to associated with it z layer.
154 //! If the z layer is not presented in the view, the structure will
155 //! be displayed in default bottom-level z layer.
156 void DisplayStructure (const OpenGl_Structure *theStructure,
157 const Standard_Integer thePriority);
159 //! Erase structure from display list.
160 void EraseStructure (const OpenGl_Structure *theStructure);
162 //! Insert a new top-level z layer with ID <theLayerId>
163 void AddZLayer (const Standard_Integer theLayerId);
165 //! Remove a z layer with ID <theLayerId>
166 void RemoveZLayer (const Standard_Integer theLayerId);
168 //! Display structure in z layer with ID <theNewLayerId>
169 //! If the layer with ID <theNewLayerId> is not presented in the view,
170 //! the structure will be displayed in default bottom-level layer.
171 void ChangeZLayer (const OpenGl_Structure *theStructure,
172 const Standard_Integer theNewLayerId);
174 void CreateBackgroundTexture (const Standard_CString AFileName, const Aspect_FillMethod AFillStyle);
175 void SetBackgroundTextureStyle (const Aspect_FillMethod FillStyle);
176 void SetBackgroundGradient (const Quantity_Color& AColor1, const Quantity_Color& AColor2, const Aspect_GradientFillMethod AType);
177 void SetBackgroundGradientType (const Aspect_GradientFillMethod AType);
179 void Render (const Handle(OpenGl_Workspace) &AWorkspace,
180 const Graphic3d_CView& ACView,
181 const Aspect_CLayer2d& ACUnderLayer,
182 const Aspect_CLayer2d& ACOverLayer);
186 DEFINE_STANDARD_RTTI(OpenGl_View)
190 void RenderStructs (const Handle(OpenGl_Workspace) &AWorkspace);
191 void RedrawLayer2d (const Handle(OpenGl_Workspace) &AWorkspace, const Graphic3d_CView& ACView, const Aspect_CLayer2d& ACLayer);
193 Standard_Integer myTextureEnv; //WSTextureEnv
194 Visual3d_TypeOfSurfaceDetail mySurfaceDetail; //WSSurfaceDetail
195 Standard_Integer myBackfacing; //WSBackfacing
197 OPENGL_BG_TEXTURE myBgTexture; //WSBgTexture
198 OPENGL_BG_GRADIENT myBgGradient; //WSBgGradient
201 Tmatrix3 myOrientationMatrix;
202 Tmatrix3 myMappingMatrix;
204 //Tint shield_indicator;
205 //TEL_COLOUR shield_colour;
206 //Tint border_indicator;
207 //TEL_COLOUR border_colour;
208 //Tint active_status;
210 OPENGL_ZCLIP myZClip;
211 NCollection_List<OPENGL_CLIP_REP> myClippingPlanes;
213 OPENGL_EXTRA_REP myExtra;
217 Handle(OpenGl_Trihedron) myTrihedron;
218 Handle(OpenGl_GraduatedTrihedron) myGraduatedTrihedron;
220 //View_LABViewContext
222 int myIntShadingMethod;
225 OpenGl_ListOfLight myLights;
229 Standard_Boolean myAntiAliasing;
231 //View_LABDepthCueing - fixed index used
233 OpenGl_LayerList myZLayers;
235 int myAnimationListIndex;
236 Standard_Boolean myAnimationListReady;
238 const TEL_TRANSFORM_PERSISTENCE *myTransPers;
239 Standard_Boolean myIsTransPers;
241 Standard_Boolean myResetFLIST;
244 DEFINE_STANDARD_ALLOC
247 #endif //_OpenGl_View_Header