!------------------------------------------------------------------------------!
! Test the plotting of a Layer1D file as a raster and toggle between line/raster
! See Bug 605 for details.
!
! Author:  J. Bauer
!------------------------------------------------------------------------------!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE

  call setDatDir

  set def_instructions &
      "Should see a RASTER plot of fftdemo. Click the LINE button."

  set line_instructions &
      "Should see a LINE plot of fftdemo. Click the RASTER button to change &
       the TYPE to RASTER."

  set rast_instructions &
      "Should see a RASTER plot of fftdemo. Prior to Bug 605 fix this display &
       would revert back to the default (TYPE=LINE). Click the LINE button &
       to change the TYPE to LINE or PASS/FAIL to exit. "

  if interAct then
    pipe init

    panel/msgid=MAIN/setup/controls=gc
    plot/id=idplot/READOUT="+OnAxis" ^{datDir}.fftdemo.prm{fs=24}

    gcontrol label mainLabel "Main"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}
    gcontrol text idtext "Instructions" "^def_instructions" 24 12 /title

    gcontrol button changeType "CHANGE TYPE" "LINE,RASTER" none

    pipe off

  endif

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

  elseif msg.name EQS "CHANGETYPE" then
    if msg.data EQS "LINE" then
      set reg.panel.controls.idtext.value "^line_instructions"
      message FUNC=send ID=IDPLOT NAME=TYPE DATA=LINE
    elseif msg.data EQS "RASTER" then
      set reg.panel.controls.idtext.value "^rast_instructions"
      message FUNC=send ID=IDPLOT NAME=TYPE DATA=RASTER
    endif

  else
    ! do nothing
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
! Set the dat directory
!******************************************************************************!
procedure setDatDir
  invoke nxmMajor env.nmversion.subString(0,1)
  invoke major java.lang.Integer.valueOf(nxmMajor)
  if major GE 4 then
    invoke s:datDir           nxm.sys.test.DatLocator.getDatDirLocation()
    invoke s:datDirSlash      nxm.sys.test.DatLocator.getDatDirSlashLocation()
    invoke z:sysDatFull       nxm.sys.test.DatLocator.sysDatFull()
    invoke z:sysTestDatExists nxm.sys.test.DatLocator.sysTestDatExists()
  else
    set s:datDir           "nxm.sys.dat"
    set s:datDirSlash      "nxm/sys/dat"
    set z:sysDatFull       true
    set z:sysTestDatExists false
  endif
return
