[vtk-developers] vtkSeedWidget - seeds disappear

Daniel Haehn haehn at bwh.harvard.edu
Tue Aug 10 11:55:10 EDT 2010


Hi,

I try to use the vtkSeedWidget in a displayableManager of Slicer4 with the following code:


// Create vtkSeedWidget with display coordinates and directly add one seed
void vtkMRMLAnnotationDisplayableManager::PlaceSeed(double x, double y)
{
  std::cout << "PlaceSeed" << x << ":" << y << std::endl;

  VTK_CREATE(vtkSphereHandleRepresentation, handle);
  handle->GetProperty()->SetColor(1,0,0);
  handle->SetHandleSize(5);

  VTK_CREATE(vtkSeedRepresentation, rep);
  rep->SetHandleRepresentation(handle);

  //seed widget
  VTK_CREATE(vtkSeedWidget, seedWidget);
  //seedWidget->CreateDefaultRepresentation();
  seedWidget->SetRepresentation(rep);

  seedWidget->SetInteractor(this->GetInteractor());
  seedWidget->SetCurrentRenderer(this->GetRenderer());

  double p[3];
  p[0]=x;
  p[1]=y;
  p[2]=0;
  //seedWidget->ProcessEventsOff();

  vtkHandleWidget* newhandle = seedWidget->CreateNewHandle();

  vtkHandleRepresentation::SafeDownCast(newhandle->GetRepresentation())->SetDisplayPosition(p);


  //this->GetRenderer()->AddActor(newhandle->GetRepresentation());

  //this->RequestRender();

  seedWidget->On();

}


I tried different scenarios (see comments) but with the code above the small sphereHandles appear shortly and then directly disappear again. 

If I add the vtkHandleRepresentation as an actor to the renderer, the sphereHandles appear until I rotate or zoom the 3D Render Window.

What am I doing wrong? As a side note: it does not make a difference if I call RequestRender() or not. I don't know if I might be using VTK wrong or if there is a problem in combination with the displayableManager.


Thank you so much!!

Daniel


More information about the vtk-developers mailing list