[vtkusers] Get a list of selected graph vertices

Jim Peterson jimcp at cox.net
Sun Sep 19 14:19:21 EDT 2010


Dav
You added the content of your email. The Selector and GetSelector() 
method are attribute and method of vtkRenderer. I would expect the view 
to use view->GetRenderer()->GetSelector() to access the vtkHardwareSelector.

The vtkHardwareSelector has pretty thorough documentation, and has this 
general usage description:

> manager for OpenGL-based selection.
>
> vtkHardwareSelector <a00773.html> is a helper that orchestrates color 
> buffer based selection. This relies on OpenGL. vtkHardwareSelector 
> <a00773.html> can be used to select visible cells or points within a 
> given rectangle of the RenderWindow. To use it, call in order:
>
>     * SetRenderer() <a00773.html#0cda3066e13f754e4029cca91f4fe8a7> -
>       to select the renderer in which we want to select the cells/points.
>     * SetArea() <a00773.html#516071b17c03ff9cd0149f1f8da9a2ac> - to
>       set the rectangular region in the render window to select in.
>     * SetFieldAssociation()
>       <a00773.html#03b9cdd86eaace2286a5c64cf8eb6cbb> - to select the
>       attribute to select i.e. cells/points etc.
>     * Finally, call Select()
>       <a00773.html#e7596bcdd2db5316d660406670a28f24>. Select will
>       cause the attached vtkRenderer <a01708.html> to render in a
>       special color mode, where each cell/point is given it own color
>       so that later inspection of the Rendered Pixels can determine
>       what cells are visible. Select()
>       <a00773.html#e7596bcdd2db5316d660406670a28f24> returns a new
>       vtkSelection <a01755.html> instance with the cells/points selected.
>
In the broken example we are only calling Select(). Assuming the 
vertices in the graph can be selected by a vtkHardwareSelector,  I would 
expect if we are handling the mouse events, we would need to collect the 
mouse location as leftbuttondown and then call SetArea() at left button 
up with the new location to specify the area, and perhaps the 
SetFieldAssociation() to pick vertices if that is applicable.
 
There are restrictions documented for the vtkHardwareSelector, I am not 
sure graph vertices are candidates for selection.

Hope that helps,
Jim

David Doria wrote:
> On Sun, Sep 19, 2010 at 1:12 PM, Jim Peterson <jimcp at cox.net> wrote:
>   
>> David,
>> The example compiles and executes, and has no other description of what is
>> intended, so my read is "it works".  I cannot determine what you think the
>> intended result is, we appear to be adding two identical vertices, (have you
>> verified v1 and v2 are actually different?)  and creating two identical
>> edges. could you describe what is expected from this code?
>>
>> thanks,
>> Jim
>>     
>
> Hi Jim,
>
> I added a modified description of my original post to the top of the
> example: http://www.vtk.org/Wiki/VTK/Examples/Cxx/Broken/Graphs/SelectedVertices
>
> FYI, when the link contains "Broken", the only way to get to the
> example is from the "Broken" section
> (http://www.vtk.org/Wiki/VTK/Examples/Cxx#Broken.2FMissing_Examples_.28Please_write.2Ffix_me.21.29)
> so there should be no reasonable expectation by a viewer that it
> should work :) haha. Please feel free to adopt some of these broken
> examples as you have time!
>
> What I am trying to do is simply get a list (or output) the IDs of the
> vertices that the user selects. Exactly like this:
> http://www.vtk.org/Wiki/VTK/Examples/Cxx/Picking/HighlightSelectedPoints
> but with a graph.
>
> Thanks,
>
> David
>
>   




More information about the vtkusers mailing list