[vtkusers] fit to screen in vtkImageViewer2 + QVTKWidget
Andaharoo
Andx_roo at live.com
Fri Jul 28 02:12:17 EDT 2017
Hi,
I can't say why it does this but I've battled this effect by doing the
following with parallel scale defined as half the size of the image. I
usually do something like this:
extent = new double[3]
{
image->GetDimensions()[0] * image->GetSpacing()[0] * 0.5,
image->GetDimensions()[1] * image->GetSpacing()[1] * 0.5,
image->GetDimensions()[2] * image->GetSpacing()[2] * 0.5
};
imageViewer->GetRenderer()->ResetCamera();
vtkCamera* cam = imageViewer->GetRenderer()->GetActiveCamera();
cam->ParallelProjectionOn();
cam->SetParallelScale(extent[0]);
This gets a little more complicated if you want to use a different
orientation though. Here's some psuedo
if (XY orientation)
SetParallelScale(extent[0]);
cam->SetViewUp(0, 1, 0);
else if (YZ orientation)
SetParallelScale(std::max(extent[1], extent[2] * h / w))
cam->SetViewUp(0, 0, 1);
else if (XZ orientation)
SetParallelScale(std::max(extent[0], extent[2] * h / w));
cam->SetViewUp(0, 0, 1);
--
View this message in context: http://vtk.1045678.n5.nabble.com/fit-to-screen-in-vtkImageViewer2-QVTKWidget-tp5744151p5744187.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list