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

Home » Public Forums » archive » Re: Is that window open??
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Is that window open?? [message #8562] Thu, 03 April 1997 00:00
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Brian Jackel wrote:
>
> In article <33427754.41C6@irc.chmcc.org> Phil Williams <williams@irc.chmcc.org> writes:
>
>> How would I check to see if a window ID is still open in a widget
>> program?
>
> For the "standard" set of windows, DEVICE,WINDOW_STATE=window_state
> works, but this seems to apply only to windows 0 to 30, and the Draw_widget
> comes out of a pool from 31 or more. I ran across this when trying to make
> a window manager which would remember plotting states in different windows,
> but never found a good way to handle widget windows.

I don't think this is correct, at least on my system which is
a Sparc 2 running IDL 4.0.1 . Check out the following session:

IDL> device, window_state=win
IDL> help,win
WIN BYTE = Array[36]
IDL> for i = 0, 50 do window, xsize=10, ysize=10, /free
IDL> device, window_state=win
IDL> help,win
WIN BYTE = Array[83]
IDL>

Now, win(0:31)=0, win(32:82)=1

I've used WINDOW_STATE to manage windows in draw-widgets within
a "show-image" application where we have over 100 windows up at
one time.

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2200
La Jolla, CA 92037
[ UCSD Mail Code 0949 ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
Re: Is that window open?? [message #8567 is a reply to message #8562] Thu, 03 April 1997 00:00 Go to previous message
steinhh is currently offline  steinhh
Messages: 260
Registered: June 1994
Senior Member
In article <brian.jackel.115.5380EC62@uwo.ca>, brian.jackel@uwo.ca (Brian Jackel) writes:

[..]
|> For the "standard" set of windows, DEVICE,WINDOW_STATE=window_state
|> works, but this seems to apply only to windows 0 to 30, and the Draw_widget
|> comes out of a pool from 31 or more. I ran across this when trying to make
|> a window manager which would remember plotting states in different windows,
|> but never found a good way to handle widget windows. In the end I wrapped
|> the WSET inside an EXECUTE(), and caught the error (if any) that way. Please
|> post if some more graceful approach is possible.
|>

I don't think this is a problem - the array size returned
by the WINDOW_STATE keyword expands as you go (at least for
me), e.g.:

IDL> device,window_state=w
IDL> help,w
W BYTE = Array(32)
IDL> base=widget_base()
IDL> drw=widget_draw(base,xsize=10,ysize=10)
IDL> widget_control,base,/realize
IDL> device,window_state=ww
IDL> help,ww
WW BYTE = Array(33)

The reason I know is that I once made a system for saving/restoring plot
region states which works OK. It's available as a tiny part of the solarsoft
library (see e.g., http://www.space.lockheed.com/eit/ssw_setup.html)

If you don't want the whole package, the routines are called
pstore.pro, prestore.pro, pconvert.pro, pfind.pro, at
http://sohowww.nascom.nasa.gov/solarsoft/gen/idl/display/

There may be dependencies on other software in the solarsoft/gen tree,
though... at least the following:

../idl/string/trim.pro
../idl/system/get_viewport.pro
../idl/system/setscale.pro
../idl/system/setwindow.pro

Regards,

Stein Vidar
Re: Is that window open?? [message #8570 is a reply to message #8562] Wed, 02 April 1997 00:00 Go to previous message
hegde is currently offline  hegde
Messages: 17
Registered: December 1995
Junior Member
In article <33427754.41C6@irc.chmcc.org>, Phil Williams <williams@irc.chmcc.org> writes:
> How would I check to see if a window ID is still open in a widget
> program?
>
> Here's what I did
> oldwin = !d.window
> wset, info.wid
>
> ; some code here
>
> ;--- restore the oldwin
> wset, oldwin
>
> and it crashes with
> % WSET: Window is closed and unavailable.

Use CATCH to trap the error signal and act accordingly. For example:

oldwin = !d.window
WSET, info.wid

; some code here

CATCH, err_status
CASE err_status OF
-324 : BEGIN
; do what you want when the window is closed
PRINT, 'warning ........'
END

ELSE : WSET, info.wid
ENDCASE

CATCH, err_status, /CANCEL

As in any other structured language, IDL doesn't define these error signals
as constants. Hence programmer is at a disadvantage, if RSI changes them with
each version.

Hope it helps.

-M. Hegde
Re: Is that window open?? [message #8571 is a reply to message #8570] Wed, 02 April 1997 00:00 Go to previous message
David Foster is currently offline  David Foster
Messages: 341
Registered: January 1996
Senior Member
Phil Williams wrote:
>
> How would I check to see if a window ID is still open in a widget
> program?
>
> Here's what I did
> oldwin = !d.window
> wset, info.wid
>
> ; some code here
>
> ;--- restore the oldwin
> wset, oldwin
>
> and it crashes with
> % WSET: Window is closed and unavailable.

I think the most straightforward thing to do would be:

oldwin = !d.window
device, window_state=windows
case ( windows(info.wid) ) of
0: <window is closed...recreate or whatever>
1: wset, info.wid
endcase

Dave
--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
David S. Foster Univ. of California, San Diego
Programmer/Analyst Brain Image Analysis Laboratory
foster@bial1.ucsd.edu Department of Psychiatry
(619) 622-5892 8950 Via La Jolla Drive, Suite 2200
La Jolla, CA 92037
[ UCSD Mail Code 0949 ]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~
Re: Is that window open?? [message #8573 is a reply to message #8570] Wed, 02 April 1997 00:00 Go to previous message
Tim Patterson is currently offline  Tim Patterson
Messages: 65
Registered: October 1995
Member
Sorry if I'm on the wrong track, but wouldn't a window ID
being closed ina widget program also imply that the
container widget has disappeared too? Couldn't you check for
the widget existing still (I presume you're worried about
the user closing the window using the Window manager menu
rather than letting the program close it).

Tim



Phil Williams wrote:
>
> How would I check to see if a window ID is still open in a widget
> program?
>
> Here's what I did
> oldwin = !d.window
> wset, info.wid
>
> ; some code here
>
> ;--- restore the oldwin
> wset, oldwin
>
> and it crashes with
> % WSET: Window is closed and unavailable.
>
> Thanks,
> Phil
Re: Is that window open?? [message #8575 is a reply to message #8570] Wed, 02 April 1997 00:00 Go to previous message
brian.jackel is currently offline  brian.jackel
Messages: 23
Registered: May 1996
Junior Member
In article <33427754.41C6@irc.chmcc.org> Phil Williams <williams@irc.chmcc.org> writes:

> How would I check to see if a window ID is still open in a widget
> program?

For the "standard" set of windows, DEVICE,WINDOW_STATE=window_state
works, but this seems to apply only to windows 0 to 30, and the Draw_widget
comes out of a pool from 31 or more. I ran across this when trying to make
a window manager which would remember plotting states in different windows,
but never found a good way to handle widget windows. In the end I wrapped
the WSET inside an EXECUTE(), and caught the error (if any) that way. Please
post if some more graceful approach is possible.

Brian Jackel
temporarily at: jackel@danlon.physics.uwo.ca
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: file paths
Next Topic: Re: ANY LINUX IDL USERS?

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

Current Time: Wed Oct 08 13:32:37 PDT 2025

Total time taken to generate the page: 0.00747 seconds