From 434ffc090992f797f21ef70bdd9554130e8290e2 Mon Sep 17 00:00:00 2001 From: osa Date: Mon, 31 Oct 2016 17:08:37 +0300 Subject: [PATCH] 0028031: Visualization, TKV3d - do not use height/width ratio of window during V3d_View::FitAll() --- src/V3d/V3d_View.cxx | 43 +++++++++++++------------------------------ src/V3d/V3d_View.hxx | 5 ----- 2 files changed, 13 insertions(+), 35 deletions(-) diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index bcbc36aeed..c6b4104cd8 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -165,7 +165,7 @@ void V3d_View::SetMagnify (const Handle(Aspect_Window)& theWindow, thePreviousView->Convert (theX1, theY1, aU1, aV1); thePreviousView->Convert (theX2, theY2, aU2, aV2); myView->SetWindow (theWindow); - FitAll (theWindow, aU1, aV1, aU2, aV2); + FitAll (aU1, aV1, aU2, aV2); MyViewer->SetViewOn (this); MyWindow = theWindow; SetRatio(); @@ -1586,18 +1586,6 @@ void V3d_View::DepthFitAll(const Quantity_Coefficient Aspect, ImmediateUpdate(); } -//============================================================================= -//function : FitAll -//purpose : -//============================================================================= -void V3d_View::FitAll(const Standard_Real theMinXv, - const Standard_Real theMinYv, - const Standard_Real theMaxXv, - const Standard_Real theMaxYv) -{ - FitAll (MyWindow, theMinXv, theMinYv, theMaxXv, theMaxYv); -} - //============================================================================= //function : WindowFitAll //purpose : @@ -2658,32 +2646,27 @@ void V3d_View::AxialScale (const Standard_Integer Dx, //function : FitAll //purpose : //============================================================================= -void V3d_View::FitAll(const Handle(Aspect_Window)& aWindow, - const Standard_Real Xmin, - const Standard_Real Ymin, - const Standard_Real Xmax, - const Standard_Real Ymax) +void V3d_View::FitAll(const Standard_Real theXmin, + const Standard_Real theYmin, + const Standard_Real theXmax, + const Standard_Real theYmax) { - Standard_Integer aWinWidth, aWinHeight; - aWindow->Size (aWinWidth, aWinHeight); + Handle(Graphic3d_Camera) aCamera = Camera(); + Standard_Real anAspect = aCamera->Aspect(); - Standard_Real aWinAspect = (Standard_Real)aWinWidth / aWinHeight; - Standard_Real aFitSizeU = Abs (Xmax - Xmin); - Standard_Real aFitSizeV = Abs (Ymax - Ymin); + Standard_Real aFitSizeU = Abs (theXmax - theXmin); + Standard_Real aFitSizeV = Abs (theYmax - theYmin); Standard_Real aFitAspect = aFitSizeU / aFitSizeV; - if (aFitAspect >= aWinAspect) + if (aFitAspect >= anAspect) { - aFitSizeV = aFitSizeU / aWinAspect; + aFitSizeV = aFitSizeU / anAspect; } else { - aFitSizeU = aFitSizeV * aWinAspect; + aFitSizeU = aFitSizeV * anAspect; } - Handle(Graphic3d_Camera) aCamera = Camera(); - - aCamera->SetAspect (aWinAspect); - Translate (aCamera, (Xmin + Xmax) * 0.5, (Ymin + Ymax) * 0.5); + Translate (aCamera, (theXmin + theXmax) * 0.5, (theYmin + theYmax) * 0.5); Scale (aCamera, aFitSizeU, aFitSizeV); AutoZFit(); diff --git a/src/V3d/V3d_View.hxx b/src/V3d/V3d_View.hxx index 9bed1e9d49..81cbb46212 100644 --- a/src/V3d/V3d_View.hxx +++ b/src/V3d/V3d_View.hxx @@ -982,11 +982,6 @@ private: //! the associated window is defined or resized. Standard_EXPORT void SetRatio(); - //! Change the scale factor and position of the view - //! such as the bounding box is contains - //! in the view. - Standard_EXPORT void FitAll (const Handle(Aspect_Window)& aWindow, const V3d_Coordinate Umin, const V3d_Coordinate Vmin, const V3d_Coordinate Umax, const V3d_Coordinate Vmax); - //! Determines the screen axes in the reference //! framework of the view. Standard_EXPORT static Standard_Boolean ScreenAxis (const gp_Dir& Vpn, const gp_Dir& Vup, Graphic3d_Vector& Xaxe, Graphic3d_Vector& Yaxe, Graphic3d_Vector& Zaxe);