[vtkusers] Screen coordinates to world coordinates

Andres Munarriz munarriz.a at gmail.com
Thu Aug 10 22:37:09 EDT 2006


> Hi everyone,

> I'm still coming across issues converting display coordinates to  
> world (image) coordinates. Here's what I've done and what I'm  
> trying to do.

> I've loaded a single DICOM CT image (slice) to a
> vtkImageViewer2.  I wish to allow a user to double click a point on
> this image (slice) and draw a "marker" in this case a sphere on the
> point the user double clicked.  Later down the pipeline I will be
> using this point as a seed for a connectivity filter.
>
> I've created my own wxVTKInteractor derived class (ie.
> MyVTKRenderWindowInteractor) where I've defined my own EVT_LEFT_DCLICK
> handler (ie. void
> MyVTKRenderWindowInteractor::OnButtonDouble(wxMouseEvent& p_Event) ).
>
> I can obtain two sets of "display" coordinates (wx coordinates); one
> by calling the p_Event.m_x, p_Event.m_y property or by calling the
> wxVTKInteractor GetEventPosition method which is inherited form  
> VTKRenderWindowInteractor.
>
> I'll pass whichever coordinate set to a vtkWorldPointPicker through
> the Pick method
> (ie. 	
> vtk_pointPicker->Pick(double(eventPosition[0]), double
> (eventPosition[1]), 0.0, vtk_windowRenderer);
> )
>
> however when I retrieve the picked coordinates using the
> vtk_pointPicker->GetPickPosition(pointCoordSet); call, the coordinates
> returned are not the coordinates I expect.  The x values are OK but
> the Y coord is wrong.

> I'm aware that the display Y axis is inverted in relation to the  
> VTK world axis, but even if I use the SetEventPositionFlipY method  
> the y axis coordinate I get from the picker does not match the  
> point the user double clicked on.

> Could you please help me?
>
>
> Regrads,
> Andres
>
>
> On 8/9/06, Nigel Nunn <nNunn at ausport.gov.au> wrote:
>>
>>
>> Andres Munarriz <munarriz.a at gmail.com> wrote:
>>
>> > > Has someone come across the need of converting screen "display"
>> > > corrdinates (ie. wxEvent ._x, ._y) to VTK world coordinates?
>> > > I've read about a get event method in the  
>> VTKRenderWindowInteractor
>> > > but wxVTKRenderWindowInteractor doesn't seem to support this  
>> method.
>> > > If someone can help it'll be greatly appreciated.
>>
>> ...
>>
>>
>> > I'm using the interactor->GetLastEventPosition(&event_x,
>> &event_y);
>> > method. event_x and event_y are both integers.
>> >
>> > Am I using the wrong method?
>>
>>
>> Hi Andres,
>>
>> From file <vtkCoordinate.h>:
>>
>> The coordinate systems in vtk are as follows:
>>
>>   DISPLAY -             x-y pixel values in window
>>   NORMALIZED DISPLAY -  x-y (0,1) normalized values
>>   VIEWPORT -            x-y pixel values in viewport
>>   NORMALIZED VIEWPORT - x-y (0,1) normalized value in viewport
>>   VIEW -                x-y-z (-1,1) values in camera coordinates.  
>> (z is
>> depth)
>>   WORLD -               x-y-z global coordinate values
>>   USERDEFINED -         x-y-z in User defined space
>>
>>
>> First question is what would you like to do?  Are you trying to  
>> convert a
>> wxWindow "pick" position to vtk "world" or "viewport"?  Or are you  
>> trying to
>> go the other way, i.e. from Vtk to Wx?  Can you describe when and  
>> how you
>> get the source coordinates, and what you would like to do with the  
>> target
>> coordinates?
>>
>> A test for most possible conversions can be found here:
>>
>>   /VTK/Rendering/Testing/Cxx/otherCoordinate.cxx
>>
>>
>> Nigel
>> --------------------------------------------------------------------- 
>> ----------------
>> This message is intended for the addressee named and may contain
>> confidential and privileged information. If you are not the intended
>> recipient please note that any form of distribution, copying or  
>> use of this
>> communication or the information in it is strictly prohibited and  
>> may be
>> unlawful. If you receive this message in error, please delete it  
>> and notify
>> the sender. Keep up to date with what's happening in Australian  
>> sport. Visit
>> http://www.ausport.gov.au
>> --------------------------------------------------------------------- 
>> ----------------
>
>
> -- 
> -æ- Andrés E. Munarriz Soto -æ-




More information about the vtkusers mailing list