mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-01 10:44:56 +03:00
remove the old trip histogram, make room for cleaning it up
This commit is contained in:
parent
7c67c8673a
commit
ddd98d315e
@ -75,6 +75,7 @@ impl State for EditMode {
|
|||||||
fn event(&mut self, ctx: &mut EventCtx, app: &mut App) -> Transition {
|
fn event(&mut self, ctx: &mut EventCtx, app: &mut App) -> Transition {
|
||||||
// Can't do this in the constructor, because SandboxMode's on_destroy clears out Layers
|
// Can't do this in the constructor, because SandboxMode's on_destroy clears out Layers
|
||||||
if self.once {
|
if self.once {
|
||||||
|
// Once is never...
|
||||||
self.once = false;
|
self.once = false;
|
||||||
// apply_map_edits will do the job later
|
// apply_map_edits will do the job later
|
||||||
app.layer = crate::layer::map::edits(ctx, app);
|
app.layer = crate::layer::map::edits(ctx, app);
|
||||||
|
@ -5,7 +5,6 @@ mod pandemic;
|
|||||||
mod parking;
|
mod parking;
|
||||||
mod population;
|
mod population;
|
||||||
pub mod traffic;
|
pub mod traffic;
|
||||||
pub mod trips;
|
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
use crate::common::{Colorer, HeatmapOptions, Warping};
|
use crate::common::{Colorer, HeatmapOptions, Warping};
|
||||||
@ -32,7 +31,6 @@ pub enum Layers {
|
|||||||
BusNetwork(Colorer),
|
BusNetwork(Colorer),
|
||||||
Elevation(Colorer, Drawable),
|
Elevation(Colorer, Drawable),
|
||||||
Edits(Colorer),
|
Edits(Colorer),
|
||||||
TripsHistogram(Time, Composite),
|
|
||||||
PopulationMap(Time, population::Options, Drawable, Composite),
|
PopulationMap(Time, population::Options, Drawable, Composite),
|
||||||
Pandemic(Time, pandemic::Options, Drawable, Composite),
|
Pandemic(Time, pandemic::Options, Drawable, Composite),
|
||||||
|
|
||||||
@ -79,11 +77,6 @@ impl Layers {
|
|||||||
app.layer = traffic::intersection_demand(ctx, app, i);
|
app.layer = traffic::intersection_demand(ctx, app, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Layers::TripsHistogram(t, _) => {
|
|
||||||
if now != t {
|
|
||||||
app.layer = trips::trips_histogram(ctx, app);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Layers::BusRoute(t, id, _) => {
|
Layers::BusRoute(t, id, _) => {
|
||||||
if now != t {
|
if now != t {
|
||||||
app.layer = bus::ShowBusRoute::new(ctx, app, id);
|
app.layer = bus::ShowBusRoute::new(ctx, app, id);
|
||||||
@ -149,18 +142,6 @@ impl Layers {
|
|||||||
None => {}
|
None => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Layers::TripsHistogram(_, ref mut c) => {
|
|
||||||
c.align_above(ctx, minimap);
|
|
||||||
match c.event(ctx) {
|
|
||||||
Some(Outcome::Clicked(x)) => match x.as_ref() {
|
|
||||||
"X" => {
|
|
||||||
app.layer = Layers::Inactive;
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
|
||||||
},
|
|
||||||
None => {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Layers::PopulationMap(_, ref mut opts, _, ref mut c) => {
|
Layers::PopulationMap(_, ref mut opts, _, ref mut c) => {
|
||||||
c.align_above(ctx, minimap);
|
c.align_above(ctx, minimap);
|
||||||
match c.event(ctx) {
|
match c.event(ctx) {
|
||||||
@ -243,9 +224,6 @@ impl Layers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// All of these shouldn't care about zoom
|
// All of these shouldn't care about zoom
|
||||||
Layers::TripsHistogram(_, ref composite) => {
|
|
||||||
composite.draw(g);
|
|
||||||
}
|
|
||||||
Layers::IntersectionDemand(_, _, ref draw, ref legend) => {
|
Layers::IntersectionDemand(_, _, ref draw, ref legend) => {
|
||||||
g.redraw(draw);
|
g.redraw(draw);
|
||||||
legend.draw(g);
|
legend.draw(g);
|
||||||
@ -279,7 +257,6 @@ impl Layers {
|
|||||||
Layers::Pandemic(_, _, ref draw, _) => {
|
Layers::Pandemic(_, _, ref draw, _) => {
|
||||||
g.redraw(draw);
|
g.redraw(draw);
|
||||||
}
|
}
|
||||||
Layers::TripsHistogram(_, _) => {}
|
|
||||||
Layers::IntersectionDemand(_, _, _, _) => {}
|
Layers::IntersectionDemand(_, _, _, _) => {}
|
||||||
Layers::BusRoute(_, _, ref s) => {
|
Layers::BusRoute(_, _, ref s) => {
|
||||||
s.draw(g);
|
s.draw(g);
|
||||||
|
@ -1,45 +0,0 @@
|
|||||||
use crate::app::App;
|
|
||||||
use crate::layer::Layers;
|
|
||||||
use ezgui::{
|
|
||||||
Btn, Color, Composite, EventCtx, Histogram, HorizontalAlignment, Line, Text, VerticalAlignment,
|
|
||||||
Widget,
|
|
||||||
};
|
|
||||||
|
|
||||||
pub fn trips_histogram(ctx: &mut EventCtx, app: &App) -> Layers {
|
|
||||||
if app.has_prebaked().is_none() {
|
|
||||||
return Layers::Inactive;
|
|
||||||
}
|
|
||||||
|
|
||||||
let now = app.primary.sim.time();
|
|
||||||
Layers::TripsHistogram(
|
|
||||||
now,
|
|
||||||
Composite::new(
|
|
||||||
Widget::col(vec![
|
|
||||||
Widget::row(vec![
|
|
||||||
{
|
|
||||||
let mut txt = Text::from(Line("Are trips "));
|
|
||||||
txt.append(Line("faster").fg(Color::GREEN));
|
|
||||||
txt.append(Line(", "));
|
|
||||||
txt.append(Line("slower").fg(Color::RED));
|
|
||||||
txt.append(Line(", or "));
|
|
||||||
txt.append(Line("the same").fg(Color::YELLOW));
|
|
||||||
txt.append(Line("?"));
|
|
||||||
txt.draw(ctx)
|
|
||||||
}
|
|
||||||
.margin(10),
|
|
||||||
Btn::text_fg("X").build_def(ctx, None).align_right(),
|
|
||||||
]),
|
|
||||||
Histogram::new(
|
|
||||||
ctx,
|
|
||||||
app.primary
|
|
||||||
.sim
|
|
||||||
.get_analytics()
|
|
||||||
.trip_time_deltas(now, app.prebaked()),
|
|
||||||
),
|
|
||||||
])
|
|
||||||
.bg(app.cs.panel_bg),
|
|
||||||
)
|
|
||||||
.aligned(HorizontalAlignment::Right, VerticalAlignment::Center)
|
|
||||||
.build(ctx),
|
|
||||||
)
|
|
||||||
}
|
|
@ -7,8 +7,8 @@ use crate::sandbox::SandboxMode;
|
|||||||
use abstutil::prettyprint_usize;
|
use abstutil::prettyprint_usize;
|
||||||
use abstutil::Counter;
|
use abstutil::Counter;
|
||||||
use ezgui::{
|
use ezgui::{
|
||||||
hotkey, Btn, Color, Composite, EventCtx, Histogram, Key, Line, Plot, PlotOptions, Series, Text,
|
hotkey, Btn, Color, Composite, EventCtx, Key, Line, Plot, PlotOptions, Series, Text, TextExt,
|
||||||
TextExt, Widget,
|
Widget,
|
||||||
};
|
};
|
||||||
use geom::{Statistic, Time};
|
use geom::{Statistic, Time};
|
||||||
use map_model::BusRouteID;
|
use map_model::BusRouteID;
|
||||||
@ -149,15 +149,6 @@ fn trips_summary_prebaked(ctx: &EventCtx, app: &App) -> Widget {
|
|||||||
Widget::col(vec![
|
Widget::col(vec![
|
||||||
txt.draw(ctx),
|
txt.draw(ctx),
|
||||||
finished_trips_plot(ctx, app).bg(app.cs.section_bg),
|
finished_trips_plot(ctx, app).bg(app.cs.section_bg),
|
||||||
"Are trips faster or slower than the baseline?".draw_text(ctx),
|
|
||||||
Histogram::new(
|
|
||||||
ctx,
|
|
||||||
app.primary
|
|
||||||
.sim
|
|
||||||
.get_analytics()
|
|
||||||
.trip_time_deltas(app.primary.sim.time(), app.prebaked()),
|
|
||||||
)
|
|
||||||
.bg(app.cs.section_bg),
|
|
||||||
Line("Active agents").small_heading().draw(ctx),
|
Line("Active agents").small_heading().draw(ctx),
|
||||||
Plot::new(
|
Plot::new(
|
||||||
ctx,
|
ctx,
|
||||||
|
@ -11,7 +11,6 @@ use sim::{BorderSpawnOverTime, OriginDestination, ScenarioGenerator};
|
|||||||
const GOAL: Duration = Duration::const_seconds(30.0);
|
const GOAL: Duration = Duration::const_seconds(30.0);
|
||||||
|
|
||||||
pub struct FixTrafficSignals {
|
pub struct FixTrafficSignals {
|
||||||
once: bool,
|
|
||||||
top_center: WrappedComposite,
|
top_center: WrappedComposite,
|
||||||
// TODO Keeping a copy in here seems redundant?
|
// TODO Keeping a copy in here seems redundant?
|
||||||
mode: GameplayMode,
|
mode: GameplayMode,
|
||||||
@ -20,7 +19,6 @@ pub struct FixTrafficSignals {
|
|||||||
impl FixTrafficSignals {
|
impl FixTrafficSignals {
|
||||||
pub fn new(ctx: &mut EventCtx, app: &App, mode: GameplayMode) -> Box<dyn GameplayState> {
|
pub fn new(ctx: &mut EventCtx, app: &App, mode: GameplayMode) -> Box<dyn GameplayState> {
|
||||||
Box::new(FixTrafficSignals {
|
Box::new(FixTrafficSignals {
|
||||||
once: true,
|
|
||||||
top_center: challenge_controller(
|
top_center: challenge_controller(
|
||||||
ctx,
|
ctx,
|
||||||
app,
|
app,
|
||||||
@ -40,12 +38,6 @@ impl GameplayState for FixTrafficSignals {
|
|||||||
app: &mut App,
|
app: &mut App,
|
||||||
_: &mut SandboxControls,
|
_: &mut SandboxControls,
|
||||||
) -> (Option<Transition>, bool) {
|
) -> (Option<Transition>, bool) {
|
||||||
// Once is never...
|
|
||||||
if self.once {
|
|
||||||
app.layer = crate::layer::trips::trips_histogram(ctx, app);
|
|
||||||
self.once = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
match self.top_center.event(ctx, app) {
|
match self.top_center.event(ctx, app) {
|
||||||
Some(WrappedOutcome::Transition(t)) => {
|
Some(WrappedOutcome::Transition(t)) => {
|
||||||
return (Some(t), false);
|
return (Some(t), false);
|
||||||
|
@ -329,36 +329,27 @@ impl AgentMeter {
|
|||||||
)
|
)
|
||||||
.margin(15)
|
.margin(15)
|
||||||
.centered_horiz(),
|
.centered_horiz(),
|
||||||
{
|
Widget::row(vec![
|
||||||
let mut txt = Text::new();
|
{
|
||||||
let pct = if unfinished == 0 {
|
let mut txt = Text::new();
|
||||||
100.0
|
let pct = if unfinished == 0 {
|
||||||
} else {
|
100.0
|
||||||
100.0 * (finished as f64) / ((finished + unfinished) as f64)
|
|
||||||
};
|
|
||||||
txt.add(Line(format!(
|
|
||||||
"Finished trips: {} ({}%)",
|
|
||||||
prettyprint_usize(finished),
|
|
||||||
pct as usize
|
|
||||||
)));
|
|
||||||
txt.draw(ctx)
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Widget::row(vec![
|
|
||||||
Btn::text_bg2("more data")
|
|
||||||
.build_def(ctx, None)
|
|
||||||
.margin_right(10),
|
|
||||||
Btn::text_bg2("finished trips").build_def(ctx, hotkey(Key::Q)),
|
|
||||||
if app.has_prebaked().is_some() {
|
|
||||||
Btn::svg_def("../data/system/assets/meters/trip_histogram.svg")
|
|
||||||
.build(ctx, "compare trips to baseline", None)
|
|
||||||
.align_right()
|
|
||||||
} else {
|
} else {
|
||||||
Widget::nothing()
|
100.0 * (finished as f64) / ((finished + unfinished) as f64)
|
||||||
},
|
};
|
||||||
])
|
txt.add(Line(format!(
|
||||||
.centered()
|
"Finished trips: {} ({}%)",
|
||||||
},
|
prettyprint_usize(finished),
|
||||||
|
pct as usize
|
||||||
|
)));
|
||||||
|
txt.draw(ctx)
|
||||||
|
},
|
||||||
|
Btn::svg_def("../data/system/assets/meters/trip_histogram.svg")
|
||||||
|
.build(ctx, "finished trips", hotkey(Key::Q))
|
||||||
|
.align_right(),
|
||||||
|
]),
|
||||||
|
// TODO On it's way out
|
||||||
|
Btn::text_bg2("more data").build_def(ctx, None),
|
||||||
];
|
];
|
||||||
// TODO Slight hack. If we're jumping right into a tutorial and don't have the prebaked
|
// TODO Slight hack. If we're jumping right into a tutorial and don't have the prebaked
|
||||||
// stuff loaded yet, just skip a tick.
|
// stuff loaded yet, just skip a tick.
|
||||||
@ -425,9 +416,6 @@ impl AgentMeter {
|
|||||||
"finished trips" => {
|
"finished trips" => {
|
||||||
return Some(Transition::Push(trip_results::TripResults::new(ctx, app)));
|
return Some(Transition::Push(trip_results::TripResults::new(ctx, app)));
|
||||||
}
|
}
|
||||||
"compare trips to baseline" => {
|
|
||||||
app.layer = crate::layer::trips::trips_histogram(ctx, app);
|
|
||||||
}
|
|
||||||
_ => unreachable!(),
|
_ => unreachable!(),
|
||||||
},
|
},
|
||||||
None => {}
|
None => {}
|
||||||
|
@ -268,6 +268,7 @@ impl Analytics {
|
|||||||
|
|
||||||
// Returns unsorted list of deltas, one for each trip finished or ongoing in both worlds.
|
// Returns unsorted list of deltas, one for each trip finished or ongoing in both worlds.
|
||||||
// Positive dt means faster.
|
// Positive dt means faster.
|
||||||
|
// TODO Now unused
|
||||||
pub fn trip_time_deltas(&self, now: Time, baseline: &Analytics) -> Vec<Duration> {
|
pub fn trip_time_deltas(&self, now: Time, baseline: &Analytics) -> Vec<Duration> {
|
||||||
fn trip_times(a: &Analytics, now: Time) -> BTreeMap<TripID, Duration> {
|
fn trip_times(a: &Analytics, now: Time) -> BTreeMap<TripID, Duration> {
|
||||||
let mut ongoing = a.started_trips.clone();
|
let mut ongoing = a.started_trips.clone();
|
||||||
|
Loading…
Reference in New Issue
Block a user