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