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