[vtkusers] picking points in 3D data

Aaron Cois aaron_vtk at yahoo.com
Mon Oct 31 16:35:28 EST 2005


I have some 3D image data, and i'd like to allow the
user to pick a point in that data.  Looking at some
examples and going through the user list archives, i
can to the conclusion that I should be able to use
vtkPointPicker in the following way:

-------------------------------------------------
// init picker
  vtkPointPicker *picker = vtkPointPicker::New();
  picker->SetTolerance(0.5);
  GetInputRenderWindowInteractor()->SetPicker(picker);

  // init callback
  vtkMyCallback *callback = vtkMyCallback::New();

GetInputRenderWindowInteractor()->AddObserver(vtkCommand::EndPickEvent,
callback);

  // start interaction - NOTE: I have tried both
versions of the line below with no success

  //GetInputRenderWindowInteractor()->Start();

GetInputRenderWindowInteractor()->StartPickCallback();

----------------------------------------------------

Note that the interactors here are
vtkFlRenderWindowInteractors (could this be the
problem?).  

The callback is not being called.  i've tried various
other events to observe (StartInteractionEvent,
PickEvent, etc) with no success.  The callback code is
below, so you can verify that it is correct.  Can
anyone offer any help on this?  

I'd guess the alternative is to create a separate
callback to observe each vtkImagePlaneWidget, but that
seems more complicated than should be necessary...


------------------------------------
//Callback
class vtkMyCallback : public vtkCommand
{
public:
  static vtkMyCallback *New() 
    { return new vtkMyCallback; }
  void Delete()
    { delete this; }
  virtual void Execute(vtkObject *caller, unsigned
long, void*)
  {
    std::cerr << "callback initiated" << std::endl;
    vtkFlRenderWindowInteractor *iren =
reinterpret_cast<vtkFlRenderWindowInteractor*>(caller);
    vtkPointPicker *picker = (vtkPointPicker
*)iren->GetPicker();
    std::cout << "PointId: " << picker->GetPointId()
<< std::endl;
  }
};
-----------------------------------------------


		
__________________________________ 
Start your day with Yahoo! - Make it your home page! 
http://www.yahoo.com/r/hs



More information about the vtkusers mailing list