[vtkusers] Problem with vtkPicker

Kevin Teich kteich at nmr.mgh.harvard.edu
Fri Aug 23 13:45:48 EDT 2002


I am having difficulty with vtkPicker, particularly
vtkPointPicker. I'm working on a basic MRI slice viewer. I have an
actor made up of a texture and a plane (256x256 resolution, scaled to
256x256).  It's the only actor I have in the space. I want to click on
it and get some kind of coordinate or point number that I can
transform (if necessary) into an index into the 256x256 space
regardless of the orientation of the plane (mainly so I can let the
user pan and zoom). When I use vtkPointPicker this seems to work when
the camera is at its initial setup but once I start interacting with
the scene, it starts giving inconsistent picks. It seems as the picker
doesn't know about the camera changes being made to the scene and is
picking based on the original actor's location and camera setup. Here
is the code I am using to set up the picker:

    set picker [vtkPointPicker _picker]
    $picker AddObserver EndPickEvent PickPointCB
    $picker SetTolerance 0.1

    set interactor [vtkRenderWindowInteractor _interactor]
    $interactor SetRenderWindow $renderWindow
    $interactor SetPicker $picker
    
    bind $rwRender <KeyPress-p> \
	"$picker Pick %x %y 0 $renderer;"

I can provide mroe code if necessary. I feel like there should be call
to 'connect' a picker to the renderer or camera somehow, but none of
the picker sample code I've seen seems to do this. Am I missing
something? Thanks.

-- 
Kevin Teich





More information about the vtkusers mailing list