[vtkusers] VTKPointPicker getting negative values for y-axis
Luis Roberto P. Paula
luisrpp at gmail.com
Wed Feb 11 11:27:28 EST 2009
Hi All,
I'm using the VTKPointPicker to get the coords of the mouse over a widget
displaying a vtkImageData object.
To display this image, I'm using the vtkImageViewer2.
The coords are get correctly when I use a blank image like this:
vtlImageData* image = vtlImageData::New();
image->SetSize(200, 200);
image->AllocateScalars();
image->Update();
When I use an image that was extracted from a 3D volume, the x-axis is
correct, but the y-axis is getting negative values.
Does anybody knows why this is happening? Is it an orientation problem? How
can I fix that?
This is the code to get the coords:
if (!picker->Pick(this->Interactor->GetEventPosition()[0],
this->Interactor->GetEventPosition()[1],
0,
viewer->GetRenderer())) {
return;
}
double ptMapped[3];
picker->GetMapperPosition(ptMapped);
double dSpacing[3];
viewer->GetInput()->GetSpacing(dSpacing);
ptMapped[2] = viewer->GetSlice() * dSpacing[2];
// Update Image
vtkImageData* image = vtkImageData::New();
image->DeepCopy(this->editorGui->getImageMarker());
int nVolIdx = viewer->GetInput()->FindPoint(ptMapped);
unsigned short* pPix = (unsigned
short*)viewer->GetInput()->GetScalarPointer();
int usPix = (int)pPix[nVolIdx];
printf("Coords: x %f y %f\n", ptMapped[0], ptMapped[1]);
Thanks,
Luis
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20090211/9f894452/attachment.htm>
More information about the vtkusers
mailing list