mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-18 03:41:52 +03:00
Always draw modal filters for the whole map, even in per-neighborhood views. For example, in the pathfinding view, now the 'before' route can cross existing filters anywhere, so it's kind of necessary to actually see them
This commit is contained in:
parent
3de1ab3d9d
commit
3729cba0c7
@ -4,9 +4,8 @@ use abstutil::Timer;
|
||||
use map_model::RoadID;
|
||||
use widgetry::{Choice, EventCtx};
|
||||
|
||||
use super::rat_runs::find_rat_runs;
|
||||
use super::Neighborhood;
|
||||
use crate::App;
|
||||
use crate::rat_runs::find_rat_runs;
|
||||
use crate::{after_edit, App, Neighborhood};
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum Heuristic {
|
||||
@ -64,6 +63,7 @@ impl Heuristic {
|
||||
}
|
||||
|
||||
app.session.modal_filters.cancel_empty_edit();
|
||||
after_edit(ctx, app);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,14 +12,13 @@ use widgetry::{
|
||||
|
||||
use super::auto::Heuristic;
|
||||
use super::{Neighborhood, NeighborhoodID, Partitioning};
|
||||
use crate::{App, ModalFilters, Toggle3Zoomed, Transition};
|
||||
use crate::{App, ModalFilters, Transition};
|
||||
|
||||
pub struct BrowseNeighborhoods {
|
||||
panel: Panel,
|
||||
world: World<NeighborhoodID>,
|
||||
draw_over_roads: ToggleZoomed,
|
||||
labels: DrawRoadLabels,
|
||||
draw_all_filters: Toggle3Zoomed,
|
||||
draw_boundary_roads: ToggleZoomed,
|
||||
}
|
||||
|
||||
@ -34,13 +33,13 @@ impl BrowseNeighborhoods {
|
||||
app.session.modal_filters = ModalFilters::default();
|
||||
crate::filters::transform_existing_filters(ctx, app, timer);
|
||||
app.session.partitioning = Partitioning::seed_using_heuristics(app, timer);
|
||||
app.session.draw_all_filters = app.session.modal_filters.draw(ctx, &app.map);
|
||||
}
|
||||
(
|
||||
make_world(ctx, app, timer),
|
||||
draw_over_roads(ctx, app, timer),
|
||||
)
|
||||
});
|
||||
let draw_all_filters = app.session.modal_filters.draw(ctx, &app.map, None);
|
||||
|
||||
let panel = Panel::new_builder(Widget::col(vec![
|
||||
crate::app_header(ctx, app),
|
||||
@ -107,7 +106,6 @@ impl BrowseNeighborhoods {
|
||||
world,
|
||||
draw_over_roads,
|
||||
labels: DrawRoadLabels::only_major_roads(),
|
||||
draw_all_filters,
|
||||
draw_boundary_roads: draw_boundary_roads(ctx, app),
|
||||
})
|
||||
}
|
||||
@ -195,7 +193,7 @@ impl State<App> for BrowseNeighborhoods {
|
||||
if self.panel.is_checked("highlight boundary roads") {
|
||||
self.draw_boundary_roads.draw(g);
|
||||
}
|
||||
self.draw_all_filters.draw(g);
|
||||
app.session.draw_all_filters.draw(g);
|
||||
if g.canvas.is_unzoomed() {
|
||||
self.labels.draw(g, app);
|
||||
}
|
||||
|
@ -148,7 +148,7 @@ impl State<App> for Viewer {
|
||||
g.redraw(&self.neighborhood.fade_irrelevant);
|
||||
|
||||
self.panel.draw(g);
|
||||
self.neighborhood.draw_filters.draw(g);
|
||||
app.session.draw_all_filters.draw(g);
|
||||
// TODO Since we cover such a small area, treating multiple segments of one road as the
|
||||
// same might be nice. And we should seed the quadtree with the locations of filters and
|
||||
// arrows, possibly.
|
||||
|
@ -10,7 +10,6 @@ use widgetry::mapspace::{DrawUnzoomedShapes, ToggleZoomed};
|
||||
use widgetry::{Color, EventCtx, GeomBatch, GfxCtx};
|
||||
|
||||
pub use self::existing::transform_existing_filters;
|
||||
use super::Neighborhood;
|
||||
use crate::App;
|
||||
|
||||
/// Stored in App session state. Before making any changes, call `before_edit`.
|
||||
@ -84,25 +83,12 @@ impl ModalFilters {
|
||||
true
|
||||
}
|
||||
|
||||
/// Draw all modal filters. If `only_neighborhood` is specified, only draw filters belonging to
|
||||
/// one area.
|
||||
pub fn draw(
|
||||
&self,
|
||||
ctx: &EventCtx,
|
||||
map: &Map,
|
||||
only_neighborhood: Option<&Neighborhood>,
|
||||
) -> Toggle3Zoomed {
|
||||
/// Draw all modal filters
|
||||
pub fn draw(&self, ctx: &EventCtx, map: &Map) -> Toggle3Zoomed {
|
||||
let mut batch = ToggleZoomed::builder();
|
||||
let mut low_zoom = DrawUnzoomedShapes::builder();
|
||||
|
||||
for (r, dist) in &self.roads {
|
||||
if only_neighborhood
|
||||
.map(|n| !n.orig_perimeter.interior.contains(r))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
let road = map.get_r(*r);
|
||||
if let Ok((pt, angle)) = road.center_pts.dist_along(*dist) {
|
||||
let road_width = road.get_width();
|
||||
@ -135,14 +121,7 @@ impl ModalFilters {
|
||||
);
|
||||
}
|
||||
}
|
||||
for (i, filter) in &self.intersections {
|
||||
if only_neighborhood
|
||||
.map(|n| !n.interior_intersections.contains(i))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (_, filter) in &self.intersections {
|
||||
let line = filter.geometry(map);
|
||||
|
||||
// It's really hard to see a tiny squished line thickened, so use the same circle
|
||||
|
@ -9,14 +9,13 @@ use widgetry::{
|
||||
};
|
||||
|
||||
use super::{end_of_day, Filters, Impact};
|
||||
use crate::{App, BrowseNeighborhoods, Toggle3Zoomed, Transition};
|
||||
use crate::{App, BrowseNeighborhoods, Transition};
|
||||
|
||||
// TODO Share structure or pieces with Ungap's predict mode
|
||||
// ... can't we just produce data of a certain shape, and have a UI pretty tuned for that?
|
||||
|
||||
pub struct ShowResults {
|
||||
draw_all_neighborhoods: Drawable,
|
||||
draw_all_filters: Toggle3Zoomed,
|
||||
}
|
||||
|
||||
impl ShowResults {
|
||||
@ -66,7 +65,6 @@ impl ShowResults {
|
||||
<dyn SimpleState<_>>::new_state(
|
||||
panel,
|
||||
Box::new(ShowResults {
|
||||
draw_all_filters: app.session.modal_filters.draw(ctx, &app.map, None),
|
||||
draw_all_neighborhoods,
|
||||
}),
|
||||
)
|
||||
@ -153,7 +151,7 @@ impl SimpleState<App> for ShowResults {
|
||||
fn draw(&self, g: &mut GfxCtx, app: &App) {
|
||||
g.redraw(&self.draw_all_neighborhoods);
|
||||
app.session.impact.compare_counts.draw(g);
|
||||
self.draw_all_filters.draw(g);
|
||||
app.session.draw_all_filters.draw(g);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,8 @@ use structopt::StructOpt;
|
||||
use widgetry::{lctrl, EventCtx, GfxCtx, Key, Line, Settings, Widget};
|
||||
|
||||
pub use browse::BrowseNeighborhoods;
|
||||
pub use filters::{DiagonalFilter, ModalFilters, Toggle3Zoomed};
|
||||
use filters::Toggle3Zoomed;
|
||||
pub use filters::{DiagonalFilter, ModalFilters};
|
||||
pub use neighborhood::{Cell, DistanceInterval, Neighborhood};
|
||||
pub use partition::{NeighborhoodID, Partitioning};
|
||||
|
||||
@ -60,6 +61,7 @@ fn run(mut settings: Settings) {
|
||||
let session = Session {
|
||||
partitioning: Partitioning::empty(),
|
||||
modal_filters: ModalFilters::default(),
|
||||
draw_all_filters: Toggle3Zoomed::empty(ctx),
|
||||
|
||||
impact: impact::Impact::empty(ctx),
|
||||
|
||||
@ -120,6 +122,7 @@ pub fn run_wasm(root_dom_id: String, assets_base_url: String, assets_are_gzipped
|
||||
pub struct Session {
|
||||
pub partitioning: Partitioning,
|
||||
pub modal_filters: ModalFilters,
|
||||
pub draw_all_filters: Toggle3Zoomed,
|
||||
|
||||
pub impact: impact::Impact,
|
||||
|
||||
@ -213,3 +216,7 @@ fn handle_app_header_click(ctx: &mut EventCtx, app: &App, x: &str) -> Option<Tra
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn after_edit(ctx: &EventCtx, app: &mut App) {
|
||||
app.session.draw_all_filters = app.session.modal_filters.draw(ctx, &app.map);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use map_gui::tools::DrawRoadLabels;
|
||||
use map_model::{IntersectionID, Map, PathConstraints, Perimeter, RoadID};
|
||||
use widgetry::{Drawable, EventCtx, GeomBatch};
|
||||
|
||||
use crate::{App, ModalFilters, NeighborhoodID, Toggle3Zoomed};
|
||||
use crate::{App, ModalFilters, NeighborhoodID};
|
||||
|
||||
pub struct Neighborhood {
|
||||
pub id: NeighborhoodID,
|
||||
@ -23,7 +23,6 @@ pub struct Neighborhood {
|
||||
pub cells: Vec<Cell>,
|
||||
|
||||
pub fade_irrelevant: Drawable,
|
||||
pub draw_filters: Toggle3Zoomed,
|
||||
pub labels: DrawRoadLabels,
|
||||
}
|
||||
|
||||
@ -73,7 +72,6 @@ impl Neighborhood {
|
||||
cells: Vec::new(),
|
||||
|
||||
fade_irrelevant: Drawable::empty(ctx),
|
||||
draw_filters: Toggle3Zoomed::empty(ctx),
|
||||
// Temporary value
|
||||
labels: DrawRoadLabels::only_major_roads(),
|
||||
};
|
||||
@ -123,8 +121,6 @@ impl Neighborhood {
|
||||
&app.session.modal_filters,
|
||||
);
|
||||
|
||||
n.draw_filters = app.session.modal_filters.draw(ctx, map, Some(&n));
|
||||
|
||||
let mut label_roads = n.perimeter.clone();
|
||||
label_roads.extend(n.orig_perimeter.interior.clone());
|
||||
n.labels = DrawRoadLabels::new(Box::new(move |r| label_roads.contains(&r.id)));
|
||||
|
@ -295,7 +295,7 @@ impl State<App> for RoutePlanner {
|
||||
|
||||
g.redraw(&self.neighborhood.fade_irrelevant);
|
||||
self.draw_routes.draw(g);
|
||||
self.neighborhood.draw_filters.draw(g);
|
||||
app.session.draw_all_filters.draw(g);
|
||||
if g.canvas.is_unzoomed() {
|
||||
self.neighborhood.labels.draw(g, app);
|
||||
}
|
||||
|
@ -7,8 +7,9 @@ use widgetry::{
|
||||
VerticalAlignment, Widget, DEFAULT_CORNER_RADIUS,
|
||||
};
|
||||
|
||||
use super::{BrowseNeighborhoods, DiagonalFilter, Neighborhood, NeighborhoodID};
|
||||
use crate::{App, Transition};
|
||||
use crate::{
|
||||
after_edit, App, BrowseNeighborhoods, DiagonalFilter, Neighborhood, NeighborhoodID, Transition,
|
||||
};
|
||||
|
||||
#[derive(PartialEq)]
|
||||
pub enum Tab {
|
||||
@ -206,6 +207,7 @@ pub fn handle_world_outcome(
|
||||
|
||||
app.session.modal_filters.roads.insert(r, distance);
|
||||
}
|
||||
after_edit(ctx, app);
|
||||
true
|
||||
}
|
||||
WorldOutcome::ClickedObject(FilterableObj::InteriorIntersection(i)) => {
|
||||
@ -234,6 +236,7 @@ pub fn handle_world_outcome(
|
||||
.intersections
|
||||
.insert(i, all.remove(0));
|
||||
}
|
||||
after_edit(ctx, app);
|
||||
true
|
||||
}
|
||||
WorldOutcome::Keypress("debug", FilterableObj::InteriorIntersection(i)) => {
|
||||
|
@ -201,7 +201,7 @@ impl State<App> for BrowseRatRuns {
|
||||
}
|
||||
|
||||
g.redraw(&self.neighborhood.fade_irrelevant);
|
||||
self.neighborhood.draw_filters.draw(g);
|
||||
app.session.draw_all_filters.draw(g);
|
||||
if g.canvas.is_unzoomed() {
|
||||
self.neighborhood.labels.draw(g, app);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user