[vtkusers] reading DICOM series QVTKWidget interactorStyle problem

Massi Massinissa.Bandou at USherbrooke.ca
Thu Aug 30 01:35:44 EDT 2012


Hello,
I have a Qt project and I'm trying to read dicom images according this
example:
http://www.itk.org/Wiki/VTK/Examples/Cxx/IO/ReadDICOMSeries
This example works perfectly.  
I want to display the result into a *QVTKWidget*, it shows me the first
dicom image but when I press "up" my program crashes so I'm expecting the
problem is related with the myinteractorStyle. Can anyone help me figure
this out or give me a hint how to fix it? 
I'm not familiar with interactorstyle but here is my code:

I kept the same code of "class myVtkInteractorStyleImage"

int main(int argc, char* argv[])
{
    vtkSmartPointer<vtkDICOMImageReader> reader =
vtkSmartPointer<vtkDICOMImageReader>::New();
    reader->SetDirectoryName(filename);
    reader->Update();
   
/******************************Visualization*******************************/
    vtkSmartPointer<vtkImageViewer2> imageViewer =
vtkSmartPointer<vtkImageViewer2>::New();
    imageViewer->SetInputConnection(reader->GetOutputPort());
    
    vtkSmartPointer<vtkTextProperty> sliceTextProp =
vtkSmartPointer<vtkTextProperty>::New();
    sliceTextProp->SetFontFamilyToCourier();
    sliceTextProp->SetFontSize(20);
    sliceTextProp->SetVerticalJustificationToBottom();
    sliceTextProp->SetJustificationToLeft();
    
    vtkSmartPointer<vtkTextMapper> sliceTextMapper =
vtkSmartPointer<vtkTextMapper>::New();
    std::string msg = StatusMessage::Format(imageViewer->GetSliceMin(),
imageViewer->GetSliceMax());
    sliceTextMapper->SetInput(msg.c_str());
    sliceTextMapper->SetTextProperty(sliceTextProp);
    
    vtkSmartPointer<vtkActor2D> sliceTextActor =
vtkSmartPointer<vtkActor2D>::New();
    sliceTextActor->SetMapper(sliceTextMapper);
    sliceTextActor->SetPosition(15,10);
    
    vtkSmartPointer<vtkTextProperty> usageTextProp =
vtkSmartPointer<vtkTextProperty>::New();
    usageTextProp->SetFontFamilyToCourier();
    usageTextProp->SetFontSize(14);
    usageTextProp->SetVerticalJustificationToTop();
    usageTextProp->SetJustificationToLeft();
    
    vtkSmartPointer<vtkTextMapper> usageTextMapper =
vtkSmartPointer<vtkTextMapper>::New();
    usageTextMapper->SetInput("-Slice with mouse wheel\n or Up/Down-Key\n"
    "-Zoom with pressed right\n mouse button while dragging");
    usageTextMapper->SetTextProperty(usageTextProp);
    
    vtkSmartPointer<vtkActor2D> usageTextActor =
vtkSmartPointer<vtkActor2D>::New();
    usageTextActor->SetMapper(usageTextMapper);
   
usageTextActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedDisplay();
    usageTextActor->GetPositionCoordinate()->SetValue(0.05,0.95);
    
    //vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
    vtkSmartPointer<myVtkInteractorStyleImage> myInteractorStyle =
vtkSmartPointer<myVtkInteractorStyleImage>::New();
    
    myInteractorStyle->SetImageViewer(imageViewer);
    myInteractorStyle->SetStatusMapper(sliceTextMapper);
    //imageViewer->SetupInteractor(renderWindowInteractor);
    //renderWindowInteractor->SetInteractorStyle(myInteractorStyle);
    imageViewer->GetRenderer()->AddActor2D(sliceTextActor);
    imageViewer->GetRenderer()->AddActor2D(usageTextActor);
    
   
widget.qvtkWidget->GetRenderWindow()->GetInteractor()->SetInteractorStyle(myInteractorStyle);
   
imageViewer->SetRenderWindow(widget.qvtkWidget->GetInteractor()->GetRenderWindow());
    widget.qvtkWidget->update();
}

Thank you for your help!

Massi



--
View this message in context: http://vtk.1045678.n5.nabble.com/reading-DICOM-series-QVTKWidget-interactorStyle-problem-tp5715676.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list