[vtkusers] vtkPicker and PickEvent

Mike Jackson maillist at bluequartz.net
Tue Dec 13 19:15:25 EST 2005


I am trying to use the built in picker in renderer. I put the mouse  
over my scene and hit the "p"
  key and a red box shows up around my vtkActor which is really neat.  
Now how do I actually get any information from that? Looking through  
the docs I tried to implement a subclass of vtkCommand:

class PickListener : public vtkCommand
{
   public:
     ~PickListener();

   void Execute (vtkObject* caller, unsigned long eventId, void  
*callData);

   private:
      void *_document;  //Really a PFDocument object
};

And when I create each actor in the scene I add it there.

PickListener *pickEvent = new PickListener();
pickEvent->setDocument( (void *)self);
for (unsigned int i = 0; i < numRegions; ++i)
{
  // code above here...
   vtkActor *dataActor = vtkActor::New();
   dataActor->AddObserver(vtkCommand::PickEvent, pickEvent );
   // code below here
}

Now what happens is that for every "Pick" I get multiple calls to the  
Execute method, each call has a different "caller" associated with  
it. I figured this was because the "ray" was intersecting multiple  
actors. How do I sort out which actor was really "picked"?  
vtkRenderWindow gets it right?

---
Mike Jackson
mike _at_ bluequartz dot net


---
Mike Jackson
mike _at_ bluequartz dot net





More information about the vtkusers mailing list