From aba7acba7aa63b6d8c4dce549d7f86244a7a0866 Mon Sep 17 00:00:00 2001 From: dabreegster Date: Sat, 24 Oct 2020 20:34:02 +0000 Subject: [PATCH] deploy: 614c744dc9deb713abf77387b20043545dbe8be4 --- rustdoc/game/all.html | 2 +- rustdoc/game/app/struct.App.html | 4 +- rustdoc/game/devtools/osm_viewer/index.html | 4 +- .../game/devtools/osm_viewer/sidebar-items.js | 2 +- .../osm_viewer/struct.BusinessSearch.html | 24 ++ .../devtools/osm_viewer/struct.Viewer.html | 9 +- .../built_info/constant.BUILT_TIME_UTC.html | 2 +- .../implementors/core/marker/trait.Freeze.js | 2 +- .../implementors/core/marker/trait.Send.js | 2 +- .../implementors/core/marker/trait.Sync.js | 2 +- .../implementors/core/marker/trait.Unpin.js | 2 +- .../std/panic/trait.RefUnwindSafe.js | 2 +- .../std/panic/trait.UnwindSafe.js | 2 +- rustdoc/search-index.js | 2 +- rustdoc/src/game/devtools/osm_viewer.rs.html | 210 +++++++++++++++++- .../game-e788b46a21eaee2a/out/built.rs.html | 2 +- 16 files changed, 250 insertions(+), 23 deletions(-) create mode 100644 rustdoc/game/devtools/osm_viewer/struct.BusinessSearch.html diff --git a/rustdoc/game/all.html b/rustdoc/game/all.html index 99930a203c..11b535def4 100644 --- a/rustdoc/game/all.html +++ b/rustdoc/game/all.html @@ -1,4 +1,4 @@ List of all items in this crate

[] - List of all items

Structs

Enums

Traits

Functions

Typedefs

Constants

\ No newline at end of file + List of all items

Structs

Enums

Traits

Functions

Typedefs

Constants

\ No newline at end of file diff --git a/rustdoc/game/app/struct.App.html b/rustdoc/game/app/struct.App.html index 4d375b1ac2..b2d3d8741a 100644 --- a/rustdoc/game/app/struct.App.html +++ b/rustdoc/game/app/struct.App.html @@ -58,8 +58,8 @@

impl State<App> for Viewer[src]

impl State<App> for Viewer[src]

impl State<App> for IsochroneViewer[src]

[][src]Module game::devtools::osm_viewer

Structs

+
BusinessSearch
Viewer
\ No newline at end of file diff --git a/rustdoc/game/devtools/osm_viewer/sidebar-items.js b/rustdoc/game/devtools/osm_viewer/sidebar-items.js index bd9f9e866b..7bf3956361 100644 --- a/rustdoc/game/devtools/osm_viewer/sidebar-items.js +++ b/rustdoc/game/devtools/osm_viewer/sidebar-items.js @@ -1 +1 @@ -initSidebarItems({"struct":[["Viewer",""]]}); \ No newline at end of file +initSidebarItems({"struct":[["BusinessSearch",""],["Viewer",""]]}); \ No newline at end of file diff --git a/rustdoc/game/devtools/osm_viewer/struct.BusinessSearch.html b/rustdoc/game/devtools/osm_viewer/struct.BusinessSearch.html new file mode 100644 index 0000000000..d6d8159c9e --- /dev/null +++ b/rustdoc/game/devtools/osm_viewer/struct.BusinessSearch.html @@ -0,0 +1,24 @@ +game::devtools::osm_viewer::BusinessSearch - Rust

[][src]Struct game::devtools::osm_viewer::BusinessSearch

struct BusinessSearch {
+    counts: Counter<String>,
+    show: BTreeSet<String>,
+    highlight: Drawable,
+}

+ Fields

counts: Counter<String>show: BTreeSet<String>highlight: Drawable

Implementations

impl BusinessSearch[src]

