Re: IDL data coordinates in a widget [message #28729] |
Wed, 09 January 2002 11:24 |
Ben Tupper
Messages: 186 Registered: August 1999
|
Senior Member |
|
|
"Juan I. Cicuendez" wrote:
> Hi,
>
> Can anyone help me with this?
> I am trying to set up an interactive widget that provides the data
> value corresponding to a plot on a widget_draw pannel. I am stuck as I
> can't manage to obtain the right data coordinates of the system.
> First I was using a multiple plot, and from the motion_event obtaining
> x,y coordinates on the draw pannel. This seem to work fine and I
> obtain the device coordinates, but when I try to use
> data=CONVERT_COORD(x,y,/DEVICE, /TO_DATA)
> the output I get does not make any sense and does not match my data
> (some of them are negative values). I thought that this could be an
> interference when using a multiple plot so I tried to decompose my
> whole plot into individual ones (tedious way) and apply this described
> method individually and still does not work and even though the values
> are better, for fixed x intervals in the plot the calculated x length
> varies.
>
>
Hi,
In addition to David's suggestions, you might try the frame management
tools that I recently modeled after Liam Gumley's frame tools. They are
easy to use and despite being object based, they are quite straight
forward for the end user. You can picture each sub-plot as a frame
within the draw widget. The is an example routine using multiple plots
interactively. You can get my frame tools here
(www.tidewater.net/~pemaquid) or Liam's original set of tools here
(www.gumley.com).
Ben
--
Ben Tupper
248 Lower Round Pond Road
POB 106
Bristol, ME 04539
Tel: (207) 563-1048
Email: PemaquidRiver@tidewater.net
|
|
|
Re: IDL data coordinates in a widget [message #28739 is a reply to message #28729] |
Wed, 09 January 2002 05:58  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Juan I. Cicuendez (jicicuendez@gmv.es) writes:
> I am trying to set up an interactive widget that provides the data
> value corresponding to a plot on a widget_draw pannel. I am stuck as I
> can't manage to obtain the right data coordinates of the system.
> First I was using a multiple plot, and from the motion_event obtaining
> x,y coordinates on the draw pannel. This seem to work fine and I
> obtain the device coordinates, but when I try to use
> data=CONVERT_COORD(x,y,/DEVICE, /TO_DATA)
> the output I get does not make any sense and does not match my data
> (some of them are negative values). I thought that this could be an
> interference when using a multiple plot so I tried to decompose my
> whole plot into individual ones (tedious way) and apply this described
> method individually and still does not work and even though the values
> are better, for fixed x intervals in the plot the calculated x length
> varies.
>
> Does enyone know why this is happenning? Is there any solution to this
> or another way do solve this?
Since you are doing several plots, I suspect the problem
is that the scaling factors you are using to convert between
device coordinates and data coordinates are not the correct
factors for the plot you are using. These factors are
calculated and stored in system variables at the time
the plot is drawn. You will have to save these variables
and restore them before you interact with the plot, if
you want them to be correct. Otherwise, they will only
be correct for the most recent plot drawn that day in IDL. :-)
I typically do something like this:
Plot, data
info.x1 = !X
info.y1 = !Y
info.p1 = !P
Plot, moredata
info.x2 = !X
info.y2 = !Y
info.p2 = !P
Then, when I want to interact with a plot (say, Plot 2 in this case)
I do this:
!X = info.x2
!Y = info.y2
!P = info.p2
Oplot, stillmoredata ; Or whatever.
You can find an example widget program demonstrating these
ideas here:
http://www.dfanning.com/tip_examples/track_data_value.pro
Another problem, sometimes, is using the CURSOR command in
draw widget windows instead of the built-in capability of
the draw widget. This can cause subtle, and extremely
annoying, problems, too.
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|