; revu.pro

; ReVu is a quick look tool to review UVI data for 
; the purpose of scanning a large number of images.
; No color bar is provided since the color intensity scale
; is not guaranteed to be accurate.

; v1.0 created by M. Brittnacher based on code developed by
;   G. Germany for L1VU.
; v2.0 revision by J. O'Meara, M. Brittnacher, and G. Germany 9/19/97

PRO revu_event,event

COMMON IMGINFO, filseq,ipseq,roti_val,xborder,yborder,enhance,speed,scale
COMMON WIDGID,stim,etim,enhs,forw,revr,sped
COMMON RECINFO, numrecs, begRec, endRec, curRec
COMMON FLAGS, file_flag,run_flag

WIDGET_CONTROL, event.id, GET_UVALUE=type

ipeqv = [3,1,2,4] ; list integ. period in droplist order
fileqv = [4,3,2,1,5,7,0,6,8] ; list filter number in droplist order

CASE type OF
  0: WIDGET_CONTROL, /DESTROY, event.top
  1: open_files
  2: decrement_image
  3: increment_image
  4: BEGIN
       roti_val = event.index
       IF file_flag THEN make_image,curRec
     END
  5: ipseq = ipeqv(event.index)
  6: filseq = fileqv(event.index)
  7: WIDGET_CONTROL, GET_VALUE=start_time, stim
  8: WIDGET_CONTROL, GET_VALUE=end_time, etim
  9: BEGIN
       WIDGET_CONTROL, GET_VALUE=enhance, enhs
       IF file_flag THEN make_image,curRec
     END
 10: WIDGET_CONTROL, GET_VALUE=speed, sped
 11: first_image
 12: last_image
ENDCASE

END

;--------------------------------------------------------------

PRO open_files

COMMON IDS, img_id
COMMON WIDGID,stim,etim,enhs,forw,revr,sped
COMMON HOUSE, filter_arr,rate_arr,gain_arr,doorpos_arr,system_arr
COMMON RECINFO, numrecs, begRec, endRec, curRec
COMMON PATHS,img_path
COMMON FLAGS, file_flag,run_flag
COMMON STRUCT, begep,endep,ft

img_file=PICKFILE(PATH=img_path,FILTER='*.cdf',GET_PATH=img_path,$
  TITLE='Please Select Image File')
IF (img_file EQ '') THEN RETURN ELSE img_id=CDF_OPEN(img_file)

file_flag = 1

info=CDF_INQUIRE(img_id)                     
numrecs=info.maxrec+1

CDF_VARGET,img_id,'FILTER',tmp,REC_COUNT=numrecs,COUNT=[1,1,1]
filter_arr = REFORM(tmp)

CDF_VARGET,img_id,'FRAMERATE',tmp,REC_COUNT=numrecs,COUNT=[1,1,1]
rate_arr = REFORM(tmp)

CDF_VARGET,img_id,'GAIN',tmp,REC_COUNT=numrecs,COUNT=[1,1,1]
gain_arr = REFORM(tmp)

CDF_VARGET,img_id,'DOORPOS',tmp,REC_COUNT=numrecs,COUNT=[1,1,1]
doorpos_arr = REFORM(tmp)

CDF_VARGET,img_id,'SYSTEM',tmp,REC_COUNT=numrecs,COUNT=[1,1,1]
system_arr = REFORM(tmp)

time_limits

make_tags,begep,date_tag,time_tag
WIDGET_CONTROL,stim,SET_VALUE=time_tag

make_tags,endep,date_tag,time_tag
WIDGET_CONTROL,etim,SET_VALUE=time_tag

curRec = 0
make_image,curRec

END

;--------------------------------------------------------------

PRO first_image

COMMON RECINFO, numrecs, begRec, endRec, curRec
COMMON FLAGS, file_flag,run_flag

IF NOT (file_flag) THEN BEGIN
  filw = WIDGET_MESSAGE('Please select file first!')
  RETURN
ENDIF

curRec = begRec
make_image,curRec

END

;--------------------------------------------------------------

PRO last_image

COMMON RECINFO, numrecs, begRec, endRec, curRec
COMMON FLAGS, file_flag,run_flag

