[vtkusers] setSlice problem on QVTKWidget
goodsit2
goodsije at live.com
Sat Oct 27 01:07:38 EDT 2012
I hate to resurface this problem, but I have similar code and was able to
reproduce the error. Before trying Massi's of getting the window to render
in the widget, I kind of went in a loop as you will see right below, but
myInteractor would not work in the widget. However, it does work if I try it
in an external window (just not in the widget). Code below for non-working
interactor.
iToVconnector->SetInput(reader->GetOutput());
vtkSmartPointer<vtkImageViewer2> imageViewer =
vtkSmartPointer<vtkImageViewer2>::New();
imageViewer->SetInput(iToVconnector->GetOutput());
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
vtkSmartPointer<DicomInteractorStyleImage> myInteractor =
vtkSmartPointer<DicomInteractorStyleImage>::New();
myInteractor->SetImageViewer(imageViewer);
myInteractor->SetStatusMapper(myLabel);
imageViewer->SetupInteractor(renderWindowInteractor);
myWindow->SetRenderWindow(renderWindowInteractor->GetRenderWindow());
imageViewer->SetupInteractor(myWindow->GetRenderWindow()->GetInteractor());
myWindow->GetRenderWindow()->GetInteractor()->SetInteractorStyle(myInteractor);
imageViewer->Render();
imageViewer->GetRenderer()->ResetCamera();
imageViewer->Render();
myWindow->update();
And since I saw Mass's interactor working, I thought I would try his method
as seen below:
vtkImageViewer2 * imageViewer = vtkImageViewer2::New();
imageViewer->SetInput(iToVconnector->GetOutput());
DicomInteractorStyleImage * myInteractor =
DicomInteractorStyleImage::New();
// make imageviewer2 and dicomViewerLabel visible to our interactorstyle
// to enable slice status message updates when scrolling through the
slices
myInteractor->SetImageViewer(imageViewer);
myInteractor->SetStatusMapper(myLabel);
myWindow->SetRenderWindow(imageViewer->GetRenderWindow());
imageViewer->SetupInteractor(myWindow->GetRenderWindow()->GetInteractor());
myWindow->GetRenderWindow()->GetInteractor()->SetInteractorStyle(myInteractor);
myWindow->update();
Though the program crashed instantly when it ran through this section. I
even tried his pointer theory, but still my program crashed. I narrowed it
down to two lines of code. Those are:
myWindow->SetRenderWindow(imageViewer->GetRenderWindow());
imageViewer->SetupInteractor(myWindow->GetRenderWindow()->GetInteractor());
If either of these lines were in the code, it crashed the program. Any
thoughts? Thanks for reading :)
Bests,
Jeremy
--
View this message in context: http://vtk.1045678.n5.nabble.com/setSlice-problem-on-QVTKWidget-tp5715880p5716843.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list