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