always display layer's panel, even when zoomed in

This commit is contained in:
Dustin Carlino 2020-04-04 14:54:11 -07:00
parent 51d91640e4
commit c477897b1b
5 changed files with 61 additions and 91 deletions

View File

@ -215,16 +215,6 @@ impl ColorScheme {
idx,
)
}
pub fn osm_rank_to_color(&self, rank: usize) -> Color {
if rank >= 16 {
self.unzoomed_highway
} else if rank >= 6 {
self.unzoomed_arterial
} else {
self.unzoomed_residential
}
}
}
fn modulo_color(colors: Vec<Color>, idx: usize) -> Color {

View File

@ -189,9 +189,7 @@ impl Minimap {
g.redraw(&app.primary.draw_map.draw_all_unzoomed_intersections);
g.redraw(&app.primary.draw_map.draw_all_buildings);
// Not the building paths
if let Some(ref c) = app.overlay.maybe_colorer() {
g.redraw(&c.unzoomed);
}
app.overlay.draw_minimap(g);
let mut cache = app.primary.draw_map.agents.borrow_mut();
cache.draw_unzoomed_agents(
@ -360,24 +358,6 @@ fn make_tool_panel(ctx: &mut EventCtx, app: &App) -> Widget {
}
fn make_horiz_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {
let mut col = Vec::new();
// TODO Really rethink this
if ctx.canvas.cam_zoom >= MIN_ZOOM_FOR_DETAIL {
if let Some(name) = app.overlay.zoomed_name() {
// TODO Should the full legend have this icon too?
col.push(Widget::row(vec![
Widget::draw_svg_transform(
ctx,
"../data/system/assets/tools/layers.svg",
RewriteColor::ChangeAll(app.cs.hovering),
)
.margin(5),
Line(name).small().draw(ctx),
]));
}
}
let mut row = Vec::new();
for (label, color, enabled) in &app.agent_cs.rows {
row.push(colored_checkbox(ctx, app, label, *color, *enabled).margin_right(8));
@ -385,9 +365,7 @@ fn make_horiz_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {
}
let last = row.pop().unwrap();
row.push(last.margin_right(0));
col.push(Widget::row(row));
Widget::col(col)
Widget::row(row)
}
fn make_vert_viz_panel(ctx: &mut EventCtx, app: &App) -> Widget {

View File

@ -96,16 +96,16 @@ impl Overlays {
};
match app.overlay {
Overlays::ParkingAvailability(_, ref mut heatmap)
| Overlays::BikeNetwork(ref mut heatmap)
| Overlays::BusNetwork(ref mut heatmap)
| Overlays::Elevation(ref mut heatmap, _)
| Overlays::WorstDelay(_, ref mut heatmap)
| Overlays::TrafficJams(_, ref mut heatmap)
| Overlays::CumulativeThroughput(_, ref mut heatmap)
| Overlays::Edits(ref mut heatmap) => {
heatmap.legend.align_above(ctx, minimap);
if heatmap.event(ctx) {
Overlays::ParkingAvailability(_, ref mut c)
| Overlays::BikeNetwork(ref mut c)
| Overlays::BusNetwork(ref mut c)
| Overlays::Elevation(ref mut c, _)
| Overlays::WorstDelay(_, ref mut c)
| Overlays::TrafficJams(_, ref mut c)
| Overlays::CumulativeThroughput(_, ref mut c)
| Overlays::Edits(ref mut c) => {
c.legend.align_above(ctx, minimap);
if c.event(ctx) {
app.overlay = Overlays::Inactive;
}
}
@ -177,31 +177,29 @@ impl Overlays {
None
}
// Draw both controls and, if zoomed, the overlay contents
pub fn draw(&self, g: &mut GfxCtx) {
match self {
Overlays::Inactive => {}
Overlays::ParkingAvailability(_, ref heatmap)
| Overlays::BikeNetwork(ref heatmap)
| Overlays::BusNetwork(ref heatmap)
| Overlays::WorstDelay(_, ref heatmap)
| Overlays::TrafficJams(_, ref heatmap)
| Overlays::CumulativeThroughput(_, ref heatmap)
| Overlays::Edits(ref heatmap) => {
if g.canvas.cam_zoom < MIN_ZOOM_FOR_DETAIL {
heatmap.draw(g);
}
Overlays::ParkingAvailability(_, ref c)
| Overlays::BikeNetwork(ref c)
| Overlays::BusNetwork(ref c)
| Overlays::WorstDelay(_, ref c)
| Overlays::TrafficJams(_, ref c)
| Overlays::CumulativeThroughput(_, ref c)
| Overlays::Edits(ref c) => {
c.draw(g);
}
Overlays::Elevation(ref heatmap, ref draw) => {
// TODO Maybe this is still useful when zoomed in
Overlays::Elevation(ref c, ref draw) => {
c.draw(g);
if g.canvas.cam_zoom < MIN_ZOOM_FOR_DETAIL {
heatmap.draw(g);
g.redraw(draw);
}
}
Overlays::PopulationMap(_, _, ref draw, ref composite) => {
composite.draw(g);
if g.canvas.cam_zoom < MIN_ZOOM_FOR_DETAIL {
g.redraw(draw);
composite.draw(g);
}
}
// All of these shouldn't care about zoom
@ -218,18 +216,31 @@ impl Overlays {
}
}
pub fn maybe_colorer(&self) -> Option<&Colorer> {
// Just draw contents and do it always
pub fn draw_minimap(&self, g: &mut GfxCtx) {
match self {
Overlays::ParkingAvailability(_, ref heatmap)
| Overlays::BikeNetwork(ref heatmap)
| Overlays::BusNetwork(ref heatmap)
| Overlays::Elevation(ref heatmap, _)
| Overlays::WorstDelay(_, ref heatmap)
| Overlays::TrafficJams(_, ref heatmap)
| Overlays::CumulativeThroughput(_, ref heatmap)
| Overlays::Edits(ref heatmap) => Some(heatmap),
Overlays::BusRoute(_, _, ref s) => Some(&s.colorer),
_ => None,
Overlays::Inactive => {}
Overlays::ParkingAvailability(_, ref c)
| Overlays::BikeNetwork(ref c)
| Overlays::BusNetwork(ref c)
| Overlays::WorstDelay(_, ref c)
| Overlays::TrafficJams(_, ref c)
| Overlays::CumulativeThroughput(_, ref c)
| Overlays::Edits(ref c) => {
g.redraw(&c.unzoomed);
}
Overlays::Elevation(ref c, ref draw) => {
g.redraw(&c.unzoomed);
g.redraw(draw);
}
Overlays::PopulationMap(_, _, ref draw, _) => {
g.redraw(draw);
}
Overlays::TripsHistogram(_, _) => {}
Overlays::IntersectionDemand(_, _, _, _) => {}
Overlays::BusRoute(_, _, ref s) => {
s.draw(g);
}
}
}
@ -367,25 +378,6 @@ impl Overlays {
);
Some(Transition::Push(ManagedGUIState::over_map(c)))
}
// Only for those hidden when zoomed in
pub fn zoomed_name(&self) -> Option<&'static str> {
match self {
Overlays::Inactive => None,
Overlays::ParkingAvailability(_, _) => Some("parking availability"),
Overlays::WorstDelay(_, _) => Some("delay"),
Overlays::TrafficJams(_, _) => Some("traffic jams"),
Overlays::CumulativeThroughput(_, _) => Some("throughput"),
Overlays::BikeNetwork(_) => Some("bike network"),
Overlays::BusNetwork(_) => Some("bus network"),
Overlays::Elevation(_, _) => Some("elevation"),
Overlays::Edits(_) => Some("map edits"),
Overlays::PopulationMap(_, _, _, _) => Some("population map"),
Overlays::TripsHistogram(_, _) => None,
Overlays::IntersectionDemand(_, _, _, _) => None,
Overlays::BusRoute(_, _, _) => None,
}
}
}
impl Overlays {

View File

@ -65,7 +65,7 @@ impl DrawMap {
let mut all_roads = GeomBatch::new();
for r in road_refs {
all_roads.push(
cs.osm_rank_to_color(r.get_rank()),
osm_rank_to_color(cs, r.get_rank()),
r.get_thick_polygon(map).get(timer),
);
/*if false {
@ -113,7 +113,7 @@ impl DrawMap {
// TODO Would be neat to show closed intersections here, but then edits need to
// regenerate this
if i.is_stop_sign() {
all_intersections.push(cs.osm_rank_to_color(i.get_rank(map)), i.polygon.clone());
all_intersections.push(osm_rank_to_color(cs, i.get_rank(map)), i.polygon.clone());
/*if false {
all_intersections.push(
color,
@ -496,3 +496,13 @@ impl AgentColorScheme {
panic!("Unknown AgentColorScheme category {}", category);
}
}
fn osm_rank_to_color(cs: &ColorScheme, rank: usize) -> Color {
if rank >= 16 {
cs.unzoomed_highway
} else if rank >= 6 {
cs.unzoomed_arterial
} else {
cs.unzoomed_residential
}
}

View File

@ -1129,7 +1129,7 @@ impl TutorialState {
)
.msg(
vec![
"Apply different heatmap layers to the map, to find data such as:",
"Apply different layers to the map, to find data such as:",
"- roads with high traffic",
"- bus stops",
"- current parking",