!******************************************************************************!
! Test the selection of points when using multiple instances of LayerT5 inside
! and outside of LayerDrawable
!
!
! @bug      NXM-3511 Multiple LayerT5 select
! @since    3.9.3
! @author:  Kevin Esterheld
!******************************************************************************!
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)

  call setDatDir

  if interAct then
    set instructions "Left Plot - 2 LayerT5 instances in a LayerDrawable\n\n&
                      Right Plot - 2 separate LayerT5 instances\n\n&
                      Bottom Plot - geodetic mode with points in space.&
                      (Note: the points in space should have lines connecting them)\n\n&
                      1) Click between the 2 points in each plot:\n&
                      Left: will select the closest point\n&
                      Right: both points will be selected\n\n&
                      2) Hold down ctrl and click on a point.\n&
                      You should see a popup showing the attributes for the selected point.&
                      \n\n&
                      3) On the bottom plot, click on some of the points and they should select&
                      correctly. (ctrl click as well)\n\n"

    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 20 /title
      set quals1 {HEADERROWS=L:1,COLUMNNAMES="D:X,D:Y,D:Z,NAME,F3", LAYER={LT="T5",name=LT5_draw1,group=TEST,autoselectenable="click",AutoSelectMode=Pixel}}
      set quals2 {HEADERROWS=L:1,COLUMNNAMES="D:X,D:Y,D:Z,NAME,F3", LAYER={LT="T5",name=LT5_draw2,group=TEST,autoselectenable="click"}}
      set quals3 {HEADERROWS=L:1,COLUMNNAMES="D:X,D:Y,D:Z,NAME,F3", LAYER={LT="T5",name=LT5_1,autoselectenable="click"}}
      set quals4 {HEADERROWS=L:1,COLUMNNAMES="D:X,D:Y,D:Z,NAME,F3", LAYER={LT="T5",name=LT5_2,autoselectenable="click"}}
      set quals5 {LAYER={LT="T5",name=LT5_sv3,group=TEST,autoselectenable="click",AutoSelectMode=Pixel}}

      plot/id=plot1  ^{datDir}.world.prm|{LT="Drawable",name=TEST,listlayers=true}|nxm.sys.test.test_drawable1.csv^{quals1}|nxm.sys.test.test_drawable2.csv^{quals2} xmin=-20,xmax=33,ymin=-27,ymax=31
      plot/id=plot2  ^{datDir}.world.prm|nxm.sys.test.test_drawable1.csv^{quals3}|nxm.sys.test.test_drawable2.csv^{quals4} xmin=-20,xmax=33,ymin=-27,ymax=31
      plot/id=plot3  ^{datDir}.world.prm|{LT="Drawable",name=TEST,listlayers=true}|^{datDir}.sv3.prm^{quals5}|nxm.sys.test.test_drawable1.csv^{quals1}|nxm.sys.test.test_drawable2.csv^{quals2} view=geo
    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
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
! If an unexpected exception is caught, mark test as failed, unless it is expected
!******************************************************************************!
procedure processException m:emsg
  if expectedException REXISTS then
    assert/text="^reg.main.name: Expected ERROR starts with: ^{expectedException}" expectedException EQSS emsg.data.message
    remove expectedException
  else
    assert/text="^reg.main.name: Caught unexpected exception ^{emsg.data}" "FALSE" isTrue
    if "Trace" SUBS ENV.DEBUG then invoke ,, emsg.data.printStackTrace()
  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
