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