[vtkusers] :( I need urgent help witk PointPicking and user	interactor style
    Oana MS 
    oanams at gmail.com
       
    Tue May 24 16:19:54 EDT 2005
    
    
  
Hello!
It's the first time I'm using point picking in vtk. I'm trying to get
the id of a point on my scene under OnRightButtonPress function.I have
the secvence of the code below:
	imActor2D=vtkActor2D::New();
	imActor2D->SetMapper(imMapper);
	
	picker = vtkPointPicker::New();
	userstyle = vtkInteractorStyleUser::New();
	vtkMyCallback *callback = vtkMyCallback::New();
	callback->RightButtonPressEvent;
	
/*	picker->PickFromListOn();
	picker->AddPickList(imActor2D);*/
	picker->SetTolerance(0.01);
	userstyle->AddObserver(vtkCommand::RightButtonReleaseEvent, callback);
	
	iren->SetInteractorStyle(userstyle);
	iren->SetPicker(picker);
	iren->Initialize();
and the callback procedure like this:
class vtkMyCallback : public vtkCommand
{
public:
        static vtkMyCallback *New() { return new vtkMyCallback; }
    virtual void Execute(vtkObject *caller, unsigned long, void*)
    {	
        vtkRenderWindowInteractor *iren =
reinterpret_cast<vtkRenderWindowInteractor*>(caller);
		vtkPointPicker *picker = (vtkPointPicker *)iren->GetPicker();
		
		if (picker->GetPointId()>=0)
		{		
		CString text3;
		text3.Format("pick: %d",picker->GetPointId());
		AfxMessageBox(text3);
		}
    }
};
when he gets to GetPointId instruction it stops. I think the problem
is with interactor style. Before, I was trying to add observer to
interactor but it didn't do anything so this seems the only way to see
that at least it considers my function.
Can anybody find a solution? Please.
Thanks in advance.
OMS
    
    
More information about the vtkusers
mailing list