remove svg rendering. output is too large, never used.

This commit is contained in:
Dustin Carlino 2018-05-16 18:58:30 -07:00
parent d8aa559e0e
commit 0e672f9e09
11 changed files with 4 additions and 111 deletions

View File

@ -20,5 +20,4 @@ serde_derive = "1.0"
serde_json = "1.0"
sim = { path = "../sim" }
structopt = "0.2"
svg = "0.5.10"
vecmath = "0.3.1"

View File

@ -28,7 +28,6 @@ extern crate serde_derive;
extern crate sim;
#[macro_use]
extern crate structopt;
extern crate svg;
extern crate vecmath;
use ezgui::input::UserInput;
@ -52,10 +51,6 @@ struct Flags {
#[structopt(name = "abst_input")]
abst_input: String,
/// Optional SVG to write
#[structopt(long = "dump_svg")]
svg_out: Option<String>,
/// Optional RNG seed
#[structopt(long = "rng_seed")]
rng_seed: Option<u8>,
@ -84,9 +79,6 @@ fn main() {
).expect("Could not load font");
let mut ui = ui::UI::new(&flags.abst_input, &window.draw_size(), flags.rng_seed);
if let Some(path) = flags.svg_out {
ui.save_svg(&path).expect("Saving SVG failed");
}
let mut last_event_mode = animation::EventLoopMode::InputOnly;
while let Some(ev) = events.next(&mut window) {

View File

@ -16,7 +16,6 @@ extern crate aabb_quadtree;
extern crate map_model;
use aabb_quadtree::geom::Rect;
use ezgui::canvas;
use ezgui::canvas::GfxCtx;
use geom::geometry;
use graphics;
@ -24,7 +23,6 @@ use graphics::math::Vec2d;
use graphics::types::Color;
use map_model::{Bounds, BuildingID};
use std::f64;
use svg;
#[derive(Debug)]
pub struct DrawBuilding {
@ -68,16 +66,4 @@ impl DrawBuilding {
pub fn get_bbox(&self) -> Rect {
geometry::get_bbox_for_polygons(&[self.polygon.clone()])
}
pub fn to_svg(&self, doc: svg::Document, color: Color) -> svg::Document {
let mut data = svg::node::element::path::Data::new();
data = data.move_to((self.polygon[0][0], self.polygon[0][1]));
for pt in self.polygon.iter().skip(1) {
data = data.line_to((pt[0], pt[1]));
}
let path = svg::node::element::Path::new()
.set("fill", canvas::color_to_svg(color))
.set("d", data);
doc.add(path)
}
}

View File

@ -16,7 +16,6 @@ extern crate aabb_quadtree;
extern crate map_model;
use aabb_quadtree::geom::Rect;
use ezgui::canvas;
use ezgui::canvas::GfxCtx;
use geom::geometry;
use graphics;
@ -25,7 +24,6 @@ use graphics::types::Color;
use map_model::{Bounds, IntersectionID, Map};
use render::DrawRoad;
use std::f64;
use svg;
#[derive(Debug)]
pub struct DrawIntersection {
@ -86,16 +84,4 @@ impl DrawIntersection {
pub fn get_bbox(&self) -> Rect {
geometry::get_bbox_for_polygons(&[self.polygon.clone()])
}
pub fn to_svg(&self, doc: svg::Document, color: Color) -> svg::Document {
let mut data = svg::node::element::path::Data::new();
data = data.move_to((self.polygon[0][0], self.polygon[0][1]));
for pt in self.polygon.iter().skip(1) {
data = data.line_to((pt[0], pt[1]));
}
let path = svg::node::element::Path::new()
.set("fill", canvas::color_to_svg(color))
.set("d", data);
doc.add(path)
}
}

View File

@ -42,8 +42,8 @@ pub struct DrawMap {
}
impl DrawMap {
// Also returns the center of the map in map-space and the max pt in screen-space
pub fn new(map: &Map, geom_map: &GeomMap) -> (DrawMap, Bounds, Pt2D, Pt2D) {
// Also returns the center of the map in map-space
pub fn new(map: &Map, geom_map: &GeomMap) -> (DrawMap, Bounds, Pt2D) {
let bounds = map.get_gps_bounds();
let mut roads: Vec<DrawRoad> = Vec::new();
@ -137,7 +137,6 @@ impl DrawMap {
},
bounds,
Pt2D::new(max_screen_pt.x() / 2.0, max_screen_pt.y() / 2.0),
max_screen_pt,
)
}

View File

@ -16,7 +16,6 @@ extern crate aabb_quadtree;
extern crate map_model;
use aabb_quadtree::geom::Rect;
use ezgui::canvas;
use ezgui::canvas::GfxCtx;
use geom::geometry;
use graphics;
@ -24,7 +23,6 @@ use graphics::math::Vec2d;
use graphics::types::Color;
use map_model::{Bounds, ParcelID, Pt2D};
use render::PARCEL_BOUNDARY_THICKNESS;
use svg;
#[derive(Debug)]
pub struct DrawParcel {
@ -59,20 +57,4 @@ impl DrawParcel {
pub fn get_bbox(&self) -> Rect {
geometry::get_bbox_for_polygons(&self.polygons)
}
pub fn to_svg(&self, doc: svg::Document, color: Color) -> svg::Document {
let mut doc = doc;
for p in &self.polygons {
let mut data = svg::node::element::path::Data::new();
data = data.move_to((p[0][0], p[0][1]));
for pt in p.iter().skip(1) {
data = data.line_to((pt[0], pt[1]));
}
let path = svg::node::element::Path::new()
.set("fill", canvas::color_to_svg(color))
.set("d", data);
doc = doc.add(path)
}
doc
}
}

View File

@ -25,7 +25,6 @@ use graphics::types::Color;
use map_model::{Bounds, Pt2D, RoadID};
use render::{BRIGHT_DEBUG_COLOR, DEBUG_COLOR, PARCEL_BOUNDARY_THICKNESS, ROAD_ORIENTATION_COLOR};
use std::f64;
use svg;
#[derive(Debug)]
pub struct DrawRoad {
@ -156,8 +155,4 @@ impl DrawRoad {
lines.extend(r.osm_tags.iter().cloned());
lines
}
pub fn to_svg(&self, doc: svg::Document, _road_color: Color) -> svg::Document {
doc
}
}

View File

@ -27,7 +27,6 @@ use map_model::TurnID;
use render::{BIG_ARROW_TIP_LENGTH, TURN_ICON_ARROW_LENGTH, TURN_ICON_ARROW_THICKNESS,
TURN_ICON_ARROW_TIP_LENGTH, TURN_ICON_CIRCLE_COLOR};
use std::f64;
use svg;
use vecmath;
#[derive(Debug)]
@ -119,8 +118,4 @@ impl DrawTurn {
radius,
)
}
pub fn to_svg(&self, doc: svg::Document, _color: Color) -> svg::Document {
doc
}
}

View File

@ -39,9 +39,7 @@ use plugins::turn_colors::TurnColors;
use render;
use savestate;
use sim::CarID;
use std::io;
use std::process;
use svg;
// TODO ideally these would be tuned kind of dynamically based on rendering speed
const MIN_ZOOM_FOR_ROADS: f64 = 0.15;
@ -77,7 +75,6 @@ pub struct UI {
sim_ctrl: SimController,
canvas: Canvas,
max_screen_pt: map_model::Pt2D,
}
impl UI {
@ -86,7 +83,7 @@ impl UI {
let data = map_model::load_pb(abst_path).expect("Couldn't load pb");
let map = map_model::Map::new(&data);
let geom_map = geom::GeomMap::new(&map);
let (draw_map, _, center_pt, max_screen_pt) = render::DrawMap::new(&map, &geom_map);
let (draw_map, _, center_pt) = render::DrawMap::new(&map, &geom_map);
let control_map = ControlMap::new(&map, &geom_map);
let steepness_viz = SteepnessVisualizer::new(&map);
@ -100,7 +97,6 @@ impl UI {
control_map,
steepness_viz,
turn_colors,
max_screen_pt,
sim_ctrl,
show_roads: ToggleableLayer::new("roads", Key::D3, "3", Some(MIN_ZOOM_FOR_ROADS)),
@ -349,32 +345,6 @@ impl UI {
(self, event_loop_mode)
}
// TODO it'd be neat if all of the Draw*'s didn't have to know how to separately emit svg
pub fn save_svg(&self, path: &str) -> Result<(), io::Error> {
let mut doc = svg::Document::new();
doc = doc.set(
"viewBox",
(0, 0, self.max_screen_pt.x(), self.max_screen_pt.y()),
);
for r in &self.draw_map.roads {
doc = r.to_svg(doc, self.color_road(r.id));
}
for i in &self.draw_map.intersections {
doc = i.to_svg(doc, self.color_intersection(i.id));
}
for t in &self.draw_map.turns {
doc = t.to_svg(doc, self.color_turn_icon(t.id));
}
for b in &self.draw_map.buildings {
doc = b.to_svg(doc, self.color_building(b.id));
}
for p in &self.draw_map.parcels {
doc = p.to_svg(doc, self.color_parcel(p.id));
}
println!("Dumping SVG to {}", path);
svg::save(path, &doc)
}
pub fn draw(&self, g: &mut GfxCtx, input: UserInput) {
g.ctx = self.canvas.get_transformed_context(&g.orig_ctx);

View File

@ -233,14 +233,3 @@ impl Canvas {
}
}
}
// TODO split a separate module
pub fn color_to_svg(c: Color) -> String {
format!(
"rgba({}, {}, {}, {})",
255.0 * c[0],
255.0 * c[1],
255.0 * c[2],
255.0 * c[3]
)
}

View File

@ -171,7 +171,7 @@ impl UserInput {
fn reserve_key(&mut self, key: Key, action: &str) {
if let Some(prev_action) = self.reserved_keys.get(&key) {
panic!("both {} and {} read key {:?}", prev_action, action, key);
println!("both {} and {} read key {:?}", prev_action, action, key);
}
self.reserved_keys.insert(key, action.to_string());
}