From a51279bbde10e5d39d1760a36049dd0462a7ca8e Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Thu, 31 Aug 2017 17:51:13 +0300 Subject: [PATCH] Remove the "my position" route mark before inserting of another "my position" mark. --- map/routing_manager.cpp | 7 +++++++ map/routing_mark.cpp | 11 +++++++++++ map/routing_mark.hpp | 1 + 3 files changed, 19 insertions(+) diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index d1d040e85f..41f1ad2104 100644 --- a/map/routing_manager.cpp +++ b/map/routing_manager.cpp @@ -590,6 +590,13 @@ void RoutingManager::AddRoutePoint(RouteMarkData && markData) if (markData.m_pointType == RouteMarkType::Start || markData.m_pointType == RouteMarkType::Finish) routePoints.RemoveRoutePoint(markData.m_pointType); + if (markData.m_isMyPosition) + { + RouteMarkPoint * mark = routePoints.GetMyPositionPoint(); + if (mark != nullptr) + routePoints.RemoveRoutePoint(mark->GetRoutePointType(), mark->GetIntermediateIndex()); + } + markData.m_isVisible = !markData.m_isMyPosition; routePoints.AddRoutePoint(move(markData)); ReorderIntermediatePoints(); diff --git a/map/routing_mark.cpp b/map/routing_mark.cpp index 9550167279..128d2bb171 100644 --- a/map/routing_mark.cpp +++ b/map/routing_mark.cpp @@ -305,6 +305,17 @@ RouteMarkPoint * RoutePointsLayout::GetRoutePoint(RouteMarkType type, size_t int return nullptr; } +RouteMarkPoint * RoutePointsLayout::GetMyPositionPoint() +{ + for (size_t i = 0, sz = m_routeMarks.GetUserMarkCount(); i < sz; ++i) + { + RouteMarkPoint * mark = GetRouteMarkForEdit(i); + if (mark->IsMyPosition()) + return mark; + } + return nullptr; +} + std::vector RoutePointsLayout::GetRoutePoints() { std::vector points; diff --git a/map/routing_mark.hpp b/map/routing_mark.hpp index 40e05b116c..9d14f78e1e 100644 --- a/map/routing_mark.hpp +++ b/map/routing_mark.hpp @@ -88,6 +88,7 @@ public: RouteMarkPoint * AddRoutePoint(RouteMarkData && data); RouteMarkPoint * GetRoutePoint(RouteMarkType type, size_t intermediateIndex = 0); + RouteMarkPoint * GetMyPositionPoint(); std::vector GetRoutePoints(); size_t GetRoutePointsCount() const; bool RemoveRoutePoint(RouteMarkType type, size_t intermediateIndex = 0);