Hi Daniel, <br><br>Using the macro VTK_CREATE(vtkClass, var) means:<br><br>vtkSmartPointer<vtkClass> var = vtkSmartPointer<vtkClass>::New()<br><br>It's also important to understand the smartpointer object will go out of scope when the function  <span style="font-family: courier new,monospace;">PlaceSeed</span> seed returns. Assuming the created object isn't referenced somewhere else, it will be deleted !<br>

<br>Just make sure you keep a reference of your object ... <br><br>Thks<br>Jc<br><br><div class="gmail_quote">On Tue, Aug 10, 2010 at 11:55 AM, Daniel Haehn <span dir="ltr"><<a href="mailto:haehn@bwh.harvard.edu">haehn@bwh.harvard.edu</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Hi,<br>
<br>
I try to use the vtkSeedWidget in a displayableManager of Slicer4 with the following code:<br>
<br>
<br>
// Create vtkSeedWidget with display coordinates and directly add one seed<br>
void vtkMRMLAnnotationDisplayableManager::PlaceSeed(double x, double y)<br>
{<br>
  std::cout << "PlaceSeed" << x << ":" << y << std::endl;<br>
<br>
  VTK_CREATE(vtkSphereHandleRepresentation, handle);<br>
  handle->GetProperty()->SetColor(1,0,0);<br>
  handle->SetHandleSize(5);<br>
<br>
  VTK_CREATE(vtkSeedRepresentation, rep);<br>
  rep->SetHandleRepresentation(handle);<br>
<br>
  //seed widget<br>
  VTK_CREATE(vtkSeedWidget, seedWidget);<br>
  //seedWidget->CreateDefaultRepresentation();<br>
  seedWidget->SetRepresentation(rep);<br>
<br>
  seedWidget->SetInteractor(this->GetInteractor());<br>
  seedWidget->SetCurrentRenderer(this->GetRenderer());<br>
<br>
  double p[3];<br>
  p[0]=x;<br>
  p[1]=y;<br>
  p[2]=0;<br>
  //seedWidget->ProcessEventsOff();<br>
<br>
  vtkHandleWidget* newhandle = seedWidget->CreateNewHandle();<br>
<br>
  vtkHandleRepresentation::SafeDownCast(newhandle->GetRepresentation())->SetDisplayPosition(p);<br>
<br>
<br>
  //this->GetRenderer()->AddActor(newhandle->GetRepresentation());<br>
<br>
  //this->RequestRender();<br>
<br>
  seedWidget->On();<br>
<br>
}<br>
<br>
<br>
I tried different scenarios (see comments) but with the code above the small sphereHandles appear shortly and then directly disappear again.<br>
<br>
If I add the vtkHandleRepresentation as an actor to the renderer, the sphereHandles appear until I rotate or zoom the 3D Render Window.<br>
<br>
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.<br>


<br>
<br>
Thank you so much!!<br>
<font color="#888888"><br>
Daniel</font></blockquote></div><br><br clear="all"><br>-- <br>Phone: 1-518-836-2174<br>Ext: 304<br>