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