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