From 0a70041e18aa8a8a728bbf95a3884dfd35de7223 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 28 Jan 2021 10:57:54 +0300 Subject: [PATCH] 0032091: Visualization - possibility to redefine Graphic3d_TransformPers --- src/Graphic3d/Graphic3d_TransformPers.hxx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/Graphic3d/Graphic3d_TransformPers.hxx b/src/Graphic3d/Graphic3d_TransformPers.hxx index cb5c501b46..4c69b63d8c 100644 --- a/src/Graphic3d/Graphic3d_TransformPers.hxx +++ b/src/Graphic3d/Graphic3d_TransformPers.hxx @@ -223,6 +223,19 @@ public: } public: + virtual Standard_Real persistentScale (const Handle(Graphic3d_Camera)& theCamera, + const Standard_Integer /*theViewportWidth*/, + const Standard_Integer theViewportHeight) const + { + // use total size when tiling is active + const Standard_Integer aVPSizeY = theCamera->Tile().IsValid() ? theCamera->Tile().TotalSize.y() : theViewportHeight; + + gp_Vec aVecToEye (theCamera->Direction()); + gp_Vec aVecToObj (theCamera->Eye(), gp_Pnt (myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ)); + const Standard_Real aFocus = aVecToObj.Dot (aVecToEye); + const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus); + return Abs(aViewDim.Y()) / Standard_Real(aVPSizeY); + } //! Apply transformation to bounding box of presentation. //! @param theCamera [in] camera definition @@ -452,11 +465,7 @@ void Graphic3d_TransformPers::Apply (const Handle(Graphic3d_Camera)& theCamera, if ((myMode & Graphic3d_TMF_ZoomPers) != 0) { // lock zooming - gp_Vec aVecToEye (theCamera->Direction()); - gp_Vec aVecToObj (theCamera->Eye(), gp_Pnt (myParams.Params3d.PntX, myParams.Params3d.PntY, myParams.Params3d.PntZ)); - const Standard_Real aFocus = aVecToObj.Dot (aVecToEye); - const gp_XYZ aViewDim = theCamera->ViewDimensions (aFocus); - const Standard_Real aScale = Abs(aViewDim.Y()) / Standard_Real(aVPSizeY); + Standard_Real aScale = persistentScale (theCamera, theViewportWidth, theViewportHeight); Graphic3d_TransformUtils::Scale (aWorldView, aScale, aScale, aScale); } theWorldView.ConvertFrom (aWorldView); -- 2.39.5