;+
; NAME        : EIT_SUB_UTIL_AREA
;
; PURPOSE     :
;
; CATEGORY    :
;
; EXPLANATION : 
;
; SYNTAX      : 
;
; EXAMPLES    : none
; 
; CALLED BY   :
;
; CALLS TO    : none
;
; ARGUMENTS   :	none
;
; KEYWORDS    : none
;
; OUTPUTS     : none
;
; COMMON      : none
;
; RESTRICTIONS: none
;
; SIDE EFFECTS: none
;
; PROJECT     : SOHO - EIT
;
; HISTORY     : V1,  Elaine Einfalt (HSTX)
;
; CONTACT     : eit@xanado.nascom.nasa.gov
;-

pro EIT_SUB_UTIL_AREA, sub_ids=sub_ids, substruc=substruc 

 ; Get box corners, upper left and lower right

 coord = EIT_SUB_UTIL_BOX(/get_coord)

 coord.up_left_x = 0 > coord.up_left_x < substruc.resize_x
 coord.up_left_y = 0 > coord.up_left_y < substruc.resize_x
 coord.low_right_x = 0 > coord.low_right_x < substruc.resize_x
 coord.low_right_y = 0 > coord.low_right_y < substruc.resize_x

 block1 = fix(coord.up_left_x/substruc.pix_per)  +  $
	      	(32 * (32-fix(coord.up_left_y/substruc.pix_per)))
 block2 = fix((coord.low_right_x-substruc.pix_per)/substruc.pix_per) + $
		(32 * (31-fix(coord.low_right_y/substruc.pix_per)))


 ;
 ; Mark just boxed blocks with a 2, process any with a 2
 ;

 area_ids = sub_ids
;95/10/27 for i = block1, block2, 32 do area_ids(i:i+(block2 mod 32)-(block1 mod 32))= 2
 for i = block1, block2, 32 do begin
	area_ids(i:i+(block2 mod 32)-(block1 mod 32))= 2
 endfor
 blocks = where(area_ids eq 2b)			; just ones inside new box
 
 ;
 ; When in EIT grid mode, then highlight just this new boxed area.
 ; When in solar grid mode then must redraw the whole thing,
 ; (with previous sub_ids and then add in the new blocks)
 ; because the EIT grid lines that are drawn inside highlighted
 ; areas need to be erased.
 ;

 if substruc.grid_flag then refile = 0  $	; don't re-TV the image
 		       else refile = 1		; re-TV the image


 ; File        : same
 ; Grid        : same
 ; Rotation    : current displayed in tool interface
 ; Offset      : current displayed in tool interface
 ; Subfields   : same, but with these new blocks to be added
 ; Window size : same

 EIT_SUB_DISP, 	blocks	  = blocks,		$	; just the new blocks
		refile 	  = refile, 		$	; maybe full redraw
		sub_ids   = sub_ids,		$	; the previous pattern
		substruc  = substruc


return
end

