! Test the MPlot.clearData() function added as per Bug 429 (DR 542355-1)
!
! Author:  J. Czechowski
! Version: $Id: test_plot_cleardata.mm,v 1.4 2013/03/08 20:59:52 jwb Exp $
!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  set inst "Clicking the 'Clear' button should momentarily clear both of the &
            plots (this is hard to see in the line plot). The raster should &
            clear and start drawing from the top again. Once 'Clear' has been &
            pressed resize the window slightly to verify that the old data is &
            gone from the raster."

  if interAct then
    pipe on
      set sr 1e4
      set sfreq sr/10
      waveform/throttle=real _wave sf 10e10 sin freq=sr/10 amp=1e4 delta=1/sr
      fft/dbf _wave _waveb{form=sb} nfft=1k over=0

      panel/msgid=MAIN/setup/controls=gc
      plot/id=plot1/nice _waveb{cl=8} cnt=motion type=line y1=-100 y2=80
      plot/id=plot2/nice _waveb cnt=click z1=-100 z2=80 /lpb=16
      gcontrol label macro "MACRO"
      gcontrol menu   main   "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}
      gcontrol text   idtext "Instructions" "^inst" 24 11 /title
      gcontrol button clear  "Options" "Clear" /

    pipe off

  endif
endmacro


!******************************************************************************!
procedure processMessage m:msg
  !say "msg.name ^msg.name, data ^msg.data"

  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.name eqs "CLEAR" then
    invoke ,, reg.plot1.clearData()
    invoke ,, reg.plot2.clearData()
  else
    ! do nothing
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return
