Hi,<br>I am trying to use a combination of vtkRenderWindow and vtkSelectionList to pick vertices and edges of a vtkGraph I am displaying. I will add/delete vertices/edges after I get the ids of selected components.<br><br>
The first problem is:When I drag the mouse to make selections, only the edge colors change. As a note, the vertices are small spheres. Shouldn&#39;t vertex colors change as well?<br>&nbsp;<br>The second problem is if I try to get the ids of objects being selected, I never get any single id for vertices. I suspect that when I click on a sphere, All the points(or maybe small lines) that construct each sphere are being picked. How can I just get the ids of vertices? By the way, picking succeeds only for one vertex. If I do it for several vertices and if there are edges among them, only the edges are picked!<br>
<br>What is the best way of extracting vertices and edges from the vtkSelectionLink? I show how I attempt to do this in the following code. Any suggestions? <br><br>Thanks a lot for your time and help.<br>Aytekin<br><br><br>
<br>Here is the first part of my code:<br>...<br>VTK_CREATE(vtkCallbackCommand,isPicked);<br>&nbsp;&nbsp;&nbsp; isPicked-&gt;SetCallback(processVertexSelection);<br>&nbsp;&nbsp;&nbsp; VTK_CREATE(vtkSelectionLink,link);<br>&nbsp;&nbsp;&nbsp; VTK_CREATE(vtkSurfaceRepresentation, selections);<br>
&nbsp;&nbsp;&nbsp; selections-&gt;SetInputConnection(poly-&gt;GetOutputPort());<br>&nbsp;&nbsp;&nbsp; selections-&gt;SetSelectionLink(link);<br>&nbsp;&nbsp;&nbsp; view-&gt;AddRepresentation(selections);<br>&nbsp;&nbsp;&nbsp; view-&gt;Update();<br>&nbsp;&nbsp;&nbsp; isPicked-&gt;SetClientData((void *)static_cast&lt;vtkSelectionLink*&gt;(link));<br>
<br>&nbsp;&nbsp;&nbsp; iren-&gt;AddObserver(vtkCommand::LeftButtonReleaseEvent,isPicked);<br>...<br><br><br>And some parts of the the function to be called after picking:<br><br>void processVertexSelection(vtkObject* caller, unsigned long event, <br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; void* clientdata, void* callerdata) {<br><br><br>&nbsp;&nbsp;&nbsp; vtkSelection *p = static_cast&lt;vtkSelectionLink*&gt;(clientdata)-&gt;GetSelection();<br>&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; printf(&quot;I got %d nodes\n&quot;,p-&gt;GetNumberOfNodes());<br>
&nbsp;&nbsp;&nbsp; for(int counter=0; counter&lt;p-&gt;GetNumberOfNodes(); counter++)<br>&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkSelectionNode *n = p-&gt;GetNode(counter);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //n-&gt;SetFieldType(vtkSelectionNode::EDGE);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; //n-&gt;SetContentType(vtkSelectionNode::INDICES);<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; printf(&quot;FieldType for %d is %d\n&quot;,counter,n-&gt;GetFieldType());<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; cout&lt;&lt;&quot;Num of Tuples: &quot;&lt;&lt;n-&gt;GetSelectionList()-&gt;GetNumberOfTuples();<br>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; cout&lt;&lt;endl&lt;&lt;endl;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; vtkAbstractArray* arra = n-&gt;GetSelectionList();<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; for (int i=0;i&lt;n-&gt;GetSelectionList()-&gt;GetNumberOfTuples();i++) {<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;vtkVariant aaa=arra-&gt;GetVariantValue(i);<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;cout&lt;&lt;&quot;Type : &quot;&lt;&lt;n-&gt;GetContentType()&lt;&lt;endl;<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;cout&lt;&lt;&quot;Variant : &quot;&lt;&lt;i&lt;&lt;&quot; &quot;&lt;&lt;aaa.ToInt()&lt;&lt;endl;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;cout&lt;&lt;endl&lt;&lt;endl;<br>&nbsp;&nbsp;&nbsp; }<br>}<br><br><br clear="all"><br>-- <br>My web page: <a href="http://www.cs.rpi.edu/~vargua">http://www.cs.rpi.edu/~vargua</a><br>