Hi All,<br><br>I'm using the VTKPointPicker to get the coords of the mouse over a widget displaying a vtkImageData object.<br><br>To display this image, I'm using the vtkImageViewer2.<br><br>The coords are get correctly when I use a blank image like this:<br>
<br> vtlImageData* image = vtlImageData::New();<br> image->SetSize(200, 200);<br> image->AllocateScalars();<br> image->Update();<br><br>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.<br>
<br>Does anybody knows why this is happening? Is it an orientation problem? How can I fix that?<br><br>This is the code to get the coords:<br>
<br> if (!picker->Pick(this->Interactor->GetEventPosition()[0],<br> this->Interactor->GetEventPosition()[1],<br> 0,<br> viewer->GetRenderer())) {<br>
return;<br> }<br> double ptMapped[3];<br> picker->GetMapperPosition(ptMapped);<br><br> double dSpacing[3];<br> viewer->GetInput()->GetSpacing(dSpacing);<br> ptMapped[2] = viewer->GetSlice() * dSpacing[2];<br>
<br> // Update Image<br> vtkImageData* image = vtkImageData::New();<br> image->DeepCopy(this->editorGui->getImageMarker());<br><br> int nVolIdx = viewer->GetInput()->FindPoint(ptMapped);<br> unsigned short* pPix = (unsigned short*)viewer->GetInput()->GetScalarPointer();<br>
int usPix = (int)pPix[nVolIdx];<br><br> printf("Coords: x %f y %f\n", ptMapped[0], ptMapped[1]);<br><br><br>Thanks,<br>Luis<br>