!******************************************************************************!
! Additional tests for LayerDrawable that apply to piped data.
!
! @bug      2913
! @author:  J Czechowski IV
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE  ! for defects or more obscure test case(s)

  if interAct then
    set instructions "On the Left\n&
                      -----------\n&
                      You should a line and raster plot of a signal. The data for both plots &
                      should fill the visible plot areas. The signal in the line &
                      plot should be highlighted by a yellow bar. (Bug 2913)\n&
                      \n&
                      \n&
                      On the Right\n&
                      ------------\n&
                      You should see a raster &
                      plot in the upper right, the data should fill the visible plot area and there &
                      should be no 'compressByte()' warnings printing to the terminal. (Bug 2913)\n\n\n&
                      Try XCuts and YCuts on these piped files\n&
                      ----------------------------------------\n&
                      TL Plot: get WARN only supported on Layer2D\n&
                      BL Plot: work\n&
                      TR Plot: get WARN need CUTS switch"

    set hasSV2 true
    set hasSV3 false

    pipe on
      set D:RF 123e6  ! simulated receiver RF freq.
      set D:BW  10e6  ! simulated receiver bandwidth

      panel/msgid=MAIN/setup/controls=gc
      shellgui/id=idshellgui/attach
      waveform/rt _signal FORM=CF DURATION=Inf SHAPE=Sine  RF=^{RF} VRF=^{RF} BW=^{BW}
      waveform/rt _noise  FORM=CF DURATION=Inf SHAPE=White RF=^{RF} VRF=^{RF} BW=^{BW}
      fcalc       _pred  _signal _noise +
      fft/psd     _pred  _psd NFFT=512 OVER=0.5 NAVG=4 /id=FFT
      status      _psd   XSTART=IF          ! get receiver IF from file (usually 0.0)
      headermod   _psd   XSTART=^{IF}+^{RF} ! set XSTART so plot shows it at RF not IF

      plot/id=LINEPLOT _psd|{LT="Drawable",name="FEATURES"} CM=10Log TYPE=LINE   MIMIC=RASTER /CUTS
      plot/id=RASTER   _psd|{LT="Drawable",name="FEATURES"} CM=10Log TYPE=RASTER MIMIC=LINEPLOT /CUTS
      plot/id=NOISE    _noise{FS=1024,XS=1000,YS=1000}|{LT="Drawable",name="FEATURES"} TYPE=RASTER CMAP=XRAMP AXIS=BRFrame

      feature ,, "SIGNAL" {NAME="SIGNAL",LAYER=reg.lineplot.features,LINE={COLOR="#66FFFF00"},&
                           TYPE=VBAR,X=^{RF},Y=-100,DX=1e6,DY=0} LINEPLOT


      gcontrol label macro  "Test MACRO"
      gcontrol menu  main   "Exit with Status =" "PASS,FAIL" TABLE={ItemColors={PASS="GREEN",FAIL="RED"}} /tleft
      gcontrol text  idtext "Instructions" instructions 24 24 /title
    pipe off
  endif
endmacro

!******************************************************************************!
! Main process message for this macro. Should be right after the ENDMACRO.
!******************************************************************************!
procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
! If an unexpected exception is caught, mark test as failed, unless it is expected
!******************************************************************************!
procedure processException m:emsg
  if expectedException REXISTS then
    assert/text="^reg.main.name: Expected ERROR starts with: ^{expectedException}" expectedException EQSS emsg.data.message
    remove expectedException
  else
    assert/text="^reg.main.name: Caught unexpected exception ^{emsg.data}" "FALSE" isTrue
    if "Trace" SUBS ENV.DEBUG then invoke ,, emsg.data.printStackTrace()
  endif
return

