[vtkusers] picking actor
    John Hunter 
    jdhunter at ace.bsd.uchicago.edu
       
    Thu Apr  3 13:35:11 EST 2003
    
    
  
>>>>> "Prabhu" == Prabhu Ramachandran <prabhu at aero.iitm.ernet.in> writes:
    Prabhu> That is a little surprising.  I'm way out of touch on this
    Prabhu> but the following fragment works fine for me with VTK off
    Prabhu> CVS, Python2.2.
Yep, that would work fine for me too.  My case is a little different.
My class is derived from vtk.Actor and I am dealing with an actor
*returned by a call a vtk.vtkPropPicker*.   It's only after it comes
back from the picker that I lose the derived attributes.
Here is how I am working around it now.  When I add my marker to the
vtkActorCollection, I add the original object to a dictionary with the
address as key.
    key = marker.GetAddressAsString('Marker')
    self.markerMap[key] = marker
    self.markers.AddItem(marker)
    self.ren.AddActor(marker)
After I pick the actor and get a vtkOpenGLActor back, I can get the
original actor back with it's special attributes with:
    picker = vtk.vtkPropPicker()
    picker.PickProp(x, y, renderer, self.markers)
    actor = picker.GetActor()
    key = actor.GetAddressAsString('Marker')
    marker = self.markerMap[key]
    print marker.call_some_derived_func()
This works for now, but if someone knows a better way, I'm eager to
hear it.
    Prabhu> p.s. I'm using the excellent IPython interpreter
Me too :-)
John Hunter
    
    
More information about the vtkusers
mailing list