!******************************************************************************!
! Tests LayerT5 scenarios with highlighting based on Jeremy's wish list:
!   1) Track fade should be based on the number of points in a track.
!   2) Highlighted tracks should never be fade.
!   3) Highlighted tracks should be "on top" and not covered up by non-highlighted tracks.
!   4) There should be messages about any change in status of highlighted tracks.
!   5) Add popup for highlighted point rather than unhighlighted.
!
! Arguments: None
!
! @bug      NXM-4013 Test for Jeremy's highlighting wish list
! @since    NeXtMidas 4.1.3
! @author:  Zachary Matthews
!******************************************************************************!
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

    ! Create highlight filters for the NAME field in the MultiTrack LayerT5
    invoke track2MapPT nxm.sys.lib.PredicateType.getNewPredicateTypeMap()
    invoke track3MapPT nxm.sys.lib.PredicateType.getNewPredicateTypeMap()
    invoke ,, nxm.sys.lib.PredicateType.addKeyFunction(track2MapPT,"NAME","STARTS","TRACK2")
    invoke ,, nxm.sys.lib.PredicateType.addKeyFunction(track3MapPT,"NAME","STARTS","TRACK3")

    ! Increments for adding points to tracks in the MultiTrack LayerT5
    set d:track1LatInc -0.1
    set d:track1LonInc -1
    set d:track2LatInc 3
    set d:track2LonInc 3
    set d:track3LatInc 5
    set d:track3LonInc 7.5
    set d:track4LatInc 5
    set d:track4LonInc 0

    ! Number of points to add to each Layer
    set l:numPtsToAddForMultiTrackFading 50
    set l:numPtsToAddForLongTrackFading  100

    ! Set the attributes for each LayerT5
    invoke L:symbolsField nxm.sys.libg.LayerT5.SYMBOLS
    set layerMultiTrack "LT=T5,TimeOrder=False,Group=t5Group,NAME=MULTITRACK,ColorFade=TRUE,ColorFadeFactor=1,AutoselectEnable=CLICK,AutoSelectMode=PIXEL,&
                         SELECTCOLOR=NONE,SELECTMESSAGES=TRUE,HIGHLIGHTTOTALMESSAGES=TRUE,METADATAFIELDS=NAME|NOTE,FILTERDATAFIELDS=ALL,FIELD=^symbolsField"
    set layerShortTrack "LT=T5,TimeOrder=False,Group=t5Group,NAME=SHORTTRACK,ColorFade=TRUE,ColorFadeFactor=1,AutoselectEnable=CLICK,AutoSelectMode=PIXEL,&
                         SELECTCOLOR=NONE,SELECTMESSAGES=TRUE,METADATAFIELDS=NAME|NOTE,FILTERDATAFIELDS=ALL,FIELD=^symbolsField"
    set layerLongTrack  "LT=T5,TimeOrder=False,Group=t5Group,NAME=LONGTRACK,ColorFade=TRUE,ColorFadeFactor=1,AutoselectEnable=CLICK,AutoSelectMode=PIXEL,&
                         SELECTCOLOR=NONE,SELECTMESSAGES=TRUE,METADATAFIELDS=NAME|NOTE,FILTERDATAFIELDS=ALL,FIELD=^symbolsField"

    ! Set colors for each track in the MultiTrack LayerT5
    set track1Color          "YELLOW"
    set track2Color          "PINK"
    set track3Color          "PURPLE"
    set track4Color          "WHITE"
    set track2HighlightColor "AQUA"
    set track3HighlightColor "MAGENTA"
    set shortTrackColor      "RED"
    set longTrackColor       "GREEN"
    set longTrackRepeatColor "BLACK"

    ! Set the file names for each 5000 DataFile
    set multiTrackFile "multiTrack.tmp"
    set shortTrackFile "shortTrack.tmp"
    set longTrackFile  "longTrack.tmp"

    ! Create the 5000 DataFile for each LayerT5
    call createMultiTrack5000File
    call createShortTrack5000File
    call createLongTrack5000File

    set instructions "Current behavior:\n&
                      1) Tracks on a layer fade according to # or points in the layer.\n&
                      2) Highlighted tracks fade, if fading is on for the layer.\n&
                      3) Later points draw over points of interest (i.e. highlighted ones).\n&
                      4) Selection popup will be of latest point in location.\n&
                      5) No support for messages detailing the # of points in a highlighted track.\n\n&
                      Desired Behavior:\n&
                      1) Tracks fade according to # of points in a track (keep dreaming Jeremy).\n&
                      2) Highlighted tracks should not fade.\n&
                      3) highlighted points should be on top.\n&
                      4) Popup should give preference to highlighted points.\n&
                      5) Highlighted tracks should send a message with # or points in track, when that # changes.\n\n&
                      _________________________________________________________\n&
                      Track 1 Natural Color: ^{track1Color}\n&
                      Track 2 Natural Color: ^{track2Color}\n&
                      Track 3 Natural Color: ^{track3Color}\n&
                      Track 4 Natural Color: ^{track4Color}\n\n&
                      Track 2 Highlight Color: ^{track2HighlightColor}\n&
                      Track 3 Highlight Color: ^{track3HighlightColor}\n\n&
                      Short Track Natural Color: ^{shortTrackColor}\n&
                      Long Track Natural Color: ^{longTrackColor}"

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

      plot/id=idplot/msgid=MAIN ^{datDir}.world.prm|{LT="Drawable",name=t5Group,listlayers=true}|^{multiTrackFile}{Layer={^layerMultiTrack}}|&
                     ^{shortTrackFile}{Layer={^layerShortTrack}}|^{longTrackFile}{Layer={^layerLongTrack}} &
                      readoutExt=+SHOW|-FEATURES|+POINTS readout=+OnAxis view=latloncontinuous

      gcontrol label labelZoomHighlightSection "Zoom to a Section with Highlighted Points"
       gcontrol/nc=1 button zoomHighlightSection "" "Zoom"
      gcontrol label labelHideShowMultiTrack "Hide/Show the Multi-Track Layer"
       gcontrol/nc=1 button hideShowMultiTrack "" "Hide"
      gcontrol label labelAddPts "Add Points to a given track"
       gcontrol/nomsg lval numPtsToAddToTrack1 "Track 1" DEF=10 MIN=1 MAX=10 INC=1
       gcontrol/nc=1 button addPtsToTrack1 "" "Add Points to Track 1"
       gcontrol/nomsg lval numPtsToAddToTrack2 "Track 2" DEF=3  MIN=1 MAX=10 INC=1
       gcontrol/nc=1 button addPtsToTrack2 "" "Add Points to Track 2"
       gcontrol/nomsg lval numPtsToAddToTrack3 "Track 3" DEF=3  MIN=1 MAX=10 INC=1
       gcontrol/nc=1 button addPtsToTrack3 "" "Add Points to Track 3"
       gcontrol/nomsg lval numPtsToAddToTrack4 "Track 4" DEF=3  MIN=1 MAX=10 INC=1
       gcontrol/nc=1 button addPtsToTrack4 "" "Add Points to Track 4"
      shellgui/id=idshellgui/attach/rows=15

      call applyHighlightFilterToMultiTrackLayer
    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 "ZOOMHIGHLIGHTSECTION" then
    message sendw id=idplot name=ZOOM data={xmin=-58.5,xmax=67.5,ymin=-34.9,ymax=25.5}
  elseif msg.name eqs "HIDESHOWMULTITRACK" then
    if msg.data eqs "HIDE" then
      invoke ,, lt5MultiTrack.setEnable(-GLOBAL)
      invoke ,,  gc.hideShowMultiTrack.setItems("Show")
    elseif msg.data eqs "SHOW" then
      invoke ,, lt5MultiTrack.setEnable(+GLOBAL)
      invoke ,,  gc.hideShowMultiTrack.setItems("Hide")
    endif
  elseif msg.name eqs "ADDPTSTOTRACK1" then
    call addPointsToMultiTrackLayer "TRACK1" gc.numPtsToAddToTrack1.value
  elseif msg.name eqs "ADDPTSTOTRACK2" then
    call addPointsToMultiTrackLayer "TRACK2" gc.numPtsToAddToTrack2.value
  elseif msg.name eqs "ADDPTSTOTRACK3" then
    call addPointsToMultiTrackLayer "TRACK3" gc.numPtsToAddToTrack3.value
  elseif msg.name eqs "ADDPTSTOTRACK4" then
    call addPointsToMultiTrackLayer "TRACK4" gc.numPtsToAddToTrack4.value
  elseif msg.name EQS "SELECT" OR msg.name EQS "DESELECT" then
    info "^msg.name MESSAGE"
    say "^msg.name ^msg.data"
  elseif msg.name EQS "HIGHLIGHT_TOTAL" then
    info "^msg.name MESSAGE"
    say "^msg.name HighlightFilter:^msg.data Total:^msg.info"
  elseif msg.name EQS "HIGHLIGHT_VISIBLE_TOTAL" then
    info "^msg.name MESSAGE"
    say "^msg.name HighlightFilter:^msg.data Total Visible:^msg.info"
  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

