1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-05 18:16:23 +03:00

0028031: Visualization, TKV3d - do not use height/width ratio of window during V3d_View::FitAll()

This commit is contained in:
osa 2016-10-31 17:08:37 +03:00 committed by apn
parent 62ef08dfc8
commit 434ffc0909
2 changed files with 13 additions and 35 deletions

View 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();

View 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);