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());
101 SetProj (theViewer->DefaultViewProj());
102 SetSize (theViewer->DefaultViewSize());
103 Standard_Real zsize = theViewer->DefaultViewSize();
105 SetDepth (theViewer->DefaultViewSize() / 2.0);
106 SetViewMappingDefault();
107 SetViewOrientationDefault();
108 theViewer->AddView (this);
110 myImmediateUpdate = Standard_True;
113 //=============================================================================
114 //function : Constructor
116 //=============================================================================
117 V3d_View::V3d_View (const Handle(V3d_Viewer)& theViewer, const Handle(V3d_View)& theView)
118 : myIsInvalidatedImmediate (Standard_True),
119 MyViewer (theViewer.operator->()),
120 SwitchSetFront(Standard_False),
121 myZRotation (Standard_False),
124 myView = theViewer->Driver()->CreateView (theViewer->StructureManager());
126 myView->CopySettings (theView->View());
127 myDefaultViewPoint = theView->myDefaultViewPoint;
128 myDefaultViewAxis = theView->myDefaultViewAxis;
130 myDefaultCamera = new Graphic3d_Camera (theView->DefaultCamera());
132 myImmediateUpdate = Standard_False;
133 SetAutoZFitMode (theView->AutoZFitMode(), theView->AutoZFitScaleFactor());
134 theViewer->AddView (this);
136 myImmediateUpdate = Standard_True;
139 //=============================================================================
140 //function : Destructor
142 //=============================================================================
143 V3d_View::~V3d_View()
145 if (!myView->IsRemoved())
151 //=============================================================================
152 //function : SetMagnify
154 //=============================================================================
155 void V3d_View::SetMagnify (const Handle(Aspect_Window)& theWindow,
156 const Handle(V3d_View)& thePreviousView,
157 const Standard_Integer theX1,
158 const Standard_Integer theY1,
159 const Standard_Integer theX2,
160 const Standard_Integer theY2)
162 if (!myView->IsRemoved() && !myView->IsDefined())
164 Standard_Real aU1, aV1, aU2, aV2;
165 thePreviousView->Convert (theX1, theY1, aU1, aV1);
166 thePreviousView->Convert (theX2, theY2, aU2, aV2);
167 myView->SetWindow (theWindow);
168 FitAll (aU1, aV1, aU2, aV2);
169 MyViewer->SetViewOn (this);
170 MyWindow = theWindow;
173 SetViewMappingDefault();
177 //=============================================================================
178 //function : SetWindow
180 //=============================================================================
181 void V3d_View::SetWindow (const Handle(Aspect_Window)& theWindow,
182 const Aspect_RenderingContext theContext)
184 if (myView->IsRemoved())
189 // method V3d_View::SetWindow() should assign the field MyWindow before calling Redraw()
190 MyWindow = theWindow;
191 myView->SetWindow (theWindow, theContext);
192 MyViewer->SetViewOn (this);
194 if (myImmediateUpdate)
200 //=============================================================================
203 //=============================================================================
204 void V3d_View::Remove()
206 if (!MyGrid.IsNull())
210 if (!myTrihedron.IsNull())
212 myTrihedron->Erase();
215 MyViewer->DelView (this);
217 Handle(Aspect_Window)& aWin = const_cast<Handle(Aspect_Window)&> (MyWindow);
221 //=============================================================================
224 //=============================================================================
225 void V3d_View::Update() const
227 if (!myView->IsDefined()
228 || !myView->IsActive())
233 myIsInvalidatedImmediate = Standard_False;
240 //=============================================================================
243 //=============================================================================
244 void V3d_View::Redraw() const
246 if (!myView->IsDefined()
247 || !myView->IsActive())
252 myIsInvalidatedImmediate = Standard_False;
253 Handle(Graphic3d_StructureManager) aStructureMgr = MyViewer->StructureManager();
254 for (Standard_Integer aRetryIter = 0; aRetryIter < 2; ++aRetryIter)
256 if (aStructureMgr->IsDeviceLost())
258 aStructureMgr->RecomputeStructures();
265 if (!aStructureMgr->IsDeviceLost())
272 //=============================================================================
273 //function : RedrawImmediate
275 //=============================================================================
276 void V3d_View::RedrawImmediate() const
278 if (!myView->IsDefined()
279 || !myView->IsActive())
284 myIsInvalidatedImmediate = Standard_False;
285 myView->RedrawImmediate();
288 //=============================================================================
289 //function : Invalidate
291 //=============================================================================
292 void V3d_View::Invalidate() const
294 if (!myView->IsDefined())
299 myView->Invalidate();
302 //=============================================================================
303 //function : IsInvalidated
305 //=============================================================================
306 Standard_Boolean V3d_View::IsInvalidated() const
308 return !myView->IsDefined()
309 || myView->IsInvalidated();
312 // ========================================================================
313 // function : SetAutoZFitMode
315 // ========================================================================
316 void V3d_View::SetAutoZFitMode (const Standard_Boolean theIsOn,
317 const Standard_Real theScaleFactor)
319 Standard_ASSERT_RAISE (theScaleFactor > 0.0, "Zero or negative scale factor is not allowed.");
320 myAutoZFitScaleFactor = theScaleFactor;
321 myAutoZFitIsOn = theIsOn;
324 //=============================================================================
325 //function : AutoZFit
327 //=============================================================================
328 void V3d_View::AutoZFit() const
335 ZFitAll (myAutoZFitScaleFactor);
338 //=============================================================================
341 //=============================================================================
342 void V3d_View::ZFitAll (const Standard_Real theScaleFactor) const
344 Bnd_Box aMinMaxBox = myView->MinMaxValues (Standard_False); // applicative min max boundaries
345 Bnd_Box aGraphicBox = myView->MinMaxValues (Standard_True); // real graphical boundaries (not accounting infinite flag).
347 myView->Camera()->ZFitAll (theScaleFactor, aMinMaxBox, aGraphicBox);
350 //=============================================================================
353 //=============================================================================
354 Standard_Boolean V3d_View::IsEmpty() const
356 Standard_Boolean TheStatus = Standard_True ;
357 if( myView->IsDefined() ) {
358 Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ;
359 if( Nstruct > 0 ) TheStatus = Standard_False ;
364 //=============================================================================
365 //function : UpdateLights
367 //=============================================================================
368 void V3d_View::UpdateLights() const
370 Handle(Graphic3d_LightSet) aLights = new Graphic3d_LightSet();
371 for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More(); anActiveLightIter.Next())
373 aLights->Add (anActiveLightIter.Value());
375 myView->SetLights (aLights);
378 //=============================================================================
379 //function : DoMapping
381 //=============================================================================
382 void V3d_View::DoMapping()
384 if (!myView->IsDefined())
389 myView->Window()->DoMapping();
392 //=============================================================================
393 //function : MustBeResized
395 //=============================================================================
396 void V3d_View::MustBeResized()
398 if (!myView->IsDefined())
406 if (myImmediateUpdate)
412 //=============================================================================
413 //function : SetBackgroundColor
415 //=============================================================================
416 void V3d_View::SetBackgroundColor (const Quantity_TypeOfColor theType,
417 const Standard_Real theV1,
418 const Standard_Real theV2,
419 const Standard_Real theV3)
421 Standard_Real aV1 = Max (Min (theV1, 1.0), 0.0);
422 Standard_Real aV2 = Max (Min (theV2, 1.0), 0.0);
423 Standard_Real aV3 = Max (Min (theV3, 1.0), 0.0);
425 SetBackgroundColor (Quantity_Color (aV1, aV2, aV3, theType));
428 //=============================================================================
429 //function : SetBackgroundColor
431 //=============================================================================
432 void V3d_View::SetBackgroundColor (const Quantity_Color& theColor)
434 myView->SetBackground (Aspect_Background (theColor));
436 if (myImmediateUpdate)
442 //=============================================================================
443 //function : SetBgGradientColors
445 //=============================================================================
446 void V3d_View::SetBgGradientColors (const Quantity_Color& theColor1,
447 const Quantity_Color& theColor2,
448 const Aspect_GradientFillMethod theFillStyle,
449 const Standard_Boolean theToUpdate)
451 Aspect_GradientBackground aGradientBg (theColor1, theColor2, theFillStyle);
453 myView->SetGradientBackground (aGradientBg);
455 if (myImmediateUpdate || theToUpdate)
461 //=============================================================================
462 //function : SetBgGradientStyle
464 //=============================================================================
465 void V3d_View::SetBgGradientStyle (const Aspect_GradientFillMethod theFillStyle, const Standard_Boolean theToUpdate)
467 Quantity_Color aColor1;
468 Quantity_Color aColor2;
469 GradientBackground().Colors (aColor1, aColor2);
471 SetBgGradientColors (aColor1, aColor2, theFillStyle, theToUpdate);
474 //=============================================================================
475 //function : SetBackgroundImage
477 //=============================================================================
478 void V3d_View::SetBackgroundImage (const Standard_CString theFileName,
479 const Aspect_FillMethod theFillStyle,
480 const Standard_Boolean theToUpdate)
482 Handle(Graphic3d_Texture2D) aTextureMap = new Graphic3d_Texture2Dmanual (theFileName);
483 aTextureMap->DisableModulate();
484 SetBackgroundImage (aTextureMap, theFillStyle, theToUpdate);
487 //=============================================================================
488 //function : SetBackgroundImage
490 //=============================================================================
491 void V3d_View::SetBackgroundImage (const Handle(Graphic3d_Texture2D)& theTexture,
492 const Aspect_FillMethod theFillStyle,
493 const Standard_Boolean theToUpdate)
495 myView->SetBackgroundImage (theTexture);
496 myView->SetBackgroundImageStyle (theFillStyle);
497 if (myImmediateUpdate || theToUpdate)
503 //=============================================================================
504 //function : SetBgImageStyle
506 //=============================================================================
507 void V3d_View::SetBgImageStyle (const Aspect_FillMethod theFillStyle, const Standard_Boolean theToUpdate)
509 myView->SetBackgroundImageStyle (theFillStyle);
511 if (myImmediateUpdate || theToUpdate)
517 //=============================================================================
518 //function : SetBackgroundCubeMap
520 //=============================================================================
521 void V3d_View::SetBackgroundCubeMap (const Handle(Graphic3d_CubeMap)& theCubeMap,
522 Standard_Boolean theToUpdatePBREnv,
523 Standard_Boolean theToUpdate)
525 myView->SetBackgroundImage (theCubeMap, theToUpdatePBREnv);
526 if (myImmediateUpdate || theToUpdate)
532 //=============================================================================
533 //function : IsImageBasedLighting
535 //=============================================================================
536 Standard_Boolean V3d_View::IsImageBasedLighting() const
538 return !myView->IBLCubeMap().IsNull();
541 //=============================================================================
542 //function : SetImageBasedLighting
544 //=============================================================================
545 void V3d_View::SetImageBasedLighting (Standard_Boolean theToEnableIBL,
546 Standard_Boolean theToUpdate)
548 myView->SetImageBasedLighting (theToEnableIBL);
549 if (myImmediateUpdate || theToUpdate)
555 //=============================================================================
558 //=============================================================================
559 void V3d_View::SetAxis (const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ,
560 const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
562 myDefaultViewPoint.SetCoord (theX, theY, theZ);
563 myDefaultViewAxis.SetCoord (theVx, theVy, theVz);
566 //=============================================================================
567 //function : SetShadingModel
569 //=============================================================================
570 void V3d_View::SetShadingModel (const Graphic3d_TypeOfShadingModel theShadingModel)
572 myView->SetShadingModel (theShadingModel);
575 //=============================================================================
576 //function : SetTextureEnv
578 //=============================================================================
579 void V3d_View::SetTextureEnv (const Handle(Graphic3d_TextureEnv)& theTexture)
581 myView->SetTextureEnv (theTexture);
583 if (myImmediateUpdate)
589 //=============================================================================
590 //function : SetVisualization
592 //=============================================================================
593 void V3d_View::SetVisualization (const V3d_TypeOfVisualization theType)
595 myView->SetVisualizationType (static_cast <Graphic3d_TypeOfVisualization> (theType));
597 if (myImmediateUpdate)
603 //=============================================================================
604 //function : SetFront
606 //=============================================================================
607 void V3d_View::SetFront()
609 gp_Ax3 a = MyViewer->PrivilegedPlane();
610 Standard_Real xo, yo, zo, vx, vy, vz, xu, yu, zu;
612 a.Direction().Coord(vx,vy,vz);
613 a.YDirection().Coord(xu,yu,zu);
614 a.Location().Coord(xo,yo,zo);
616 Handle(Graphic3d_Camera) aCamera = Camera();
618 aCamera->SetCenter (gp_Pnt (xo, yo, zo));
622 aCamera->SetDirection (gp_Dir (vx, vy, vz));
626 aCamera->SetDirection (gp_Dir (vx, vy, vz).Reversed());
629 aCamera->SetUp (gp_Dir (xu, yu, zu));
631 SwitchSetFront = !SwitchSetFront;
636 //=============================================================================
639 //=============================================================================
640 void V3d_View::Rotate (const Standard_Real ax,
641 const Standard_Real ay,
642 const Standard_Real az,
643 const Standard_Boolean Start)
645 Standard_Real Ax = ax;
646 Standard_Real Ay = ay;
647 Standard_Real Az = az;
649 if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI;
650 else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI;
651 if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI;
652 else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI;
653 if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI;
654 else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI;
656 Handle(Graphic3d_Camera) aCamera = Camera();
660 myCamStartOpUp = aCamera->Up();
661 myCamStartOpDir = aCamera->Direction();
662 myCamStartOpEye = aCamera->Eye();
663 myCamStartOpCenter = aCamera->Center();
666 aCamera->SetUp (myCamStartOpUp);
667 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
668 aCamera->SetDirectionFromEye (myCamStartOpDir);
670 // rotate camera around 3 initial axes
671 gp_Dir aBackDir = -myCamStartOpDir;
672 gp_Dir aXAxis (myCamStartOpUp.Crossed (aBackDir));
673 gp_Dir aYAxis (aBackDir.Crossed (aXAxis));
674 gp_Dir aZAxis (aXAxis.Crossed (aYAxis));
676 gp_Trsf aRot[3], aTrsf;
677 aRot[0].SetRotation (gp_Ax1 (myCamStartOpCenter, aYAxis), -Ax);
678 aRot[1].SetRotation (gp_Ax1 (myCamStartOpCenter, aXAxis), Ay);
679 aRot[2].SetRotation (gp_Ax1 (myCamStartOpCenter, aZAxis), Az);
680 aTrsf.Multiply (aRot[0]);
681 aTrsf.Multiply (aRot[1]);
682 aTrsf.Multiply (aRot[2]);
684 aCamera->Transform (aTrsf);
689 //=============================================================================
692 //=============================================================================
693 void V3d_View::Rotate(const Standard_Real ax, const Standard_Real ay, const Standard_Real az,
694 const Standard_Real X, const Standard_Real Y, const Standard_Real Z, const Standard_Boolean Start)
697 Standard_Real Ax = ax ;
698 Standard_Real Ay = ay ;
699 Standard_Real Az = az ;
701 if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ;
702 else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ;
703 if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI ;
704 else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI ;
705 if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ;
706 else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ;
708 Handle(Graphic3d_Camera) aCamera = Camera();
712 myGravityReferencePoint.SetCoord (X, Y, Z);
713 myCamStartOpUp = aCamera->Up();
714 myCamStartOpDir = aCamera->Direction();
715 myCamStartOpEye = aCamera->Eye();
716 myCamStartOpCenter = aCamera->Center();
719 const Graphic3d_Vertex& aVref = myGravityReferencePoint;
721 aCamera->SetUp (myCamStartOpUp);
722 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
723 aCamera->SetDirectionFromEye (myCamStartOpDir);
725 // rotate camera around 3 initial axes
726 gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z());
728 gp_Dir aZAxis (aCamera->Direction().Reversed());
729 gp_Dir aYAxis (aCamera->Up());
730 gp_Dir aXAxis (aYAxis.Crossed (aZAxis));
732 gp_Trsf aRot[3], aTrsf;
733 aRot[0].SetRotation (gp_Ax1 (aRCenter, aYAxis), -Ax);
734 aRot[1].SetRotation (gp_Ax1 (aRCenter, aXAxis), Ay);
735 aRot[2].SetRotation (gp_Ax1 (aRCenter, aZAxis), Az);
736 aTrsf.Multiply (aRot[0]);
737 aTrsf.Multiply (aRot[1]);
738 aTrsf.Multiply (aRot[2]);
740 aCamera->Transform (aTrsf);
745 //=============================================================================
748 //=============================================================================
749 void V3d_View::Rotate(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start)
753 Rotate(angle,0.,0.,Start);
756 Rotate(0.,angle,0.,Start);
759 Rotate(0.,0.,angle,Start);
764 //=============================================================================
767 //=============================================================================
768 void V3d_View::Rotate (const V3d_TypeOfAxe theAxe, const Standard_Real theAngle,
769 const Standard_Real theX, const Standard_Real theY, const Standard_Real theZ, const Standard_Boolean theStart)
771 Standard_Real anAngle = theAngle;
773 if (anAngle > 0.0) while (anAngle > DEUXPI) anAngle -= DEUXPI;
774 else if (anAngle < 0.0) while (anAngle < -DEUXPI) anAngle += DEUXPI;
776 Handle(Graphic3d_Camera) aCamera = Camera();
780 myGravityReferencePoint.SetCoord (theX, theY, theZ);
781 myCamStartOpUp = aCamera->Up();
782 myCamStartOpDir = aCamera->Direction();
783 myCamStartOpEye = aCamera->Eye();
784 myCamStartOpCenter = aCamera->Center();
787 case V3d_X: myViewAxis = gp::DX(); break;
788 case V3d_Y: myViewAxis = gp::DY(); break;
789 case V3d_Z: myViewAxis = gp::DZ(); break;
793 const Graphic3d_Vertex& aVref = myGravityReferencePoint;
795 aCamera->SetUp (myCamStartOpUp);
796 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
797 aCamera->SetDirectionFromEye (myCamStartOpDir);
799 // rotate camera around passed axis
801 gp_Pnt aRCenter (aVref.X(), aVref.Y(), aVref.Z());
802 gp_Dir aRAxis ((theAxe == V3d_X) ? 1.0 : 0.0,
803 (theAxe == V3d_Y) ? 1.0 : 0.0,
804 (theAxe == V3d_Z) ? 1.0 : 0.0);
806 aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), anAngle);
808 aCamera->Transform (aRotation);
813 //=============================================================================
816 //=============================================================================
817 void V3d_View::Rotate(const Standard_Real angle, const Standard_Boolean Start)
819 Standard_Real Angle = angle;
821 if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
822 else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
824 Handle(Graphic3d_Camera) aCamera = Camera();
828 myCamStartOpUp = aCamera->Up();
829 myCamStartOpDir = aCamera->Direction();
830 myCamStartOpEye = aCamera->Eye();
831 myCamStartOpCenter = aCamera->Center();
834 aCamera->SetUp (myCamStartOpUp);
835 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
836 aCamera->SetDirectionFromEye (myCamStartOpDir);
839 gp_Pnt aRCenter (myDefaultViewPoint);
840 gp_Dir aRAxis (myDefaultViewAxis);
841 aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
843 aCamera->Transform (aRotation);
848 //=============================================================================
851 //=============================================================================
852 void V3d_View::Turn(const Standard_Real ax, const Standard_Real ay, const Standard_Real az, const Standard_Boolean Start)
854 Standard_Real Ax = ax;
855 Standard_Real Ay = ay;
856 Standard_Real Az = az;
858 if( Ax > 0. ) while ( Ax > DEUXPI ) Ax -= DEUXPI ;
859 else if( Ax < 0. ) while ( Ax < -DEUXPI ) Ax += DEUXPI ;
860 if( Ay > 0. ) while ( Ay > DEUXPI ) Ay -= DEUXPI ;
861 else if( Ay < 0. ) while ( Ay < -DEUXPI ) Ay += DEUXPI ;
862 if( Az > 0. ) while ( Az > DEUXPI ) Az -= DEUXPI ;
863 else if( Az < 0. ) while ( Az < -DEUXPI ) Az += DEUXPI ;
865 Handle(Graphic3d_Camera) aCamera = Camera();
869 myCamStartOpUp = aCamera->Up();
870 myCamStartOpDir = aCamera->Direction();
871 myCamStartOpEye = aCamera->Eye();
872 myCamStartOpCenter = aCamera->Center();
875 aCamera->SetUp (myCamStartOpUp);
876 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
877 aCamera->SetDirectionFromEye (myCamStartOpDir);
879 // rotate camera around 3 initial axes
880 gp_Pnt aRCenter = aCamera->Eye();
881 gp_Dir aZAxis (aCamera->Direction().Reversed());
882 gp_Dir aYAxis (aCamera->Up());
883 gp_Dir aXAxis (aYAxis.Crossed (aZAxis));
885 gp_Trsf aRot[3], aTrsf;
886 aRot[0].SetRotation (gp_Ax1 (aRCenter, aYAxis), -Ax);
887 aRot[1].SetRotation (gp_Ax1 (aRCenter, aXAxis), Ay);
888 aRot[2].SetRotation (gp_Ax1 (aRCenter, aZAxis), Az);
889 aTrsf.Multiply (aRot[0]);
890 aTrsf.Multiply (aRot[1]);
891 aTrsf.Multiply (aRot[2]);
893 aCamera->Transform (aTrsf);
898 //=============================================================================
901 //=============================================================================
902 void V3d_View::Turn(const V3d_TypeOfAxe Axe, const Standard_Real angle, const Standard_Boolean Start)
906 Turn(angle,0.,0.,Start);
909 Turn(0.,angle,0.,Start);
912 Turn(0.,0.,angle,Start);
917 //=============================================================================
920 //=============================================================================
921 void V3d_View::Turn(const Standard_Real angle, const Standard_Boolean Start)
923 Standard_Real Angle = angle ;
925 if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
926 else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
928 Handle(Graphic3d_Camera) aCamera = Camera();
932 myCamStartOpUp = aCamera->Up();
933 myCamStartOpDir = aCamera->Direction();
934 myCamStartOpEye = aCamera->Eye();
935 myCamStartOpCenter = aCamera->Center();
938 aCamera->SetUp (myCamStartOpUp);
939 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
940 aCamera->SetDirectionFromEye (myCamStartOpDir);
943 gp_Pnt aRCenter = aCamera->Eye();
944 gp_Dir aRAxis (myDefaultViewAxis);
945 aRotation.SetRotation (gp_Ax1 (aRCenter, aRAxis), Angle);
947 aCamera->Transform (aRotation);
952 //=============================================================================
953 //function : SetTwist
955 //=============================================================================
956 void V3d_View::SetTwist(const Standard_Real angle)
958 Standard_Real Angle = angle ;
960 if( Angle > 0. ) while ( Angle > DEUXPI ) Angle -= DEUXPI ;
961 else if( Angle < 0. ) while ( Angle < -DEUXPI ) Angle += DEUXPI ;
963 Handle(Graphic3d_Camera) aCamera = Camera();
965 const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
966 if (!screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
967 && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
968 && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
970 throw V3d_BadValue ("V3d_ViewSetTwist, alignment of Eye,At,Up,");
973 gp_Pnt aRCenter = aCamera->Center();
974 gp_Dir aZAxis (aCamera->Direction().Reversed());
977 aTrsf.SetRotation (gp_Ax1 (aRCenter, aZAxis), Angle);
979 aCamera->SetUp (gp_Dir (myYscreenAxis));
980 aCamera->Transform (aTrsf);
985 //=============================================================================
988 //=============================================================================
989 void V3d_View::SetEye(const Standard_Real X,const Standard_Real Y,const Standard_Real Z)
991 Standard_Real aTwistBefore = Twist();
993 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
995 Handle(Graphic3d_Camera) aCamera = Camera();
997 aCamera->SetEye (gp_Pnt (X, Y, Z));
999 SetTwist (aTwistBefore);
1001 SetImmediateUpdate (wasUpdateEnabled);
1006 //=============================================================================
1007 //function : SetDepth
1009 //=============================================================================
1010 void V3d_View::SetDepth(const Standard_Real Depth)
1012 V3d_BadValue_Raise_if (Depth == 0. ,"V3d_View::SetDepth, bad depth");
1014 Handle(Graphic3d_Camera) aCamera = Camera();
1018 // Move eye using center (target) as anchor.
1019 aCamera->SetDistance (Depth);
1023 // Move the view ref point instead of the eye.
1024 gp_Vec aDir (aCamera->Direction());
1025 gp_Pnt aCameraEye = aCamera->Eye();
1026 gp_Pnt aCameraCenter = aCameraEye.Translated (aDir.Multiplied (Abs (Depth)));
1028 aCamera->SetCenter (aCameraCenter);
1034 //=============================================================================
1035 //function : SetProj
1037 //=============================================================================
1038 void V3d_View::SetProj( const Standard_Real Vx,const Standard_Real Vy, const Standard_Real Vz )
1040 V3d_BadValue_Raise_if( Sqrt(Vx*Vx + Vy*Vy + Vz*Vz) <= 0.,
1041 "V3d_View::SetProj, null projection vector");
1043 Standard_Real aTwistBefore = Twist();
1045 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
1047 Camera()->SetDirection (gp_Dir (Vx, Vy, Vz).Reversed());
1049 SetTwist(aTwistBefore);
1051 SetImmediateUpdate (wasUpdateEnabled);
1056 //=============================================================================
1057 //function : SetProj
1059 //=============================================================================
1060 void V3d_View::SetProj (const V3d_TypeOfOrientation theOrientation,
1061 const Standard_Boolean theIsYup)
1063 Graphic3d_Vec3d anUp = theIsYup ? Graphic3d_Vec3d (0.0, 1.0, 0.0) : Graphic3d_Vec3d (0.0, 0.0, 1.0);
1066 if (theOrientation == V3d_Ypos
1067 || theOrientation == V3d_Yneg)
1069 anUp.SetValues (0.0, 0.0, -1.0);
1074 if (theOrientation == V3d_Zpos)
1076 anUp.SetValues (0.0, 1.0, 0.0);
1078 else if (theOrientation == V3d_Zneg)
1080 anUp.SetValues (0.0, -1.0, 0.0);
1084 const gp_Dir aBck = V3d::GetProjAxis (theOrientation);
1086 // retain camera panning from origin when switching projection
1087 const Handle(Graphic3d_Camera)& aCamera = Camera();
1088 const gp_Pnt anOriginVCS = aCamera->ConvertWorld2View (gp::Origin());
1090 const Standard_Real aNewDist = aCamera->Eye().Distance (gp_Pnt (0, 0, 0));
1091 aCamera->SetEyeAndCenter (gp_XYZ (0, 0, 0) + aBck.XYZ() * aNewDist,
1093 aCamera->SetDirectionFromEye (-aBck);
1094 aCamera->SetUp (gp_Dir (anUp.x(), anUp.y(), anUp.z()));
1095 aCamera->OrthogonalizeUp();
1097 Panning (anOriginVCS.X(), anOriginVCS.Y());
1102 //=============================================================================
1105 //=============================================================================
1106 void V3d_View::SetAt(const Standard_Real X,const Standard_Real Y,const Standard_Real Z)
1108 Standard_Real aTwistBefore = Twist();
1110 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
1112 Camera()->SetCenter (gp_Pnt (X, Y, Z));
1114 SetTwist (aTwistBefore);
1116 SetImmediateUpdate (wasUpdateEnabled);
1121 //=============================================================================
1124 //=============================================================================
1125 void V3d_View::SetUp (const Standard_Real theVx, const Standard_Real theVy, const Standard_Real theVz)
1127 Handle(Graphic3d_Camera) aCamera = Camera();
1129 const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
1130 const gp_Dir anUp (theVx, theVy, theVz);
1131 if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis)
1132 && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
1133 && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
1134 && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
1136 throw V3d_BadValue ("V3d_View::Setup, alignment of Eye,At,Up");
1139 aCamera->SetUp (gp_Dir (myYscreenAxis));
1144 //=============================================================================
1147 //=============================================================================
1148 void V3d_View::SetUp (const V3d_TypeOfOrientation theOrientation)
1150 Handle(Graphic3d_Camera) aCamera = Camera();
1152 const gp_Dir aReferencePlane (aCamera->Direction().Reversed());
1153 const gp_Dir anUp = V3d::GetProjAxis (theOrientation);
1154 if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis)
1155 && !screenAxis (aReferencePlane, gp::DZ(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
1156 && !screenAxis (aReferencePlane, gp::DY(), myXscreenAxis, myYscreenAxis, myZscreenAxis)
1157 && !screenAxis (aReferencePlane, gp::DX(), myXscreenAxis, myYscreenAxis, myZscreenAxis))
1159 throw V3d_BadValue ("V3d_View::SetUp, alignment of Eye,At,Up");
1162 aCamera->SetUp (gp_Dir (myYscreenAxis));
1167 //=============================================================================
1168 //function : SetViewOrientationDefault
1170 //=============================================================================
1171 void V3d_View::SetViewOrientationDefault()
1173 myDefaultCamera->CopyOrientationData (Camera());
1176 //=======================================================================
1177 //function : SetViewMappingDefault
1179 //=======================================================================
1180 void V3d_View::SetViewMappingDefault()
1182 myDefaultCamera->CopyMappingData (Camera());
1185 //=============================================================================
1186 //function : ResetViewOrientation
1188 //=============================================================================
1189 void V3d_View::ResetViewOrientation()
1191 Camera()->CopyOrientationData (myDefaultCamera);
1195 //=======================================================================
1196 //function : ResetViewMapping
1198 //=======================================================================
1199 void V3d_View::ResetViewMapping()
1201 Camera()->CopyMappingData (myDefaultCamera);
1205 //=============================================================================
1208 //=============================================================================
1209 void V3d_View::Reset (const Standard_Boolean theToUpdate)
1211 Camera()->Copy (myDefaultCamera);
1213 SwitchSetFront = Standard_False;
1215 if (myImmediateUpdate || theToUpdate)
1221 //=======================================================================
1222 //function : SetCenter
1224 //=======================================================================
1225 void V3d_View::SetCenter (const Standard_Integer theXp,
1226 const Standard_Integer theYp)
1228 Standard_Real aXv, aYv;
1229 Convert (theXp, theYp, aXv, aYv);
1230 Translate (Camera(), aXv, aYv);
1235 //=============================================================================
1236 //function : SetSize
1238 //=============================================================================
1239 void V3d_View::SetSize (const Standard_Real theSize)
1241 V3d_BadValue_Raise_if (theSize <= 0.0, "V3d_View::SetSize, Window Size is NULL");
1243 Handle(Graphic3d_Camera) aCamera = Camera();
1245 aCamera->SetScale (aCamera->Aspect() >= 1.0 ? theSize / aCamera->Aspect() : theSize);
1250 //=============================================================================
1251 //function : SetZSize
1253 //=============================================================================
1254 void V3d_View::SetZSize (const Standard_Real theSize)
1256 Handle(Graphic3d_Camera) aCamera = Camera();
1258 Standard_Real Zmax = theSize / 2.;
1260 Standard_Real aDistance = aCamera->Distance();
1267 // ShortReal precision factor used to add meaningful tolerance to
1268 // ZNear, ZFar values in order to avoid equality after type conversion
1269 // to ShortReal matrices type.
1270 const Standard_Real aPrecision = 1.0 / Pow (10.0, ShortRealDigits() - 1);
1272 Standard_Real aZFar = Zmax + aDistance * 2.0;
1273 Standard_Real aZNear = -Zmax + aDistance;
1274 aZNear -= Abs (aZNear) * aPrecision;
1275 aZFar += Abs (aZFar) * aPrecision;
1277 if (!aCamera->IsOrthographic())
1279 if (aZFar < aPrecision)
1281 // Invalid case when both values are negative
1282 aZNear = aPrecision;
1283 aZFar = aPrecision * 2.0;
1285 else if (aZNear < Abs (aZFar) * aPrecision)
1287 // Z is less than 0.0, try to fix it using any appropriate z-scale
1288 aZNear = Abs (aZFar) * aPrecision;
1292 // If range is too small
1293 if (aZFar < (aZNear + Abs (aZFar) * aPrecision))
1295 aZFar = aZNear + Abs (aZFar) * aPrecision;
1298 aCamera->SetZRange (aZNear, aZFar);
1300 if (myImmediateUpdate)
1306 //=============================================================================
1307 //function : SetZoom
1309 //=============================================================================
1310 void V3d_View::SetZoom (const Standard_Real theCoef,const Standard_Boolean theToStart)
1312 V3d_BadValue_Raise_if (theCoef <= 0., "V3d_View::SetZoom, bad coefficient");
1314 Handle(Graphic3d_Camera) aCamera = Camera();
1318 myCamStartOpEye = aCamera->Eye();
1319 myCamStartOpCenter = aCamera->Center();
1322 Standard_Real aViewWidth = aCamera->ViewDimensions().X();
1323 Standard_Real aViewHeight = aCamera->ViewDimensions().Y();
1325 // ensure that zoom will not be too small or too big
1326 Standard_Real aCoef = theCoef;
1327 if (aViewWidth < aCoef * Precision::Confusion())
1329 aCoef = aViewWidth / Precision::Confusion();
1331 else if (aViewWidth > aCoef * 1e12)
1333 aCoef = aViewWidth / 1e12;
1335 if (aViewHeight < aCoef * Precision::Confusion())
1337 aCoef = aViewHeight / Precision::Confusion();
1339 else if (aViewHeight > aCoef * 1e12)
1341 aCoef = aViewHeight / 1e12;
1344 aCamera->SetEye (myCamStartOpEye);
1345 aCamera->SetCenter (myCamStartOpCenter);
1346 aCamera->SetScale (aCamera->Scale() / aCoef);
1351 //=============================================================================
1352 //function : SetScale
1354 //=============================================================================
1355 void V3d_View::SetScale( const Standard_Real Coef )
1357 V3d_BadValue_Raise_if( Coef <= 0. ,"V3d_View::SetScale, bad coefficient");
1359 Handle(Graphic3d_Camera) aCamera = Camera();
1361 Standard_Real aDefaultScale = myDefaultCamera->Scale();
1362 aCamera->SetAspect (myDefaultCamera->Aspect());
1363 aCamera->SetScale (aDefaultScale / Coef);
1368 //=============================================================================
1369 //function : SetAxialScale
1371 //=============================================================================
1372 void V3d_View::SetAxialScale( const Standard_Real Sx, const Standard_Real Sy, const Standard_Real Sz )
1374 V3d_BadValue_Raise_if( Sx <= 0. || Sy <= 0. || Sz <= 0.,"V3d_View::SetAxialScale, bad coefficient");
1376 Camera()->SetAxialScale (gp_XYZ (Sx, Sy, Sz));
1379 //=============================================================================
1380 //function : SetRatio
1382 //=============================================================================
1383 void V3d_View::SetRatio()
1385 if (MyWindow.IsNull())
1390 Standard_Integer aWidth = 0;
1391 Standard_Integer aHeight = 0;
1392 MyWindow->Size (aWidth, aHeight);
1393 if (aWidth > 0 && aHeight > 0)
1395 Standard_Real aRatio = static_cast<Standard_Real> (aWidth) /
1396 static_cast<Standard_Real> (aHeight);
1398 Camera() ->SetAspect (aRatio);
1399 myDefaultCamera->SetAspect (aRatio);
1403 //=============================================================================
1406 //=============================================================================
1407 void V3d_View::FitAll (const Standard_Real theMargin, const Standard_Boolean theToUpdate)
1409 FitAll (myView->MinMaxValues(), theMargin, theToUpdate);
1412 //=============================================================================
1415 //=============================================================================
1416 void V3d_View::FitAll (const Bnd_Box& theBox, const Standard_Real theMargin, const Standard_Boolean theToUpdate)
1418 Standard_ASSERT_RAISE(theMargin >= 0.0 && theMargin < 1.0, "Invalid margin coefficient");
1420 if (myView->NumberOfDisplayedStructures() == 0)
1425 if (!FitMinMax (Camera(), theBox, theMargin, 10.0 * Precision::Confusion()))
1430 if (myImmediateUpdate || theToUpdate)
1436 //=============================================================================
1437 //function : DepthFitAll
1439 //=============================================================================
1440 void V3d_View::DepthFitAll(const Standard_Real Aspect,
1441 const Standard_Real Margin)
1443 Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax,U,V,W,U1,V1,W1 ;
1444 Standard_Real Umin,Vmin,Wmin,Umax,Vmax,Wmax ;
1445 Standard_Real Dx,Dy,Dz,Size;
1447 Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ;
1449 if((Nstruct <= 0) || (Aspect < 0.) || (Margin < 0.) || (Margin > 1.)) {
1454 Bnd_Box aBox = myView->MinMaxValues();
1460 aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
1461 Project (Xmin,Ymin,Zmin,U,V,W) ;
1462 Project (Xmax,Ymax,Zmax,U1,V1,W1) ;
1463 Umin = Min(U,U1) ; Umax = Max(U,U1) ;
1464 Vmin = Min(V,V1) ; Vmax = Max(V,V1) ;
1465 Wmin = Min(W,W1) ; Wmax = Max(W,W1) ;
1466 Project (Xmin,Ymin,Zmax,U,V,W) ;
1467 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1468 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1469 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1470 Project (Xmax,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,Zmin,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,Ymax,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 (Xmin,Ymax,Zmax,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,Zmin,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) ;
1492 Wmax = Max(Abs(Wmin),Abs(Wmax)) ;
1493 Dz = 2.*Wmax + Margin * Wmax;
1495 // Compute depth value
1496 Dx = Abs(Umax - Umin) ; Dy = Abs(Vmax - Vmin) ; // Dz = Abs(Wmax - Wmin);
1497 Dx += Margin * Dx; Dy += Margin * Dy;
1498 Size = Sqrt(Dx*Dx + Dy*Dy + Dz*Dz);
1501 SetDepth( Aspect * Size / 2.);
1507 //=======================================================================
1508 //function : WindowFit
1510 //=======================================================================
1511 void V3d_View::WindowFit (const Standard_Integer theMinXp,
1512 const Standard_Integer theMinYp,
1513 const Standard_Integer theMaxXp,
1514 const Standard_Integer theMaxYp)
1516 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
1518 Handle(Graphic3d_Camera) aCamera = Camera();
1520 if (!aCamera->IsOrthographic())
1522 // normalize view coordinates
1523 Standard_Integer aWinWidth, aWinHeight;
1524 MyWindow->Size (aWinWidth, aWinHeight);
1526 // z coordinate of camera center
1527 Standard_Real aDepth = aCamera->Project (aCamera->Center()).Z();
1529 // camera projection coordinate are in NDC which are normalized [-1, 1]
1530 Standard_Real aUMin = (2.0 / aWinWidth) * theMinXp - 1.0;
1531 Standard_Real aUMax = (2.0 / aWinWidth) * theMaxXp - 1.0;
1532 Standard_Real aVMin = (2.0 / aWinHeight) * theMinYp - 1.0;
1533 Standard_Real aVMax = (2.0 / aWinHeight) * theMaxYp - 1.0;
1535 // compute camera panning
1536 gp_Pnt aScreenCenter (0.0, 0.0, aDepth);
1537 gp_Pnt aFitCenter ((aUMin + aUMax) * 0.5, (aVMin + aVMax) * 0.5, aDepth);
1538 gp_Pnt aPanTo = aCamera->ConvertProj2View (aFitCenter);
1539 gp_Pnt aPanFrom = aCamera->ConvertProj2View (aScreenCenter);
1540 gp_Vec aPanVec (aPanFrom, aPanTo);
1542 // compute section size
1543 gp_Pnt aFitTopRight (aUMax, aVMax, aDepth);
1544 gp_Pnt aFitBotLeft (aUMin, aVMin, aDepth);
1545 gp_Pnt aViewBotLeft = aCamera->ConvertProj2View (aFitBotLeft);
1546 gp_Pnt aViewTopRight = aCamera->ConvertProj2View (aFitTopRight);
1548 Standard_Real aUSize = aViewTopRight.X() - aViewBotLeft.X();
1549 Standard_Real aVSize = aViewTopRight.Y() - aViewBotLeft.Y();
1551 Translate (aCamera, aPanVec.X(), -aPanVec.Y());
1552 Scale (aCamera, aUSize, aVSize);
1556 Standard_Real aX1, aY1, aX2, aY2;
1557 Convert (theMinXp, theMinYp, aX1, aY1);
1558 Convert (theMaxXp, theMaxYp, aX2, aY2);
1559 FitAll (aX1, aY1, aX2, aY2);
1562 SetImmediateUpdate (wasUpdateEnabled);
1567 //=======================================================================
1568 //function : ConvertToGrid
1570 //=======================================================================
1571 void V3d_View::ConvertToGrid(const Standard_Integer theXp,
1572 const Standard_Integer theYp,
1573 Standard_Real& theXg,
1574 Standard_Real& theYg,
1575 Standard_Real& theZg) const
1577 Graphic3d_Vec3d anXYZ;
1578 Convert (theXp, theYp, anXYZ.x(), anXYZ.y(), anXYZ.z());
1580 Graphic3d_Vertex aVrp;
1581 aVrp.SetCoord (anXYZ.x(), anXYZ.y(), anXYZ.z());
1582 if (MyViewer->IsGridActive())
1584 Graphic3d_Vertex aNewVrp = Compute (aVrp);
1585 aNewVrp.Coord (theXg, theYg, theZg);
1589 aVrp.Coord (theXg, theYg, theZg);
1593 //=======================================================================
1594 //function : ConvertToGrid
1596 //=======================================================================
1597 void V3d_View::ConvertToGrid(const Standard_Real theX,
1598 const Standard_Real theY,
1599 const Standard_Real theZ,
1600 Standard_Real& theXg,
1601 Standard_Real& theYg,
1602 Standard_Real& theZg) const
1604 if (MyViewer->IsGridActive())
1606 Graphic3d_Vertex aVrp (theX, theY, theZ);
1607 Graphic3d_Vertex aNewVrp = Compute (aVrp);
1608 aNewVrp.Coord (theXg, theYg, theZg);
1612 theXg = theX; theYg = theY; theZg = theZ;
1616 //=======================================================================
1617 //function : Convert
1619 //=======================================================================
1620 Standard_Real V3d_View::Convert(const Standard_Integer Vp) const
1622 Standard_Integer aDxw, aDyw ;
1624 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1626 MyWindow->Size (aDxw, aDyw);
1627 Standard_Real aValue;
1629 gp_Pnt aViewDims = Camera()->ViewDimensions();
1630 aValue = aViewDims.X() * (Standard_Real)Vp / (Standard_Real)aDxw;
1635 //=======================================================================
1636 //function : Convert
1638 //=======================================================================
1639 void V3d_View::Convert(const Standard_Integer Xp,
1640 const Standard_Integer Yp,
1642 Standard_Real& Yv) const
1644 Standard_Integer aDxw, aDyw;
1646 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1648 MyWindow->Size (aDxw, aDyw);
1650 gp_Pnt aPoint (Xp * 2.0 / aDxw - 1.0, (aDyw - Yp) * 2.0 / aDyw - 1.0, 0.0);
1651 aPoint = Camera()->ConvertProj2View (aPoint);
1657 //=======================================================================
1658 //function : Convert
1660 //=======================================================================
1661 Standard_Integer V3d_View::Convert(const Standard_Real Vv) const
1663 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1665 Standard_Integer aDxw, aDyw;
1666 MyWindow->Size (aDxw, aDyw);
1668 gp_Pnt aViewDims = Camera()->ViewDimensions();
1669 Standard_Integer aValue = RealToInt (aDxw * Vv / (aViewDims.X()));
1674 //=======================================================================
1675 //function : Convert
1677 //=======================================================================
1678 void V3d_View::Convert(const Standard_Real Xv,
1679 const Standard_Real Yv,
1680 Standard_Integer& Xp,
1681 Standard_Integer& Yp) const
1683 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1685 Standard_Integer aDxw, aDyw;
1686 MyWindow->Size (aDxw, aDyw);
1688 gp_Pnt aPoint (Xv, Yv, 0.0);
1689 aPoint = Camera()->ConvertView2Proj (aPoint);
1690 aPoint = gp_Pnt ((aPoint.X() + 1.0) * aDxw / 2.0, aDyw - (aPoint.Y() + 1.0) * aDyw / 2.0, 0.0);
1692 Xp = RealToInt (aPoint.X());
1693 Yp = RealToInt (aPoint.Y());
1696 //=======================================================================
1697 //function : Convert
1699 //=======================================================================
1700 void V3d_View::Convert(const Standard_Integer theXp,
1701 const Standard_Integer theYp,
1702 Standard_Real& theX,
1703 Standard_Real& theY,
1704 Standard_Real& theZ) const
1706 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1707 Standard_Integer aHeight = 0, aWidth = 0;
1708 MyWindow->Size (aWidth, aHeight);
1710 const gp_Pnt anXYZ (2.0 * theXp / aWidth - 1.0,
1711 2.0 * (aHeight - 1 - theYp) / aHeight - 1.0,
1712 Camera()->IsZeroToOneDepth() ? 0.0 : -1.0);
1713 const gp_Pnt aResult = Camera()->UnProject (anXYZ);
1719 //=======================================================================
1720 //function : ConvertWithProj
1722 //=======================================================================
1723 void V3d_View::ConvertWithProj(const Standard_Integer theXp,
1724 const Standard_Integer theYp,
1725 Standard_Real& theX,
1726 Standard_Real& theY,
1727 Standard_Real& theZ,
1728 Standard_Real& theDx,
1729 Standard_Real& theDy,
1730 Standard_Real& theDz) const
1732 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1733 Standard_Integer aHeight = 0, aWidth = 0;
1734 MyWindow->Size (aWidth, aHeight);
1736 const Standard_Real anX = 2.0 * theXp / aWidth - 1.0;
1737 const Standard_Real anY = 2.0 * (aHeight - 1 - theYp) / aHeight - 1.0;
1738 const Standard_Real aZ = 2.0 * 0.0 - 1.0;
1740 const Handle(Graphic3d_Camera)& aCamera = Camera();
1741 const gp_Pnt aResult1 = aCamera->UnProject (gp_Pnt (anX, anY, aZ));
1742 const gp_Pnt aResult2 = aCamera->UnProject (gp_Pnt (anX, anY, aZ - 10.0));
1744 theX = aResult1.X();
1745 theY = aResult1.Y();
1746 theZ = aResult1.Z();
1747 Graphic3d_Vec3d aNormDir (theX - aResult2.X(),
1748 theY - aResult2.Y(),
1749 theZ - aResult2.Z());
1750 aNormDir.Normalize();
1752 theDx = aNormDir.x();
1753 theDy = aNormDir.y();
1754 theDz = aNormDir.z();
1757 //=======================================================================
1758 //function : Convert
1760 //=======================================================================
1761 void V3d_View::Convert(const Standard_Real X,
1762 const Standard_Real Y,
1763 const Standard_Real Z,
1764 Standard_Integer& Xp,
1765 Standard_Integer& Yp) const
1767 V3d_UnMapped_Raise_if (!myView->IsDefined(), "view has no window");
1768 Standard_Integer aHeight, aWidth;
1769 MyWindow->Size (aWidth, aHeight);
1771 gp_Pnt aPoint = Camera()->Project (gp_Pnt (X, Y, Z));
1773 Xp = RealToInt ((aPoint.X() + 1) * 0.5 * aWidth);
1774 Yp = RealToInt (aHeight - 1 - (aPoint.Y() + 1) * 0.5 * aHeight);
1777 //=======================================================================
1778 //function : Project
1780 //=======================================================================
1781 void V3d_View::Project (const Standard_Real theX,
1782 const Standard_Real theY,
1783 const Standard_Real theZ,
1784 Standard_Real& theXp,
1785 Standard_Real& theYp) const
1788 Project (theX, theY, theZ, theXp, theYp, aZp);
1791 //=======================================================================
1792 //function : Project
1794 //=======================================================================
1795 void V3d_View::Project (const Standard_Real theX,
1796 const Standard_Real theY,
1797 const Standard_Real theZ,
1798 Standard_Real& theXp,
1799 Standard_Real& theYp,
1800 Standard_Real& theZp) const
1802 Handle(Graphic3d_Camera) aCamera = Camera();
1804 gp_XYZ aViewSpaceDimensions = aCamera->ViewDimensions();
1805 Standard_Real aXSize = aViewSpaceDimensions.X();
1806 Standard_Real aYSize = aViewSpaceDimensions.Y();
1807 Standard_Real aZSize = aViewSpaceDimensions.Z();
1809 gp_Pnt aPoint = aCamera->Project (gp_Pnt (theX, theY, theZ));
1811 // NDC [-1, 1] --> PROJ [ -size / 2, +size / 2 ]
1812 theXp = aPoint.X() * aXSize * 0.5;
1813 theYp = aPoint.Y() * aYSize * 0.5;
1814 theZp = Camera()->IsZeroToOneDepth()
1815 ? aPoint.Z() * aZSize
1816 : aPoint.Z() * aZSize * 0.5;
1819 //=======================================================================
1820 //function : BackgroundColor
1822 //=======================================================================
1823 void V3d_View::BackgroundColor(const Quantity_TypeOfColor Type,
1826 Standard_Real& V3) const
1828 Quantity_Color C = BackgroundColor() ;
1829 C.Values(V1,V2,V3,Type) ;
1832 //=======================================================================
1833 //function : BackgroundColor
1835 //=======================================================================
1836 Quantity_Color V3d_View::BackgroundColor() const
1838 return myView->Background().Color() ;
1841 //=======================================================================
1842 //function : GradientBackgroundColors
1844 //=======================================================================
1845 void V3d_View::GradientBackgroundColors (Quantity_Color& theColor1, Quantity_Color& theColor2) const
1847 myView->GradientBackground().Colors (theColor1, theColor2);
1850 //=======================================================================
1851 //function : GradientBackground
1853 //=======================================================================
1854 Aspect_GradientBackground V3d_View::GradientBackground() const
1856 return myView->GradientBackground();
1859 //=======================================================================
1862 //=======================================================================
1863 Standard_Real V3d_View::Scale() const
1865 return myDefaultCamera->Scale() / Camera()->Scale();
1868 //=======================================================================
1869 //function : AxialScale
1871 //=======================================================================
1872 void V3d_View::AxialScale(Standard_Real& Sx, Standard_Real& Sy, Standard_Real& Sz) const
1874 gp_Pnt anAxialScale = Camera()->AxialScale();
1875 Sx = anAxialScale.X();
1876 Sy = anAxialScale.Y();
1877 Sz = anAxialScale.Z();
1880 //=======================================================================
1883 //=======================================================================
1884 void V3d_View::Size(Standard_Real& Width, Standard_Real& Height) const
1886 gp_Pnt aViewDims = Camera()->ViewDimensions();
1888 Width = aViewDims.X();
1889 Height = aViewDims.Y();
1892 //=======================================================================
1895 //=======================================================================
1896 Standard_Real V3d_View::ZSize() const
1898 gp_Pnt aViewDims = Camera()->ViewDimensions();
1900 return aViewDims.Z();
1903 //=======================================================================
1906 //=======================================================================
1907 Standard_Integer V3d_View::MinMax(Standard_Real& Umin,
1908 Standard_Real& Vmin,
1909 Standard_Real& Umax,
1910 Standard_Real& Vmax) const
1912 Standard_Real Wmin,Wmax,U,V,W ;
1913 Standard_Real Xmin,Ymin,Zmin,Xmax,Ymax,Zmax ;
1915 Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ;
1918 Bnd_Box aBox = myView->MinMaxValues();
1919 aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
1920 Project (Xmin,Ymin,Zmin,Umin,Vmin,Wmin) ;
1921 Project (Xmax,Ymax,Zmax,Umax,Vmax,Wmax) ;
1922 Project (Xmin,Ymin,Zmax,U,V,W) ;
1923 Umin = Min(U,Umin) ; Umax = Max(U,Umax) ;
1924 Vmin = Min(V,Vmin) ; Vmax = Max(V,Vmax) ;
1925 Wmin = Min(W,Wmin) ; Wmax = Max(W,Wmax) ;
1926 Project (Xmax,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,Zmin,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,Ymax,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 (Xmin,Ymax,Zmax,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,Zmin,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) ;
1950 //=======================================================================
1953 //=======================================================================
1954 Standard_Integer V3d_View::MinMax(Standard_Real& Xmin,
1955 Standard_Real& Ymin,
1956 Standard_Real& Zmin,
1957 Standard_Real& Xmax,
1958 Standard_Real& Ymax,
1959 Standard_Real& Zmax) const
1962 // Standard_Integer Nstruct = (MyView->DisplayedStructures())->Extent() ;
1963 Standard_Integer Nstruct = myView->NumberOfDisplayedStructures() ;
1966 Bnd_Box aBox = myView->MinMaxValues();
1967 aBox.Get (Xmin,Ymin,Zmin,Xmax,Ymax,Zmax);
1972 //=======================================================================
1973 //function : GravityPoint
1975 //=======================================================================
1976 gp_Pnt V3d_View::GravityPoint() const
1978 Graphic3d_MapOfStructure aSetOfStructures;
1979 myView->DisplayedStructures (aSetOfStructures);
1981 Standard_Boolean hasSelection = Standard_False;
1982 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures);
1983 aStructIter.More(); aStructIter.Next())
1985 if (aStructIter.Key()->IsHighlighted()
1986 && aStructIter.Key()->IsVisible())
1988 hasSelection = Standard_True;
1993 Standard_Real Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
1994 Standard_Integer aNbPoints = 0;
1995 gp_XYZ aResult (0.0, 0.0, 0.0);
1996 for (Graphic3d_MapIteratorOfMapOfStructure aStructIter (aSetOfStructures);
1997 aStructIter.More(); aStructIter.Next())
1999 const Handle(Graphic3d_Structure)& aStruct = aStructIter.Key();
2000 if (!aStruct->IsVisible()
2001 || aStruct->IsInfinite()
2002 || (hasSelection && !aStruct->IsHighlighted()))
2007 const Graphic3d_BndBox3d& aBox = aStruct->CStructure()->BoundingBox();
2008 if (!aBox.IsValid())
2013 // skip transformation-persistent objects
2014 if (!aStruct->TransformPersistence().IsNull())
2019 // use camera projection to find gravity point
2020 Xmin = aBox.CornerMin().x();
2021 Ymin = aBox.CornerMin().y();
2022 Zmin = aBox.CornerMin().z();
2023 Xmax = aBox.CornerMax().x();
2024 Ymax = aBox.CornerMax().y();
2025 Zmax = aBox.CornerMax().z();
2026 gp_Pnt aPnts[THE_NB_BOUND_POINTS] =
2028 gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
2029 gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax),
2030 gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax),
2031 gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax)
2034 for (Standard_Integer aPntIt = 0; aPntIt < THE_NB_BOUND_POINTS; ++aPntIt)
2036 const gp_Pnt& aBndPnt = aPnts[aPntIt];
2037 const gp_Pnt aProjected = Camera()->Project (aBndPnt);
2038 if (Abs (aProjected.X()) <= 1.0
2039 && Abs (aProjected.Y()) <= 1.0)
2041 aResult += aBndPnt.XYZ();
2049 // fallback - just use bounding box of entire scene
2050 Bnd_Box aBox = myView->MinMaxValues();
2053 aBox.Get (Xmin, Ymin, Zmin,
2055 gp_Pnt aPnts[THE_NB_BOUND_POINTS] =
2057 gp_Pnt (Xmin, Ymin, Zmin), gp_Pnt (Xmin, Ymin, Zmax),
2058 gp_Pnt (Xmin, Ymax, Zmin), gp_Pnt (Xmin, Ymax, Zmax),
2059 gp_Pnt (Xmax, Ymin, Zmin), gp_Pnt (Xmax, Ymin, Zmax),
2060 gp_Pnt (Xmax, Ymax, Zmin), gp_Pnt (Xmax, Ymax, Zmax)
2063 for (Standard_Integer aPntIt = 0; aPntIt < THE_NB_BOUND_POINTS; ++aPntIt)
2065 const gp_Pnt& aBndPnt = aPnts[aPntIt];
2066 aResult += aBndPnt.XYZ();
2074 aResult /= aNbPoints;
2080 //=======================================================================
2083 //=======================================================================
2084 void V3d_View::Eye(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
2086 gp_Pnt aCameraEye = Camera()->Eye();
2092 //=============================================================================
2093 //function : ProjReferenceAxe
2095 //=============================================================================
2096 void V3d_View::ProjReferenceAxe(const Standard_Integer Xpix,
2097 const Standard_Integer Ypix,
2103 Standard_Real& VZ) const
2105 Standard_Real Xo,Yo,Zo;
2107 Convert (Xpix, Ypix, XP, YP, ZP);
2108 if ( Type() == V3d_PERSPECTIVE )
2110 FocalReferencePoint (Xo,Yo,Zo);
2121 //=============================================================================
2124 //=============================================================================
2125 Standard_Real V3d_View::Depth() const
2127 return Camera()->Distance();
2130 //=============================================================================
2133 //=============================================================================
2134 void V3d_View::Proj(Standard_Real& Dx, Standard_Real& Dy, Standard_Real& Dz) const
2136 gp_Dir aCameraDir = Camera()->Direction().Reversed();
2137 Dx = aCameraDir.X();
2138 Dy = aCameraDir.Y();
2139 Dz = aCameraDir.Z();
2142 //=============================================================================
2145 //=============================================================================
2146 void V3d_View::At(Standard_Real& X, Standard_Real& Y, Standard_Real& Z) const
2148 gp_Pnt aCameraCenter = Camera()->Center();
2149 X = aCameraCenter.X();
2150 Y = aCameraCenter.Y();
2151 Z = aCameraCenter.Z();
2154 //=============================================================================
2157 //=============================================================================
2158 void V3d_View::Up(Standard_Real& Vx, Standard_Real& Vy, Standard_Real& Vz) const
2160 gp_Dir aCameraUp = Camera()->Up();
2166 //=============================================================================
2169 //=============================================================================
2170 Standard_Real V3d_View::Twist() const
2172 gp_Vec Xaxis, Yaxis, Zaxis;
2173 const gp_Dir aReferencePlane (Camera()->Direction().Reversed());
2174 if (!screenAxis (aReferencePlane, gp::DZ(), Xaxis, Yaxis, Zaxis)
2175 && !screenAxis (aReferencePlane, gp::DY(), Xaxis, Yaxis, Zaxis)
2176 && !screenAxis (aReferencePlane, gp::DX(), Xaxis, Yaxis, Zaxis))
2181 // Compute Cross Vector From Up & Origin
2182 const gp_Dir aCameraUp = Camera()->Up();
2183 const gp_XYZ aP = Yaxis.XYZ().Crossed (aCameraUp.XYZ());
2186 Standard_Real anAngle = ASin (Max (Min (aP.Modulus(), 1.0), -1.0));
2187 if (Yaxis.Dot (aCameraUp.XYZ()) < 0.0)
2189 anAngle = M_PI - anAngle;
2194 const gp_Dir aProjDir = Camera()->Direction().Reversed();
2195 if (aP.Dot (aProjDir.XYZ()) < 0.0)
2197 anAngle = DEUXPI - anAngle;
2203 //=============================================================================
2204 //function : ShadingModel
2206 //=============================================================================
2207 Graphic3d_TypeOfShadingModel V3d_View::ShadingModel() const
2209 return myView->ShadingModel();
2212 //=============================================================================
2213 //function : TextureEnv
2215 //=============================================================================
2216 Handle(Graphic3d_TextureEnv) V3d_View::TextureEnv() const
2218 return myView->TextureEnv();
2221 //=============================================================================
2222 //function : Visualization
2224 //=============================================================================
2225 V3d_TypeOfVisualization V3d_View::Visualization() const
2227 return static_cast<V3d_TypeOfVisualization> (myView->VisualizationType());
2230 //=============================================================================
2231 //function : IfWindow
2233 //=============================================================================
2234 Standard_Boolean V3d_View::IfWindow() const
2236 return myView->IsDefined();
2239 //=============================================================================
2242 //=============================================================================
2243 V3d_TypeOfView V3d_View::Type() const
2245 return Camera()->IsOrthographic() ? V3d_ORTHOGRAPHIC : V3d_PERSPECTIVE;
2248 //=============================================================================
2249 //function : SetFocale
2251 //=============================================================================
2252 void V3d_View::SetFocale( const Standard_Real focale )
2254 Handle(Graphic3d_Camera) aCamera = Camera();
2256 if (aCamera->IsOrthographic())
2261 Standard_Real aFOVyRad = ATan (focale / (aCamera->Distance() * 2.0));
2263 aCamera->SetFOVy (aFOVyRad * (360 / M_PI));
2268 //=============================================================================
2271 //=============================================================================
2272 Standard_Real V3d_View::Focale() const
2274 Handle(Graphic3d_Camera) aCamera = Camera();
2276 if (aCamera->IsOrthographic())
2281 return aCamera->Distance() * 2.0 * Tan (aCamera->FOVy() * M_PI / 360.0);
2284 //=============================================================================
2285 //function : screenAxis
2287 //=============================================================================
2288 Standard_Boolean V3d_View::screenAxis (const gp_Dir& theVpn, const gp_Dir& theVup,
2289 gp_Vec& theXaxe, gp_Vec& theYaxe, gp_Vec& theZaxe)
2291 theXaxe = theVup.XYZ().Crossed (theVpn.XYZ());
2292 if (theXaxe.Magnitude() <= gp::Resolution())
2294 return Standard_False;
2296 theXaxe.Normalize();
2298 theYaxe = theVpn.XYZ().Crossed (theXaxe.XYZ());
2299 if (theYaxe.Magnitude() <= gp::Resolution())
2301 return Standard_False;
2303 theYaxe.Normalize();
2305 theZaxe = theVpn.XYZ();
2306 theZaxe.Normalize();
2307 return Standard_True;
2310 //=============================================================================
2311 //function : TrsPoint
2313 //=============================================================================
2314 gp_XYZ V3d_View::TrsPoint (const Graphic3d_Vertex& thePnt, const TColStd_Array2OfReal& theMat)
2317 const Standard_Integer lr = theMat.LowerRow();
2318 const Standard_Integer ur = theMat.UpperRow();
2319 const Standard_Integer lc = theMat.LowerCol();
2320 const Standard_Integer uc = theMat.UpperCol();
2321 if ((ur - lr + 1 != 4) || (uc - lc + 1 != 4))
2323 return gp_XYZ (thePnt.X(), thePnt.Y(), thePnt.Z());
2326 Standard_Real X, Y, Z;
2327 thePnt.Coord (X,Y,Z);
2328 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);
2329 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);
2330 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);
2331 return gp_XYZ (XX, YY, ZZ);
2334 //=======================================================================
2337 //=======================================================================
2338 void V3d_View::Pan (const Standard_Integer theDXp,
2339 const Standard_Integer theDYp,
2340 const Standard_Real theZoomFactor,
2341 const Standard_Boolean theToStart)
2343 Panning (Convert (theDXp), Convert (theDYp), theZoomFactor, theToStart);
2346 //=======================================================================
2347 //function : Panning
2349 //=======================================================================
2350 void V3d_View::Panning (const Standard_Real theDXv,
2351 const Standard_Real theDYv,
2352 const Standard_Real theZoomFactor,
2353 const Standard_Boolean theToStart)
2355 Standard_ASSERT_RAISE (theZoomFactor > 0.0, "Bad zoom factor");
2357 Handle(Graphic3d_Camera) aCamera = Camera();
2361 myCamStartOpDir = aCamera->Direction();
2362 myCamStartOpEye = aCamera->Eye();
2363 myCamStartOpCenter = aCamera->Center();
2366 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
2368 gp_Pnt aViewDims = aCamera->ViewDimensions();
2370 aCamera->SetEyeAndCenter (myCamStartOpEye, myCamStartOpCenter);
2371 aCamera->SetDirectionFromEye (myCamStartOpDir);
2372 Translate (aCamera, -theDXv, -theDYv);
2373 Scale (aCamera, aViewDims.X() / theZoomFactor, aViewDims.Y() / theZoomFactor);
2375 SetImmediateUpdate (wasUpdateEnabled);
2380 //=======================================================================
2383 //=======================================================================
2384 void V3d_View::Zoom (const Standard_Integer theXp1,
2385 const Standard_Integer theYp1,
2386 const Standard_Integer theXp2,
2387 const Standard_Integer theYp2)
2389 Standard_Integer aDx = theXp2 - theXp1;
2390 Standard_Integer aDy = theYp2 - theYp1;
2391 if (aDx != 0 || aDy != 0)
2393 Standard_Real aCoeff = Sqrt( (Standard_Real)(aDx * aDx + aDy * aDy) ) / 100.0 + 1.0;
2394 aCoeff = (aDx > 0) ? aCoeff : 1.0 / aCoeff;
2395 SetZoom (aCoeff, Standard_True);
2399 //=======================================================================
2400 //function : StartZoomAtPoint
2402 //=======================================================================
2403 void V3d_View::StartZoomAtPoint (const Standard_Integer theXp,
2404 const Standard_Integer theYp)
2406 MyZoomAtPointX = theXp;
2407 MyZoomAtPointY = theYp;
2410 //=======================================================================
2411 //function : ZoomAtPoint
2413 //=======================================================================
2414 void V3d_View::ZoomAtPoint (const Standard_Integer theMouseStartX,
2415 const Standard_Integer theMouseStartY,
2416 const Standard_Integer theMouseEndX,
2417 const Standard_Integer theMouseEndY)
2419 Standard_Boolean wasUpdateEnabled = SetImmediateUpdate (Standard_False);
2422 Standard_Real aDxy = Standard_Real ((theMouseEndX + theMouseEndY) - (theMouseStartX + theMouseStartY));
2423 Standard_Real aDZoom = Abs (aDxy) / 100.0 + 1.0;
2424 aDZoom = (aDxy > 0.0) ? aDZoom : 1.0 / aDZoom;
2426 V3d_BadValue_Raise_if (aDZoom <= 0.0, "V3d_View::ZoomAtPoint, bad coefficient");
2428 Handle(Graphic3d_Camera) aCamera = Camera();
2430 Standard_Real aViewWidth = aCamera->ViewDimensions().X();
2431 Standard_Real aViewHeight = aCamera->ViewDimensions().Y();
2433 // ensure that zoom will not be too small or too big.
2434 Standard_Real aCoef = aDZoom;
2435 if (aViewWidth < aCoef * Precision::Confusion())
2437 aCoef = aViewWidth / Precision::Confusion();
2439 else if (aViewWidth > aCoef * 1e12)
2441 aCoef = aViewWidth / 1e12;
2443 if (aViewHeight < aCoef * Precision::Confusion())
2445 aCoef = aViewHeight / Precision::Confusion();
2447 else if (aViewHeight > aCoef * 1e12)
2449 aCoef = aViewHeight / 1e12;
2452 Standard_Real aZoomAtPointXv = 0.0;
2453 Standard_Real aZoomAtPointYv = 0.0;
2454 Convert (MyZoomAtPointX, MyZoomAtPointY, aZoomAtPointXv, aZoomAtPointYv);
2456 Standard_Real aDxv = aZoomAtPointXv / aCoef;
2457 Standard_Real aDyv = aZoomAtPointYv / aCoef;
2459 aCamera->SetScale (aCamera->Scale() / aCoef);
2460 Translate (aCamera, aZoomAtPointXv - aDxv, aZoomAtPointYv - aDyv);
2462 SetImmediateUpdate (wasUpdateEnabled);
2467 //=============================================================================
2468 //function : AxialScale
2470 //=============================================================================
2471 void V3d_View::AxialScale (const Standard_Integer Dx,
2472 const Standard_Integer Dy,
2473 const V3d_TypeOfAxe Axis)
2475 if( Dx != 0. || Dy != 0. ) {
2476 Standard_Real Sx, Sy, Sz;
2477 AxialScale( Sx, Sy, Sz );
2478 Standard_Real dscale = Sqrt(Dx*Dx + Dy*Dy) / 100. + 1;
2479 dscale = (Dx > 0) ? dscale : 1./dscale;
2480 if( Axis == V3d_X ) Sx = dscale;
2481 if( Axis == V3d_Y ) Sy = dscale;
2482 if( Axis == V3d_Z ) Sz = dscale;
2483 SetAxialScale( Sx, Sy, Sz );
2487 //=============================================================================
2490 //=============================================================================
2491 void V3d_View::FitAll(const Standard_Real theXmin,
2492 const Standard_Real theYmin,
2493 const Standard_Real theXmax,
2494 const Standard_Real theYmax)
2496 Handle(Graphic3d_Camera) aCamera = Camera();
2497 Standard_Real anAspect = aCamera->Aspect();
2499 Standard_Real aFitSizeU = Abs (theXmax - theXmin);
2500 Standard_Real aFitSizeV = Abs (theYmax - theYmin);
2501 Standard_Real aFitAspect = aFitSizeU / aFitSizeV;
2502 if (aFitAspect >= anAspect)
2504 aFitSizeV = aFitSizeU / anAspect;
2508 aFitSizeU = aFitSizeV * anAspect;
2511 Translate (aCamera, (theXmin + theXmax) * 0.5, (theYmin + theYmax) * 0.5);
2512 Scale (aCamera, aFitSizeU, aFitSizeV);
2517 //=============================================================================
2518 //function : StartRotation
2520 //=============================================================================
2521 void V3d_View::StartRotation(const Standard_Integer X,
2522 const Standard_Integer Y,
2523 const Standard_Real zRotationThreshold)
2528 rx = Standard_Real(Convert(x));
2529 ry = Standard_Real(Convert(y));
2530 myRotateGravity = GravityPoint();
2531 Rotate (0.0, 0.0, 0.0,
2532 myRotateGravity.X(), myRotateGravity.Y(), myRotateGravity.Z(),
2534 myZRotation = Standard_False;
2535 if( zRotationThreshold > 0. ) {
2536 Standard_Real dx = Abs(sx - rx/2.);
2537 Standard_Real dy = Abs(sy - ry/2.);
2538 // if( dx > rx/3. || dy > ry/3. ) myZRotation = Standard_True;
2539 Standard_Real dd = zRotationThreshold * (rx + ry)/2.;
2540 if( dx > dd || dy > dd ) myZRotation = Standard_True;
2545 //=============================================================================
2546 //function : Rotation
2548 //=============================================================================
2549 void V3d_View::Rotation(const Standard_Integer X,
2550 const Standard_Integer Y)
2552 if( rx == 0. || ry == 0. ) {
2556 Standard_Real dx=0.,dy=0.,dz=0.;
2558 dz = atan2(Standard_Real(X)-rx/2., ry/2.-Standard_Real(Y)) -
2559 atan2(sx-rx/2.,ry/2.-sy);
2561 dx = (Standard_Real(X) - sx) * M_PI / rx;
2562 dy = (sy - Standard_Real(Y)) * M_PI / ry;
2566 myRotateGravity.X(), myRotateGravity.Y(), myRotateGravity.Z(),
2570 //=============================================================================
2571 //function : SetComputedMode
2573 //=============================================================================
2574 void V3d_View::SetComputedMode (const Standard_Boolean theMode)
2580 myView->SetComputedMode (Standard_True);
2585 myView->SetComputedMode (Standard_False);
2589 //=============================================================================
2590 //function : ComputedMode
2592 //=============================================================================
2593 Standard_Boolean V3d_View::ComputedMode() const
2595 return myView->ComputedMode();
2598 //=============================================================================
2599 //function : SetBackFacingModel
2601 //=============================================================================
2602 void V3d_View::SetBackFacingModel (const Graphic3d_TypeOfBackfacingModel theModel)
2604 myView->SetBackfacingModel (theModel);
2608 //=============================================================================
2609 //function : BackFacingModel
2611 //=============================================================================
2612 Graphic3d_TypeOfBackfacingModel V3d_View::BackFacingModel() const
2614 return myView->BackfacingModel();
2617 //=============================================================================
2620 //=============================================================================
2621 void V3d_View::Init()
2623 myComputedMode = MyViewer->ComputedMode();
2624 if (!myComputedMode || !MyViewer->DefaultComputedMode())
2626 SetComputedMode (Standard_False);
2630 //=============================================================================
2633 //=============================================================================
2634 Standard_Boolean V3d_View::Dump (const Standard_CString theFile,
2635 const Graphic3d_BufferType& theBufferType)
2637 Standard_Integer aWinWidth, aWinHeight;
2638 MyWindow->Size (aWinWidth, aWinHeight);
2639 Image_AlienPixMap anImage;
2641 return ToPixMap (anImage, aWinWidth, aWinHeight, theBufferType) && anImage.Save (theFile);
2644 //=============================================================================
2645 //function : ToPixMap
2647 //=============================================================================
2648 Standard_Boolean V3d_View::ToPixMap (Image_PixMap& theImage,
2649 const V3d_ImageDumpOptions& theParams)
2651 Graphic3d_Vec2i aTargetSize (theParams.Width, theParams.Height);
2652 if (aTargetSize.x() != 0
2653 && aTargetSize.y() != 0)
2655 // allocate image buffer for dumping
2656 if (theImage.IsEmpty()
2657 || theImage.SizeX() != Standard_Size(aTargetSize.x())
2658 || theImage.SizeY() != Standard_Size(aTargetSize.y()))
2660 Image_Format aFormat = Image_Format_UNKNOWN;
2661 switch (theParams.BufferType)
2663 case Graphic3d_BT_RGB: aFormat = Image_Format_RGB; break;
2664 case Graphic3d_BT_RGBA: aFormat = Image_Format_RGBA; break;
2665 case Graphic3d_BT_Depth: aFormat = Image_Format_GrayF; break;
2666 case Graphic3d_BT_RGB_RayTraceHdrLeft: aFormat = Image_Format_RGBF; break;
2667 case Graphic3d_BT_Red: aFormat = Image_Format_Gray; break;
2670 if (!theImage.InitZero (aFormat, Standard_Size(aTargetSize.x()), Standard_Size(aTargetSize.y())))
2672 Message::SendFail (TCollection_AsciiString ("Fail to allocate an image ") + aTargetSize.x() + "x" + aTargetSize.y() + " for view dump");
2673 return Standard_False;
2677 if (theImage.IsEmpty())
2679 Message::SendFail ("V3d_View::ToPixMap() has been called without image dimensions");
2680 return Standard_False;
2682 aTargetSize.x() = (Standard_Integer )theImage.SizeX();
2683 aTargetSize.y() = (Standard_Integer )theImage.SizeY();
2685 Handle(Standard_Transient) aFBOPtr;
2686 Handle(Standard_Transient) aPrevFBOPtr = myView->FBO();
2687 Graphic3d_Vec2i aFBOVPSize = aTargetSize;
2689 bool isTiling = false;
2690 if (theParams.TileSize > 0)
2692 if (aFBOVPSize.x() > theParams.TileSize
2693 || aFBOVPSize.y() > theParams.TileSize)
2695 aFBOVPSize.x() = Min (aFBOVPSize.x(), theParams.TileSize);
2696 aFBOVPSize.y() = Min (aFBOVPSize.y(), theParams.TileSize);
2701 Graphic3d_Vec2i aPrevFBOVPSize;
2702 if (!aPrevFBOPtr.IsNull())
2704 Graphic3d_Vec2i aPrevFBOSizeMax;
2705 myView->FBOGetDimensions (aPrevFBOPtr,
2706 aPrevFBOVPSize.x(), aPrevFBOVPSize.y(),
2707 aPrevFBOSizeMax.x(), aPrevFBOSizeMax.y());
2708 if (aFBOVPSize.x() <= aPrevFBOSizeMax.x()
2709 && aFBOVPSize.y() <= aPrevFBOSizeMax.y())
2711 aFBOPtr = aPrevFBOPtr;
2715 if (aFBOPtr.IsNull())
2717 Standard_Integer aMaxTexSizeX = MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxViewDumpSizeX);
2718 Standard_Integer aMaxTexSizeY = MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_MaxViewDumpSizeY);
2719 if (theParams.TileSize > aMaxTexSizeX
2720 || theParams.TileSize > aMaxTexSizeY)
2722 Message::SendFail (TCollection_AsciiString ("Image dump can not be performed - specified tile size (")
2723 + theParams.TileSize + ") exceeds hardware limits (" + aMaxTexSizeX + "x" + aMaxTexSizeY + ")");
2724 return Standard_False;
2727 if (aFBOVPSize.x() > aMaxTexSizeX
2728 || aFBOVPSize.y() > aMaxTexSizeY)
2730 if (MyViewer->Driver()->InquireLimit (Graphic3d_TypeOfLimit_IsWorkaroundFBO))
2732 Message::SendWarning ("Warning, workaround for Intel driver problem with empty FBO for images with big width is applied");
2734 Message::SendInfo (TCollection_AsciiString ("Info, tiling image dump is used, image size (")
2735 + aFBOVPSize.x() + "x" + aFBOVPSize.y() + ") exceeds hardware limits (" + aMaxTexSizeX + "x" + aMaxTexSizeY + ")");
2736 aFBOVPSize.x() = Min (aFBOVPSize.x(), aMaxTexSizeX);
2737 aFBOVPSize.y() = Min (aFBOVPSize.y(), aMaxTexSizeY);
2741 // Try to create hardware accelerated buffer
2742 aFBOPtr = myView->FBOCreate (aFBOVPSize.x(), aFBOVPSize.y());
2744 myView->SetFBO (aFBOPtr);
2746 if (aFBOPtr.IsNull())
2748 // try to use on-screen buffer
2749 Graphic3d_Vec2i aWinSize;
2750 MyWindow->Size (aWinSize.x(), aWinSize.y());
2751 if (aFBOVPSize.x() != aWinSize.x()
2752 || aFBOVPSize.y() != aWinSize.y())
2756 aFBOVPSize = aWinSize;
2758 Message::SendWarning ("Warning, on screen buffer is used for image dump - content might be invalid");
2761 // backup camera parameters
2762 Handle(Graphic3d_Camera) aStoreMapping = new Graphic3d_Camera();
2763 Handle(Graphic3d_Camera) aCamera = Camera();
2764 aStoreMapping->Copy (aCamera);
2765 if (aCamera->IsStereo())
2767 switch (theParams.StereoOptions)
2771 aCamera->SetProjectionType (Graphic3d_Camera::Projection_Perspective);
2774 case V3d_SDO_LEFT_EYE:
2776 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoLeftEye);
2779 case V3d_SDO_RIGHT_EYE:
2781 aCamera->SetProjectionType (Graphic3d_Camera::Projection_MonoRightEye);
2784 case V3d_SDO_BLENDED:
2786 break; // dump as is
2790 if (theParams.ToAdjustAspect)
2792 aCamera->SetAspect (Standard_Real(aTargetSize.x()) / Standard_Real(aTargetSize.y()));
2795 // render immediate structures into back buffer rather than front
2796 const Standard_Boolean aPrevImmediateMode = myView->SetImmediateModeDrawToFront (Standard_False);
2798 Standard_Boolean isSuccess = Standard_True;
2801 if (!aFBOPtr.IsNull())
2803 myView->FBOChangeViewport (aFBOPtr, aTargetSize.x(), aTargetSize.y());
2806 isSuccess = isSuccess && myView->BufferDump (theImage, theParams.BufferType);
2810 Image_PixMap aTilePixMap;
2811 aTilePixMap.SetTopDown (theImage.IsTopDown());
2813 Graphic3d_Vec2i anOffset (0, 0);
2814 for (; anOffset.y() < aTargetSize.y(); anOffset.y() += aFBOVPSize.y())
2817 for (; anOffset.x() < aTargetSize.x(); anOffset.x() += aFBOVPSize.x())
2819 Graphic3d_CameraTile aTileUncropped;
2820 aTileUncropped.Offset = anOffset;
2821 aTileUncropped.TotalSize = aTargetSize;
2822 aTileUncropped.TileSize = aFBOVPSize;
2823 const Graphic3d_CameraTile aTile = aTileUncropped.Cropped();
2824 if (aTile.TileSize.x() < 1
2825 || aTile.TileSize.y() < 1)
2830 const Standard_Integer aLeft = aTile.Offset.x();
2831 Standard_Integer aBottom = aTile.Offset.y();
2832 if (theImage.IsTopDown())
2834 const Standard_Integer aTop = aTile.Offset.y() + aTile.TileSize.y();
2835 aBottom = aTargetSize.y() - aTop;
2837 aTilePixMap.InitWrapper (theImage.Format(), theImage.ChangeData()
2838 + theImage.SizeRowBytes() * aBottom + theImage.SizePixelBytes() * aLeft,
2839 aTile.TileSize.x(), aTile.TileSize.y(),
2840 theImage.SizeRowBytes());
2842 if (!aFBOPtr.IsNull())
2844 aCamera->SetTile (aTile);
2845 myView->FBOChangeViewport (aFBOPtr, aTile.TileSize.x(), aTile.TileSize.y());
2849 // no API to resize viewport of on-screen buffer - render uncropped
2850 aCamera->SetTile (aTileUncropped);
2853 isSuccess = isSuccess && myView->BufferDump (aTilePixMap, theParams.BufferType);
2867 myView->SetImmediateModeDrawToFront (aPrevImmediateMode);
2868 aCamera->Copy (aStoreMapping);
2869 if (aFBOPtr != aPrevFBOPtr)
2871 myView->FBORelease (aFBOPtr);
2873 else if (!aPrevFBOPtr.IsNull())
2875 myView->FBOChangeViewport (aPrevFBOPtr, aPrevFBOVPSize.x(), aPrevFBOVPSize.y());
2877 myView->SetFBO (aPrevFBOPtr);
2881 //=============================================================================
2882 //function : ImmediateUpdate
2884 //=============================================================================
2885 void V3d_View::ImmediateUpdate() const
2887 if (myImmediateUpdate)
2893 //=============================================================================
2894 //function : SetImmediateUpdate
2896 //=============================================================================
2897 Standard_Boolean V3d_View::SetImmediateUpdate (const Standard_Boolean theImmediateUpdate)
2899 Standard_Boolean aPreviousMode = myImmediateUpdate;
2900 myImmediateUpdate = theImmediateUpdate;
2901 return aPreviousMode;
2904 // =======================================================================
2905 // function : SetCamera
2907 // =======================================================================
2908 void V3d_View::SetCamera (const Handle(Graphic3d_Camera)& theCamera)
2910 myView->SetCamera (theCamera);
2915 // =======================================================================
2916 // function : GetCamera
2918 // =======================================================================
2919 const Handle(Graphic3d_Camera)& V3d_View::Camera() const
2921 return myView->Camera();
2924 // =======================================================================
2925 // function : FitMinMax
2926 // purpose : Internal
2927 // =======================================================================
2928 Standard_Boolean V3d_View::FitMinMax (const Handle(Graphic3d_Camera)& theCamera,
2929 const Bnd_Box& theBox,
2930 const Standard_Real theMargin,
2931 const Standard_Real theResolution,
2932 const Standard_Boolean theToEnlargeIfLine) const
2934 if (!theCamera->FitMinMax (theBox, theResolution, theToEnlargeIfLine))
2936 return Standard_False; // bounding box is out of bounds...
2939 const Standard_Real aZoomCoef = myView->ConsiderZoomPersistenceObjects();
2940 Scale (theCamera, theCamera->ViewDimensions().X() * (aZoomCoef + theMargin), theCamera->ViewDimensions().Y() * (aZoomCoef + theMargin));
2941 return Standard_True;
2944 // =======================================================================
2946 // purpose : Internal
2947 // =======================================================================
2948 void V3d_View::Scale (const Handle(Graphic3d_Camera)& theCamera,
2949 const Standard_Real theSizeXv,
2950 const Standard_Real theSizeYv) const
2952 Standard_Real anAspect = theCamera->Aspect();
2955 theCamera->SetScale (Max (theSizeXv / anAspect, theSizeYv));
2959 theCamera->SetScale (Max (theSizeXv, theSizeYv * anAspect));
2964 // =======================================================================
2965 // function : Translate
2966 // purpose : Internal
2967 // =======================================================================
2968 void V3d_View::Translate (const Handle(Graphic3d_Camera)& theCamera,
2969 const Standard_Real theDXv,
2970 const Standard_Real theDYv) const
2972 const gp_Pnt& aCenter = theCamera->Center();
2973 const gp_Dir& aDir = theCamera->Direction();
2974 const gp_Dir& anUp = theCamera->Up();
2975 gp_Ax3 aCameraCS (aCenter, aDir.Reversed(), aDir ^ anUp);
2977 gp_Vec aCameraPanXv = gp_Vec (aCameraCS.XDirection()) * theDXv;
2978 gp_Vec aCameraPanYv = gp_Vec (aCameraCS.YDirection()) * theDYv;
2979 gp_Vec aCameraPan = aCameraPanXv + aCameraPanYv;
2981 aPanTrsf.SetTranslation (aCameraPan);
2983 theCamera->Transform (aPanTrsf);
2987 // =======================================================================
2988 // function : DiagnosticInformation
2990 // =======================================================================
2991 void V3d_View::DiagnosticInformation (TColStd_IndexedDataMapOfStringString& theDict,
2992 Graphic3d_DiagnosticInfo theFlags) const
2994 myView->DiagnosticInformation (theDict, theFlags);
2997 //=======================================================================
2998 //function : StatisticInformation
3000 //=======================================================================
3001 void V3d_View::StatisticInformation (TColStd_IndexedDataMapOfStringString& theDict) const
3003 myView->StatisticInformation (theDict);
3006 // =======================================================================
3007 // function : StatisticInformation
3009 // =======================================================================
3010 TCollection_AsciiString V3d_View::StatisticInformation() const
3012 return myView->StatisticInformation();
3015 //=============================================================================
3016 //function : RenderingParams
3018 //=============================================================================
3019 const Graphic3d_RenderingParams& V3d_View::RenderingParams() const
3021 return myView->RenderingParams();
3024 //=============================================================================
3025 //function : ChangeRenderingParams
3027 //=============================================================================
3028 Graphic3d_RenderingParams& V3d_View::ChangeRenderingParams()
3030 return myView->ChangeRenderingParams();
3034 //=============================================================================
3035 //function : SetLightOn
3037 //=============================================================================
3038 void V3d_View::SetLightOn (const Handle(V3d_Light)& theLight)
3040 if (!myActiveLights.Contains (theLight))
3042 myActiveLights.Append (theLight);
3047 //=============================================================================
3048 //function : SetLightOff
3050 //=============================================================================
3051 void V3d_View::SetLightOff (const Handle(V3d_Light)& theLight)
3053 if (MyViewer->IsGlobalLight (theLight))
3054 throw Standard_TypeMismatch("V3d_View::SetLightOff, the light is global");
3055 myActiveLights.Remove (theLight);
3059 //=============================================================================
3060 //function : IsActiveLight
3062 //=============================================================================
3063 Standard_Boolean V3d_View::IsActiveLight (const Handle(V3d_Light)& theLight) const
3065 return !theLight.IsNull()
3066 && myActiveLights.Contains (theLight);
3069 //=============================================================================
3070 //function : SetLightOn
3072 //=============================================================================
3073 void V3d_View::SetLightOn()
3075 for (V3d_ListOfLightIterator aDefLightIter (MyViewer->DefinedLightIterator()); aDefLightIter.More(); aDefLightIter.Next())
3077 if (!myActiveLights.Contains (aDefLightIter.Value()))
3079 myActiveLights.Append (aDefLightIter.Value());
3085 //=============================================================================
3086 //function : SetLightOff
3088 //=============================================================================
3089 void V3d_View::SetLightOff()
3091 for (V3d_ListOfLight::Iterator anActiveLightIter (myActiveLights); anActiveLightIter.More();)
3093 if (!MyViewer->IsGlobalLight (anActiveLightIter.Value()))
3095 myActiveLights.Remove (anActiveLightIter);
3099 anActiveLightIter.Next();
3105 //=============================================================================
3106 //function : IfMoreLights
3108 //=============================================================================
3109 Standard_Boolean V3d_View::IfMoreLights() const
3111 return myActiveLights.Extent() < LightLimit();
3114 //=======================================================================
3115 //function : LightLimit
3117 //=======================================================================
3118 Standard_Integer V3d_View::LightLimit() const
3120 return Viewer()->Driver()->InquireLightLimit();
3123 //=======================================================================
3124 //function : AddClipPlane
3126 //=======================================================================
3127 void V3d_View::AddClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
3129 Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes();
3130 if (aSeqOfPlanes.IsNull())
3132 aSeqOfPlanes = new Graphic3d_SequenceOfHClipPlane();
3136 for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next())
3138 const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
3139 if (aPlane == thePlane)
3141 // plane is already defined in view
3147 aSeqOfPlanes->Append (thePlane);
3148 SetClipPlanes (aSeqOfPlanes);
3151 //=======================================================================
3152 //function : RemoveClipPlane
3154 //=======================================================================
3155 void V3d_View::RemoveClipPlane (const Handle(Graphic3d_ClipPlane)& thePlane)
3157 Handle(Graphic3d_SequenceOfHClipPlane) aSeqOfPlanes = ClipPlanes();
3158 if (aSeqOfPlanes.IsNull())
3163 for (Graphic3d_SequenceOfHClipPlane::Iterator aPlaneIt (*aSeqOfPlanes); aPlaneIt.More(); aPlaneIt.Next())
3165 const Handle(Graphic3d_ClipPlane)& aPlane = aPlaneIt.Value();
3166 if (aPlane != thePlane)
3171 aSeqOfPlanes->Remove (aPlaneIt);
3172 SetClipPlanes (aSeqOfPlanes);
3177 //=======================================================================
3178 //function : SetClipPlanes
3180 //=======================================================================
3181 void V3d_View::SetClipPlanes (const Handle(Graphic3d_SequenceOfHClipPlane)& thePlanes)
3183 myView->SetClipPlanes (thePlanes);
3186 //=======================================================================
3187 //function : ClipPlanes
3189 //=======================================================================
3190 const Handle(Graphic3d_SequenceOfHClipPlane)& V3d_View::ClipPlanes() const
3192 return myView->ClipPlanes();
3195 //=======================================================================
3196 //function : PlaneLimit
3198 //=======================================================================
3199 Standard_Integer V3d_View::PlaneLimit() const
3201 return Viewer()->Driver()->InquirePlaneLimit();
3204 //=============================================================================
3207 //=============================================================================
3208 void V3d_View::Move (const Standard_Real theDx,
3209 const Standard_Real theDy,
3210 const Standard_Real theDz,
3211 const Standard_Boolean theStart)
3213 Handle(Graphic3d_Camera) aCamera = Camera();
3216 myCamStartOpEye = aCamera->Eye();
3218 gp_Dir aReferencePlane (aCamera->Direction().Reversed());
3219 gp_Dir anUp (aCamera->Up());
3220 if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
3222 throw V3d_BadValue ("V3d_View::Translate, alignment of Eye,At,Up");
3226 Standard_Real XX, XY, XZ, YX, YY, YZ, ZX, ZY, ZZ;
3227 myXscreenAxis.Coord (XX,XY,XZ);
3228 myYscreenAxis.Coord (YX,YY,YZ);
3229 myZscreenAxis.Coord (ZX,ZY,ZZ);
3231 aCamera->SetEye (myCamStartOpEye);
3233 aCamera->SetEye (aCamera->Eye().XYZ()
3234 + theDx * gp_Pnt (XX, XY, XZ).XYZ()
3235 + theDy * gp_Pnt (YX, YY, YZ).XYZ()
3236 + theDz * gp_Pnt (ZX, ZY, ZZ).XYZ()
3242 //=============================================================================
3245 //=============================================================================
3246 void V3d_View::Move (const Standard_Real theLength, const Standard_Boolean theStart)
3248 Handle(Graphic3d_Camera) aCamera = Camera();
3251 myCamStartOpEye = aCamera->Eye();
3253 aCamera->SetEye (myCamStartOpEye);
3254 aCamera->SetEye (aCamera->Eye().XYZ() + theLength * myDefaultViewAxis.XYZ());
3259 //=============================================================================
3262 //=============================================================================
3263 void V3d_View::Move (const V3d_TypeOfAxe theAxe,
3264 const Standard_Real theLength,
3265 const Standard_Boolean theStart)
3270 Move (theLength,0.,0.,theStart);
3273 Move (0.,theLength,0.,theStart);
3276 Move (0.,0.,theLength,theStart);
3281 //=============================================================================
3282 //function : Translate
3284 //=============================================================================
3285 void V3d_View::Translate (const Standard_Real theDx,
3286 const Standard_Real theDy,
3287 const Standard_Real theDz,
3288 const Standard_Boolean theStart)
3290 Handle(Graphic3d_Camera) aCamera = Camera();
3293 myCamStartOpEye = aCamera->Eye();
3294 myCamStartOpCenter = aCamera->Center();
3296 gp_Dir aReferencePlane (aCamera->Direction().Reversed());
3297 gp_Dir anUp (aCamera->Up());
3298 if (!screenAxis (aReferencePlane, anUp, myXscreenAxis, myYscreenAxis, myZscreenAxis))
3300 throw V3d_BadValue ("V3d_View::Translate, alignment of Eye,At,Up");
3304 aCamera->SetEye (myCamStartOpEye);
3305 aCamera->SetCenter (myCamStartOpCenter);
3307 aCamera->SetCenter (aCamera->Center().XYZ()
3308 - theDx * myXscreenAxis.XYZ()
3309 - theDy * myYscreenAxis.XYZ()
3310 - theDz * myZscreenAxis.XYZ()
3313 aCamera->SetEye (aCamera->Eye().XYZ()
3314 - theDx * myXscreenAxis.XYZ()
3315 - theDy * myYscreenAxis.XYZ()
3316 - theDz * myZscreenAxis.XYZ()
3322 //=============================================================================
3323 //function : Translate
3325 //=============================================================================
3326 void V3d_View::Translate (const V3d_TypeOfAxe theAxe, const Standard_Real theLength,const Standard_Boolean theStart)
3331 Translate (theLength,0.,0., theStart);
3334 Translate (0.,theLength,0., theStart);
3337 Translate (0.,0.,theLength, theStart);
3342 //=======================================================================
3345 //=======================================================================
3346 void V3d_View::Place (const Standard_Integer theXp,
3347 const Standard_Integer theYp,
3348 const Standard_Real theZoomFactor)
3350 Standard_Integer aWinWidth = 0;
3351 Standard_Integer aWinHeight = 0;
3352 View()->Window()->Size (aWinWidth, aWinHeight);
3354 Standard_Integer aWinCXp = aWinWidth / 2;
3355 Standard_Integer aWinCYp = aWinHeight / 2;
3356 Pan (aWinCXp - theXp, -(aWinCYp - theYp), theZoomFactor / Scale());
3359 //=======================================================================
3360 //function : Translate
3362 //=======================================================================
3363 void V3d_View::Translate (const Standard_Real theLength, const Standard_Boolean theStart)
3365 Handle(Graphic3d_Camera) aCamera = Camera();
3368 myCamStartOpCenter = aCamera->Center() ;
3371 gp_Pnt aNewCenter (myCamStartOpCenter.XYZ() - myDefaultViewAxis.XYZ() * theLength);
3372 aCamera->SetCenter (aNewCenter);
3377 //=============================================================================
3378 //function : SetGrid
3380 //=============================================================================
3381 void V3d_View::SetGrid (const gp_Ax3& aPlane, const Handle(Aspect_Grid)& aGrid)
3386 Standard_Real xl, yl, zl;
3387 Standard_Real xdx, xdy, xdz;
3388 Standard_Real ydx, ydy, ydz;
3389 Standard_Real dx, dy, dz;
3390 aPlane.Location ().Coord (xl, yl, zl);
3391 aPlane.XDirection ().Coord (xdx, xdy, xdz);
3392 aPlane.YDirection ().Coord (ydx, ydy, ydz);
3393 aPlane.Direction ().Coord (dx, dy, dz);
3395 Standard_Real CosAlpha = Cos (MyGrid->RotationAngle ());
3396 Standard_Real SinAlpha = Sin (MyGrid->RotationAngle ());
3398 TColStd_Array2OfReal Trsf1 (1, 4, 1, 4);
3400 Trsf1 (4, 1) = Trsf1 (4, 2) = Trsf1 (4, 3) = 0.0;
3405 // Transformation change of marker
3416 TColStd_Array2OfReal Trsf2 (1, 4, 1, 4);
3418 Trsf2 (4, 1) = Trsf2 (4, 2) = Trsf2 (4, 3) = 0.0;
3419 // Translation of the origin
3420 Trsf2 (1, 4) = -MyGrid->XOrigin (),
3421 Trsf2 (2, 4) = -MyGrid->YOrigin (),
3423 // Rotation Alpha around axis -Z
3424 Trsf2 (1, 1) = CosAlpha,
3425 Trsf2 (2, 1) = -SinAlpha,
3427 Trsf2 (1, 2) = SinAlpha,
3428 Trsf2 (2, 2) = CosAlpha,
3434 Standard_Real valuetrsf;
3435 Standard_Real valueoldtrsf;
3436 Standard_Real valuenewtrsf;
3437 Standard_Integer i, j, k;
3438 // Calculation of the product of matrices
3439 for (i=1; i<=4; i++)
3440 for (j=1; j<=4; j++) {
3441 MyTrsf (i, j) = 0.0;
3442 for (k=1; k<=4; k++) {
3443 valueoldtrsf = Trsf1 (i, k);
3444 valuetrsf = Trsf2 (k, j);
3445 valuenewtrsf = MyTrsf (i, j) + valueoldtrsf * valuetrsf;
3446 MyTrsf (i, j) = valuenewtrsf;
3451 //=============================================================================
3452 //function : SetGridActivity
3454 //=============================================================================
3455 void V3d_View::SetGridActivity (const Standard_Boolean AFlag)
3457 if (AFlag) MyGrid->Activate ();
3458 else MyGrid->Deactivate ();
3461 //=============================================================================
3462 //function : toPolarCoords
3464 //=============================================================================
3465 void toPolarCoords (const Standard_Real theX, const Standard_Real theY,
3466 Standard_Real& theR, Standard_Real& thePhi)
3468 theR = Sqrt (theX * theX + theY * theY);
3469 thePhi = ATan2 (theY, theX);
3472 //=============================================================================
3473 //function : toCartesianCoords
3475 //=============================================================================
3476 void toCartesianCoords (const Standard_Real theR, const Standard_Real thePhi,
3477 Standard_Real& theX, Standard_Real& theY)
3479 theX = theR * Cos (thePhi);
3480 theY = theR * Sin (thePhi);
3483 //=============================================================================
3484 //function : Compute
3486 //=============================================================================
3487 Graphic3d_Vertex V3d_View::Compute (const Graphic3d_Vertex& theVertex) const
3489 const Handle(Graphic3d_Camera)& aCamera = Camera();
3490 gp_Dir VPN = aCamera->Direction().Reversed(); // RefPlane
3491 gp_Dir GPN = MyPlane.Direction();
3493 Standard_Real XPp = 0.0, YPp = 0.0;
3494 Project (theVertex.X(), theVertex.Y(), theVertex.Z(), XPp, YPp);
3496 // Casw when the plane of the grid and the plane of the view
3497 // are perpendicular to MYEPSILON2 close radians
3498 #define MYEPSILON2 M_PI / 180.0 // Delta between 2 angles
3499 if (Abs (VPN.Angle (GPN) - M_PI / 2.) < MYEPSILON2)
3504 const gp_XYZ aPnt0 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 0.0, 0.0), MyTrsf);
3506 // get grid axes in world space
3507 const gp_XYZ aPnt1 = V3d_View::TrsPoint (Graphic3d_Vertex (1.0, 0.0, 0.0), MyTrsf);
3508 gp_Vec aGridX (aPnt0, aPnt1);
3511 const gp_XYZ aPnt2 = V3d_View::TrsPoint (Graphic3d_Vertex (0.0, 1.0, 0.0), MyTrsf);
3512 gp_Vec aGridY (aPnt0, aPnt2);
3515 // project ray from camera onto grid plane
3516 const gp_Vec aProjection = aCamera->IsOrthographic()
3517 ? gp_Vec (aCamera->Direction())
3518 : gp_Vec (aCamera->Eye(), gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z())).Normalized();
3519 const gp_Vec aPointOrigin = gp_Vec (gp_Pnt (theVertex.X(), theVertex.Y(), theVertex.Z()), aPnt0);
3520 const Standard_Real aT = aPointOrigin.Dot (MyPlane.Direction()) / aProjection.Dot (MyPlane.Direction());
3521 const gp_XYZ aPointOnPlane = gp_XYZ (theVertex.X(), theVertex.Y(), theVertex.Z()) + aProjection.XYZ() * aT;
3523 if (Handle(Aspect_RectangularGrid) aRectGrid = Handle(Aspect_RectangularGrid)::DownCast (MyGrid))
3525 // project point on plane to grid local space
3526 const gp_Vec aToPoint (aPnt0, aPointOnPlane);
3527 const Standard_Real anXSteps = Round (aGridX.Dot (aToPoint) / aRectGrid->XStep());
3528 const Standard_Real anYSteps = Round (aGridY.Dot (aToPoint) / aRectGrid->YStep());
3530 // clamp point to grid
3531 const gp_Vec aResult = aGridX * anXSteps * aRectGrid->XStep()
3532 + aGridY * anYSteps * aRectGrid->YStep()
3534 return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z());
3536 else if (Handle(Aspect_CircularGrid) aCircleGrid = Handle(Aspect_CircularGrid)::DownCast (MyGrid))
3538 const Standard_Real anAlpha = M_PI / Standard_Real (aCircleGrid->DivisionNumber());
3540 // project point on plane to grid local space
3541 const gp_Vec aToPoint (aPnt0, aPointOnPlane);
3542 Standard_Real aLocalX = aGridX.Dot (aToPoint);
3543 Standard_Real aLocalY = aGridY.Dot (aToPoint);
3544 Standard_Real anR = 0.0, aPhi = 0.0;
3545 toPolarCoords (aLocalX, aLocalY, anR, aPhi);
3547 // clamp point to grid
3548 const Standard_Real anRSteps = Round (anR / aCircleGrid->RadiusStep());
3549 const Standard_Real aPhiSteps = Round (aPhi / anAlpha);
3550 toCartesianCoords (anRSteps * aCircleGrid->RadiusStep(), aPhiSteps * anAlpha, aLocalX, aLocalY);
3552 const gp_Vec aResult = aGridX * aLocalX + aGridY * aLocalY + gp_Vec (aPnt0);
3553 return Graphic3d_Vertex (aResult.X(), aResult.Y(), aResult.Z());
3555 return Graphic3d_Vertex (0.0, 0.0, 0.0);
3558 //=============================================================================
3559 //function : ZBufferTriedronSetup
3561 //=============================================================================
3562 void V3d_View::ZBufferTriedronSetup (const Quantity_Color& theXColor,
3563 const Quantity_Color& theYColor,
3564 const Quantity_Color& theZColor,
3565 const Standard_Real theSizeRatio,
3566 const Standard_Real theAxisDiametr,
3567 const Standard_Integer theNbFacettes)
3569 const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true);
3570 aTrihedron->SetArrowsColor (theXColor, theYColor, theZColor);
3571 aTrihedron->SetSizeRatio (theSizeRatio);
3572 aTrihedron->SetNbFacets (theNbFacettes);
3573 aTrihedron->SetArrowDiameter (theAxisDiametr);
3576 //=============================================================================
3577 //function : TriedronDisplay
3579 //=============================================================================
3580 void V3d_View::TriedronDisplay (const Aspect_TypeOfTriedronPosition thePosition,
3581 const Quantity_Color& theColor,
3582 const Standard_Real theScale,
3583 const V3d_TypeOfVisualization theMode)
3585 const Handle(V3d_Trihedron)& aTrihedron = Trihedron (true);
3586 aTrihedron->SetLabelsColor (theColor);
3587 aTrihedron->SetScale (theScale);
3588 aTrihedron->SetPosition (thePosition);
3589 aTrihedron->SetWireframe (theMode == V3d_WIREFRAME);
3591 aTrihedron->Display (*this);
3594 //=============================================================================
3595 //function : TriedronErase
3597 //=============================================================================
3598 void V3d_View::TriedronErase()
3600 if (!myTrihedron.IsNull())
3602 myTrihedron->Erase();
3606 //=============================================================================
3607 //function : GetGraduatedTrihedron
3609 //=============================================================================
3610 const Graphic3d_GraduatedTrihedron& V3d_View::GetGraduatedTrihedron() const
3612 return myView->GetGraduatedTrihedron();
3615 //=============================================================================
3616 //function : GraduatedTrihedronDisplay
3618 //=============================================================================
3619 void V3d_View::GraduatedTrihedronDisplay (const Graphic3d_GraduatedTrihedron& theTrihedronData)
3621 myView->GraduatedTrihedronDisplay (theTrihedronData);
3624 //=============================================================================
3625 //function : GraduatedTrihedronErase
3627 //=============================================================================
3628 void V3d_View::GraduatedTrihedronErase()
3630 myView->GraduatedTrihedronErase();
3633 // =======================================================================
3634 // function : DumpJson
3636 // =======================================================================
3637 void V3d_View::DumpJson (Standard_OStream& theOStream, Standard_Integer theDepth) const
3639 OCCT_DUMP_TRANSIENT_CLASS_BEGIN (theOStream)
3641 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOldMouseX)
3642 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myOldMouseY)
3643 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpUp)
3644 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpDir)
3645 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpEye)
3646 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myCamStartOpCenter)
3647 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myDefaultCamera.get())
3648 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myView.get())
3649 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myImmediateUpdate)
3650 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myIsInvalidatedImmediate)
3652 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, MyViewer)
3653 for (V3d_ListOfLight::Iterator anIterator (myActiveLights); anIterator.More(); anIterator.Next())
3655 class Handle(Graphic3d_CLight)& anActiveLight = anIterator.Value();
3656 OCCT_DUMP_FIELD_VALUE_POINTER (theOStream, anActiveLight)
3658 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultViewAxis)
3659 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myDefaultViewPoint)
3660 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyWindow.get())
3661 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, sx)
3662 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, sy)
3663 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, rx)
3664 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, ry)
3665 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myRotateGravity)
3666 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myComputedMode)
3667 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, SwitchSetFront)
3668 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myZRotation)
3669 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, MyZoomAtPointX)
3670 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, MyZoomAtPointY)
3671 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, myTrihedron.get())
3672 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyGrid.get())
3673 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &MyPlane)
3674 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyGridEchoStructure.get())
3675 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, MyGridEchoGroup.get())
3676 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myXscreenAxis)
3677 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myYscreenAxis)
3678 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myZscreenAxis)
3679 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myViewAxis)
3680 OCCT_DUMP_FIELD_VALUES_DUMPED (theOStream, theDepth, &myGravityReferencePoint)
3681 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoZFitIsOn)
3682 OCCT_DUMP_FIELD_VALUE_NUMERICAL (theOStream, myAutoZFitScaleFactor)