!******************************************************************************!
! EXPERIMENTAL Tests the clustering of LayerT5
!
! @author:  Kevin Esterheld
!******************************************************************************!

startmacro

switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE
switch KEEP        keep     GET DEF=FALSE SDEF=TRUE

set expPointCount  8
call setDatDir

if interAct then
  mergefile ^{datDir}.cities.prm temp_testplot_cities /replay=40
  nxm.sys.test.plotellipsetester OUT="temp_testplot_hugefile" ELEM=10K
  !set startPoint 0
  set instructions "Both plots show clustering of points. Confirm that clustering functionality is working on both plots:\n\n&
                    1. The Left Plot should show a static set of clusters of points\n\n&
                    2. The Right Plot's feature count (number of red circles) should increment by one each time points are cleared &
                    (every 5 seconds)."

  pipe on
    nxm.sys.test.plotellipsetester/RT/RATE=100/TL=25 OUT=_t5pipe{SIZE=150000} ELEM=Inf

    panel/msgid=MAIN/setup/controls=gc
    plot/mousewheelzoom/usemouseposition/id=pipe ^{datDir}.world.prm|_t5pipe{Layer={NAME=piped,ShowClusters=true}} &
                                                 x1=-180 x2=180 y1=-90 y2=90 options="-BStore" &
                                                 readoutExt=+SHOW|+FEATURE|+POINTS readout=+OnAxis
    plot/mousewheelzoom/usemouseposition/id=cities ^{datDir}.world.prm|^{datDir}.cities.prm{Layer={NAME=cities,ShowClusters=true}} &
                                                   readoutExt=+SHOW|+FEATURE|+POINTS readout=+OnAxis


    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" ^instructions 24 12 /title
    invoke nxm.sys.test.plotellipsetester.resetPlot(reg.pipe, 5)   ! changed to 5-second intervals - since 4.0.0

  pipe off
endif
endmacro

!******************************************************************************!
procedure processMessage m:msg
  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: Interactive tests" msg.data eqss "PASS"
    pipe stop
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid dats: ^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

!******************************************************************************!
procedure setInstructions s:msgString
  set reg.panel.controls.idtext.value msgString
return
