2018-02-09 18:55:53 +00:00
|
|
|
# Copyright 2018 Stuart Buchanan
|
|
|
|
# This file is part of FlightGear.
|
|
|
|
#
|
2018-05-28 19:15:57 +00:00
|
|
|
# FlightGear is free software: you can redistribute it and/or modify
|
2018-02-09 18:55:53 +00:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# FlightGear is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with FlightGear. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
2017-12-10 22:15:21 +00:00
|
|
|
# IntersectionInfo
|
|
|
|
var IntersectionInfo =
|
|
|
|
{
|
|
|
|
new : func (mfd, myCanvas, device, svg)
|
|
|
|
{
|
|
|
|
var obj = {
|
2017-12-27 19:51:54 +00:00
|
|
|
parents : [
|
|
|
|
IntersectionInfo,
|
|
|
|
MFDPage.new(mfd, myCanvas, device, svg, "IntersectionInfo", "WPT - INTERSECTION INFORMATION")
|
|
|
|
],
|
2017-12-10 22:15:21 +00:00
|
|
|
};
|
|
|
|
|
2018-04-15 18:44:10 +00:00
|
|
|
# Dynamic text elements in the SVG file. In the SVG these have an "IntersectionInfo" prefix.
|
|
|
|
textelements = [
|
|
|
|
"ID",
|
|
|
|
"Region",
|
|
|
|
"Lat",
|
|
|
|
"Lon",
|
|
|
|
"VORID",
|
|
|
|
"VORCRS",
|
|
|
|
"VORDST"
|
|
|
|
];
|
|
|
|
|
|
|
|
obj.addTextElements(textelements);
|
|
|
|
|
|
|
|
# Data Entry information. Keyed from the name of the element, which must
|
|
|
|
# be one of the textelements above. Each data element maps to a set of
|
|
|
|
# text elements in the SVG of the form [PageName][TextElement]{0...n}, each
|
|
|
|
# representing a single character for data entry.
|
|
|
|
#
|
|
|
|
# .size is the number of characters of data entry
|
|
|
|
# .chars is the set of characters, used to scroll through using the small
|
|
|
|
# FMS knob.
|
|
|
|
obj.dataEntry = PFD.DataEntryElement.new(obj.pageName, svg, "ID", "", 5, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
|
|
|
|
|
|
|
|
obj.Map = fg1000.NavMap.new(
|
|
|
|
obj,
|
|
|
|
obj.getElement("NavMap"),
|
|
|
|
[860,400],
|
|
|
|
"",
|
|
|
|
-50,
|
|
|
|
0,
|
|
|
|
1);
|
|
|
|
|
2018-01-13 18:53:06 +00:00
|
|
|
obj.topMenu(device, obj, nil);
|
2017-12-10 22:15:21 +00:00
|
|
|
|
2018-01-26 19:06:06 +00:00
|
|
|
obj.setController(fg1000.IntersectionInfoController.new(obj, svg));
|
2018-04-15 18:44:10 +00:00
|
|
|
obj.update(nil,nil);
|
2017-12-27 19:51:54 +00:00
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
return obj;
|
|
|
|
},
|
2018-04-15 18:44:10 +00:00
|
|
|
|
|
|
|
update : func(navdata, vordata) {
|
|
|
|
if (navdata != nil) {
|
|
|
|
me.setTextElementLat("Lat", navdata.lat);
|
|
|
|
me.setTextElementLon("Lon", navdata.lon);
|
|
|
|
me.setTextElement("ID", navdata.id);
|
|
|
|
|
|
|
|
me.Map.getController().setPosition(navdata.lat, navdata.lon);
|
|
|
|
me.Map.show();
|
|
|
|
} else {
|
|
|
|
me.setTextElementLat("Lat", nil);
|
|
|
|
me.setTextElementLon("Lon", nil);
|
|
|
|
me.setTextElement("ID", "#####");
|
|
|
|
me.Map.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (vordata != nil) {
|
|
|
|
var crsAndDst = courseAndDistance(navdata, vordata);
|
|
|
|
me.setTextElement("VORID", vordata.id);
|
|
|
|
me.setTextElementBearing("VORCRS", vordata.crs);
|
|
|
|
me.setTextElementDistance("VORDST", vordata.dst);
|
|
|
|
} else {
|
|
|
|
me.setTextElement("VORID", "");
|
|
|
|
me.setTextElement("VORCRS", "");
|
|
|
|
me.setTextElement("VORDST", "");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-12-10 22:15:21 +00:00
|
|
|
offdisplay : func() {
|
|
|
|
me._group.setVisible(0);
|
|
|
|
|
|
|
|
# Reset the menu colours. Shouldn't have to do this here, but
|
|
|
|
# there's not currently an obvious other location to do so.
|
|
|
|
for(var i = 0; i < 12; i +=1) {
|
|
|
|
var name = sprintf("SoftKey%d",i);
|
|
|
|
me.device.svg.getElementById(name ~ "-bg").setColorFill(0.0,0.0,0.0);
|
|
|
|
me.device.svg.getElementById(name).setColor(1.0,1.0,1.0);
|
|
|
|
}
|
2018-04-15 18:44:10 +00:00
|
|
|
me.getElement("NavMap").setVisible(0);
|
|
|
|
me.Map.setVisible(0);
|
2018-01-26 19:06:06 +00:00
|
|
|
me.getController().offdisplay();
|
2017-12-10 22:15:21 +00:00
|
|
|
},
|
|
|
|
ondisplay : func() {
|
|
|
|
me._group.setVisible(1);
|
|
|
|
me.mfd.setPageTitle(me.title);
|
2018-04-15 18:44:10 +00:00
|
|
|
|
|
|
|
me.getElement("NavMap").setVisible(1);
|
|
|
|
me.Map.setVisible(1);
|
2018-01-26 19:06:06 +00:00
|
|
|
me.getController().ondisplay();
|
2017-12-10 22:15:21 +00:00
|
|
|
},
|
2018-01-13 18:53:06 +00:00
|
|
|
topMenu : func(device, pg, menuitem) {
|
|
|
|
pg.clearMenu();
|
|
|
|
pg.resetMenuColors();
|
2018-04-16 12:38:41 +00:00
|
|
|
pg.addMenuItem(0, "ENGINE", pg.mfd.EIS, pg.mfd.EIS.engineMenu);
|
|
|
|
pg.addMenuItem(2, "MAP", pg.mfd.NavigationMap, pg.mfd.NavigationMap.mapMenu);
|
2018-01-13 18:53:06 +00:00
|
|
|
device.updateMenus();
|
|
|
|
},
|
2017-12-10 22:15:21 +00:00
|
|
|
};
|