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