[vtkusers] Picking and identifying Actors (and it's custodian data object)‏

Gary Holton gary_holton at hotmail.com
Mon Jan 10 11:26:09 EST 2011



I have a rendering
scene with more than a hundred pickable VTK Actors (which can be modified/moved/changed when selected).

Each VTK
Actor will be closely linked (conceptually speaking!) with an object, 
one for each individual Actor, which contains data and procedures to 
create and modify the Actor.
So
 when an Actor is picked I would like to quickly also find the object 
that is the "custodian" the Actor and not only the Actor itself.

 The idea is
that PropPicker is used to identify the Actor, and from that it’s “custodian" (some python pseudocode below)


Anyone who knows
an easy way to make this work (something essential that I have missed)?






Thanks and Rgds Gary
--------------
 #python pseudocode++:
 

def takeAction(obj=custodian:        #do something cool

def _LeftButtonPressEvent(iren):

        #Find picked Actor

        (x, y) = iren.GetEventPosition()

        self.propPick = vtk.vtkPropPicker()

        selectedActor = self.propPick.GetActor()
        #Find Actor's 'custodian' object        custodian = <HOW TO FIND THIS ONE??>         takeAction(custodian)


#Create 'custodian' objects for each vtkActor#which also create the Actors immediately (and the pipeline behind)
item1 = Item(resolution=5, type='circle', radius=0.9)item2 = Item(resolution=10, type='shoulder', width=4.2, length=7.8)

#retrieve actors
actor1 =
item1.GetActor()

actor2 = item2.GetActor()


#rendering scene
ren = vtk.vtkRenderer()
renWin = vtk.vtkRenderWindow()
renWin.SetSize(700,700)
renWin.AddRenderer(self.ren)
iren = vtk.vtkRenderWindowInteractor()
iren.SetRenderWindow(self.renWin)

iren.SetInteractorStyle(None)
iren.AddObserver("LeftButtonPressEvent", ButtonEvent)
ren.AddActor(actor1)ren.AddActor(actor2) 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110110/d05b6b5c/attachment.htm>


More information about the vtkusers mailing list