[vtkusers] Qt & VTK Intereaction problem
al.gry
al.gry at web.de
Fri Jul 22 08:31:35 EDT 2011
Hi all,
I'm new to VTK and Qt. Now to my problem, I'm trying to visualize 3d volume
from dicom files using vtk in qt. So far it goes fine but I cannot rotate
the scene or do other interactions except zooming. If I use the same code
without Qt everything works. I searched in the mailing list and found some
hints but nothing I can work with.
m_pRenWin = vtkSmartPointer<vtkRenderWindow>::New();
m_pQVTKWidget->SetRenderWindow(m_pRenWin);
m_pIren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
m_pIren->SetRenderWindow(m_pQVTKWidget->GetRenderWindow());
m_pRen = vtkSmartPointer<vtkRenderer>::New();
m_pQVTKWidget->GetRenderWindow()->AddRenderer(m_pRen);
vtkSmartPointer<vtkAlgorithm> m_reader =
vtkSmartPointer<vtkAlgorithm>::New();
m_reader = m_pDicomReader;
vtkSmartPointer<vtkImageData> input =
vtkSmartPointer<vtkImageData>::New();
input = m_pDicomReader->GetOutput();
int dim[3];
input->GetDimensions(dim);
if( (dim[0] < 2)||(dim[1] < 2)||(dim[2] < 2))
{
QMessageBox::information(this, tr("Error"), tr("Wrong dimension!"));
return;
}
// Create our volume and mapper
vtkSmartPointer<vtkVolume> volume = vtkSmartPointer<vtkVolume>::New();
vtkSmartPointer<vtkFixedPointVolumeRayCastMapper> mapper =
vtkSmartPointer<vtkFixedPointVolumeRayCastMapper>::New();
mapper->SetInputConnection( m_reader->GetOutputPort() );
double spacing[3];
input->GetSpacing(spacing);
vtkSmartPointer<vtkColorTransferFunction> colorFun =
vtkSmartPointer<vtkColorTransferFunction>::New();
vtkSmartPointer<vtkPiecewiseFunction> opacityFun =
vtkSmartPointer<vtkPiecewiseFunction>::New();
vtkSmartPointer<vtkVolumeProperty> property =
vtkSmartPointer<vtkVolumeProperty>::New();
bool independentComponents=true;
property->SetIndependentComponents(independentComponents);
property->SetColor( colorFun );
property->SetScalarOpacity( opacityFun );
property->SetInterpolationTypeToLinear();
// connect up the volume to the property and the mapper
volume->SetProperty( property );
volume->SetMapper( mapper );
double opacityWindow = 4096.0;
double opacityLevel = 2048.0;
colorFun->AddRGBSegment(0.0, 1.0, 1.0, 1.0, 255.0, 1.0, 1.0, 1.0 );
opacityFun->AddSegment( opacityLevel - 0.5*opacityWindow, 0.0,
opacityLevel + 0.5*opacityWindow, 1.0 );
mapper->SetBlendModeToMaximumIntensity();
m_pIren = vtkSmartPointer<vtkRenderWindowInteractor>::New();
m_pIren->SetRenderWindow(m_pQVTKWidget->GetRenderWindow());
m_pIren->GetInteractorStyle()->SetDefaultRenderer(m_pRen);
//m_pQVTKWidget->GetRenderWindow()->Render();
m_pRen->AddVolume(volume);
m_pRen->ResetCamera();
m_pRen->Modified();
m_pQVTKWidget->GetRenderWindow()->Render();
--
View this message in context: http://vtk.1045678.n5.nabble.com/Qt-VTK-Intereaction-problem-tp4622853p4622853.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list