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