!******************************************************************************!
! Tests rendering of axis labels on small plots in extended range
! NOTE: mmp has {TYPE=POS,X=25,Y=25,W=1010,H=353} to cause right plot
! to have labels overlap without fix
!
! @bug      NXM-3583 LatLonContinuous plot axis tics should show standard longitude values
! @since    4.0.0
! @author:  Jeanette McCall
!******************************************************************************!
startmacro S:file_ext["shp"] 
  switch INTERACTIVE interAct   GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline   GET DEF=FALSE SDEF=TRUE

  if interAct then
    call setDatDir

    ! NXM-3976 since NeXtMidas 4.1.3
    if ^{env.NMROOT} EQS "classpath:" then
      res world_file  "world_copy.^{file_ext}{AUX=RAM}"
      file copy ^{datDir}.world.^{file_ext} world_file
      if file_ext eqs "shp" then file copy ^{datDir}.world.dbf world_copy.dbf{AUX=RAM}
    else
      res world_file "^{datDir}.world.^{file_ext}"
    endif

    set instructions "Check the Longitude (X) axis labels\n&
                      LEFT PLOT:\n&
                      - extended range shows both standard and extended range values\n&
                      - values should be readable\n\n&
                      RIGHT PLOT:\n&
                      - right most axis tic should have only standard range value\n&
                      - values should be readable\n\n\n&
                      ********************************************************\n&
                      note: extended range value is only shown on right tic if there & 
                      is enough space to show it without overlapping labels"

    set this.timer(0) 0.5
    pipe init

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

      panel/setup/controls=gc
      !/usemouseposition
      plot/msgid=MAIN/id=toosmall/mousewheelzoom/USEMOUSEPOSITION/READOUT="+OnAxis"/zoomadj=.1/DBLCLICKZOOM &
              world_file view=latloncontinuous
      plot/msgid=MAIN/id=okay/mousewheelzoom/USEMOUSEPOSITION/READOUT="+OnAxis"/zoomadj=.1/DBLCLICKZOOM &
              world_file view=latloncontinuous

      gcontrol label mainLabel "Main"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}
      gcontrol text idtext "Instructions" instructions 46 14 /title
 
    pipe off

  endif

endmacro

!******************************************************************************!
procedure processMessage m:msg

  !say "msg.name ^msg.name, data ^msg.data"

  if msg.name eqs "MAIN" then
    assert/text="Plot ZOOM tests" msg.data eqss "PASS" 
    ! Set keyMap back to default
    res t:km "nxm.sys.cfg.keyMap.tbl"
    env set keymap ^km
    pipe stop
  elseif msg.name eqs "TIMER" then
    set this.timer(0) 0
    invoke ,, toosmall.setScale("FIX")
    message send toosmall name=openfile data="world_file" quals={outerlimits={xmin=90,xmax=270,ymin=-90,ymax=90},viewlimits={xmin=170,xmax=260,ymin=-90,ymax=90}}
    invoke ,, okay.setScale("FIX")
    message send okay name=openfile data="world_file" quals={outerlimits={xmin=90,xmax=270,ymin=-90,ymax=90},viewlimits={xmin=170,xmax=260,ymin=-90,ymax=90}}
  else
    ! do nothing
    !say "^reg.main.name: 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

!******************************************************************************!
procedure open
  ! Automatically called
return
