Mentions légales du service

Skip to content
Snippets Groups Projects
Commit e128ef79 authored by Paul Lafoix's avatar Paul Lafoix
Browse files

Zoom closer to the data and fix too much zoom bug

parent 299f3c11
No related branches found
No related tags found
No related merge requests found
5791a385e48a7213fb85a3da060ce788f7050ef0ce53bda1df8b2f126947b860b0ddd6e405ee9c44f54b91eaaed3d3565a7479350b03e4d99c4774f4e648075f 1dfa972a6f686870f82cc5dc99035516f5d4e79bb41a014be9eec96a6b07f42044b012bb32690a84abfe78f1dfaf7f1671a250752f3f4f15b115792267933a0b
...@@ -1404,15 +1404,6 @@ void vtkRenderer::ResetCameraScreenSpace(const double bounds[6]) ...@@ -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 // Project the focal point in screen space
double fp[4]; double fp[4];
this->ActiveCamera->GetFocalPoint(fp); this->ActiveCamera->GetFocalPoint(fp);
...@@ -1465,18 +1456,13 @@ vtkVector3d vtkRenderer::DisplayToWorld(const vtkVector3d& display) ...@@ -1465,18 +1456,13 @@ vtkVector3d vtkRenderer::DisplayToWorld(const vtkVector3d& display)
void vtkRenderer::ZoomToBoxUsingViewAngle(const vtkRecti& box) void vtkRenderer::ZoomToBoxUsingViewAngle(const vtkRecti& box)
{ {
const int* size = this->GetSize(); const int* size = this->GetSize();
double zoomFactor; double zf1 = size[0] / static_cast<double>(box.GetWidth());
if (box.GetWidth() > box.GetHeight()) double zf2 = size[1] / static_cast<double>(box.GetHeight());
{ double zoomFactor = std::min(zf1, zf2);
zoomFactor = size[0] / static_cast<double>(box.GetWidth());
}
else
{
zoomFactor = size[1] / static_cast<double>(box.GetHeight());
}
vtkCamera* cam = this->GetActiveCamera(); // Offset a little to let a free space between the zoomed data
cam->Zoom(zoomFactor); // And the edges of the window
this->GetActiveCamera()->Zoom(zoomFactor * 0.90);
} }
// Specify the rendering window in which to draw. This is automatically set // Specify the rendering window in which to draw. This is automatically set
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment