! Tests plotting a DATA Feature on a Layer1D plot, then switching to a Layer2D (BUG 2802)
! The follow-on test covers the case where the piped data is not avialble yet
! The DATA feature should remain, even when not visible
!
! Note: This test runs to completion on its own
!
! @issue:   NXM-2710 and NXM-4075
! @author:  Jeanette McCall
!
startmacro

	switch INTERACTIVE interAct GET DEF=TRUE SDEF=TRUE

  ! set sampling rate
  set sr 1e5
  ! Inital plot is of type=line
  set plottype line
  
  set instr "This test will run to completion on its own."

  invoke z:waswarning nxm.sys.libg.Feature.isWarningFeatureNotDrawn()
  invoke ,, nxm.sys.libg.Feature.setWarningFeatureNotDrawn(true)

  if interAct then

    pipe on

      panel/msgid=main/setup/controls=gc
 
      ! Generate sine wave and get fft of the sine wave     
      waveform/rt _mywave{ps=32k} shape=sin form=cf elem=inf amp=32e3 freq=sr/40 delta=1/sr
      fft _mywave _myfft

      ! line plot of fft
      plot/id=idplot/READOU="+OnAxis" _myfft{FS=^fs} TYPE=LINE
      ! add DATA feature, which is only valid on Layer1D plots
      feature label=fdata table={NAME="PLOTFEAT", &
          TYPE=DATA,X=sr/40,DX=sr/10,COLOR=RED} plot=idplot
   
      ! Display instructions   
      gcontrol text info "Instructions" "^instr" 34 20 /title
 
      ! Switch to RASTER (Layer2D) plot type and then finish test - use timer to make switches   
      info "There should be one Warning about the use of TYPE=|DATA|."  
      set this.timer(0) 1 ! pauses for one second then sends TIMER message back to macro

   endif

  invoke ,, nxm.sys.libg.Feature.setWarningFeatureNotDrawn(waswarning)
endmacro

!******************************************************************!
procedure processMessage m:msg
  if msg.name EQS "Timer" then
    if ^plottype EQS "line" then
      ! switch to RASTER (Layer2D) plot type
      message FUNC=sendw ID=IDPLOT NAME=TYPE DATA=RASTER /WAIT=2
      res plottype raster
    else
      ! Check to make sure DATA feature remains though not visible
      set this.timer(0) 0 ! this turns timer off
      assert/text="^reg.main.name: Feature Not Lost When Hidden" &
    	   reg.idplot.features.plotfeat.type eqss "|Data|"
      pipe stop
    endif
 
  else
    ! do nothing
    say "^reg.main.name: Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return