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