!******************************************************************************!
! Test plotting files using new LayerScatter
!
! @author  J. Czechowski IV / Edward R. Cable
!******************************************************************************!
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
    call setDatDir

    file open/d/n test_file ram:test_file{SR=(AZ/SD,EL/SD)}
      do azi -10 50 1
        do eli -10 50 1
          file write test_file {AZ=^azi,EL=^eli}
        enddo
      enddo
    file close test_file

    set instructions "Plot 1/2: Both should display vertical lines comprised of &
                      circular points that are connected by straight, diagonal &
                      lines (no circles). Click 'ZoomIn' and verify that neither &
                      plot has any extra points.\n&
                      \n&
                      Plot 3/4: Both should show straight diagonal lines. (Prior to &
                      the fix for Bug 2721 the lines would have clearly been wavy.)\n&
                      \n&
                      Plot 5: A map of the world with red marks indicating global &
                      airport positions.\n&
                      \n&
                      Plot 6: A zoomed-in map of the world with major cities indicated &
                      by a green dot and capital cities (e.g. London) indicated with &
                      a red circle around the dot."

    ! Create data for Plot 1 and Plot 2
    call createMidasFileData ram:test3000 3000
    call createMidasFileData ram:test6000 6000
    res azelQuals {LAYER={LT="Scatter",X="AZ",Y="EL",LINE={TYPE=SOLID|SYMBOL,SYMBOL=CIRCLE}}}

    ! Create data for Plot 3 and Plot 4
    ramp ram:time SD 16 2012:01:01::00:00:00 300
    ramp ram:data SD 16 0 300
    group ram:myfile ram:time ram:data
    headermod ram:myfile SR=(TIME/SD,DATA/SD) YU=TIME_S

    ! Create data for Plot 5
    result airportQuals {HEADERROWS=1,LAYER={LT="Scatter",X="LONGITUDE",Y="LATITUDE",LINE={COLOR="red",TYPE="symbol"}}}

    ! Create data for Plot 6
    noop ^{datDir}.capital_cities.prm{SR=(ALT/SD,LAT/SD,LON/SD,NAME/1A)} ram:caps

    res citiesQuals {LAYER={SYMBOL="DOT"}}
    res capsQuals   {LAYER={COLOR=RED,LT="Scatter",X="LON",Y="LAT",LINE={TYPE=SYMBOL,SYMBOL=CIRCLE}}}

    pipe on
      panel/setup/controls=gc

      gcontrol menu   main   "Exit with Status = " "PASS,FAIL" /tleft
      gcontrol text   idtext "Instructions" "^instructions" 24 25 /title
      gcontrol button zoom   ""             "ZoomIn"
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}

      plot/id=plot1 ram:test3000^{azelQuals}
      plot/id=plot2 ram:test6000^{azelQuals}
      plot/id=plot3 ram:myfile{LAYER={LT="Scatter",X=TIME,Y=DATA,TYPE="+SYMBOL"}}     readout=+DateString
      plot/id=plot4 ram:time{YU=TIME_S,LAYER={LT="Multi",COLUMNS="*",TYPE="+SYMBOL"}} readout=+DateString
      plot/id=plot5 ^{datDir}.world.prm|^{datDir}.airports.csv^{airportQuals}
      plot/id=plot6 ^{datDir}.world.prm|^{datDir}.cities.prm^{citiesQuals}|ram:caps^{capsQuals}

      message send PLOT6 NAME=ZOOM INFO=0 DATA={XMIN=-10,XMAX=5,YMIN=48,YMAX=54}
    pipe off
  endif

  ! Additional interactive tests, only run with /BASELINE
  if baseline then
    %test_plot_layerscatter_units ! Bug 2795
  endif
endmacro

!******************************************************************************!
! ProcessMessage procedure
!******************************************************************************!
procedure processMessage m:msg

  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: Interactive tests" msg.data EQSS "PASS"
    pipe stop

  elseif msg.name eqs "ZOOM" and msg.data eqs "ZoomIn" then
    message sendw PLOT1 ,, ZOOM ,, {XMIN=D:0.75,XMAX=D:1.3,YMIN=D:38,YMAX=D:48.5}
    message sendw PLOT2 ,, ZOOM ,, {XMIN=D:0.75,XMAX=D:1.3,YMIN=D:38,YMAX=D:48.5}
  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

!******************************************************************************!
! Create a Midas Blue 3000 or 6000 file for testing
!******************************************************************************!
procedure createMidasFileData FN:fileName s:type
  file open/d/n filetag ^{fileName}{TYPE=^{type},SR=(AZ/SD,EL/SD)}
    do azi -10 50 1
      do eli -10 50 1
        file write filetag {AZ=^azi,EL=^eli}
      enddo
    enddo
  file close filetag
return