fn new(ctx: &mut EventCtx<'_>, app: &App) -> BusinessSearch[src]

fn update(&mut self, panel: &Panel)[src]

fn render(&mut self, ctx: &mut EventCtx<'_>, app: &App) -> Widget[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Downcast for T where
    T: Any

impl<T> DowncastSync for T where
    T: Send + Sync + Any

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

+

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

+

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

+

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

\ No newline at end of file diff --git a/rustdoc/game/devtools/osm_viewer/struct.Viewer.html b/rustdoc/game/devtools/osm_viewer/struct.Viewer.html index d049cc8ea7..b140994232 100644 --- a/rustdoc/game/devtools/osm_viewer/struct.Viewer.html +++ b/rustdoc/game/devtools/osm_viewer/struct.Viewer.html @@ -1,11 +1,12 @@ -game::devtools::osm_viewer::Viewer - Rust

[][src]Struct game::devtools::osm_viewer::Viewer

pub struct Viewer {
+game::devtools::osm_viewer::Viewer - Rust

[][src]Struct game::devtools::osm_viewer::Viewer

pub struct Viewer {
     top_panel: Panel,
     fixed_object_outline: Option<Drawable>,
     minimap: Minimap,
+    businesses: Option<BusinessSearch>,
 }

- Fields

top_panel: Panelfixed_object_outline: Option<Drawable>minimap: Minimap

Implementations

impl Viewer[src]

pub fn new(ctx: &mut EventCtx<'_>, app: &mut App) -> Box<dyn State<App>>[src]

fn update_tags(&mut self, ctx: &mut EventCtx<'_>, app: &App)[src]

Trait Implementations

impl State<App> for Viewer[src]

-use abstutil::prettyprint_usize;
+use std::collections::BTreeSet;
+
+use abstutil::{prettyprint_usize, Counter};
 use geom::ArrowCap;
 use map_model::osm;
 use widgetry::{
-    lctrl, Btn, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key, Line, Outcome,
-    Panel, State, Text, TextExt, VerticalAlignment, Widget,
+    lctrl, Btn, Checkbox, Color, Drawable, EventCtx, GeomBatch, GfxCtx, HorizontalAlignment, Key,
+    Line, Outcome, Panel, State, Text, TextExt, VerticalAlignment, Widget,
 };
 
 use crate::app::App;
@@ -304,6 +407,7 @@
     top_panel: Panel,
     fixed_object_outline: Option<Drawable>,
     minimap: Minimap,
+    businesses: Option<BusinessSearch>,
 }
 
 impl Viewer {
@@ -313,6 +417,7 @@
         Box::new(Viewer {
             fixed_object_outline: None,
             minimap: Minimap::new(ctx, app, false),
+            businesses: None,
             top_panel: Panel::new(Widget::col(vec![
                 Widget::row(vec![
                     Line("OpenStreetMap viewer").small_heading().draw(ctx),
@@ -341,9 +446,10 @@
                 "Zoom in and select something to begin"
                     .draw_text(ctx)
                     .named("tags"),
+                Widget::horiz_separator(ctx, 0.3),
+                Btn::text_bg2("Search for businesses").build_def(ctx, Key::Tab),
             ]))
             .aligned(HorizontalAlignment::Left, VerticalAlignment::Top)
-            .exact_size_percent(35, 80)
             .build(ctx),
         })
     }
@@ -546,6 +652,24 @@
                         ],
                     ));
                 }
+                "Search for businesses" => {
+                    let mut businesses = BusinessSearch::new(ctx, app);
+                    let search = businesses.render(ctx, app);
+                    self.businesses = Some(businesses);
+                    self.top_panel.replace(
+                        ctx,
+                        "Search for businesses",
+                        search.named("Search for businesses"),
+                    );
+                }
+                "Hide business search" => {
+                    self.businesses = None;
+                    self.top_panel.replace(
+                        ctx,
+                        "Search for businesses",
+                        Btn::text_bg2("Search for businesses").build_def(ctx, Key::Tab),
+                    );
+                }
                 x => {
                     if let Some(url) = x.strip_prefix("open ") {
                         open_browser(url.to_string());
@@ -554,6 +678,16 @@
                     }
                 }
             },
+            Outcome::Changed => {
+                let mut b = self.businesses.as_mut().unwrap();
+                b.update(&self.top_panel);
+                let search = b.render(ctx, app);
+                self.top_panel.replace(
+                    ctx,
+                    "Search for businesses",
+                    search.named("Search for businesses"),
+                );
+            }
             _ => {}
         }
 
