1
0
Fork 0

Direct To part 2 - Waypoint Submenu

This commit is contained in:
Stuart Buchanan 2018-01-27 21:55:22 +00:00
parent da252c8a18
commit ee69231220
6 changed files with 482 additions and 152 deletions

View file

@ -23,9 +23,9 @@
borderopacity="0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="12.989583"
inkscape:cx="963.35035"
inkscape:cy="168.45634"
inkscape:zoom="2.2962556"
inkscape:cx="778.1918"
inkscape:cy="230.23655"
inkscape:document-units="px"
inkscape:current-layer="DirectToGroup"
showgrid="true"
@ -69,7 +69,7 @@
id="DirectToGroup"
inkscape:label="#g9755">
<path
style="opacity:1;fill:#1a3030;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:1;fill:#4b4b4b;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="m 698.99609,58.498047 0,684.503903 325.00391,0 0,-684.503903 -325.00391,0 z M 705.5,279.93359 l 314.4277,0 0,322.2793 -314.4277,0 0,-322.2793 z"
id="rect4230"
inkscape:connector-curvature="0" />
@ -93,7 +93,7 @@
height="19.691175"
width="139.19115"
id="rect9753"
style="opacity:1;fill:#1a3030;fill-opacity:1;fill-rule:nonzero;stroke:#fffcfa;stroke-width:1.30882514;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
style="opacity:1;fill:#4b4b4b;fill-opacity:1;fill-rule:nonzero;stroke:#fffcfa;stroke-width:1.30882514;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
sodipodi:linespacing="125%"
id="text9749"
@ -107,7 +107,7 @@
sodipodi:role="line"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow Condensed'">IDENT, FACILITY, CITY</tspan></text>
<rect
style="opacity:1;fill:#1a3030;fill-opacity:1;fill-rule:nonzero;stroke:#fffcfa;stroke-width:1;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
style="opacity:1;fill:#4b4b4b;fill-opacity:1;fill-rule:nonzero;stroke:#fffcfa;stroke-width:1;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4150"
width="34.834621"
height="20.334629"
@ -169,36 +169,36 @@
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:20px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow Condensed';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#80ffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="947.97852"
y="137.80469"
x="711.01562"
y="187.80469"
id="DirectToCity"
sodipodi:linespacing="125%"
inkscape:label="#text4174"><tspan
sodipodi:role="line"
id="tspan4176"
x="947.97852"
y="137.80469">CITY</tspan></text>
x="711.01562"
y="187.80469">CITY</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:20px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow Condensed';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#80ffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="711.10352"
y="186.96484"
x="948.65234"
y="136.96484"
id="DirectToRegion"
sodipodi:linespacing="125%"
inkscape:label="#text4198"><tspan
sodipodi:role="line"
id="tspan4200"
x="711.10352"
y="186.96484">REGION</tspan></text>
x="948.65234"
y="136.96484">REGION</tspan></text>
<text
inkscape:label="#text4166"
sodipodi:linespacing="125%"
id="DirectToID0"
y="136.96484"
y="137.16016"
x="711.10352"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:20px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow Condensed';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#80ffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
y="136.96484"
y="137.16016"
x="711.10352"
id="tspan4227"
sodipodi:role="line">K</tspan></text>
@ -218,11 +218,11 @@
inkscape:label="#text4166"
sodipodi:linespacing="125%"
id="DirectToID2"
y="137.08984"
y="137.16016"
x="732.99805"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:20px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow Condensed';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#80ffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
y="137.08984"
y="137.16016"
x="732.99805"
id="tspan4236"
sodipodi:role="line">F</tspan></text>
@ -275,7 +275,7 @@
height="20.289667"
width="39.789661"
id="rect3455"
style="opacity:1;fill:#1a3030;fill-opacity:1;fill-rule:nonzero;stroke:#fffcfa;stroke-width:1;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
style="opacity:1;fill:#4b4b4b;fill-opacity:1;fill-rule:nonzero;stroke:#fffcfa;stroke-width:1;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<text
sodipodi:linespacing="125%"
id="text3457"
@ -493,22 +493,23 @@
x="743.75"
y="721.96484">000</tspan></text>
<rect
y="703.95667"
x="857.39319"
height="20.033949"
width="74.533913"
y="699"
x="861"
height="25"
width="100"
id="rect4393"
style="opacity:1;fill:#1a3030;fill-opacity:1;fill-rule:nonzero;stroke:#fffcfa;stroke-width:2;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
style="opacity:1;fill:#1a3030;fill-opacity:1;fill-rule:nonzero;stroke:#fffcfa;stroke-width:2;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
ry="0" />
<text
sodipodi:linespacing="125%"
id="DirectToActivate"
y="718.97363"
x="862.41016"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:15px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow Condensed';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#ffffff;fill-opacity:1;stroke:#fffcfa;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
y="718.38477"
x="911.64844"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:20px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow, Condensed';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#ffffff;fill-opacity:1;stroke:#fffcff;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;"
xml:space="preserve"
inkscape:label="#text4395"><tspan
y="718.97363"
x="862.41016"
y="718.38477"
x="911.64844"
sodipodi:role="line"
id="tspan4397">ACTIVATE?</tspan></text>
<text
@ -576,7 +577,7 @@
height="24.004704"
width="68.004707"
id="rect8420"
style="display:inline;opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0.99528456;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
style="display:inline;opacity:1;fill:#4b4b4b;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:0.99528456;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
<text
sodipodi:linespacing="0%"
inkscape:label="RangeDisplay"
@ -592,7 +593,7 @@
id="tspan5131-3-5-3"
sodipodi:role="line">Zoom nm</tspan></text>
<rect
style="display:inline;opacity:1;fill:#000000;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
style="display:inline;opacity:1;fill:#4b4b4b;fill-opacity:1;fill-rule:nonzero;stroke:#ffffff;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="rect4265"
width="75.057129"
height="19.057156"
@ -600,7 +601,7 @@
y="279.47144" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:11.80263901px;line-height:0%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow, Condensed';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;display:inline;fill:#31ffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:11.80263901px;line-height:0%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow, Condensed';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;display:inline;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;"
x="1029.4486"
y="281.5152"
id="text4267"
@ -611,7 +612,119 @@
id="tspan4269"
x="1029.4486"
y="281.5152"
style="font-size:17.21218109px;line-height:1.25;fill:#31ffff;fill-opacity:1;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none">NORTH UP</tspan></text>
style="font-size:17.21218109px;line-height:1.25;fill:#ffffff;fill-opacity:1;stroke-width:1;stroke-miterlimit:4;stroke-dasharray:none;">NORTH UP</tspan></text>
<g
id="DirectToWaypointSubmenuGroup"
inkscape:label="#g4271">
<rect
y="143.38834"
x="709.38837"
height="149.22327"
width="115.22327"
id="rect4232"
style="opacity:1;fill:#4b4b4b;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.77672273;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
ry="0"
style="opacity:1;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#ffffff;stroke-width:0.77518052;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="rect4239"
width="107.22482"
height="141.22482"
x="713.38757"
y="147.38759" />
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:20px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow, Condensed';text-align:center;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#80ffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="765.59869"
y="170.66508"
id="DirectToWaypointSubmenuSelect"
sodipodi:linespacing="125%"
inkscape:label="#text4198"><tspan
sodipodi:role="line"
id="tspan4243"
x="765.59869"
y="170.66508">REGION</tspan></text>
<path
inkscape:label="#path4245"
inkscape:connector-curvature="0"
id="DirectToWaypointSubmenuSelectRight"
d="m 800.5,153.35355 0,20 10,-10 -10,-10"
style="fill:#feffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<path
inkscape:label="#path4247"
style="fill:#feffff;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 730.70711,153.35355 0,20 -10,-10 10,-10"
id="DirectToWaypointSubmenuSelectLeft"
inkscape:connector-curvature="0" />
<path
inkscape:connector-curvature="0"
id="path4249"
d="m 720,178 95,0"
style="fill:none;fill-opacity:1;fill-rule:evenodd;stroke:#4b4b4b;stroke-width:0.85485041px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
<text
inkscape:label="#text4198"
sodipodi:linespacing="125%"
id="DirectToWaypointSubmenuScroll0"
y="201.96484"
x="718.65234"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:20px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow Condensed';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#80ffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
y="201.96484"
x="718.65234"
id="tspan4253"
sodipodi:role="line">REGION</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:20px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow Condensed';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#80ffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="718.65234"
y="226.96484"
id="DirectToWaypointSubmenuScroll1"
sodipodi:linespacing="125%"
inkscape:label="#text4198"><tspan
sodipodi:role="line"
id="tspan4257"
x="718.65234"
y="226.96484">REGION</tspan></text>
<text
inkscape:label="#text4198"
sodipodi:linespacing="125%"
id="DirectToWaypointSubmenuScroll2"
y="251.96484"
x="718.65234"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:20px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow Condensed';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#80ffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
xml:space="preserve"><tspan
y="251.96484"
x="718.65234"
id="tspan4261"
sodipodi:role="line">REGION</tspan></text>
<text
xml:space="preserve"
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:condensed;font-size:20px;line-height:125%;font-family:'Liberation Sans Narrow';-inkscape-font-specification:'Liberation Sans Narrow Condensed';text-align:start;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:start;fill:#80ffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
x="718.65234"
y="276.96484"
id="DirectToWaypointSubmenuScroll3"
sodipodi:linespacing="125%"
inkscape:label="#text4198"><tspan
sodipodi:role="line"
id="tspan4265"
x="718.65234"
y="276.96484">REGION</tspan></text>
<rect
inkscape:label="#rect4267"
y="188"
x="810"
height="90"
width="5"
id="DirectToWaypointSubmenuScrollTrough"
style="opacity:1;fill:#c0c0c0;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1" />
<rect
inkscape:label="#rect4269"
style="opacity:1;fill:#808080;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1;stroke-linecap:butt;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="DirectToWaypointSubmenuScrollThumb"
width="5"
height="30"
x="810"
y="188" />
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 42 KiB

