Viewing contents of file '../idllib/astron/contrib/varosi/code/allpro/display_elevs.pro'
;+
; NAME:
;	Display_ELevs
; PURPOSE:
;	Display the Energy Levels obtained from TOPBASE (atomic database)
;	as horizontal lines with color indicating status.
;	Default is to display just Levels that have non-zero color.
; CALLING:
;	Display_ELevs, ELevs
; INPUTS:
;	ELevs = array of structures with tags for graphic Location of Levels.
; KEYWORDS:
;	/NEW : display only Levels for which ELevs.disp EQ 1 and color GT 0.
;
;	WHICH = array of subscripts indicating which Levels to display,
;		default is to display ones with non-zero color.
;
;	ZOOM_FACTOR = magnification to be applied to:
;		both x & y axes if one number is specified, or
;		x & y axes respectively if two numbers are specified.
;
;	PANXY = two numbers specifying x & y translation in device coordinates.
; OUTPUTS:
;	ELevs = the "disp" tag of each Level displayed is set to zero.
; EXTERNAL CALLS:
;	function N_struct
; PROCEDURE:
;	Display energy levels using TV, in backwards order to avoid
;	obscuring display with the ionization line (which is last in array).
; HISTORY:
;	Written: Frank Varosi NASA/GSFC 1994.
;-

pro Display_ELevs, ELevs, ZOOM_FACTOR=zoomf, PANXY=panxy, WHICH=wc, NEW=new

	on_error,2
	if N_struct( ELevs ) LE 0 then return
	NLev =  N_elements( wc )

	if (NLev GT 0) then  wc = wc > 0  else begin
		if keyword_set( new ) then $
			wc = where( (ELevs.color GT 0) AND ELevs.disp, NLev ) $
		  else	wc = where( ELevs.color, NLev ) 
		if (NLev LE 0) then return
	  endelse

	CASE N_elements( zoomf ) OF
	  1: BEGIN
		Sxy = ( ELevs(wc).size * zoomf ) > 1
		Sxy(1,*) = ( Sxy(1,*)/2 ) > 1
		Locs = ELevs(wc).Loc * zoomf
		END
	  2: BEGIN
		zf = zoomf # replicate( 1,NLev )
		Sxy = ( ELevs(wc).size * zf ) > 1
		Sxy(1,*) = ( Sxy(1,*)/2 ) > 1
		Locs = ELevs(wc).Loc * zf
		END
	  else: BEGIN
		Sxy = ELevs(wc).size
		Locs = ELevs(wc).Loc
		END
	 ENDCASE

	if N_elements( panxy ) EQ 2 then Locs = Locs + panxy#replicate( 1,NLev )
	Locs = Locs > 0
	cols = ELevs(wc).color

	ws = where( ELevs(wc).sel, ns )
	if (ns GT 0) then Sxy(0,ws) = Sxy(0,ws) * 1.2

	for i = NLev-1, 0, -1 do $
	  tv, make_array( DIM=Sxy(*,i),VAL=cols(i),/BYTE ), Locs(0,i), Locs(1,i)

	ELevs(wc).disp = 0
end