Re: Problems with system variables [message #16432] |
Tue, 27 July 1999 00:00 |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
Brad L. Fisher (fisher@trmm.gsfc.nasa.gov) writes:
> This problem requires a little bit explanation. I am e
xtracting data
> from an image window with the cursor command, which I am using to
> generate two different windows (the cursor coordinates are used to
> select the central pixel in one of two windows). One window is
> displayed with TV; the other with PLOT (draws a simple graph). The idea
> is for user to be able to select different points in the main data
> window and carry out analysis on the data selected within the other two
> windows. Consequently, the program was designed to interact with the
> main data image multiple times using the cursor command.
>
> Before adding the PLOT window everything was fine, but after generating
> a PLOT, which was drawn in a unique window opened by the program, it
> seems that the window system info from the main image is getting lost or
> replaced. For instance, when I select a point with the cursor the first
> time through everything is fine, for at first, there is only one window
> drawn, but the second time through the cursor return bogus data
> coordinates. It turns out that the data selected from the main window
> was actually data in my PLOT window. I did notice that the system
> values in !p were getting changed. I then tried just saving the
> original !p and reassigning it after generating the PLOT, but that
> solution did not rectify the problem I described above. Can anyone help
> with this? If so, please send responses to fisher@trmm.gsfc.nasa.gov.
In doing this kind of thing with data coordinates (and I'm
NOT sure that is such a good idea with images, by the way,
since images don't work in a data coordinate system, but in
a DEVICE coordinate system), then you have to save the
proper plot system variables for each graph you want to
draw on. I've never bothered to figure out exactly
*which* system variables these are, because I always
save !P, !X, and !Y as a matter of course. Then, I always
restore these before I draw something on the graph.
Plot, data
p = !P
x = !X
y = !Y
Then, sometime later...
WSet, plotWindow
!P = p
!X = x
!Y = y
OPlot, moredata
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|