[vtkusers] vtkSeedWidget is not shown on QVTKWidget

Miguel Sotaquirá msotaquira at gmail.com
Wed Mar 28 01:06:07 EDT 2012


Hi everybody,

I'm rendering a 2D image in a QVTKWidget and I want to manually select a
few seed points from this image using vtkSeedWidget. I've created the
seedWidget callback using this example
http://www.vtk.org/Wiki/VTK/Examples/Widgets/SeedWidgetImage).

The problem is that when executing the pipeline the 2D image is correctly
rendered on the QVTKWidget but the seedWidget is simply not working, as if
it was disabled. Is there's something wrong in my pipeline? Here's part of
my code:

// Create  actor, renderer and interactor style for the 2D image
vtkSmartPointer<vtkImageActor> actor2D =
vtkSmartPointer<vtkImageActor>::New();
actor2D->SetInput(reslicer->GetOutput());

vtkSmartPointer<vtkRenderer> renderer2D =
vtkSmartPointer<vtkRenderer>::New();
renderer2D->AddActor(actor2D);

vtkSmartPointer<vtkInteractorStyleImage> iStyle
= vtkSmartPointer<vtkInteractorStyleImage>::New();
// Connect everything to the qvtkwidget
this->ui->viewer2D->GetRenderWindow()->AddRenderer(renderer2D);
this->ui->viewer2D->GetRenderWindow()->GetInteractor()->SetInteractorStyle(iStyle);
renderer2D->ResetCamera();

this->ui->viewer2D->show();

//
// Setup seed widget and render
//
// Representation
vtkSmartPointer<vtkPointHandleRepresentation2D> handleRepresentation
= vtkSmartPointer<vtkPointHandleRepresentation2D>::New();
handleRepresentation->GetProperty()->SetColor(1,0,0);
vtkSmartPointer<vtkSeedRepresentation> seedRepresentation
= vtkSmartPointer<vtkSeedRepresentation>::New();
seedRepresentation->SetHandleRepresentation(handleRepresentation);
// The widget
vtkSmartPointer<vtkSeedWidget> seedWidget
= vtkSmartPointer<vtkSeedWidget>::New();
seedWidget->SetInteractor(this->ui->viewer2D->GetRenderWindow()->GetInteractor());
seedWidget->SetRepresentation(seedRepresentation);
// Callback
vtkSmartPointer<vtkSeedCallback> scbk
= vtkSmartPointer<vtkSeedCallback>::New();
scbk->SetWidget(seedWidget);

seedWidget->AddObserver( vtkCommand::PlacePointEvent, scbk );
seedWidget->AddObserver( vtkCommand::InteractionEvent, scbk );
seedWidget->On();

Thanks for your suggestions,

Miguel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120328/1e12653f/attachment.htm>


More information about the vtkusers mailing list