!******************************************************************************!
! Test part of PLOT axis label being cut-off.
!
! @bug      2505 Plot: occasional errors in axis labels
! @bug      2932 PLOT: Problem with axis labels
! @author:  JC4 , J Bauer
! @since    NeXtMidas 3.1.0
! @version: $Id: test_plot_axislabels.mm,v 1.8 2015/11/17 21:43:56 ntn Exp $
!******************************************************************************!
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 "You should see 4 zoomed in line plots. \n&
                      Click through the views and make sure the X and Y axis labels are visible on all the raster plots, &
                      even when the window is shrunk until the individual plots are about 1 in. square.\n&  
                      X axis should have a -10 E6 label.\nY axis should have a 200 E-6 label \n\n&
                      Press the Toggle RotateVals button and the Y-axis labels should rotate and draw vertically.\n&
                      Again, click through each of the views and make sure the X and Y axis labels are visible."

    waveform ram:temp form=SF amp=6e6
    waveform ram:pred FORM=CF SHAPE=SINE RF=200e6 BW=20e6 VRF=200e6
    fft/psd  ram:pred ram:psd

    pipe on
      panel/msgid=MAIN/setup/controls=gc
      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 16 /title

      gcontrol button action "" "Toggle RotateVals (Y-axis)"
      gcontrol panel lineplot "Line Plot" 300 300
      plot/id=lineplot ram:temp
      invoke ,, reg.lineplot.setAxisDiv(3,5,5)

      ! plots for testing BUG 2932
      plot/id=plot1 ram:psd axis=BRFrame readout=+OnAxis
      plot/id=plot2 ram:psd axis=TRFrame readout=+OnAxis
      plot/id=plot3 ram:psd axis=BLFrame readout=+OnAxis
      plot/id=plot4 ram:psd axis=TLFrame readout=+OnAxis
      gcontrol menu view "Set View on Raster Plots" "YX,iYX,YiX,iYiX,XY,iXY,XiY,iXiY" reg.plot2.view

      ! Zoom in to show one of the issue for BUG 2505
      message send lineplot name=zoom data={x1=3.2e3,x2=1.9e3,y1=-2e6,y2=2e6}
    pipe off

    erase ram:temp ram:pred ram:psd
  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

  elseif msg.name eqs "ACTION" AND "ROTATE" SUBS msg.data then
    message send lineplot name=axis data="~RotateVals"
    set reg.plot1.axis ~RotateVals
    set reg.plot2.axis ~RotateVals
    set reg.plot3.axis ~RotateVals
    set reg.plot4.axis ~RotateVals

  elseif msg.name eqs "VIEW" then
    set reg.plot1.view msg.data
    set reg.plot2.view msg.data
    set reg.plot3.view msg.data
    set reg.plot4.view msg.data

  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return
