a9576e8c8d
- 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
68 lines
No EOL
1.5 KiB
Text
68 lines
No EOL
1.5 KiB
Text
##
|
|
# Draw a route with tracks and waypoints (from Gijs' 744 ND.nas code)
|
|
#
|
|
|
|
|
|
## FIXME: encapsulate properly
|
|
var wp = [];
|
|
var text_wp = [];
|
|
|
|
# Change color of active waypoints
|
|
var updatewp = func(activeWp)
|
|
{
|
|
forindex(var i; wp) {
|
|
if(i == activeWp) {
|
|
wp[i].setColor(1,0,1);
|
|
#text_wp[i].setColor(1,0,1);
|
|
} else {
|
|
wp[i].setColor(1,1,1);
|
|
#text_wp[i].setColor(1,1,1);
|
|
}
|
|
}
|
|
};
|
|
|
|
|
|
var draw_route = func (group, theroute, controller=nil, lod=0)
|
|
{
|
|
#print("draw_route");
|
|
var route_group = group;
|
|
|
|
var route = route_group.createChild("path","route")
|
|
.setStrokeLineWidth(5)
|
|
.setColor(1,0,1);
|
|
|
|
var cmds = [];
|
|
var coords = [];
|
|
|
|
var fp = flightplan();
|
|
var fpSize = fp.getPlanSize();
|
|
|
|
wp = [];
|
|
text_wp = [];
|
|
setsize(wp,fpSize);
|
|
setsize(text_wp,fpSize);
|
|
|
|
# Retrieve route coordinates
|
|
for (var i=0; i<(fpSize); i += 1)
|
|
{
|
|
if (i == 0) {
|
|
var leg = fp.getWP(1);
|
|
append(coords,"N"~leg.path()[0].lat);
|
|
append(coords,"E"~leg.path()[0].lon);
|
|
append(cmds,2);
|
|
canvas.drawwp(group, leg.path()[0].lat,leg.path()[0].lon,fp.getWP(0).wp_name,i, wp);
|
|
i+=1;
|
|
}
|
|
var leg = fp.getWP(i);
|
|
append(coords,"N"~leg.path()[1].lat);
|
|
append(coords,"E"~leg.path()[1].lon);
|
|
append(cmds,4);
|
|
canvas.drawwp(group, leg.path()[1].lat,leg.path()[1].lon,leg.wp_name,i, wp);
|
|
}
|
|
|
|
# Update route coordinates
|
|
debug.dump(cmds);
|
|
debug.dump(coords);
|
|
route.setDataGeo(cmds, coords);
|
|
updatewp(0);
|
|
} |