map_gui/render/
mod.rs

1//! Render static map elements.
2
3use geom::{Bounds, Distance, Pt2D, Tessellation};
4use map_model::{IntersectionID, Map};
5use widgetry::GfxCtx;
6
7pub use crate::render::area::DrawArea;
8pub use crate::render::building::DrawBuilding;
9pub use crate::render::intersection::{calculate_corners, DrawIntersection};
10pub use crate::render::map::DrawMap;
11pub use crate::render::turn::DrawMovement;
12use crate::{AppLike, ID};
13
14mod area;
15mod building;
16mod intersection;
17mod lane;
18mod map;
19mod parking_lot;
20mod road;
21pub mod traffic_signal;
22mod transit_stop;
23mod turn;
24
25pub const BIG_ARROW_THICKNESS: Distance = Distance::const_meters(0.5);
26
27pub const OUTLINE_THICKNESS: Distance = Distance::const_meters(0.5);
28
29// Does something belong here or as a method on ID? If it ONLY applies to renderable things, then
30// here. For example, trips aren't drawn, so it's meaningless to ask what their bounding box is.
31pub trait Renderable {
32    fn get_id(&self) -> ID;
33    // Only traffic signals need UI. :\
34    fn draw(&self, g: &mut GfxCtx, app: &dyn AppLike, opts: &DrawOptions);
35    // Higher z-ordered objects are drawn later. Default to low so roads at -1 don't vanish.
36    fn get_zorder(&self) -> isize {
37        -5
38    }
39    // This outline is drawn over the base object to show that it's selected. It also represents
40    // the boundaries for quadtrees. This isn't called often; don't worry about caching.
41    fn get_outline(&self, map: &Map) -> Tessellation;
42    fn get_bounds(&self, map: &Map) -> Bounds;
43    fn contains_pt(&self, pt: Pt2D, map: &Map) -> bool;
44}
45
46/// Control how the map is drawn.
47pub struct DrawOptions {
48    /// Don't draw the current traffic signal state.
49    pub suppress_traffic_signal_details: Vec<IntersectionID>,
50    /// Label every building.
51    pub label_buildings: bool,
52}
53
54impl DrawOptions {
55    /// Default options for drawing a map.
56    pub fn new() -> DrawOptions {
57        DrawOptions {
58            suppress_traffic_signal_details: Vec::new(),
59            label_buildings: false,
60        }
61    }
62}