From a0ca65e01e70098f0104338c8e898d035bcddc7a Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Fri, 28 Oct 2016 11:36:50 +0300 Subject: Added roads selection to Qt app --- map/framework.cpp | 39 +++++++++++++++++++++++++++++++++++++++ map/framework.hpp | 3 +++ 2 files changed, 42 insertions(+) (limited to 'map') diff --git a/map/framework.cpp b/map/framework.cpp index 32fa8aba04..3276a0fa46 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -13,6 +13,7 @@ #include "routing/road_graph_router.hpp" #include "routing/route.hpp" #include "routing/routing_algorithm.hpp" +#include "routing/routing_helpers.hpp" #include "search/downloader_search_callback.hpp" #include "search/editor_delegate.hpp" @@ -3137,3 +3138,41 @@ bool Framework::GenerateRouteAltitudeChart(uint32_t width, uint32_t height, } return true; } + +namespace +{ + vector colorList = { dp::Color(255, 0, 0, 255), dp::Color(0, 255, 0, 255), dp::Color(0, 0, 255, 255), + dp::Color(255, 255, 0, 255), dp::Color(0, 255, 255, 255), dp::Color(255, 0, 255, 255), + dp::Color(100, 0, 0, 255), dp::Color(0, 100, 0, 255), dp::Color(0, 0, 100, 255), + dp::Color(100, 100, 0, 255), dp::Color(0, 100, 100, 255), dp::Color(100, 0, 100, 255) + }; +} // namespace + +void Framework::VizualizeRoadsInRect(m2::RectD const & rect) +{ + int constexpr kScale = scales::GetUpperScale(); + size_t counter = 0; + m_model.ForEachFeature(rect, [this, &counter, &rect](FeatureType & ft) + { + if (routing::IsRoad(feature::TypesHolder(ft))) + { + bool allPointsOutside = true; + vector points; + ft.ForEachPoint([&points, &rect, &allPointsOutside](m2::PointD const & pt) + { + if (rect.IsPointInside(pt)) + allPointsOutside = false; + points.push_back(pt); + }, kScale); + + if (!allPointsOutside) + { + size_t const colorIndex = counter % colorList.size(); + m_drapeApi.AddLine(strings::to_string(ft.GetID().m_index), + df::DrapeApiLineData(points, colorList[colorIndex]) + .Width(3.0f).ShowPoints(true).ShowId()); + counter++; + } + } + }, kScale); +} diff --git a/map/framework.hpp b/map/framework.hpp index 4e509a0d96..b03c6b0036 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -303,6 +303,9 @@ public: m2::PointD GetSearchMarkSize(SearchMarkType searchMarkType); + // Utilities + void VizualizeRoadsInRect(m2::RectD const & rect); + protected: // search::ViewportSearchCallback::Delegate overrides: void RunUITask(function fn) override { GetPlatform().RunOnGuiThread(move(fn)); } -- cgit v1.2.3