!******************************************************************************!
! Tests the ability to PLOT multiple lines within a single plot in line format, 
! including RVI complex mode. This interactive test case demonstrates
! that BUG 2397 (Plot multi-line races in RVI mode) has been resolved.
!
! Arguments: None
!
! @bug      2397: PLOT: Multi-line traces from 2000 files
! @author:  Chris Simons
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=TRUE SDEF=TRUE  ! for defects or more obscure test case(s)


  call setDatDir

  if interAct then
    set instructions "Click the 'Convert' button.\n\n&
                     The top-left line plot should now exactly match the RVI &
                     plot at the top-right.\n\nNext, compare the bottom-left line plot of Alaska &
                     to the screenshot of the same plot in the bottom-right.\n\n&
                     The plot and the screenshot should appear identical.\n\n&
                     If both test cases pass, press the 'PASS' button."


    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 23 /title

      ! GControls
      gcontrol button btnSwitchMode "Convert to RVI" "Convert" /tleft

      ! This will test the resolution for bug 2397, 
      ! which resolves an issue that prevented multi-line type 2000 
      ! traces from plotting correctly when plotted as "line" type
      ! and "rvi" complex mode.
      ! The same resolution includes a modification to Layer1D.java
      ! that adds support for "-1" value for the /LPS switch,
      ! which, when supplied, will cause Layer1D to
      ! to compute the size of the underlying plot data buffer
      ! in order to determine the lines per screen value

      plot/id=rviplot ^{datDir}.test2000_cf.prm type=line cm=rvi /lps=-1
      plot/id=lineplot ^{datDir}.test2000_cf.prm type=line /lps=-1
      plot/id=alaskaplot ^{datDir}.alaska.prm type=line /lps=-1
      plot/id=alaskaexport ^{datDir}.alaska_line_lps.jpg axis=NONE

    pipe off

  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 "BTNSWITCHMODE" then
    set reg.lineplot.mode "RVI"
  else
    say "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
