Small steps towards matching more GMNS signals: #626

- toss a loading screen around it
- allow jump to ID in edit mode
- break down failure types more
This commit is contained in:
Dustin Carlino 2021-06-13 11:59:37 -07:00
parent 59597708ec
commit 96aa09edd0
3 changed files with 46 additions and 23 deletions

View File

@ -41,11 +41,8 @@ impl CommonState {
app: &mut App,
ctx_actions: &mut dyn ContextualActions,
) -> Option<Transition> {
if ctx.input.pressed(lctrl(Key::S)) {
app.opts.dev = !app.opts.dev;
}
if ctx.input.pressed(lctrl(Key::J)) {
return Some(Transition::Push(warp::DebugWarp::new_state(ctx)));
if let Some(t) = CommonState::debug_actions(ctx, app) {
return Some(t);
}
// Layers can be launched from many places, many of which don't have a way of getting at
@ -304,6 +301,17 @@ impl CommonState {
pub fn info_panel_open(&self, app: &App) -> Option<ID> {
self.info_panel.as_ref().and_then(|i| i.active_id(app))
}
/// Allow toggling of dev mode and warping to an object by ID.
pub fn debug_actions(ctx: &mut EventCtx, app: &mut App) -> Option<Transition> {
if ctx.input.pressed(lctrl(Key::S)) {
app.opts.dev = !app.opts.dev;
}
if ctx.input.pressed(lctrl(Key::J)) {
return Some(Transition::Push(warp::DebugWarp::new_state(ctx)));
}
None
}
}
// TODO Kinda misnomer

View File

@ -154,6 +154,10 @@ impl State<App> for EditMode {
}
}
if let Some(t) = CommonState::debug_actions(ctx, app) {
return t;
}
ctx.canvas_movement();
// Restrict what can be selected.
if ctx.redo_mouseover() {

View File

@ -115,27 +115,37 @@ pub fn import_all(ctx: &mut EventCtx, app: &mut App, path: &str) -> Box<dyn Stat
})
.collect();
let mut successes = 0;
let mut failures = 0;
let mut failures_no_match = 0;
let mut failures_other = 0;
let mut edits = app.primary.map.get_edits().clone();
for i in all_signals {
match import(&app.primary.map, i, path).and_then(|signal| signal.validate().map(|_| signal))
{
Ok(signal) => {
info!("Success at {}", i);
successes += 1;
edits.commands.push(EditCmd::ChangeIntersection {
i,
old: app.primary.map.get_i_edit(i),
new: EditIntersection::TrafficSignal(signal.export(&app.primary.map)),
});
}
Err(err) => {
error!("Failure at {}: {}", i, err);
failures += 1;
ctx.loading_screen("import signal timing", |_, timer| {
timer.start_iter("import", all_signals.len());
for i in all_signals {
timer.next();
match import(&app.primary.map, i, path)
.and_then(|signal| signal.validate().map(|_| signal))
{
Ok(signal) => {
info!("Success at {}", i);
successes += 1;
edits.commands.push(EditCmd::ChangeIntersection {
i,
old: app.primary.map.get_i_edit(i),
new: EditIntersection::TrafficSignal(signal.export(&app.primary.map)),
});
}
Err(err) => {
error!("Failure at {}: {}", i, err);
if err.to_string().contains("no matches for") {
failures_no_match += 1;
} else {
failures_other += 1;
}
}
}
}
}
});
apply_map_edits(ctx, app, edits);
@ -144,7 +154,8 @@ pub fn import_all(ctx: &mut EventCtx, app: &mut App, path: &str) -> Box<dyn Stat
&format!("Import from {}", path),
vec![
format!("{} traffic signals successfully imported", successes),
format!("{} failures, no changes made", failures),
format!("{} intersections without any data", failures_no_match),
format!("{} other failures", failures_other),
],
)
}