Clean up the impact prediction UI a bit, add caveats

This commit is contained in:
Dustin Carlino 2022-08-04 12:37:38 +01:00
parent c12edaf80e
commit 6abdeaf2a3
2 changed files with 27 additions and 31 deletions

View File

@ -6,7 +6,7 @@ use map_gui::tools::{ColorNetwork, DrawRoadLabels};
use widgetry::mapspace::{ToggleZoomed, World, WorldOutcome};
use widgetry::{
Choice, Color, DrawBaselayer, EventCtx, GeomBatch, GfxCtx, Key, Line, Outcome, Panel, State,
Text, TextExt, Toggle, Widget,
TextExt, Toggle, Widget,
};
use crate::edit::EditMode;
@ -302,32 +302,17 @@ pub enum Style {
}
fn impact_widget(ctx: &EventCtx, app: &App) -> Widget {
let map_name = app.map.get_name();
if &app.session.impact.map != map_name {
// Starting from scratch
return Widget::col(vec![
Text::from_multiline(vec![
Line("This will take a moment.").small(),
Line("The app may freeze while calculating.").small(),
])
.into_widget(ctx),
ctx.style().btn_outline.text("Calculate").build_def(ctx),
]);
}
if app.session.impact.change_key == app.session.modal_filters.get_change_key() {
if &app.session.impact.map == app.map.get_name()
&& app.session.impact.change_key == app.session.modal_filters.get_change_key()
{
// Nothing to calculate!
return ctx.style().btn_outline.text("Show impact").build_def(ctx);
}
// We'll need to do some pathfinding
Widget::col(vec![
Text::from_multiline(vec![
Line("Predicting impact of your proposal may take a moment."),
Line("The application may freeze up during that time."),
])
.into_widget(ctx),
Line("The app may freeze while calculating this.")
.small()
.into_widget(ctx),
ctx.style().btn_outline.text("Calculate").build_def(ctx),
])
}

View File

@ -68,17 +68,28 @@ impl ShowResults {
Line("Impact prediction").small_heading().into_widget(ctx),
Text::from(Line("This tool starts with a travel demand model, calculates the route every trip takes before and after changes, and displays volumes along roads")).wrap_to_pct(ctx, 20).into_widget(ctx),
Text::from_all(vec![
Line("Red").fg(Color::RED),
Line(" roads have increased volume, and "),
Line("green").fg(Color::GREEN),
Line(" roads have less. Width of the road shows how much baseline traffic it has."),
]).wrap_to_pct(ctx, 20).into_widget(ctx),
"Click a road to see changed routes through it.".text_widget(ctx),
Line("Red").fg(Color::RED),
Line(" roads have increased volume, and "),
Line("green").fg(Color::GREEN),
Line(" roads have less. Width of the road shows how much baseline traffic it has."),
]).wrap_to_pct(ctx, 20).into_widget(ctx),
Text::from(Line("Click a road to see changed routes through it.")).wrap_to_pct(ctx, 20).into_widget(ctx),
Text::from(Line("Results may be wrong for various reasons. Interpret carefully.")).wrap_to_pct(ctx, 20).into_widget(ctx),
// TODO Dropdown for the scenario, and explain its source/limitations
app.session.impact.filters.to_panel(ctx, app),
app.session.impact.compare_counts.get_panel_widget(ctx).named("compare counts"),
ctx.style().btn_outline.text("Save before/after counts to files (JSON)").build_def(ctx),
ctx.style().btn_outline.text("Save before/after counts to files (CSV)").build_def(ctx),
app.session
.impact
.compare_counts
.get_panel_widget(ctx)
.named("compare counts"),
ctx.style()
.btn_outline
.text("Save before/after counts to files (JSON)")
.build_def(ctx),
ctx.style()
.btn_outline
.text("Save before/after counts to files (CSV)")
.build_def(ctx),
]);
let top_panel = crate::components::TopPanel::panel(ctx, app);
let left_panel =