!******************************************************************************!
! Starter test for access to LayerDrawable Features through MMB Layer menu
!
! Arguments: none
!
! @bug      NXM-4117 Need Continuous Lat/Lon Plot
! @since    4.1.4
! @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 "Go into the Layers menu\n&
                      Select VENN\n&
                      Select Features\n&
                      Select a Feature Group\n&
                      Select and modify a Feature"


    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 26 /title

      ! Change the keyMap to custom settings
      env set KEYMAP {PLOT={LEFT="L",RIGHT="R",in=i,down=d,up=u,out=o}}


      plot/id=layfeat ^{datDir}.world.prm|{LT="Drawable",name="VENN"}  /MSGID=MAIN  view=latloncontinuous

      set layVenn reg.layfeat.layers.VENN
      feature ,, vennRed    {NAME="RED", GROUP="TRAFFICLIGHT", LINE={COLOR="#66FF0000"},LAYER=layVenn,TYPE=BOX|FILLED, X=-180,Y=60,DX=50,DY=50} LAYFEAT
      feature ,, vennGreen  {NAME="GREEN", GROUP="TRAFFICLIGHT", LINE={COLOR="#6600FF00"},LAYER=layVenn,TYPE=BOX|FILLED, X=-100,Y=-20,DX=30,DY=30} LAYFEAT
      feature ,, vennBlue   {NAME="BLUE", GROUP="SKY", LINE={COLOR="#660000FF"},LAYER=layVenn,TYPE=BOX|FILLED, X=0,Y=20,DX=25,DY=25} LAYFEAT
      feature ,, vennYellow {NAME="YELLOW",GROUP="TRAFFICLIGHT",LINE={COLOR="#99FFFF00"},LAYER=layVenn,TYPE=VBAR|FILLED,X=180,Y=-40,DX=15,DY=15} LAYFEAT
      feature ,, vennWhite  {NAME="WHITE", GROUP="SKY", LINE={COLOR="#66AAAAAA"},LAYER=layVenn,TYPE=CIRC|FILLED,X=100,Y=10,DX=30,DY=30} LAYFEAT
!      !feature ,, vennPink {NAME="PINK",LINE={COLOR=PINK},LAYER=layVenn,TYPE=ELPS|FILLED,X=140,Y=0,DX=25,DY=40,SEMIMAJOR=10,SEMIMINOR=10,TILT=30} LAYFEAT !Add if BUG 2940 is worked

      shellgui/id=idshellgui/attach

!      gcontrol button listButt  "List Features               " "FEAT" "" /TLeft

    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 "LISTBUTT" then
    if msg.data eqs "FEAT"
      invoke t:featObjs layFeats.getDrawables("FEATURES",true)
      res t:featObjs
    endif
  elseif msg.name eqs "PAN" then
    invoke nxm.sys.test.TestLayerDrawable.panTest(reg.plot1)
  elseif msg.fid EQS "LAYFEAT" then
    if msg.name EQS "MARK" then
      res msg.data
      invoke matches REG.LAYFEAT.LAYERS.VENN.getDrawablesAt(msg.data)

      if (matches.size == 0) then
        say "Selected colors: <NONE>"
      else
        say/L=0 "Selected colors:"
        for f in matches
          say/L=0 " ^f.name"
        endfor
        say/L=1 ""
      endif
    endif

  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





