diff --git a/Rendering/Core/Testing/Data/Baseline/TestResetCameraScreenSpace.png.sha512 b/Rendering/Core/Testing/Data/Baseline/TestResetCameraScreenSpace.png.sha512 index 99ba1f38a77283e503575281218e6ecb5f3684b5..892ecab430d3b187bceaf0a35844fb557d7ea754 100644 --- a/Rendering/Core/Testing/Data/Baseline/TestResetCameraScreenSpace.png.sha512 +++ b/Rendering/Core/Testing/Data/Baseline/TestResetCameraScreenSpace.png.sha512 @@ -1 +1 @@ -5791a385e48a7213fb85a3da060ce788f7050ef0ce53bda1df8b2f126947b860b0ddd6e405ee9c44f54b91eaaed3d3565a7479350b03e4d99c4774f4e648075f +1dfa972a6f686870f82cc5dc99035516f5d4e79bb41a014be9eec96a6b07f42044b012bb32690a84abfe78f1dfaf7f1671a250752f3f4f15b115792267933a0b diff --git a/Rendering/Core/vtkRenderer.cxx b/Rendering/Core/vtkRenderer.cxx index c73350c3df6cc5c3d4910116909657b9c2493ea7..b96674ab5c71511ae05cbf2c94c7632ca49c9031 100644 --- a/Rendering/Core/vtkRenderer.cxx +++ b/Rendering/Core/vtkRenderer.cxx @@ -1404,15 +1404,6 @@ void vtkRenderer::ResetCameraScreenSpace(const double bounds[6]) } } - // Offset a little to make sure bounds are not clipped - int offsetX = std::max(static_cast<int>((xmax - xmin) * 0.01), 10); - int offsetY = std::max(static_cast<int>((ymax - ymin) * 0.01), 10); - - xmin -= offsetX; - xmax += offsetX; - ymin -= offsetY; - ymax += offsetY; - // Project the focal point in screen space double fp[4]; this->ActiveCamera->GetFocalPoint(fp); @@ -1465,18 +1456,13 @@ vtkVector3d vtkRenderer::DisplayToWorld(const vtkVector3d& display) void vtkRenderer::ZoomToBoxUsingViewAngle(const vtkRecti& box) { const int* size = this->GetSize(); - double zoomFactor; - if (box.GetWidth() > box.GetHeight()) - { - zoomFactor = size[0] / static_cast<double>(box.GetWidth()); - } - else - { - zoomFactor = size[1] / static_cast<double>(box.GetHeight()); - } + double zf1 = size[0] / static_cast<double>(box.GetWidth()); + double zf2 = size[1] / static_cast<double>(box.GetHeight()); + double zoomFactor = std::min(zf1, zf2); - vtkCamera* cam = this->GetActiveCamera(); - cam->Zoom(zoomFactor); + // Offset a little to let a free space between the zoomed data + // And the edges of the window + this->GetActiveCamera()->Zoom(zoomFactor * 0.90); } // Specify the rendering window in which to draw. This is automatically set