[vtkusers] :( I need urgent help witk PointPicking and userinteractor style

de Boer Ingo I.deBoer at polytec.de
Wed May 25 02:20:28 EDT 2005


Hi,

this might help:

http://public.kitware.com/pipermail/vtkusers/2004-April/073344.html

greets
  Ingo

---
Dr.-Ing. Ingo H. de Boer

Polytec GmbH
Polytec-Platz 1-7, 76337 Waldbronn, Germany
phone: ++49 7243 604 106
fax  : ++49 7243 604 255
 

> -----Original Message-----
> 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
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: 
http://www.vtk.org/Wiki/VTK_FAQ
Follow this link to subscribe/unsubscribe:
http://www.vtk.org/mailman/listinfo/vtkusers



More information about the vtkusers mailing list