Hi !
I’m trying to build an application with Qt and VTK. I want to display a 3D image (DICOM) in a widget like QVTKOpenGLNativeWidget
and be able to change slices using the mouse wheel (and other thigs).
I was inspired by this example: https://examples.vtk.org/site/Cxx/IO/ReadDICOMSeries/ and I’m trying to run it under Qt.
The beginning of interactor is:
// Define own interaction style.
class myVtkInteractorStyleImage : public vtkInteractorStyleImage
{
public:
static myVtkInteractorStyleImage *New();
vtkTypeMacro(myVtkInteractorStyleImage, vtkInteractorStyleImage);
My problem concerns the definition of the interactor. Here is the code:
vtkSmartPointer<vtkImageViewer2> imageViewer = vtkSmartPointer<vtkImageViewer2>::New();
imageViewer->SetInputConnection(_reader->GetOutputPort());
imageViewer->SetSliceOrientationToYZ();
...
// Create an interactor with our own style (inherit from
// vtkInteractorStyleImage) in order to catch mousewheel and key events.
// vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
vtkNew<vtkGenericRenderWindowInteractor> renderWindowInteractor;
vtkNew<myVtkInteractorStyleImage> myInteractorStyle;
vtkNew<vtkGenericOpenGLRenderWindow> renderWindowCenter;
// Make imageviewer2 and sliceTextMapper visible to our interactorstyle
// to enable slice status message updates when scrolling through the slices.
myInteractorStyle->SetImageViewer(imageViewer);
myInteractorStyle->SetStatusMapper(sliceTextMapper);
imageViewer->SetupInteractor(renderWindowInteractor);
// Make the interactor use our own interactorstyle
// cause SetupInteractor() is defining it's own default interatorstyle
// this must be called after SetupInteractor().
renderWindowInteractor->SetInteractorStyle(myInteractorStyle);
this->ui->qvtkWidgetCenter->setRenderWindow(renderWindowCenter);
imageViewer->SetRenderWindow(renderWindowCenter);
// Crash if do that :
//renderWindowCenter->GetInteractor()->SetInteractorStyle(myInteractorStyle);
imageViewer->Render();
I tried to change the interactor classes using: QVTKInteractor
and vtkGenericRenderWindowInteractor
in particular, without success…
Thanks for your help !