[vtkusers] vtkResliceImageViewer and vtkCornerAnnotator

Ale notinmyhead at gmail.com
Thu May 24 06:37:40 EDT 2012


Hello,

I connected a  vtkResliceImageViewer and a vtkCornerAnnotetor, setting up few pre-defined annotation such as "<slice_and_max>" using the inclued vtk Example as skeleton. The total number of slices that is displayed is correct but the current slice number behaves wrongly, as instance: (i) the first two slices don't change the slice number and, (ii) the last slice is counted 23 (instead of 24) and (iii) once reached the last slice, if the user goes back to the previous one, it'll get a 24 as slice number, which is clearly wrong.

Did I miss some extra set up?

I paste (part of) the widget code:

 MRIWidget::MRIWidget(QWidget *parent, vtkImageData * image, QString wtitle) :
    QWidget(parent),
    ui(new Ui::MRIWidget)
{
    ui->setupUi(this);

    this->vtkImage = image;

    this->viewer = vtkSmartPointer< vtkResliceImageViewer >::New();

    /* Set the Viewer Input */
    this->viewer->SetInput(vtkImage);
    this->viewer->GetRenderer()->SetViewport(0, 0, 1, 1);
    this->ui->mainImage->SetRenderWindow(viewer->GetRenderWindow());
    this->viewer->SetupInteractor(ui->mainImage->GetRenderWindow()->GetInteractor());

    this->renderer = viewer->GetRenderer();
    this->render_window = viewer->GetRenderWindow();

    this->annotator = vtkSmartPointer<vtkCornerAnnotation>::New();
    
    this->setupAnnotator();
    this->displayImage();
    
}
}
void MRIWidget::displayImage() {
    /* update the view */
    this->updateAnnotator();

    this->update();
}
void MRIWidget::setupAnnotator() {
    this->annotator->SetLinearFontScaleFactor( 2 );
    this->annotator->SetNonlinearFontScaleFactor( 1 );
    this->annotator->SetMaximumFontSize( 13 );
    this->annotator->GetTextProperty()->SetColor( 1,1,1);
}
void MRIWidget::updateAnnotator() {
    this->annotator->SetText( 0, "<slice_and_max>");
    this->annotator->SetText( 1, "<slice_pos>" );
    this->annotator->SetText( 2, "title" );
    this->annotator->SetText( 3, "<level>" );
    this->renderer->AddViewProp(this->annotator);
    this->render_window->Render();
}
  


More information about the vtkusers mailing list