[vtkusers] vtkinteractor (point picker) in Qt

mbcx9rb9 richard.j.brown at live.co.uk
Tue Dec 30 10:24:15 EST 2014


Hi all,

I am trying to change the interactor so that the left click returns the x,y
coordinates of a 2D DICOM slice. It seems simple enough, but copying and
pasting the relevant section of the PointPicker example code doesn't work
(the example itself works). I haven't even initialised the interactor or set
it to the QVTKWidget. Does it change anything because I'm doing it in Qt?

I'm a little at a loss as to what's gone wrong when it's almost a carbon
copy from the example. Commenting out the lines starting vtkTypeMacro and
vtkStandardNewMacro enable it to build without any problems, but obviously
the interactor then wouldn't work. Any help would be greatly appreciated.

Here's what I've been trying:

class MouseInteractorStylePP : public vtkInteractorStyleImage
{
  public:
    static MouseInteractorStylePP* New();
    vtkTypeMacro(MouseInteractorStylePP, vtkInteractorStyleImage);

    virtual void OnLeftButtonDown()
    {
      std::cout << "Picking pixel: " <<
this->Interactor->GetEventPosition()[0] << " " <<
this->Interactor->GetEventPosition()[1] << std::endl;
     
this->Interactor->GetPicker()->Pick(this->Interactor->GetEventPosition()[0],
                         this->Interactor->GetEventPosition()[1],
                         0,  // always zero.
                        
this->Interactor->GetRenderWindow()->GetRenderers()->GetFirstRenderer());
      double picked[3];
      this->Interactor->GetPicker()->GetPickPosition(picked);
      std::cout << "Picked value: " << picked[0] << " " << picked[1] << " "
<< picked[2] << std::endl;
      // Forward events
      vtkInteractorStyleImage::OnLeftButtonDown();
    }
};

vtkStandardNewMacro(MouseInteractorStylePP);



--
View this message in context: http://vtk.1045678.n5.nabble.com/vtkinteractor-point-picker-in-Qt-tp5729959.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list