[vtkusers] How to identify picked objects in a scene?

Cory Quammen cquammen at cs.unc.edu
Sun Mar 9 23:26:28 EDT 2008


Steffen,

Can you just use the pointer as the ID of the vtkPolyData? If you have
just a few actors, then a set of if statements like you give might
satisfy your needs. If you have a bunch of actors and a bunch of
different actions, you could set up a hash table with actors as keys
and function pointers -- which represent actions to be taken -- as
values. When you get the vtkPolyData from the picked actor, you can
just look up the appropriate function in this hash table and execute
it. Alternatively, you could create a hash table again with the
vtkPolyData pointers as keys, but this time with integer IDs as values
and switch the action based on the ID returned from a lookup to that
hash table.

Hope that helps,
Cory

On Sun, Mar 9, 2008 at 6:36 PM,  <stoeltze at isg.cs.uni-magdeburg.de> wrote:
> Sorry that I could not make myself clear. I do exactly what you describe :
>  getting the mapper, getting its inputs and casting it with vtkPolyData. My
>  problem is, that I have several actors in the scene, each of them with an
>  associated vtkPolyData. How do I know which one I picked? I want to to
>  something like that:
>
>  IF Actor (vtkPolyData) x was picked DO action A
>  IF Actor (vtkPolyData) y was picked DO action B
>  ...
>
>  For that purpose, I need to assign an ID to the actor, or in my case it
>  would be even better to have an ID associated to the vtkPolyData.
>
>  Hope, that clarifies things.
>
>  Steffen
>
>
>
>



-- 
Cory Quammen
Department of Computer Science
University of North Carolina at Chapel Hill
http://www.cs.unc.edu/~cquammen



More information about the vtkusers mailing list