!******************************************************************************!
! Create the 5000 DataFile for the MultiTrack LayerT5
!******************************************************************************!
procedure createMultiTrack5000File
  header/create ram:^{multiTrackFile} TYPE=5000 RF=ECR COMPONENTS=(POS/VD/GEODETIC/DISTANCE_M,NAME/2A/UNDEFINED/NONE,COLOR/2A/UNDEFINED/NONE)
  set t:multitrack_data {}
  set t:multitrack_data.0  {POS=(0,60,-75),NAME="TRACK1_0",COLOR="^track1Color"}
  set t:multitrack_data.1  {POS=(0,57,-66),NAME="TRACK1_1",COLOR="^track1Color"}
  set t:multitrack_data.2  {POS=(0,54,-57.5),NAME="TRACK1_2",COLOR="^track1Color"}
  set t:multitrack_data.3  {POS=(0,51,-49.5),NAME="TRACK1_3",COLOR="^track1Color"}
  set t:multitrack_data.4  {POS=(0,48,-42),NAME="TRACK1_4",COLOR="^track1Color"}
  set t:multitrack_data.5  {POS=(0,6,3),NAME="TRACK2_0",COLOR="^track2Color"}
  set t:multitrack_data.6  {POS=(0,-25,-15),NAME="TRACK3_0",COLOR="^track3Color"}
  set t:multitrack_data.7  {POS=(0,-70,15),NAME="TRACK4_0",COLOR="^track4Color"}
  set t:multitrack_data.8  {POS=(0,45,-35),NAME="TRACK1_5",COLOR="^track1Color"}
  set t:multitrack_data.9  {POS=(0,42,-28.5),NAME="TRACK1_6",COLOR="^track1Color"}
  set t:multitrack_data.10 {POS=(0,39,-22.5),NAME="TRACK1_7",COLOR="^track1Color"}
  set t:multitrack_data.11 {POS=(0,36,-17),NAME="TRACK1_8",COLOR="^track1Color"}
  set t:multitrack_data.12 {POS=(0,33,-12),NAME="TRACK1_9",COLOR="^track1Color"}
  set t:multitrack_data.13 {POS=(0,9,6),NAME="TRACK2_1",COLOR="^track2Color"}
  set t:multitrack_data.14 {POS=(0,-30,-7.5),NAME="TRACK3_1",COLOR="^track3Color"}
  set t:multitrack_data.15 {POS=(0,-65,15),NAME="TRACK4_1",COLOR="^track4Color"}
  set t:multitrack_data.16 {POS=(0,30,-7.5),NAME="TRACK1_10",COLOR="^track1Color"}
  set t:multitrack_data.17 {POS=(0,27,-3.5),NAME="TRACK1_11",COLOR="^track1Color"}
  set t:multitrack_data.18 {POS=(0,24,0),NAME="TRACK1_12",COLOR="^track1Color"}
  set t:multitrack_data.19 {POS=(0,21,3),NAME="TRACK1_13",COLOR="^track1Color"}
  set t:multitrack_data.20 {POS=(0,18,5.5),NAME="TRACK1_14",COLOR="^track1Color"}
  set t:multitrack_data.21 {POS=(0,12,9),NAME="TRACK2_2",COLOR="^track2Color"}
  set t:multitrack_data.22 {POS=(0,-35,0),NAME="TRACK3_2",COLOR="^track3Color"}
  set t:multitrack_data.23 {POS=(0,-60,15),NAME="TRACK4_2",COLOR="^track4Color"}
  set t:multitrack_data.24 {POS=(0,15,7.5),NAME="TRACK1_15",COLOR="^track1Color"}
  set t:multitrack_data.25 {POS=(0,12,9),NAME="TRACK1_16",COLOR="^track1Color"}
  set t:multitrack_data.26 {POS=(0,9,10),NAME="TRACK1_17",COLOR="^track1Color"}
  set t:multitrack_data.27 {POS=(0,6,10.5),NAME="TRACK1_18",COLOR="^track1Color"}
  set t:multitrack_data.28 {POS=(0,3,10.5),NAME="TRACK1_19",COLOR="^track1Color"}
  set t:multitrack_data.29 {POS=(0,15,12),NAME="TRACK2_3",COLOR="^track2Color"}
  set t:multitrack_data.30 {POS=(0,-40,7.5),NAME="TRACK3_3",COLOR="^track3Color"}
  set t:multitrack_data.31 {POS=(0,-55,15),NAME="TRACK4_3",COLOR="^track4Color"}
  set t:multitrack_data.32 {POS=(0,0,10.5),NAME="TRACK1_20",COLOR="^track1Color"}
  set t:multitrack_data.33 {POS=(0,-3,10.5),NAME="TRACK1_21",COLOR="^track1Color"}
  set t:multitrack_data.34 {POS=(0,-6,10.5),NAME="TRACK1_22",COLOR="^track1Color"}
  set t:multitrack_data.35 {POS=(0,-9,10),NAME="TRACK1_23",COLOR="^track1Color"}
  set t:multitrack_data.36 {POS=(0,-12,9),NAME="TRACK1_24",COLOR="^track1Color"}
  set t:multitrack_data.37 {POS=(0,18,15),NAME="TRACK2_4",COLOR="^track2Color"}
  set t:multitrack_data.38 {POS=(0,-40,15),NAME="TRACK3_4",COLOR="^track3Color"}
  set t:multitrack_data.39 {POS=(0,-50,15),NAME="TRACK4_4",COLOR="^track4Color"}
  set t:multitrack_data.40 {POS=(0,-15,7.5),NAME="TRACK1_25",COLOR="^track1Color"}
  set t:multitrack_data.41 {POS=(0,-18,5.5),NAME="TRACK1_26",COLOR="^track1Color"}
  set t:multitrack_data.42 {POS=(0,-21,3),NAME="TRACK1_27",COLOR="^track1Color"}
  set t:multitrack_data.43 {POS=(0,-24,0),NAME="TRACK1_28",COLOR="^track1Color"}
  set t:multitrack_data.44 {POS=(0,-27,-3.5),NAME="TRACK1_29",COLOR="^track1Color"}
  set t:multitrack_data.45 {POS=(0,21,18),NAME="TRACK2_5",COLOR="^track2Color"}
  set t:multitrack_data.46 {POS=(0,-35,22.5),NAME="TRACK3_5",COLOR="^track3Color"}
  set t:multitrack_data.47 {POS=(0,-45,15),NAME="TRACK4_5",COLOR="^track4Color"}
  set t:multitrack_data.48 {POS=(0,-30,-7.5),NAME="TRACK1_30",COLOR="^track1Color"}
  set t:multitrack_data.49 {POS=(0,-33,-12),NAME="TRACK1_31",COLOR="^track1Color"}
  set t:multitrack_data.50 {POS=(0,-36,-17),NAME="TRACK1_32",COLOR="^track1Color"}
  set t:multitrack_data.51 {POS=(0,-39,-22.7),NAME="TRACK1_33",COLOR="^track1Color"}
  set t:multitrack_data.52 {POS=(0,-42,-28.5),NAME="TRACK1_34",COLOR="^track1Color"}
  set t:multitrack_data.53 {POS=(0,24,21),NAME="TRACK2_6",COLOR="^track2Color"}
  set t:multitrack_data.54 {POS=(0,-30,30),NAME="TRACK3_6",COLOR="^track3Color"}
  set t:multitrack_data.55 {POS=(0,-40,15),NAME="TRACK4_6",COLOR="^track4Color"}
  set t:multitrack_data.56 {POS=(0,-45,-35),NAME="TRACK1_35",COLOR="^track1Color"}
  set t:multitrack_data.57 {POS=(0,-48,-42),NAME="TRACK1_36",COLOR="^track1Color"}
  set t:multitrack_data.58 {POS=(0,-51,-49.5),NAME="TRACK1_37",COLOR="^track1Color"}
  set t:multitrack_data.59 {POS=(0,-54,-57.5),NAME="TRACK1_38",COLOR="^track1Color"}
  set t:multitrack_data.60 {POS=(0,-57,-66),NAME="TRACK1_39",COLOR="^track1Color"}
  set t:multitrack_data.61 {POS=(0,-60,-75),NAME="TRACK1_40",COLOR="^track1Color"}
  set t:multitrack_data.62 {POS=(0,27,24),NAME="TRACK2_7",COLOR="^track2Color"}
  set t:multitrack_data.63 {POS=(0,-25,37.5),NAME="TRACK3_7",COLOR="^track3Color"}
  set t:multitrack_data.64 {POS=(0,-35,15),NAME="TRACK4_7",COLOR="^track4Color"}

  ! Populate the MultiTrack 5000 DataFile with table entries
  res additionalPts 0
  res insertionIdx 18
  file open/d/a out ram:^{multiTrackFile}
  foreach l:keyIdx intable multitrack_data
    if keyIdx eq insertionIdx then
      set t:repeatedEntry multitrack_data.^{insertionIdx}
      set l:numRepeatPts numPtsToAddForMultiTrackFading
      call addRepeatedPts
    endif
    calc dataIdx keyIdx additionalPts +
    invoke ,, out.setData(dataIdx,multitrack_data.^{keyIdx})
  endfor

  file close out

  set l:track1LastIdx 40
  set d:track1LastLat -60
  set d:track1LastLon -75
  set l:track2LastIdx 7
  set d:track2LastLat 27
  set d:track2LastLon 24
  set l:track3LastIdx 7
  set d:track3LastLat -25
  set d:track3LastLon 37.5
  set l:track4LastIdx 7
  set d:track4LastLat -35
  set d:track4LastLon 15