View file

@ -7,6 +7,8 @@
var DirectTo =
{
SHORTCUTS : [ "FPL", "NRST", "RECENT", "USER", "AIRWAY" ],
new : func (mfd, myCanvas, device, svg)
{
var obj = {
@ -45,7 +47,15 @@ var DirectTo =
obj.VNVAltEntry = PFD.DataEntryElement.new(obj.pageName, svg, "VNVAlt", "", 5, "0123456789");
obj.VNVOffsetEntry = PFD.DataEntryElement.new(obj.pageName, svg, "VNVOffset", "", 2, "0123456789");
obj.CourseEntry = PFD.DataEntryElement.new(obj.pageName, svg, "Course", "", 3, "0123456789");
obj.Activate = PFD.TextElement.new(obj.pageName, svg, "Activate", "ACTIVATE");
obj.Activate = PFD.TextElement.new(obj.pageName, svg, "Activate", "ACTIVATE?");
# The Shortcut window. This allows the user to scroll through a set of lists
# of waypoints.
obj.WaypointSubmenuGroup = obj._SVGGroup.getElementById("DirectToWaypointSubmenuGroup");
assert(obj.WaypointSubmenuGroup != nil, "Unable to find DirectToWaypointSubmenuGroup");
obj.WaypointSubmenuGroup.setVisible(0);
obj.WaypointSubmenuSelect = PFD.ScrollElement.new(obj.pageName, svg, "WaypointSubmenuSelect", DirectTo.SHORTCUTS);
obj.WaypointSubmenuScroll = PFD.GroupElement.new(obj.pageName, svg, [ "WaypointSubmenuScroll" ] , 4, "WaypointSubmenuScroll", 0, "WaypointSubmenuScrollTrough" , "WaypointSubmenuScrollThumb", 60);
# The Airport Chart
obj.DirectToChart = obj._group.createChild("map");
@ -88,9 +98,11 @@ var DirectTo =
},
displayDestination : func(destination) {
#me.IDEntry.clearElement();
if (destination != nil) {
# Display a given location
debug.dump(destination);
#debug.dump(destination);
me.DirectToChart.setVisible(1);
me.DirectToChart.getController().setPosition(destination.lat,destination.lon);
me.setTextElement("Name", string.uc(destination.name));
@ -117,17 +129,12 @@ var DirectTo =
me.CourseEntry.setValue(0);
}
},
setRange : func(range, label) {
me.DirectToChart.setRange(range);
me.DirectToChart.update();
me.setTextElement("RangeDisplay", label);
},
# Clear any cursor, highlights. Used when exiting from CRSR mode
resetCRSR : func() {
me.airportEntry.unhighlightElement();
me.runwaySelect.unhighlightElement();
me.freqSelect.hideCRSR();
},
offdisplay : func() {
me._group.setVisible(0);

View file

@ -53,17 +53,21 @@ var DirectToController =
obj.page.Activate
];
obj._activateIndex = size(obj._cursorElements) - 1;
# -1 indicates nothing selected at present
obj._selectedElement = -1;
# Whether the WaypointSubmenuGroup is enabled
obj._waypointSubmenuVisible = 0;
return obj;
},
setCursorElement : func(value) {
if (me._selectedElement != -1) {
# Unhighlight the current element, if one is highlighted
me._cursorElements[me._selectedElement ].unhighlightElement();
for (var i = 0; i < size(me._cursorElements); i = i+1) {
me._cursorElements[i].unhighlightElement();
}
if (value < 0) value = 0;
@ -98,23 +102,129 @@ var DirectToController =
# No effect, but shouldn't be passed to underlying page?
return emesary.Transmitter.ReceiptStatus_Finished;
},
handleFMSInner : func(value) {
if (me._selectedElement == -1) {
# TODO: handle display of waypoint submenu on anti-clockwise initial rotation!
# If no element is selected, then the inner FMS knob selects the ID field
me.nextCursorElement(1);
updateWaypointSubmenu : func() {
var type = me.page.WaypointSubmenuSelect.getValue();
var items = [];
if (type == "FPL") {
# Get the contents of the flightplan and display the list of waypoints.
var fp = me.getNavData("Flightplan");
for (var i = 0; i < fp.getPlanSize(); i = i + 1) {
var wp = fp.getWP(i);
if (wp.wp_name != nil) append(items, wp.wp_name);
}
}
if (type == "NRST") {
# Get the nearest airports
var apts = me.getNavData("NearestAirports");
for (var i = 0; i < size(apts); i = i + 1) {
var apt = apts[i];
if (apt.id != nil) append(items, apt.id);
}
}
if (type == "RECENT") {
# Get the set of recent waypoints
items = me.getNavData("RecentWaypoints");
}
if (type == "USER") {
items = me.getNavData("UserWaypoints");
}
if (type == "AIRWAY") {
var fp = me.getNavData("AirwayWaypoints");
if (fp != nil) {
for (var i = 0; i < fp.getPlanSize(); i = i + 1) {
var wp = fp.getWP(i);
if (wp.wp_name != nil) append(items, wp.wp_name);
}
}
}
if ((items != nil) and (size(items) > 0)) {
# At this point we have a vector of waypoint names. We need to convert
# this into a vector of { "WaypointSubmenuScroll" : [name] } hashes for consumption by the
# list of waypoints
var groupitems = [];
foreach (var item; items) {
append(groupitems, { "WaypointSubmenuScroll" : item } );
}
# Now display them!
me.page.WaypointSubmenuScroll.setValues(groupitems);
} else {
# Nothing to display
me.page.WaypointSubmenuScroll.setValues([]);
}
},
getNavData : func(type, value=nil) {
# Use Emesary to get a piece from the NavData system, using the provided
# type and value;
var notification = notifications.PFDEventNotification.new(
"MFD",
1,
notifications.PFDEventNotification.NavData,
{Id: type, Value: value});
var response = me._transmitter.NotifyAll(notification);
if (! me._transmitter.IsFailed(response)) {
return notification.EventParameter.Value;
} else {
return nil;
}
},
handleFMSInner : func(value) {
if (me._waypointSubmenuVisible) {
# We're in the Waypoint Submenu, in which case the inner FMS knob
# selects between the different waypoint types.
me.page.WaypointSubmenuSelect.highlightElement();
me.page.WaypointSubmenuSelect.incrSmall(value);
# Now update the Scroll group with the new type of waypoints
me.updateWaypointSubmenu();
} else if (me._selectedElement == -1) {
if (value == -1) {
# The WaypointSubmenuGroup group is displayed if the small FMS knob is rotated
# anti-clockwise as an initial rotation.
me._cursorElements[0].unhighlightElement();
me.page.WaypointSubmenuGroup.setVisible(1);
me.page.WaypointSubmenuSelect.highlightElement();
me._waypointSubmenuVisible = 1;
me.updateWaypointSubmenu();
} else {
# If the user rotates clockwise, then they simply start editing
# the cursor element
me.nextCursorElement(1);
me._cursorElements[me._selectedElement].incrSmall(value);
}
} else {
# We've already got something selected, and we're not in the
# WaypointSubmenuGroup, so increment it.
me._cursorElements[me._selectedElement].incrSmall(value);
}
me._cursorElements[me._selectedElement].incrSmall(value);
return emesary.Transmitter.ReceiptStatus_Finished;
},
handleFMSOuter : func(value) {
if (me._selectedElement == -1) {
if (me._waypointSubmenuVisible) {
# We're in the Waypoint Submenu, in which case the outer FMS knob
# selects between the different waypoints in the Waypoint Submenu.
me.page.WaypointSubmenuSelect.unhighlightElement();
me.page.WaypointSubmenuScroll.incrLarge(value);
} else if (me._selectedElement == -1) {
# If no element is selected, then the Outer FMS knob has no effect
return emesary.Transmitter.ReceiptStatus_Finished;
}
if (me._cursorElements[me._selectedElement].isInEdit()) {
} else if (me._cursorElements[me._selectedElement].isInEdit()) {
# If we're editing an element, then get on with it!
me._cursorElements[me._selectedElement].incrLarge(value);
} else {
me.nextCursorElement(value);
@ -123,30 +233,110 @@ var DirectToController =
return emesary.Transmitter.ReceiptStatus_Finished;
},
handleEnter : func(value) {
if (me._selectedElement == -1) {
if (me._waypointSubmenuVisible) {
# If we're in the Waypoint Submenu, then take whatever is highlighted
# in the scroll list, load it and hide the Waypoint submenu
var id = me.page.WaypointSubmenuScroll.getValue();
if (id != nil) me.loadDestination(id);
me.page.WaypointSubmenuGroup.setVisible(0);
me._waypointSubmenuVisible = 0;
# Select the activate ACTIVATE item.
me.setCursorElement(me._activateIndex);
} else if (me._selectedElement == -1) {
# If no element is selected, then the ENT key has no effect
return emesary.Transmitter.ReceiptStatus_Finished;
} else {
# If we're on the Activate button, then set up the DirectTo and hide the
# page. We're finished
if (me._selectedElement == me._activateIndex) {
var mappage = me._page.getMFD().getPage("NavigationMap");
assert(mappage != nil, "Unable to find NavigationMap page");
me._page.getDevice().selectPage(mappage);
return emesary.Transmitter.ReceiptStatus_Finished;
}
# If we're editing an element, complete the data entry.
if (me._cursorElements[me._selectedElement].isInEdit()) {
me._cursorElements[me._selectedElement].enterElement();
}
if (me._cursorElements[me._selectedElement] == me.page.IDEntry) {
# We've finished entering an ID, so load it.
me.loadDestination(me.page.IDEntry.getValue());
}
# Determine where to highlight next. In most cases, we go straight to ACTIVATE.
# The exception is the VNV Alt field which goes to the VNV Distance field;
if (me._cursorElements[me._selectedElement] == me.page.VNVAltEntry) {
# VNV DIS entry is the next element
me.nextCursorElement(1);
} else {
# ACTIVATE is the last element of the group
me.setCursorElement(me._activateIndex);
}
}
# If we're on the Activate button, then set up the DirectTo and hide the
# page. We're finished
if (me._cursorElements[me._selectedElement] == me.page.Activate) {
return emesary.Transmitter.ReceiptStatus_Finished;
},
handleClear : func(value) {
if (me._waypointSubmenuVisible) {
# If we're in the Waypoint Submenu, then this clears it.
me.page.WaypointSubmenuGroup.setVisible(0);
me._waypointSubmenuVisible = 0;
} else if ((me._selectedElement != -1) and me._cursorElements[me._selectedElement].isInEdit()) {
me._cursorElements[me._selectedElement].clearElement();
} else {
# Cancel the entire Direct To page, and go back to the Navigation Map.
var mappage = me._page.getMFD().getPage("NavigationMap");
assert(mappage != nil, "Unable to find NavigationMap page");
me._page.getDevice().selectPage(mappage);
return emesary.Transmitter.ReceiptStatus_Finished;
}
return emesary.Transmitter.ReceiptStatus_Finished;
},
# Reset controller if required when the page is displayed or hidden
ondisplay : func() {
me.RegisterWithEmesary();
for (var i = 0; i < size(me._cursorElements); i = i+1) {
me._cursorElements[i].unhighlightElement();
}
# If we're editing an element, complete the data entry.
if (me._cursorElements[me._selectedElement].isInEdit()) {
me._cursorElements[me._selectedElement].enterElement();
}
me._selectedElement = -1;
if (me._cursorElements[me._selectedElement] == me.page.IDEntry) {
# We've finished entering an ID, so load it.
var destination = me.getDestination(me.page.IDEntry.getValue());
if (destination != nil) {
var id = me.getNavData("CurrentDTO");
me.page.IDEntry.setValue(id);
me.loadDestination(id);
},
offdisplay : func() {
me.DeRegisterWithEmesary();
},
loadDestination : func(id) {
var d = {
id: id,
name: "",
lat: 0,
lon: 0,
course : 0,
range_nm : 0,
};
if ((id != nil) and size(id) > 1) {
# Use Emesary to get the destination
var notification = notifications.PFDEventNotification.new(
"MFD",
1,
notifications.PFDEventNotification.NavData,
{Id: "NavDataByID", Value: id});
var response = me._transmitter.NotifyAll(notification);
var retval = notification.EventParameter.Value;
if ((! me._transmitter.IsFailed(response)) and (size(retval) > 0)) {
var destination = retval[0];
# set the course and distance to the destination if required
var (course, dist) = courseAndDistance(destination);
var d = {
@ -157,84 +347,9 @@ var DirectToController =
course : course,
range_nm : dist,
};
me.page.displayDestination(d);
}
}
# Determine where to highlight next. In most cases, we go straight to ACTIVATE.
# The exception is the VNV Alt field which goes to the VNV Distance field;
if (me._cursorElements[me._selectedElement] == me.page.VNVAltEntry) {
# VNV DIS entry is the next element
me.nextCursorElement(1);
} else {
# ACTIVATE is the last element of the group
me.setCursorElement(size(me._cursorElements) - 1);
}
return emesary.Transmitter.ReceiptStatus_Finished;
},
handleClear : func(value) {
var mappage = me._page.getMFD().getPage("NavigationMap");
assert(mappage != nil, "Unable to find NavigationMap page");
me._page.getDevice().selectPage(mappage);
return emesary.Transmitter.ReceiptStatus_Finished;
},
handleSoftKey : func(key) {
# DirectTo has no softkeys, but if the user presses one from the underlying
# page we should switch outselves off.
me.page.setVisible(0);
return emesary.Transmitter.ReceiptStatus_OK;
},
# Reset controller if required when the page is displayed or hidden
ondisplay : func() {
me.RegisterWithEmesary();
for (var i = 0; i < size(me._cursorElements); i = i+1) {
me._cursorElements[i].unhighlightElement();
}
me.setCursorElement(0);
me.page.IDEntry.setValue("KHAF");
var destination = me.getDestination(me.page.IDEntry.getValue());
if (destination != nil) {
# set the course and distance to the destination if required
var (course, dist) = courseAndDistance(destination);
var d = {
id: destination.id,
name: destination.name,
lat: destination.lat,
lon: destination.lon,
course : course,
range_nm : dist,
};
me.page.displayDestination(d);
}
},
offdisplay : func() {
me.DeRegisterWithEmesary();
},
getDestination : func(id) {
# Use Emesary to get the destination
var notification = notifications.PFDEventNotification.new(
"MFD",
1,
notifications.PFDEventNotification.NavData,
{Id: "NavDataByID", Value: id});
var response = me._transmitter.NotifyAll(notification);
var retval = notification.EventParameter.Value;
if ((! me._transmitter.IsFailed(response)) and (size(retval) > 0)) {
return retval[0];
} else {
return nil;
}
me.page.displayDestination(d);
},
};

View file

@ -14,6 +14,16 @@ new : func (device)
obj._registered = 0;
obj._device = device;
# List of recently use waypoints
obj._recentWaypoints = std.Vector.new();
# Current DirectTo ID.
var nearest = obj.getNearestAirports();
if (size(nearest) > 0) {
nearest = nearest[0];
obj._currentDTO = nearest.id;
}
return obj;
},
@ -41,6 +51,11 @@ getNearestAirports : func()
getAirportById : func(id)
{
var apt = findAirportsByICAO(id, "airport");
if ((apt != nil) and (! me._recentWaypoints.contains(id))) {
me._recentWaypoints.insert(0, id);
}
return apt;
},
@ -57,9 +72,65 @@ getNavDataById : func (id)
# Check for fix.
if (size(navdata) == 0) navdata = findFixesByID(id);
if ((size(navdata) > 0) and (! me._recentWaypoints.contains(id))) {
me._recentWaypoints.insert(0, id);
}
return navdata;
},
# Retrieve the current flightplan and return it
getFlightplan : func ()
{
return flightplan();
},
# Retrieve the Airway waypoints on the current leg.
getAirwayWaypoints : func() {
var fp = flightplan();
if (fp != nil) {
var current_wp = fp.currentWP();
if ((current_wp != nil) and (fp.indexOfWP(current_wp) > 0)) {
var last_wp = fp.getWP(fp.indexOfWP(current_wp) -1);
return airwaysRoute(last_wp, current_wp);
}
}
return nil;
},
# Return the recently seen waypoints, collected from previous calls to
# other nav data functions
getRecentWaypoints : func()
{
return me._recentWaypoints.vector;
},
# Add an ID to the list of recent waypoints
addRecentWaypoint : func(id)
{
if ((id != nil) and (! me._recentWaypoints.contains(id))) {
me._recentWaypoints.insert(0, id);
}
},
# Return the array of user waypoints. TODO
getUserWaypoints : func()
{
return [];
},
# Return the current DTO location to use
getCurrentDTO : func()
{
return me._currentDTO;
},
# Set the current DTO location to use
setCurrentDTO : func(id)
{
me._currentDTO = id;
},
RegisterWithEmesary : func()
{
if (me._recipient == nil){
@ -80,13 +151,35 @@ RegisterWithEmesary : func()
return emesary.Transmitter.ReceiptStatus_Finished;
}
if (id == "AirportByID") {
var apt = controller.getAirportById(notification.EventParameter.Value);
notification.EventParameter.Value = apt;
notification.EventParameter.Value = controller.getAirportById(notification.EventParameter.Value);
return emesary.Transmitter.ReceiptStatus_Finished;
}
if (id == "NavDataByID") {
var navdata = controller.getNavDataById(notification.EventParameter.Value);
notification.EventParameter.Value = navdata;
notification.EventParameter.Value = controller.getNavDataById(notification.EventParameter.Value);
return emesary.Transmitter.ReceiptStatus_Finished;
}
if (id == "Flightplan") {
notification.EventParameter.Value = controller.getFlightplan();
return emesary.Transmitter.ReceiptStatus_Finished;
}
if (id == "RecentWaypoints") {
notification.EventParameter.Value = controller.getRecentWaypoints();
return emesary.Transmitter.ReceiptStatus_Finished;
}
if (id == "AddRecentWaypoint") {
controller.addRecentWaypoint(notification.EventParameter.Value);
return emesary.Transmitter.ReceiptStatus_Finished;
}
if (id == "AirwayWaypoints") {
notification.EventParameter.Value = controller.getAirwayWaypoints();
return emesary.Transmitter.ReceiptStatus_Finished;
}
if (id == "UserWaypoints") {
notification.EventParameter.Value = controller.getUserWaypoints();
return emesary.Transmitter.ReceiptStatus_Finished;
}
if (id == "CurrentDTO") {
notification.EventParameter.Value = controller.getCurrentDTO();
return emesary.Transmitter.ReceiptStatus_Finished;
}
}

View file

@ -167,7 +167,7 @@ var NearestAirportsController =
ondisplay : func() {
me._currentGroup = NearestAirportsController.UIGROUP.NONE;
me.RegisterWithEmesary();
me.getAirports();
me.getNearestAirports();
me.page.mfd.NavigationMap.getController().enableDTO(1);
},
offdisplay : func() {
@ -175,7 +175,7 @@ var NearestAirportsController =
me.DeRegisterWithEmesary();
},
getAirports : func() {
getNearestAirports : func() {
var notification = notifications.PFDEventNotification.new(
"MFD",

View file

@ -89,9 +89,11 @@ var ScrollElement =
}
},
highlightElement : func() {
me._flashElement();
me._flashTimer = maketimer(0.5, me, me._flashElement);
me._flashTimer.start();
if (me._flashTimer == nil) {
me._flashElement();
me._flashTimer = maketimer(0.5, me, me._flashElement);
me._flashTimer.start();
}
},
unhighlightElement : func() {
if (me._flashTimer != nil) me._flashTimer.stop();