;+
; NAME        : EIT_SUB_TOOL
;
; PURPOSE     : Select one or more EIT subfields.
;
; CATEGORY    : EIT Subfields
;
; EXPLANATION : 
;
; SYNTAX      : result = EIT_SUB_TOOL([file])
;
; EXAMPLES    : none
; 
; CALLED BY   :
;
; CALLS TO    : none
;
; ARGURMENTS  :	none
;
; KEYWORDS    : 
;	FILE	When present, the data file that will be displayed under the grid.
;		If not present, routine uses last receive full sun image.
;       OLD_POINT 	if set, use pre recentering (sun more north) coords.
;
; OUTPUTS     :
;       Returns the selected subfields, with the subfield offset substracted.
;
; COMMON      : none
;
; RESTRICTIONS: none
;
; SIDE EFFECTS: 
;	When un-highlighting a subfield block, then the part of the image
;	that was the little "nubby" is lost as well.
;
; PROJECT     : SOHO - EIT
;
; HISTORY     : V1,  Elaine Einfalt (HSTX)
;		1998 Jan - eitnfalt- added old_point keyword
;
; CONTACT     : eit@xanado.nascom.nasa.gov
;-

pro EIT_SUB_TOOL, $
		  blocks	= blocks,	$ 	; add these blocks
		  error		= error, 	$
		  offset	= offset,	$	; move to this offset
		  refile	= refile,	$	; read and display file 
		  sub_ids	= sub_ids, 	$	; previious pattern
		  substruc	= substruc,     $
		  old_point     = old_point

 if n_elements(no_offset) eq 0 then no_offset = 0	; do redraw pattern

 ;
 ; Some initialization
 ;

 error = 1						; assume errors
 wset, substruc.draw_index				; correct window

 ; Bring hidden draw window to the top, and keep user out until finished.

 if xregistered('EIT_SUBFIELD') then widget_control, hourglass=1

 ;
 ; Determine possible new grid and block size, due to window resizes.
 ;

 EIT_SUB_UTIL_LINE,  pix_per  = substruc.pix_per, $
		     resize_x = substruc.resize_x 


 ;
 ; When BLOCKS is present, highlight or unhighlight just these blocks.
 ;

 if blocks(0) ne -1 then $

    EIT_SUB_UTIL_BLK, 	blocks 	  = blocks,    		$
			sub_ids   = sub_ids,		$
			substruc  = substruc

 ;
 ; When OFFSET is present, then redraw subfield pattern at this offset locale.
 ;

 if offset ne -1 then $

    EIT_SUB_UTIL_MOVE, 	offset    	= offset,    	$
			sub_ids	  	= sub_ids,	$
			substruc	= substruc


 ;
 ; When REFILE is present, then display a fresh file.
 ;

 if refile then $

    EIT_SUB_UTIL_FILE, sub_ids	 = sub_ids,		 $
		       substruc	 = substruc,		 $
		       old_point = old_point	



 ;  
 ; Indicate the offset subfield with "nubbies" and rewrite interface(s)
 ;  

 EIT_SUB_UTIL_OFF, old_offset	= substruc.offset, 		$
		   sub_ids	= sub_ids,			$
		   substruc	= substruc

			
 ;
 ; Bring subfield tool back to the foreground.
 ;

 if xregistered('EIT_SUBFIELD') then widget_control, hourglass=0


error = 0					; made it with no errors
 
return
end