IF NOT (file_flag) THEN BEGIN
  filw = WIDGET_MESSAGE('Please select file first!')
  RETURN
ENDIF

curRec = endRec
make_image,curRec

END

;--------------------------------------------------------------

PRO increment_image

COMMON WIDGID,stim,etim,enhs,forw,revr,sped
COMMON FLAGS, file_flag,run_flag
COMMON RECINFO, numrecs, begRec, endRec, curRec

IF NOT (file_flag) THEN BEGIN
  filw = WIDGET_MESSAGE('Please select file first!')
  RETURN
ENDIF

show_frame = 0
record = curRec
WHILE (record+1 LE endRec) AND (NOT show_frame) DO BEGIN
  record = record + 1
  check_image,record,show_frame
ENDWHILE
IF (record GE endRec) THEN run_flag = 0
IF show_frame THEN BEGIN
  curRec = record
  make_image,record
ENDIF

END

;--------------------------------------------------------------

PRO decrement_image

COMMON WIDGID,stim,etim,enhs,forw,revr,sped
COMMON FLAGS, file_flag,run_flag
COMMON RECINFO, numrecs, begRec, endRec, curRec

IF NOT (file_flag) THEN BEGIN
  filw = WIDGET_MESSAGE('Please select file first!')
  RETURN
ENDIF

show_frame = 0
record = curRec
WHILE (record-1 GE begRec) AND (NOT show_frame) DO BEGIN
  record = record - 1
  check_image,record,show_frame
ENDWHILE
IF (record LE begRec) THEN run_flag = 0
IF show_frame THEN BEGIN
  curRec = record
  make_image,record
ENDIF

END

;--------------------------------------------------------------

PRO forward_event,event

COMMON WIDGID,stim,etim,enhs,forw,revr,sped
COMMON FLAGS, file_flag,run_flag
COMMON RECINFO, numrecs, begRec, endRec, curRec

IF NOT (file_flag) THEN BEGIN
  filw = WIDGET_MESSAGE('Please select file first!')
  RETURN
ENDIF

WIDGET_CONTROL,forw,SET_VALUE='Stop'
WIDGET_CONTROL,forw,EVENT_PRO='stop_event'

run_flag = 1
WHILE (run_flag) DO BEGIN
  IF (curRec+1 LE endRec) THEN increment_image ELSE run_flag = 0
  dest = WIDGET_EVENT(forw,/NOWAIT)
ENDWHILE
run_flag = 1

WIDGET_CONTROL,forw,SET_VALUE=' >> '
WIDGET_CONTROL,forw,EVENT_PRO='forward_event'

END

;--------------------------------------------------------------

PRO reverse_event,event

COMMON WIDGID,stim,etim,enhs,forw,revr,sped
COMMON FLAGS, file_flag,run_flag
COMMON RECINFO, numrecs, begRec, endRec, curRec

IF NOT (file_flag) THEN BEGIN
  filw = WIDGET_MESSAGE('Please select file first!')
  RETURN
ENDIF

WIDGET_CONTROL,revr,SET_VALUE='Stop'
WIDGET_CONTROL,revr,EVENT_PRO='stop_event'

run_flag = 1
WHILE (run_flag) DO BEGIN
  IF (curRec-1 GE begRec) THEN decrement_image ELSE run_flag = 0
  dest = WIDGET_EVENT(revr,/NOWAIT)
ENDWHILE
run_flag = 1

WIDGET_CONTROL,revr,SET_VALUE=' << '
WIDGET_CONTROL,revr,EVENT_PRO='reverse_event'

END

;--------------------------------------------------------------

PRO stop_event,event

COMMON FLAGS, file_flag,run_flag

run_flag = 0

END

;--------------------------------------------------------------

PRO init_colors, color

COMMON COLORS, r_orig, g_orig, b_orig, r_curr, g_curr, b_curr
COMMON UCOLORS,white

LOADCT,color
r_curr = r_orig
g_curr = g_orig
b_curr = b_orig
dim = (SIZE(r_curr))(1)
white = dim - 1
r_curr(white) = 255
g_curr(white) = 255
b_curr(white) = 255
TVLCT,r_curr,g_curr,b_curr

END

;--------------------------------------------------------------

PRO init_calib

COMMON CALIB,dor_trn,cal_pri,cal_sec

dor_trn = [1.,.42,.42,.5,.54,.6,1.]

cal_pri = [[0.00000, 0.00000, 0.00000, 0.00000, 0.00000], $
           [104856., 69040.9, 16178.0, 19339.2, 467548.], $
           [32188.6, 21194.0, 4966.40, 5936.71, 143527.], $
           [11276.5, 7424.84, 1739.80, 2079.79, 50281.4], $
           [3304.10, 2175.52, 509.790, 609.391, 14732.8], $
           [1824.39, 1201.24, 281.490, 336.482, 8134.86], $
           [454.213, 299.068, 70.0810, 83.7727, 2025.30], $
           [189.559, 124.812, 29.2470, 34.9614, 845.234], $
           [88.5061, 58.2751, 13.6550, 16.3236, 394.642], $
           [34.7352, 22.8707, 5.35940, 6.40639, 154.882], $
           [16.0651, 10.5777, 2.47870, 2.96296, 71.6332], $
           [7.68857, 5.06239, 1.18620, 1.41804, 34.2828], $
           [1.61900, 1.06600, 0.24980, 0.29860, 7.21900], $
           [.405390, 0.26692, 0.06250, 0.07476, 1.80763], $
           [0.00000, 0.00000, 0.00000, 0.00000, 0.00000]]

cal_pri = TRANSPOSE(cal_pri)
  
cal_sec = [[0.00000, 0.00000, 0.00000, 0.00000, 0.00000], $
           [127321., 62534.4, 14864.4, 17965.3, 0.00000], $
           [61454.8, 30183.9, 7174.72, 8671.45, 0.00000], $
           [18202.4, 8940.24, 2125.10, 2568.42, 0.00000], $
           [4852.45, 2383.31, 566.514, 684.695, 0.00000], $
           [2653.04, 1303.06, 309.737, 374.352, 0.00000], $
           [860.102, 422.444, 100.415, 121.363, 0.00000], $
           [412.820, 202.759, 48.1959, 58.2501, 0.00000], $
           [195.276, 95.9109, 22.7980, 27.5540, 0.00000], $
           [71.1447, 34.9431, 8.30599, 10.0387, 0.00000], $
           [34.5806, 16.9845, 4.03721, 4.87942, 0.00000], $
           [16.0025, 7.85974, 1.86826, 2.25800, 0.00000], $
           [3.79000, 1.86146, 0.44246, 0.53477, 0.00000], $
           [1.22975, 0.60399, 0.14357, 0.17352, 0.00000], $
           [0.35836, 0.17601, 0.04184, 0.05056, 0.00000]]

cal_sec = TRANSPOSE(cal_sec)

END

;--------------------------------------------------------------

PRO  make_tags,eps,date_tag,time_tag

yeastr = STRING(eps.year-1900,FORMAT='(I2)')
monstr = STRING(eps.month,FORMAT='(I2)')
daystr = STRING(eps.day,FORMAT='(I2)')
houstr = STRING(eps.hour,FORMAT='(I2)')
minstr = STRING(eps.minute,FORMAT='(I2)')
secstr = STRING(eps.second,FORMAT='(I2)')
IF (eps.month LT 10) THEN monstr = '0'+STRING(eps.month,FORMAT='(I1)')
IF (eps.day LT 10) THEN daystr = '0'+STRING(eps.day,FORMAT='(I1)')
IF (eps.hour LT 10) THEN houstr = '0'+STRING(eps.hour,FORMAT='(I1)')
IF (eps.minute LT 10) THEN minstr = '0'+STRING(eps.minute,FORMAT='(I1)')
IF (eps.second LT 10) THEN secstr = '0'+STRING(eps.second,FORMAT='(I1)')
date_tag = yeastr+monstr+daystr
time_tag = houstr+minstr+' UT'

END

;--------------------------------------------------------------

PRO get_atc_time,id,record,eps,epoch_err

eps = {epoch_struct, YEAR: 0, MONTH: 0, DAY: 0, HOUR: 0, $
   MINUTE: 0, SECOND: 0}

; limits for valid epoch
epoch0 = 60000000000000.D
epoch1 = 70000000000000.D

epoch = 0.D
CDF_VARGET1,id,'EPOCH',epoch,REC_START=record

IF (epoch GT epoch0) AND (epoch LT epoch1) THEN BEGIN
  epoch_err = 0
  CDF_EPOCH,epoch,year,month,day,hour,minute,second,/BREAKDOWN_EPOCH
  eps.year = year
  eps.month = month
  eps.day = day
  eps.hour = hour
  eps.minute = minute
  eps.second = second
ENDIF ELSE epoch_err = 1

END

;--------------------------------------------------------------

PRO time_limits

COMMON IDS, img_id
COMMON RECINFO, numrecs, begRec, endRec, curRec
COMMON STRUCT, begep,endep,ft

; find the first and last valid epochs
epoch_err = 1
record = 0
WHILE epoch_err DO BEGIN
  get_atc_time,img_id,record,begep,epoch_err
  record = record + 1
ENDWHILE
begRec = record - 1

epoch_err = 1
record = numrecs - 1
WHILE epoch_err DO BEGIN
  get_atc_time,img_id,record,endep,epoch_err
  record = record - 1
ENDWHILE
endRec = record + 1

END

;--------------------------------------------------------------

PRO getTime_event,event

COMMON IDS, img_id
COMMON WIDGID,stim,etim,enhs,forw,revr,sped
COMMON RECINFO, numrecs, begRec, endRec, curRec
COMMON FLAGS, file_flag,run_flag
COMMON STRUCT, begep,endep,ft

IF NOT (file_flag) THEN BEGIN
  filw = WIDGET_MESSAGE('Please select file first!')
  RETURN
ENDIF

time_limits

get_record,begep,begRec,'Start Time',time_tag
WIDGET_CONTROL,stim,SET_VALUE=time_tag

get_record,endep,endRec,'End Time',time_tag
WIDGET_CONTROL,etim,SET_VALUE=time_tag

curRec = begRec
make_image,curRec

END

;--------------------------------------------------------------

PRO find_record,flag,id,epoch,record

COMMON RECINFO, numrecs, begRec, endRec, curRec

CDF_VARGET,id,'EPOCH',tmp,REC_COUNT=numrecs,COUNT=[1,1,1]
epoch_ary = REFORM(tmp)
diff = ABS(epoch_ary - epoch)
r_ary = WHERE(diff EQ MIN(diff))
record=r_ary(0)

END

;--------------------------------------------------------------

PRO get_record,eps,record,wid_title,time_tag

COMMON IDS, img_id
COMMON RECINFO, numrecs, begRec, endRec, curRec

; build compound widget
usrBase=WIDGET_BASE(COLUMN=1,TITLE=wid_title)
hID=CW_FIELD(usrBase,TITLE='  Hour:',VALUE=eps.hour $
             ,/INTEGER,/RETURN_EVENTS)
mID=CW_FIELD(usrBase,TITLE='Minute:',VALUE=eps.minute $
             ,/INTEGER,/RETURN_EVENTS)
sID=CW_FIELD(usrBase,TITLE='Second:',VALUE=eps.second $
             ,/INTEGER,/RETURN_EVENTS)

; realize base and start event handler for this base
WIDGET_CONTROL,usrBase,/REALIZE
uevent=WIDGET_EVENT(usrBase) 

; the return key was hit.  read values and then
; get rid of text widget
WIDGET_CONTROL, hID, GET_VALUE=hary
WIDGET_CONTROL, mID, GET_VALUE=mary
WIDGET_CONTROL, sID, GET_VALUE=sary
WIDGET_CONTROL, usrBase, /DESTROY

; reformat values read from text widget
hour=hary(0)
minute=mary(0)
second=sary(0)

; build epoch corresponding to requested time.
; note that we are using year, month, and day
; from original epoch
CDF_EPOCH,new_epoch,eps.year,eps.month,eps.day, $
  hour,minute,second,/COMPUTE_EPOCH    

; this provides a reference to determine whether the first or last
; record should be chosen if the out of limits flag is set
CDF_EPOCH,epoch,eps.year,eps.month,eps.day,eps.hour,eps.minute $ 
  ,eps.second,/COMPUTE_EPOCH    

; find record corresponding to time.  
; a return value of -1 means time was 
; outside of data limits.  set default
; of goto record input to appropriate value
find_record,'img',img_id,new_epoch,record
IF(record EQ -1) THEN BEGIN
    IF(new_epoch LT epoch) THEN record = 0
    IF(new_epoch GT epoch) THEN record = numrecs-1
ENDIF

CDF_VARGET1,img_id,'EPOCH',epoch,REC_START=record
CDF_EPOCH,epoch,year,month,day,hour,minute,second,/BREAKDOWN_EPOCH
  
; reset epoch structure
eps.hour = hour
eps.minute = minute
eps.second = second

; create timetag
make_tags,eps,date_tag,time_tag

END

;--------------------------------------------------------------

PRO check_image,record,show_frame

COMMON HOUSE, filter_arr,rate_arr,gain_arr,doorpos_arr,system_arr
COMMON IMGINFO, filseq,ipseq,roti_val,xborder,yborder,enhance,speed,scale
COMMON RECINFO, numrecs, begRec, endRec, curRec
COMMON IDS, img_id

; determine if the filter(s) is available
filter = filter_arr(record)
CASE filseq OF
  0: IF (filter EQ 0) THEN show_frame = 1 ELSE show_frame = 0
  1: IF (filter EQ 1) THEN show_frame = 1 ELSE show_frame = 0
  2: IF (filter EQ 2) THEN show_frame = 1 ELSE show_frame = 0
  3: IF (filter EQ 3) THEN show_frame = 1 ELSE show_frame = 0
  4: IF (filter EQ 4) THEN show_frame = 1 ELSE show_frame = 0
  5: IF (filter EQ 5) THEN show_frame = 1 ELSE show_frame = 0
  6: IF (filter EQ 6) THEN show_frame = 1 ELSE show_frame = 0
  7: IF (filter GE 0) AND (filter LT 7) THEN show_frame = 1 $
       ELSE show_frame = 0
  8: IF (filter EQ 3) OR (filter EQ 4) THEN show_frame = 1 $
       ELSE show_frame = 0
ELSE: show_frame = 0
ENDCASE
  
; determine if the integration period is available 
IF show_frame THEN BEGIN
  rate = rate_arr(record)
  CASE ipseq OF
    1:  IF (rate EQ 1) THEN show_frame = 1 ELSE show_frame = 0
    2:  IF (rate EQ 2) THEN show_frame = 1 ELSE show_frame = 0
    3:  show_frame = 1
    4:  IF (rate EQ 4) THEN show_frame = 1 ELSE show_frame = 0
  ELSE: show_frame = 0
  ENDCASE
ENDIF

END

;--------------------------------------------------------------

PRO make_image,record

COMMON HOUSE, filter_arr,rate_arr,gain_arr,doorpos_arr,system_arr
COMMON IMGINFO, filseq,ipseq,roti_val,xborder,yborder,enhance,speed,scale
COMMON RECINFO, numrecs, begRec, endRec, curRec
COMMON IDS, img_id
COMMON UCOLORS,white
COMMON CALIB,dor_trn,cal_pri,cal_sec

; correct for integration period
rate = rate_arr(record)
IF (rate GE 1.) AND (rate LT 5.) THEN ip_corr = 4./rate $
  ELSE ip_corr = 1.
CASE rate OF
  1: ratstr = '9 sec'
  2: ratstr = '18 sec'
  4: ratstr = '36 sec'
ELSE: ratstr = 'N/A'
ENDCASE

; make filter string
filter = filter_arr(record)
CASE filter OF
  0: filstr = 'HOME'
  1: filstr = '1304'
  2: filstr = '1356'
  3: filstr = 'LBHS'
  4: filstr = 'LBHL'
  5: filstr = 'SOLR'
  6: filstr = 'SHUT'
ELSE: filstr = 'N/A'
ENDCASE

doorpos = doorpos_arr(record)
CASE doorpos OF
  1: BEGIN 
       door_trans = 1.          ; full extent
       dorstr = 'open'
     END
  2: BEGIN
       door_trans = 1.          ; open
       dorstr = 'open'
     END
  3: BEGIN
       door_trans = dor_trn(filter)
       dorstr = 'closed'
     END
  ELSE: BEGIN
          door_trans = 1.
          dorstr = 'door?'
        END
ENDCASE

; obtain absolute calibration factor
gain = gain_arr(record)
system = system_arr(record) + 1
IF (filter GT 0) AND (filter LE 5) AND $
  (gain GT 0) AND (gain LE 15) THEN BEGIN
  CASE system OF
    1: abs = cal_pri(gain-1,filter-1)
    2: abs = cal_sec(gain-1,filter-1)
  ELSE: abs = 1.
  ENDCASE
ENDIF ELSE BEGIN 
  abs = 1.
ENDELSE

; get image                      
image=INTARR(200,228)                      
sub_image=INTARR(50,228)                      
IF !VERSION.OS EQ 'Win32' THEN BEGIN                      
  ;The CDF interface under the 32-bit Windows versions of IDL
  ;cannot handle transfers of >64K.  We have to read the 
  ;image in 4 passes.
  CDF_VARGET,img_id,'INT_IMAGE',sub_image,REC_START=record, $
      OFFSET=[0,0],COUNT=[50,228]                      
  image(0:49,*) = sub_image                      
  CDF_VARGET,img_id,'INT_IMAGE',sub_image,REC_START=record, $
      OFFSET=[50,0],COUNT=[50,228]                      
  image(50:99,*) = sub_image                      
  CDF_VARGET,img_id,'INT_IMAGE',sub_image,REC_START=record, $
      OFFSET=[100,0],COUNT=[50,228]                      
  image(100:149,*) = sub_image                      
  CDF_VARGET,img_id,'INT_IMAGE',sub_image,REC_START=record, $
      OFFSET=[150,0],COUNT=[50,228]                      
  image(150:199,*) = sub_image                      
ENDIF ELSE BEGIN                      
  CDF_VARGET,img_id,'INT_IMAGE',image,REC_START=record
ENDELSE                      

; get atc time and time tags
get_atc_time,img_id,record,eps,epoch_err
IF epoch_err THEN BEGIN
  date_tag = 'unknown'
  time_tag = 'unknown'
ENDIF ELSE make_tags,eps,date_tag,time_tag

image = scale*enhance*ip_corr*abs*(image-27.)/door_trans

CASE system OF
  1: image = ROTATE(image,2) 
  2: image = REVERSE(image) 
  ELSE: ;do nothing
ENDCASE

fin_img = ROTATE(image,roti_val)

CASE roti_val OF
  0: origin = [xborder+14,yborder]
  1: origin = [xborder,yborder+14]
  2: origin = [xborder+14,yborder]
  3: origin = [xborder,yborder+14]
ENDCASE

ERASE  
TV,fin_img>0<255,origin(0),origin(1)
top = [xborder,yborder+228+10]
bot = [xborder,10]
brt = [xborder+180,10]
top_tag = date_tag+'                 '+dorstr
bot_tag = 'ATC '+time_tag+'   '+filstr
brt_tag = ratstr
XYOUTS,top(0),top(1),top_tag,/DEVICE,CHARSIZE=1.5,COLOR=white
XYOUTS,bot(0),bot(1),bot_tag,/DEVICE,CHARSIZE=1.5,COLOR=white
XYOUTS,brt(0),brt(1),brt_tag,/DEVICE,CHARSIZE=1.5,COLOR=white
period = (100. - speed)/99.
WAIT,period
   
END

;--------------------------------------------------------------

PRO revu

versionstr = 'ReVu v2.0'

COMMON WIDGID,stim,etim,enhs,forw,revr,sped
COMMON IMGINFO, filseq,ipseq,roti_val,xborder,yborder,enhance,speed,scale
COMMON FLAGS, file_flag,run_flag
COMMON STRUCT, begep,endep,ft
COMMON PATHS,img_path

; structures for beginning and ending sequence of images
begep = {beg_epoch, YEAR: 0, MONTH: 0, DAY: 0, HOUR: 0, $
   MINUTE: 0, SECOND: 0}
endep = {end_epoch, YEAR: 0, MONTH: 0, DAY: 0, HOUR: 0, $
   MINUTE: 0, SECOND: 0}
; structure for image frame time
ft = {frame_time, YEAR: 0, MONTH: 0, DAY: 0, HOUR: 0, $
   MINUTE: 0, SECOND: 0}

; user set path [ e.g. img_path = '/disk99/uvi' ]
; location of the po_l1_uvi_199xxxxx_v0x.cdf files

img_path = '.'
   
; set up to use 8-bit color on a true color device

; device, pseudo_color = 8
  device, decompose = 0

; user set color table [valid numbers are 0-40]
; type LOADCT at the IDL prompt to list options
; suggested value: color_table_number = 33

color_table_number = 33

; user set image intensity
; this parameter adjusts the intensity range of the displayed image
; suggested value: scale = 0.03

scale = 0.03

init_colors,color_table_number
init_calib

; initialize flags
file_flag = 0
run_flag = 1

; initialize constants and variables
nxpix = 200
nypix = 228
enhance = 100
xborder = 20
yborder = 30
xwin = nypix + 2*xborder
ywin = nypix + 2*yborder

;Initialize Widgets
filt_dplist = ['LBHL','LBHS','1356','1304','SOLR', $
               'ALL ','HOME','SHUT','LBH']
intp_dplist = ['ALL ','  9 ',' 18 ',' 36 ']
roti_dplist = ['NORM','90  ','180 ','270 ']
filseq = 4
ipseq=3
roti_val = 0
speed = 100

; parent
base = WIDGET_BASE(/ROW,TITLE=versionstr)

; child 1 (chi1)
chi1 = WIDGET_BASE(base,/COLUMN)
quit = WIDGET_BUTTON(chi1,UVALUE=0,VALUE='Quit')
getf = WIDGET_BUTTON(chi1,UVALUE=1,VALUE='Select File')
roti = WIDGET_DROPLIST(chi1,UVALUE=4,VALUE=roti_dplist,TITLE='Rotation:')
filt = WIDGET_DROPLIST(chi1,UVALUE=6,VALUE=filt_dplist,TITLE='Filter:  ')
intp = WIDGET_DROPLIST(chi1,UVALUE=5,VALUE=intp_dplist,TITLE='Int Per: ')
gett = WIDGET_BUTTON(chi1,VALUE='   Select Range   ', $
  EVENT_PRO='getTime_event')

enhs = WIDGET_SLIDER(chi1,UVALUE=9,VALUE=100,TITLE='     Intensity %', $
   MINIMUM=1,MAXIMUM=500)
sped = WIDGET_SLIDER(chi1,UVALUE=10,VALUE=100,TITLE='        Speed', $
   MINIMUM=1,MAXIMUM=100)

; child 2 (chi2)
chi2 = WIDGET_BASE(base,/COLUMN)
wdw1 = WIDGET_DRAW(chi2,XSIZE=xwin,YSIZE=ywin)

; grandchild 1
gch1 = WIDGET_BASE(chi2,/ROW)
begr = WIDGET_BUTTON(gch1,UVALUE=11,VALUE=' |< ')
revr = WIDGET_BUTTON(gch1,VALUE='  <<  ',EVENT_PRO='reverse_event')
decr = WIDGET_BUTTON(gch1,UVALUE=2,VALUE=' < ')
incr = WIDGET_BUTTON(gch1,UVALUE=3,VALUE=' > ')
forw = WIDGET_BUTTON(gch1,VALUE='  >>  ',EVENT_PRO='forward_event')
endr = WIDGET_BUTTON(gch1,UVALUE=12,VALUE=' >| ')

; grandchild 2
gch2 = WIDGET_BASE(chi2,/ROW)
slbl = WIDGET_LABEL(gch2,VALUE='Start:')
stim = WIDGET_TEXT(gch2,UVALUE=7,VALUE='  ',XSIZE=7,/ALL_EVENTS)
elbl = WIDGET_LABEL(gch2,VALUE='    End:')
etim = WIDGET_TEXT(gch2,UVALUE=8,VALUE='  ',XSIZE=7,/ALL_EVENTS)

;Produce the interface tool

WIDGET_CONTROL, base, /REALIZE
WIDGET_CONTROL, GET_VALUE=windex, wdw1

;Hand-off control to the event manager

XMANAGER, 'revu', base

END