Re: Widget_draw coordinates? [message #44948] |
Fri, 29 July 2005 10:21  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
b_efremova@yahoo.com writes:
> Can somebody tell me how can I obtain x and y coordinates in data
> units, when using the widget_draw.
> The events have X and Y fields, but their values are only in pixels
> or inches, and I don't see an option for them to be in the data
> coordinate units.
c = Convert_Coord(event.x, event.y, /Device, /To_Data)
x = c[0,0]
y = c[1,0]
Just be sure you *have* a data coordinate system established
when you do the conversion! Typically, you save !X, and !Y
from a PLOT command and restore them before the conversion
takes place. Or, this occurs just after a PLOT, CONTOUR,
SURFACE, etc.
!X = info.bang_x
!Y = info.bang_y
c = Convert_Coord(event.x, event.y, /Device, /To_Data)
x = c[0,0]
y = c[1,0]
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
|
Re: Widget_draw coordinates? [message #45097 is a reply to message #44948] |
Fri, 29 July 2005 10:42  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> Just be sure you *have* a data coordinate system established
> when you do the conversion! Typically, you save !X, and !Y
> from a PLOT command and restore them before the conversion
> takes place. Or, this occurs just after a PLOT, CONTOUR,
> SURFACE, etc.
See ZPLOT for an example of how this is done, if you
don't understand how to set up a data coordinate system:
http://www.dfanning.com/programs/zplot.pro
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|