;===============================================================================
; file UVSPDEFAULTS.PRO
;
; UVSPDEFAULTS.PRO -- set variables use in UVSP to default conditions 
;                      and turn on the default buttons
;
; EXPTYP	: 1=raster type data; 0=plot type data
; RESET		: If present, then still using same experiment but set
;		  to default options.
;
;==============================================================================


pro uvspdefaults, exptyp=exptyp, reset=reset

common order1, diskexp, control, generic, comment
common locals, widgt,  expran, yaxbase, detcount, binbase, lastmexe
common ctable, color_def

@uvspkeys.common
@uvspsave.common
@uvspstruct.common


 if n_elements(reset) eq 0 then reset=0 $	; avoid resetting everything
			   else reset=1		; reset everything 

 hard = 0	      				; 0=not a hard copy, 1=hardcopy
 set_plot,'X'         				; image to go to screen

 point = 0   					; reset for ea. new experiment
 maxcyc = 0  &  cycle = 1  & lastmexe=0		; info page variables

 c_det    = 0  					; reset each pass
 one_det  = 0    				; plot all detectors
 plotover = 1    				; overplot detectors

 nsome  = 1                  			; plot every point

 ;
 ; The axis ranges are always reset between experiments.
 ;

 ylohi  = [0L, 0L]				; full y-axis range
 
 color_def = 1					; use default color table

 omax = max(data)   		; get original data max, (may change)


 ;
 ; Remember current options between experiments (unless this is the first). 
 ; Only set back to default if the "RESET" button is pressed. 
 ;

 if (reset or (n_elements(p_scal) eq 0)) then begin          
	p_scal = 0                      ; plots in linear

   	plotover= 1    		 	; overplot detectors
        one_det = 0     		; plot all detectors

	mypsym = 0			; 0 is normal, 10 is histrogram
	mytick = 0.02			; 0.02 is normal, 1 is grid

        if omax gt 2000 then scal = 2 else scal = 1     	; image scale

   	solgrid= 0	      ; 0 = don't draw solar grid
   	rollo  = 0	      ; 0 = only roll -90, 1 = roll correction made
   	smuth  = 0	      ; 0 = not smooth image, 1 = smooth image
   	contur = 0	      ; 0 = contouring not in effect, 1 = contour image

        if hd(81) eq 1 then ave_sep = 0 else ave_sep = 1

	silent = 1 
 endif

 case exptyp of         ; 0=plots, 1=rasters

    0: begin            
	;
	; PLOTTING: Setup the default values for plots 
  	;

	struc.st2.tempwinx = 620  
	struc.st2.tempwiny = 512

        if not(timfil) then begin
		struc.st9.xaxis_start = 0 
		struc.st9.xaxis_end   = n_elements(data)/struc.st7.ndet-1  
	endif else begin
		struc.st9.xaxis_start = min(abscissa)
		struc.st9.xaxis_end   = max(abscissa)
	endelse
       end


    1: begin   		
	; 
	; RASTER: Setup the default values for rasters  
	;

   	struc.st1.tempscal=0      	     &  struc.st1.tempipc=5
   	struc.st1.tempnfr = struc.st7.nrpt   &  struc.st1.tempfrst = 1
   	struc.st1.temppixS = 0d   	     &  struc.st1.temppixA = 0d

   	templev = [-1]                		; default contour levels

   	struc.st3.tempdet = struc.st7.ndet 
        struc.st3.tempnd = struc.st7.ndet 
   	struc.st3.d1 = 0	    
        struc.st3.d2 = struc.st3.tempnd-1

;6/93 	struc.st2.win = 1.0d       	; the part of window to be used by image
;6/93   	struc.st2.tempwinx = 512.       ; the x size of window 
;6/93   	struc.st2.tempwiny = 512.       ; the y size of window

        if not(timfil) then begin
		struc.st9.xaxis_start = 1
		struc.st9.xaxis_end   = ((size(data))(5)) 
	endif else begin
		struc.st9.xaxis_start = min(abscissa)
		struc.st9.xaxis_end   = max(abscissa)
	endelse

       end

    else: 
 endcase

 ;
 ; Plot will use the full data range unless UVSPMAGNI changes XLOHI.
 ;

; if not(timfil) then struc.st9.xaxis_start = 0 $
; 	        else struc.st9.xaxis_start = min(abscissa)

 xlohi = [struc.st9.xaxis_start, struc.st9.xaxis_end]

 ;
 ;
 ; Go ahead and display with these sesttings
 ;
 ;

 uvspprocess, struc=struc, data=data, hd=hd, ave_sep=ave_sep, $
			scal=scal, p_scal=p_scal, contur=contur, $
			silent=silent, solgrid=solgrid, point=point,$
			rollo=rollo, $
			smuth=smuth, templev=templev, maxcyc=maxcyc, $
			exptyp=exptyp, timfil=timfil, cycle=cycle,  $
			abscissa=abscissa, plotover=plotover, one_det=one_det, $
			c_det=c_det, mytick=mytick, $
			ylohi=ylohi, xlohi=xlohi, nsome=nsome, mypsym=mypsym


end
