! Plot tests for LayerMulti.
!
! @bug     954   LayerMulti: does not correctly handle pipe data ...
! @bug     1210   LayerMulti: Missing refresh() at the end of setColumns(..)
!
! @Author:  J. Hallam / Neon Ngo
!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE

  call setDatDir

  if interAct then
    ! ==== Make the file of waves ====
    waveform ram:waves{FLAGS=APPEND} elem=512 shape=Sine
    waveform ram:waves{FLAGS=APPEND} elem=512 shape=Triangle
    waveform ram:waves{FLAGS=APPEND} elem=512 shape=Square

    status ram:waves xs=file_xs xd=file_xd xu=file_ux
    headermod ram:waves fs=512 ys=file_xs yd=file_xd yu=file_ux
    keyword ram:waves put "LEGEND" "Sine,Triangle,Square"

    pipe on
      panel/msgid=MAIN/setup/controls=gc
      gcontrol label macro "MACRO"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}

      set myInstructions "TOP PLOT:\n&
                          1) initially a square wave\n&
                          2) change the value of the 'Traces' widget\n&
                          -> should change which waves are shown\n\n&
                          BOTTOM PLOT:\n&
                          - a whole bunch of data in multiple colors."

      gcontrol text idtext "Instructions" "^myInstructions" 24 10 /title
      gcontrol menu changeColumns "Traces" "Sine,Triangle,Square" "|Square|" /tleft /toggle /togglelist /chkbox /nc=3

      plot/id=waves  ram:waves{LAYER={LT="Multi2D",TRACES="^{gc.changeColumns.value}"}}
      plot/id=alaska ^{datDir}.alaskat.prm{LAYER={LT="Multi2D"}} y1=-8000 y2=3000
    pipe off

  endif

endmacro

!**************************************************************************************************!
procedure processMessage
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop

  elseif msg.name eqs "CHANGECOLUMNS" then
    set reg.waves.layers.waves.traces "^msg.data"

  elseif msg.name eqs "STATE"
    pipe ^msg.data

  else
    !warning "^reg.main.name: unrecognized message ^msg.name from ^msg.fid"
  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
