[vtkusers] picking actor

Jeff Lee jeff at cdnorthamerica.com
Wed Apr 2 16:27:41 EST 2003


Hi,
Is there some form of instanceof or dynamic cast in python (i'm sure 
there is)?  If so, you could cast the actor to your concrete type and 
then ask it for the appropriate info.  Not elegant, but functional.
-Jeff

John Hunter wrote:

>I have a class Marker that is derived from vtk.vtkActor in python, and
>a scene that is populated with a number of these markers and some
>other actors that I don't want to pick.  I pick a marker with
>
>    picker = vtk.vtkPropPicker()
>    picker.PickProp(x, y, renderer, markers)
>    actor = picker.GetActor()
>    if actor is None: return
>
>where markers is a vtkActorCollection of the actors I'm interested in.
>This code successfully picks the actor under point; eg, if I call
>actor.SetVisibility(0), it becomes invisible.
>
>However, when I get the string representation of the actor, it reports
>itself as a vtkOpenGLActor, and does not have the attributes of my
>derived class.  I need to be able to get the instance of my derived
>class.  I can imagine a way to hack this out, eg by comparing some
>attribute of the vtkOpenGLActor with the instances of my Marker class
>(like the center, which will be unique for my markers), but I suspect
>there is an elegant, right way to do it.
>
>Thanks,
>John Hunter
>_______________________________________________
>This is the private VTK discussion list. 
>Please keep messages on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/vtkusers
>
>
>  
>

-- 
Jeff Lee
Software Engineer
Computational Dynamics North America Ltd
21 Lafayette Street, Suite 230
Lebanon NH 03766 USA
fax:   603 643 9994
phone: 603 643 9993 x109
http://www.cd-adapco.com





More information about the vtkusers mailing list