return

!******************************************************************************!
! Create the 5000 DataFile for the ShortTrack LayerT5
!******************************************************************************!
procedure createShortTrack5000File
  header/create ram:^{shortTrackFile} TYPE=5000 RF=ECR COMPONENTS=(POS/VD/GEODETIC/DISTANCE_M,NAME/2A/UNDEFINED/NONE,COLOR/2A/UNDEFINED/NONE)
  set t:shorttrack_data {}
  set t:shorttrack_data.0 {POS=(0,30,-135),NAME="SHORTTRACK_0",COLOR="^shortTrackColor"}
  set t:shorttrack_data.1 {POS=(0,35,-134),NAME="SHORTTRACK_1",COLOR="^shortTrackColor"}
  set t:shorttrack_data.2 {POS=(0,40,-133),NAME="SHORTTRACK_2",COLOR="^shortTrackColor"}
  set t:shorttrack_data.3 {POS=(0,45,-132),NAME="SHORTTRACK_3",COLOR="^shortTrackColor"}
  set t:shorttrack_data.4 {POS=(0,50,-131),NAME="SHORTTRACK_4",COLOR="^shortTrackColor"}
  set t:shorttrack_data.5 {POS=(0,55,-130),NAME="SHORTTRACK_5",COLOR="^shortTrackColor"}
  set t:shorttrack_data.6 {POS=(0,60,-129),NAME="SHORTTRACK_6",COLOR="^shortTrackColor"}
  set t:shorttrack_data.7 {POS=(0,65,-128),NAME="SHORTTRACK_7",COLOR="^shortTrackColor"}

  ! Populate the ShortTrack 5000 DataFile with table entries
  file open/d/a out ram:^{shortTrackFile}
  foreach l:keyIdx intable shorttrack_data
    invoke ,, out.setData(keyIdx,shorttrack_data.^{keyIdx})
  endfor

  file close out
