1 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 // This file is part of Open CASCADE Technology software library.
5 // This library is free software; you can redistribute it and/or modify it under
6 // the terms of the GNU Lesser General Public License version 2.1 as published
7 // by the Free Software Foundation, with special exception defined in the file
8 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
9 // distribution for complete text of the license and disclaimer of any warranty.
11 // Alternatively, this file may be used under the terms of Open CASCADE
12 // commercial license or contractual agreement.
14 #include <V3d_View.hxx>
16 #include <Aspect_CircularGrid.hxx>
17 #include <Aspect_GradientBackground.hxx>
18 #include <Aspect_Grid.hxx>
19 #include <Aspect_RectangularGrid.hxx>
20 #include <Aspect_Window.hxx>
21 #include <Bnd_Box.hxx>
25 #include <Graphic3d_AspectMarker3d.hxx>
26 #include <Graphic3d_GraphicDriver.hxx>
27 #include <Graphic3d_Group.hxx>
28 #include <Graphic3d_MapIteratorOfMapOfStructure.hxx>
29 #include <Graphic3d_MapOfStructure.hxx>
30 #include <Graphic3d_Structure.hxx>
31 #include <Graphic3d_TextureEnv.hxx>
32 #include <Image_AlienPixMap.hxx>
33 #include <Message.hxx>
34 #include <Message_Messenger.hxx>
35 #include <NCollection_Array1.hxx>
36 #include <Precision.hxx>
37 #include <Quantity_Color.hxx>
38 #include <Standard_Assert.hxx>
39 #include <Standard_DivideByZero.hxx>
40 #include <Standard_ErrorHandler.hxx>
41 #include <Standard_MultiplyDefined.hxx>
42 #include <Standard_ShortReal.hxx>
43 #include <Standard_Type.hxx>
44 #include <Standard_TypeMismatch.hxx>
45 #include <TColgp_Array1OfPnt.hxx>
46 #include <TColStd_Array2OfReal.hxx>
47 #include <TColStd_HSequenceOfInteger.hxx>
49 #include <V3d_BadValue.hxx>
50 #include <V3d_Light.hxx>
51 #include <V3d_StereoDumpOptions.hxx>
52 #include <V3d_UnMapped.hxx>
53 #include <V3d_Viewer.hxx>
55 IMPLEMENT_STANDARD_RTTIEXT(V3d_View,Standard_Transient)
57 #define DEUXPI (2. * M_PI)
61 static const Standard_Integer THE_NB_BOUND_POINTS = 8;
64 //=============================================================================
65 //function : Constructor
67 //=============================================================================
68 V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const V3d_TypeOfView theType)
69 : myIsInvalidatedImmediate (Standard_True),
70 MyViewer (theViewer.operator->()),
71 SwitchSetFront (Standard_False),
72 myZRotation (Standard_False),
75 myView = theViewer->Driver()->CreateView (theViewer->StructureManager());
77 myView->SetBackground (theViewer->GetBackgroundColor());
78 myView->SetGradientBackground (theViewer->GetGradientBackground());
80 ChangeRenderingParams() = theViewer->DefaultRenderingParams();
83 Handle(Graphic3d_Camera) aCamera = new Graphic3d_Camera();
84 aCamera->SetFOVy (45.0);
85 aCamera->SetIOD (Graphic3d_Camera::IODType_Relative, 0.05);
86 aCamera->SetZFocus (Graphic3d_Camera::FocusType_Relative, 1.0);
87 aCamera->SetProjectionType ((theType == V3d_ORTHOGRAPHIC)
88 ? Graphic3d_Camera::Projection_Orthographic
89 : Graphic3d_Camera::Projection_Perspective);
91 myDefaultCamera = new Graphic3d_Camera();
93 myImmediateUpdate = Standard_False;
94 SetAutoZFitMode (Standard_True, 1.0);
95 SetBackFacingModel (V3d_TOBM_AUTOMATIC);
97 SetAxis (0.,0.,0.,1.,1.,1.);
98 SetVisualization (theViewer->DefaultVisualization());
99 SetShadingModel (theViewer->DefaultShadingModel());
102 SetProj (theViewer->DefaultViewProj());
103 SetSize (theViewer->DefaultViewSize());
104 Standard_Real zsize = theViewer->DefaultViewSize();
106 SetDepth (theViewer->DefaultViewSize() / 2.0);
107 SetViewMappingDefault();
108 SetViewOrientationDefault();
109 theViewer->AddView (this);
111 myImmediateUpdate = Standard_True;
114 //=============================================================================
115 //function : Constructor
117 //=============================================================================
118 V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const Handle(V3d_View)& theView)
119 : myIsInvalidatedImmediate (Standard_True),
120 MyViewer (theViewer.operator->()),
121 SwitchSetFront(Standard_False),
122 myZRotation (Standard_False),
125 myView = theViewer->Driver()->CreateView (theViewer->StructureManager());
127 myView->CopySettings (theView->View());
128 myDefaultViewPoint = theView->myDefaultViewPoint;
129 myDefaultViewAxis = theView->myDefaultViewAxis;
131 myDefaultCamera = new Graphic3d_Camera (theView->DefaultCamera());
133 myImmediateUpdate = Standard_False;
134 SetAutoZFitMode (theView->AutoZFitMode(), theView->AutoZFitScaleFactor());
135 theViewer->AddView (this);
137 myImmediateUpdate = Standard_True;
140 //=============================================================================
141 //function : Destructor
143 //=============================================================================
144 V3d_View::~V3d_View()
146 if (!myView->IsRemoved())
152 //=============================================================================
153 //function : SetMagnify
155 //=============================================================================
156 void V3d_View::SetMagnify (const Handle(Aspect_Window)& theWindow,
157 const Handle(V3d_View)& thePreviousView,
158 const Standard_Integer theX1,
159 const Standard_Integer theY1,
160 const Standard_Integer theX2,
161 const Standard_Integer theY2)
163 if (!myView->IsRemoved() && !myView->IsDefined())
165 Standard_Real aU1, aV1, aU2, aV2;
166 thePreviousView->Convert (theX1, theY1, aU1, aV1);
167 thePreviousView->Convert (theX2, theY2, aU2, aV2);
168 myView->SetWindow (theWindow);
169 FitAll (aU1, aV1, aU2, aV2);
170 MyViewer->SetViewOn (this);
171 MyWindow = theWindow;
174 SetViewMappingDefault();
178 //=============================================================================
179 //function : SetWindow
181 //=============================================================================
182 void V3d_View::SetWindow (const Handle(Aspect_Window)& theWindow,
183 const Aspect_RenderingContext theContext)
185 if (myView->IsRemoved())
190 // method V3d_View::SetWindow() should assign the field MyWindow before calling Redraw()
191 MyWindow = theWindow;
192 myView->SetWindow (theWindow, theContext);
193 MyViewer->SetViewOn (this);
195 if (myImmediateUpdate)
201 //=============================================================================
204 //=============================================================================
205 void V3d_View::Remove()
207 if (!MyGrid.IsNull())
211 if (!myTrihedron.IsNull())
213 myTrihedron->Erase();
216 MyViewer->DelView (this);
218 Handle(Aspect_Window)& aWin = const_cast<Handle(Aspect_Window)&> (MyWindow);
222 //=============================================================================
225 //=============================================================================
226 void V3d_View::Update() const
228 if (!myView->IsDefined()
229 || !myView->IsActive())
234 myIsInvalidatedImmediate = Standard_False;
241 //=============================================================================
244 //=============================================================================
245 void V3d_View::Redraw() const
247 if (!myView->IsDefined()
248 || !myView->IsActive())
253 myIsInvalidatedImmediate = Standard_False;
254 Handle(Graphic3d_StructureManager) aStructureMgr = MyViewer->StructureManager();
255 for (Standard_Integer aRetryIter = 0; aRetryIter < 2; ++aRetryIter)
257 if (aStructureMgr->IsDeviceLost())
259 aStructureMgr->RecomputeStructures();
266 if (!aStructureMgr->IsDeviceLost())
273 //=============================================================================
274 //function : RedrawImmediate
276 //=============================================================================
277 void V3d_View::RedrawImmediate() const
279 if (!myView->IsDefined()
280 || !myView->IsActive())
285 myIsInvalidatedImmediate = Standard_False;
286 myView->RedrawImmediate();
289 //=============================================================================
290 //function : Invalidate
292 //=============================================================================
293 void V3d_View::Invalidate() const
295 if (!myView->IsDefined())
300 myView->Invalidate();
303 //=============================================================================
304 //function : IsInvalidated
306 //=============================================================================
307 Standard_Boolean V3d_View::IsInvalidated() const
309 return !myView->IsDefined()
310 || myView->IsInvalidated();
313 // ========================================================================
314 // function : SetAutoZFitMode
316 // ========================================================================
317 void V3d_View::SetAutoZFitMode (const Standard_Boolean theIsOn,
318 const Standard_Real theScaleFactor)
320 Standard_ASSERT_RAISE (theScaleFactor > 0.0, "Zero or negative scale factor is not allowed.");
321 myAutoZFitScaleFactor = theScaleFactor;
322 myAutoZFitIsOn = theIsOn;
325 //=============================================================================
326 //function : AutoZFit
328 //=============================================================================
329 void V3d_View::AutoZFit() const
336 ZFitAll (myAutoZFitScaleFactor);
339 //=============================================================================
342 //=============================================================================
343 void V3d_View::ZFitAll (const Standard_Real theScaleFactor) const
345 Bnd_Box aMinMaxBox = myView->MinMaxValues (Standard_False); // applicative min max boundaries
346 Bnd_Box aGraphicBox = myView->MinMaxValues (Standard_True); // real graphical boundaries (not accounting infinite flag).
348 myView->Camera()->ZFitAll (theScaleFactor, aMinMaxBox, aGraphicBox);
351 //=============================================================================
354 //=============================================================================
355 Standard_Boolean V3d_View::IsEmpty() const
357 Standard_Boolean TheStatus = Standard_True ;
358 if( myView->IsDefined() ) {
359 Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ;
360 if( Nstruct > 0 ) TheStatus = Standard_False ;
365 //=============================================================================
366 //function : UpdateLights
368 //=============================================================================
369 void V3d_View::UpdateLights() const
371 Handle(Graphic3d_LightSet) aLights = new Graphic3d_LightSet();
372 for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More(); anActiveLightIter.Next())
374 aLights->Add (anActiveLightIter.Value());
376 myView->SetLights (aLights);
379 //=============================================================================
380 //function : DoMapping
382 //=============================================================================
383 void V3d_View::DoMapping()
385 if (!myView->IsDefined())
390 myView->Window()->DoMapping();
393 //=============================================================================
394 //function : MustBeResized
396 //=============================================================================
397 void V3d_View::MustBeResized()
399 if (!myView->IsDefined())
407 if (myImmediateUpdate)
413 //=============================================================================
414 //function : SetBackgroundColor
416 //=============================================================================
417 void V3d_View::SetBackgroundColor (const Quantity_TypeOfColor theType,
418 const Standard_Real theV1,
419 const Standard_Real theV2,
420 const Standard_Real theV3)
422 Standard_Real aV1 = Max (Min (theV1, 1.0), 0.0);
423 Standard_Real aV2 = Max (Min (theV2, 1.0), 0.0);
424 Standard_Real aV3 = Max (Min (theV3, 1.0), 0.0);
426 SetBackgroundColor (Quantity_Color (aV1, aV2, aV3, theType));
429 //=============================================================================
430 //function : SetBackgroundColor
432 //=============================================================================
433 void V3d_View::SetBackgroundColor (const Quantity_Color& theColor)
435 myView->SetBackground (Aspect_Background (theColor));
437 if (myImmediateUpdate)
443 //=============================================================================
444 //function : SetBgGradientColors
446 //=============================================================================
447 void V3d_View::SetBgGradientColors (const Quantity_Color& theColor1,
448 const Quantity_Color& theColor2,
449 const Aspect_GradientFillMethod theFillStyle,
450 const Standard_Boolean theToUpdate)
452 Aspect_GradientBackground aGradientBg (theColor1, theColor2, theFillStyle);
454 myView->SetGradientBackground (aGradientBg);
456 if (myImmediateUpdate || theToUpdate)
462 //=============================================================================
463 //function : SetBgGradientStyle
465 //=============================================================================
466 void V3d_View::SetBgGradientStyle (const Aspect_GradientFillMethod theFillStyle, const Standard_Boolean theToUpdate)
468 Quantity_Color aColor1;
469 Quantity_Color aColor2;
470 GradientBackground().Colors (aColor1, aColor2);
472 SetBgGradientColors (aColor1, aColor2, theFillStyle, theToUpdate);
475 //=============================================================================
476 //function : SetBackgroundImage
478 //=============================================================================
479 void V3d_View::SetBackgroundImage (const Standard_CString theFileName,
480 const Aspect_FillMethod theFillStyle,
481 const Standard_Boolean theToUpdate)
483 Handle(Graphic3d_Texture2D) aTextureMap = new Graphic3d_Texture2Dmanual (theFileName);
484 aTextureMap->DisableModulate();
485 SetBackgroundImage (aTextureMap, theFillStyle, theToUpdate);
488 //=============================================================================
489 //function : SetBackgroundImage
491 //=============================================================================
492 void V3d_View::SetBackgroundImage (const Handle(Graphic3d_Texture2D)& theTexture,
493 const Aspect_FillMethod theFillStyle,
494 const Standard_Boolean theToUpdate)
496 myView->SetBackgroundImage (theTexture);
497 myView->SetBackgroundImageStyle (theFillStyle);
498 if (myImmediateUpdate || theToUpdate)
504 //=============================================================================
505 //function : SetBgImageStyle
507 //=============================================================================
508 void V3d_View::SetBgImageStyle (const Aspect_FillMethod theFillStyle, const Standard_Boolean theToUpdate)
510 myView->SetBackgroundImageStyle (theFillStyle);
512 if (myImmediateUpdate || theToUpdate)
518 //=============================================================================
519 //function : SetBackgroundCubeMap
521 //=============================================================================
522 void V3d_View::SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap,
523 Standard_Boolean theToUpdatePBREnv,
524 Standard_Boolean theToUpdate)
526 myView->SetBackgroundImage (theCubeMap, theToUpdatePBREnv);
527 if (myImmediateUpdate || theToUpdate)
533 //=============================================================================
534 //function : GeneratePBREnvironment
536 //=============================================================================
537 void V3d_View::GeneratePBREnvironment (Standard_Boolean theToUpdate)
539 myView->GeneratePBREnvironment();
540 if (myImmediateUpdate || theToUpdate)
546 //=============================================================================
547 //function : ClearPBREnvironment
549 //=============================================================================
550 void V3d_View::ClearPBREnvironment (Standard_Boolean theToUpdate)
552 myView->ClearPBREnvironment();
553 if (myImmediateUpdate || theToUpdate)
559 //=============================================================================
562 //=============================================================================
563 void V3d_View::SetAxis (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
564 const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
566 myDefaultViewPoint.SetCoord (theX, theY, theZ);
567 myDefaultViewAxis.SetCoord (theVx, theVy, theVz);
570 //=============================================================================
571 //function : SetShadingModel
573 //=============================================================================
574 void V3d_View::SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel)
576 myView->SetShadingModel (theShadingModel);
579 //=============================================================================
580 //function : SetTextureEnv
582 //=============================================================================
583 void V3d_View::SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTexture)
585 myView->SetTextureEnv (theTexture);
587 if (myImmediateUpdate)
593 //=============================================================================
594 //function : SetVisualization
596 //=============================================================================
597 void V3d_View::SetVisualization (const V3d_TypeOfVisualization theType)
599 myView->SetVisualizationType (static_cast <Graphic3d_TypeOfVisualization> (theType));
601 if (myImmediateUpdate)
607 //=============================================================================
608 //function : SetFront
610 //=============================================================================
611 void V3d_View::SetFront()
613 gp_Ax3 a = MyViewer->PrivilegedPlane();
614 Standard_Real xo, yo, zo, vx, vy, vz, xu, yu, zu;
616 a.Direction().Coord(vx,vy,vz);
617 a.YDirection().Coord(xu,yu,zu);
618 a.Location().Coord(xo,yo,zo);
620 Handle(Graphic3d_Camera) aCamera = Camera();
622 aCamera->SetCenter (gp_Pnt (xo, yo, zo));
626 aCamera->SetDirection (gp_Dir (vx, vy, vz));
630 aCamera->SetDirection (gp_Dir (vx, vy, vz).Reversed());
633 aCamera->SetUp (gp_Dir (xu, yu, zu));
635 SwitchSetFront = !SwitchSetFront;
640 //=============================================================================
643 //=============================================================================
644 void V3d_View::Rotate (const Standard_Real ax,
645 const Standard_Real ay,
646 const Standard_Real az,
647 const Standard_Boolean Start)
649 Standard_Real Ax = ax;
650 Standard_Real Ay = ay;
651 Standard_Real Az = az;
653 if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI;
654 else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI;
655 if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI;
656 else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI;
657 if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI;
658 else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI;
660 Handle(Graphic3d_Camera) aCamera = Camera();
664 myCamStartOpUp = aCamera->Up();
665 myCamStartOpDir = aCamera->Direction();
666 myCamStartOpEye = aCamera->Eye();
667 myCamStartOpCenter = aCamera->Center();
670 aCamera->SetUp (myCamStartOpUp);
671 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
672 aCamera->SetDirectionFromEye (myCamStartOpDir);
674 // rotate camera around 3 initial axes
675 gp_Dir aBackDir = -myCamStartOpDir;
676 gp_Dir aXAxis (myCamStartOpUp.Crossed (aBackDir));
677 gp_Dir aYAxis (aBackDir.Crossed (aXAxis));
678 gp_Dir aZAxis (aXAxis.Crossed (aYAxis));
680 gp_Trsf aRot[3], aTrsf;
681 aRot[0].SetRotation (gp_Ax1 (myCamStartOpCenter, aYAxis), -Ax);
682 aRot[1].SetRotation (gp_Ax1 (myCamStartOpCenter, aXAxis), Ay);
683 aRot[2].SetRotation (gp_Ax1 (myCamStartOpCenter, aZAxis), Az);
684 aTrsf.Multiply (aRot[0]);
685 aTrsf.Multiply (aRot[1]);
686 aTrsf.Multiply (aRot[2]);
688 aCamera->Transform (aTrsf);
693 //=============================================================================
696 //=============================================================================
697 void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Standard_Real az,
698 const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start)
701 Standard_Real Ax = ax ;
702 Standard_Real Ay = ay ;
703 Standard_Real Az = az ;
705 if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ;
706 else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ;
707 if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI ;
708 else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI ;
709 if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ;
710 else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ;
712 Handle(Graphic3d_Camera) aCamera = Camera();
716 myGravityReferencePoint.SetCoord (X, Y, Z);
717 myCamStartOpUp = aCamera->Up();
718 myCamStartOpDir = aCamera->Direction();
719 myCamStartOpEye = aCamera->Eye();
720 myCamStartOpCenter = aCamera->Center();
723 const Graphic3d_Vertex& aVref = myGravityReferencePoint;
725 aCamera->SetUp (myCamStartOpUp);
726 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
727 aCamera->SetDirectionFromEye (myCamStartOpDir);
729 // rotate camera around 3 initial axes
730 gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z());
732 gp_Dir aZAxis (aCamera->Direction().Reversed());
733 gp_Dir aYAxis (aCamera->Up());
734 gp_Dir aXAxis (aYAxis.Crossed (aZAxis));
736 gp_Trsf aRot[3], aTrsf;
737 aRot[0].SetRotation (gp_Ax1 (aRCenter, aYAxis), -Ax);
738 aRot[1].SetRotation (gp_Ax1 (aRCenter, aXAxis), Ay);
739 aRot[2].SetRotation (gp_Ax1 (aRCenter, aZAxis), Az);
740 aTrsf.Multiply (aRot[0]);
741 aTrsf.Multiply (aRot[1]);
742 aTrsf.Multiply (aRot[2]);
744 aCamera->Transform (aTrsf);
749 //=============================================================================
752 //=============================================================================
753 void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start)
757 Rotate(angle,0.,0.,Start);
760 Rotate(0.,angle,0.,Start);
763 Rotate(0.,0.,angle,Start);
768 //=============================================================================
771 //=============================================================================
772 void V3d_View::Rotate (const V3d_TypeOfAxe theAxe, const Standard_Real theAngle,
773 const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ, const Standard_Boolean theStart)
775 Standard_Real anAngle = theAngle;
777 if (anAngle > 0.0) while (anAngle > DEUXPI) anAngle -= DEUXPI;
778 else if (anAngle < 0.0) while (anAngle < -DEUXPI) anAngle += DEUXPI;
780 Handle(Graphic3d_Camera) aCamera = Camera();
784 myGravityReferencePoint.SetCoord (theX, theY, theZ);
785 myCamStartOpUp = aCamera->Up();
786 myCamStartOpDir = aCamera->Direction();
787 myCamStartOpEye = aCamera->Eye();
788 myCamStartOpCenter = aCamera->Center();
791 case V3d_X: myViewAxis = gp::DX(); break;
792 case V3d_Y: myViewAxis = gp::DY(); break;
793 case V3d_Z: myViewAxis = gp::DZ(); break;
797 const Graphic3d_Vertex& aVref = myGravityReferencePoint;
799 aCamera->SetUp (myCamStartOpUp);
800 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
801 aCamera->SetDirectionFromEye (myCamStartOpDir);
803 // rotate camera around passed axis
805 gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z());
806 gp_Dir aRAxis ((theAxe == V3d_X) ? 1.0 : 0.0,
807 (theAxe == V3d_Y) ? 1.0 : 0.0,
808 (theAxe == V3d_Z) ? 1.0 : 0.0);
810 aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), anAngle);
812 aCamera->Transform (aRotation);
817 //=============================================================================
820 //=============================================================================
821 void V3d_View::Rotate(const Standard_Real angle, const Standard_Boolean Start)
823 Standard_Real Angle = angle;
825 if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
826 else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
828 Handle(Graphic3d_Camera) aCamera = Camera();
832 myCamStartOpUp = aCamera->Up();
833 myCamStartOpDir = aCamera->Direction();
834 myCamStartOpEye = aCamera->Eye();
835 myCamStartOpCenter = aCamera->Center();
838 aCamera->SetUp (myCamStartOpUp);
839 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
840 aCamera->SetDirectionFromEye (myCamStartOpDir);
843 gp_Pnt aRCenter (myDefaultViewPoint);
844 gp_Dir aRAxis (myDefaultViewAxis);
845 aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
847 aCamera->Transform (aRotation);
852 //=============================================================================
855 //=============================================================================
856 void V3d_View::Turn(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Boolean Start)
858 Standard_Real Ax = ax;
859 Standard_Real Ay = ay;
860 Standard_Real Az = az;
862 if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ;
863 else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ;
864 if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI ;
865 else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI ;
866 if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ;
867 else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ;
869 Handle(Graphic3d_Camera) aCamera = Camera();
873 myCamStartOpUp = aCamera->Up();
874 myCamStartOpDir = aCamera->Direction();
875 myCamStartOpEye = aCamera->Eye();
876 myCamStartOpCenter = aCamera->Center();
879 aCamera->SetUp (myCamStartOpUp);
880 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
881 aCamera->SetDirectionFromEye (myCamStartOpDir);
883 // rotate camera around 3 initial axes
884 gp_Pnt aRCenter = aCamera->Eye();
885 gp_Dir aZAxis (aCamera->Direction().Reversed());
886 gp_Dir aYAxis (aCamera->Up());
887 gp_Dir aXAxis (aYAxis.Crossed (aZAxis));
889 gp_Trsf aRot[3], aTrsf;
890 aRot[0].SetRotation (gp_Ax1 (aRCenter, aYAxis), -Ax);
891 aRot[1].SetRotation (gp_Ax1 (aRCenter, aXAxis), Ay);
892 aRot[2].SetRotation (gp_Ax1 (aRCenter, aZAxis), Az);
893 aTrsf.Multiply (aRot[0]);
894 aTrsf.Multiply (aRot[1]);
895 aTrsf.Multiply (aRot[2]);
897 aCamera->Transform (aTrsf);
902 //=============================================================================
905 //=============================================================================
906 void V3d_View::Turn(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start)
910 Turn(angle,0.,0.,Start);
913 Turn(0.,angle,0.,Start);
916 Turn(0.,0.,angle,Start);
921 //=============================================================================
924 //=============================================================================
925 void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start)
927 Standard_Real Angle = angle ;
929 if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
930 else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
932 Handle(Graphic3d_Camera) aCamera = Camera();
936 myCamStartOpUp = aCamera->Up();
937 myCamStartOpDir = aCamera->Direction();
938 myCamStartOpEye = aCamera->Eye();
939 myCamStartOpCenter = aCamera->Center();
942 aCamera->SetUp (myCamStartOpUp);
943 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
944 aCamera->SetDirectionFromEye (myCamStartOpDir);
947 gp_Pnt aRCenter = aCamera->Eye();
948 gp_Dir aRAxis (myDefaultViewAxis);
949 aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
951 aCamera->Transform (aRotation);
956 //=============================================================================
957 //function : SetTwist
959 //=============================================================================
960 void V3d_View::SetTwist(const Standard_Real angle)
962 Standard_Real Angle = angle ;
964 if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
965 else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
967 Handle(Graphic3d_Camera) aCamera = Camera();
969 const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
970 if (!screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
971 && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
972 && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
974 throw V3d_BadValue ("V3d_ViewSetTwist, alignment of Eye,At,Up,");
977 gp_Pnt aRCenter = aCamera->Center();
978 gp_Dir aZAxis (aCamera->Direction().Reversed());
981 aTrsf.SetRotation (gp_Ax1 (aRCenter, aZAxis), Angle);
983 aCamera->SetUp (gp_Dir (myYscreenAxis));
984 aCamera->Transform (aTrsf);
989 //=============================================================================
992 //=============================================================================
993 void V3d_View::SetEye(const Standard_Real X,const Standard_Real Y,const Standard_Real Z)
995 Standard_Real aTwistBefore = Twist();
997 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
999 Handle(Graphic3d_Camera) aCamera = Camera();
1001 aCamera->SetEye (gp_Pnt (X, Y, Z));
1003 SetTwist (aTwistBefore);
1005 SetImmediateUpdate (wasUpdateEnabled);
1010 //=============================================================================
1011 //function : SetDepth
1013 //=============================================================================
1014 void V3d_View::SetDepth(const Standard_Real Depth)
1016 V3d_BadValue_Raise_if (Depth == 0. ,"V3d_View::SetDepth, bad depth");
1018 Handle(Graphic3d_Camera) aCamera = Camera();
1022 // Move eye using center (target) as anchor.
1023 aCamera->SetDistance (Depth);
1027 // Move the view ref point instead of the eye.
1028 gp_Vec aDir (aCamera->Direction());
1029 gp_Pnt aCameraEye = aCamera->Eye();
1030 gp_Pnt aCameraCenter = aCameraEye.Translated (aDir.Multiplied (Abs (Depth)));
1032 aCamera->SetCenter (aCameraCenter);
1038 //=============================================================================
1039 //function : SetProj
1041 //=============================================================================
1042 void V3d_View::SetProj( const Standard_Real Vx,const Standard_Real Vy, const Standard_Real Vz )
1044 V3d_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0.,
1045 "V3d_View::SetProj, null projection vector");
1047 Standard_Real aTwistBefore = Twist();
1049 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
1051 Camera()->SetDirection (gp_Dir (Vx, Vy, Vz).Reversed());
1053 SetTwist(aTwistBefore);
1055 SetImmediateUpdate (wasUpdateEnabled);
1060 //=============================================================================
1061 //function : SetProj
1063 //=============================================================================
1064 void V3d_View::SetProj (const V3d_TypeOfOrientation theOrientation,
1065 const Standard_Boolean theIsYup)
1067 Graphic3d_Vec3d anUp = theIsYup ? Graphic3d_Vec3d (0.0, 1.0, 0.0) : Graphic3d_Vec3d (0.0, 0.0, 1.0);
1070 if (theOrientation == V3d_Ypos
1071 || theOrientation == V3d_Yneg)
1073 anUp.SetValues (0.0, 0.0, -1.0);
1078 if (theOrientation == V3d_Zpos)
1080 anUp.SetValues (0.0, 1.0, 0.0);
1082 else if (theOrientation == V3d_Zneg)
1084 anUp.SetValues (0.0, -1.0, 0.0);
1088 const gp_Dir aBck = V3d::GetProjAxis (theOrientation);
1090 // retain camera panning from origin when switching projection
1091 const Handle(Graphic3d_Camera)& aCamera = Camera();
1092 const gp_Pnt anOriginVCS = aCamera->ConvertWorld2View (gp::Origin());
1094 const Standard_Real aNewDist = aCamera->Eye().Distance (gp_Pnt (0, 0, 0));
1095 aCamera->SetEyeAndCenter (gp_XYZ (0, 0, 0) + aBck.XYZ() * aNewDist,
1097 aCamera->SetDirectionFromEye (-aBck);
1098 aCamera->SetUp (gp_Dir (anUp.x(), anUp.y(), anUp.z()));
1099 aCamera->OrthogonalizeUp();
1101 Panning (anOriginVCS.X(), anOriginVCS.Y());
1106 //=============================================================================
1109 //=============================================================================
1110 void V3d_View::SetAt(const Standard_Real X,const Standard_Real Y,const Standard_Real Z)
1112 Standard_Real aTwistBefore = Twist();
1114 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
1116 Camera()->SetCenter (gp_Pnt (X, Y, Z));
1118 SetTwist (aTwistBefore);
1120 SetImmediateUpdate (wasUpdateEnabled);
1125 //=============================================================================
1128 //=============================================================================
1129 void V3d_View::SetUp (const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
1131 Handle(Graphic3d_Camera) aCamera = Camera();
1133 const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
1134 const gp_Dir anUp (theVx, theVy, theVz);
1135 if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis)
1136 && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
1137 && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
1138 && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
1140 throw V3d_BadValue ("V3d_View::Setup, alignment of Eye,At,Up");
1143 aCamera->SetUp (gp_Dir (myYscreenAxis));
1148 //=============================================================================
1151 //=============================================================================
1152 void V3d_View::SetUp (const V3d_TypeOfOrientation theOrientation)
1154 Handle(Graphic3d_Camera) aCamera = Camera();
1156 const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
1157 const gp_Dir anUp = V3d::GetProjAxis (theOrientation);
1158 if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis)
1159 && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
1160 && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
1161 && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
1163 throw V3d_BadValue ("V3d_View::SetUp, alignment of Eye,At,Up");
1166 aCamera->SetUp (gp_Dir (myYscreenAxis));
1171 //=============================================================================
1172 //function : SetViewOrientationDefault
1174 //=============================================================================
1175 void V3d_View::SetViewOrientationDefault()
1177 myDefaultCamera->CopyOrientationData (Camera());
1180 //=======================================================================
1181 //function : SetViewMappingDefault
1183 //=======================================================================
1184 void V3d_View::SetViewMappingDefault()
1186 myDefaultCamera->CopyMappingData (Camera());
1189 //=============================================================================
1190 //function : ResetViewOrientation
1192 //=============================================================================
1193 void V3d_View::ResetViewOrientation()
1195 Camera()->CopyOrientationData (myDefaultCamera);
1199 //=======================================================================
1200 //function : ResetViewMapping
1202 //=======================================================================
1203 void V3d_View::ResetViewMapping()
1205 Camera()->CopyMappingData (myDefaultCamera);
1209 //=============================================================================
1212 //=============================================================================
1213 void V3d_View::Reset (const Standard_Boolean theToUpdate)
1215 Camera()->Copy (myDefaultCamera);
1217 SwitchSetFront = Standard_False;
1219 if (myImmediateUpdate || theToUpdate)
1225 //=======================================================================
1226 //function : SetCenter
1228 //=======================================================================
1229 void V3d_View::SetCenter (const Standard_Integer theXp,
1230 const Standard_Integer theYp)
1232 Standard_Real aXv, aYv;
1233 Convert (theXp, theYp, aXv, aYv);
1234 Translate (Camera(), aXv, aYv);
1239 //=============================================================================
1240 //function : SetSize
1242 //=============================================================================
1243 void V3d_View::SetSize (const Standard_Real theSize)
1245 V3d_BadValue_Raise_if (theSize <= 0.0, "V3d_View::SetSize, Window Size is NULL");
1247 Handle(Graphic3d_Camera) aCamera = Camera();
1249 aCamera->SetScale (aCamera->Aspect() >= 1.0 ? theSize / aCamera->Aspect() : theSize);
1254 //=============================================================================
1255 //function : SetZSize
1257 //=============================================================================
1258 void V3d_View::SetZSize (const Standard_Real theSize)
1260 Handle(Graphic3d_Camera) aCamera = Camera();
1262 Standard_Real Zmax = theSize / 2.;
1264 Standard_Real aDistance = aCamera->Distance();
1271 // ShortReal precision factor used to add meaningful tolerance to
1272 // ZNear, ZFar values in order to avoid equality after type conversion
1273 // to ShortReal matrices type.
1274 const Standard_Real aPrecision = 1.0 / Pow (10.0, ShortRealDigits() - 1);
1276 Standard_Real aZFar = Zmax + aDistance * 2.0;
1277 Standard_Real aZNear = -Zmax + aDistance;
1278 aZNear -= Abs (aZNear) * aPrecision;
1279 aZFar += Abs (aZFar) * aPrecision;
1281 if (!aCamera->IsOrthographic())
1283 if (aZFar < aPrecision)
1285 // Invalid case when both values are negative
1286 aZNear = aPrecision;
1287 aZFar = aPrecision * 2.0;
1289 else if (aZNear < Abs (aZFar) * aPrecision)
1291 // Z is less than 0.0, try to fix it using any appropriate z-scale
1292 aZNear = Abs (aZFar) * aPrecision;
1296 // If range is too small
1297 if (aZFar < (aZNear + Abs (aZFar) * aPrecision))
1299 aZFar = aZNear + Abs (aZFar) * aPrecision;
1302 aCamera->SetZRange (aZNear, aZFar);
1304 if (myImmediateUpdate)
1310 //=============================================================================
1311 //function : SetZoom
1313 //=============================================================================
1314 void V3d_View::SetZoom (const Standard_Real theCoef,const Standard_Boolean theToStart)
1316 V3d_BadValue_Raise_if (theCoef <= 0., "V3d_View::SetZoom, bad coefficient");
1318 Handle(Graphic3d_Camera) aCamera = Camera();
1322 myCamStartOpEye = aCamera->Eye();
1323 myCamStartOpCenter = aCamera->Center();
1326 Standard_Real aViewWidth = aCamera->ViewDimensions().X();
1327 Standard_Real aViewHeight = aCamera->ViewDimensions().Y();
1329 // ensure that zoom will not be too small or too big
1330 Standard_Real aCoef = theCoef;
1331 if (aViewWidth < aCoef * Precision::Confusion())
1333 aCoef = aViewWidth / Precision::Confusion();
1335 else if (aViewWidth > aCoef * 1e12)
1337 aCoef = aViewWidth / 1e12;
1339 if (aViewHeight < aCoef * Precision::Confusion())
1341 aCoef = aViewHeight / Precision::Confusion();
1343 else if (aViewHeight > aCoef * 1e12)
1345 aCoef = aViewHeight / 1e12;
1348 aCamera->SetEye (myCamStartOpEye);
1349 aCamera->SetCenter (myCamStartOpCenter);
1350 aCamera->SetScale (aCamera->Scale() / aCoef);
1355 //=============================================================================
1356 //function : SetScale
1358 //=============================================================================
1359 void V3d_View::SetScale( const Standard_Real Coef )
1361 V3d_BadValue_Raise_if( Coef <= 0. ,"V3d_View::SetScale, bad coefficient");
1363 Handle(Graphic3d_Camera) aCamera = Camera();
1365 Standard_Real aDefaultScale = myDefaultCamera->Scale();
1366 aCamera->SetAspect (myDefaultCamera->Aspect());
1367 aCamera->SetScale (aDefaultScale / Coef);
1372 //=============================================================================
1373 //function : SetAxialScale
1375 //=============================================================================
1376 void V3d_View::SetAxialScale( const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz )
1378 V3d_BadValue_Raise_if( Sx <= 0. || Sy <= 0. || Sz <= 0.,"V3d_View::SetAxialScale, bad coefficient");
1380 Camera()->SetAxialScale (gp_XYZ (Sx, Sy, Sz));
1383 //=============================================================================
1384 //function : SetRatio
1386 //=============================================================================
1387 void V3d_View::SetRatio()
1389 if (MyWindow.IsNull())
1394 Standard_Integer aWidth = 0;
1395 Standard_Integer aHeight = 0;
1396 MyWindow->Size (aWidth, aHeight);
1397 if (aWidth > 0 && aHeight > 0)
1399 Standard_Real aRatio = static_cast<Standard_Real> (aWidth) /
1400 static_cast<Standard_Real> (aHeight);
1402 Camera() ->SetAspect (aRatio);
1403 myDefaultCamera->SetAspect (aRatio);
1407 //=============================================================================
1410 //=============================================================================
1411 void V3d_View::FitAll (const Standard_Real theMargin, const Standard_Boolean theToUpdate)
1413 FitAll (myView->MinMaxValues(), theMargin, theToUpdate);
1416 //=============================================================================
1419 //=============================================================================
1420 void V3d_View::FitAll (const Bnd_Box& theBox, const Standard_Real theMargin, const Standard_Boolean theToUpdate)
1422 Standard_ASSERT_RAISE(theMargin >= 0.0 && theMargin < 1.0, "Invalid margin coefficient");
1424 if (myView->NumberOfDisplayedStructures() == 0)
1429 if (!FitMinMax (Camera(), theBox, theMargin, 10.0 * Precision::Confusion()))
1434 if (myImmediateUpdate || theToUpdate)
1440 //=============================================================================
1441 //function : DepthFitAll
1443 //=============================================================================
1444 void V3d_View::DepthFitAll(const Standard_Real Aspect,
1445 const Standard_Real Margin)
1447 Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W,U1,V1,W1 ;
1448 Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ;
1449 Standard_Real Dx,Dy,Dz,Size;
1451 Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ;
1453 if((Nstruct <= 0) || (Aspect < 0.) || (Margin < 0.) || (Margin > 1.)) {
1458 Bnd_Box aBox = myView->MinMaxValues();
1464 aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
1465 Project (Xmin,Ymin,Zmin,U,V,W) ;
1466 Project (Xmax,Ymax,Zmax,U1,V1,W1) ;
1467 Umin = Min(U,U1) ; Umax = Max(U,U1) ;
1468 Vmin = Min(V,V1) ; Vmax = Max(V,V1) ;
1469 Wmin = Min(W,W1) ; Wmax = Max(W,W1) ;
1470 Project (Xmin,Ymin,Zmax,U,V,W) ;
1471 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1472 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1473 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1474 Project (Xmax,Ymin,Zmax,U,V,W) ;
1475 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1476 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1477 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1478 Project (Xmax,Ymin,Zmin,U,V,W) ;
1479 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1480 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1481 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1482 Project (Xmax,Ymax,Zmin,U,V,W) ;
1483 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1484 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1485 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1486 Project (Xmin,Ymax,Zmax,U,V,W) ;
1487 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1488 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1489 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1490 Project (Xmin,Ymax,Zmin,U,V,W) ;
1491 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1492 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1493 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1496 Wmax = Max(Abs(Wmin),Abs(Wmax)) ;
1497 Dz = 2.*Wmax + Margin * Wmax;
1499 // Compute depth value
1500 Dx = Abs(Umax - Umin) ; Dy = Abs(Vmax - Vmin) ; // Dz = Abs(Wmax - Wmin);
1501 Dx += Margin * Dx; Dy += Margin * Dy;
1502 Size = Sqrt(Dx*Dx + Dy*Dy + Dz*Dz);
1505 SetDepth( Aspect * Size / 2.);
1511 //=======================================================================
1512 //function : WindowFit
1514 //=======================================================================
1515 void V3d_View::WindowFit (const Standard_Integer theMinXp,
1516 const Standard_Integer theMinYp,
1517 const Standard_Integer theMaxXp,
1518 const Standard_Integer theMaxYp)
1520 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
1522 Handle(Graphic3d_Camera) aCamera = Camera();
1524 if (!aCamera->IsOrthographic())
1526 // normalize view coordinates
1527 Standard_Integer aWinWidth, aWinHeight;
1528 MyWindow->Size (aWinWidth, aWinHeight);
1530 // z coordinate of camera center
1531 Standard_Real aDepth = aCamera->Project (aCamera->Center()).Z();
1533 // camera projection coordinate are in NDC which are normalized [-1, 1]
1534 Standard_Real aUMin = (2.0 / aWinWidth) * theMinXp - 1.0;
1535 Standard_Real aUMax = (2.0 / aWinWidth) * theMaxXp - 1.0;
1536 Standard_Real aVMin = (2.0 / aWinHeight) * theMinYp - 1.0;
1537 Standard_Real aVMax = (2.0 / aWinHeight) * theMaxYp - 1.0;
1539 // compute camera panning
1540 gp_Pnt aScreenCenter (0.0, 0.0, aDepth);
1541 gp_Pnt aFitCenter ((aUMin + aUMax) * 0.5, (aVMin + aVMax) * 0.5, aDepth);
1542 gp_Pnt aPanTo = aCamera->ConvertProj2View (aFitCenter);
1543 gp_Pnt aPanFrom = aCamera->ConvertProj2View (aScreenCenter);
1544 gp_Vec aPanVec (aPanFrom, aPanTo);
1546 // compute section size
1547 gp_Pnt aFitTopRight (aUMax, aVMax, aDepth);
1548 gp_Pnt aFitBotLeft (aUMin, aVMin, aDepth);
1549 gp_Pnt aViewBotLeft = aCamera->ConvertProj2View (aFitBotLeft);
1550 gp_Pnt aViewTopRight = aCamera->ConvertProj2View (aFitTopRight);
1552 Standard_Real aUSize = aViewTopRight.X() - aViewBotLeft.X();
1553 Standard_Real aVSize = aViewTopRight.Y() - aViewBotLeft.Y();
1555 Translate (aCamera, aPanVec.X(), -aPanVec.Y());
1556 Scale (aCamera, aUSize, aVSize);
1560 Standard_Real aX1, aY1, aX2, aY2;
1561 Convert (theMinXp, theMinYp, aX1, aY1);
1562 Convert (theMaxXp, theMaxYp, aX2, aY2);
1563 FitAll (aX1, aY1, aX2, aY2);
1566 SetImmediateUpdate (wasUpdateEnabled);
1571 //=======================================================================
1572 //function : ConvertToGrid
1574 //=======================================================================
1575 void V3d_View::ConvertToGrid(const Standard_Integer theXp,
1576 const Standard_Integer theYp,
1577 Standard_Real& theXg,
1578 Standard_Real& theYg,
1579 Standard_Real& theZg) const
1581 Graphic3d_Vec3d anXYZ;
1582 Convert (theXp, theYp, anXYZ.x(), anXYZ.y(), anXYZ.z());
1584 Graphic3d_Vertex aVrp;
1585 aVrp.SetCoord (anXYZ.x(), anXYZ.y(), anXYZ.z());
1586 if (MyViewer->IsGridActive())
1588 Graphic3d_Vertex aNewVrp = Compute (aVrp);
1589 aNewVrp.Coord (theXg, theYg, theZg);
1593 aVrp.Coord (theXg, theYg, theZg);
1597 //=======================================================================
1598 //function : ConvertToGrid
1600 //=======================================================================
1601 void V3d_View::ConvertToGrid(const Standard_Real theX,
1602 const Standard_Real theY,
1603 const Standard_Real theZ,
1604 Standard_Real& theXg,
1605 Standard_Real& theYg,
1606 Standard_Real& theZg) const
1608 if (MyViewer->IsGridActive())
1610 Graphic3d_Vertex aVrp (theX, theY, theZ);
1611 Graphic3d_Vertex aNewVrp = Compute (aVrp);
1612 aNewVrp.Coord (theXg, theYg, theZg);
1616 theXg = theX; theYg = theY; theZg = theZ;
1620 //=======================================================================
1621 //function : Convert
1623 //=======================================================================
1624 Standard_Real V3d_View::Convert(const Standard_Integer Vp) const
1626 Standard_Integer aDxw, aDyw ;
1628 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1630 MyWindow->Size (aDxw, aDyw);
1631 Standard_Real aValue;
1633 gp_Pnt aViewDims = Camera()->ViewDimensions();
1634 aValue = aViewDims.X() * (Standard_Real)Vp / (Standard_Real)aDxw;
1639 //=======================================================================
1640 //function : Convert
1642 //=======================================================================
1643 void V3d_View::Convert(const Standard_Integer Xp,
1644 const Standard_Integer Yp,
1646 Standard_Real& Yv) const
1648 Standard_Integer aDxw, aDyw;
1650 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1652 MyWindow->Size (aDxw, aDyw);
1654 gp_Pnt aPoint (Xp * 2.0 / aDxw - 1.0, (aDyw - Yp) * 2.0 / aDyw - 1.0, 0.0);
1655 aPoint = Camera()->ConvertProj2View (aPoint);
1661 //=======================================================================
1662 //function : Convert
1664 //=======================================================================
1665 Standard_Integer V3d_View::Convert(const Standard_Real Vv) const
1667 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1669 Standard_Integer aDxw, aDyw;
1670 MyWindow->Size (aDxw, aDyw);
1672 gp_Pnt aViewDims = Camera()->ViewDimensions();
1673 Standard_Integer aValue = RealToInt (aDxw * Vv / (aViewDims.X()));
1678 //=======================================================================
1679 //function : Convert
1681 //=======================================================================
1682 void V3d_View::Convert(const Standard_Real Xv,
1683 const Standard_Real Yv,
1684 Standard_Integer& Xp,
1685 Standard_Integer& Yp) const
1687 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1689 Standard_Integer aDxw, aDyw;
1690 MyWindow->Size (aDxw, aDyw);
1692 gp_Pnt aPoint (Xv, Yv, 0.0);
1693 aPoint = Camera()->ConvertView2Proj (aPoint);
1694 aPoint = gp_Pnt ((aPoint.X() + 1.0) * aDxw / 2.0, aDyw - (aPoint.Y() + 1.0) * aDyw / 2.0, 0.0);
1696 Xp = RealToInt (aPoint.X());
1697 Yp = RealToInt (aPoint.Y());
1700 //=======================================================================
1701 //function : Convert
1703 //=======================================================================
1704 void V3d_View::Convert(const Standard_Integer theXp,
1705 const Standard_Integer theYp,
1706 Standard_Real& theX,
1707 Standard_Real& theY,
1708 Standard_Real& theZ) const
1710 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1711 Standard_Integer aHeight = 0, aWidth = 0;
1712 MyWindow->Size (aWidth, aHeight);
1714 const gp_Pnt anXYZ (2.0 * theXp / aWidth - 1.0,
1715 2.0 * (aHeight - 1 - theYp) / aHeight - 1.0,
1716 Camera()->IsZeroToOneDepth() ? 0.0 : -1.0);
1717 const gp_Pnt aResult = Camera()->UnProject (anXYZ);
1723 //=======================================================================
1724 //function : ConvertWithProj
1726 //=======================================================================
1727 void V3d_View::ConvertWithProj(const Standard_Integer theXp,
1728 const Standard_Integer theYp,
1729 Standard_Real& theX,
1730 Standard_Real& theY,
1731 Standard_Real& theZ,
1732 Standard_Real& theDx,
1733 Standard_Real& theDy,
1734 Standard_Real& theDz) const
1736 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1737 Standard_Integer aHeight = 0, aWidth = 0;
1738 MyWindow->Size (aWidth, aHeight);
1740 const Standard_Real anX = 2.0 * theXp / aWidth - 1.0;
1741 const Standard_Real anY = 2.0 * (aHeight - 1 - theYp) / aHeight - 1.0;
1742 const Standard_Real aZ = 2.0 * 0.0 - 1.0;
1744 const Handle(Graphic3d_Camera)& aCamera = Camera();
1745 const gp_Pnt aResult1 = aCamera->UnProject (gp_Pnt (anX, anY, aZ));
1746 const gp_Pnt aResult2 = aCamera->UnProject (gp_Pnt (anX, anY, aZ - 10.0));
1748 theX = aResult1.X();
1749 theY = aResult1.Y();
1750 theZ = aResult1.Z();
1751 Graphic3d_Vec3d aNormDir (theX - aResult2.X(),
1752 theY - aResult2.Y(),
1753 theZ - aResult2.Z());
1754 aNormDir.Normalize();
1756 theDx = aNormDir.x();
1757 theDy = aNormDir.y();
1758 theDz = aNormDir.z();
1761 //=======================================================================
1762 //function : Convert
1764 //=======================================================================
1765 void V3d_View::Convert(const Standard_Real X,
1766 const Standard_Real Y,
1767 const Standard_Real Z,
1768 Standard_Integer& Xp,
1769 Standard_Integer& Yp) const
1771 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1772 Standard_Integer aHeight, aWidth;
1773 MyWindow->Size (aWidth, aHeight);
1775 gp_Pnt aPoint = Camera()->Project (gp_Pnt (X, Y, Z));
1777 Xp = RealToInt ((aPoint.X() + 1) * 0.5 * aWidth);
1778 Yp = RealToInt (aHeight - 1 - (aPoint.Y() + 1) * 0.5 * aHeight);
1781 //=======================================================================
1782 //function : Project
1784 //=======================================================================
1785 void V3d_View::Project (const Standard_Real theX,
1786 const Standard_Real theY,
1787 const Standard_Real theZ,
1788 Standard_Real& theXp,
1789 Standard_Real& theYp) const
1792 Project (theX, theY, theZ, theXp, theYp, aZp);
1795 //=======================================================================
1796 //function : Project
1798 //=======================================================================
1799 void V3d_View::Project (const Standard_Real theX,
1800 const Standard_Real theY,
1801 const Standard_Real theZ,
1802 Standard_Real& theXp,
1803 Standard_Real& theYp,
1804 Standard_Real& theZp) const
1806 Handle(Graphic3d_Camera) aCamera = Camera();
1808 gp_XYZ aViewSpaceDimensions = aCamera->ViewDimensions();
1809 Standard_Real aXSize = aViewSpaceDimensions.X();
1810 Standard_Real aYSize = aViewSpaceDimensions.Y();
1811 Standard_Real aZSize = aViewSpaceDimensions.Z();
1813 gp_Pnt aPoint = aCamera->Project (gp_Pnt (theX, theY, theZ));
1815 // NDC [-1, 1] --> PROJ [ -size / 2, +size / 2 ]
1816 theXp = aPoint.X() * aXSize * 0.5;
1817 theYp = aPoint.Y() * aYSize * 0.5;
1818 theZp = Camera()->IsZeroToOneDepth()
1819 ? aPoint.Z() * aZSize
1820 : aPoint.Z() * aZSize * 0.5;
1823 //=======================================================================
1824 //function : BackgroundColor
1826 //=======================================================================
1827 void V3d_View::BackgroundColor(const Quantity_TypeOfColor Type,
1830 Standard_Real& V3) const
1832 Quantity_Color C = BackgroundColor() ;
1833 C.Values(V1,V2,V3,Type) ;
1836 //=======================================================================
1837 //function : BackgroundColor
1839 //=======================================================================
1840 Quantity_Color V3d_View::BackgroundColor() const
1842 return myView->Background().Color() ;
1845 //=======================================================================
1846 //function : GradientBackgroundColors
1848 //=======================================================================
1849 void V3d_View::GradientBackgroundColors (Quantity_Color& theColor1, Quantity_Color& theColor2) const
1851 myView->GradientBackground().Colors (theColor1, theColor2);
1854 //=======================================================================
1855 //function : GradientBackground
1857 //=======================================================================
1858 Aspect_GradientBackground V3d_View::GradientBackground() const
1860 return myView->GradientBackground();
1863 //=======================================================================
1866 //=======================================================================
1867 Standard_Real V3d_View::Scale() const
1869 return myDefaultCamera->Scale() / Camera()->Scale();
1872 //=======================================================================
1873 //function : AxialScale
1875 //=======================================================================
1876 void V3d_View::AxialScale(Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz) const
1878 gp_Pnt anAxialScale = Camera()->AxialScale();
1879 Sx = anAxialScale.X();
1880 Sy = anAxialScale.Y();
1881 Sz = anAxialScale.Z();
1884 //=======================================================================
1887 //=======================================================================
1888 void V3d_View::Size(Standard_Real& Width, Standard_Real& Height) const
1890 gp_Pnt aViewDims = Camera()->ViewDimensions();
1892 Width = aViewDims.X();
1893 Height = aViewDims.Y();
1896 //=======================================================================
1899 //=======================================================================
1900 Standard_Real V3d_View::ZSize() const
1902 gp_Pnt aViewDims = Camera()->ViewDimensions();
1904 return aViewDims.Z();
1907 //=======================================================================
1910 //=======================================================================
1911 Standard_Integer V3d_View::MinMax(Standard_Real& Umin,
1912 Standard_Real& Vmin,
1913 Standard_Real& Umax,
1914 Standard_Real& Vmax) const
1916 Standard_Real Wmin,Wmax,U,V,W ;
1917 Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax ;
1919 Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ;
1922 Bnd_Box aBox = myView->MinMaxValues();
1923 aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
1924 Project (Xmin,Ymin,Zmin,Umin,Vmin,Wmin) ;
1925 Project (Xmax,Ymax,Zmax,Umax,Vmax,Wmax) ;
1926 Project (Xmin,Ymin,Zmax,U,V,W) ;
1927 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1928 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1929 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1930 Project (Xmax,Ymin,Zmax,U,V,W) ;
1931 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1932 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1933 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1934 Project (Xmax,Ymin,Zmin,U,V,W) ;
1935 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1936 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1937 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1938 Project (Xmax,Ymax,Zmin,U,V,W) ;
1939 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1940 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1941 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1942 Project (Xmin,Ymax,Zmax,U,V,W) ;
1943 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1944 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1945 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1946 Project (Xmin,Ymax,Zmin,U,V,W) ;
1947 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1948 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1949 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1954 //=======================================================================
1957 //=======================================================================
1958 Standard_Integer V3d_View::MinMax(Standard_Real& Xmin,
1959 Standard_Real& Ymin,
1960 Standard_Real& Zmin,
1961 Standard_Real& Xmax,
1962 Standard_Real& Ymax,
1963 Standard_Real& Zmax) const
1966 // Standard_Integer Nstruct = (MyView->DisplayedStructures())->Extent() ;
1967 Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ;
1970 Bnd_Box aBox = myView->MinMaxValues();
1971 aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
1976 //=======================================================================
1977 //function : GravityPoint
1979 //=======================================================================
1980 gp_Pnt V3d_View::GravityPoint() const
1982 Graphic3d_MapOfStructure aSetOfStructures;
1983 myView->DisplayedStructures (aSetOfStructures);
1985 Standard_Boolean hasSelection = Standard_False;
1986 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures);
1987 aStructIter.More(); aStructIter.Next())
1989 if (aStructIter.Key()->IsHighlighted()
1990 && aStructIter.Key()->IsVisible())
1992 hasSelection = Standard_True;
1997 Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
1998 Standard_Integer aNbPoints = 0;
1999 gp_XYZ aResult (0.0, 0.0, 0.0);
2000 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures);
2001 aStructIter.More(); aStructIter.Next())
2003 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
2004 if (!aStruct->IsVisible()
2005 || aStruct->IsInfinite()
2006 || (hasSelection && !aStruct->IsHighlighted()))
2011 const Graphic3d_BndBox3d& aBox = aStruct->CStructure()->BoundingBox();
2012 if (!aBox.IsValid())
2017 // skip transformation-persistent objects
2018 if (!aStruct->TransformPersistence().IsNull())
2023 // use camera projection to find gravity point
2024 Xmin = aBox.CornerMin().x();
2025 Ymin = aBox.CornerMin().y();
2026 Zmin = aBox.CornerMin().z();
2027 Xmax = aBox.CornerMax().x();
2028 Ymax = aBox.CornerMax().y();
2029 Zmax = aBox.CornerMax().z();
2030 gp_Pnt aPnts[THE_NB_BOUND_POINTS] =
2032 gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
2033 gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax),
2034 gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax),
2035 gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax)
2038 for (Standard_Integer aPntIt = 0; aPntIt < THE_NB_BOUND_POINTS; ++aPntIt)
2040 const gp_Pnt& aBndPnt = aPnts[aPntIt];
2041 const gp_Pnt aProjected = Camera()->Project (aBndPnt);
2042 if (Abs (aProjected.X()) <= 1.0
2043 && Abs (aProjected.Y()) <= 1.0)
2045 aResult += aBndPnt.XYZ();
2053 // fallback - just use bounding box of entire scene
2054 Bnd_Box aBox = myView->MinMaxValues();
2057 aBox.Get (Xmin, Ymin, Zmin,
2059 gp_Pnt aPnts[THE_NB_BOUND_POINTS] =
2061 gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
2062 gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax),
2063 gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax),
2064 gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax)
2067 for (Standard_Integer aPntIt = 0; aPntIt < THE_NB_BOUND_POINTS; ++aPntIt)
2069 const gp_Pnt& aBndPnt = aPnts[aPntIt];
2070 aResult += aBndPnt.XYZ();
2078 aResult /= aNbPoints;
2084 //=======================================================================
2087 //=======================================================================
2088 void V3d_View::Eye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
2090 gp_Pnt aCameraEye = Camera()->Eye();
2096 //=============================================================================
2097 //function : ProjReferenceAxe
2099 //=============================================================================
2100 void V3d_View::ProjReferenceAxe(const Standard_Integer Xpix,
2101 const Standard_Integer Ypix,
2107 Standard_Real& VZ) const
2109 Standard_Real Xo,Yo,Zo;
2111 Convert (Xpix, Ypix, XP, YP, ZP);
2112 if ( Type() == V3d_PERSPECTIVE )
2114 FocalReferencePoint (Xo,Yo,Zo);
2125 //=============================================================================
2128 //=============================================================================
2129 Standard_Real V3d_View::Depth() const
2131 return Camera()->Distance();
2134 //=============================================================================
2137 //=============================================================================
2138 void V3d_View::Proj(Standard_Real& Dx, Standard_Real& Dy, Standard_Real& Dz) const
2140 gp_Dir aCameraDir = Camera()->Direction().Reversed();
2141 Dx = aCameraDir.X();
2142 Dy = aCameraDir.Y();
2143 Dz = aCameraDir.Z();
2146 //=============================================================================
2149 //=============================================================================
2150 void V3d_View::At(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
2152 gp_Pnt aCameraCenter = Camera()->Center();
2153 X = aCameraCenter.X();
2154 Y = aCameraCenter.Y();
2155 Z = aCameraCenter.Z();
2158 //=============================================================================
2161 //=============================================================================
2162 void V3d_View::Up(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const
2164 gp_Dir aCameraUp = Camera()->Up();
2170 //=============================================================================
2173 //=============================================================================
2174 Standard_Real V3d_View::Twist() const
2176 gp_Vec Xaxis, Yaxis, Zaxis;
2177 const gp_Dir aReferencePlane (Camera()->Direction().Reversed());
2178 if (!screenAxis (aReferencePlane, gp::DZ(), Xaxis, Yaxis, Zaxis)
2179 && !screenAxis (aReferencePlane, gp::DY(), Xaxis, Yaxis, Zaxis)
2180 && !screenAxis (aReferencePlane, gp::DX(), Xaxis, Yaxis, Zaxis))
2185 // Compute Cross Vector From Up & Origin
2186 const gp_Dir aCameraUp = Camera()->Up();
2187 const gp_XYZ aP = Yaxis.XYZ().Crossed (aCameraUp.XYZ());
2190 Standard_Real anAngle = ASin (Max (Min (aP.Modulus(), 1.0), -1.0));
2191 if (Yaxis.Dot (aCameraUp.XYZ()) < 0.0)
2193 anAngle = M_PI - anAngle;
2198 const gp_Dir aProjDir = Camera()->Direction().Reversed();
2199 if (aP.Dot (aProjDir.XYZ()) < 0.0)
2201 anAngle = DEUXPI - anAngle;
2207 //=============================================================================
2208 //function : ShadingModel
2210 //=============================================================================
2211 Graphic3d_TypeOfShadingModel V3d_View::ShadingModel() const
2213 return myView->ShadingModel();
2216 //=============================================================================
2217 //function : TextureEnv
2219 //=============================================================================
2220 Handle(Graphic3d_TextureEnv) V3d_View::TextureEnv() const
2222 return myView->TextureEnv();
2225 //=============================================================================
2226 //function : Visualization
2228 //=============================================================================
2229 V3d_TypeOfVisualization V3d_View::Visualization() const
2231 return static_cast<V3d_TypeOfVisualization> (myView->VisualizationType());
2234 //=============================================================================
2235 //function : IfWindow
2237 //=============================================================================
2238 Standard_Boolean V3d_View::IfWindow() const
2240 return myView->IsDefined();
2243 //=============================================================================
2246 //=============================================================================
2247 V3d_TypeOfView V3d_View::Type() const
2249 return Camera()->IsOrthographic() ? V3d_ORTHOGRAPHIC : V3d_PERSPECTIVE;
2252 //=============================================================================
2253 //function : SetFocale
2255 //=============================================================================
2256 void V3d_View::SetFocale( const Standard_Real focale )
2258 Handle(Graphic3d_Camera) aCamera = Camera();
2260 if (aCamera->IsOrthographic())
2265 Standard_Real aFOVyRad = ATan (focale / (aCamera->Distance() * 2.0));
2267 aCamera->SetFOVy (aFOVyRad * (360 / M_PI));
2272 //=============================================================================
2275 //=============================================================================
2276 Standard_Real V3d_View::Focale() const
2278 Handle(Graphic3d_Camera) aCamera = Camera();
2280 if (aCamera->IsOrthographic())
2285 return aCamera->Distance() * 2.0 * Tan (aCamera->FOVy() * M_PI / 360.0);
2288 //=============================================================================
2289 //function : screenAxis
2291 //=============================================================================
2292 Standard_Boolean V3d_View::screenAxis (const gp_Dir& theVpn, const gp_Dir& theVup,
2293 gp_Vec& theXaxe, gp_Vec& theYaxe, gp_Vec& theZaxe)
2295 theXaxe = theVup.XYZ().Crossed (theVpn.XYZ());
2296 if (theXaxe.Magnitude() <= gp::Resolution())
2298 return Standard_False;
2300 theXaxe.Normalize();
2302 theYaxe = theVpn.XYZ().Crossed (theXaxe.XYZ());
2303 if (theYaxe.Magnitude() <= gp::Resolution())
2305 return Standard_False;
2307 theYaxe.Normalize();
2309 theZaxe = theVpn.XYZ();
2310 theZaxe.Normalize();
2311 return Standard_True;
2314 //=============================================================================
2315 //function : TrsPoint
2317 //=============================================================================
2318 gp_XYZ V3d_View::TrsPoint (const Graphic3d_Vertex& thePnt, const TColStd_Array2OfReal& theMat)
2321 const Standard_Integer lr = theMat.LowerRow();
2322 const Standard_Integer ur = theMat.UpperRow();
2323 const Standard_Integer lc = theMat.LowerCol();
2324 const Standard_Integer uc = theMat.UpperCol();
2325 if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4))
2327 return gp_XYZ (thePnt.X(), thePnt.Y(), thePnt.Z());
2330 Standard_Real X, Y, Z;
2331 thePnt.Coord (X,Y,Z);
2332 const Standard_Real XX = (theMat(lr,lc+3) + X*theMat(lr,lc) + Y*theMat(lr,lc+1) + Z*theMat(lr,lc+2)) / theMat(lr+3,lc+3);
2333 const Standard_Real YY = (theMat(lr+1,lc+3) + X*theMat(lr+1,lc) + Y*theMat(lr+1,lc+1) + Z*theMat(lr+1,lc+2))/theMat(lr+3,lc+3);
2334 const Standard_Real ZZ = (theMat(lr+2,lc+3) + X*theMat(lr+2,lc) + Y*theMat(lr+2,lc+1) + Z*theMat(lr+2,lc+2))/theMat(lr+3,lc+3);
2335 return gp_XYZ (XX, YY, ZZ);
2338 //=======================================================================
2341 //=======================================================================
2342 void V3d_View::Pan (const Standard_Integer theDXp,
2343 const Standard_Integer theDYp,
2344 const Standard_Real theZoomFactor,
2345 const Standard_Boolean theToStart)
2347 Panning (Convert (theDXp), Convert (theDYp), theZoomFactor, theToStart);
2350 //=======================================================================
2351 //function : Panning
2353 //=======================================================================
2354 void V3d_View::Panning (const Standard_Real theDXv,
2355 const Standard_Real theDYv,
2356 const Standard_Real theZoomFactor,
2357 const Standard_Boolean theToStart)
2359 Standard_ASSERT_RAISE (theZoomFactor > 0.0, "Bad zoom factor");
2361 Handle(Graphic3d_Camera) aCamera = Camera();
2365 myCamStartOpDir = aCamera->Direction();
2366 myCamStartOpEye = aCamera->Eye();
2367 myCamStartOpCenter = aCamera->Center();
2370 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
2372 gp_Pnt aViewDims = aCamera->ViewDimensions();
2374 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
2375 aCamera->SetDirectionFromEye (myCamStartOpDir);
2376 Translate (aCamera, -theDXv, -theDYv);
2377 Scale (aCamera, aViewDims.X() / theZoomFactor, aViewDims.Y() / theZoomFactor);
2379 SetImmediateUpdate (wasUpdateEnabled);
2384 //=======================================================================
2387 //=======================================================================
2388 void V3d_View::Zoom (const Standard_Integer theXp1,
2389 const Standard_Integer theYp1,
2390 const Standard_Integer theXp2,
2391 const Standard_Integer theYp2)
2393 Standard_Integer aDx = theXp2 - theXp1;
2394 Standard_Integer aDy = theYp2 - theYp1;
2395 if (aDx != 0 || aDy != 0)
2397 Standard_Real aCoeff = Sqrt( (Standard_Real)(aDx * aDx + aDy * aDy) ) / 100.0 + 1.0;
2398 aCoeff = (aDx > 0) ? aCoeff : 1.0 / aCoeff;
2399 SetZoom (aCoeff, Standard_True);
2403 //=======================================================================
2404 //function : StartZoomAtPoint
2406 //=======================================================================
2407 void V3d_View::StartZoomAtPoint (const Standard_Integer theXp,
2408 const Standard_Integer theYp)
2410 MyZoomAtPointX = theXp;
2411 MyZoomAtPointY = theYp;
2414 //=======================================================================
2415 //function : ZoomAtPoint
2417 //=======================================================================
2418 void V3d_View::ZoomAtPoint (const Standard_Integer theMouseStartX,
2419 const Standard_Integer theMouseStartY,
2420 const Standard_Integer theMouseEndX,
2421 const Standard_Integer theMouseEndY)
2423 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
2426 Standard_Real aDxy = Standard_Real ((theMouseEndX + theMouseEndY) - (theMouseStartX + theMouseStartY));
2427 Standard_Real aDZoom = Abs (aDxy) / 100.0 + 1.0;
2428 aDZoom = (aDxy > 0.0) ? aDZoom : 1.0 / aDZoom;
2430 V3d_BadValue_Raise_if (aDZoom <= 0.0, "V3d_View::ZoomAtPoint, bad coefficient");
2432 Handle(Graphic3d_Camera) aCamera = Camera();
2434 Standard_Real aViewWidth = aCamera->ViewDimensions().X();
2435 Standard_Real aViewHeight = aCamera->ViewDimensions().Y();
2437 // ensure that zoom will not be too small or too big.
2438 Standard_Real aCoef = aDZoom;
2439 if (aViewWidth < aCoef * Precision::Confusion())
2441 aCoef = aViewWidth / Precision::Confusion();
2443 else if (aViewWidth > aCoef * 1e12)
2445 aCoef = aViewWidth / 1e12;
2447 if (aViewHeight < aCoef * Precision::Confusion())
2449 aCoef = aViewHeight / Precision::Confusion();
2451 else if (aViewHeight > aCoef * 1e12)
2453 aCoef = aViewHeight / 1e12;
2456 Standard_Real aZoomAtPointXv = 0.0;
2457 Standard_Real aZoomAtPointYv = 0.0;
2458 Convert (MyZoomAtPointX, MyZoomAtPointY, aZoomAtPointXv, aZoomAtPointYv);
2460 Standard_Real aDxv = aZoomAtPointXv / aCoef;
2461 Standard_Real aDyv = aZoomAtPointYv / aCoef;
2463 aCamera->SetScale (aCamera->Scale() / aCoef);
2464 Translate (aCamera, aZoomAtPointXv - aDxv, aZoomAtPointYv - aDyv);
2466 SetImmediateUpdate (wasUpdateEnabled);
2471 //=============================================================================
2472 //function : AxialScale
2474 //=============================================================================
2475 void V3d_View::AxialScale (const Standard_Integer Dx,
2476 const Standard_Integer Dy,
2477 const V3d_TypeOfAxe Axis)
2479 if( Dx != 0. || Dy != 0. ) {
2480 Standard_Real Sx, Sy, Sz;
2481 AxialScale( Sx, Sy, Sz );
2482 Standard_Real dscale = Sqrt(Dx*Dx + Dy*Dy) / 100. + 1;
2483 dscale = (Dx > 0) ? dscale : 1./dscale;
2484 if( Axis == V3d_X ) Sx = dscale;
2485 if( Axis == V3d_Y ) Sy = dscale;
2486 if( Axis == V3d_Z ) Sz = dscale;
2487 SetAxialScale( Sx, Sy, Sz );
2491 //=============================================================================
2494 //=============================================================================
2495 void V3d_View::FitAll(const Standard_Real theXmin,
2496 const Standard_Real theYmin,
2497 const Standard_Real theXmax,
2498 const Standard_Real theYmax)
2500 Handle(Graphic3d_Camera) aCamera = Camera();
2501 Standard_Real anAspect = aCamera->Aspect();
2503 Standard_Real aFitSizeU = Abs (theXmax - theXmin);
2504 Standard_Real aFitSizeV = Abs (theYmax - theYmin);
2505 Standard_Real aFitAspect = aFitSizeU / aFitSizeV;
2506 if (aFitAspect >= anAspect)
2508 aFitSizeV = aFitSizeU / anAspect;
2512 aFitSizeU = aFitSizeV * anAspect;
2515 Translate (aCamera, (theXmin + theXmax) * 0.5, (theYmin + theYmax) * 0.5);
2516 Scale (aCamera, aFitSizeU, aFitSizeV);
2521 //=============================================================================
2522 //function : StartRotation
2524 //=============================================================================
2525 void V3d_View::StartRotation(const Standard_Integer X,
2526 const Standard_Integer Y,
2527 const Standard_Real zRotationThreshold)
2532 rx = Standard_Real(Convert(x));
2533 ry = Standard_Real(Convert(y));
2534 myRotateGravity = GravityPoint();
2535 Rotate (0.0, 0.0, 0.0,
2536 myRotateGravity.X(), myRotateGravity.Y(), myRotateGravity.Z(),
2538 myZRotation = Standard_False;
2539 if( zRotationThreshold > 0. ) {
2540 Standard_Real dx = Abs(sx - rx/2.);
2541 Standard_Real dy = Abs(sy - ry/2.);
2542 // if( dx > rx/3. || dy > ry/3. ) myZRotation = Standard_True;
2543 Standard_Real dd = zRotationThreshold * (rx + ry)/2.;
2544 if( dx > dd || dy > dd ) myZRotation = Standard_True;
2549 //=============================================================================
2550 //function : Rotation
2552 //=============================================================================
2553 void V3d_View::Rotation(const Standard_Integer X,
2554 const Standard_Integer Y)
2556 if( rx == 0. || ry == 0. ) {
2560 Standard_Real dx=0.,dy=0.,dz=0.;
2562 dz = atan2(Standard_Real(X)-rx/2., ry/2.-Standard_Real(Y)) -
2563 atan2(sx-rx/2.,ry/2.-sy);
2565 dx = (Standard_Real(X) - sx) * M_PI / rx;
2566 dy = (sy - Standard_Real(Y)) * M_PI / ry;
2570 myRotateGravity.X(), myRotateGravity.Y(), myRotateGravity.Z(),
2574 //=============================================================================
2575 //function : SetComputedMode
2577 //=============================================================================
2578 void V3d_View::SetComputedMode (const Standard_Boolean theMode)
2584 myView->SetComputedMode (Standard_True);
2589 myView->SetComputedMode (Standard_False);
2593 //=============================================================================
2594 //function : ComputedMode
2596 //=============================================================================
2597 Standard_Boolean V3d_View::ComputedMode() const
2599 return myView->ComputedMode();
2602 //=============================================================================
2603 //function : SetBackFacingModel
2605 //=============================================================================
2606 void V3d_View::SetBackFacingModel (const Graphic3d_TypeOfBackfacingModel theModel)
2608 myView->SetBackfacingModel (theModel);
2612 //=============================================================================
2613 //function : BackFacingModel
2615 //=============================================================================
2616 Graphic3d_TypeOfBackfacingModel V3d_View::BackFacingModel() const
2618 return myView->BackfacingModel();
2621 //=============================================================================
2624 //=============================================================================
2625 void V3d_View::Init()
2627 myComputedMode = MyViewer->ComputedMode();
2628 if (!myComputedMode || !MyViewer->DefaultComputedMode())
2630 SetComputedMode (Standard_False);
2634 //=============================================================================
2637 //=============================================================================
2638 Standard_Boolean V3d_View::Dump (const Standard_CString theFile,
2639 const Graphic3d_BufferType& theBufferType)
2641 Standard_Integer aWinWidth, aWinHeight;
2642 MyWindow->Size (aWinWidth, aWinHeight);
2643 Image_AlienPixMap anImage;
2645 return ToPixMap (anImage, aWinWidth, aWinHeight, theBufferType) && anImage.Save (theFile);
2648 //=============================================================================
2649 //function : ToPixMap
2651 //=============================================================================
2652 Standard_Boolean V3d_View::ToPixMap (Image_PixMap& theImage,
2653 const V3d_ImageDumpOptions& theParams)
2655 Graphic3d_Vec2i aTargetSize (theParams.Width, theParams.Height);
2656 if (aTargetSize.x() != 0
2657 && aTargetSize.y() != 0)
2659 // allocate image buffer for dumping
2660 if (theImage.IsEmpty()
2661 || theImage.SizeX() != Standard_Size(aTargetSize.x())
2662 || theImage.SizeY() != Standard_Size(aTargetSize.y()))
2664 Image_Format aFormat = Image_Format_UNKNOWN;
2665 switch (theParams.BufferType)
2667 case Graphic3d_BT_RGB: aFormat = Image_Format_RGB; break;
2668 case Graphic3d_BT_RGBA: aFormat = Image_Format_RGBA; break;
2669 case Graphic3d_BT_Depth: aFormat = Image_Format_GrayF; break;
2670 case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF; break;
2671 case Graphic3d_BT_Red: aFormat = Image_Format_Gray; break;
2674 if (!theImage.InitZero (aFormat, Standard_Size(aTargetSize.x()), Standard_Size(aTargetSize.y())))
2676 Message::SendFail (TCollection_AsciiString ("Fail to allocate an image ") + aTargetSize.x() + "x" + aTargetSize.y() + " for view dump");
2677 return Standard_False;
2681 if (theImage.IsEmpty())
2683 Message::SendFail ("V3d_View::ToPixMap() has been called without image dimensions");
2684 return Standard_False;
2686 aTargetSize.x() = (Standard_Integer )theImage.SizeX();
2687 aTargetSize.y() = (Standard_Integer )theImage.SizeY();
2689 Handle(Standard_Transient) aFBOPtr;
2690 Handle(Standard_Transient) aPrevFBOPtr = myView->FBO();
2691 Graphic3d_Vec2i aFBOVPSize = aTargetSize;
2693 bool isTiling = false;
2694 if (theParams.TileSize > 0)
2696 if (aFBOVPSize.x() > theParams.TileSize
2697 || aFBOVPSize.y() > theParams.TileSize)
2699 aFBOVPSize.x() = Min (aFBOVPSize.x(), theParams.TileSize);
2700 aFBOVPSize.y() = Min (aFBOVPSize.y(), theParams.TileSize);
2705 Graphic3d_Vec2i aPrevFBOVPSize;
2706 if (!aPrevFBOPtr.IsNull())
2708 Graphic3d_Vec2i aPrevFBOSizeMax;
2709 myView->FBOGetDimensions (aPrevFBOPtr,
2710 aPrevFBOVPSize.x(), aPrevFBOVPSize.y(),
2711 aPrevFBOSizeMax.x(), aPrevFBOSizeMax.y());
2712 if (aFBOVPSize.x() <= aPrevFBOSizeMax.x()
2713 && aFBOVPSize.y() <= aPrevFBOSizeMax.y())
2715 aFBOPtr = aPrevFBOPtr;
2719 if (aFBOPtr.IsNull())
2721 Standard_Integer aMaxTexSizeX = MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxViewDumpSizeX);
2722 Standard_Integer aMaxTexSizeY = MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxViewDumpSizeY);
2723 if (theParams.TileSize > aMaxTexSizeX
2724 || theParams.TileSize > aMaxTexSizeY)
2726 Message::SendFail (TCollection_AsciiString ("Image dump can not be performed - specified tile size (")
2727 + theParams.TileSize + ") exceeds hardware limits (" + aMaxTexSizeX + "x" + aMaxTexSizeY + ")");
2728 return Standard_False;
2731 if (aFBOVPSize.x() > aMaxTexSizeX
2732 || aFBOVPSize.y() > aMaxTexSizeY)
2734 if (MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_IsWorkaroundFBO))
2736 Message::SendWarning ("Warning, workaround for Intel driver problem with empty FBO for images with big width is applied");
2738 Message::SendInfo (TCollection_AsciiString ("Info, tiling image dump is used, image size (")
2739 + aFBOVPSize.x() + "x" + aFBOVPSize.y() + ") exceeds hardware limits (" + aMaxTexSizeX + "x" + aMaxTexSizeY + ")");
2740 aFBOVPSize.x() = Min (aFBOVPSize.x(), aMaxTexSizeX);
2741 aFBOVPSize.y() = Min (aFBOVPSize.y(), aMaxTexSizeY);
2745 // Try to create hardware accelerated buffer
2746 aFBOPtr = myView->FBOCreate (aFBOVPSize.x(), aFBOVPSize.y());
2748 myView->SetFBO (aFBOPtr);
2750 if (aFBOPtr.IsNull())
2752 // try to use on-screen buffer
2753 Graphic3d_Vec2i aWinSize;
2754 MyWindow->Size (aWinSize.x(), aWinSize.y());
2755 if (aFBOVPSize.x() != aWinSize.x()
2756 || aFBOVPSize.y() != aWinSize.y())
2760 aFBOVPSize = aWinSize;
2762 Message::SendWarning ("Warning, on screen buffer is used for image dump - content might be invalid");
2765 // backup camera parameters
2766 Handle(Graphic3d_Camera) aStoreMapping = new Graphic3d_Camera();
2767 Handle(Graphic3d_Camera) aCamera = Camera();
2768 aStoreMapping->Copy (aCamera);
2769 if (aCamera->IsStereo())
2771 switch (theParams.StereoOptions)
2775 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
2778 case V3d_SDO_LEFT_EYE:
2780 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye);
2783 case V3d_SDO_RIGHT_EYE:
2785 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye);
2788 case V3d_SDO_BLENDED:
2790 break; // dump as is
2794 if (theParams.ToAdjustAspect)
2796 aCamera->SetAspect (Standard_Real(aTargetSize.x()) / Standard_Real(aTargetSize.y()));
2799 // render immediate structures into back buffer rather than front
2800 const Standard_Boolean aPrevImmediateMode = myView->SetImmediateModeDrawToFront (Standard_False);
2802 Standard_Boolean isSuccess = Standard_True;
2805 if (!aFBOPtr.IsNull())
2807 myView->FBOChangeViewport (aFBOPtr, aTargetSize.x(), aTargetSize.y());
2810 isSuccess = isSuccess && myView->BufferDump (theImage, theParams.BufferType);
2814 Image_PixMap aTilePixMap;
2815 aTilePixMap.SetTopDown (theImage.IsTopDown());
2817 Graphic3d_Vec2i anOffset (0, 0);
2818 for (; anOffset.y() < aTargetSize.y(); anOffset.y() += aFBOVPSize.y())
2821 for (; anOffset.x() < aTargetSize.x(); anOffset.x() += aFBOVPSize.x())
2823 Graphic3d_CameraTile aTileUncropped;
2824 aTileUncropped.Offset = anOffset;
2825 aTileUncropped.TotalSize = aTargetSize;
2826 aTileUncropped.TileSize = aFBOVPSize;
2827 const Graphic3d_CameraTile aTile = aTileUncropped.Cropped();
2828 if (aTile.TileSize.x() < 1
2829 || aTile.TileSize.y() < 1)
2834 const Standard_Integer aLeft = aTile.Offset.x();
2835 Standard_Integer aBottom = aTile.Offset.y();
2836 if (theImage.IsTopDown())
2838 const Standard_Integer aTop = aTile.Offset.y() + aTile.TileSize.y();
2839 aBottom = aTargetSize.y() - aTop;
2841 aTilePixMap.InitWrapper (theImage.Format(), theImage.ChangeData()
2842 + theImage.SizeRowBytes() * aBottom + theImage.SizePixelBytes() * aLeft,
2843 aTile.TileSize.x(), aTile.TileSize.y(),
2844 theImage.SizeRowBytes());
2846 if (!aFBOPtr.IsNull())
2848 aCamera->SetTile (aTile);
2849 myView->FBOChangeViewport (aFBOPtr, aTile.TileSize.x(), aTile.TileSize.y());
2853 // no API to resize viewport of on-screen buffer - render uncropped
2854 aCamera->SetTile (aTileUncropped);
2857 isSuccess = isSuccess && myView->BufferDump (aTilePixMap, theParams.BufferType);
2871 myView->SetImmediateModeDrawToFront (aPrevImmediateMode);
2872 aCamera->Copy (aStoreMapping);
2873 if (aFBOPtr != aPrevFBOPtr)
2875 myView->FBORelease (aFBOPtr);
2877 else if (!aPrevFBOPtr.IsNull())
2879 myView->FBOChangeViewport (aPrevFBOPtr, aPrevFBOVPSize.x(), aPrevFBOVPSize.y());
2881 myView->SetFBO (aPrevFBOPtr);
2885 //=============================================================================
2886 //function : ImmediateUpdate
2888 //=============================================================================
2889 void V3d_View::ImmediateUpdate() const
2891 if (myImmediateUpdate)
2897 //=============================================================================
2898 //function : SetImmediateUpdate
2900 //=============================================================================
2901 Standard_Boolean V3d_View::SetImmediateUpdate (const Standard_Boolean theImmediateUpdate)
2903 Standard_Boolean aPreviousMode = myImmediateUpdate;
2904 myImmediateUpdate = theImmediateUpdate;
2905 return aPreviousMode;
2908 // =======================================================================
2909 // function : SetCamera
2911 // =======================================================================
2912 void V3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
2914 myView->SetCamera (theCamera);
2919 // =======================================================================
2920 // function : GetCamera
2922 // =======================================================================
2923 const Handle(Graphic3d_Camera)& V3d_View::Camera() const
2925 return myView->Camera();
2928 // =======================================================================
2929 // function : FitMinMax
2930 // purpose : Internal
2931 // =======================================================================
2932 Standard_Boolean V3d_View::FitMinMax (const Handle(Graphic3d_Camera)& theCamera,
2933 const Bnd_Box& theBox,
2934 const Standard_Real theMargin,
2935 const Standard_Real theResolution,
2936 const Standard_Boolean theToEnlargeIfLine) const
2938 if (!theCamera->FitMinMax (theBox, theResolution, theToEnlargeIfLine))
2940 return Standard_False; // bounding box is out of bounds...
2943 const Standard_Real aZoomCoef = myView->ConsiderZoomPersistenceObjects();
2944 Scale (theCamera, theCamera->ViewDimensions().X() * (aZoomCoef + theMargin), theCamera->ViewDimensions().Y() * (aZoomCoef + theMargin));
2945 return Standard_True;
2948 // =======================================================================
2950 // purpose : Internal
2951 // =======================================================================
2952 void V3d_View::Scale (const Handle(Graphic3d_Camera)& theCamera,
2953 const Standard_Real theSizeXv,
2954 const Standard_Real theSizeYv) const
2956 Standard_Real anAspect = theCamera->Aspect();
2959 theCamera->SetScale (Max (theSizeXv / anAspect, theSizeYv));
2963 theCamera->SetScale (Max (theSizeXv, theSizeYv * anAspect));
2967 // =======================================================================
2968 // function : Translate
2969 // purpose : Internal
2970 // =======================================================================
2971 void V3d_View::Translate (const Handle(Graphic3d_Camera)& theCamera,
2972 const Standard_Real theDXv,
2973 const Standard_Real theDYv) const
2975 const gp_Pnt& aCenter = theCamera->Center();
2976 const gp_Dir& aDir = theCamera->Direction();
2977 const gp_Dir& anUp = theCamera->Up();
2978 gp_Ax3 aCameraCS (aCenter, aDir.Reversed(), aDir ^ anUp);
2980 gp_Vec aCameraPanXv = gp_Vec (aCameraCS.XDirection()) * theDXv;
2981 gp_Vec aCameraPanYv = gp_Vec (aCameraCS.YDirection()) * theDYv;
2982 gp_Vec aCameraPan = aCameraPanXv + aCameraPanYv;
2984 aPanTrsf.SetTranslation (aCameraPan);
2986 theCamera->Transform (aPanTrsf);
2989 // =======================================================================
2990 // function : DiagnosticInformation
2992 // =======================================================================
2993 void V3d_View::DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
2994 Graphic3d_DiagnosticInfo theFlags) const
2996 myView->DiagnosticInformation (theDict, theFlags);
2999 //=======================================================================
3000 //function : StatisticInformation
3002 //=======================================================================
3003 void V3d_View::StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const
3005 myView->StatisticInformation (theDict);
3008 // =======================================================================
3009 // function : StatisticInformation
3011 // =======================================================================
3012 TCollection_AsciiString V3d_View::StatisticInformation() const
3014 return myView->StatisticInformation();
3017 //=============================================================================
3018 //function : RenderingParams
3020 //=============================================================================
3021 const Graphic3d_RenderingParams& V3d_View::RenderingParams() const
3023 return myView->RenderingParams();
3026 //=============================================================================
3027 //function : ChangeRenderingParams
3029 //=============================================================================
3030 Graphic3d_RenderingParams& V3d_View::ChangeRenderingParams()
3032 return myView->ChangeRenderingParams();
3036 //=============================================================================
3037 //function : SetLightOn
3039 //=============================================================================
3040 void V3d_View::SetLightOn (const Handle(V3d_Light)& theLight)
3042 if (!myActiveLights.Contains (theLight))
3044 myActiveLights.Append (theLight);
3049 //=============================================================================
3050 //function : SetLightOff
3052 //=============================================================================
3053 void V3d_View::SetLightOff (const Handle(V3d_Light)& theLight)
3055 if (MyViewer->IsGlobalLight (theLight))
3056 throw Standard_TypeMismatch("V3d_View::SetLightOff, the light is global");
3057 myActiveLights.Remove (theLight);
3061 //=============================================================================
3062 //function : IsActiveLight
3064 //=============================================================================
3065 Standard_Boolean V3d_View::IsActiveLight (const Handle(V3d_Light)& theLight) const
3067 return !theLight.IsNull()
3068 && myActiveLights.Contains (theLight);
3071 //=============================================================================
3072 //function : SetLightOn
3074 //=============================================================================
3075 void V3d_View::SetLightOn()
3077 for (V3d_ListOfLightIterator aDefLightIter (MyViewer->DefinedLightIterator()); aDefLightIter.More(); aDefLightIter.Next())
3079 if (!myActiveLights.Contains (aDefLightIter.Value()))
3081 myActiveLights.Append (aDefLightIter.Value());
3087 //=============================================================================
3088 //function : SetLightOff
3090 //=============================================================================
3091 void V3d_View::SetLightOff()
3093 for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More();)
3095 if (!MyViewer->IsGlobalLight (anActiveLightIter.Value()))
3097 myActiveLights.Remove (anActiveLightIter);
3101 anActiveLightIter.Next();
3107 //=============================================================================
3108 //function : IfMoreLights
3110 //=============================================================================
3111 Standard_Boolean V3d_View::IfMoreLights() const
3113 return myActiveLights.Extent() < LightLimit();
3116 //=======================================================================
3117 //function : LightLimit
3119 //=======================================================================
3120 Standard_Integer V3d_View::LightLimit() const
3122 return Viewer()->Driver()->InquireLightLimit();
3125 //=======================================================================
3126 //function : AddClipPlane
3128 //=======================================================================
3129 void V3d_View::AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
3131 Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes();
3132 if (aSeqOfPlanes.IsNull())
3134 aSeqOfPlanes = new Graphic3d_SequenceOfHClipPlane();
3138 for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next())
3140 const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
3141 if (aPlane == thePlane)
3143 // plane is already defined in view
3149 aSeqOfPlanes->Append (thePlane);
3150 SetClipPlanes (aSeqOfPlanes);
3153 //=======================================================================
3154 //function : RemoveClipPlane
3156 //=======================================================================
3157 void V3d_View::RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
3159 Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes();
3160 if (aSeqOfPlanes.IsNull())
3165 for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next())
3167 const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
3168 if (aPlane != thePlane)
3173 aSeqOfPlanes->Remove (aPlaneIt);
3174 SetClipPlanes (aSeqOfPlanes);
3179 //=======================================================================
3180 //function : SetClipPlanes
3182 //=======================================================================
3183 void V3d_View::SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
3185 myView->SetClipPlanes (thePlanes);
3188 //=======================================================================
3189 //function : ClipPlanes
3191 //=======================================================================
3192 const Handle(Graphic3d_SequenceOfHClipPlane)& V3d_View::ClipPlanes() const
3194 return myView->ClipPlanes();
3197 //=======================================================================
3198 //function : PlaneLimit
3200 //=======================================================================
3201 Standard_Integer V3d_View::PlaneLimit() const
3203 return Viewer()->Driver()->InquirePlaneLimit();
3206 //=============================================================================
3209 //=============================================================================
3210 void V3d_View::Move (const Standard_Real theDx,
3211 const Standard_Real theDy,
3212 const Standard_Real theDz,
3213 const Standard_Boolean theStart)
3215 Handle(Graphic3d_Camera) aCamera = Camera();
3218 myCamStartOpEye = aCamera->Eye();
3220 gp_Dir aReferencePlane (aCamera->Direction().Reversed());
3221 gp_Dir anUp (aCamera->Up());
3222 if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
3224 throw V3d_BadValue ("V3d_View::Translate, alignment of Eye,At,Up");
3228 Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
3229 myXscreenAxis.Coord (XX,XY,XZ);
3230 myYscreenAxis.Coord (YX,YY,YZ);
3231 myZscreenAxis.Coord (ZX,ZY,ZZ);
3233 aCamera->SetEye (myCamStartOpEye);
3235 aCamera->SetEye (aCamera->Eye().XYZ()
3236 + theDx * gp_Pnt (XX, XY, XZ).XYZ()
3237 + theDy * gp_Pnt (YX, YY, YZ).XYZ()
3238 + theDz * gp_Pnt (ZX, ZY, ZZ).XYZ()
3244 //=============================================================================
3247 //=============================================================================
3248 void V3d_View::Move (const Standard_Real theLength, const Standard_Boolean theStart)
3250 Handle(Graphic3d_Camera) aCamera = Camera();
3253 myCamStartOpEye = aCamera->Eye();
3255 aCamera->SetEye (myCamStartOpEye);
3256 aCamera->SetEye (aCamera->Eye().XYZ() + theLength * myDefaultViewAxis.XYZ());
3261 //=============================================================================
3264 //=============================================================================
3265 void V3d_View::Move (const V3d_TypeOfAxe theAxe,
3266 const Standard_Real theLength,
3267 const Standard_Boolean theStart)
3272 Move (theLength,0.,0.,theStart);
3275 Move (0.,theLength,0.,theStart);
3278 Move (0.,0.,theLength,theStart);
3283 //=============================================================================
3284 //function : Translate
3286 //=============================================================================
3287 void V3d_View::Translate (const Standard_Real theDx,
3288 const Standard_Real theDy,
3289 const Standard_Real theDz,
3290 const Standard_Boolean theStart)
3292 Handle(Graphic3d_Camera) aCamera = Camera();
3295 myCamStartOpEye = aCamera->Eye();
3296 myCamStartOpCenter = aCamera->Center();
3298 gp_Dir aReferencePlane (aCamera->Direction().Reversed());
3299 gp_Dir anUp (aCamera->Up());
3300 if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
3302 throw V3d_BadValue ("V3d_View::Translate, alignment of Eye,At,Up");
3306 aCamera->SetEye (myCamStartOpEye);
3307 aCamera->SetCenter (myCamStartOpCenter);
3309 aCamera->SetCenter (aCamera->Center().XYZ()
3310 - theDx * myXscreenAxis.XYZ()
3311 - theDy * myYscreenAxis.XYZ()
3312 - theDz * myZscreenAxis.XYZ()
3315 aCamera->SetEye (aCamera->Eye().XYZ()
3316 - theDx * myXscreenAxis.XYZ()
3317 - theDy * myYscreenAxis.XYZ()
3318 - theDz * myZscreenAxis.XYZ()
3324 //=============================================================================
3325 //function : Translate
3327 //=============================================================================
3328 void V3d_View::Translate (const V3d_TypeOfAxe theAxe, const Standard_Real theLength,const Standard_Boolean theStart)
3333 Translate (theLength,0.,0., theStart);
3336 Translate (0.,theLength,0., theStart);
3339 Translate (0.,0.,theLength, theStart);
3344 //=======================================================================
3347 //=======================================================================
3348 void V3d_View::Place (const Standard_Integer theXp,
3349 const Standard_Integer theYp,
3350 const Standard_Real theZoomFactor)
3352 Standard_Integer aWinWidth = 0;
3353 Standard_Integer aWinHeight = 0;
3354 View()->Window()->Size (aWinWidth, aWinHeight);
3356 Standard_Integer aWinCXp = aWinWidth / 2;
3357 Standard_Integer aWinCYp = aWinHeight / 2;
3358 Pan (aWinCXp - theXp, -(aWinCYp - theYp), theZoomFactor / Scale());
3361 //=======================================================================
3362 //function : Translate
3364 //=======================================================================
3365 void V3d_View::Translate (const Standard_Real theLength, const Standard_Boolean theStart)
3367 Handle(Graphic3d_Camera) aCamera = Camera();
3370 myCamStartOpCenter = aCamera->Center() ;
3373 gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - myDefaultViewAxis.XYZ() * theLength);
3374 aCamera->SetCenter (aNewCenter);
3379 //=============================================================================
3380 //function : SetGrid
3382 //=============================================================================
3383 void V3d_View::SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid)
3388 Standard_Real xl, yl, zl;
3389 Standard_Real xdx, xdy, xdz;
3390 Standard_Real ydx, ydy, ydz;
3391 Standard_Real dx, dy, dz;
3392 aPlane.Location ().Coord (xl, yl, zl);
3393 aPlane.XDirection ().Coord (xdx, xdy, xdz);
3394 aPlane.YDirection ().Coord (ydx, ydy, ydz);
3395 aPlane.Direction ().Coord (dx, dy, dz);
3397 Standard_Real CosAlpha = Cos (MyGrid->RotationAngle ());
3398 Standard_Real SinAlpha = Sin (MyGrid->RotationAngle ());
3400 TColStd_Array2OfReal Trsf1 (1, 4, 1, 4);
3402 Trsf1 (4, 1) = Trsf1 (4, 2) = Trsf1 (4, 3) = 0.0;
3407 // Transformation change of marker
3418 TColStd_Array2OfReal Trsf2 (1, 4, 1, 4);
3420 Trsf2 (4, 1) = Trsf2 (4, 2) = Trsf2 (4, 3) = 0.0;
3421 // Translation of the origin
3422 Trsf2 (1, 4) = -MyGrid->XOrigin (),
3423 Trsf2 (2, 4) = -MyGrid->YOrigin (),
3425 // Rotation Alpha around axis -Z
3426 Trsf2 (1, 1) = CosAlpha,
3427 Trsf2 (2, 1) = -SinAlpha,
3429 Trsf2 (1, 2) = SinAlpha,
3430 Trsf2 (2, 2) = CosAlpha,
3436 Standard_Real valuetrsf;
3437 Standard_Real valueoldtrsf;
3438 Standard_Real valuenewtrsf;
3439 Standard_Integer i, j, k;
3440 // Calculation of the product of matrices
3441 for (i=1; i<=4; i++)
3442 for (j=1; j<=4; j++) {
3443 MyTrsf (i, j) = 0.0;
3444 for (k=1; k<=4; k++) {
3445 valueoldtrsf = Trsf1 (i, k);
3446 valuetrsf = Trsf2 (k, j);
3447 valuenewtrsf = MyTrsf (i, j) + valueoldtrsf * valuetrsf;
3448 MyTrsf (i, j) = valuenewtrsf;
3453 //=============================================================================
3454 //function : SetGridActivity
3456 //=============================================================================
3457 void V3d_View::SetGridActivity (const Standard_Boolean AFlag)
3459 if (AFlag) MyGrid->Activate ();
3460 else MyGrid->Deactivate ();
3463 //=============================================================================
3464 //function : toPolarCoords
3466 //=============================================================================
3467 void toPolarCoords (const Standard_Real theX, const Standard_Real theY,
3468 Standard_Real& theR, Standard_Real& thePhi)
3470 theR = Sqrt (theX * theX + theY * theY);
3471 thePhi = ATan2 (theY, theX);
3474 //=============================================================================
3475 //function : toCartesianCoords
3477 //=============================================================================
3478 void toCartesianCoords (const Standard_Real theR, const Standard_Real thePhi,
3479 Standard_Real& theX, Standard_Real& theY)
3481 theX = theR * Cos (thePhi);
3482 theY = theR * Sin (thePhi);
3485 //=============================================================================
3486 //function : Compute
3488 //=============================================================================
3489 Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex& theVertex) const
3491 const Handle(Graphic3d_Camera)& aCamera = Camera();
3492 gp_Dir VPN = aCamera->Direction().Reversed(); // RefPlane
3493 gp_Dir GPN = MyPlane.Direction();
3495 Standard_Real XPp = 0.0, YPp = 0.0;
3496 Project (theVertex.X(), theVertex.Y(), theVertex.Z(), XPp, YPp);
3498 // Casw when the plane of the grid and the plane of the view
3499 // are perpendicular to MYEPSILON2 close radians
3500 #define MYEPSILON2 M_PI / 180.0 // Delta between 2 angles
3501 if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2)
3506 const gp_XYZ aPnt0 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 0.0, 0.0), MyTrsf);
3508 // get grid axes in world space
3509 const gp_XYZ aPnt1 = V3d_View::TrsPoint (Graphic3d_Vertex (1.0, 0.0, 0.0), MyTrsf);
3510 gp_Vec aGridX (aPnt0, aPnt1);
3513 const gp_XYZ aPnt2 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 1.0, 0.0), MyTrsf);
3514 gp_Vec aGridY (aPnt0, aPnt2);
3517 // project ray from camera onto grid plane
3518 const gp_Vec aProjection = aCamera->IsOrthographic()
3519 ? gp_Vec (aCamera->Direction())
3520 : gp_Vec (aCamera->Eye(), gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z())).Normalized();
3521 const gp_Vec aPointOrigin = gp_Vec (gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z()), aPnt0);
3522 const Standard_Real aT = aPointOrigin.Dot (MyPlane.Direction()) / aProjection.Dot (MyPlane.Direction());
3523 const gp_XYZ aPointOnPlane = gp_XYZ (theVertex.X(), theVertex.Y(), theVertex.Z()) + aProjection.XYZ() * aT;
3525 if (Handle(Aspect_RectangularGrid) aRectGrid = Handle(Aspect_RectangularGrid)::DownCast (MyGrid))
3527 // project point on plane to grid local space
3528 const gp_Vec aToPoint (aPnt0, aPointOnPlane);
3529 const Standard_Real anXSteps = Round (aGridX.Dot (aToPoint) / aRectGrid->XStep());
3530 const Standard_Real anYSteps = Round (aGridY.Dot (aToPoint) / aRectGrid->YStep());
3532 // clamp point to grid
3533 const gp_Vec aResult = aGridX * anXSteps * aRectGrid->XStep()
3534 + aGridY * anYSteps * aRectGrid->YStep()
3536 return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z());
3538 else if (Handle(Aspect_CircularGrid) aCircleGrid = Handle(Aspect_CircularGrid)::DownCast (MyGrid))
3540 const Standard_Real anAlpha = M_PI / Standard_Real (aCircleGrid->DivisionNumber());
3542 // project point on plane to grid local space
3543 const gp_Vec aToPoint (aPnt0, aPointOnPlane);
3544 Standard_Real aLocalX = aGridX.Dot (aToPoint);
3545 Standard_Real aLocalY = aGridY.Dot (aToPoint);
3546 Standard_Real anR = 0.0, aPhi = 0.0;
3547 toPolarCoords (aLocalX, aLocalY, anR, aPhi);
3549 // clamp point to grid
3550 const Standard_Real anRSteps = Round (anR / aCircleGrid->RadiusStep());
3551 const Standard_Real aPhiSteps = Round (aPhi / anAlpha);
3552 toCartesianCoords (anRSteps * aCircleGrid->RadiusStep(), aPhiSteps * anAlpha, aLocalX, aLocalY);
3554 const gp_Vec aResult = aGridX * aLocalX + aGridY * aLocalY + gp_Vec (aPnt0);
3555 return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z());
3557 return Graphic3d_Vertex (0.0, 0.0, 0.0);
3560 //=============================================================================
3561 //function : ZBufferTriedronSetup
3563 //=============================================================================
3564 void V3d_View::ZBufferTriedronSetup (const Quantity_Color& theXColor,
3565 const Quantity_Color& theYColor,
3566 const Quantity_Color& theZColor,
3567 const Standard_Real theSizeRatio,
3568 const Standard_Real theAxisDiametr,
3569 const Standard_Integer theNbFacettes)
3571 const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true);
3572 aTrihedron->SetArrowsColor (theXColor, theYColor, theZColor);
3573 aTrihedron->SetSizeRatio (theSizeRatio);
3574 aTrihedron->SetNbFacets (theNbFacettes);
3575 aTrihedron->SetArrowDiameter (theAxisDiametr);
3578 //=============================================================================
3579 //function : TriedronDisplay
3581 //=============================================================================
3582 void V3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
3583 const Quantity_Color& theColor,
3584 const Standard_Real theScale,
3585 const V3d_TypeOfVisualization theMode)
3587 const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true);
3588 aTrihedron->SetLabelsColor (theColor);
3589 aTrihedron->SetScale (theScale);
3590 aTrihedron->SetPosition (thePosition);
3591 aTrihedron->SetWireframe (theMode == V3d_WIREFRAME);
3593 aTrihedron->Display (*this);
3596 //=============================================================================
3597 //function : TriedronErase
3599 //=============================================================================
3600 void V3d_View::TriedronErase()
3602 if (!myTrihedron.IsNull())
3604 myTrihedron->Erase();
3608 //=============================================================================
3609 //function : GetGraduatedTrihedron
3611 //=============================================================================
3612 const Graphic3d_GraduatedTrihedron& V3d_View::GetGraduatedTrihedron() const
3614 return myView->GetGraduatedTrihedron();
3617 //=============================================================================
3618 //function : GraduatedTrihedronDisplay
3620 //=============================================================================
3621 void V3d_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData)
3623 myView->GraduatedTrihedronDisplay (theTrihedronData);
3626 //=============================================================================
3627 //function : GraduatedTrihedronErase
3629 //=============================================================================
3630 void V3d_View::GraduatedTrihedronErase()
3632 myView->GraduatedTrihedronErase();
3635 // =======================================================================
3636 // function : DumpJson
3638 // =======================================================================
3639 void V3d_View::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
3641 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
3643 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOldMouseX)
3644 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOldMouseY)
3645 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpUp)
3646 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpDir)
3647 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpEye)
3648 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpCenter)
3649 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDefaultCamera.get())
3650 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myView.get())
3651 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myImmediateUpdate)
3652 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsInvalidatedImmediate)
3654 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, MyViewer)
3655 for (V3d_ListOfLight::Iterator anIterator (myActiveLights); anIterator.More(); anIterator.Next())
3657 class Handle(Graphic3d_CLight)& anActiveLight = anIterator.Value();
3658 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, anActiveLight)
3660 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultViewAxis)
3661 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultViewPoint)
3662 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyWindow.get())
3663 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, sx)
3664 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, sy)
3665 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, rx)
3666 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, ry)
3667 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myRotateGravity)
3668 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputedMode)
3669 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, SwitchSetFront)
3670 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myZRotation)
3671 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, MyZoomAtPointX)
3672 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, MyZoomAtPointY)
3673 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTrihedron.get())
3674 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyGrid.get())
3675 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &MyPlane)
3676 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyGridEchoStructure.get())
3677 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyGridEchoGroup.get())
3678 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myXscreenAxis)
3679 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myYscreenAxis)
3680 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myZscreenAxis)
3681 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myViewAxis)
3682 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myGravityReferencePoint)
3683 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoZFitIsOn)
3684 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoZFitScaleFactor)