pro show_obs2, structure, selimg, ss
;
;+
;NAME:
;	show_obs2
;PURPOSE:
;	To plot when images are taken for each of the particular
;	observing regions.  Also mark where the sequence table or
;	entry table changed.  An option exists to select images with
;	the cursor (select time range).
;CALLING SEQUENCE:
;	show_obs2, roadmap
;	show_obs2, roadmap, sel
;	show_obs2, sxtp, sel, ss	;observing log vector
;INPUT:
;	Structure- Roadmap or observing log entry.  Index structures
;		   cannot be passed at this time.
;OPTIONAL OUTPUT:
;	selimg	- If present, the user is prompted to mark a
;		  starting and ending time of interest.  The value
;                 returned is an array of the same length as
;                 the input array with the selected datasets
;                 having a "1".  The way to use this value is
;                 something like the following:
;                       ss = where(selimg)
;                       ss = where(selimg and (roadmap.percentd eq 255))
;       ss      - Return the list of indicies that were selected.
;                 This should be used only if you do not want to
;                 do other searches using the "where" function.
;HISTORY:
;	Written 7-Nov-91 by M.Morrison (using S.Freeland routine as a start)
;       12-Nov-91 (MDM) - Added "ss" parameter option
;	16-Nov-91 (MDM) - Changed to use UTPLOT instead of plot
;	20-Nov-91 (MDM) - Changed DP_MODE and DP_PLOT symbol from histogram
;			  (psym=10) to usersym (simple horizontal line) because
;			  histogram mode fools the user into thinking that data
;			  exists where it does not
;-
;
ref_tim = structure(0)
x = int2secarr(structure, ref_tim)
xrange = [min(x), max(x)]
dummy = fmt_tim(structure(0), day_str)
;
parts = [.18, .30, .45]
;
usersym,[-0.5,0.5],[0,0]
                        !p.region = [0,0, .95,parts(0)]
                        dp_mode = gt_dp_mode(structure)
                        ytickv = indgen(7)+8
                        ytickname = [' ', 'FL', ' ', 'BCS', 'NGT', 'QT', ' ']
                        utplot, x, dp_mode, ref_tim, psym=8, $
                                yrange = [8,14], ytitle = 'DP Mode', $
                                yticks = 6, ytickv=ytickv, ytickname=ytickname, ystyle=1, ymargin=[4,0], $
				xrange = xrange, xstyle=8, xticklen=.2	;UTPLOT has a problem with ticklengths?
                                ;;xtitle='Hour of day starting ' + day_str, $

                        !p.region = [0,parts(0)+.01, .95,parts(1)]
                        dp_rate = gt_dp_rate(structure)
                        ytickv = indgen(6)
                        ytickname = [' ', 'Low', 'Med', ' ', 'High', ' ']
                        utplot, x, dp_rate, ref_tim, psym=8, /noerase, $
                                yrange = [0,5], ytitle = 'DP Rate', $
                                yticks = 5, ytickv=ytickv, ytickname=ytickname, ystyle=1, ymargin=[0,0], $
                                xrange = xrange, xstyle=4

!p.region = [0,parts(1)+.01, .95,parts(2)]
utplot, x, gt_seq_tab(structure), ref_tim, /noerase, $
        xrange = xrange, xstyle=4, $
	ystyle = 1, psym=10, ymargin=[1,1], $
	ytitle = 'Seq Table Ser#', $
	yrange = [min(gt_seq_tab(structure))-1, max(gt_seq_tab(structure))+1]


usersym,[0,0],[-1.5,1.5]

!p.region = [0,parts(2)+.01, .95,.95]
y = gt_seq_num(structure)
ors = y(uniq(y,sort(y)))
utplot, x, y, ref_tim, /noerase, $
        xrange=xrange, xstyle=4, $
	ystyle=8, psym=8, title='Image Start Times!c', $
	yrange=[min(y)-1, $
	        max(y)+1], $
        ; ytickname=[string(ors)],	$
	yticklen=-.01,$ 
	ytickv=ors, $ ; ytickname=[string(ors)], $
	yticks=n_elements(ors)+2, $
	ytitle='Sequence Number', ymargin=[1,2]
;
if (n_params(0) ge 2) then begin
    selimg = bytarr(n_elements(x))
    get_boxcorn, x0, y0, x1, y1, /data
    draw_boxcorn, x0, y0, x1, y1, /data
    print, 'X Range: ', x0, x1
    print, 'Y Range: ', y0, y1
    ss = where( (x ge x0) and (x le x1) and (y ge y0) and (y le y1))
    if (ss(0) ne -1) then selimg(ss) = 1
    print, 'There are ', strtrim(fix(total(selimg)),2), ' images selected'
end
;
!p.region = 0
end
