Debian Codegraph @

Aircraft/Instruments-3d/FG1000/Nasal/MFDPages/IntersectionInfo/IntersectionInfo.nas

raw
1 # Copyright 2018 Stuart Buchanan
2 # This file is part of FlightGear.
3 #
4 # FlightGear is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # FlightGear is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with FlightGear. If not, see <http://www.gnu.org/licenses/>.
16 #
17 # IntersectionInfo
18 var IntersectionInfo =
19 {
20 new : func (mfd, myCanvas, device, svg)
21 {
22 var obj = {
23 parents : [
24 IntersectionInfo,
25 MFDPage.new(mfd, myCanvas, device, svg, "IntersectionInfo", "WPT - INTERSECTION INFORMATION")
26 ],
27 };
28
29 # Dynamic text elements in the SVG file. In the SVG these have an "IntersectionInfo" prefix.
30 textelements = [
31 "ID",
32 "Region",
33 "Lat",
34 "Lon",
35 "VORID",
36 "VORCRS",
37 "VORDST"
38 ];
39
40 obj.addTextElements(textelements);
41
42 # Data Entry information. Keyed from the name of the element, which must
43 # be one of the textelements above. Each data element maps to a set of
44 # text elements in the SVG of the form [PageName][TextElement]{0...n}, each
45 # representing a single character for data entry.
46 #
47 # .size is the number of characters of data entry
48 # .chars is the set of characters, used to scroll through using the small
49 # FMS knob.
50 obj.dataEntry = PFD.DataEntryElement.new(obj.pageName, svg, "ID", "", 5, "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
51
52 obj.Map = fg1000.NavMap.new(
53 obj,
54 obj.getElement("NavMap"),
55 [860,400],
56 "",
57 -50,
58 0,
59 1);
60
61 obj.topMenu(device, obj, nil);
62
63 obj.setController(fg1000.IntersectionInfoController.new(obj, svg));
64 obj.update(nil,nil);
65
66 return obj;
67 },
68
69 update : func(navdata, vordata) {
70 if (navdata != nil) {
71 me.setTextElementLat("Lat", navdata.lat);
72 me.setTextElementLon("Lon", navdata.lon);
73 me.setTextElement("ID", navdata.id);
74
75 me.Map.getController().setPosition(navdata.lat, navdata.lon);
76 me.Map.show();
77 } else {
78 me.setTextElementLat("Lat", nil);
79 me.setTextElementLon("Lon", nil);
80 me.setTextElement("ID", "#####");
81 me.Map.hide();
82 }
83
84 if (vordata != nil) {
85 var crsAndDst = courseAndDistance(navdata, vordata);
86 me.setTextElement("VORID", vordata.id);
87 me.setTextElementBearing("VORCRS", vordata.crs);
88 me.setTextElementDistance("VORDST", vordata.dst);
89 } else {
90 me.setTextElement("VORID", "");
91 me.setTextElement("VORCRS", "");
92 me.setTextElement("VORDST", "");
93 }
94 },
95
96 offdisplay : func() {
97 me._group.setVisible(0);
98
99 # Reset the menu colours. Shouldn't have to do this here, but
100 # there's not currently an obvious other location to do so.
101 for(var i = 0; i < 12; i +=1) {
102 var name = sprintf("SoftKey%d",i);
103 me.device.svg.getElementById(name ~ "-bg").setColorFill(0.0,0.0,0.0);
104 me.device.svg.getElementById(name).setColor(1.0,1.0,1.0);
105 }
106 me.getElement("NavMap").setVisible(0);
107 me.Map.setVisible(0);
108 me.getController().offdisplay();
109 },
110 ondisplay : func() {
111 me._group.setVisible(1);
112 me.mfd.setPageTitle(me.title);
113
114 me.getElement("NavMap").setVisible(1);
115 me.Map.setVisible(1);
116 me.getController().ondisplay();
117 },
118 topMenu : func(device, pg, menuitem) {
119 pg.clearMenu();
120 pg.resetMenuColors();
121 pg.addMenuItem(0, "ENGINE", pg.mfd.EIS, pg.mfd.EIS.engineMenu);
122 pg.addMenuItem(2, "MAP", pg.mfd.NavigationMap, pg.mfd.NavigationMap.mapMenu);
123 device.updateMenus();
124 },
125 };