fix contains_pt signature

This commit is contained in:
Dustin Carlino 2018-08-09 10:49:20 -07:00
parent 9e2ac24b0c
commit 0caa8969dd
8 changed files with 25 additions and 24 deletions

View File

@ -52,8 +52,8 @@ impl DrawBuilding {
}
}
pub fn contains_pt(&self, x: f64, y: f64) -> bool {
self.fill_polygon.contains_pt(Pt2D::new(x, y))
pub fn contains_pt(&self, pt: Pt2D) -> bool {
self.fill_polygon.contains_pt(pt)
}
pub fn tooltip_lines(&self, map: &Map) -> Vec<String> {

View File

@ -81,8 +81,8 @@ impl DrawIntersection {
}
}
pub fn contains_pt(&self, x: f64, y: f64) -> bool {
self.polygon.contains_pt(Pt2D::new(x, y))
pub fn contains_pt(&self, pt: Pt2D) -> bool {
self.polygon.contains_pt(pt)
}
pub fn get_bbox(&self) -> Rect {

View File

@ -121,8 +121,8 @@ impl DrawLane {
get_bbox(&self.polygon.get_bounds())
}
pub fn lane_contains_pt(&self, x: f64, y: f64) -> bool {
self.polygon.contains_pt(Pt2D::new(x, y))
pub fn contains_pt(&self, pt: Pt2D) -> bool {
self.polygon.contains_pt(pt)
}
pub fn tooltip_lines(&self, map: &map_model::Map) -> Vec<String> {

View File

@ -34,8 +34,6 @@ impl DrawParcel {
}
}
//pub fn contains_pt(&self, x: f64, y: f64) -> bool {}
pub fn get_bbox(&self) -> Rect {
get_bbox(&self.fill_polygon.get_bounds())
}

View File

@ -3,6 +3,7 @@
use colors::{ColorScheme, Colors};
use dimensioned::si;
use ezgui::GfxCtx;
use geom::Pt2D;
use graphics;
use graphics::math::Vec2d;
use graphics::types::Color;
@ -85,11 +86,11 @@ impl DrawTurn {
}
// for the icon
pub fn contains_pt(&self, x: f64, y: f64) -> bool {
pub fn contains_pt(&self, pt: Pt2D) -> bool {
let radius = self.icon_circle[2] / 2.0;
geometry::point_in_circle(
x,
y,
pt.x(),
pt.y(),
[self.icon_circle[0] + radius, self.icon_circle[1] + radius],
radius,
)

View File

@ -10,6 +10,7 @@ use ezgui;
use ezgui::canvas::Canvas;
use ezgui::input::UserInput;
use ezgui::{GfxCtx, ToggleableLayer};
use geom::Pt2D;
use graphics::types::Color;
use gui;
use map_model;
@ -159,6 +160,7 @@ impl UI {
fn mouseover_something(&self) -> Option<ID> {
let (x, y) = self.canvas.get_cursor_in_map_space();
let pt = Pt2D::new(x, y);
let screen_bbox = self.canvas.get_screen_bbox();
@ -169,12 +171,12 @@ impl UI {
};
for l in &lanes_onscreen {
for c in &self.sim_ctrl.sim.get_draw_cars_on_lane(l.id, &self.map) {
if c.contains_pt(x, y) {
if c.contains_pt(pt) {
return Some(ID::Car(c.id));
}
}
for p in &self.sim_ctrl.sim.get_draw_peds_on_lane(l.id, &self.map) {
if p.contains_pt(x, y) {
if p.contains_pt(pt) {
return Some(ID::Pedestrian(p.id));
}
}
@ -187,23 +189,23 @@ impl UI {
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) {
if show_icons && self.draw_map.get_t(*t).contains_pt(pt) {
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) {
if c.contains_pt(pt) {
return Some(ID::Car(c.id));
}
}
for p in &self.sim_ctrl.sim.get_draw_peds_on_turn(*t, &self.map) {
if p.contains_pt(x, y) {
if p.contains_pt(pt) {
return Some(ID::Pedestrian(p.id));
}
}
}
if i.contains_pt(x, y) {
if i.contains_pt(pt) {
return Some(ID::Intersection(i.id));
}
}
@ -211,7 +213,7 @@ impl UI {
if self.show_lanes.is_enabled() {
for l in &lanes_onscreen {
if l.lane_contains_pt(x, y) {
if l.contains_pt(pt) {
return Some(ID::Lane(l.id));
}
}
@ -221,7 +223,7 @@ impl UI {
for b in &self.draw_map
.get_buildings_onscreen(screen_bbox, &self.hider)
{
if b.contains_pt(x, y) {
if b.contains_pt(pt) {
return Some(ID::Building(b.id));
}
}

View File

@ -90,8 +90,8 @@ impl DrawCar {
}
}
pub fn contains_pt(&self, x: f64, y: f64) -> bool {
self.polygon.contains_pt(Pt2D::new(x, y))
pub fn contains_pt(&self, pt: Pt2D) -> bool {
self.polygon.contains_pt(pt)
}
pub fn focus_pt(&self) -> Pt2D {

View File

@ -44,10 +44,10 @@ impl DrawPedestrian {
}
}
pub fn contains_pt(&self, x: f64, y: f64) -> bool {
pub fn contains_pt(&self, pt: Pt2D) -> bool {
geometry::point_in_circle(
x,
y,
pt.x(),
pt.y(),
[self.circle[0] + RADIUS, self.circle[1] + RADIUS],
RADIUS,
)