Re: Display widgets' scaling factors [message #12791] |
Thu, 10 September 1998 00:00 |
steinhh
Messages: 260 Registered: June 1994
|
Senior Member |
|
|
David Fanning wrote:
> The proper thing would be to draw into the first window
> and *immediately* save the system variables.
Yep. That's the name of the game. I wrote a couple of routines
many years ago (ca 1994!) to deal with this kind of task. They're
used like this:
plot,something
p1 = pstore(1) ;; Returns a "plot region ID number"
plot,somethingelse ;; You may have more than one plot in
;; a window.
p2 = pstore(2) ;; Hence the number "2"
wset,some_other_window
plot,third_thing
p3 = pstore(1) ;; First plot this window
prestore,p1 ;; Restores variables + does wset
oplot,on_top_of_first_one
prestore,p3
oplot,on_top_of_third_plot
etc.
To get just these files, look at
http://sohowww.nascom.nasa.gov/softops/cds/idl/util/display/
Get files pstore.pro, prestore.pro, pfind.pro and pconvert.pro.
The routines were designed to work with scaled (rebinned), displayed
images as well (actually, mostly!), hence the mention in the
doc's about data X/Y size etc.
I think these routines are *mostly* independent of other
routines in that S/W tree, but you may have to change
TRIM() -> STRCOMPRESS(STRING(),??)
SETWINDOW -> WSET
Regards,
Stein Vidar
|
|
|
Re: Display widgets' scaling factors [message #12803 is a reply to message #12791] |
Wed, 09 September 1998 00:00  |
Liam Gumley
Messages: 473 Registered: November 1994
|
Senior Member |
|
|
David Fanning wrote:
> The proper thing would be to draw into the first window
> and *immediately* save the system variables.
> WSet, window1
> Plot, data
> p1 = !P
> x1 = !X
> y1 = !Y
> z1 = !Z
I also recommend saving the !MAP system variables, just in case you use
a map projection. I've used the technique David outlines quite
successfully in my IDL Frame Tools, available at
http://cimss.ssec.wisc.edu/~gumley/frame.html. That reminds me that I
really should put the source code on the web site (right now it's SAVE
files).
Cheers,
Liam.
|
|
|
Re: Display widgets' scaling factors [message #12804 is a reply to message #12803] |
Wed, 09 September 1998 00:00  |
davidf
Messages: 2866 Registered: September 1996
|
Senior Member |
|
|
TJ Saunders (tjs@u.washington.edu) writes:
> Something that often crops in up my widget programming is the difficulty I
> have in trying to have two child draw widgets under one parent, each with
> different xy ranges, scaling, that sort of thing. Ideally, I would like
> to be able to draw in each widget with the correct scaling factors. But,
> I have found that the scale factors for the last plot drawn remain in
> effect, even if WSET is used. I have tried to manually change the !P, !X,
> !Y, and !Z system variables for each display, but that doesn't seem to
> work. I'm sure that there is a solution somewhere...any ideas?
Oh, I'm working on my web page this morning and I was looking for
good ideas for tips. :-)
You write "even if WSET is used". Believe me, in a widget
program WSET *must* be used! But I don't want to get into
*that*. :-)
You are correct that WSET has absolutely no bearing on
the plot scale factors in the window. It's one and only
purpose is to allow you to select the current graphics
window (I.e., the window that very next graphic command
will be sent to).
Data scaling parameters are set in the system variables.
If you keep track of these for each window, then you
will have no trouble getting things to work properly. The
fact that you *are* having trouble, even when you try
setting them suggests you are not doing it properly.
The proper thing would be to draw into the first window
and *immediately* save the system variables.
WSet, window1
Plot, data
p1 = !P
x1 = !X
y1 = !Y
z1 = !Z
Then, do the same thing for the other window:
WSet, window2
Plot, moredata
p2 = !P
x2 = !X
y2 = !Y
z2 = !Z
When you want to go back to the first window (perhaps to
overplot on the plot that is already there), you simply
restore the proper system variables before overplotting:
WSet, window1
!P = p1
!X = x1
!Y = y1
!Z = z1
OPlot, stillmoredata
Of course, in a widget program these values will have to
be saved in the info structure so you can access them.
If I have time later today I'll write this idea up more
formally and put an example on my web page.
Cheers,
David
----------------------------------------------------------
David Fanning, Ph.D.
Fanning Software Consulting
E-Mail: davidf@dfanning.com
Phone: 970-221-0438, Toll-Free Book Orders: 1-888-461-0155
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|