only draw turn icons in editor mode

This commit is contained in:
Dustin Carlino 2018-08-05 14:17:18 -07:00
parent c7bae2b6ef
commit be4ffc8d31
7 changed files with 43 additions and 62 deletions

View File

@ -1,5 +1,12 @@
# TODO for Phase 1 (Basemap)
- lots more data
- lanes: https://data-seattlecitygis.opendata.arcgis.com/datasets/49d417979fec452981a068ca078e7070_3
- traffic circles: https://data-seattlecitygis.opendata.arcgis.com/datasets/717b10434d4945658355eba78b66971a_6
- https://data-seattlecitygis.opendata.arcgis.com/datasets/sidewalks
- https://data-seattlecitygis.opendata.arcgis.com/datasets/curb-ramps
- high quality thick roads: https://seattlecitygis.maps.arcgis.com/apps/webappviewer/index.html?id=86cb6824307c4d63b8e180ebcff58ce2
- trim buidings and parcels that're nowhere near roads (aka, the bbox is kinda wrong)
- maybe also the time to split into different lane types? what's similar/not between them?

View File

@ -168,9 +168,8 @@ impl SelectionState {
if !relevant_turns.is_empty() {
match current_turn_index {
Some(idx) => {
let turn = map.get_t(relevant_turns[idx % relevant_turns.len()].id);
let draw_turn =
draw_map.get_t(relevant_turns[idx % relevant_turns.len()].id);
let turn = relevant_turns[idx % relevant_turns.len()];
let draw_turn = draw_map.get_t(turn.id);
draw_turn.draw_full(g, cs.get(Colors::Turn));
for t in map.get_turns_in_intersection(turn.parent) {

View File

@ -97,4 +97,11 @@ impl StopSignEditor {
}
}
}
pub fn show_turn_icons(&self, id: IntersectionID) -> bool {
match self {
StopSignEditor::Active(i) => *i == id,
StopSignEditor::Inactive => false,
}
}
}

View File

@ -118,4 +118,14 @@ impl TrafficSignalEditor {
}
}
}
pub fn show_turn_icons(&self, id: IntersectionID) -> bool {
match self {
TrafficSignalEditor::Active {
i,
current_cycle: _,
} => *i == id,
TrafficSignalEditor::Inactive => false,
}
}
}

View File

@ -21,7 +21,6 @@ pub struct DrawMap {
lanes_quadtree: QuadTree<LaneID>,
intersections_quadtree: QuadTree<IntersectionID>,
turn_icons_quadtree: QuadTree<TurnID>,
buildings_quadtree: QuadTree<BuildingID>,
parcels_quadtree: QuadTree<ParcelID>,
}
@ -76,10 +75,6 @@ impl DrawMap {
for i in &intersections {
intersections_quadtree.insert_with_box(i.id, i.get_bbox());
}
let mut turn_icons_quadtree = QuadTree::default(map_bbox);
for t in turns.values() {
turn_icons_quadtree.insert_with_box(t.id, t.get_bbox());
}
let mut buildings_quadtree = QuadTree::default(map_bbox);
for b in &buildings {
buildings_quadtree.insert_with_box(b.id, b.get_bbox());
@ -99,7 +94,6 @@ impl DrawMap {
lanes_quadtree,
intersections_quadtree,
turn_icons_quadtree,
buildings_quadtree,
parcels_quadtree,
},
@ -134,14 +128,6 @@ impl DrawMap {
pub fn edit_remove_turn(&mut self, id: TurnID) {
self.turns.remove(&id);
// TODO remember ItemId instead
let item_id = *self.turn_icons_quadtree
.iter()
.find(|pair| (pair.1).0 == id)
.unwrap()
.0;
self.turn_icons_quadtree.remove(item_id);
}
pub fn edit_add_turn(&mut self, id: TurnID, map: &Map) {
@ -149,8 +135,6 @@ impl DrawMap {
let mut turn_to_lane_offset: HashMap<TurnID, usize> = HashMap::new();
DrawMap::compute_turn_to_lane_offset(&mut turn_to_lane_offset, map.get_l(t.src), map);
let draw_turn = DrawTurn::new(map, t, turn_to_lane_offset[&id]);
self.turn_icons_quadtree
.insert_with_box(id, draw_turn.get_bbox());
self.turns.insert(id, draw_turn);
}
@ -199,16 +183,6 @@ impl DrawMap {
v
}
pub fn get_turn_icons_onscreen(&self, screen_bbox: Rect, hider: &Hider) -> Vec<&DrawTurn> {
let mut v = Vec::new();
for &(id, _, _) in &self.turn_icons_quadtree.query(screen_bbox) {
if hider.show_l(id.src) {
v.push(self.get_t(*id));
}
}
v
}
pub fn get_buildings_onscreen(&self, screen_bbox: Rect, hider: &Hider) -> Vec<&DrawBuilding> {
let mut v = Vec::new();
for &(id, _, _) in &self.buildings_quadtree.query(screen_bbox) {

View File

@ -1,6 +1,5 @@
// Copyright 2018 Google LLC, licensed under http://www.apache.org/licenses/LICENSE-2.0
use aabb_quadtree::geom::Rect;
use colors::{ColorScheme, Colors};
use dimensioned::si;
use ezgui::GfxCtx;
@ -85,11 +84,7 @@ impl DrawTurn {
);
}
// the two below are for the icon
pub fn get_bbox(&self) -> Rect {
geometry::circle_to_bbox(&self.icon_circle)
}
// for the icon
pub fn contains_pt(&self, x: f64, y: f64) -> bool {
let radius = self.icon_circle[2] / 2.0;
geometry::point_in_circle(

View File

@ -49,7 +49,6 @@ pub struct UI {
show_buildings: ToggleableLayer,
show_intersections: ToggleableLayer,
show_parcels: ToggleableLayer,
show_icons: ToggleableLayer,
debug_mode: ToggleableLayer,
// This is a particularly special plugin, since it's always kind of active and other things
@ -110,12 +109,6 @@ impl UI {
Some(MIN_ZOOM_FOR_LANES),
),
show_parcels: ToggleableLayer::new("parcels", Key::D4, "4", Some(MIN_ZOOM_FOR_PARCELS)),
show_icons: ToggleableLayer::new(
"turn icons",
Key::D7,
"7",
Some(MIN_ZOOM_FOR_LANE_MARKERS),
),
debug_mode: ToggleableLayer::new("debug mode", Key::G, "G", None),
current_selection_state: SelectionState::Empty,
@ -161,7 +154,6 @@ impl UI {
self.show_buildings.handle_zoom(old_zoom, new_zoom);
self.show_intersections.handle_zoom(old_zoom, new_zoom);
self.show_parcels.handle_zoom(old_zoom, new_zoom);
self.show_icons.handle_zoom(old_zoom, new_zoom);
self.debug_mode.handle_zoom(old_zoom, new_zoom);
}
@ -188,21 +180,17 @@ impl UI {
}
}
if self.show_icons.is_enabled() {
for t in &self.draw_map
.get_turn_icons_onscreen(screen_bbox, &self.hider)
{
if t.contains_pt(x, y) {
return Some(ID::Turn(t.id));
}
}
}
if self.show_intersections.is_enabled() {
for i in &self.draw_map
.get_intersections_onscreen(screen_bbox, &self.hider)
{
let show_icons = self.show_icons_for(i.id);
for t in &self.map.get_i(i.id).turns {
if show_icons && self.draw_map.get_t(*t).contains_pt(x, y) {
return Some(ID::Turn(*t));
}
for c in &self.sim_ctrl.sim.get_draw_cars_on_turn(*t, &self.map) {
if c.contains_pt(x, y) {
return Some(ID::Car(c.id));
@ -346,6 +334,10 @@ impl UI {
}
ezgui::shift_color(self.cs.get(Colors::Pedestrian), id.0)
}
fn show_icons_for(&self, id: IntersectionID) -> bool {
self.stop_sign_editor.show_turn_icons(id) || self.traffic_signal_editor.show_turn_icons(id)
}
}
impl gui::GUI for UI {
@ -438,7 +430,6 @@ impl gui::GUI for UI {
}
stop_if_done!(self.show_parcels.handle_event(input));
stop_if_done!(self.show_icons.handle_event(input));
stop_if_done!(self.debug_mode.handle_event(input));
stop_if_done!(self.steepness_viz.handle_event(input));
stop_if_done!(self.osm_classifier.handle_event(input));
@ -561,7 +552,13 @@ impl gui::GUI for UI {
.get_intersections_onscreen(screen_bbox, &self.hider)
{
i.draw(g, self.color_intersection(i.id), &self.cs);
let show_icons = self.show_icons_for(i.id);
for t in &self.map.get_i(i.id).turns {
if show_icons {
self.draw_map
.get_t(*t)
.draw_icon(g, self.color_turn_icon(*t), &self.cs);
}
for c in &self.sim_ctrl.sim.get_draw_cars_on_turn(*t, &self.map) {
c.draw(g, self.color_car(c.id));
}
@ -572,14 +569,6 @@ impl gui::GUI for UI {
}
}
if self.show_icons.is_enabled() {
for t in &self.draw_map
.get_turn_icons_onscreen(screen_bbox, &self.hider)
{
t.draw_icon(g, self.color_turn_icon(t.id), &self.cs);
}
}
// Building paths overlap sidewalks, so do these first to not look messy
if self.show_buildings.is_enabled() {
for b in &self.draw_map