[vtkusers] Problem with getting pointId using vtkPointPicker

Łukasz Tutaj ltutaj at wp.pl
Wed Oct 5 08:42:10 EDT 2005


Hi vtkUsers.

    I have problem with getting pointId using vtkPointPicker. I display 
images from computed tomography. I added observer to interactor to get 
position of left button mouse click event and I want to get pointId with 
selected soordinates. The class performing callback is added below. Do 
you have some ideas what is wrong? I get right coordinates but picking 
works wrong. Any suggestions?

Thanks in advance.
Łukasz Tutaj

class vtkMyCallback : public vtkCommand
{
public:
    vtkRenderer * m_ren;
    int x, y;
  static vtkMyCallback *New()
    { return new vtkMyCallback; }
  virtual void Execute(vtkObject *caller, unsigned long, void*)
    {
      vtkRenderWindowInteractor *iren = 
reinterpret_cast<vtkRenderWindowInteractor*>(caller);
            x = iren->GetEventPosition()[0];
            y = iren->GetEventPosition()[1];
            vtkPointPicker *picker = vtkPointPicker::New();
            int succed = picker->Pick(x, y, 0, m_ren);
            int pointId = picker->GetPointId();
            cout << "(" << x << ", " << y << ") " << succed << " " << 
pointId << endl;
    }
        void SetRenderer(vtkRenderer * ren)
        {
            m_ren = ren;
        }
};





More information about the vtkusers mailing list