dont draw some overlays when zoomed in

This commit is contained in:
Dustin Carlino 2020-04-04 16:01:44 -07:00
parent c477897b1b
commit d995a494dd
6 changed files with 25 additions and 20 deletions

View File

@ -60,7 +60,7 @@ impl ShowBusRoute {
}
ShowBusRoute {
colorer: colorer.build(ctx, app),
colorer: colorer.build_both(ctx, app),
labels,
bus_locations,
}

View File

@ -99,7 +99,7 @@ impl ColorerBuilder {
self.bus_stops.insert(bs, color);
}
pub fn build(self, ctx: &mut EventCtx, app: &App) -> Colorer {
pub fn build_both(self, ctx: &mut EventCtx, app: &App) -> Colorer {
let mut zoomed = GeomBatch::new();
let mut unzoomed = GeomBatch::new();
let map = &app.primary.map;
@ -155,7 +155,12 @@ impl ColorerBuilder {
}
pub fn build_zoomed(self, ctx: &mut EventCtx, app: &App) -> Drawable {
self.build(ctx, app).zoomed
self.build_both(ctx, app).zoomed
}
pub fn build_unzoomed(self, ctx: &mut EventCtx, app: &App) -> Colorer {
let mut c = self.build_both(ctx, app);
c.zoomed = GeomBatch::new().upload(ctx);
c
}
}

View File

@ -450,7 +450,7 @@ impl Overlays {
colorer.add_l(l, color, &app.primary.map);
}
Overlays::ParkingAvailability(app.primary.sim.time(), colorer.build(ctx, app))
Overlays::ParkingAvailability(app.primary.sim.time(), colorer.build_unzoomed(ctx, app))
}
fn worst_delay(ctx: &mut EventCtx, app: &App) -> Overlays {
@ -489,7 +489,7 @@ impl Overlays {
colorer.add_i(i, color);
}
Overlays::WorstDelay(app.primary.sim.time(), colorer.build(ctx, app))
Overlays::WorstDelay(app.primary.sim.time(), colorer.build_unzoomed(ctx, app))
}
pub fn traffic_jams(ctx: &mut EventCtx, app: &App) -> Overlays {
@ -518,7 +518,7 @@ impl Overlays {
}
}
Overlays::TrafficJams(app.primary.sim.time(), colorer.build(ctx, app))
Overlays::TrafficJams(app.primary.sim.time(), colorer.build_unzoomed(ctx, app))
}
fn cumulative_throughput(ctx: &mut EventCtx, app: &App) -> Overlays {
@ -572,7 +572,7 @@ impl Overlays {
}
}
Overlays::CumulativeThroughput(app.primary.sim.time(), colorer.build(ctx, app))
Overlays::CumulativeThroughput(app.primary.sim.time(), colorer.build_unzoomed(ctx, app))
}
fn bike_network(ctx: &mut EventCtx, app: &App) -> Overlays {
@ -586,7 +586,7 @@ impl Overlays {
colorer.add_l(l.id, color, &app.primary.map);
}
}
Overlays::BikeNetwork(colorer.build(ctx, app))
Overlays::BikeNetwork(colorer.build_unzoomed(ctx, app))
}
fn bus_network(ctx: &mut EventCtx, app: &App) -> Overlays {
@ -605,7 +605,7 @@ impl Overlays {
colorer.add_bs(*bs, stop);
}
Overlays::BusNetwork(colorer.build(ctx, app))
Overlays::BusNetwork(colorer.build_unzoomed(ctx, app))
}
fn elevation(ctx: &mut EventCtx, app: &App) -> Overlays {
@ -687,7 +687,7 @@ impl Overlays {
}
}
Overlays::Elevation(colorer.build(ctx, app), batch.upload(ctx))
Overlays::Elevation(colorer.build_unzoomed(ctx, app), batch.upload(ctx))
}
pub fn trips_histogram(ctx: &mut EventCtx, app: &App) -> Overlays {
@ -810,7 +810,7 @@ impl Overlays {
colorer.add_i(*i, changed);
}
Overlays::Edits(colorer.build(ctx, app))
Overlays::Edits(colorer.build_both(ctx, app))
}
// TODO Disable drawing unzoomed agents... or alternatively, implement this by asking Sim to

View File

@ -64,7 +64,7 @@ impl Floodfiller {
vec![format!("{} unreachable lanes", num_unreachable)],
vec![],
),
colorer: colorer.build(ctx, app),
colorer: colorer.build_both(ctx, app),
})
}
}

View File

@ -138,7 +138,7 @@ impl ScenarioManager {
trips_to_bldg,
trips_from_border,
trips_to_border,
bldg_colors: bldg_colors.build(ctx, app),
bldg_colors: bldg_colors.build_both(ctx, app),
demand: None,
}
}

View File

@ -612,7 +612,7 @@ pub fn execute(ctx: &mut EventCtx, app: &mut App, id: ID, action: String) -> Tra
),
from: Source::WalkFromBldg(id),
maybe_goal: None,
colorer: c.build(ctx, app),
colorer: c.build_both(ctx, app),
}))
}
(ID::Building(id), "spawn a pedestrian here using an owned parked car") => {
@ -626,7 +626,7 @@ pub fn execute(ctx: &mut EventCtx, app: &mut App, id: ID, action: String) -> Tra
),
from: Source::WalkFromBldgThenMaybeUseCar(id),
maybe_goal: None,
colorer: c.build(ctx, app),
colorer: c.build_both(ctx, app),
}))
}
(ID::Building(id), "spawn a car starting here") => {
@ -641,7 +641,7 @@ pub fn execute(ctx: &mut EventCtx, app: &mut App, id: ID, action: String) -> Tra
),
from: Source::Drive(pos),
maybe_goal: None,
colorer: c.build(ctx, app),
colorer: c.build_both(ctx, app),
}))
}
(ID::Building(id), "spawn a bike starting here") => {
@ -656,7 +656,7 @@ pub fn execute(ctx: &mut EventCtx, app: &mut App, id: ID, action: String) -> Tra
),
from: Source::BikeFromBldg(id, pos),
maybe_goal: None,
colorer: c.build(ctx, app),
colorer: c.build_both(ctx, app),
}))
}
(ID::Lane(id), "spawn a car starting here") => {
@ -670,7 +670,7 @@ pub fn execute(ctx: &mut EventCtx, app: &mut App, id: ID, action: String) -> Tra
),
from: Source::Drive(Position::new(id, map.get_l(id).length() / 2.0)),
maybe_goal: None,
colorer: c.build(ctx, app),
colorer: c.build_both(ctx, app),
}))
}
(ID::Lane(id), "spawn a pedestrian starting here") => {
@ -684,7 +684,7 @@ pub fn execute(ctx: &mut EventCtx, app: &mut App, id: ID, action: String) -> Tra
),
from: Source::WalkFromSidewalk(Position::new(id, map.get_l(id).length() / 2.0)),
maybe_goal: None,
colorer: c.build(ctx, app),
colorer: c.build_both(ctx, app),
}))
}
(ID::Lane(l), "spawn many cars starting here") => {
@ -705,7 +705,7 @@ pub fn execute(ctx: &mut EventCtx, app: &mut App, id: ID, action: String) -> Tra
from: l,
maybe_goal: None,
schedule: None,
colorer: c.build(ctx, app),
colorer: c.build_both(ctx, app),
}))
}
(ID::Intersection(id), "spawn agents here") => {