Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/display_images.pro'
;+
; NAME:
; display_images
; PURPOSE:
; Display images from the List into specified window,
; with respective Locations as specified in structure,
; and stacked in the order given by their visibility Levels.
; CALLING EXAMPLE:
; display_images, image_List [ , image_pool, /RESIZE ]
; INPUTS:
; image_List = structured array containing images and specifications
; image_pool = optional array containing the images,
; in such case image_List has pointers into array image_pool.
; KEYWORDS:
; INUMS = specify indices of images in the List (default is all).
; GROUP = specify group # of images (default is all groups).
; /ERASE : erase window before display of images.
; /RESIZE : resize window to accomodate all images.
; WINDOW = window # in which to display (default is image_List(0).windo)
; XPOS, YPOS = position of window on monitor (only if /RESIZE),
; default = upper right corner of monitor.
; EXTERNAL CALLS:
; pro display_image (to handle display of each individual image)
; pro get_window
; pro resize_window
; function N_struct
; function check_Mag_Fact
; SYSTEM VARIABLES:
; !DEVX , !DEVY = size of monitor screen in pixels.
; COMMON BLOCKS:
; common display_images, min_xsiz ;the mininum X-size of window
; common display_images2, always_all ;flag to force display of all
; HISTORY:
; Written, Frank Varosi NASA/GSFC 1989
; F.V.1991, added /RESIZE keyword option to resize window around images.
; F.V.1992, generalized for collection of arbitray images {mosaic_List}.
; F.V.1997, mod to display only top image in a trivial stack of many.
;-
pro display_images, image_List, image_pool, GROUP=group, INUMS=inums, $
ERASE=erase, RESIZE=resize, $
WINDOW=window, XPOS=xpos, YPOS=ypos
common display_images, min_xsiz
common display_images2, always_all
Nim = N_struct( image_List )
if (Nim LE 0) then return
;Check if a particular window requested:
if N_elements( window ) EQ 1 then begin
ww = where( [image_List.windo] EQ window , Nim )
if (Nim LE 0) then return
wtitle = image_List(ww(0)).winame
endif else begin
ww = indgen( Nim )
window = image_List(0).windo
wtitle = image_List(0).winame
endelse
;Re-size the window if requested:
if keyword_set( resize ) then begin
resize_window, image_List, !D.y_ch_size*5, xsiz,ysiz,WIN=window
if N_elements( min_xsiz ) NE 1 then min_xsiz=400
xsiz = xsiz > min_xsiz
if N_elements( xpos ) NE 1 then xpos = !DEVX-xsiz
if N_elements( ypos ) NE 1 then ypos = !DEVY-ysiz
get_window, window, TIT=wtitle, XSIZ=xsiz, XPOS=xpos, $
YSIZ=ysiz, YPOS=ypos
erase
endif else begin
wset,window
if keyword_set( erase ) then erase
endelse
wshow,window,ICON=0
;Check if any subsets are requested by indices:
if N_elements( inums ) GT 0 then begin
inums = [inums]
match, inums, ww, mi, mw
Nim = N_elements( mi )
if (Nim LE 0) then begin
message,"specified image #s not in window",/INFO
print," image #s :",inums
print," window = ",strtrim( window, 2 )
return
endif else inums = [inums(mi)]
endif else inums = ww
;Check if particular group is requested:
if N_elements( group ) EQ 1 then begin
groups = [image_List(inums).group]
if (group LT 0) then begin ;exclude this group.
group = -group-1
wg = where( groups NE group, Nim )
endif else wg = where( groups EQ group, Nim )
if (Nim LE 0) then begin
message,"specified group # " + strtrim( group, 2 ) + $
" not found",/INFO
return
endif else inums = [inums(wg)]
endif
;Now get stacking order and display them:
if (Nim GT 1) then inums = inums( sort( image_List(inums).Level ) )
xmin = [image_List(inums).Xmin]
ymin = [image_List(inums).Ymin]
tags = tag_names( image_List )
if max( tags EQ "IMAGE" ) then begin
if( (min( xmin, MAX=maxx ) EQ maxx) AND $
(min( ymin, MAX=maxy ) EQ maxy) ) AND $
( NOT keyword_set( always_all ) ) then begin
flush = 1
fim = Nim-1 ;need only display Last image = top image.
endif else begin
sim = size( image_List(0).imscaled )
flush = sim(4) GT 14000
fim = 0
endelse
for i=fim,Nim-1 do begin
display_image, image_List(inums(i)).imscaled, xmin(i),ymin(i)
if( flush ) then empty
endfor
endif else if max( tags EQ "SIZE_IMSCALED" ) AND $
(N_elements( image_pool ) GT 1) then begin
for i=0,Nim-1 do begin
display_image, image_extract( inums(i), image_pool, $
image_List.size_imscaled ), $
xmin(i),ymin(i)
empty
endfor
endif else message,"image arrays or size_image tags not in structure !",/INFO
image_List(inums).windo = window
end