comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: IDL data coordinates in a widget
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: IDL data coordinates in a widget [message #28739 is a reply to message #28729] Wed, 09 January 2002 05:58 Go to previous message
David Fanning is currently offline  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
[Message index]
 
Read Message
Read Message
Previous Topic: Re: splitting difficult(?) strings
Next Topic: Re: Sacrilegious but genuine question

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:25:27 PDT 2025

Total time taken to generate the page: 0.01149 seconds