[vtkusers] vtkWorldPointPicker

Anja Ende anja.ende at googlemail.com
Thu Sep 7 06:44:37 EDT 2006


Hi all,

Well, still struggling with point picking in 2D actors. I am trying to use
the vtkWorldPointPicker and then converting it to display coordinates later.

However, does vtkWorldPointPicker work with renderers that are essentially
rendering 2D actors. I am getting some values that make no sense to me
(well, that is not new) and when I convert them back to screen coordinates,
the values are just wrong.

Here is the code and the output that t returns at various stages. I would
really appreciate it if someone cana ctually provide some help or an
indication to a direction worth pursuing...

I will just give some information about the scene. So, the input to the
viewer is the output from a vtkImageReslice that just returns one slice. So,
it is basically a 2D image. However, the reslicer has other parameters that
might zoom and rotate the image. So, I wanted to find out the position in
the image when I click my mouse somewhere on the screen. No luck, so far...
Is it even possible? Any ideas on how we can implement that?

// This code is in my interactor.

int x = this->Interactor->GetEventPosition()[0];
int y = this->Interactor->GetEventPosition()[1];
this->FindPokedRenderer(x, y);

if (this->CurrentRenderer == NULL)
       return;

 vtkWorldPointPicker * picker = vtkWorldPointPicker::New();
 int picked = picker->Pick(x, y, 0, this->CurrentRenderer);
 if (picked != -1)
 {
         std::cout << picker->GetPickPosition()[0] << ": " <<
picker->GetPickPosition()[1] << std::endl;
         // The values returned are: -0.00106603 and -0.00149245.... Does
this make any sense? How do we interpret these values...??

         vtkCoordinate* c = vtkCoordinate::New();
         c->SetViewport(this->CurrentRenderer);
         c->SetCoordinateSystemToWorld();
         c->SetValue(picker->GetPickPosition()[0],
picker->GetPickPosition()[1]);
         int *p = c->GetComputedDisplayValue(this->CurrentRenderer);
         std::cout << p[0] << ": " << p[1] << std::endl;
         // These converted values are not correct.
}

Cheers and thanks,

Anja
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20060907/f77e2398/attachment.htm>


More information about the vtkusers mailing list