1
0
Fork 0
fgdata/Nasal/canvas/map/vor.draw
Gijs de Rooy a9576e8c8d Canvas Navigational Display:
- get rid of global variables and use instance variables
- identified all important drawing routines and move them into *.draw files
- changed to dynamic loading of *.draw *.model and *.layer files
- implemented poor-man's controller hash to move use-case specific conditionals out of the draw files, and back into the instantiation, i.e. Gijs' EFIS class
- started identifying stuff that is not specific to drawing, but to what is to be drawn, i.e. Model stuff - such as positioned queries, moved those out into *.model files
- some more work on supporting more than a single ND MFD instance per aircraft
- renamed a handful of SVG identifiers to avoid naming conflicts and to simplify usage of SVG IDs as member fields
- moved all of the setlistener setup out of the fdm-initialized stub right into the ctor of the Efis class (actually that's controller stuff...)
- initial MapStructure framework
- aircraft-agnostic NavDisplay class
- preparations for deprecating map.nas
- additions to canvas.map
- preparations for making NDStyles configurable via XML
2013-12-01 13:36:23 +01:00

59 lines
1.7 KiB
Text

var draw_vor = func (group, vor, controller=nil, lod = 0) {
if (0) {
if (controller == nil)
print("Ooops, VOR controller undefined!");
else
debug.dump( controller );
}
var lat = vor.lat;
var lon = vor.lon;
var name = vor.id;
var freq = vor.frequency;
var range = vor.range_nm;
# FIXME: Hack - implement a real controller for this!
var rangeNm = (controller!=nil) ? controller['query_range']() : 50;
var vor_grp = group.createChild("group",name);
var icon_vor = vor_grp.createChild("path", "vor-icon-" ~ name)
.moveTo(-15,0)
.lineTo(-7.5,12.5)
.lineTo(7.5,12.5)
.lineTo(15,0)
.lineTo(7.5,-12.5)
.lineTo(-7.5,-12.5)
.close()
.setStrokeLineWidth(3)
.setColor(0,0.6,0.85);
# next check if the current VOR is tuned, if so show it
# for this to work, we need a controller hash with an "is_tuned" member that points to a callback
# (set up by the layer managing this view)
# for an example, see the NavDisplay.newMFD() in navdisplay.mfd
if (controller != nil and controller['is_tuned'](freq/100)) {
# print("VOR is tuned:", name);
var radius = (range/rangeNm)*345;
var range_vor = vor_grp.createChild("path", "range-vor-" ~ name)
.moveTo(-radius,0)
.arcSmallCW(radius,radius,0,2*radius,0)
.arcSmallCW(radius,radius,0,-2*radius,0)
.setStrokeLineWidth(3)
.setStrokeDashArray([5, 15, 5, 15, 5])
.setColor(0,1,0);
var course = controller['get_tuned_course'](freq/100);
vor_grp.createChild("path", "radial-vor-" ~ name)
.moveTo(0,-radius)
.vert(2*radius)
.setStrokeLineWidth(3)
.setStrokeDashArray([15, 5, 15, 5, 15])
.setColor(0,1,0)
.setRotation(course*D2R);
icon_vor.setColor(0,1,0);
}
vor_grp.setGeoPosition(lat, lon)
.set("z-index",3);
}