;+
; Project     : SOHO - CDS     
;                   
; Name        : DISPLAY_GIS_WIN
;               
; Purpose     : Display GIS line-windows on the technical planning plot.
;               
; Explanation : On the technical planning TPLAN display, draw an outline of
;               the defined line window(s), or if in display-windows-only mode
;               just display the data within the window(s).  If in flag
;               window display mode then assumes a maximum of max_num_fwindow
;               plots will be needed.
;               
; Use         : IDL> display_gis_win [,num, /solid]
;    
; Inputs      : None
;               
; Opt. Inputs : num  -  the number of the line to display.  If absent, all are
;                       displayed.
;               
; Outputs     : None
;               
; Opt. Outputs: None
;               
; Keywords    : Solid   -  if present delineate window with a solid line
;                          rather than a dashed one.
;
; Calls       : None
;               
; Restrictions: Variable are transferred in the tp_page1 common blocks
;               
; Side effects: None
;               
; Category    : Technical planning.
;               
; Prev. Hist. :
;
; Written     : C D Pike, RAL, 10-Jun-1993
;               
; Modified    : To handle flag windows.  CDP, 19-Sep-94
;               Update plotting of flag windows.  CDP, 07-Nov-95
;
; Version     : Version 3, 07-Nov-95
;-            

pro display_gis_win, num, solid=solid

;
;  include tp common for display mode 
;
@tplan_com

;
;  which band are we dealing with?
;
gb  = string(GIS_band,format='(i1)')
gbc = 'GIS'+gb

;
;  solid or dashed?
;
if keyword_set(solid) then ltype=0 else ltype=2

;
;  save input plot scheme
;
sp = !p.multi

;
;  If the parameter num was specified, it is the window to display, 
;  otherwise do all of them.
;
;  Draw limits of the windows otherwise display the data within the 
;  window(s).
;
if n_elements(num) eq 0 then begin
   num = max(where(line_window.x_pos ge 0))
   if num ge 0 then begin
      inband = where(which_gis_band(line_window(indgen(num+1)).lam*  $
                                line_window(indgen(num+1)).order) eq GIS_band)
      if inband(0) ge 0 then begin
         for i=0,n_elements(inband)-1 do begin
            wl = pix2wave(gbc,(0 > line_window(inband(i)).left  < 2047))
            wr = pix2wave(gbc,(0 > line_window(inband(i)).right < 2047))
            if window_mode eq 'ALL' then begin
               if flag_state eq 0 and line_window(inband(i)).flag eq 1 $
                       then wid=3 else wid=1
               oplot,[wl,wl],[0,10000],line=ltype,col=236,thick=wid  
               oplot,[wr,wr],[0,10000],line=ltype,col=236,thick=wid  
            endif else begin
               if i eq 0 then !p.multi=[0,n_elements(inband),1]
               xl = 0 > line_window(inband(i)).left  < 2047
               xr = 0 > line_window(inband(i)).right < 2047
               wave = pix2wave(gbc,indgen(xr-xl+1)+xl)
               if not (flag_state eq 0 and line_window(inband(i)).flag eq 1) then begin
                  plot,wave,GIS_data(GIS_band-1,xl:xr),psym=10,col=236  
               endif
            endelse
         endfor
      endif
   endif
;
;  single line requested
;
endif else begin
   if which_gis_band(line_window(num).lam* $
                     line_window(num).order) eq GIS_band then begin
      wl = pix2wave(gbc,(0 > line_window(num).left  < 2047))
      wr = pix2wave(gbc,(0 > line_window(num).right < 2047))
      if window_mode eq 'ALL' then begin
         if keyword_set(solid) then begin
            fill_box,(wl+wr)/2.,!y.crange(1),wr-wl,6
         endif
         oplot,[wl,wl],[0,!y.crange(1)],line=ltype,col=236  
         oplot,[wr,wr],[0,!y.crange(1)],line=ltype,col=236  
         xl = 0 > line_window(num).left  < 2047
         xr = 0 > line_window(num).right < 2047
         wave = pix2wave(gbc,indgen(xr-xl+1)+xl)
         oplot,wave,GIS_data(GIS_band-1,xl:xr),psym=10,col=236  
         oplot,[wl,wr],[!y.crange(1),!y.crange(1)],col=236  
      endif else begin
         xl = 0 > line_window(num).left  < 2047
         xr = 0 > line_window(num).right < 2047
         wave = pix2wave(gbc,indgen(xr-xl+1)+xl)
         plot,wave,GIS_data(GIS_band-1,xl:xr),psym=10,col=236  
         sp = !p.multi
      endelse
   endif
endelse

;
;  restore plot scheme
;
!p.multi = sp

end

