1
0
Fork 0

Navdisplay:

- set z-index on layers
- correct PLAN range
- hide/show navaids on mode change
- display runway identifier
This commit is contained in:
Gijs de Rooy 2014-07-08 12:28:26 +02:00
parent c2455bcafe
commit 1ba6af1284
13 changed files with 52 additions and 52 deletions

View file

@ -118,8 +118,7 @@ var init = func {
.horiz(-14.5)
.vert(-14.5)
.close()
.setStrokeLineWidth( me.layer.style.line_width )
.set("z-index",-2);
.setStrokeLineWidth( me.layer.style.line_width );
# finally scale the symbol as requested, this is done last so that people can override this when creating the layer
me.apply_scale();

View file

@ -28,8 +28,7 @@ var drawFIX = func(group) {
.lineTo(15,15)
.close()
.setStrokeLineWidth(line_width)
.setColor(color)
.set("z-index",-3);
.setColor(color);
}
var cache = StyleableCacheable.new(
@ -45,6 +44,6 @@ var init = func {
# non-cached stuff:
if (me.style.show_labels)
me.text_fix = me.newText(me.model.id).setScale(me.style.scale_factor).setTranslation(17,35).set("z-index",-3);
me.text_fix = me.newText(me.model.id).setScale(me.style.scale_factor).setTranslation(17,35).setColor(0,0.6,0.85);
}
var draw = func;

View file

@ -14,6 +14,7 @@ SymbolLayer.add(name, {
df_options: { # default configuration options
active_node: "/autopilot/route-manager/active",
current_wp_node: "/autopilot/route-manager/current-wp",
wp_num: "/autopilot/route-manager/route/num",
}
});
var new = func(layer) {
@ -24,7 +25,7 @@ var new = func(layer) {
listeners: [],
};
layer.searcher._equals = func(l,r) 0; # TODO: create model objects instead?
append(m.listeners, setlistener(layer.options.active_node, func m.layer.update() ));
append(m.listeners, setlistener(layer.options.active_node, func m.layer.update() ), setlistener(layer.options.wp_num, func m.layer.update() ));
m.addVisibilityListener();
return m;

View file

@ -46,7 +46,7 @@ var draw = func {
.setText(sprintf("%+02.0f",altDiff/100))
.setFont("LiberationFonts/LiberationSans-Regular.ttf")
.setColor(1,1,1)
.setFontSize(28)
.setFontSize(20)
.setAlignment("center-center");
me.icon_tcas = me.element.createChild("path")
.setStrokeLineWidth(3);

View file

@ -11,6 +11,7 @@ SymbolLayer.add(name, {
df_options: { # default configuration options
active_node: "/autopilot/route-manager/active",
current_wp_node: "/autopilot/route-manager/current-wp",
wp_num: "/autopilot/route-manager/route/num",
}
});
var new = func(layer) {
@ -22,7 +23,7 @@ var new = func(layer) {
listeners: [],
};
layer.searcher._equals = func(l,r) l.equals(r);
append(m.listeners, setlistener(layer.options.active_node, func m.layer.update() ));
append(m.listeners, setlistener(layer.options.active_node, func m.layer.update() ), setlistener(layer.options.wp_num, func m.layer.update() ));
m.addVisibilityListener();
return m;
@ -37,8 +38,8 @@ var WPT_model = {
new: func(fp, idx, offset=0) {
var m = { parents:[WPT_model], idx:(idx+offset) };
var wp = fp.getWP(idx);
m.name = wp.wp_name;
var alt = wp.alt_cstr;
if (alt != 0)
m.name ~= "\n"~alt;

View file

@ -31,13 +31,11 @@ var init = func {
.lineTo(5,-5)
.setColor(1,1,1)
.close()
.setScale(me.style.scale_factor)
.set("z-index",2);
.setScale(me.style.scale_factor);
me.text = me.newText(me.model.name, me.style.font_color)
.setTranslation(25,35)
.setScale(me.style.scale_factor)
.set("z-index",2);
.setScale(me.style.scale_factor);
me.draw();
};

View file

@ -15,8 +15,7 @@ var draw = func {
.setFile("Nasal/canvas/map/Images/storm.png")
.setSize(128*me.model.radiusNm,128*me.model.radiusNm)
.setTranslation(-64*me.model.radiusNm,-64*me.model.radiusNm)
.setCenter(0,0)
.set("z-index",-4);
.setCenter(0,0);
# .setScale(0.3);
# TODO: overlapping storms should probably set their z-index according to altitudes

View file

@ -26,8 +26,7 @@ var draw_apt = func (group, apt, controller=nil, lod=0) {
.setFont("LiberationFonts/LiberationSans-Regular.ttf")
.setColor(0,0.6,0.85)
.setFontSize(28);
apt_grp.setGeoPosition(lat, lon)
.set("z-index",-1); # FIXME: this needs to be configurable!!
apt_grp.setGeoPosition(lat, lon); # FIXME: this needs to be configurable!!
#}
# draw routines should always return their canvas group to the caller for further processing

View file

@ -28,7 +28,6 @@ var draw_fix = func (group, fix, controller=nil, lod=0) {
.setTranslation(5,25);
# the fix position
fix_grp.setGeoPosition(lat, lon)
.set("z-index",-3);
fix_grp.setGeoPosition(lat, lon);
}

View file

@ -448,22 +448,21 @@ var NavDisplay = {
alt: nil, hdg: nil,
range: nil,
};
pos.range = me.rangeNm(); # avoid this here, use a listener instead
# reposition the map, change heading & range:
if(me.in_mode('toggle_display_mode', ['PLAN'])) {
pos.hdg = 0;
if (getprop(me.efis_path ~ "/inputs/plan-wpt-index") >= 0) {
pos.lat = getprop("/autopilot/route-manager/route/wp["~getprop(me.efis_path ~ "/inputs/plan-wpt-index")~"]/latitude-deg");
pos.lon = getprop("/autopilot/route-manager/route/wp["~getprop(me.efis_path ~ "/inputs/plan-wpt-index")~"]/longitude-deg");
} else {
pos.lat = me.map.getLat();
pos.lon = me.map.getLon();
}
if(me.in_mode('toggle_display_mode', ['PLAN']) and getprop(me.efis_path ~ "/inputs/plan-wpt-index") >= 0) {
pos.lat = getprop("/autopilot/route-manager/route/wp["~getprop(me.efis_path ~ "/inputs/plan-wpt-index")~"]/latitude-deg");
pos.lon = getprop("/autopilot/route-manager/route/wp["~getprop(me.efis_path ~ "/inputs/plan-wpt-index")~"]/longitude-deg");
} else {
pos.hdg = userHdgTrkTru;
pos.lat = userLat;
pos.lon = userLon;
}
if(me.in_mode('toggle_display_mode', ['PLAN'])) {
pos.hdg = 0;
pos.range = me.rangeNm()*2
} else {
pos.range = me.rangeNm(); # avoid this here, use a listener instead
pos.hdg = userHdgTrkTru;
}
call(me.map.setPos, [pos.lat, pos.lon], me.map, pos);
},
# each model should keep track of when it last got updated, using current lat/lon

View file

@ -42,20 +42,20 @@ var NDStyles = {
# TODO: phase out isMapStructure flag once map.nas & *.draw files are killed
layers: [
# TODO: take z-indices from *.draw files -- now handled by MapStructure in the addLayer method.
{ name:'FIX', isMapStructure:1, update_on:['toggle_range','toggle_waypoints'],
{ name:'FIX', isMapStructure:1, update_on:['toggle_display_mode','toggle_range','toggle_waypoints'],
# FIXME: this is a really ugly place for controller code
predicate: func(nd, layer) {
# print("Running fix layer predicate");
# toggle visibility here
var visible=nd.get_switch('toggle_waypoints') and nd.in_mode('toggle_display_mode', ['MAP']) and (nd.rangeNm() <= 40);
layer.group.setVisible( nd.get_switch('toggle_waypoints') );
layer.group.setVisible( visible );
if (visible) {
#print("Updating MapStructure ND layer: FIX");
# (Hopefully) smart update
layer.update();
}
}, # end of layer update predicate
'z-index': 3,
'z-index': -3,
}, # end of FIX layer
# Should redraw every 10 seconds TODO: use new MapStructure/WXR here once that works properly (Gijs should check first!)
@ -69,6 +69,7 @@ var NDStyles = {
layer.update();
}
}, # end of layer update predicate
'z-index': -4,
}, # end of storms/WXR layer
{ name:'APS', isMapStructure:1, update_on:['toggle_display_mode'],
@ -91,7 +92,7 @@ var NDStyles = {
layer.update();
}
}, # end of layer update predicate
'z-index': 1,
'z-index': -1,
}, # end of APT layer
# Should distinct between low and high altitude navaids. Hiding above 40 NM for now, to prevent clutter/lag.
@ -106,10 +107,10 @@ var NDStyles = {
layer.update();
}
}, # end of layer update predicate
'z-index': 3,
'z-index': -2,
}, # end of VOR layer
{ name:'DME', isMapStructure:1, update_on:['toggle_range','toggle_stations'],
{ name:'DME', isMapStructure:1, update_on:['toggle_display_mode','toggle_range','toggle_stations'],
# FIXME: this is a really ugly place for controller code
predicate: func(nd, layer) {
var visible = nd.get_switch('toggle_stations') and nd.in_mode('toggle_display_mode', ['MAP']) and (nd.rangeNm() <= 40);
@ -120,7 +121,7 @@ var NDStyles = {
layer.update();
}
}, # end of layer update predicate
'z-index': 3,
'z-index': -2,
}, # end of DME layer
{ name:'TFC', isMapStructure:1, update_on:['toggle_range','toggle_traffic'],
@ -132,7 +133,7 @@ var NDStyles = {
layer.update();
}
}, # end of layer update predicate
'z-index': 1,
'z-index': 4,
}, # end of traffic layer
{ name:'runway-nd', update_on:['toggle_range','toggle_display_mode'],
@ -152,7 +153,7 @@ var NDStyles = {
if (visible)
layer.update();
}, # end of layer update predicate
'z-index': 2, # apparently route.draw doesn't have a z-index?
'z-index': 1,
}, # end of route layer
{ name:'WPT', isMapStructure:1, update_on:['toggle_range','toggle_display_mode'],
predicate: func(nd, layer) {
@ -162,7 +163,7 @@ var NDStyles = {
if (visible)
layer.update();
}, # end of layer update predicate
'z-index': 4,
'z-index': 2,
}, # end of waypoint layer
{ name:'ALT-profile', isMapStructure:1, update_on:['toggle_range','toggle_display_mode'],
predicate: func(nd, layer) {
@ -172,7 +173,7 @@ var NDStyles = {
if (visible)
layer.update();
}, # end of layer update predicate
'z-index': 4,
'z-index': 3,
}, # end of altitude profile layer
## add other layers here, layer names must match the registered names as used in *.layer files for now
@ -546,7 +547,7 @@ var NDStyles = {
predicate: func(nd) (nd.get_switch('toggle_centered') and nd.in_mode('toggle_display_mode', ['APP','MAP','VOR'])),
is_true: func(nd) {
nd.symbols.rangeCtr1.show();
nd.symbols.rangeCtr1.setText(sprintf("%3.1f",nd.rangeNm()/4));
nd.symbols.rangeCtr1.setText(sprintf("%g",nd.rangeNm()/4));
},
is_false: func(nd) nd.symbols.rangeCtr1.hide(),
},
@ -558,7 +559,7 @@ var NDStyles = {
predicate: func(nd) (nd.get_switch('toggle_centered') and nd.in_mode('toggle_display_mode', ['APP','MAP','VOR'])),
is_true: func(nd) {
nd.symbols.rangeCtr2.show();
nd.symbols.rangeCtr2.setText(sprintf("%3.1f",nd.rangeNm()/4));
nd.symbols.rangeCtr2.setText(sprintf("%g",nd.rangeNm()/4));
},
is_false: func(nd) nd.symbols.rangeCtr2.hide(),
},

View file

@ -2,14 +2,14 @@
var draw_rwy_nd = func (group, rwy, controller=nil, lod=nil) {
# print("drawing runways-nd");
canvas._draw_rwy_nd(group,rwy.lat,rwy.lon,rwy.length,rwy.width,rwy.heading);
canvas._draw_rwy_nd(group,rwy.lat,rwy.lon,rwy.length,rwy.width,rwy.heading,rwy.id);
}
##
# TODO: this is not yet a real draw callback ... (wrong signature, not yet integrated)
var _draw_rwy_nd = func (group, lat, lon, length, width, rwyhdg) {
var _draw_rwy_nd = func (group, lat, lon, length, width, rwyhdg, id) {
var apt = airportinfo("EHAM");
var rwy = apt.runway("18R");
@ -51,4 +51,12 @@ var _draw_rwy_nd = func (group, lat, lon, length, width, rwyhdg) {
.setStrokeLineWidth(3)
.setDataGeo([2,4],crds)
.setColor(1,1,1);
group.createChild("text", "rwy-text")
.setDrawMode( canvas.Text.TEXT )
.setText(id)
.setFont("LiberationFonts/LiberationSans-Regular.ttf")
.setFontSize(28)
.setTranslation(35,0)
.setColor(1,1,1)
.setBackdropColor(0,0,0);
}

View file

@ -23,17 +23,14 @@ var drawwp = func (group, lat, lon, alt, name, i, wp) {
#
# text_wp[i] = wp_group.createChild("text", "wp-text-" ~ i)
#
if (alt == 0)
alt = "";
else
alt = "\n"~alt;
if (alt != 0)
name ~= "\n"~alt;
var text_wps = wp_group.createChild("text", "wp-text-" ~ i)
.setDrawMode( canvas.Text.TEXT )
.setText(name~alt)
.setText(name)
.setFont("LiberationFonts/LiberationSans-Regular.ttf")
.setFontSize(28)
.setTranslation(25,35)
.setColor(1,1,1);
wp_group.setGeoPosition(lat, lon)
.set("z-index",4);
wp_group.setGeoPosition(lat, lon);
};