42cf5bc1 |
1 | // Created on: 1992-01-15 |
2 | // Created by: GG |
3 | // Copyright (c) 1992-1999 Matra Datavision |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
5 | // |
6 | // This file is part of Open CASCADE Technology software library. |
7 | // |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
13 | // |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
16 | |
17 | #ifndef _V3d_View_HeaderFile |
18 | #define _V3d_View_HeaderFile |
19 | |
c357e426 |
20 | #include <Aspect_Background.hxx> |
21 | #include <Aspect_FillMethod.hxx> |
22 | #include <Aspect_GradientBackground.hxx> |
23 | #include <Aspect_GradientFillMethod.hxx> |
24 | #include <Aspect_GraphicCallbackProc.hxx> |
25 | #include <Aspect_Handle.hxx> |
26 | #include <Aspect_PrintAlgo.hxx> |
27 | #include <Aspect_RenderingContext.hxx> |
28 | #include <Aspect_TypeOfTriedronPosition.hxx> |
29 | #include <Aspect_TypeOfTriedronEcho.hxx> |
42cf5bc1 |
30 | |
c357e426 |
31 | #include <Bnd_Box.hxx> |
32 | |
33 | #include <gp_Ax3.hxx> |
42cf5bc1 |
34 | #include <gp_Dir.hxx> |
35 | #include <gp_Pnt.hxx> |
c357e426 |
36 | |
37 | #include <Graphic3d_BufferType.hxx> |
42cf5bc1 |
38 | #include <Graphic3d_Camera.hxx> |
c357e426 |
39 | #include <Graphic3d_ClipPlane.hxx> |
40 | #include <Graphic3d_CView.hxx> |
41 | #include <Graphic3d_GraduatedTrihedron.hxx> |
42 | #include <Graphic3d_RenderingParams.hxx> |
43 | #include <Graphic3d_SequenceOfHClipPlane.hxx> |
42cf5bc1 |
44 | #include <Graphic3d_Vector.hxx> |
45 | #include <Graphic3d_Vertex.hxx> |
c357e426 |
46 | |
47 | #include <Image_PixMap.hxx> |
48 | |
42cf5bc1 |
49 | #include <MMgt_TShared.hxx> |
c357e426 |
50 | |
51 | #include <Quantity_Coefficient.hxx> |
52 | #include <Quantity_Factor.hxx> |
53 | #include <Quantity_Length.hxx> |
42cf5bc1 |
54 | #include <Quantity_NameOfColor.hxx> |
c357e426 |
55 | #include <Quantity_Parameter.hxx> |
56 | #include <Quantity_PlaneAngle.hxx> |
57 | #include <Quantity_Ratio.hxx> |
58 | #include <Quantity_TypeOfColor.hxx> |
59 | |
60 | #include <Standard.hxx> |
61 | #include <Standard_Address.hxx> |
62 | #include <Standard_Boolean.hxx> |
42cf5bc1 |
63 | #include <Standard_CString.hxx> |
c357e426 |
64 | #include <Standard_Integer.hxx> |
65 | #include <Standard_Real.hxx> |
66 | #include <Standard_Type.hxx> |
67 | |
68 | #include <TColStd_Array2OfReal.hxx> |
69 | #include <TColStd_ListIteratorOfListOfTransient.hxx> |
70 | |
42cf5bc1 |
71 | #include <V3d_Coordinate.hxx> |
c357e426 |
72 | #include <V3d_ListOfTransient.hxx> |
73 | #include <V3d_StereoDumpOptions.hxx> |
74 | #include <V3d_TypeOfAxe.hxx> |
75 | |
76 | #include <V3d_TypeOfBackfacingModel.hxx> |
77 | #include <V3d_TypeOfOrientation.hxx> |
42cf5bc1 |
78 | #include <V3d_TypeOfShadingModel.hxx> |
79 | #include <V3d_TypeOfSurfaceDetail.hxx> |
c357e426 |
80 | #include <V3d_TypeOfView.hxx> |
42cf5bc1 |
81 | #include <V3d_TypeOfVisualization.hxx> |
42cf5bc1 |
82 | #include <V3d_TypeOfZclipping.hxx> |
c357e426 |
83 | #include <V3d_Viewer.hxx> |
84 | #include <V3d_ViewerPointer.hxx> |
85 | |
42cf5bc1 |
86 | class Aspect_Grid; |
c357e426 |
87 | class Aspect_Window; |
88 | class Bnd_Box; |
42cf5bc1 |
89 | class Graphic3d_Group; |
c357e426 |
90 | class Graphic3d_Structure; |
42cf5bc1 |
91 | class Graphic3d_TextureEnv; |
42cf5bc1 |
92 | class Graphic3d_Vector; |
c357e426 |
93 | class Quantity_Color; |
94 | class Standard_MultiplyDefined; |
95 | class Standard_TypeMismatch; |
96 | class V3d_BadValue; |
97 | class V3d_Light; |
98 | class V3d_UnMapped; |
42cf5bc1 |
99 | |
100 | class V3d_View; |
101 | DEFINE_STANDARD_HANDLE(V3d_View, MMgt_TShared) |
102 | |
103 | //! Defines the application object VIEW for the |
104 | //! VIEWER application. |
105 | //! The methods of this class allow the editing |
106 | //! and inquiring the parameters linked to the view. |
107 | //! (Projection,Mapping,Zclipping,DepthCueing,AntiAliasing |
108 | //! et Conversions) . |
109 | //! Provides a set of services common to all types of view. |
110 | //! Warning: The default parameters are defined by the class |
111 | //! Viewer (Example : SetDefaultViewSize()). |
112 | //! Certain methods are mouse oriented, and it is |
113 | //! necessary to know the difference between the start and |
114 | //! the continuation of this gesture in putting the method |
115 | //! into operation. |
116 | //! Example : Shifting the eye-view along the screen axes. |
117 | //! |
118 | //! View->Move(10.,20.,0.,True) (Starting motion) |
119 | //! View->Move(15.,-5.,0.,False) (Next motion) |
120 | class V3d_View : public MMgt_TShared |
121 | { |
122 | |
123 | public: |
124 | |
42cf5bc1 |
125 | //! Initializes the view. |
c357e426 |
126 | Standard_EXPORT V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView theType = V3d_ORTHOGRAPHIC); |
127 | |
42cf5bc1 |
128 | //! Initializes the view by copying. |
c357e426 |
129 | Standard_EXPORT V3d_View (const Handle(V3d_Viewer)& theViewer, const Handle(V3d_View)& theView); |
130 | |
131 | //! Default destructor. |
132 | Standard_EXPORT virtual ~V3d_View(); |
133 | |
42cf5bc1 |
134 | //! Activates the view in the specified Window |
135 | //! If <aContext> is not NULL the graphic context is used |
136 | //! to draw something in this view. |
137 | //! Otherwise an internal graphic context is created. |
138 | //! If <aDisplayCB> is not NULL then a user display CB is |
139 | //! call at the end of the OCC graphic traversal and just |
140 | //! before the swap of buffers. The <aClientData> is pass |
141 | //! to this call back. |
142 | //! Warning! raises MultiplyDefined from Standard |
143 | //! if the view is already activated in a window. |
144 | //! Warning: The view is centered and resized to preserve |
145 | //! the height/width ratio of the window. |
c357e426 |
146 | Standard_EXPORT void SetWindow (const Handle(Aspect_Window)& theWindow, |
147 | const Aspect_RenderingContext theContext = NULL, |
148 | const Aspect_GraphicCallbackProc& theDisplayCB = NULL, |
149 | const Standard_Address theClientData = NULL); |
150 | |
151 | Standard_EXPORT void SetMagnify (const Handle(Aspect_Window)& theWindow, |
152 | const Handle(V3d_View)& thePreviousView, |
153 | const Standard_Integer theX1, |
154 | const Standard_Integer theY1, |
155 | const Standard_Integer theX2, |
156 | const Standard_Integer theY2); |
157 | |
42cf5bc1 |
158 | //! Destroys the view. |
159 | Standard_EXPORT void Remove() const; |
c357e426 |
160 | |
42cf5bc1 |
161 | //! Deprecated, Redraw() should be used instead. |
162 | Standard_EXPORT void Update() const; |
c357e426 |
163 | |
42cf5bc1 |
164 | //! Redisplays the view even if there has not |
165 | //! been any modification. |
166 | //! Must be called if the view is shown. |
167 | //! (Ex: DeIconification ) . |
168 | Standard_EXPORT void Redraw() const; |
c357e426 |
169 | |
42cf5bc1 |
170 | //! Updates layer of immediate presentations. |
171 | Standard_EXPORT void RedrawImmediate() const; |
c357e426 |
172 | |
42cf5bc1 |
173 | //! Invalidates view content but does not redraw it. |
174 | Standard_EXPORT void Invalidate() const; |
62e1beed |
175 | |
176 | //! Returns true if cached view content has been invalidated. |
177 | Standard_EXPORT Standard_Boolean IsInvalidated() const; |
178 | |
42cf5bc1 |
179 | //! Must be called when the window supporting the |
180 | //! view changes size. |
181 | //! if the view is not mapped on a window. |
182 | //! Warning: The view is centered and resized to preserve |
183 | //! the height/width ratio of the window. |
184 | Standard_EXPORT void MustBeResized(); |
c357e426 |
185 | |
42cf5bc1 |
186 | //! Must be called when the window supporting the |
187 | //! view is mapped or unmapped. |
188 | Standard_EXPORT void DoMapping(); |
c357e426 |
189 | |
42cf5bc1 |
190 | //! Returns the status of the view regarding |
191 | //! the displayed structures inside |
192 | //! Returns True is The View is empty |
193 | Standard_EXPORT Standard_Boolean IsEmpty() const; |
c357e426 |
194 | |
42cf5bc1 |
195 | //! Updates the lights of the view. The view is redrawn. |
196 | Standard_EXPORT void UpdateLights() const; |
c357e426 |
197 | |
198 | //! Sets the automatic z-fit mode and its parameters. |
199 | //! The auto z-fit has extra parameters which can controlled from application level |
200 | //! to ensure that the size of viewing volume will be sufficiently large to cover |
201 | //! the depth of unmanaged objects, for example, transformation persistent ones. |
202 | //! @param theScaleFactor [in] the scale factor for Z-range. |
203 | //! The range between Z-min, Z-max projection volume planes |
204 | //! evaluated by z fitting method will be scaled using this coefficient. |
205 | //! Program error exception is thrown if negative or zero value |
206 | //! is passed. |
207 | Standard_EXPORT void SetAutoZFitMode (const Standard_Boolean theIsOn, const Standard_Real theScaleFactor = 1.0); |
208 | |
209 | //! returns TRUE if automatic z-fit mode is turned on. |
210 | Standard_EXPORT Standard_Boolean AutoZFitMode() const; |
211 | |
212 | //! returns scale factor parameter of automatic z-fit mode. |
213 | Standard_EXPORT Standard_Real AutoZFitScaleFactor() const; |
214 | |
42cf5bc1 |
215 | //! If automatic z-range fitting is turned on, adjusts Z-min and Z-max |
216 | //! projection volume planes with call to ZFitAll. |
c357e426 |
217 | Standard_EXPORT void AutoZFit() const; |
218 | |
42cf5bc1 |
219 | //! Change Z-min and Z-max planes of projection volume to match the |
220 | //! displayed objects. |
c357e426 |
221 | Standard_EXPORT void ZFitAll (const Standard_Real theScaleFactor = 1.0) const; |
222 | |
223 | //! Defines the background color of the view by the color definition type and the three corresponding values. |
224 | Standard_EXPORT void SetBackgroundColor (const Quantity_TypeOfColor theType, |
225 | const Quantity_Parameter theV1, |
226 | const Quantity_Parameter theV2, |
227 | const Quantity_Parameter theV3); |
228 | |
229 | //! Defines the background color of the view. |
230 | Standard_EXPORT void SetBackgroundColor (const Quantity_Color& theColor); |
231 | |
232 | //! Defines the background color of the view by supplying the color name in the form Quantity_NOC_xxxx. |
233 | Standard_EXPORT void SetBackgroundColor (const Quantity_NameOfColor theName); |
234 | |
235 | //! Defines the gradient background colors of the view by supplying the colors |
236 | //! and the fill method (horizontal by default). |
237 | Standard_EXPORT void SetBgGradientColors (const Quantity_Color& theColor1, |
238 | const Quantity_Color& theColor2, |
239 | const Aspect_GradientFillMethod theFillStyle = Aspect_GFM_HOR, |
240 | const Standard_Boolean theToUpdate = Standard_False); |
241 | |
242 | //! Defines the gradient background colors of the view by supplying the color names |
243 | //! and the fill method (horizontal by default). |
244 | Standard_EXPORT void SetBgGradientColors (const Quantity_NameOfColor theColor1, |
245 | const Quantity_NameOfColor theColor2, |
246 | const Aspect_GradientFillMethod theFillStyle = Aspect_GFM_HOR, |
247 | const Standard_Boolean theToUpdate = Standard_False); |
248 | |
249 | //! Defines the gradient background fill method of the view. |
250 | Standard_EXPORT void SetBgGradientStyle (const Aspect_GradientFillMethod theMethod = Aspect_GFM_HOR, |
251 | const Standard_Boolean theToUpdate = Standard_False); |
252 | |
253 | //! Defines the background texture of the view by supplying the texture image file name |
254 | //! and fill method (centered by default). |
255 | Standard_EXPORT void SetBackgroundImage (const Standard_CString theFileName, |
256 | const Aspect_FillMethod theFillStyle = Aspect_FM_CENTERED, |
257 | const Standard_Boolean theToUpdate = Standard_False); |
258 | |
259 | //! Defines the textured background fill method of the view. |
260 | Standard_EXPORT void SetBgImageStyle (const Aspect_FillMethod theFillStyle, |
261 | const Standard_Boolean theToUpdate = Standard_False); |
262 | |
42cf5bc1 |
263 | //! Definition of an axis from its origin and |
264 | //! its orientation . |
265 | //! This will be the current axis for rotations and movements. |
266 | //! Warning! raises BadValue from V3d if the vector normal is NULL. . |
267 | Standard_EXPORT void SetAxis (const V3d_Coordinate X, const V3d_Coordinate Y, const V3d_Coordinate Z, const Quantity_Parameter Vx, const Quantity_Parameter Vy, const Quantity_Parameter Vz); |
c357e426 |
268 | |
269 | //! Defines the shading model for the visualization. Various models are available. |
270 | Standard_EXPORT void SetShadingModel (const V3d_TypeOfShadingModel theShadingModel); |
271 | |
272 | //! Selects the kind of rendering for texture mapping. No texture mapping by default. |
273 | Standard_EXPORT void SetSurfaceDetail (const V3d_TypeOfSurfaceDetail theSurfaceDetail); |
274 | |
275 | //! Sets the environment texture to use. No environment texture by default. |
276 | Standard_EXPORT void SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTexture); |
277 | |
278 | //! Defines the visualization type in the view. |
279 | Standard_EXPORT void SetVisualization (const V3d_TypeOfVisualization theType); |
280 | |
42cf5bc1 |
281 | //! Activates antialiasing in the view. |
282 | Standard_EXPORT void SetAntialiasingOn(); |
c357e426 |
283 | |
284 | //! Deactivates antialiasing in the view. |
42cf5bc1 |
285 | Standard_EXPORT void SetAntialiasingOff(); |
c357e426 |
286 | |
42cf5bc1 |
287 | //! Defines the depth of the medium clipping plane. |
c357e426 |
288 | Standard_EXPORT void SetZClippingDepth (const Quantity_Length theDepth); |
289 | |
290 | //! Defines the thickness around the medium clipping plane. |
291 | Standard_EXPORT void SetZClippingWidth (const Quantity_Length theWidth); |
292 | |
42cf5bc1 |
293 | //! Defines the type of ZClipping. |
c357e426 |
294 | Standard_EXPORT void SetZClippingType (const V3d_TypeOfZclipping theType); |
295 | |
42cf5bc1 |
296 | //! Defines the depth of the medium plane. |
c357e426 |
297 | Standard_EXPORT void SetZCueingDepth (const Quantity_Length theDepth); |
298 | |
42cf5bc1 |
299 | //! Defines the thickness around the medium plane. |
c357e426 |
300 | Standard_EXPORT void SetZCueingWidth (const Quantity_Length theWidth); |
301 | |
42cf5bc1 |
302 | //! Activates ZCueing in the view. |
303 | Standard_EXPORT void SetZCueingOn(); |
c357e426 |
304 | |
305 | //! Deactivates ZCueing in the view. |
42cf5bc1 |
306 | Standard_EXPORT void SetZCueingOff(); |
c357e426 |
307 | |
308 | //! Activates theLight in the view. |
309 | Standard_EXPORT void SetLightOn (const Handle(V3d_Light)& theLight); |
310 | |
42cf5bc1 |
311 | //! Activates all the lights defined in this view. |
312 | Standard_EXPORT void SetLightOn(); |
c357e426 |
313 | |
314 | //! Deactivate theLight in this view. |
315 | Standard_EXPORT void SetLightOff (const Handle(V3d_Light)& theLight); |
316 | |
42cf5bc1 |
317 | //! Deactivate all the Lights defined in this view. |
318 | Standard_EXPORT void SetLightOff(); |
c357e426 |
319 | |
42cf5bc1 |
320 | //! Returns TRUE when the light is active in this view. |
c357e426 |
321 | Standard_EXPORT Standard_Boolean IsActiveLight (const Handle(V3d_Light)& theLight) const; |
322 | |
42cf5bc1 |
323 | //! sets the immediate update mode and returns the previous one. |
324 | Standard_EXPORT Standard_Boolean SetImmediateUpdate (const Standard_Boolean theImmediateUpdate); |
c357e426 |
325 | |
42cf5bc1 |
326 | //! Customization of the ZBUFFER Triedron. |
327 | //! XColor,YColor,ZColor - colors of axis |
c357e426 |
328 | //! SizeRatio - ratio of decreasing of the trihedron size when its physical |
42cf5bc1 |
329 | //! position comes out of the view |
330 | //! AxisDiametr - diameter relatively to axis length |
c357e426 |
331 | //! NbFacettes - number of facets of cylinders and cones |
332 | Standard_EXPORT void ZBufferTriedronSetup (const Quantity_NameOfColor theXColor = Quantity_NOC_RED, |
333 | const Quantity_NameOfColor theYColor = Quantity_NOC_GREEN, |
334 | const Quantity_NameOfColor theZColor = Quantity_NOC_BLUE1, |
335 | const Standard_Real theSizeRatio = 0.8, |
336 | const Standard_Real theAxisDiametr = 0.05, |
337 | const Standard_Integer theNbFacettes = 12); |
338 | |
42cf5bc1 |
339 | //! Display of the Triedron. |
340 | //! Initialize position, color and length of Triedron axes. |
341 | //! The scale is a percent of the window width. |
c357e426 |
342 | Standard_EXPORT void TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition = Aspect_TOTP_CENTER, |
343 | const Quantity_NameOfColor theColor = Quantity_NOC_WHITE, |
344 | const Standard_Real theScale = 0.02, |
345 | const V3d_TypeOfVisualization theMode = V3d_WIREFRAME); |
346 | |
42cf5bc1 |
347 | //! Erases the Triedron. |
348 | Standard_EXPORT void TriedronErase(); |
c357e426 |
349 | |
42cf5bc1 |
350 | //! Highlights the echo zone of the Triedron. |
c357e426 |
351 | Standard_EXPORT void TriedronEcho (const Aspect_TypeOfTriedronEcho theType = Aspect_TOTE_NONE); |
352 | |
42cf5bc1 |
353 | //! Returns data of a graduated trihedron. |
354 | Standard_EXPORT const Graphic3d_GraduatedTrihedron& GetGraduatedTrihedron() const; |
c357e426 |
355 | |
42cf5bc1 |
356 | //! Displays a graduated trihedron. |
c357e426 |
357 | Standard_EXPORT void GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData); |
358 | |
42cf5bc1 |
359 | //! Erases a graduated trihedron from the view. |
360 | Standard_EXPORT void GraduatedTrihedronErase(); |
c357e426 |
361 | |
42cf5bc1 |
362 | //! modify the Projection of the view perpendicularly to |
363 | //! the privileged plane of the viewer. |
364 | Standard_EXPORT void SetFront(); |
c357e426 |
365 | |
42cf5bc1 |
366 | //! Rotates the eye about the coordinate system of |
367 | //! reference of the screen |
368 | //! for which the origin is the view point of the projection, |
369 | //! with a relative angular value in RADIANS with respect to |
370 | //! the initial position expressed by Start = Standard_True |
371 | //! Warning! raises BadValue from V3d |
372 | //! If the eye, the view point, or the high point are |
373 | //! aligned or confused. |
374 | Standard_EXPORT void Rotate (const Quantity_PlaneAngle Ax, const Quantity_PlaneAngle Ay, const Quantity_PlaneAngle Az, const Standard_Boolean Start = Standard_True); |
c357e426 |
375 | |
42cf5bc1 |
376 | //! Rotates the eye about the coordinate system of |
377 | //! reference of the screen |
378 | //! for which the origin is Gravity point {X,Y,Z}, |
379 | //! with a relative angular value in RADIANS with respect to |
380 | //! the initial position expressed by Start = Standard_True |
381 | //! If the eye, the view point, or the high point are |
382 | //! aligned or confused. |
383 | Standard_EXPORT void Rotate (const Quantity_PlaneAngle Ax, const Quantity_PlaneAngle Ay, const Quantity_PlaneAngle Az, const V3d_Coordinate X, const V3d_Coordinate Y, const V3d_Coordinate Z, const Standard_Boolean Start = Standard_True); |
c357e426 |
384 | |
42cf5bc1 |
385 | //! Rotates the eye about one of the coordinate axes of |
386 | //! of the view for which the origin is the Gravity point{X,Y,Z} |
387 | //! with an relative angular value in RADIANS with |
388 | //! respect to the initial position expressed by |
389 | //! Start = Standard_True |
390 | Standard_EXPORT void Rotate (const V3d_TypeOfAxe Axe, const Quantity_PlaneAngle Angle, const V3d_Coordinate X, const V3d_Coordinate Y, const V3d_Coordinate Z, const Standard_Boolean Start = Standard_True); |
c357e426 |
391 | |
42cf5bc1 |
392 | //! Rotates the eye about one of the coordinate axes of |
393 | //! of the view for which the origin is the view point of the |
394 | //! projection with an relative angular value in RADIANS with |
395 | //! respect to the initial position expressed by |
396 | //! Start = Standard_True |
397 | Standard_EXPORT void Rotate (const V3d_TypeOfAxe Axe, const Quantity_PlaneAngle Angle, const Standard_Boolean Start = Standard_True); |
c357e426 |
398 | |
42cf5bc1 |
399 | //! Rotates the eye around the current axis a relative |
400 | //! angular value in RADIANS with respect to the initial |
401 | //! position expressed by Start = Standard_True |
402 | Standard_EXPORT void Rotate (const Quantity_PlaneAngle Angle, const Standard_Boolean Start = Standard_True); |
c357e426 |
403 | |
42cf5bc1 |
404 | //! Movement of the eye parallel to the coordinate system |
405 | //! of reference of the screen a distance relative to the |
406 | //! initial position expressed by Start = Standard_True. |
407 | Standard_EXPORT void Move (const Quantity_Length Dx, const Quantity_Length Dy, const Quantity_Length Dz, const Standard_Boolean Start = Standard_True); |
c357e426 |
408 | |
42cf5bc1 |
409 | //! Movement of the eye parallel to one of the axes of the |
410 | //! coordinate system of reference of the view a distance |
411 | //! relative to the initial position expressed by |
412 | //! Start = Standard_True. |
413 | Standard_EXPORT void Move (const V3d_TypeOfAxe Axe, const Quantity_Length Length, const Standard_Boolean Start = Standard_True); |
c357e426 |
414 | |
42cf5bc1 |
415 | //! Movement of the eye parllel to the current axis |
416 | //! a distance relative to the initial position |
417 | //! expressed by Start = Standard_True |
418 | Standard_EXPORT void Move (const Quantity_Length Length, const Standard_Boolean Start = Standard_True); |
c357e426 |
419 | |
42cf5bc1 |
420 | //! Movement of the ye and the view point parallel to the |
421 | //! frame of reference of the screen a distance relative |
422 | //! to the initial position expressed by |
423 | //! Start = Standard_True |
424 | Standard_EXPORT void Translate (const Quantity_Length Dx, const Quantity_Length Dy, const Quantity_Length Dz, const Standard_Boolean Start = Standard_True); |
c357e426 |
425 | |
42cf5bc1 |
426 | //! Movement of the eye and the view point parallel to one |
427 | //! of the axes of the fame of reference of the view a |
428 | //! distance relative to the initial position |
429 | //! expressed by Start = Standard_True |
430 | Standard_EXPORT void Translate (const V3d_TypeOfAxe Axe, const Quantity_Length Length, const Standard_Boolean Start = Standard_True); |
c357e426 |
431 | |
42cf5bc1 |
432 | //! Movement of the eye and view point parallel to |
433 | //! the current axis a distance relative to the initial |
434 | //! position expressed by Start = Standard_True |
435 | Standard_EXPORT void Translate (const Quantity_Length Length, const Standard_Boolean Start = Standard_True); |
c357e426 |
436 | |
42cf5bc1 |
437 | //! places the point of the view corresponding |
438 | //! at the pixel position x,y at the center of the window |
439 | //! and updates the view. |
440 | Standard_EXPORT void Place (const Standard_Integer theXp, const Standard_Integer theYp, const Quantity_Factor theZoomFactor = 1); |
c357e426 |
441 | |
42cf5bc1 |
442 | //! Rotation of the view point around the frame of reference |
443 | //! of the screen for which the origin is the eye of the |
444 | //! projection with a relative angular value in RADIANS |
445 | //! with respect to the initial position expressed by |
446 | //! Start = Standard_True |
447 | Standard_EXPORT void Turn (const Quantity_PlaneAngle Ax, const Quantity_PlaneAngle Ay, const Quantity_PlaneAngle Az, const Standard_Boolean Start = Standard_True); |
c357e426 |
448 | |
42cf5bc1 |
449 | //! Rotation of the view point around one of the axes of the |
450 | //! frame of reference of the view for which the origin is |
451 | //! the eye of the projection with an angular value in |
452 | //! RADIANS relative to the initial position expressed by |
453 | //! Start = Standard_True |
454 | Standard_EXPORT void Turn (const V3d_TypeOfAxe Axe, const Quantity_PlaneAngle Angle, const Standard_Boolean Start = Standard_True); |
c357e426 |
455 | |
42cf5bc1 |
456 | //! Rotation of the view point around the current axis an |
457 | //! angular value in RADIANS relative to the initial |
458 | //! position expressed by Start = Standard_True |
459 | Standard_EXPORT void Turn (const Quantity_PlaneAngle Angle, const Standard_Boolean Start = Standard_True); |
c357e426 |
460 | |
42cf5bc1 |
461 | //! Defines the angular position of the high point of |
462 | //! the reference frame of the view with respect to the |
463 | //! Y screen axis with an absolute angular value in |
464 | //! RADIANS. |
465 | Standard_EXPORT void SetTwist (const Quantity_PlaneAngle Angle); |
c357e426 |
466 | |
42cf5bc1 |
467 | //! Defines the position of the eye.. |
468 | Standard_EXPORT void SetEye (const V3d_Coordinate X, const V3d_Coordinate Y, const V3d_Coordinate Z); |
c357e426 |
469 | |
42cf5bc1 |
470 | //! Defines the Depth of the eye from the view point |
471 | //! without update the projection . |
472 | Standard_EXPORT void SetDepth (const Quantity_Length Depth); |
c357e426 |
473 | |
42cf5bc1 |
474 | //! Defines the orientation of the projection. |
475 | Standard_EXPORT void SetProj (const Quantity_Parameter Vx, const Quantity_Parameter Vy, const Quantity_Parameter Vz); |
c357e426 |
476 | |
42cf5bc1 |
477 | //! Defines the orientation of the projection . |
478 | Standard_EXPORT void SetProj (const V3d_TypeOfOrientation Orientation); |
c357e426 |
479 | |
42cf5bc1 |
480 | //! Defines the position of the view point. |
481 | Standard_EXPORT void SetAt (const V3d_Coordinate X, const V3d_Coordinate Y, const V3d_Coordinate Z); |
c357e426 |
482 | |
42cf5bc1 |
483 | //! Defines the orientation of the high point. |
484 | Standard_EXPORT void SetUp (const Quantity_Parameter Vx, const Quantity_Parameter Vy, const Quantity_Parameter Vz); |
c357e426 |
485 | |
42cf5bc1 |
486 | //! Defines the orientation(SO) of the high point. |
487 | Standard_EXPORT void SetUp (const V3d_TypeOfOrientation Orientation); |
c357e426 |
488 | |
42cf5bc1 |
489 | //! Saves the current state of the orientation of the view |
490 | //! which will be the return state at ResetViewOrientation. |
491 | Standard_EXPORT void SetViewOrientationDefault(); |
c357e426 |
492 | |
42cf5bc1 |
493 | //! Resets the orientation of the view. |
494 | //! Updates the view |
495 | Standard_EXPORT void ResetViewOrientation(); |
c357e426 |
496 | |
42cf5bc1 |
497 | //! Translates the center of the view along "x" and "y" axes of |
498 | //! view projection. Can be used to perform interactive panning operation. |
499 | //! In that case the DXv, DXy parameters specify panning relative to the |
500 | //! point where the operation is started. |
501 | //! @param theDXv [in] the relative panning on "x" axis of view projection, in view space coordinates. |
502 | //! @param theDYv [in] the relative panning on "y" axis of view projection, in view space coordinates. |
503 | //! @param theZoomFactor [in] the zooming factor. |
504 | //! @param theToStart [in] pass TRUE when starting panning to remember view |
505 | //! state prior to panning for relative arguments. If panning is started, |
506 | //! passing {0, 0} for {theDXv, theDYv} will return view to initial state. |
507 | //! Performs update of view. |
508 | Standard_EXPORT void Panning (const Standard_Real theDXv, const Standard_Real theDYv, const Quantity_Factor theZoomFactor = 1, const Standard_Boolean theToStart = Standard_True); |
c357e426 |
509 | |
42cf5bc1 |
510 | //! Relocates center of screen to the point, determined by |
511 | //! {Xp, Yp} pixel coordinates relative to the bottom-left corner of |
512 | //! screen. To calculate pixel coordinates for any point from world |
513 | //! coordinate space, it can be projected using "Project". |
514 | //! @param theXp [in] the x coordinate. |
515 | //! @param theYp [in] the y coordinate. |
516 | Standard_EXPORT void SetCenter (const Standard_Integer theXp, const Standard_Integer theYp); |
c357e426 |
517 | |
42cf5bc1 |
518 | //! Defines the view projection size in its maximum dimension, |
519 | //! keeping the inital height/width ratio unchanged. |
520 | Standard_EXPORT void SetSize (const Quantity_Length theSize); |
c357e426 |
521 | |
42cf5bc1 |
522 | //! Defines the Depth size of the view |
523 | //! Front Plane will be set to Size/2. |
524 | //! Back Plane will be set to -Size/2. |
525 | //! Any Object located Above the Front Plane or |
526 | //! behind the Back Plane will be Clipped . |
527 | //! NOTE than the XY Size of the View is NOT modified . |
c357e426 |
528 | Standard_EXPORT void SetZSize (const Quantity_Length SetZSize); |
529 | |
42cf5bc1 |
530 | //! Zooms the view by a factor relative to the initial |
531 | //! value expressed by Start = Standard_True |
532 | //! Updates the view. |
533 | Standard_EXPORT void SetZoom (const Quantity_Factor Coef, const Standard_Boolean Start = Standard_True); |
c357e426 |
534 | |
42cf5bc1 |
535 | //! Zooms the view by a factor relative to the value |
536 | //! initialised by SetViewMappingDefault(). |
537 | //! Updates the view. |
538 | Standard_EXPORT void SetScale (const Quantity_Factor Coef); |
c357e426 |
539 | |
42cf5bc1 |
540 | //! Sets anisotropic (axial) scale factors <Sx>, <Sy>, <Sz> for view <me>. |
541 | //! Anisotropic scaling operation is performed through multiplying |
542 | //! the current view orientation matrix by a scaling matrix: |
543 | //! || Sx 0 0 0 || |
544 | //! || 0 Sy 0 0 || |
545 | //! || 0 0 Sz 0 || |
546 | //! || 0 0 0 1 || |
547 | //! Updates the view. |
548 | Standard_EXPORT void SetAxialScale (const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz); |
c357e426 |
549 | |
42cf5bc1 |
550 | //! Adjust view parameters to fit the displayed scene, respecting height / width ratio. |
551 | //! The Z clipping range (depth range) is fitted if AutoZFit flag is TRUE. |
552 | //! Throws program error exception if margin coefficient is < 0 or >= 1. |
553 | //! Updates the view. |
554 | //! @param theMargin [in] the margin coefficient for view borders. |
555 | //! @param theToUpdate [in] flag to perform view update. |
556 | Standard_EXPORT void FitAll (const Quantity_Coefficient theMargin = 0.01, const Standard_Boolean theToUpdate = Standard_True); |
c357e426 |
557 | |
42cf5bc1 |
558 | //! Adjust view parameters to fit the displayed scene, respecting height / width ratio |
559 | //! according to the custom bounding box given. |
560 | //! Throws program error exception if margin coefficient is < 0 or >= 1. |
561 | //! Updates the view. |
562 | //! @param theBox [in] the custom bounding box to fit. |
563 | //! @param theMargin [in] the margin coefficient for view borders. |
564 | //! @param theToUpdate [in] flag to perform view update. |
565 | Standard_EXPORT void FitAll (const Bnd_Box& theBox, const Quantity_Coefficient theMargin = 0.01, const Standard_Boolean theToUpdate = Standard_True); |
c357e426 |
566 | |
42cf5bc1 |
567 | //! Adjusts the viewing volume so as not to clip the displayed objects by front and back |
568 | //! and back clipping planes. Also sets depth value automatically depending on the |
569 | //! calculated Z size and Aspect parameter. |
570 | //! NOTE than the original XY size of the view is NOT modified . |
571 | Standard_EXPORT void DepthFitAll (const Quantity_Coefficient Aspect = 0.01, const Quantity_Coefficient Margin = 0.01); |
c357e426 |
572 | |
42cf5bc1 |
573 | //! Centers the defined projection window so that it occupies |
574 | //! the maximum space while respecting the initial |
575 | //! height/width ratio. |
576 | //! NOTE than the original Z size of the view is NOT modified . |
577 | Standard_EXPORT void FitAll (const Standard_Real theMinXv, const Standard_Real theMinYv, const Standard_Real theMaxXv, const Standard_Real theMaxYv); |
c357e426 |
578 | |
42cf5bc1 |
579 | //! Centers the defined PIXEL window so that it occupies |
580 | //! the maximum space while respecting the initial height/width ratio. |
581 | //! NOTE than the original Z size of the view is NOT modified. |
582 | //! @param theMinXp [in] pixel coordinates of minimal corner on x screen axis. |
583 | //! @param theMinYp [in] pixel coordinates of minimal corner on y screen axis. |
584 | //! @param theMaxXp [in] pixel coordinates of maximal corner on x screen axis. |
585 | //! @param theMaxYp [in] pixel coordinates of maximal corner on y screen axis. |
586 | Standard_EXPORT void WindowFit (const Standard_Integer theMinXp, const Standard_Integer theMinYp, const Standard_Integer theMaxXp, const Standard_Integer theMaxYp); |
c357e426 |
587 | |
42cf5bc1 |
588 | //! Saves the current view mapping. This will be the |
589 | //! state returned from ResetViewmapping. |
590 | Standard_EXPORT void SetViewMappingDefault(); |
c357e426 |
591 | |
42cf5bc1 |
592 | //! Resets the centering of the view. |
593 | //! Updates the view |
594 | Standard_EXPORT void ResetViewMapping(); |
c357e426 |
595 | |
596 | //! Resets the centering and the orientation of the view. |
597 | Standard_EXPORT void Reset (const Standard_Boolean theToUpdate = Standard_True); |
598 | |
42cf5bc1 |
599 | //! Converts the PIXEL value |
600 | //! to a value in the projection plane. |
601 | Standard_EXPORT Quantity_Length Convert (const Standard_Integer Vp) const; |
c357e426 |
602 | |
42cf5bc1 |
603 | //! Converts the point PIXEL into a point projected |
604 | //! in the reference frame of the projection plane. |
605 | Standard_EXPORT void Convert (const Standard_Integer Xp, const Standard_Integer Yp, V3d_Coordinate& Xv, V3d_Coordinate& Yv) const; |
c357e426 |
606 | |
42cf5bc1 |
607 | //! Converts tha value of the projection plane into |
608 | //! a PIXEL value. |
609 | Standard_EXPORT Standard_Integer Convert (const Quantity_Length Vv) const; |
c357e426 |
610 | |
42cf5bc1 |
611 | //! Converts the point defined in the reference frame |
612 | //! of the projection plane into a point PIXEL. |
613 | Standard_EXPORT void Convert (const V3d_Coordinate Xv, const V3d_Coordinate Yv, Standard_Integer& Xp, Standard_Integer& Yp) const; |
c357e426 |
614 | |
42cf5bc1 |
615 | //! Converts the projected point into a point |
616 | //! in the reference frame of the view corresponding |
617 | //! to the intersection with the projection plane |
618 | //! of the eye/view point vector. |
619 | Standard_EXPORT void Convert (const Standard_Integer Xp, const Standard_Integer Yp, V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z) const; |
c357e426 |
620 | |
42cf5bc1 |
621 | //! Converts the projected point into a point |
622 | //! in the reference frame of the view corresponding |
623 | //! to the intersection with the projection plane |
624 | //! of the eye/view point vector and returns the |
625 | //! projection ray for further computations. |
626 | Standard_EXPORT void ConvertWithProj (const Standard_Integer Xp, const Standard_Integer Yp, V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z, Quantity_Parameter& Vx, Quantity_Parameter& Vy, Quantity_Parameter& Vz) const; |
c357e426 |
627 | |
42cf5bc1 |
628 | //! Converts the projected point into the nearest grid point |
629 | //! in the reference frame of the view corresponding |
630 | //! to the intersection with the projection plane |
631 | //! of the eye/view point vector and display the grid marker. |
632 | //! Warning: When the grid is not active the result is identical to the above Convert() method. |
633 | //! How to use: |
634 | //! 1) Enable the grid echo display |
635 | //! myViewer->SetGridEcho(Standard_True); |
636 | //! 2) When application receive a move event: |
637 | //! 2.1) Check if any object is detected |
638 | //! if( myInteractiveContext->MoveTo(x,y) == AIS_SOD_Nothing ) { |
639 | //! 2.2) Check if the grid is active |
640 | //! if( myViewer->Grid()->IsActive() ) { |
641 | //! 2.3) Display the grid echo and gets the grid point |
642 | //! myView->ConvertToGrid(x,y,X,Y,Z); |
643 | //! myView->Viewer()->ShowGridEcho (myView, Graphic3d_Vertex (X,Y,Z)); |
644 | //! myView->RedrawImmediate(); |
645 | //! 2.4) Else this is the standard case |
646 | //! } else myView->Convert(x,y,X,Y,Z); |
647 | Standard_EXPORT void ConvertToGrid (const Standard_Integer Xp, const Standard_Integer Yp, V3d_Coordinate& Xg, V3d_Coordinate& Yg, V3d_Coordinate& Zg) const; |
c357e426 |
648 | |
42cf5bc1 |
649 | //! Converts the point into the nearest grid point |
650 | //! and display the grid marker. |
651 | Standard_EXPORT void ConvertToGrid (const V3d_Coordinate X, const V3d_Coordinate Y, const V3d_Coordinate Z, V3d_Coordinate& Xg, V3d_Coordinate& Yg, V3d_Coordinate& Zg) const; |
c357e426 |
652 | |
42cf5bc1 |
653 | //! Projects the point defined in the reference frame of |
654 | //! the view into the projected point in the associated window. |
655 | Standard_EXPORT void Convert (const V3d_Coordinate X, const V3d_Coordinate Y, const V3d_Coordinate Z, Standard_Integer& Xp, Standard_Integer& Yp) const; |
c357e426 |
656 | |
42cf5bc1 |
657 | //! Converts the point defined in the user space of |
c357e426 |
658 | //! the view to the projection plane at the depth |
659 | //! relative to theZ. |
660 | Standard_EXPORT void Project (const Standard_Real theX, |
661 | const Standard_Real theY, |
662 | const Standard_Real theZ, |
663 | Standard_Real& theXp, |
664 | Standard_Real& theYp) const; |
665 | |
666 | //! Converts the point defined in the user space of |
667 | //! the view to the projection plane at the depth |
668 | //! relative to theZ. |
669 | Standard_EXPORT void Project (const Standard_Real theX, |
670 | const Standard_Real theY, |
671 | const Standard_Real theZ, |
672 | Standard_Real& theXp, |
673 | Standard_Real& theYp, |
674 | Standard_Real& theZp) const; |
675 | |
42cf5bc1 |
676 | //! Returns the Background color values of the view |
677 | //! depending of the color Type. |
678 | Standard_EXPORT void BackgroundColor (const Quantity_TypeOfColor Type, Quantity_Parameter& V1, Quantity_Parameter& V2, Quantity_Parameter& V3) const; |
c357e426 |
679 | |
42cf5bc1 |
680 | //! Returns the Background color object of the view. |
681 | Standard_EXPORT Quantity_Color BackgroundColor() const; |
c357e426 |
682 | |
683 | //! Returns the gradient background colors of the view. |
684 | Standard_EXPORT void GradientBackgroundColors (Quantity_Color& theColor1, Quantity_Color& theColor2) const; |
685 | |
42cf5bc1 |
686 | //! Returns the gradient background of the view. |
687 | Standard_EXPORT Aspect_GradientBackground GradientBackground() const; |
c357e426 |
688 | |
42cf5bc1 |
689 | //! Returns the current value of the zoom expressed with |
690 | //! respect to SetViewMappingDefault(). |
691 | Standard_EXPORT Quantity_Factor Scale() const; |
c357e426 |
692 | |
42cf5bc1 |
693 | //! Returns the current values of the anisotropic (axial) scale factors. |
694 | Standard_EXPORT void AxialScale (Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz) const; |
c357e426 |
695 | |
42cf5bc1 |
696 | //! Returns the height and width of the view. |
697 | Standard_EXPORT void Size (Quantity_Length& Width, Quantity_Length& Height) const; |
c357e426 |
698 | |
42cf5bc1 |
699 | //! Returns the Depth of the view . |
700 | Standard_EXPORT Standard_Real ZSize() const; |
c357e426 |
701 | |
42cf5bc1 |
702 | //! Returns the position of the eye. |
703 | Standard_EXPORT void Eye (V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z) const; |
c357e426 |
704 | |
42cf5bc1 |
705 | //! Returns the position of point which emanating the |
706 | //! projections. |
707 | Standard_EXPORT void FocalReferencePoint (V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z) const; |
c357e426 |
708 | |
42cf5bc1 |
709 | //! Returns the coordinate of the point (Xpix,Ypix) |
710 | //! in the view (XP,YP,ZP), and the projection vector of the |
711 | //! view passing by the point (for PerspectiveView). |
712 | Standard_EXPORT void ProjReferenceAxe (const Standard_Integer Xpix, const Standard_Integer Ypix, V3d_Coordinate& XP, V3d_Coordinate& YP, V3d_Coordinate& ZP, V3d_Coordinate& VX, V3d_Coordinate& VY, V3d_Coordinate& VZ) const; |
c357e426 |
713 | |
42cf5bc1 |
714 | //! Returns the Distance between the Eye and View Point. |
715 | Standard_EXPORT Quantity_Length Depth() const; |
c357e426 |
716 | |
42cf5bc1 |
717 | //! Returns the projection vector. |
718 | Standard_EXPORT void Proj (Quantity_Parameter& Vx, Quantity_Parameter& Vy, Quantity_Parameter& Vz) const; |
c357e426 |
719 | |
42cf5bc1 |
720 | //! Returns the position of the view point. |
721 | Standard_EXPORT void At (V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z) const; |
c357e426 |
722 | |
42cf5bc1 |
723 | //! Returns the vector giving the position of the high point. |
724 | Standard_EXPORT void Up (Quantity_Parameter& Vx, Quantity_Parameter& Vy, Quantity_Parameter& Vz) const; |
c357e426 |
725 | |
42cf5bc1 |
726 | //! Returns in RADIANS the orientation of the view around |
727 | //! the visual axis measured from the Y axis of the screen. |
728 | Standard_EXPORT Quantity_PlaneAngle Twist() const; |
c357e426 |
729 | |
42cf5bc1 |
730 | //! Returns the current shading model. |
731 | Standard_EXPORT V3d_TypeOfShadingModel ShadingModel() const; |
c357e426 |
732 | |
42cf5bc1 |
733 | Standard_EXPORT V3d_TypeOfSurfaceDetail SurfaceDetail() const; |
c357e426 |
734 | |
42cf5bc1 |
735 | Standard_EXPORT Handle(Graphic3d_TextureEnv) TextureEnv() const; |
c357e426 |
736 | |
42cf5bc1 |
737 | //! Returns the current visualisation mode. |
738 | Standard_EXPORT V3d_TypeOfVisualization Visualization() const; |
c357e426 |
739 | |
42cf5bc1 |
740 | //! Indicates if the antialiasing is active (True) or |
741 | //! inactive (False). |
742 | Standard_EXPORT Standard_Boolean Antialiasing() const; |
c357e426 |
743 | |
42cf5bc1 |
744 | //! Returns activity and information on the Zcueing. |
745 | //! <Depth> : Depth of plane. |
746 | //! <Width> : Thickness around the plane. |
c357e426 |
747 | Standard_EXPORT Standard_Boolean ZCueing (Quantity_Length& theDepth, Quantity_Length& theWidth) const; |
748 | |
42cf5bc1 |
749 | //! Returns current information on the ZClipping. |
750 | //! <Depth> : Depth of plane. |
751 | //! <Width> : Thickness around the plane. |
752 | //! <TypeOfZclipping> : "BACK" |
753 | //! "FRONT" |
754 | //! "SLICE" |
755 | //! "OFF" |
c357e426 |
756 | Standard_EXPORT V3d_TypeOfZclipping ZClipping (Quantity_Length& theDepth, Quantity_Length& theWidth) const; |
757 | |
42cf5bc1 |
758 | //! Returns True if One light more can be |
759 | //! activated in this View. |
760 | Standard_EXPORT Standard_Boolean IfMoreLights() const; |
c357e426 |
761 | |
42cf5bc1 |
762 | //! initializes an iteration on the active Lights. |
763 | Standard_EXPORT void InitActiveLights(); |
c357e426 |
764 | |
42cf5bc1 |
765 | //! returns true if there are more active Light(s) to return. |
766 | Standard_EXPORT Standard_Boolean MoreActiveLights() const; |
c357e426 |
767 | |
42cf5bc1 |
768 | //! Go to the next active Light |
769 | //! (if there is not, ActiveLight will raise an exception) |
770 | Standard_EXPORT void NextActiveLights(); |
c357e426 |
771 | |
42cf5bc1 |
772 | Standard_EXPORT Handle(V3d_Light) ActiveLight() const; |
c357e426 |
773 | |
774 | //! Returns the MAX number of light associated to the view. |
775 | Standard_EXPORT Standard_Integer LightLimit() const; |
776 | |
42cf5bc1 |
777 | //! Returns the viewer in which the view has been created. |
778 | Standard_EXPORT Handle(V3d_Viewer) Viewer() const; |
c357e426 |
779 | |
42cf5bc1 |
780 | //! Returns True if MyView is associated with a window . |
781 | Standard_EXPORT Standard_Boolean IfWindow() const; |
c357e426 |
782 | |
42cf5bc1 |
783 | //! Returns the Aspect Window associated with the view. |
784 | Standard_EXPORT Handle(Aspect_Window) Window() const; |
c357e426 |
785 | |
42cf5bc1 |
786 | //! Returns the Type of the View |
787 | Standard_EXPORT V3d_TypeOfView Type() const; |
c357e426 |
788 | |
42cf5bc1 |
789 | //! Translates the center of the view along "x" and "y" axes of |
790 | //! view projection. Can be used to perform interactive panning operation. |
791 | //! In that case the DXp, DXp parameters specify panning relative to the |
792 | //! point where the operation is started. |
793 | //! @param theDXp [in] the relative panning on "x" axis of view projection, in pixels. |
794 | //! @param theDYp [in] the relative panning on "y" axis of view projection, in pixels. |
795 | //! @param theZoomFactor [in] the zooming factor. |
796 | //! @param theToStart [in] pass TRUE when starting panning to remember view |
797 | //! state prior to panning for relative arguments. Passing 0 for relative |
798 | //! panning parameter should return view panning to initial state. |
799 | //! Performs update of view. |
800 | Standard_EXPORT void Pan (const Standard_Integer theDXp, const Standard_Integer theDYp, const Quantity_Factor theZoomFactor = 1, const Standard_Boolean theToStart = Standard_True); |
c357e426 |
801 | |
42cf5bc1 |
802 | //! Zoom the view according to a zoom factor computed |
803 | //! from the distance between the 2 mouse position. |
804 | //! @param theXp1 [in] the x coordinate of first mouse position, in pixels. |
805 | //! @param theYp1 [in] the y coordinate of first mouse position, in pixels. |
806 | //! @param theXp2 [in] the x coordinate of second mouse position, in pixels. |
807 | //! @param theYp2 [in] the y coordinate of second mouse position, in pixels. |
808 | Standard_EXPORT void Zoom (const Standard_Integer theXp1, const Standard_Integer theYp1, const Standard_Integer theXp2, const Standard_Integer theYp2); |
c357e426 |
809 | |
42cf5bc1 |
810 | //! Defines starting point for ZoomAtPoint view operation. |
811 | //! @param theXp [in] the x mouse coordinate, in pixels. |
812 | //! @param theYp [in] the y mouse coordinate, in pixels. |
813 | Standard_EXPORT void StartZoomAtPoint (const Standard_Integer theXp, const Standard_Integer theYp); |
c357e426 |
814 | |
42cf5bc1 |
815 | //! Zooms the model at a pixel defined by the method StartZoomAtPoint(). |
816 | Standard_EXPORT void ZoomAtPoint (const Standard_Integer theMouseStartX, const Standard_Integer theMouseStartY, const Standard_Integer theMouseEndX, const Standard_Integer theMouseEndY); |
c357e426 |
817 | |
42cf5bc1 |
818 | //! Performs anisotropic scaling of <me> view along the given <Axis>. |
819 | //! The scale factor is calculated on a basis of |
820 | //! the mouse pointer displacement <Dx,Dy>. |
821 | //! The calculated scale factor is then passed to SetAxialScale(Sx, Sy, Sz) method. |
822 | Standard_EXPORT void AxialScale (const Standard_Integer Dx, const Standard_Integer Dy, const V3d_TypeOfAxe Axis); |
c357e426 |
823 | |
42cf5bc1 |
824 | //! Begin the rotation of the view around the screen axis |
825 | //! according to the mouse position <X,Y>. |
826 | //! Warning: Enable rotation around the Z screen axis when <zRotationThreshold> |
827 | //! factor is > 0 soon the distance from the start point and the center |
828 | //! of the view is > (medium viewSize * <zRotationThreshold> ). |
829 | //! Generally a value of 0.4 is usable to rotate around XY screen axis |
830 | //! inside the circular threshold area and to rotate around Z screen axis |
831 | //! outside this area. |
832 | Standard_EXPORT void StartRotation (const Standard_Integer X, const Standard_Integer Y, const Quantity_Ratio zRotationThreshold = 0.0); |
c357e426 |
833 | |
42cf5bc1 |
834 | //! Continues the rotation of the view |
835 | //! with an angle computed from the last and new mouse position <X,Y>. |
836 | Standard_EXPORT void Rotation (const Standard_Integer X, const Standard_Integer Y); |
c357e426 |
837 | |
42cf5bc1 |
838 | //! Change View Plane Distance for Perspective Views |
839 | //! Warning! raises TypeMismatch from Standard if the view |
840 | //! is not a perspective view. |
841 | Standard_EXPORT void SetFocale (const Quantity_Length Focale); |
c357e426 |
842 | |
42cf5bc1 |
843 | //! Returns the View Plane Distance for Perspective Views |
844 | Standard_EXPORT Quantity_Length Focale() const; |
c357e426 |
845 | |
846 | //! Returns the associated Graphic3d view. |
847 | Standard_EXPORT Handle(Graphic3d_CView) View() const; |
848 | |
849 | //! Switches computed HLR mode in the view. |
850 | Standard_EXPORT void SetComputedMode (const Standard_Boolean theMode); |
851 | |
852 | //! Returns the computed HLR mode state. |
42cf5bc1 |
853 | Standard_EXPORT Standard_Boolean ComputedMode() const; |
c357e426 |
854 | |
42cf5bc1 |
855 | //! idem than WindowFit |
856 | Standard_EXPORT void WindowFitAll (const Standard_Integer Xmin, const Standard_Integer Ymin, const Standard_Integer Xmax, const Standard_Integer Ymax); |
c357e426 |
857 | |
42cf5bc1 |
858 | //! Defines or Updates the definition of the |
859 | //! grid in <me> |
860 | Standard_EXPORT void SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid); |
c357e426 |
861 | |
42cf5bc1 |
862 | //! Defines or Updates the activity of the |
863 | //! grid in <me> |
864 | Standard_EXPORT void SetGridActivity (const Standard_Boolean aFlag); |
c357e426 |
865 | |
42cf5bc1 |
866 | //! dump the full contents of the view at the same |
867 | //! scale in the file <theFile>. The file name |
868 | //! extension must be one of ".png",".bmp",".jpg",".gif". |
869 | //! Returns FALSE when the dump has failed |
870 | Standard_EXPORT Standard_Boolean Dump (const Standard_CString theFile, const Graphic3d_BufferType& theBufferType = Graphic3d_BT_RGB); |
c357e426 |
871 | |
42cf5bc1 |
872 | //! print the contents of the view to printer with preview. |
c357e426 |
873 | //! <thePrintDC> : If you have already an PrinterDeviceContext (HDC), |
42cf5bc1 |
874 | //! then you can pass it to the print routines. |
875 | //! If you don't have an PrinterDeviceContext, then this parameter should |
876 | //! be NULL. |
c357e426 |
877 | //! <theShowDialog> : If thePrintDC == NULL, then you can force the print routines to |
42cf5bc1 |
878 | //! open a Print Dialog box. |
879 | //! If you want to do this, then set showDialog to TRUE |
880 | //! If you don't want to see a dialog (only possible, if you have a hPrnDC |
c357e426 |
881 | //! or the dialog box was opened once before) then set <theShowDialog> to FALSE. |
882 | //! <theShowBackground> : When set to FALSE then print the view without background color |
42cf5bc1 |
883 | //! (background is white) |
884 | //! else set to TRUE for printing with current background color. |
c357e426 |
885 | //! <theFilename>: If != NULL, then the view will be printed to a file. |
886 | //! <thePrintAlgorithm>: If you want to select the print algorithm, then you can |
42cf5bc1 |
887 | //! specify one of existing algorithms: Aspect_PA_STRETCH, Aspect_PA_TILE. |
888 | //! Returns Standard_True if the data is passed to the printer, otherwise |
889 | //! Standard_False if the print operation failed. This might be related to |
890 | //! insufficient memory or some internal errors. All this errors are |
891 | //! indicated by the message boxes (on level of OpenGl_GraphicDriver). |
892 | //! Warning: This function can reuse FBO assigned to the |
893 | //! view on level of OpenGl_GraphicDriver; Please take it into account if |
894 | //! you use it for your purposes; |
895 | //! Warning: Works only under Windows. |
c357e426 |
896 | Standard_EXPORT Standard_Boolean Print (const Aspect_Handle thePrintDC = 0, |
897 | const Standard_Boolean theShowDialog = Standard_True, |
898 | const Standard_Boolean theShowBackground = Standard_True, |
899 | const Standard_CString theFilename = NULL, |
900 | const Aspect_PrintAlgo thePrintAlgorithm = Aspect_PA_STRETCH) const; |
901 | |
902 | //! Export scene into the one of the Vector graphics formats (SVG, PS, PDF...). |
903 | //! In contrast to Bitmaps, Vector graphics is scalable (so you may got quality benefits |
904 | //! on printing to laser printer). Notice however that results may differ a lot and |
905 | //! do not contain some elements. |
906 | Standard_EXPORT Standard_Boolean Export (const Standard_CString theFileName, |
907 | const Graphic3d_ExportFormat theFormat, |
908 | const Graphic3d_SortType theSortType = Graphic3d_ST_BSP_Tree); |
909 | |
42cf5bc1 |
910 | //! Dumps the full contents of the view |
911 | //! to a pixmap of pixel size <theWidth> * <theHeight> and |
912 | //! buffer type <theBufferType>. If <theToKeepAspect> is true |
913 | //! the aspect ratio of view will be kept if <theWidth> and <theHeight> |
914 | //! define another ratio. |
915 | //! Pixmap will be automatically (re)allocated when needed. |
916 | //! When dumping stereographic camera - the corresponding |
917 | //! middle-point monographic projection will be used for dumping by default. |
918 | //! <theStereoOptions> flags are to be used for dumping then left or |
919 | //! right eye projections. |
920 | Standard_EXPORT Standard_Boolean ToPixMap (Image_PixMap& theImage, const Standard_Integer theWidth, const Standard_Integer theHeight, const Graphic3d_BufferType& theBufferType = Graphic3d_BT_RGB, const Standard_Boolean theToKeepAspect = Standard_True, const V3d_StereoDumpOptions theStereoOptions = V3d_SDO_MONO); |
c357e426 |
921 | |
42cf5bc1 |
922 | //! Manages display of the back faces |
923 | //! When <aModel> is TOBM_AUTOMATIC the object backfaces |
924 | //! are displayed only for surface objects and |
925 | //! never displayed for solid objects. |
926 | //! this was the previous mode. |
927 | //! <aModel> is TOBM_ALWAYS_DISPLAYED the object backfaces |
928 | //! are always displayed both for surfaces or solids. |
929 | //! <aModel> is TOBM_NEVER_DISPLAYED the object backfaces |
930 | //! are never displayed. |
c357e426 |
931 | Standard_EXPORT void SetBackFacingModel (const V3d_TypeOfBackfacingModel theModel = V3d_TOBM_AUTOMATIC); |
932 | |
42cf5bc1 |
933 | //! Returns current state of the back faces display |
934 | Standard_EXPORT V3d_TypeOfBackfacingModel BackFacingModel() const; |
c357e426 |
935 | |
42cf5bc1 |
936 | //! turns on/off opengl lighting, currently used in triedron displaying |
c357e426 |
937 | Standard_EXPORT void EnableGLLight (const Standard_Boolean theIsEnabled = Standard_True) const; |
938 | |
42cf5bc1 |
939 | //! returns the current state of the gl lighting |
940 | //! currently used in triedron displaying |
941 | Standard_EXPORT Standard_Boolean IsGLLightEnabled() const; |
c357e426 |
942 | |
42cf5bc1 |
943 | //! Adds clip plane to the view. The composition of clip planes truncates the |
944 | //! rendering space to convex volume. Number of supported clip planes can be consulted |
c357e426 |
945 | //! by PlaneLimit method of associated Graphic3d_GraphicDriver. |
946 | //! Please be aware that the planes which exceed the limit are ignored during rendering. |
42cf5bc1 |
947 | //! @param thePlane [in] the clip plane to be added to view. |
948 | Standard_EXPORT virtual void AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane); |
c357e426 |
949 | |
42cf5bc1 |
950 | //! Removes clip plane from the view. |
951 | //! @param thePlane [in] the clip plane to be removed from view. |
952 | Standard_EXPORT virtual void RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane); |
c357e426 |
953 | |
42cf5bc1 |
954 | //! Sets sequence of clip planes to the view. The planes that have been set |
955 | //! before are removed from the view. The composition of clip planes |
956 | //! truncates the rendering space to convex volume. Number of supported |
c357e426 |
957 | //! clip planes can be consulted by InquirePlaneLimit method of |
958 | //! Graphic3d_GraphicDriver. Please be aware that the planes that |
959 | //! exceed the limit are ignored during rendering. |
42cf5bc1 |
960 | //! @param thePlanes [in] the clip planes to set. |
961 | Standard_EXPORT void SetClipPlanes (const Graphic3d_SequenceOfHClipPlane& thePlanes); |
c357e426 |
962 | |
42cf5bc1 |
963 | //! Get clip planes. |
964 | //! @return sequence clip planes that have been set for the view |
965 | Standard_EXPORT const Graphic3d_SequenceOfHClipPlane& GetClipPlanes() const; |
c357e426 |
966 | |
967 | //! Returns the MAX number of clipping planes associated to the view. |
968 | Standard_EXPORT Standard_Integer PlaneLimit() const; |
969 | |
42cf5bc1 |
970 | //! Change camera used by view. |
971 | Standard_EXPORT void SetCamera (const Handle(Graphic3d_Camera)& theCamera); |
c357e426 |
972 | |
42cf5bc1 |
973 | //! Returns camera object of the view. |
974 | //! @return: handle to camera object, or NULL if 3D view does not use |
975 | //! the camera approach. |
976 | Standard_EXPORT const Handle(Graphic3d_Camera)& Camera() const; |
c357e426 |
977 | |
42cf5bc1 |
978 | //! Returns current rendering parameters and effect settings. |
979 | Standard_EXPORT const Graphic3d_RenderingParams& RenderingParams() const; |
c357e426 |
980 | |
42cf5bc1 |
981 | //! Returns reference to current rendering parameters and effect settings. |
982 | Standard_EXPORT Graphic3d_RenderingParams& ChangeRenderingParams(); |
c357e426 |
983 | |
42cf5bc1 |
984 | //! @return flag value of objects culling mechanism |
985 | Standard_EXPORT Standard_Boolean IsCullingEnabled() const; |
c357e426 |
986 | |
42cf5bc1 |
987 | //! Turn on/off automatic culling of objects outside frustrum (ON by default) |
988 | Standard_EXPORT void SetFrustumCulling (const Standard_Boolean theMode); |
989 | |
42cf5bc1 |
990 | friend |
991 | //! Activates all of the views of a viewer attached |
992 | //! to a window. |
993 | Standard_EXPORT void V3d_Viewer::SetViewOn(); |
994 | friend |
995 | //! Activates a particular view in the Viewer . |
996 | //! Must be call if the Window attached to the view |
997 | //! has been Deiconified . |
998 | Standard_EXPORT void V3d_Viewer::SetViewOn (const Handle(V3d_View)& View); |
999 | friend |
1000 | //! Deactivates all the views of a Viewer |
1001 | //! attached to a window. |
1002 | Standard_EXPORT void V3d_Viewer::SetViewOff(); |
1003 | friend |
1004 | //! Deactivates a particular view in the Viewer. |
1005 | //! Must be call if the Window attached to the view |
1006 | //! has been Iconified . |
1007 | Standard_EXPORT void V3d_Viewer::SetViewOff (const Handle(V3d_View)& View); |
1008 | |
1009 | |
1010 | DEFINE_STANDARD_RTTI(V3d_View,MMgt_TShared) |
1011 | |
1012 | protected: |
1013 | |
42cf5bc1 |
1014 | Standard_EXPORT void ImmediateUpdate() const; |
c357e426 |
1015 | |
42cf5bc1 |
1016 | //! Transform camera eye, center and scale to fit in the |
1017 | //! passed bounding box specified in WCS. |
1018 | //! @param theCamera [in] the camera. |
1019 | //! @param theBox [in] the bounding box. |
1020 | //! @param theMargin [in] the margin coefficient for view borders. |
1021 | //! @param theResolution [in] the minimum size of projection of |
1022 | //! bounding box in Xv or Yv direction when it considered to |
1023 | //! be a thin plane or point (without a volume). |
1024 | //! In this case only the center of camera is adjusted. |
1025 | //! @param theToEnlargeIfLine [in] if passed TRUE - in cases when the |
1026 | //! whole bounding box projected into thin line going along |
1027 | //! Z-axis of screen, the view plane is enlarged such that |
1028 | //! we see the whole line on rotation, otherwise only the |
1029 | //! center of camera is adjusted. |
1030 | //! @return TRUE if the fit all operation can be done. |
1031 | Standard_EXPORT Standard_Boolean FitMinMax (const Handle(Graphic3d_Camera)& theCamera, const Bnd_Box& theBox, const Standard_Real theMargin, const Standard_Real theResolution = 0.0, const Standard_Boolean theToEnlargeIfLine = Standard_True) const; |
c357e426 |
1032 | |
42cf5bc1 |
1033 | //! Scales camera to fit the view frame of defined width and height |
1034 | //! keeping the aspect. For orthogonal camera the method changes scale, |
1035 | //! for perspective adjusts Eye location about the Center point. |
1036 | //! @param theSizeXv [in] size of viewport frame on "x" axis. |
1037 | //! @param theSizeYv [in] size of viewport frame on "y" axis. |
1038 | Standard_EXPORT void Scale (const Handle(Graphic3d_Camera)& theCamera, const Standard_Real theSizeXv, const Standard_Real theSizeYv) const; |
42cf5bc1 |
1039 | |
c357e426 |
1040 | Standard_EXPORT void Translate (const Handle(Graphic3d_Camera)& theCamera, const Standard_Real theDXv, const Standard_Real theDYv) const; |
42cf5bc1 |
1041 | |
1042 | private: |
1043 | |
c357e426 |
1044 | //! Modifies the aspect ratio of the camera when |
1045 | //! the associated window is defined or resized. |
1046 | Standard_EXPORT void SetRatio(); |
1047 | |
42cf5bc1 |
1048 | //! Change the scale factor and position of the view |
1049 | //! such as the bounding box <Umin, Vmin, Umax, Vmax> is contains |
1050 | //! in the view. |
1051 | Standard_EXPORT void FitAll (const Handle(Aspect_Window)& aWindow, const V3d_Coordinate Umin, const V3d_Coordinate Vmin, const V3d_Coordinate Umax, const V3d_Coordinate Vmax); |
1052 | |
1053 | //! Determines the screen axes in the reference |
1054 | //! framework of the view. |
1055 | Standard_EXPORT static Standard_Boolean ScreenAxis (const gp_Dir& Vpn, const gp_Dir& Vup, Graphic3d_Vector& Xaxe, Graphic3d_Vector& Yaxe, Graphic3d_Vector& Zaxe); |
1056 | |
1057 | //! Transforms the Vertex V according to the matrice Matrix . |
1058 | Standard_EXPORT static Graphic3d_Vertex TrsPoint (const Graphic3d_Vertex& V, const TColStd_Array2OfReal& Matrix); |
1059 | |
1060 | //! Returns the objects number and the projection window |
1061 | //! of the objects contained in the view. |
1062 | Standard_EXPORT Standard_Integer MinMax (V3d_Coordinate& Umin, V3d_Coordinate& Vmin, V3d_Coordinate& Umax, V3d_Coordinate& Vmax) const; |
1063 | |
1064 | //! Returns the objects number and the box encompassing |
1065 | //! the objects contained in the view |
1066 | Standard_EXPORT Standard_Integer MinMax (V3d_Coordinate& Xmin, V3d_Coordinate& Ymin, V3d_Coordinate& Zmin, V3d_Coordinate& Xmax, V3d_Coordinate& Ymax, V3d_Coordinate& Zmax) const; |
1067 | |
1068 | //! Returns the Objects number and the gravity center |
1069 | //! of ALL viewable points in the view |
1070 | Standard_EXPORT void Gravity (V3d_Coordinate& X, V3d_Coordinate& Y, V3d_Coordinate& Z) const; |
1071 | |
1072 | Standard_EXPORT void Init(); |
1073 | |
1074 | //! Returns a new vertex when the grid is activated. |
1075 | Standard_EXPORT Graphic3d_Vertex Compute (const Graphic3d_Vertex& AVertex) const; |
1076 | |
c357e426 |
1077 | protected: |
1078 | |
1079 | Standard_Real myOldMouseX; |
1080 | Standard_Real myOldMouseY; |
1081 | gp_Dir myCamStartOpUp; |
1082 | gp_Pnt myCamStartOpEye; |
1083 | Standard_Real myCamStartOpBnd[6]; |
1084 | gp_Pnt myCamStartOpCenter; |
1085 | Handle(Graphic3d_Camera) myCamera; |
1086 | Handle(Graphic3d_Camera) myDefaultCamera; |
1087 | Handle(Graphic3d_CView) myView; |
1088 | Standard_Boolean myImmediateUpdate; |
1089 | |
1090 | private: |
1091 | |
42cf5bc1 |
1092 | V3d_ViewerPointer MyViewer; |
1093 | V3d_ListOfTransient MyActiveLights; |
42cf5bc1 |
1094 | Graphic3d_Vector MyDefaultViewAxis; |
1095 | Graphic3d_Vertex MyDefaultViewPoint; |
1096 | Handle(Aspect_Window) MyWindow; |
1097 | TColStd_ListIteratorOfListOfTransient myActiveLightsIterator; |
1098 | Standard_Integer sx; |
1099 | Standard_Integer sy; |
1100 | Standard_Real rx; |
1101 | Standard_Real ry; |
1102 | Standard_Real gx; |
1103 | Standard_Real gy; |
1104 | Standard_Real gz; |
1105 | Standard_Boolean myComputedMode; |
1106 | Standard_Boolean SwitchSetFront; |
1107 | Standard_Integer MyZoomAtPointX; |
1108 | Standard_Integer MyZoomAtPointY; |
1109 | Handle(Aspect_Grid) MyGrid; |
1110 | gp_Ax3 MyPlane; |
42cf5bc1 |
1111 | TColStd_Array2OfReal MyTrsf; |
1112 | Handle(Graphic3d_Structure) MyGridEchoStructure; |
1113 | Handle(Graphic3d_Group) MyGridEchoGroup; |
1114 | Graphic3d_Vector myXscreenAxis; |
1115 | Graphic3d_Vector myYscreenAxis; |
1116 | Graphic3d_Vector myZscreenAxis; |
1117 | Graphic3d_Vector myViewAxis; |
1118 | Graphic3d_Vertex myGravityReferencePoint; |
c357e426 |
1119 | Standard_Boolean myAutoZFitIsOn; |
1120 | Standard_Real myAutoZFitScaleFactor; |
42cf5bc1 |
1121 | }; |
1122 | |
42cf5bc1 |
1123 | #endif // _V3d_View_HeaderFile |