!******************************************************************************!
! Test that the select feature functionality is working correctly
!
!
! @bug      NXM-3067 Allow attaching of meta data to features
!           NXM-4121 Features that only show up when zoomed
! @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 "MMB click on one of the triangles. &
                        Select Features -> Selected -> <NAME> -> Metadata \n&
                        Should say 'This is <name of feature>'\n\n&
                      CTRL-MMB click on another triangle\n&
                      -> should get a popup describing the feature\n\n&
                      Zoom in on one of the features that does not have text &
                      and the text should show\n\n&
                      Zoom in on the lowest traingle and a red star feature will appear in the middle"
    set color WHITE
    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 18 /title
      plot/id=idplot ^{datDir}.apenny.prm
      feature/id=tri1 label=ftriangle1 table={NAME="TRIANGLE1",TYPE=SYMBOL|TEXT|RTAG,X=120,Y=125,&
                                  COLOR=^color,LINE={SYMBOL="UTRI"},METADATA="This is TRIANGLE1"} plot=idplot
      feature/id=tri2 label=ftriangle2 table={NAME="TRIANGLE2",TYPE=SYMBOL|TEXT|RTAG,X=100,Y=100,TextZoomRatio=0.5,&
                                  COLOR=^color,LINE={SYMBOL="LTRI"},METADATA="This is TRIANGLE2"} plot=idplot
      feature/id=tri3 label=ftriangle3 table={NAME="TRIANGLE3",TYPE=SYMBOL|TEXT|RTAG,X=80,Y=80,TextZoomRatio=0.5,&
                                  COLOR=^color,LINE={SYMBOL="DTRI"},METADATA="This is TRIANGLE3"} plot=idplot
      feature/id=tri4 label=ftriangle4 table={NAME="TRIANGLE4",TYPE=SYMBOL|TEXT|RTAG,X=60,Y=60,TextZoomRatio=0.5,&
                                  COLOR=^color,LINE={SYMBOL="RTRI"},METADATA="This is TRIANGLE4"} plot=idplot
      feature/id=tri5 label=ftriangle5 table={NAME="TRIANGLE5",TYPE=SYMBOL|TEXT|RTAG,X=40,Y=40,TextZoomRatio=0.5,&
                                  COLOR=^color,LINE={SYMBOL="TRI",SYMBOLSIZE=12,SymbolFill=on},METADATA="This is TRIANGLE5"} plot=idplot
      feature/id=detail label=detail table={TYPE=SYMBOL|TEXT|RTAG,X=40,Y=40,FeatureZoomRatio=0.8,TextZoomRatio=0.00001,&
                                  COLOR="RED",LINE={SYMBOL="STAR",SYMBOLSIZE=6,SymbolFill=on},METADATA="This only shows up when zoomed"} plot=idplot
    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