return

!******************************************************************************!
! Create the 5000 DataFile for the LongTrack LayerT5
!******************************************************************************!
procedure createLongTrack5000File
  header/create ram:^{longTrackFile} TYPE=5000 RF=ECR COMPONENTS=(POS/VD/GEODETIC/DISTANCE_M,NAME/2A/UNDEFINED/NONE,COLOR/2A/UNDEFINED/NONE)
  set t:longtrack_data {}
  set t:longtrack_data.0  {POS=(0,-75,75),NAME="LONGTRACK_0",COLOR="^longTrackColor"}
  set t:longtrack_data.1  {POS=(0,-67.5,77.25),NAME="LONGTRACK_1",COLOR="^longTrackColor"}
  set t:longtrack_data.2  {POS=(0,-60,79.5),NAME="LONGTRACK_2",COLOR="^longTrackColor"}
  set t:longtrack_data.3  {POS=(0,-52.5,81.75),NAME="LONGTRACK_3",COLOR="^longTrackColor"}
  set t:longtrack_data.4  {POS=(0,-45,84),NAME="LONGTRACK_4",COLOR="^longTrackColor"}
  set t:longtrack_data.5  {POS=(0,-37.5,86.25),NAME="LONGTRACK_5",COLOR="^longTrackColor"}
  set t:longtrack_data.6  {POS=(0,-30,88.5),NAME="LONGTRACK_6",COLOR="^longTrackColor"}
  set t:longtrack_data.7  {POS=(0,-22.5,90.75),NAME="LONGTRACK_7",COLOR="^longTrackColor"}
  set t:longtrack_data.8  {POS=(0,-15,93),NAME="LONGTRACK_8",COLOR="^longTrackColor"}
  set t:longtrack_data.9  {POS=(0,-7.5,95.25),NAME="LONGTRACK_9",COLOR="^longTrackColor"}
  set t:longtrack_data.10 {POS=(0,0,97.5),NAME="LONGTRACK_10",COLOR="^longTrackColor"}
  set t:longtrack_data.11 {POS=(0,7.5,99.75),NAME="LONGTRACK_11",COLOR="^longTrackColor"}
  set t:longtrack_data.12 {POS=(0,15,102),NAME="LONGTRACK_12",COLOR="^longTrackColor"}
  set t:longtrack_data.13 {POS=(0,22.5,104.25),NAME="LONGTRACK_13",COLOR="^longTrackColor"}
  set t:longtrack_data.14 {POS=(0,30,106.5),NAME="LONGTRACK_14",COLOR="^longTrackColor"}
  set t:longtrack_data.15 {POS=(0,37.5,108.75),NAME="LONGTRACK_15",COLOR="^longTrackColor"}
  set t:longtrack_data.16 {POS=(0,45,111),NAME="LONGTRACK_16",COLOR="^longTrackColor"}
  set t:longtrack_data.17 {POS=(0,52.5,113.25),NAME="LONGTRACK_17",COLOR="^longTrackColor"}
  set t:longtrack_data.18 {POS=(0,60,115.5),NAME="LONGTRACK_18",COLOR="^longTrackColor"}
  set t:longtrack_data.19 {POS=(0,67.5,117.75),NAME="LONGTRACK_19",COLOR="^longTrackColor"}
  set t:longtrack_data.20 {POS=(0,75,120),NAME="LONGTRACK_20",COLOR="^longTrackColor"}
  set t:longtrack_data.21 {POS=(0,67.5,122.25),NAME="LONGTRACK_21",COLOR="^longTrackColor"}
  set t:longtrack_data.22 {POS=(0,60,124.5),NAME="LONGTRACK_22",COLOR="^longTrackColor"}
  set t:longtrack_data.23 {POS=(0,52.5,126.75),NAME="LONGTRACK_23",COLOR="^longTrackColor"}
  set t:longtrack_data.24 {POS=(0,45,129),NAME="LONGTRACK_24",COLOR="^longTrackColor"}
  set t:longtrack_data.25 {POS=(0,37.5,131.25),NAME="LONGTRACK_25",COLOR="^longTrackColor"}
  set t:longtrack_data.26 {POS=(0,30,133.5),NAME="LONGTRACK_26",COLOR="^longTrackColor"}
  set t:longtrack_data.27 {POS=(0,22.5,135.75),NAME="LONGTRACK_27",COLOR="^longTrackColor"}
  set t:longtrack_data.28 {POS=(0,15,138),NAME="LONGTRACK_28",COLOR="^longTrackColor"}
  set t:longtrack_data.29 {POS=(0,7.5,140.25),NAME="LONGTRACK_29",COLOR="^longTrackColor"}
  set t:longtrack_data.30 {POS=(0,0,142.5),NAME="LONGTRACK_30",COLOR="^longTrackColor"}
  set t:longtrack_data.31 {POS=(0,-7.5,144.75),NAME="LONGTRACK_31",COLOR="^longTrackColor"}
  set t:longtrack_data.32 {POS=(0,-15,147),NAME="LONGTRACK_32",COLOR="^longTrackColor"}
  set t:longtrack_data.33 {POS=(0,-22.5,149.25),NAME="LONGTRACK_33",COLOR="^longTrackColor"}
  set t:longtrack_data.34 {POS=(0,-30,151.5),NAME="LONGTRACK_34",COLOR="^longTrackColor"}
  set t:longtrack_data.35 {POS=(0,-37.5,153.75),NAME="LONGTRACK_35",COLOR="^longTrackColor"}
  set t:longtrack_data.36 {POS=(0,-45,156),NAME="LONGTRACK_36",COLOR="^longTrackColor"}
  set t:longtrack_data.37 {POS=(0,-52.5,158.25),NAME="LONGTRACK_37",COLOR="^longTrackColor"}
  set t:longtrack_data.38 {POS=(0,-60,160.5),NAME="LONGTRACK_38",COLOR="^longTrackColor"}
  set t:longtrack_data.39 {POS=(0,-67.5,162.75),NAME="LONGTRACK_39",COLOR="^longTrackColor"}
  set t:longtrack_data.40 {POS=(0,-75,165),NAME="LONGTRACK_40",COLOR="^longTrackColor"}

  ! Populate the LongTrack 5000 DataFile with table entries
  res additionalPts 0
  res insertionIdx 12
  file open/d/a out ram:^{longTrackFile}
  foreach l:keyIdx intable longtrack_data
    if keyIdx eq insertionIdx then
      set t:repeatedEntry longtrack_data.^{insertionIdx}
      set l:numRepeatPts numPtsToAddForLongTrackFading
      call addRepeatedPts
    endif
    calc dataIdx keyIdx additionalPts +
    invoke ,, out.setData(dataIdx,longtrack_data.^{keyIdx})
  endfor

  file close out
