]> OCCT Git - occt.git/commitdiff
0028031: Visualization, TKV3d - do not use height/width ratio of window during V3d_Vi...
authorosa <osa@opencascade.com>
Mon, 31 Oct 2016 14:08:37 +0000 (17:08 +0300)
committerapn <apn@opencascade.com>
Thu, 3 Nov 2016 11:15:57 +0000 (14:15 +0300)
src/V3d/V3d_View.cxx
src/V3d/V3d_View.hxx

index bcbc36aeed3beca8f2505324b1b5473012745af3..c6b4104cd84dfd5eccc7b5cedacf3b79912aa37d 100644 (file)
@@ -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();
index 9bed1e9d491cd62ca9c75c943b00dc258ce34376..81cbb46212b62faa403c77bb3ac1cc4b7b31a321 100644 (file)
@@ -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 <Umin, Vmin, Umax, Vmax> 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);