[vtkusers] Pick vtkActor on OnMouseMove

kalman mohit.garg at airbus.com
Wed Jul 20 02:34:04 EDT 2011


Hi

I am trying to pick the vtkActor beneath the picked position on mouse over
event. The code snippet that I use which does not work is:

    virtual void OnMouseMove()
    {
      // Get the location of the click (in window coordinates)
      int* pos = this->GetInteractor()->GetEventPosition();

      vtkSmartPointer<vtkCellPicker> picker =
vtkSmartPointer<vtkCellPicker>::New();
      picker->SetTolerance(0.0005);

      // Pick from this location.
      picker->Pick(pos[0], pos[1], 0, this->GetDefaultRenderer());

      double* worldPosition = picker->GetPickPosition();

      if(picker->GetCellId() != -1)
        {
          vtkActor* vac = picker->GetActor();
          vac->GetProperty()->SetColor(1,0,0);
          std::cout << "Cell id is: " << picker->GetCellId() << " Pick
position is: " << worldPosition[0] << " " << worldPosition[1]  << " " <<
worldPosition[2] << endl;
        }
      // Forward events
      vtkInteractorStyleTrackballCamera::OnMouseMove();
    }

Can anyone let me know whats wrong with this piece of code? 

-
Kalman

--
View this message in context: http://vtk.1045678.n5.nabble.com/Pick-vtkActor-on-OnMouseMove-tp4614872p4614872.html
Sent from the VTK - Users mailing list archive at Nabble.com.



More information about the vtkusers mailing list