From a14ee872549bb849a257a5ebdea1845ca2d92690 Mon Sep 17 00:00:00 2001 From: ExMix Date: Thu, 11 Sep 2014 15:33:59 +0300 Subject: [PATCH] [core] visualize track --- map/framework.cpp | 5 ++++- map/track.cpp | 10 ++++++++++ map/track.hpp | 29 ++++++++++++++++++++++++----- 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/map/framework.cpp b/map/framework.cpp index 4e2fb66138..aa90106b35 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2001,7 +2001,10 @@ void Framework::InsertRoute(routing::Route const & route) Track track(route.GetPoly()); track.SetName(route.GetName()); track.SetColor(graphics::Color(0, 0xA3,0xFF, 0xFF)); - track.SetWidth(8.0f * GetVisualScale()); + track.SetWidth(4.0f * GetVisualScale()); + track.SetIsMarked(true); + track.SetOutlineWidth(3.0f * GetVisualScale()); + track.SetOutlineColor(graphics::Color::White()); cat->AddTrack(track); Invalidate(); } diff --git a/map/track.cpp b/map/track.cpp index f645f06279..85ec8ab00e 100644 --- a/map/track.cpp +++ b/map/track.cpp @@ -77,6 +77,13 @@ void Track::CreateDisplayList(graphics::Screen * dlScreen, MatrixT const & matri SimplifyDP(pts1.begin(), pts1.end(), math::sqr(m_width), m2::DistanceToLineSquare(), MakeBackInsertFunctor(pts2)); + if (IsMarked()) + { + graphics::Pen::Info outlineInfo(m_outlineColor, m_width + 2 * m_outlineWidth); + uint32_t outlineId = dlScreen->mapInfo(outlineInfo); + dlScreen->drawPath(pts2.data(), pts2.size(), 0, outlineId, graphics::tracksDepth); + } + dlScreen->drawPath(pts2.data(), pts2.size(), 0, resId, graphics::tracksDepth); dlScreen->setDisplayList(0); @@ -124,6 +131,9 @@ void Track::Swap(Track & rhs) swap(m_width, rhs.m_width); swap(m_color, rhs.m_color); swap(m_rect, rhs.m_rect); + swap(m_isMarked, rhs.m_isMarked); + swap(m_outlineColor, rhs.m_outlineColor); + swap(m_outlineWidth, rhs.m_outlineWidth); m_name.swap(rhs.m_name); m_polyline.Swap(rhs.m_polyline); diff --git a/map/track.hpp b/map/track.hpp index d9669fcd63..96425f3613 100644 --- a/map/track.hpp +++ b/map/track.hpp @@ -28,12 +28,18 @@ public: Track() : m_isVisible(true), m_width(5), m_color(graphics::Color::fromARGB(0xFFFF0000)), + m_isMarked(false), + m_outlineWidth(0), + m_outlineColor(graphics::Color::White()), m_dList(0) {} explicit Track(PolylineD const & polyline) : m_isVisible(true), m_width(5), m_color(graphics::Color::fromARGB(0xFFFF0000)), + m_isMarked(false), + m_outlineWidth(0), + m_outlineColor(graphics::Color::White()), m_polyline(polyline), m_dList(0) { @@ -55,11 +61,20 @@ public: bool IsVisible() const { return m_isVisible; } void SetVisible(bool visible) { m_isVisible = visible; } - size_t GetWidth() const { return m_width; } - void SetWidth(size_t width) { m_width = width; } + float GetWidth() const { return m_width; } + void SetWidth(float width) { m_width = width; } - graphics::Color GetColor() const { return m_color; } - void SetColor(graphics::Color color) { m_color = color; } + graphics::Color const & GetColor() const { return m_color; } + void SetColor(graphics::Color const & color) { m_color = color; } + + bool IsMarked() const { return m_isMarked; } + void SetIsMarked(bool isMarked) { m_isMarked = isMarked; } + + float GetOutlineWidth() const { return m_outlineWidth; } + void SetOutlineWidth(float outlineWidth) { m_outlineWidth = outlineWidth; } + + graphics::Color const & GetOutlineColor() { return m_outlineColor; } + void SetOutlineColor(graphics::Color const & outlineColor) { m_outlineColor = outlineColor; } string const & GetName() const { return m_name; } void SetName(string const & name) { m_name = name; } @@ -76,9 +91,13 @@ public: private: bool m_isVisible; string m_name; - size_t m_width; + float m_width; graphics::Color m_color; + bool m_isMarked; + float m_outlineWidth; + graphics::Color m_outlineColor; + PolylineD m_polyline; m2::RectD m_rect;