I use qt and vtk to visualize dicom file. And it works well.
But when I want to add picker to my program I found imageViewer->GetRenderer()->GetActors() is empty, so I can’t pick anything.
But the dicom picture can be shown, and there is a imageactor in imageViewer. Blow is part of my code:
imageViewer = vtkImageViewer2::New();
imageViewer->SetRenderWindow(widget->renderWindow());
imageViewer->SetSliceOrientation(orient);
imageViewer->SetInputConnection(data->GetOutputPort());
interactorStyle = myVtkInteractorStyleImage::New();
interactorStyle->SetImageViewer(imageViewer);
interactorStyle->NewPicker();
widget->interactor()->SetInteractorStyle(interactorStyle);
imageViewer->GetRenderer()->AddViewProp(imageViewer->GetImageActor());
auto x = imageViewer->GetImageActor();
auto t = imageViewer->GetRenderer()->GetActors();
imageViewer->Render();
imageViewer->GetRenderer()->ResetCamera();
imageViewer->GetRenderer()->SetBackground(
colors->GetColor3d("SlateGray").GetData());
imageViewer->GetRenderWindow()->SetSize(800, 800);
imageViewer->GetRenderWindow()->SetWindowName("ReadDICOMSeries");
// Annotate the image with window/level and mouse over pixel information
vtkNew<vtkCornerAnnotation> cornerAnnotation;
cornerAnnotation->SetLinearFontScaleFactor(2);
cornerAnnotation->SetNonlinearFontScaleFactor(1);
cornerAnnotation->SetMaximumFontSize(20);
cornerAnnotation->SetText(0, "Off Image");
cornerAnnotation->SetText(3, "<window>\n<level>");
cornerAnnotation->GetTextProperty()->SetColor(
colors->GetColor3d("LightGoldenrodYellow").GetData());
imageViewer->GetRenderer()->AddViewProp(cornerAnnotation);
interactorStyle->SetAnnotation(cornerAnnotation);
imageViewer->Render();
Although I add code to add imageactor to renderer, the value t(imageViewer->GetRenderer()->GetActors()) is still empry, x is proper imageactor. The annotation is add correctly and is one member in imageViewer->GetRenderer()->GetActors2D().
So, could someone tell why I fail to add image actor to renderer while the dicom file can show well.
Program is shown as below: