mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-12-28 08:53:26 +03:00
never draw turn icons for SharedSidewalkCorners. remove a field from RenderingHints accordingly.
This commit is contained in:
parent
5d7769694d
commit
1c5d3f6bbf
@ -8,7 +8,7 @@ use crate::ui::{ShowEverything, UI};
|
||||
use abstutil::Timer;
|
||||
use ezgui::{Color, EventCtx, EventLoopMode, GfxCtx, Key, Text, Wizard, WrappedWizard};
|
||||
use map_model::{
|
||||
IntersectionID, Lane, LaneID, LaneType, Map, MapEdits, Road, TurnID, TurnPriority,
|
||||
IntersectionID, Lane, LaneID, LaneType, Map, MapEdits, Road, TurnID, TurnPriority, TurnType,
|
||||
};
|
||||
use std::collections::{BTreeSet, HashMap};
|
||||
|
||||
@ -431,14 +431,13 @@ pub fn apply_map_edits(ui: &mut UI, ctx: &mut EventCtx, edits: MapEdits) {
|
||||
);
|
||||
}
|
||||
for t in turns_added {
|
||||
ui.primary.draw_map.turns.insert(
|
||||
t,
|
||||
DrawTurn::new(
|
||||
&ui.primary.map,
|
||||
ui.primary.map.get_t(t),
|
||||
turn_to_lane_offset[&t],
|
||||
),
|
||||
);
|
||||
let turn = ui.primary.map.get_t(t);
|
||||
if turn.turn_type != TurnType::SharedSidewalkCorner {
|
||||
ui.primary.draw_map.turns.insert(
|
||||
t,
|
||||
DrawTurn::new(&ui.primary.map, turn, turn_to_lane_offset[&t]),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,13 +25,6 @@ pub struct TrafficSignalEditor {
|
||||
impl TrafficSignalEditor {
|
||||
pub fn new(id: IntersectionID, ctx: &mut EventCtx, ui: &mut UI) -> TrafficSignalEditor {
|
||||
ui.hints.suppress_traffic_signal_details = Some(id);
|
||||
for t in ui.primary.map.get_turns_in_intersection(id) {
|
||||
// TODO bit weird, now looks like there's missing space between some icons. Do
|
||||
// we ever need to have an icon for SharedSidewalkCorner?
|
||||
if t.turn_type == TurnType::SharedSidewalkCorner {
|
||||
ui.hints.hide_turn_icons.insert(t.id);
|
||||
}
|
||||
}
|
||||
|
||||
let diagram_top_left = ctx.input.set_mode("Traffic Signal Editor", &ctx.canvas);
|
||||
TrafficSignalEditor {
|
||||
@ -145,7 +138,6 @@ impl TrafficSignalEditor {
|
||||
if ctx.input.modal_action("quit") {
|
||||
// Reset hints
|
||||
ui.hints.suppress_traffic_signal_details = None;
|
||||
ui.hints.hide_turn_icons.clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -7,7 +7,7 @@ use map_model::raw_data::StableRoadID;
|
||||
use map_model::{AreaID, BuildingID, BusStopID, IntersectionID, LaneID, Map, RoadID, TurnID};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use sim::{AgentID, CarID, GetDrawAgents, PedestrianID, Sim, TripID};
|
||||
use std::collections::{BTreeMap, HashMap, HashSet};
|
||||
use std::collections::{BTreeMap, HashMap};
|
||||
use std::io::Error;
|
||||
|
||||
#[derive(Clone, Copy, Hash, PartialEq, Eq, Debug, PartialOrd, Ord)]
|
||||
@ -230,7 +230,6 @@ impl ID {
|
||||
|
||||
pub struct RenderingHints {
|
||||
pub suppress_traffic_signal_details: Option<IntersectionID>,
|
||||
pub hide_turn_icons: HashSet<TurnID>,
|
||||
}
|
||||
|
||||
// TODO move to render module
|
||||
|
@ -15,7 +15,7 @@ use ezgui::{Color, Drawable, Prerender};
|
||||
use geom::{Bounds, Duration, FindClosest, Polygon};
|
||||
use map_model::{
|
||||
AreaID, BuildingID, BusStopID, DirectedRoadID, IntersectionID, Lane, LaneID, Map, RoadID,
|
||||
Traversable, Turn, TurnID, LANE_THICKNESS,
|
||||
Traversable, Turn, TurnID, TurnType, LANE_THICKNESS,
|
||||
};
|
||||
use std::borrow::Borrow;
|
||||
use std::cell::RefCell;
|
||||
@ -84,13 +84,16 @@ impl DrawMap {
|
||||
for l in map.all_lanes() {
|
||||
DrawMap::compute_turn_to_lane_offset(&mut turn_to_lane_offset, l, map);
|
||||
}
|
||||
assert_eq!(turn_to_lane_offset.len(), map.all_turns().len());
|
||||
|
||||
timer.start_iter("make DrawTurns", map.all_turns().len());
|
||||
let mut turns: HashMap<TurnID, DrawTurn> = HashMap::new();
|
||||
for t in map.all_turns().values() {
|
||||
timer.next();
|
||||
turns.insert(t.id, DrawTurn::new(map, t, turn_to_lane_offset[&t.id]));
|
||||
// There's never a reason to draw these icons; the turn priority is only ever Priority,
|
||||
// since they can't conflict with anything.
|
||||
if t.turn_type != TurnType::SharedSidewalkCorner {
|
||||
turns.insert(t.id, DrawTurn::new(map, t, turn_to_lane_offset[&t.id]));
|
||||
}
|
||||
}
|
||||
|
||||
timer.start_iter("make DrawIntersections", map.all_intersections().len());
|
||||
@ -238,6 +241,7 @@ impl DrawMap {
|
||||
let mut pair: (Vec<&Turn>, Vec<&Turn>) = map
|
||||
.get_turns_from_lane(l.id)
|
||||
.iter()
|
||||
.filter(|t| t.turn_type != TurnType::SharedSidewalkCorner)
|
||||
.partition(|t| t.id.parent == l.dst_i);
|
||||
|
||||
// Sort the turn icons by angle.
|
||||
|
@ -77,10 +77,6 @@ impl Renderable for DrawTurn {
|
||||
}
|
||||
|
||||
fn draw(&self, g: &mut GfxCtx, opts: RenderOptions, ctx: &DrawCtx) {
|
||||
if ctx.hints.hide_turn_icons.contains(&self.id) {
|
||||
return;
|
||||
}
|
||||
|
||||
g.draw_circle(
|
||||
ctx.cs.get_def("turn icon circle", Color::grey(0.3)),
|
||||
&self.icon_circle,
|
||||
|
@ -7,10 +7,10 @@ use abstutil;
|
||||
use abstutil::MeasureMemory;
|
||||
use ezgui::{Canvas, Color, EventCtx, GfxCtx, Prerender};
|
||||
use geom::{Bounds, Circle, Distance, Duration, Polygon};
|
||||
use map_model::{BuildingID, IntersectionID, LaneID, Map, Traversable};
|
||||
use map_model::{BuildingID, IntersectionID, LaneID, Map, Traversable, TurnType};
|
||||
use serde_derive::{Deserialize, Serialize};
|
||||
use sim::{GetDrawAgents, Sim, SimFlags};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::collections::HashMap;
|
||||
use structopt::StructOpt;
|
||||
|
||||
// TODO Collapse stuff!
|
||||
@ -52,7 +52,6 @@ impl UI {
|
||||
cs,
|
||||
hints: RenderingHints {
|
||||
suppress_traffic_signal_details: None,
|
||||
hide_turn_icons: HashSet::new(),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -263,7 +262,9 @@ impl UI {
|
||||
let lane = map.get_l(id);
|
||||
if show_turn_icons_for == Some(lane.dst_i) {
|
||||
for (t, _) in map.get_next_turns_and_lanes(id, lane.dst_i) {
|
||||
turn_icons.push(Box::new(draw_map.get_t(t.id)));
|
||||
if t.turn_type != TurnType::SharedSidewalkCorner {
|
||||
turn_icons.push(Box::new(draw_map.get_t(t.id)));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO Bug: pedestrians on front paths aren't selectable.
|
||||
|
Loading…
Reference in New Issue
Block a user