!******************************************************************************!
! Test drawing cones across the dateline.
!
! Arguments: None
!
! @bug      NXM-2507 Plot / LayerT5: FillCones option doesn't completely
!                    fill cones on the dateline
! @bug      NXM-3131 PLOT: Zoomed in TLOPs (TDOA LOPs) sometimes not showing up,
!                    int saturation on zooms
! @since    NeXtMidas 3.1.2
! @author:  S Henderson / J Bauer
!******************************************************************************!
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)

  if interAct then
    call setDatDir

    set instructions "Both plots should have drawn across the dateline:\n&
                      - 1 green outline and fill ellipse\n&
                      - 1 unfilled-with-red-border zig-zag polygon\n& 
                      - 1 green-fill-with-purple-border zig-zag polygon\n&
                      - both green fill shapes should be completely filled\n   in on both sides of the map\n\n&
                      Click 'Zoom In' button:\n&
                      - portion of ellipse shown should be filled\n\n&
                      Left Plot: LatLon view\n\n&
                      Right Plot: Mercator view"

    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 16 /title
      gcontrol button zoom "" "Zoom In"

      plot/id=plota ^{datDir}.world.prm|&
           nxm.sys.test.test5000_cones.prm{LAYER={FLAGS=+fillCones}}|&
           nxm.sys.test.kmlPolyFillTest.kml

      plot/id=plotb ^{datDir}.world.prm|&
           nxm.sys.test.test5000_cones.prm{LAYER={FLAGS=+fillCones}}|&
           nxm.sys.test.kmlPolyFillTest.kml &
           view=mercator
    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 "ZOOM" then
    message sendw id=plota name=ZOOM data={xmin=158.7020765425,xmax=158.7020765525,ymin=33.6477245,ymax=33.6477246}
  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
