Debian Codegraph @

gui/dialogs/airports.xml

raw symbols SCIP
1 <?xml version="1.0"?>
2
3 <PropertyList>
4 <name>airports</name>
5 <layout>vbox</layout>
6 <resizable>true</resizable>
7 <default-padding>3</default-padding>
8
9 <group>
10 <layout>hbox</layout>
11 <default-padding>1</default-padding>
12
13 <text>
14 <label>Select an Airport</label>
15 </text>
16
17 <empty><stretch>1</stretch></empty>
18
19 <button>
20 <legend>X</legend>
21 <key>Esc</key>
22 <pref-width>20</pref-width>
23 <pref-height>20</pref-height>
24 <binding>
25 <command>dialog-close</command>
26 </binding>
27 <binding>
28 <command>property-toggle</command>
29 <property>/sim/gui/dialogs/airports/signals/dialog-close</property>
30 </binding>
31 </button>
32 </group>
33
34 <hrule/>
35
36 <nasal>
37 <!-- Generalize all this, turn into helpers and load defaults via XML -->
38 <open><![CDATA[
39 var update_info = func(open = 0) {
40 var info = airportinfo(airport_id);
41 setprop("/sim/gui/dialogs/airports/selected-airport/id", airport_id);
42 setprop("/sim/gui/dialogs/airports/selected-airport/name", info.name);
43 setprop("/sim/gui/dialogs/airports/selected-airport/location", sprintf("%.3f / %.3f", info.lat, info.lon));
44 setprop("/sim/gui/dialogs/airports/selected-airport/lon", info.lon);
45 setprop("/sim/gui/dialogs/airports/selected-airport/lat", info.lat);
46 setprop("/sim/gui/dialogs/airports/selected-airport/elevation-ft", 3.28 * info.elevation);
47 setprop("/sim/gui/dialogs/airports/selected-airport/rwy", "");
48 setprop("/sim/gui/dialogs/airports/selected-airport/parkpos", "");
49 if (!open) {
50 AirportChart.getController().setPosition(info.lat, info.lon);
51 }
52
53 if (info.has_metar) {
54 # Retrieve an updated METAR, and indicate that we've not got one currently.
55 fgcommand("request-metar", var n = props.Node.new({ "path": "/sim/gui/dialogs/airports/selected-airport/metar",
56 "station": airport_id}));
57 } else {
58 # This airport has no METAR. Rather than cancelling the retrieve-metar command, simply set the TTL
59 # to a very long time so it won't over-ride our message.
60 setprop("/sim/gui/dialogs/airports/selected-airport/metar/time-to-live", 9999);
61 }
62
63
64 # Display the comms frequencies for this airport
65 var fcount = 0;
66
67 if (size(info.comms()) > 0) {
68 # Airport has one or more frequencies assigned to it.
69 var freqs = {};
70 var comms = info.comms();
71
72 foreach (var c; comms) {
73 var f = sprintf("%.3f", c.frequency);
74 if (freqs[c.ident] == nil) {
75 freqs[c.ident] = f;
76 } else {
77 freqs[c.ident] = freqs[c.ident] ~ " " ~ f;
78 }
79 }
80
81 foreach (var c; sort(keys(freqs), string.icmp)) {
82 setprop("sim/gui/dialogs/airports/selected-airport/comms/freq[" ~ fcount ~ "]/label", c);
83 setprop("sim/gui/dialogs/airports/selected-airport/comms/freq[" ~ fcount ~ "]/value", freqs[c]);
84 fcount += 1;
85 }
86 }
87
88 while (fcount < 13) {
89 # zero remaining comms channels
90 setprop("sim/gui/dialogs/airports/selected-airport/comms/freq[" ~ fcount ~ "]/label", "");
91 setprop("sim/gui/dialogs/airports/selected-airport/comms/freq[" ~ fcount ~ "]/value", "");
92 fcount += 1;
93 }
94
95 var longest_runway = 0;
96 var runways = info.runways;
97 var infoAboutRunways = []; # list of strings for display
98
99 avail_runways.removeChildren("value");
100 var runway_keys = sort(keys(runways), string.icmp);
101 var i = 0;
102
103 foreach(var rwy; runway_keys) {
104 var r = runways[rwy];
105 longest_runway = math.max(longest_runway, r.length * 3.28);
106 avail_runways.getNode("value[" ~ i ~ "]", 1).setValue(rwy);
107 var rwyInfo = sprintf("%5s %12d' / %03d deg", rwy, r.length * 3.28,
108 r.magnetic_heading);
109
110 if (r.ils != nil) {
111 rwyInfo = sprintf("%s %20.3f MHz", rwyInfo,
112 r.ils.frequency / 100);
113 }
114
115 append(infoAboutRunways, rwyInfo);
116
117 i += 1;
118 if (i == MAX_RUNWAYS)
119 break;
120 }
121
122 var runwayInfoNode = dlg.getNode("selected-airport/runways-info", 1);
123 runwayInfoNode.setValue(string.join("\n", infoAboutRunways));
124 fgcommand("dialog-update", props.Node.new({"object-name": "runways-info", "dialog-name": "airports"}));
125
126 # Update the list of available parking positions
127 avail_parking = {"AVAILABLE":1};
128 foreach (var park; info.parking()) {
129 avail_parking[park.name] = 1;
130 }
131
132 setprop("/sim/gui/dialogs/airports/selected-airport/longest-runway", longest_runway);
133
134 var airport_pos = geo.Coord.new();
135 airport_pos.set_latlon(info.lat, info.lon);
136
137 var pos = geo.aircraft_position();
138 var dst = pos.distance_to(airport_pos) / 1852.0;
139 var crs = pos.course_to(airport_pos);
140 setprop("/sim/gui/dialogs/airports/selected-airport/distance-nm", dst);
141 setprop("/sim/gui/dialogs/airports/selected-airport/course-deg", crs);
142
143 gui.dialog_update("airports", "runway-list");
144 }
145
146 var MAX_RUNWAYS = 28; # number of entries at KEDW
147
148 var DIALOG = cmdarg();
149 var listeners = [];
150
151 ## "prologue" currently required by the canvas-generic-map
152 var dialog_name ="airports"; #TODO: use substr() and cmdarg() to get this dynamically
153 var dialog_property = func(p) return "/sim/gui/dialogs/airports/"~p; #TODO: generalize using cmdarg
154 var DIALOG_CANVAS = gui.findElementByName(DIALOG, "airport-selection");
155
156 var displayMode = getprop("/sim/gui/dialogs/airports/display-mode");
157 if ((displayMode != 0) and (displayMode != 1)) {
158 setprop("/sim/gui/dialogs/airports/display-mode", 0);
159 }
160
161 var showHelipads = getprop("/sim/gui/dialogs/airports/show-helipads");
162 if ((showHelipads != 0) and (showHelipads != 1)) {
163 setprop("/sim/gui/dialogs/airports/show-helipads", 0);
164 }
165
166 var dlg = props.globals.getNode("/sim/gui/dialogs/airports", 1);
167 var avail_runways = dlg.getNode("available-runways", 1);
168 var avail_parking = {};
169
170 # Start with the closest airport
171 var airport_id = airportinfo().id;
172 update_info(open = 1);
173
174 # Retrieve METAR
175 fgcommand("request-metar", var n = props.Node.new({ "path": "/sim/gui/dialogs/airports/selected-airport/metar",
176 "station": airport_id}));
177
178 dlg.getNode("list", 1).setValue("");
179
180 var airportlist = dlg.getNode("list");
181
182 var mode = {
183 runway: dlg.getNode("use_runway", 1),
184 bestrunway: dlg.getNode("use_best_runway", 1),
185 parkpos: dlg.getNode("use_parkpos", 1)
186 };
187
188 var set_radio = func(m) {
189 foreach (k; keys(mode)) {
190 mode[k].setBoolValue(m == k);
191 }
192 }
193
194 var initialized = 0;
195 foreach (k; keys(mode)) {
196 if (mode[k].getType() == "NONE" or initialized) {
197 mode[k].setBoolValue(0);
198 } else {
199 initialized += mode[k].getBoolValue();
200 }
201 }
202 if (!initialized) {
203 set_radio("bestrunway");
204 }
205
206 var listbox = func {
207 airport_id = pop(split(" ", airportlist.getValue()));
208 airport_id = substr(airport_id, 1, size(airport_id) - 2); # strip parentheses
209
210 update_info();
211 }
212
213 var apply = func {
214 setprop("/sim/presets/airport-id", airport_id);
215 setprop("/sim/presets/longitude-deg", -9999);
216 setprop("/sim/presets/latitude-deg", -9999);
217 setprop("/sim/presets/altitude-ft", -9999);
218 setprop("/sim/presets/airspeed-kt", 0);
219 setprop("/sim/presets/offset-distance-nm", 0);
220 setprop("/sim/presets/offset-azimuth-deg", 0);
221 setprop("/sim/presets/glideslope-deg", 0);
222 setprop("/sim/presets/heading-deg", 9999.0);
223
224 if (mode["bestrunway"].getBoolValue()) {
225 setprop("/sim/presets/runway", "");
226 setprop("/sim/presets/parkpos", "");
227 setprop("/sim/presets/runway-requested", 0);
228 } else if (mode["runway"].getBoolValue()) {
229 setprop("/sim/presets/runway", getprop("/sim/gui/dialogs/airports/selected-airport/rwy"));
230 setprop("/sim/presets/parkpos", "");
231 setprop("/sim/presets/runway-requested", 1);
232 } else {
233 setprop("/sim/presets/runway", "");
234 setprop("/sim/presets/parkpos", getprop("/sim/gui/dialogs/airports/selected-airport/parkpos"));
235 }
236 }
237
238 canvas.register_callback(update_info); # FIXME: this is a workaround to run dialog-specific code in the canvas block
239 ]]>
240 </open>
241 <close><![CDATA[
242 fgcommand("clear-metar", var n = props.Node.new({ "path": "/sim/gui/dialogs/airports/selected-airport/metar",
243 "station": airport_id}));
244 #map.cleanup_listeners(); #TODO: We should be setting a signal when closing the dialog, so that cleanup code can be invoked automatically
245 AirportChart.del();
246 foreach (var l; listeners)
247 removelistener(l);
248 setsize(listeners, 0);
249 ]]></close>
250 </nasal>
251
252 <group>
253 <layout>hbox</layout>
254 <default-padding>4</default-padding>
255 <halign>fill</halign>
256 <stretch>true</stretch>
257
258 <group>
259 <layout>vbox</layout>
260 <valign>top</valign>
261 <stretch>true</stretch>
262
263 <group>
264 <layout>hbox</layout>
265 <default-padding>4</default-padding>
266
267 <text>
268 <label>Airport:</label>
269 </text>
270
271 <input>
272 <name>input</name>
273 <pref-width>120</pref-width>
274 <halign>fill</halign>
275 <stretch>true</stretch>
276 <property>/sim/gui/dialogs/airports/list</property>
277 <binding>
278 <command>dialog-apply</command>
279 <object-name>input</object-name>
280 </binding>
281 </input>
282
283 <!--
284
285 <button>
286 <legend>Clear</legend>
287 <binding>
288 <command>property-assign</command>
289 <property>/sim/gui/dialogs/airports/mode</property>
290 <value>search</value>
291 </binding>
292 <binding>
293 <command>property-assign</command>
294 <property>/sim/gui/dialogs/airports/list</property>
295 <value></value>
296 </binding>
297 <binding>
298 <command>dialog-update</command>
299 <object-name>input</object-name>
300 </binding>
301 <binding>
302 <command>dialog-update</command>
303 <object-name>airport-list</object-name>
304 </binding>
305 </button>
306 -->
307 <button>
308 <legend>Search</legend>
309 <default>true</default>
310 <binding>
311 <command>property-assign</command>
312 <property>/sim/gui/dialogs/airports/mode</property>
313 <value>search</value>
314 </binding>
315 <binding>
316 <command>dialog-apply</command>
317 <object-name>input</object-name>
318 </binding>
319 <binding>
320 <command>nasal</command>
321 <script>
322 var apt_type = "airport:";
323 var heli_type = "heliport:";
324 var search_term = getprop("/sim/gui/dialogs/airports/list");
325
326 # strip off airport type prefix
327 if (string.match(search_term,heli_type)) {
328 search_term = string.substr(search_term,size(heli_type));
329 }
330 else if (string.match(search_term,apt_type)) {
331 search_term = string.substr(search_term,size(apt_type));
332 }
333 var new_value = "";
334
335 # add new airport type prefix based off helipad checkbox
336 if (getprop("/sim/gui/dialogs/airports/show-helipads")) {
337 new_value = heli_type ~ search_term;
338 }
339 else {
340 new_value = apt_type ~ search_term;
341 }
342 setprop("/sim/gui/dialogs/airports/list", new_value);
343 </script>
344 </binding>
345 <binding>
346 <command>dialog-update</command>
347 <object-name>airport-list</object-name>
348 </binding>
349 </button>
350
351 <button>
352 <legend>&lt;100nm</legend>
353 <binding>
354 <command>property-assign</command>
355 <property>/sim/gui/dialogs/airports/mode</property>
356 <value>100nm</value>
357 </binding>
358 <binding>
359 <command>nasal</command>
360 <script>
361 # change airport type to heliport if checkbox is set
362 var apt_type = "airport";
363 if (getprop("/sim/gui/dialogs/airports/show-helipads")) {
364 apt_type = "heliport";
365 }
366 var airports = findAirportsWithinRange(100,apt_type);
367
368 var list = dlg.getNode("close-airports", 1);
369
370 list.removeChildren("value");
371
372 forindex (var idx; airports) {
373 list.getNode("value["~ idx ~ "]", 1).setValue(airports[idx].name ~ " (" ~ airports[idx].id ~ ")");
374 }
375 </script>
376 </binding>
377 <binding>
378 <command>dialog-update</command>
379 <object-name>close-airport-list</object-name>
380 </binding>
381 </button>
382
383 <checkbox>
384 <name>show-helipads</name>
385 <label>Helipads</label>
386 <property>/sim/gui/dialogs/airports/show-helipads</property>
387 <binding>
388 <command>dialog-apply</command>
389 <object-name>show-helipads</object-name>
390 </binding>
391 </checkbox>
392
393 </group>
394
395 <group>
396 <layout>table</layout>
397 <default-padding>0</default-padding>
398
399 <list>
400 <row>0</row><col>0</col>
401 <visible>
402 <equals>
403 <property>/sim/gui/dialogs/airports/mode</property>
404 <value>100nm</value>
405 </equals>
406 </visible>
407 <name>close-airport-list</name>
408 <pref-width>260</pref-width>
409 <pref-height>260</pref-height>
410 <halign>fill</halign>
411 <valign>fill</valign>
412 <stretch>true</stretch>
413 <property>/sim/gui/dialogs/airports/list</property>
414 <properties>/sim/gui/dialogs/airports/close-airports</properties>
415 <binding>
416 <command>dialog-apply</command>
417 <object-name>close-airport-list</object-name>
418 </binding>
419 <binding>
420 <command>nasal</command>
421 <script>listbox()</script>
422 </binding>
423 </list>
424
425 <airport-list>
426 <row>0</row><col>0</col>
427 <visible>
428 <equals>
429 <property>/sim/gui/dialogs/airports/mode</property>
430 <value>search</value>
431 </equals>
432 </visible>
433 <name>airport-list</name>
434 <pref-width>260</pref-width>
435 <pref-height>220</pref-height>
436 <halign>fill</halign>
437 <valign>fill</valign>
438 <stretch>true</stretch>
439 <property>/sim/gui/dialogs/airports/list</property>
440 <binding>
441 <command>dialog-apply</command>
442 <object-name>airport-list</object-name>
443 </binding>
444 <binding>
445 <command>nasal</command>
446 <script>listbox()</script>
447 </binding>
448 </airport-list>
449
450 </group>
451
452 <group>
453 <layout>hbox</layout>
454 <halign>fill</halign>
455 <text>
456 <label>METAR</label>
457 </text>
458
459 <hrule><stretch>1</stretch></hrule>
460 </group>
461
462 <textbox>
463 <name>metar</name>
464 <halign>fill</halign>
465 <stretch>true</stretch>
466 <pref-width>260</pref-width>
467 <pref-height>70</pref-height>
468 <slider>15</slider>
469 <editable>false</editable>
470 <wrap>true</wrap>
471 <live>true</live>
472 <property>/sim/gui/dialogs/airports/selected-airport/metar/data</property>
473 </textbox>
474
475 <group>
476 <layout>vbox</layout>
477 <valign>top</valign>
478
479 <group>
480 <layout>hbox</layout>
481 <halign>fill</halign>
482 <row>0</row>
483 <col>0</col>
484 <colspan>2</colspan>
485
486 <text>
487 <label>Aircraft Position</label>
488 </text>
489
490 <hrule><stretch>1</stretch></hrule>
491 </group>
492
493 <group>
494 <layout>table</layout>
495 <halign>center</halign>
496
497 <radio>
498 <row>2</row><col>0</col>
499 <property>/sim/gui/dialogs/airports/use_best_runway</property>
500 <live>true</live>
501 <binding>
502 <command>nasal</command>
503 <script>set_radio("bestrunway")</script>
504 </binding>
505 </radio>
506
507 <text>
508 <row>2</row><col>1</col>
509 <halign>right</halign>
510 <label>Best runway</label>
511 <enable>
512 <property>/sim/gui/dialogs/airports/use_best_runway</property>
513 </enable>
514 </text>
515 <text>
516 <row>2</row><col>2</col>
517 <halign>right</halign>
518 <label>(based on wind)</label>
519 <enable>
520 <property>/sim/gui/dialogs/airports/use_best_runway</property>
521 </enable>
522 </text>
523
524 <radio>
525 <row>3</row><col>0</col>
526 <property>/sim/gui/dialogs/airports/use_runway</property>
527 <live>true</live>
528 <binding>
529 <command>nasal</command>
530 <script>set_radio("runway")</script>
531 </binding>
532 </radio>
533
534 <text>
535 <row>3</row><col>1</col>
536 <halign>right</halign>
537 <label>Runway:</label>
538 <enable>
539 <property>/sim/gui/dialogs/airports/use_runway</property>
540 </enable>
541 </text>
542
543 <combo>
544 <name>runway-list</name>
545 <row>3</row><col>2</col>
546 <pref-width>85</pref-width>
547 <halign>left</halign>
548 <enable>
549 <property>/sim/gui/dialogs/airports/use_runway</property>
550 </enable>
551 <property>/sim/gui/dialogs/airports/selected-airport/rwy</property>
552 <editable>false</editable>
553 <properties>sim/gui/dialogs/airports/available-runways</properties>
554 <binding>
555 <command>dialog-apply</command>
556 <object-name>runway-list</object-name>
557 </binding>
558 </combo>
559
560 <radio>
561 <row>4</row><col>0</col>
562 <property>/sim/gui/dialogs/airports/use_parkpos</property>
563 <live>true</live>
564 <binding>
565 <command>nasal</command>
566 <script>set_radio("parkpos")</script>
567 </binding>
568 </radio>
569
570 <text>
571 <row>4</row><col>1</col>
572 <halign>right</halign>
573 <label>Parking:</label>
574 <enable>
575 <property>/sim/gui/dialogs/airports/use_parkpos</property>
576 </enable>
577 </text>
578
579 <input>
580 <row>4</row><col>2</col>
581 <name>parking-list</name>
582 <pref-width>120</pref-width>
583 <halign>fill</halign>
584 <stretch>true</stretch>
585 <property>/sim/gui/dialogs/airports/selected-airport/parkpos</property>
586 <binding>
587 <command>dialog-apply</command>
588 <object-name>parking-list</object-name>
589 </binding>
590 <binding>
591 <command>nasal</command>
592 <script>
593 var pos = getprop("/sim/gui/dialogs/airports/selected-airport/parkpos");
594 setprop(
595 "/sim/gui/dialogs/airports/selected-airport/parkpos-invalid",
596 contains(avail_parking, pos) == 0);
597 </script>
598 </binding>
599 <binding>
600 <command>dialog-update</command>
601 <object-name>parking-list-valid</object-name>
602 </binding>
603 </input>
604
605 <text>
606 <row>5</row><col>1</col>
607 <colspan>2</colspan>
608 <name>parking-list-valid</name>
609 <halign>left</halign>
610 <label>Parking position not found</label>
611 <visible>
612 <property>/sim/gui/dialogs/airports/selected-airport/parkpos-invalid</property>
613 </visible>
614 </text>
615
616 </group>
617 </group>
618
619 </group>
620
621 <vrule/>
622
623 <group>
624 <layout>vbox</layout>
625 <halign>fill</halign>
626 <valign>top</valign>
627 <default-padding>0</default-padding>
628 <stretch>true</stretch>
629
630 <group>
631 <layout>hbox</layout>
632 <halign>left</halign>
633 <default-padding>2</default-padding>
634
635 <button>
636 <legend>Airfield Information</legend>
637 <binding>
638 <command>property-assign</command>
639 <property>/sim/gui/dialogs/airports/display-mode</property>
640 <value>0</value>
641 </binding>
642 </button>
643
644 <button>
645 <legend>Airfield Chart</legend>
646 <binding>
647 <command>property-assign</command>
648 <property>/sim/gui/dialogs/airports/display-mode</property>
649 <value>1</value>
650 </binding>
651 </button>
652 </group>
653
654 <group>
655 <layout>table</layout>
656 <halign>fill</halign>
657 <valign>fill</valign>
658 <default-padding>0</default-padding>
659
660 <group>
661 <layout>vbox</layout>
662 <valign>top</valign>
663 <row>0</row>
664 <col>0</col>
665 <visible>
666 <equals>
667 <property>/sim/gui/dialogs/airports/display-mode</property>
668 <value>1</value>
669 </equals>
670 </visible>
671
672 <group>
673 <layout>vbox</layout>
674
675 <group>
676 <layout>hbox</layout>
677 <halign>fill</halign>
678 <row>0</row>
679 <text>
680 <label>Airfield Chart</label>
681 </text>
682
683 <hrule><stretch>1</stretch></hrule>
684 </group>
685
686 <canvas>
687 <name>canvas-map</name>
688 <valign>fill</valign>
689 <halign>fill</halign>
690 <stretch>true</stretch>
691 <pref-width>600</pref-width>
692 <pref-height>400</pref-height>
693 <nasal><load><![CDATA[
694 var myCanvas = canvas.get( cmdarg() );
695 var mapGrp = myCanvas.createGroup();
696 var AirportChart = mapGrp.createChild("map");
697
698 # Initialize the controller:
699 AirportChart.setController("Static position", "main");
700 var controller = AirportChart.getController();
701
702 # Initialize a range and screen resolution. Setting a range
703 # to 4nm means we pick up a good set of surrounding fixes
704 # We will use the screen range for zooming. If we use range
705 # then as we zoom in the airport center goes out of range
706 # and all the runways disappear.
707 AirportChart.setRange(4.0);
708 AirportChart.setScreenRange(500);
709
710 var range_step = 1.5;
711
712 # Center the map's origin: FIXME: move to api.nas, i.e. allow maps to have a size/view that differs from the actual canvas ??
713 AirportChart.setTranslation(
714 myCanvas.get("view[0]")/2,
715 myCanvas.get("view[1]")/2
716 );
717
718 ##
719 # Styling: This is a bit crude at the moment, i.e. no dedicated APIs yet - but it's
720 # just there to prototype things for now
721 var Styles = {};
722 Styles.get = func(type) return Styles[type];
723 var Options = {};
724 Options.get = func(type) return Options[type];
725
726 ## set up a few keys supported by the DME.symbol file to customize appearance:
727 Styles.DME = {};
728 Styles.DME.debug = 1; # HACK for benchmarking/debugging purposes
729 Styles.DME.animation_test = 0; # for prototyping animated symbols
730
731 Styles.DME.scale_factor = 0.4; # 40% (applied to whole group)
732 Styles.DME.line_width = 3.0;
733 Styles.DME.color_tuned = [0,1,0]; #rgb
734 Styles.DME.color_default = [1,1,0]; #rgb
735
736 Styles.APT = {};
737 Styles.APT.scale_factor = 0.4; # 40% (applied to whole group)
738 Styles.APT.line_width = 3.0;
739 Styles.APT.color_default = [0,0.6,0.85]; #rgb
740 Styles.APT.label_font_color = Styles.APT.color_default;
741 Styles.APT.label_font_size=28;
742
743 Styles.PARKING = {};
744 Styles.PARKING.scale_factor = 0.4; # 40% (applied to whole group)
745 Styles.PARKING.line_width = 3.0;
746 Styles.PARKING.color_default = [0,0.85,0.6]; #rgb
747 Styles.PARKING.label_font_color = Styles.APT.color_default;
748 Styles.PARKING.label_font_size=28;
749
750 Styles.FLT = {};
751 Styles.FLT.line_width = 3;
752
753 Styles.FIX = {};
754 Styles.FIX.color = [1,0,0];
755 Styles.FIX.scale_factor = 0.4; # 40%
756
757 Styles.VOR = {};
758 Styles.VOR.range_line_width = 2;
759 Styles.VOR.radial_line_width = 1;
760 Styles.VOR.scale_factor = 0.6; # 60%
761
762 var ToggleLayerVisible = func(name) {
763 (var l = AirportChart.getLayer(name)).setVisible(l.getVisible());
764 };
765 var SetLayerVisible = func(name,n=1) {
766 AirportChart.getLayer(name).setVisible(n);
767 };
768
769 Styles.APS = {};
770 Styles.APS.scale_factor = 0.25;
771
772 var r = func(name,vis=1,zindex=nil) return caller(0)[0];
773 var drawDme = getprop("sim/gui/dialogs/map-canvas/draw-DME");
774 var drawParking = getprop("/sim/gui/dialogs/map-canvas/draw-PARKING");
775 # TODO: we'll need some z-indexing here, right now it's in the layer order
776 foreach(var type; [r('TAXI',1,0),r('RWY',1,1),r('TWR',1,2),r('DME',drawDme,3),r('VOR',drawDme,4),r('NDB',drawDme,5),r('FIX',drawDme,6),r('PARKING',drawParking,7)] ) {
777 AirportChart.addLayer(factory: canvas.SymbolLayer, type_arg: type.name,
778 visible: type.vis, priority: 4,
779 style: Styles.get(type.name),
780 options: Options.get(type.name) );
781 (func {
782 # Notify MapStructure about layer visibility changes:
783 var name = type.name;
784 props.globals.initNode("/sim/gui/dialogs/map-canvas/draw-"~name, type.vis, "BOOL");
785 append(listeners,
786 setlistener("/sim/gui/dialogs/map-canvas/draw-"~name,
787 func(n) SetLayerVisible(name,n.getValue()))
788 );
789
790
791 })();
792 }
793
794 # Add some event listeners to handle mouse interactions
795 myCanvas.addEventListener("drag", func(e)
796 {
797 (func {
798 controller.applyOffset(-e.deltaX, -e.deltaY); })();
799 });
800
801 myCanvas.addEventListener("click", func(e)
802 {
803 (func {
804 controller.applyOffset(e.localX - myCanvas.get("view[0]")/2,
805 e.localY - myCanvas.get("view[1]")/2); })();
806 });
807
808 myCanvas.addEventListener("wheel", func(e)
809 {
810 var range = AirportChart.getScreenRange();
811 if (e.deltaY >0) {
812 AirportChart.setScreenRange(math.min(range*range_step, 10000));
813 } else {
814 AirportChart.setScreenRange(math.max(range/range_step, 100));
815 }
816 setprop("/sim/gui/dialogs/airports/zoom-range", AirportChart.getScreenRange());
817 });
818
819 if ((getprop("/sim/gui/dialogs/airports/selected-airport/lat") != nil) and
820 (getprop("/sim/gui/dialogs/airports/selected-airport/lon") != nil) )
821 {
822 # If we've got some values from a previous instantiation of the dialog
823 # then use them to display the correct position, consistent with the
824 # rest of the dialog.
825 AirportChart.getController().setPosition(
826 getprop("/sim/gui/dialogs/airports/selected-airport/lat"),
827 getprop("/sim/gui/dialogs/airports/selected-airport/lon"));
828 }
829 ]]></load></nasal>
830 </canvas>
831
832 <group>
833 <layout>hbox</layout>
834
835 <checkbox>
836 <label>Nav data</label>
837 <halign>left</halign>
838 <property>/sim/gui/dialogs/map-canvas/draw-DME</property>
839 <live>true</live>
840 <binding>
841 <command>property-toggle</command>
842 </binding>
843 <binding>
844 <command>nasal</command>
845 <script>
846 var visible = ! getprop("/sim/gui/dialogs/map-canvas/draw-DME");
847 setprop("/sim/gui/dialogs/map-canvas/draw-DME", visible);
848 setprop("/sim/gui/dialogs/map-canvas/draw-VOR", visible);
849 setprop("/sim/gui/dialogs/map-canvas/draw-NDB", visible);
850 setprop("/sim/gui/dialogs/map-canvas/draw-FIX", visible);
851 </script>
852 <binding>
853 <command>dialog-apply</command>
854 </binding>
855 </binding>
856 </checkbox>
857
858 <checkbox>
859 <label>Parking</label>
860 <halign>left</halign>
861 <property>/sim/gui/dialogs/map-canvas/draw-PARKING</property>
862 <live>true</live>
863 <binding>
864 <command>dialog-apply</command>
865 </binding>
866 <binding>
867 <command>property-toggle</command>
868 </binding>
869 </checkbox>
870
871 <empty><stretch>1</stretch></empty>
872
873 <button>
874 <name>zoomout</name>
875 <legend>+</legend>
876 <pref-width>52</pref-width>
877 <pref-height>22</pref-height>
878
879 <binding>
880 <command>nasal</command>
881 <script>
882 var range = AirportChart.getScreenRange();
883 AirportChart.setScreenRange(math.min(range*range_step, 10000));
884 setprop("/sim/gui/dialogs/airports/zoom-range", AirportChart.getScreenRange());
885 </script>
886 </binding>
887 </button>
888
889 <text>
890 <name>zoomdisplay</name>
891 <label>XXXXXXXXXXXX</label>
892 <format>Zoom: %d%%</format>
893 <property>/sim/gui/dialogs/airports/zoom-range</property>
894 <live>true</live>
895 </text>
896
897 <button>
898 <name>zoomin</name>
899 <legend>-</legend>
900 <pref-width>52</pref-width>
901 <pref-height>22</pref-height>
902
903 <binding>
904 <command>nasal</command>
905 <script>
906 var range = AirportChart.getScreenRange();
907 AirportChart.setScreenRange(math.max(range/range_step, 100));
908 setprop("/sim/gui/dialogs/airports/zoom-range", AirportChart.getScreenRange());
909 </script>
910 </binding>
911 </button>
912 </group>
913
914 </group>
915 </group>
916
917 <!-- airport info -->
918 <group>
919 <layout>table</layout>
920 <valign>top</valign>
921 <row>0</row>
922 <col>0</col>
923 <visible>
924 <equals>
925 <property>/sim/gui/dialogs/airports/display-mode</property>
926 <value>0</value>
927 </equals>
928 </visible>
929
930 <!-- airport info table -->
931 <group>
932 <row>0</row>
933 <col>0</col>
934
935 <layout>table</layout>
936 <valign>top</valign>
937
938 <group>
939 <layout>hbox</layout>
940 <halign>fill</halign>
941 <row>0</row>
942 <col>0</col>
943 <colspan>2</colspan>
944
945 <text>
946 <label>Airfield Information</label>
947 </text>
948
949 <hrule><stretch>1</stretch></hrule>
950 </group>
951
952 <text>
953 <row>1</row>
954 <col>0</col>
955 <halign>right</halign>
956 <label>Name:</label>
957 </text>
958 <text>
959 <row>1</row>
960 <col>1</col>
961 <halign>left</halign>
962 <live>true</live>
963 <label>Athens Intl Airport Elefterios Venizel</label>
964 <!-- The above airport is the longest name in Airports/apt.dat.gz as of 3 November 2012 -->
965 <property>/sim/gui/dialogs/airports/selected-airport/name</property>
966 </text>
967
968 <text>
969 <row>2</row>
970 <col>0</col>
971 <halign>right</halign>
972 <label>ICAO:</label>
973 </text>
974 <text>
975 <row>2</row>
976 <col>1</col>
977 <halign>left</halign>
978 <live>true</live>
979 <label>AAAA</label>
980 <property>/sim/gui/dialogs/airports/selected-airport/id</property>
981 </text>
982
983 <text>
984 <row>3</row>
985 <col>0</col>
986 <halign>right</halign>
987 <label>Lat / Lon:</label>
988 </text>
989 <text>
990 <row>3</row>
991 <col>1</col>
992 <halign>left</halign>
993 <live>true</live>
994 <label>XXXXXXXXXXXX</label>
995 <property>/sim/gui/dialogs/airports/selected-airport/location</property>
996 </text>
997
998 <text>
999 <row>4</row>
1000 <col>0</col>
1001 <halign>right</halign>
1002 <label>Elevation:</label>
1003 </text>
1004 <text>
1005 <row>4</row>
1006 <col>1</col>
1007 <halign>left</halign>
1008 <live>true</live>
1009 <format>%.0f ft</format>
1010 <property>/sim/gui/dialogs/airports/selected-airport/elevation-ft</property>
1011 </text>
1012
1013 <text>
1014 <row>5</row>
1015 <col>0</col>
1016 <halign>right</halign>
1017 <label>Longest runway:</label>
1018 </text>
1019 <text>
1020 <row>5</row>
1021 <col>1</col>
1022 <halign>left</halign>
1023 <live>true</live>
1024 <format>%.0f ft</format>
1025 <property>/sim/gui/dialogs/airports/selected-airport/longest-runway</property>
1026 </text>
1027
1028 <text>
1029 <row>6</row>
1030 <col>0</col>
1031 <halign>right</halign>
1032 <label>Distance:</label>
1033 </text>
1034 <text>
1035 <row>6</row>
1036 <col>1</col>
1037 <halign>left</halign>
1038 <live>true</live>
1039 <format>%.1f nm</format>
1040 <property>/sim/gui/dialogs/airports/selected-airport/distance-nm</property>
1041 </text>
1042
1043 <text>
1044 <row>7</row>
1045 <col>0</col>
1046 <halign>right</halign>
1047 <label>Course:</label>
1048 </text>
1049 <text>
1050 <row>7</row>
1051 <col>1</col>
1052 <halign>left</halign>
1053 <live>true</live>
1054 <format>%.0f deg</format>
1055 <property>/sim/gui/dialogs/airports/selected-airport/course-deg</property>
1056 </text>
1057 </group>
1058
1059 <!-- comms frequencies table -->
1060 <group>
1061 <row>0</row>
1062 <col>1</col>
1063 <layout>table</layout>
1064 <halign>fill</halign>
1065 <default-padding>2</default-padding>
1066
1067 <group>
1068 <layout>hbox</layout>
1069 <halign>fill</halign>
1070 <row>0</row>
1071 <col>0</col>
1072 <colspan>2</colspan>
1073
1074 <text>
1075 <label>Communications Frequencies</label>
1076 </text>
1077
1078 <hrule><stretch>1</stretch></hrule>
1079 </group>
1080
1081 <text>
1082 <row>1</row>
1083 <col>0</col>
1084 <halign>left</halign>
1085 <live>true</live>
1086 <label>ACTIVATE LIGHTS</label>
1087 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[0]/label</property>
1088 </text>
1089
1090 <text>
1091 <row>1</row>
1092 <col>1</col>
1093 <halign>left</halign>
1094 <live>true</live>
1095 <label>123.456 123.456</label>
1096 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[0]/value</property>
1097 </text>
1098
1099 <text>
1100 <row>2</row>
1101 <col>0</col>
1102 <halign>left</halign>
1103 <live>true</live>
1104 <label>ACTIVATE LIGHTS</label>
1105 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[1]/label</property>
1106 </text>
1107
1108 <text>
1109 <row>2</row>
1110 <col>1</col>
1111 <halign>left</halign>
1112 <live>true</live>
1113 <label>123.456 123.456</label>
1114 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[1]/value</property>
1115 </text>
1116
1117 <text>
1118 <row>3</row>
1119 <col>0</col>
1120 <halign>left</halign>
1121 <live>true</live>
1122 <label>ACTIVATE LIGHTS</label>
1123 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[2]/label</property>
1124 </text>
1125
1126 <text>
1127 <row>3</row>
1128 <col>1</col>
1129 <halign>left</halign>
1130 <live>true</live>
1131 <label>123.456 123.456</label>
1132 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[2]/value</property>
1133 </text>
1134
1135 <text>
1136 <row>4</row>
1137 <col>0</col>
1138 <halign>left</halign>
1139 <live>true</live>
1140 <label>ACTIVATE LIGHTS</label>
1141 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[3]/label</property>
1142 </text>
1143
1144 <text>
1145 <row>4</row>
1146 <col>1</col>
1147 <halign>left</halign>
1148 <live>true</live>
1149 <label>123.456 123.456</label>
1150 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[3]/value</property>
1151 </text>
1152
1153 <text>
1154 <row>5</row>
1155 <col>0</col>
1156 <halign>left</halign>
1157 <live>true</live>
1158 <label>ACTIVATE LIGHTS</label>
1159 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[4]/label</property>
1160 </text>
1161
1162 <text>
1163 <row>5</row>
1164 <col>1</col>
1165 <halign>left</halign>
1166 <live>true</live>
1167 <label>123.456 123.456</label>
1168 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[4]/value</property>
1169 </text>
1170
1171 <text>
1172 <row>6</row>
1173 <col>0</col>
1174 <halign>left</halign>
1175 <live>true</live>
1176 <label>ACTIVATE LIGHTS</label>
1177 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[5]/label</property>
1178 </text>
1179
1180 <text>
1181 <row>6</row>
1182 <col>1</col>
1183 <halign>left</halign>
1184 <live>true</live>
1185 <label>123.456 123.456</label>
1186 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[5]/value</property>
1187 </text>
1188
1189 <text>
1190 <row>7</row>
1191 <col>0</col>
1192 <halign>left</halign>
1193 <live>true</live>
1194 <label>ACTIVATE LIGHTS</label>
1195 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[6]/label</property>
1196 </text>
1197
1198 <text>
1199 <row>7</row>
1200 <col>1</col>
1201 <halign>left</halign>
1202 <live>true</live>
1203 <label>123.456 123.456</label>
1204 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[6]/value</property>
1205 </text>
1206
1207 <text>
1208 <row>8</row>
1209 <col>0</col>
1210 <halign>left</halign>
1211 <live>true</live>
1212 <label>ACTIVATE LIGHTS</label>
1213 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[7]/label</property>
1214 </text>
1215
1216 <text>
1217 <row>8</row>
1218 <col>1</col>
1219 <halign>left</halign>
1220 <live>true</live>
1221 <label>123.456 123.456</label>
1222 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[7]/value</property>
1223 </text>
1224
1225 <text>
1226 <row>9</row>
1227 <col>0</col>
1228 <halign>left</halign>
1229 <live>true</live>
1230 <label>ACTIVATE LIGHTS</label>
1231 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[8]/label</property>
1232 </text>
1233
1234 <text>
1235 <row>9</row>
1236 <col>1</col>
1237 <halign>left</halign>
1238 <live>true</live>
1239 <label>123.456 123.456</label>
1240 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[8]/value</property>
1241 </text>
1242
1243 <text>
1244 <row>10</row>
1245 <col>0</col>
1246 <halign>left</halign>
1247 <live>true</live>
1248 <label>ACTIVATE LIGHTS</label>
1249 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[9]/label</property>
1250 </text>
1251
1252 <text>
1253 <row>10</row>
1254 <col>1</col>
1255 <halign>left</halign>
1256 <live>true</live>
1257 <label>123.456 123.456</label>
1258 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[9]/value</property>
1259 </text>
1260
1261 <text>
1262 <row>11</row>
1263 <col>0</col>
1264 <halign>left</halign>
1265 <live>true</live>
1266 <label>ACTIVATE LIGHTS</label>
1267 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[10]/label</property>
1268 </text>
1269
1270 <text>
1271 <row>11</row>
1272 <col>1</col>
1273 <halign>left</halign>
1274 <live>true</live>
1275 <label>123.456 123.456</label>
1276 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[10]/value</property>
1277 </text>
1278
1279 <text>
1280 <row>12</row>
1281 <col>0</col>
1282 <halign>left</halign>
1283 <live>true</live>
1284 <label>ACTIVATE LIGHTS</label>
1285 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[11]/label</property>
1286 </text>
1287
1288 <text>
1289 <row>12</row>
1290 <col>1</col>
1291 <halign>left</halign>
1292 <live>true</live>
1293 <label>123.456 123.456</label>
1294 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[11]/value</property>
1295 </text>
1296
1297 <text>
1298 <row>13</row>
1299 <col>0</col>
1300 <halign>left</halign>
1301 <live>true</live>
1302 <label>ACTIVATE LIGHTS</label>
1303 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[12]/label</property>
1304 </text>
1305
1306 <text>
1307 <row>13</row>
1308 <col>1</col>
1309 <halign>left</halign>
1310 <live>true</live>
1311 <label>123.456 123.456</label>
1312 <property>/sim/gui/dialogs/airports/selected-airport/comms/freq[12]/value</property>
1313 </text>
1314
1315 </group> <!-- of comm frequencies table -->
1316
1317
1318 <!-- runways table -->
1319 <group>
1320 <row>1</row>
1321 <col>0</col>
1322 <colspan>2</colspan>
1323 <layout>table</layout>
1324 <halign>fill</halign>
1325 <default-padding>2</default-padding>
1326
1327 <group>
1328 <layout>hbox</layout>
1329 <halign>fill</halign>
1330 <row>0</row>
1331 <col>0</col>
1332
1333 <text>
1334 <label>Runways</label>
1335 </text>
1336
1337 <hrule><stretch>1</stretch></hrule>
1338 </group>
1339
1340 <textbox>
1341 <row>1</row>
1342 <col>0</col>
1343 <name>runways-info</name>
1344 <object-name>runways-info</object-name>
1345 <halign>fill</halign>
1346 <stretch>true</stretch>
1347 <pref-width>260</pref-width>
1348 <pref-height>250</pref-height>
1349 <slider>15</slider>
1350 <editable>false</editable>
1351 <wrap>false</wrap>
1352 <property>/sim/gui/dialogs/airports/selected-airport/runways-info</property>
1353 </textbox>
1354 </group> <!-- of runways table -->
1355
1356 </group> <!-- of airport info outer table -->
1357 </group>
1358 </group>
1359 <!-- End of RH Pane -->
1360 </group>
1361
1362 <hrule/>
1363
1364 <group>
1365 <layout>hbox</layout>
1366 <default-padding>5</default-padding>
1367
1368 <empty><stretch>true</stretch></empty>
1369
1370 <button>
1371 <legend>Go To Airport</legend>
1372 <equal>true</equal>
1373 <binding>
1374 <command>dialog-apply</command>
1375 <object-name>airport-list</object-name>
1376 </binding>
1377 <binding>
1378 <command>nasal</command>
1379 <script>apply()</script>
1380 </binding>
1381 <binding>
1382 <command>reposition</command>
1383 </binding>
1384 <binding>
1385 <command>dialog-close</command>
1386 </binding>
1387 </button>
1388
1389 <empty><stretch>true</stretch></empty>
1390
1391 <button>
1392 <legend>Close</legend>
1393 <equal>true</equal>
1394 <key>Esc</key>
1395 <binding>
1396 <command>dialog-apply</command>
1397 <object-name>input</object-name>
1398 </binding>
1399 <binding>
1400 <command>dialog-close</command>
1401 </binding>
1402 </button>
1403
1404 <empty><stretch>true</stretch></empty>
1405 </group>
1406 </PropertyList>