Hi Daniel, <br><br>Using the macro VTK_CREATE(vtkClass, var) means:<br><br>vtkSmartPointer&lt;vtkClass&gt; var = vtkSmartPointer&lt;vtkClass&gt;::New()<br><br>It&#39;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&#39;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">&lt;<a href="mailto:haehn@bwh.harvard.edu">haehn@bwh.harvard.edu</a>&gt;</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 &lt;&lt; &quot;PlaceSeed&quot; &lt;&lt; x &lt;&lt; &quot;:&quot; &lt;&lt; y &lt;&lt; std::endl;<br>
<br>
  VTK_CREATE(vtkSphereHandleRepresentation, handle);<br>
  handle-&gt;GetProperty()-&gt;SetColor(1,0,0);<br>
  handle-&gt;SetHandleSize(5);<br>
<br>
  VTK_CREATE(vtkSeedRepresentation, rep);<br>
  rep-&gt;SetHandleRepresentation(handle);<br>
<br>
  //seed widget<br>
  VTK_CREATE(vtkSeedWidget, seedWidget);<br>
  //seedWidget-&gt;CreateDefaultRepresentation();<br>
  seedWidget-&gt;SetRepresentation(rep);<br>
<br>
  seedWidget-&gt;SetInteractor(this-&gt;GetInteractor());<br>
  seedWidget-&gt;SetCurrentRenderer(this-&gt;GetRenderer());<br>
<br>
  double p[3];<br>
  p[0]=x;<br>
  p[1]=y;<br>
  p[2]=0;<br>
  //seedWidget-&gt;ProcessEventsOff();<br>
<br>
  vtkHandleWidget* newhandle = seedWidget-&gt;CreateNewHandle();<br>
<br>
  vtkHandleRepresentation::SafeDownCast(newhandle-&gt;GetRepresentation())-&gt;SetDisplayPosition(p);<br>
<br>
<br>
  //this-&gt;GetRenderer()-&gt;AddActor(newhandle-&gt;GetRepresentation());<br>
<br>
  //this-&gt;RequestRender();<br>
<br>
  seedWidget-&gt;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&#39;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>