Re: convert_coord problem [message #20867] |
Thu, 27 July 2000 00:00 |
Bernard Puc
Messages: 65 Registered: January 1998
|
Member |
|
|
I suspect that your problem lies with the fact that you have several
graphics windows. The convert_coord function uses the current output
device parameters to do the conversion to/from device or data
coordinates. The straightforward solution is to store the following
system variables !P, !X, !Y, !Z after you have generated your graphics
plot from which you are getting the mouse position. Then, copy the
stored variables back to the system variables whenever you need to
convert the mouse pointer again.
This may not be especially clear explanation - perhaps one of the more
eloquent readers of the group can clarify, if needed.
Klaus Scipal wrote:
>
> Hi
>
> I have a widget with several graphic windows. On of it returns the
> co-ordinates of the mouse button if pressed. These co-ordinates are then
> converted from device to data (longitude, latitude) using the convert_coord
> routine, and some data is plotted in the other windows. Now comes my
> problem: the convert_coord routine gives the correct co-ordinates only in
> its first call. when I try to convert another pair of co-ordinates the
> result is flawed. What can be wrong???
>
> Klaus
>
> p.s.: I use IDL 5.2 under Windows NT
--
-Bernard Puc
AETC,INC. (http://www.aetc.com)
1225 Jefferson Davis Hwy, Suite 800
Arlington, VA 22202
(703) 413-0500
|
|
|
Re: convert_coord problem [message #20868 is a reply to message #20867] |
Thu, 27 July 2000 00:00  |
Ben Tupper
Messages: 186 Registered: August 1999
|
Senior Member |
|
|
Hello,
it sounds like you are using direct graphics.
The CONVERT_COORD function makes the conversions using the scaling factors in
!X .Sand !Y.S from the _most_recent_ plot. So the conversion will work
properly in the most recent plot, but it will produce garbage for any of the
earlier ones. You could do a couple of things to get around this limitation.
(1) Save the values !X.S and !Y.S for each plot window (these are originally
stored after the graphic command that sets up the coordinate system for each
window.)
Win1_XS = !X.S & Win1_YS = !Y.S
Win2_XS = !X.S & Win2_YS = !Y.S
Later, when a mouse event arrives, assign the appropriate values to !X.S and
!Y.S and make the neccessary conversions. So if an event arrives from window
2
!X.S = WidgetInfoStructure.Win1_XS
!Y.S = WidgetInfoStructure.Win2_YS
DataCoord = CONVERT_COORD(Event.X, Event.Y,/Device,/To_Data)
(2) You could save the values of !X.S and !Y.S and write your own conversion
routine using the conversion formulas described in the online help. (See
Coordinate Conversion for Direct Graphics)
(3) You might check out Liam Gumley's Frame Tools (you can find them through
David Fanning's links web page.) I don't know if these tools will solve your
problem, but it sounds like the might help.
Ben
Klaus Scipal wrote:
> Hi
>
> I have a widget with several graphic windows. On of it returns the
> co-ordinates of the mouse button if pressed. These co-ordinates are then
> converted from device to data (longitude, latitude) using the convert_coord
> routine, and some data is plotted in the other windows. Now comes my
> problem: the convert_coord routine gives the correct co-ordinates only in
> its first call. when I try to convert another pair of co-ordinates the
> result is flawed. What can be wrong???
>
> Klaus
>
> p.s.: I use IDL 5.2 under Windows NT
--
Ben Tupper
Bigelow Laboratory for Ocean Science
West Boothbay Harbor, Maine
btupper@bigelow.org
note: email address new as of 25JULY2000
|
|
|