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