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