[Insight-users] How to get the mouse postion in an actor for 3D?
Feifeng Yang
yngff2008 at gmail.com
Sun Dec 24 02:31:16 EST 2006
Hi everyone,
I'm the new one to use the vtk, and there is a problem trobling me several
days so that I could not continue my research working. This problem is how
to get the mouse position in an actor for 3D rendering?
To get the event position is very available now, however the position of the
actor is wrong when I get the pickerposition of vtkpointvtk by the event
postion.
For example when getting the mouse position in the actor:
********************************************************************************************************
vtkRenderWindowInteractor* iren =
vtkRenderWindowInteractor::SafeDownCast(obj);
int x = 0, y = 0;
iren->GetEventPosition(x, y);
//get the picker handle from the interactor
vtkPointPicker *pointpicker = (vtkPointPicker *)(iren->GetPicker());
double position[3];
//start the picking process
if (pointpicker->Pick((double)position[0], (double)position[1], 0.0, ren)
!= 0)
{
//get the list of picked point
vtkPoints* thePointList = pointpicker->GetPickedPositions();
//get the number of picked points
int nbrpoints = thePointList->GetNumberOfPoints();
if (nbrpoints<=0)
return;
pointpicker->GetPickPosition(position); // The position is wrong in the
actor.
}
********************************************************************************************************
I tested it many times, and tried severl ways, but failed finally. The
position I got is not the position for the actor, and there is "small error"
for x-y, but "big error" for z.
I guess: Is this problem related with the camera viewpoint?
Any body knows it, please tell me or give me some example codes.
I'm appreciate you very much.
--
Thanks
Feifeng
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/insight-users/attachments/20061224/73a48fc6/attachment.htm
More information about the Insight-users
mailing list