Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/border_images.pro'
pro border_images, image_List, color, INUMS=im_nums, ALL_IMAGES=all, $
			COLOR=colorb, SHOW_NUMBERS=show_nums, OFFSET_XY=offxy
;+
; NAME:
;	border_images
; PURPOSE:
;	Display border of selected images in respective window.
;	Interactive mode:
;		Left button to select images, middle/right button to quit.
;	Automatic mode:
;		image #'s specified by INUMS or /ALL are bordered.
; CALLING:
;	border_images, image_List, color
; INPUTS:
;	image_List = array of structures containing images and Locations.
;	color = color table index for drawing borders, def = !D.table_size-1
; KEYWORDS:
;	INUMS =
;	COLOR =
;	/ALL_IMAGES
;	/SHOW_NUMBERS
;	OFFSET_XY =
; OUTPUTS:
;	none.
; EXTERNAL CALLS:
;	function select_image
;	pro border_image
; PROCEDURE:
; HISTORY:
;	Written: Frank Varosi NASA/GSFC 1989.
;	F.V. 1991, added keyword /SHOW_NUMBERS to print image #s within borders.
;-
	if N_struct( image_List ) LE 0 then return
	if N_elements( colorb ) EQ 1 then color=colorb
	if N_elements( offxy ) NE 2 then offxy = [0,0]
	if keyword_set( all ) then im_nums = indgen( N_elements( image_List ) )

	if N_elements( im_nums ) GT 0 then begin
		w = where( [im_nums] GE 0, Nim )
		if (Nim LE 0) then return
		inums = im_nums(w)
		im = inums(0)
		wset, image_List(im).windo
		wshow, image_List(im).windo
		return = 1
		goto,DRAW
	   endif

	return = 0
	instr = 1
	curset = 1
	winset = 1

SELECT:	inums = select_image( image_List,/ALL,INST=instr,CUR=curset,WIN=winset)
	inums = [inums]

	if (inums(0) LT 0) then begin
		printw," ",/ERASE
		return
	   endif

	Nim =  N_elements( inums )
DRAW:
	xmin = [image_List(inums).Xmin] + offxy(0)
	ymin = [image_List(inums).Ymin] + offxy(1)
	xmax = [image_List(inums).Xmax] + offxy(0)
	ymax = [image_List(inums).Ymax] + offxy(1)

	if keyword_set( show_nums ) then begin
	   if (Nim LE 1) then num_show=1 else begin
		num_show = ( !D.x_ch_size/2 LE $
				float( max( xmin, MIN=minx ) - minx )/Nim ) $
			OR ( !D.y_ch_size/2 LE $
				float( max( ymin, MIN=miny ) - miny )/Nim )
	      endelse
	  endif else num_show=0

	if keyword_set( show_nums ) AND (num_show) then begin
		for i=0,Nim-1 do $
		    border_image, xmin(i),ymin(i),xmax(i),ymax(i),color,inums(i)
	  endif else begin
		for i=0,Nim-1 do $
			border_image, xmin(i),ymin(i),xmax(i),ymax(i),color
	   endelse

	instr = 0
	curset = 0
	winset = 0

	if (return NE 1) then goto,SELECT
return
end