!******************************************************************************!
! Test that covers the placement of text on Features that are IconSymbols
!
! @bug      NXM-3647 Feature: IconSymbol text drawn in wrong location
!
! @since    4.0.0
! @author:  Jeanette McCall
!******************************************************************************!
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 "Check placement of the Feature Text in both plots\n\n&
                      - Text in zoomed in plot should still be close to the Feature   \n&
                        (i.e. placement should look similar to unzoomed plot)\n\n&
                      - placement should match the name:\n   &
                        LTAG - right justified on left of IconSymbol\n   &
                        TTAG - centered and above IconSymbol\n   &
                        RTAG - left justified on right of IconSymbol\n   &
                        BTAG - centered and below IconSymbol\n   &
                        DEFAULT - left justified against center\n\n&
                      Note: zoomed in plot tag names start with 'Z'\n& 
                      "

    set this.timer(0) 0.1
    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

      plot/id=nozoom/msgid=main world readoutExt=+SHOW|+FEATURE &
               readout=+OnAxis|+AlwaysDeltas view=latlon Y1=-90 Y2=90

      plot/id=zoom/msgid=main world readoutExt=+SHOW|+FEATURE &
               readout=+OnAxis|+AlwaysDeltas view=latlon X1=-80 X2=80 Y1=-40 Y2=40

    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 "TIMER" then
    set this.timer(0) 0
    call addFeature LTAG LTAG  -40   0
    call addFeature TTAG TTAG    0  20
    call addFeature RTAG RTAG   40   0
    call addFeature BTAG BTAG    0 -20
    call addFeature DTAG DTAG    0   0
    call addFeature ""   DEFAULT -70 30
  else

  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

!*****************************************************************************
! add Feature
!*****************************************************************************
procedure addFeature s:tagtype s:featureName l:xvalue l:yvalue

  res addon ""
  if tagtype NEQS "" then
    res addon "|^tagtype"
  endif
  feature label=^featureName table={NAME="^featureName",TYPE=SYMBOL|TEXT^{addOn},X=^xvalue,Y=^yvalue,&
                                  LINE={SYMBOL="^{datDir}.Arrow.png"}} &
                                  plot=nozoom
  feature label=Z^{featureName} table={NAME="Z^featureName",TYPE=SYMBOL|TEXT^{addOn},X=^xvalue,Y=^yvalue,&
                                  LINE={SYMBOL="^{datDir}.Arrow.png"}} &
                                  plot=zoom
return
