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't vertex colors change as well?<br> <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> isPicked->SetCallback(processVertexSelection);<br> VTK_CREATE(vtkSelectionLink,link);<br> VTK_CREATE(vtkSurfaceRepresentation, selections);<br>
selections->SetInputConnection(poly->GetOutputPort());<br> selections->SetSelectionLink(link);<br> view->AddRepresentation(selections);<br> view->Update();<br> isPicked->SetClientData((void *)static_cast<vtkSelectionLink*>(link));<br>
<br> iren->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>
void* clientdata, void* callerdata) {<br><br><br> vtkSelection *p = static_cast<vtkSelectionLink*>(clientdata)->GetSelection();<br> <br> printf("I got %d nodes\n",p->GetNumberOfNodes());<br>
for(int counter=0; counter<p->GetNumberOfNodes(); counter++)<br> {<br> <br> vtkSelectionNode *n = p->GetNode(counter);<br> //n->SetFieldType(vtkSelectionNode::EDGE);<br> //n->SetContentType(vtkSelectionNode::INDICES);<br>
printf("FieldType for %d is %d\n",counter,n->GetFieldType());<br> cout<<"Num of Tuples: "<<n->GetSelectionList()->GetNumberOfTuples();<br> cout<<endl<<endl;<br>
<br> vtkAbstractArray* arra = n->GetSelectionList();<br> for (int i=0;i<n->GetSelectionList()->GetNumberOfTuples();i++) {<br> vtkVariant aaa=arra->GetVariantValue(i);<br> cout<<"Type : "<<n->GetContentType()<<endl;<br>
cout<<"Variant : "<<i<<" "<<aaa.ToInt()<<endl;<br> }<br> cout<<endl<<endl;<br> }<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>