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