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 {
|
||||
// Can't do this in the constructor, because SandboxMode's on_destroy clears out Layers
|
||||
if self.once {
|
||||
// Once is never...
|
||||
self.once = false;
|
||||
// apply_map_edits will do the job later
|
||||
app.layer = crate::layer::map::edits(ctx, app);
|
||||
|
@ -5,7 +5,6 @@ mod pandemic;
|
||||
mod parking;
|
||||
mod population;
|
||||
pub mod traffic;
|
||||
pub mod trips;
|
||||
|
||||
use crate::app::App;
|
||||
use crate::common::{Colorer, HeatmapOptions, Warping};
|
||||
@ -32,7 +31,6 @@ pub enum Layers {
|
||||
BusNetwork(Colorer),
|
||||
Elevation(Colorer, Drawable),
|
||||
Edits(Colorer),
|
||||
TripsHistogram(Time, Composite),
|
||||
PopulationMap(Time, population::Options, Drawable, Composite),
|
||||
Pandemic(Time, pandemic::Options, Drawable, Composite),
|
||||
|
||||
@ -79,11 +77,6 @@ impl Layers {
|
||||
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, _) => {
|
||||
if now != t {
|
||||
app.layer = bus::ShowBusRoute::new(ctx, app, id);
|
||||
@ -149,18 +142,6 @@ impl Layers {
|
||||
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) => {
|
||||
c.align_above(ctx, minimap);
|
||||
match c.event(ctx) {
|
||||
@ -243,9 +224,6 @@ impl Layers {
|
||||
}
|
||||
}
|
||||
// All of these shouldn't care about zoom
|
||||
Layers::TripsHistogram(_, ref composite) => {
|
||||
composite.draw(g);
|
||||
}
|
||||
Layers::IntersectionDemand(_, _, ref draw, ref legend) => {
|
||||
g.redraw(draw);
|
||||
legend.draw(g);
|
||||
@ -279,7 +257,6 @@ impl Layers {
|
||||
Layers::Pandemic(_, _, ref draw, _) => {
|
||||
g.redraw(draw);
|
||||
}
|
||||
Layers::TripsHistogram(_, _) => {}
|
||||
Layers::IntersectionDemand(_, _, _, _) => {}
|
||||
Layers::BusRoute(_, _, ref s) => {
|
||||
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::Counter;
|
||||
use ezgui::{
|
||||
hotkey, Btn, Color, Composite, EventCtx, Histogram, Key, Line, Plot, PlotOptions, Series, Text,
|
||||
TextExt, Widget,
|
||||
hotkey, Btn, Color, Composite, EventCtx, Key, Line, Plot, PlotOptions, Series, Text, TextExt,
|
||||
Widget,
|
||||
};
|
||||
use geom::{Statistic, Time};
|
||||
use map_model::BusRouteID;
|
||||
@ -149,15 +149,6 @@ fn trips_summary_prebaked(ctx: &EventCtx, app: &App) -> Widget {
|
||||
Widget::col(vec![
|
||||
txt.draw(ctx),
|
||||
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),
|
||||
Plot::new(
|
||||
ctx,
|
||||
|
@ -11,7 +11,6 @@ use sim::{BorderSpawnOverTime, OriginDestination, ScenarioGenerator};
|
||||
const GOAL: Duration = Duration::const_seconds(30.0);
|
||||
|
||||
pub struct FixTrafficSignals {
|
||||
once: bool,
|
||||
top_center: WrappedComposite,
|
||||
// TODO Keeping a copy in here seems redundant?
|
||||
mode: GameplayMode,
|
||||
@ -20,7 +19,6 @@ pub struct FixTrafficSignals {
|
||||
impl FixTrafficSignals {
|
||||
pub fn new(ctx: &mut EventCtx, app: &App, mode: GameplayMode) -> Box<dyn GameplayState> {
|
||||
Box::new(FixTrafficSignals {
|
||||
once: true,
|
||||
top_center: challenge_controller(
|
||||
ctx,
|
||||
app,
|
||||
@ -40,12 +38,6 @@ impl GameplayState for FixTrafficSignals {
|
||||
app: &mut App,
|
||||
_: &mut SandboxControls,
|
||||
) -> (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) {
|
||||
Some(WrappedOutcome::Transition(t)) => {
|
||||
return (Some(t), false);
|
||||
|
@ -329,36 +329,27 @@ impl AgentMeter {
|
||||
)
|
||||
.margin(15)
|
||||
.centered_horiz(),
|
||||
{
|
||||
let mut txt = Text::new();
|
||||
let pct = if unfinished == 0 {
|
||||
100.0
|
||||
} else {
|
||||
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()
|
||||
Widget::row(vec![
|
||||
{
|
||||
let mut txt = Text::new();
|
||||
let pct = if unfinished == 0 {
|
||||
100.0
|
||||
} else {
|
||||
Widget::nothing()
|
||||
},
|
||||
])
|
||||
.centered()
|
||||
},
|
||||
100.0 * (finished as f64) / ((finished + unfinished) as f64)
|
||||
};
|
||||
txt.add(Line(format!(
|
||||
"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
|
||||
// stuff loaded yet, just skip a tick.
|
||||
@ -425,9 +416,6 @@ impl AgentMeter {
|
||||
"finished trips" => {
|
||||
return Some(Transition::Push(trip_results::TripResults::new(ctx, app)));
|
||||
}
|
||||
"compare trips to baseline" => {
|
||||
app.layer = crate::layer::trips::trips_histogram(ctx, app);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
},
|
||||
None => {}
|
||||
|
@ -268,6 +268,7 @@ impl Analytics {
|
||||
|
||||
// Returns unsorted list of deltas, one for each trip finished or ongoing in both worlds.
|
||||
// Positive dt means faster.
|
||||
// TODO Now unused
|
||||
pub fn trip_time_deltas(&self, now: Time, baseline: &Analytics) -> Vec<Duration> {
|
||||
fn trip_times(a: &Analytics, now: Time) -> BTreeMap<TripID, Duration> {
|
||||
let mut ongoing = a.started_trips.clone();
|
||||
|
Loading…
Reference in New Issue
Block a user