;+
; PROJECT
;           Solar-B EIS
;
; NAME
;           EIS_PLOT_OBEV
;
; PURPOSE
;           Plots any of given resource item on the resource row
;
; CATEGORY
;           Planning, Science
;
; EXPLANATION
;           This routine plots any of the resource items on the science
;           plan display. Currently, DSN contact times, commanding times
;           (throughput RCR), and delayed commanding times
;           (payload_reserved) should be plotted on the same row; Other
;           station events should be plotted on the other row.
;
; SYNTAX
;           plot_resource, obev, startdis, row = row
;
; INPUTS
;           obev     - a structure
;           startdis - the start time (TAI) of the display period
;
; KEYWORDS
;           row      - row number in which the item is plotted
;
; RESTRICTIONS
;           PLOT_FRAME must be called first.
;
; WRITTEN
;           John A Rainnie Aug-2005 RAL
;               Based on "/ssw/soho/gen/idl/science/plot_resource.pro"
;               retained backbone of procedure but changed resouse names
;               etc for EIS choice of row and subrow, now depends on
;               resource type
;
; HISTORY
;          v0.1 18-Apr-2007 JAR
;               Removed STOP from CASE ELSE: statement - and replaced
;               it with RETURN. This is to eliminate DAY and NGT
;               items which will be plotted by other means.
;          v0.2 Tidied up!
;-
;______________________________________________________________________________
PRO eis_plot_obev, obev , startdis , row = row

datastart      = anytim2utc(startdis)
datastart.time = 0
daystart       = utc2tai(datastart) ; start of STARTDIS in TAI

t1 = (obev.start_time - daystart) / 3600.d0
t2 = (obev.stop_time  - daystart) / 3600.d0

;---------------------------------------------------------------------------
;  There are SAA and HLA orbit events
;---------------------------------------------------------------------------
CASE STRLOWCASE(obev.name) OF
    'saa'  : BEGIN
                      sub_row = 0
                      color   = 2
                  END
    'hla' : BEGIN
                      sub_row = 1
                      color   = 1
                  END
    ELSE        : RETURN
ENDCASE

;---------------------------------------------------------------------------
;  Match number of sub rows in the resource row
;---------------------------------------------------------------------------
num_rows = 2

;---------------------------------------------------------------------------
;  Sub-row width refelcts the fact that there is 5% of space reserved
;  in the bottom and top of the row
;---------------------------------------------------------------------------

srow_wid = 0.9/num_rows

y1 = row + 0.05 + (sub_row * srow_wid)
y2 = y1  + srow_wid
x1 = t1 > !x.crange[0]
x2 = t2 < !x.crange[1]
IF (x2 GT x1) THEN POLYFILL , [x1 , x2 , x2 , x1] ,                         $
                              [y1 , y1 , y2 , y2] , color = color


END
