1//! Render static map elements.
23use geom::{Bounds, Distance, Pt2D, Tessellation};
4use map_model::{IntersectionID, Map};
5use widgetry::GfxCtx;
67pub 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};
1314mod area;
15mod building;
16mod intersection;
17mod lane;
18mod map;
19mod parking_lot;
20mod road;
21pub mod traffic_signal;
22mod transit_stop;
23mod turn;
2425pub const BIG_ARROW_THICKNESS: Distance = Distance::const_meters(0.5);
2627pub const OUTLINE_THICKNESS: Distance = Distance::const_meters(0.5);
2829// 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 {
32fn get_id(&self) -> ID;
33// Only traffic signals need UI. :\
34fn 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.
36fn 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.
41fn get_outline(&self, map: &Map) -> Tessellation;
42fn get_bounds(&self, map: &Map) -> Bounds;
43fn contains_pt(&self, pt: Pt2D, map: &Map) -> bool;
44}
4546/// Control how the map is drawn.
47pub struct DrawOptions {
48/// Don't draw the current traffic signal state.
49pub suppress_traffic_signal_details: Vec<IntersectionID>,
50/// Label every building.
51pub label_buildings: bool,
52}
5354impl DrawOptions {
55/// Default options for drawing a map.
56pub fn new() -> DrawOptions {
57 DrawOptions {
58 suppress_traffic_signal_details: Vec::new(),
59 label_buildings: false,
60 }
61 }
62}