!******************************************************************************!
! Test drawing of a polygon in Layert5 when zoomed in
!
! Arguments: None
!
! @bug      2488 PLOT: LayerT5 cuts off parts of polygons
! @author:  JC4 / 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)

  call setDatDir

  if interAct then
    set instructions "You should see 2 plots, each with red rectangle.\n\n&
                      Press 'ZOOM' button to zoom in on rectangle:\n&
                      1) TOP plot: rectangle should NOT be visible.\n&
                      2) BOTTOM plot: rectangle SHOULD be visible."

    ! create the Type 5000 file to display
    header/create ram:myfile TYPE=5000 SR=(NAME/4A,POS/VD,FLAG/8B,CONN/SB)

    file open/d/w out ram:myfile   ! open the file for editing

    ! define the polygon
    res t:row0 {name="POINT_0",POS=(0.0,20.0,30.0),FLAG=(0,0,2,0,-9,0,1,1),CONN=1}
    res t:row1 {name="POINT_1",POS=(0.0,20.0,60.0),FLAG=(0,0,2,0,-9,0,1,1),CONN=1}
    res t:row2 {name="POINT_2",POS=(0.0,10.0,60.0),FLAG=(0,0,2,0,-9,0,1,1),CONN=1}
    res t:row3 {name="POINT_3",POS=(0.0,10.0,30.0),FLAG=(0,0,2,0,-9,0,1,1),CONN=1}
    res t:row4 {name="POINT_4",POS=(0.0,20.0,30.0),FLAG=(0,0,2,0,-9,0,1,1),CONN=1}

    ! update the file
    invoke ,, out.writeDataTable(row0)
    invoke ,, out.writeDataTable(row1)
    invoke ,, out.writeDataTable(row2)
    invoke ,, out.writeDataTable(row3)
    invoke ,, out.writeDataTable(row4)

    file close out         ! cleanup resource

    !status/d ram:myfile   ! debugging

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

      gcontrol button myButt "" "Zoom"

      plot/id="MAP"  ^{datDir}.world.prm|ram:myfile{LAYER={COLORMAP="gray,red,yellow,green,blue"}} /quickdraw=true ! quickdraw optimizes but does not draw everything
      plot/id="MAP2" ^{datDir}.world.prm|ram:myfile{LAYER={COLORMAP="gray,red,yellow,green,blue"}} /quickdraw=false
    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 "MYBUTT" then
    message send map  name=ZOOM info=0 data={X1=25,X2=45,Y1=20,Y2=25}
    message send map2 name=ZOOM info=0 data={X1=25,X2=45,Y1=20,Y2=25}
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  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
