From 18fbed10e6a7f6d013a8acbb8a7e077206da7a21 Mon Sep 17 00:00:00 2001 From: rachytski Date: Fri, 25 May 2012 23:44:51 +0400 Subject: [PATCH] added hitTest and roughHitTest to OverlayElement. --- yg/overlay_element.cpp | 16 ++++++++++++++++ yg/overlay_element.hpp | 2 ++ 2 files changed, 18 insertions(+) diff --git a/yg/overlay_element.cpp b/yg/overlay_element.cpp index 20f1785673..1df59188fc 100644 --- a/yg/overlay_element.cpp +++ b/yg/overlay_element.cpp @@ -139,4 +139,20 @@ namespace yg } return m_roughBoundRect; } + + bool OverlayElement::hitTest(m2::PointD const & pt) const + { + vector const & rects = boundRects(); + + for (vector::const_iterator it = rects.begin(); it != rects.end(); ++it) + if (it->IsPointInside(pt)) + return true; + + return false; + } + + bool OverlayElement::roughHitTest(m2::PointD const & pt) const + { + return roughBoundRect().IsPointInside(pt); + } } diff --git a/yg/overlay_element.hpp b/yg/overlay_element.hpp index 7dfc514939..c956bd2824 100644 --- a/yg/overlay_element.hpp +++ b/yg/overlay_element.hpp @@ -78,6 +78,8 @@ namespace yg void setIsVisible(bool flag); m2::RectD const & roughBoundRect() const; + bool hitTest(m2::PointD const & pt) const; + bool roughHitTest(m2::PointD const & pt) const; virtual void offset(m2::PointD const & offs); };