PRO qView_ShowInfo, state
;+
; NAME:
;	qView_ShowInfo
; PURPOSE:
;	Display dialog box containing information about current image
; CATEGORY:
;	Widgets: qView
; CALLING SEQUENCE:
;	qView_ShowInfo
; INPUTS:
;	state		array[1]; type: structure
;					qView state structure
; OUTPUTS:
;	(to dialog box)
; INCLUDE:
	@compile_opt.pro		; On error, return to caller
; CALLS:
;	qView_GetInfo, qView_ImageInfo
; PROCEDURE:
;	Extracts information from state variable
; STATE INFO USED:
;	widget_control, state.wid_box , get_value=cbox
;	widget_control, state.wid_data, get_value=cdata
;	widget_control, state.wid_pick  , get_uvalue=allfiles, /no_copy
; STATE INFO MODIFIED:
;	widget_control, state.wid_pick, set_uvalue=allfiles, /no_copy
; MODIFICATION HISTORY:
;	FEB-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu)
;-

IF NOT qView_GetInfo(state, dim=dim, offset=offset, subdim=subdim, box=box,	$
							zval=zval, zhilo=zhilo, fixz=fixz, zlog=zlog) THEN BEGIN
	widget_control, state.wid_box , get_value=cbox
	widget_control, state.wid_data, get_value=cdata

	i = dialog_message(['No area selected yet.','"'+cbox+'" and "'+cdata+'" first.'], dialog_parent=state.wid_info)

ENDIF ELSE BEGIN
	npix = (box[2]-box[0]+1L)*(box[3]-box[1]+1L)

	active = qView_ImageInfo(state, /active)

	widget_control, state.wid_pick, get_uvalue=allfiles, /no_copy
	message = allfiles[active,0]
	IF strlen(allfiles[active,1]) NE 0 THEN message = [message,' ',allfiles[active,1]]
	widget_control, state.wid_pick, set_uvalue=allfiles, /no_copy

	message = [	message, ' ',	$
				'Image size      ' +strjoin( strcompress(dim   , /rem), ' x '),		$
				'Display offset  ['+strjoin( strcompress(offset, /rem), ' - ')+']',	$
				'Display area     X:['+strcompress(offset[0])+'-'+strcompress(offset[0]+subdim[0]-1)+']  '+	$
								 'Y:['+strcompress(offset[1])+'-'+strcompress(offset[1]+subdim[1]-1)+']',	$
				'Display size    '+strjoin( strcompress(subdim , /rem), ' x ')	,	$
				' ',	$
				'Current box      X:['+strjoin( strcompress(box[0,*], /rem), ' - ', /single)+']  '+	$
								 'Y:['+strjoin( strcompress(box[1,*], /rem), ' - ', /single)+']',	$
				'Box size          '+strcompress(box[2]-box[0]+1)+' x'+strcompress(box[3]-box[1]+1),	$
				' ',	$
				'Pixel values:',	$
				'      minimum  '	+strcompress(zval[0]),	$
				'      maximum '	+strcompress(zval[1]),	$
				'      average  '	+strcompress(zval[2]),	$
				'      std dev   '	+strcompress(zval[3]),	$
				'      nr. pixels '	+strcompress(npix),		$
				'      sum total '	+strcompress(zval[2]*npix),$
				' ',	$
				'Fixed z-range '+(['No','Yes'])[fixz],	$
				'Log scale      '+(['No','Yes'])[zlog] ]

	i = dialog_message(message, dialog_parent=state.wid_info, /information, title='Box Information')

ENDELSE

RETURN  &  END
