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