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