@@ -566,6 +700,74 @@
         if let Some(ref d) = self.fixed_object_outline {
             g.redraw(d);
         }
+        if let Some(ref b) = self.businesses {
+            g.redraw(&b.highlight);
+        }
+    }
+}
+
+struct BusinessSearch {
+    counts: Counter<String>,
+    show: BTreeSet<String>,
+    highlight: Drawable,
+}
+
+impl BusinessSearch {
+    fn new(ctx: &mut EventCtx, app: &App) -> BusinessSearch {
+        let mut counts = Counter::new();
+        for b in app.primary.map.all_buildings() {
+            for (_, amenity) in &b.amenities {
+                counts.inc(amenity.clone());
+            }
+        }
+        let show = counts.borrow().keys().cloned().collect();
+
+        BusinessSearch {
+            counts,
+            show,
+            highlight: ctx.upload(GeomBatch::new()),
+        }
+    }
+
+    fn update(&mut self, panel: &Panel) {
+        self.show.clear();
+        for amenity in self.counts.borrow().keys() {
+            if panel.is_checked(amenity) {
+                self.show.insert(amenity.clone());
+            }
+        }
+    }
+
+    // Returns the panel and also updates the highlighted buildings
+    fn render(&mut self, ctx: &mut EventCtx, app: &App) -> Widget {
+        let mut batch = GeomBatch::new();
+
+        let mut col = Vec::new();
+        col.push(Btn::text_bg2("Hide business search").build_def(ctx, Key::Tab));
+        col.push(
+            format!("{} businesses total", prettyprint_usize(self.counts.sum())).draw_text(ctx),
+        );
+        for (amenity, cnt) in self.counts.borrow() {
+            col.push(Checkbox::custom_checkbox(
+                ctx,
+                amenity,
+                vec![Line(format!("{}: {}", amenity, prettyprint_usize(*cnt)))],
+                None,
+                self.show.contains(amenity),
+            ));
+
+            if self.show.contains(amenity) {
+                for b in app.primary.map.all_buildings() {
+                    if b.amenities.iter().any(|(_, category)| category == amenity) {
+                        batch.push(Color::RED, b.polygon.clone());
+                    }
+                }
+            }
+        }
+
+        self.highlight = ctx.upload(batch);
+
+        Widget::col(col)
     }
 }
 
diff --git a/rustdoc/src/game/home/runner/work/abstreet/abstreet/target/debug/build/game-e788b46a21eaee2a/out/built.rs.html b/rustdoc/src/game/home/runner/work/abstreet/abstreet/target/debug/build/game-e788b46a21eaee2a/out/built.rs.html index f4958874ce..dd53e9b1e0 100644 --- a/rustdoc/src/game/home/runner/work/abstreet/abstreet/target/debug/build/game-e788b46a21eaee2a/out/built.rs.html +++ b/rustdoc/src/game/home/runner/work/abstreet/abstreet/target/debug/build/game-e788b46a21eaee2a/out/built.rs.html @@ -112,7 +112,7 @@ /// The output of `rustdoc -V` pub const RUSTDOC_VERSION: &str = "rustdoc 1.47.0 (18bf6b4f0 2020-10-07)"; /// The built-time in RFC2822, UTC -pub const BUILT_TIME_UTC: &str = "Sat, 24 Oct 2020 19:42:12 +0000"; +pub const BUILT_TIME_UTC: &str = "Sat, 24 Oct 2020 20:31:23 +0000"; /// The target architecture, given by `cfg!(target_arch)`. pub const CFG_TARGET_ARCH: &str = "x86_64"; /// The endianness, given by `cfg!(target_endian)`.