return

!******************************************************************************!
! Apply the highlight filters to the MultiTrack LayerT5
!******************************************************************************!
procedure applyHighlightFilterToMultiTrackLayer
  invoke lt5MultiTrack reg.idplot.layers.t5group.getLayer(MULTITRACK)
  invoke ,, lt5MultiTrack.putHighlightSetting("track2MapPT",track2MapPT,"^{track2HighlightColor}")
  invoke ,, lt5MultiTrack.putHighlightSetting("track3MapPT",track3MapPT,"^{track3HighlightColor}")
return

!******************************************************************************!
! Add points to the MultiTrack LayerT5
!******************************************************************************!
procedure addPointsToMultiTrackLayer s:track["TRACK1"] l:numPts[1]
  !file open/d/a out ram:^{multiTrackFile}
  do l:count 1 numPts 1
    if track eqs "TRACK1" then
      calc d:track1LastLat track1LastLat track1LatInc +
      calc d:track1LastLon track1LastLon track1LonInc +
      calc l:track1LastIdx track1LastIdx 1 +
      set d:multiTrackEntryLat track1LastLat
      set d:multiTrackEntryLon track1LastLon
      set s:multiTrackEntryName "TRACK1_^{track1LastIdx}"
      set s:multiTrackEntryColor track1Color
    elseif track eqs "TRACK2" then
      calc d:track2LastLat track2LastLat track2LatInc +
      calc d:track2LastLon track2LastLon track2LonInc +
      calc l:track2LastIdx track2LastIdx 1 +
      set d:multiTrackEntryLat track2LastLat
      set d:multiTrackEntryLon track2LastLon
      set s:multiTrackEntryName "TRACK2_^{track2LastIdx}"
      set s:multiTrackEntryColor track2Color
    elseif track eqs "TRACK3" then
      calc d:track3LastLat track3LastLat track3LatInc +
      calc d:track3LastLon track3LastLon track3LonInc +
      calc l:track3LastIdx track3LastIdx 1 +
      set d:multiTrackEntryLat track3LastLat
      set d:multiTrackEntryLon track3LastLon
      set s:multiTrackEntryName "TRACK3_^{track3LastIdx}"
      set s:multiTrackEntryColor track3Color
    elseif track eqs "TRACK4" then
      calc d:track4LastLat track4LastLat track4LatInc +
      calc d:track4LastLon track4LastLon track4LonInc +
      calc l:track4LastIdx track4LastIdx 1 +
      set d:multiTrackEntryLat track4LastLat
      set d:multiTrackEntryLon track4LastLon
      set s:multiTrackEntryName "TRACK4_^{track4LastIdx}"
      set s:multiTrackEntryColor track4Color
    endif

    invoke ,, lt5MultiTrack.setPoint(-1,{POS=(^{multiTrackEntryLon},^{multiTrackEntryLat},0),NAME="^{multiTrackEntryName}",COLOR="^{multiTrackEntryColor}"})
  enddo
return

procedure addRepeatedPts
  ! Populate the MultiTrack 5000 DataFile with the last point in the Table to show fading for the MultiTrack LayerT5
  do l:count 1 numRepeatPts 1
    calc l:lastIndex5000File insertionIdx 1 +
    invoke ,, out.setData(lastIndex5000File,repeatedEntry)
  enddo
  res additionalPts numRepeatPts
return
