diff options
author | Daria Volvenkova <d.volvenkova@corp.mail.ru> | 2017-08-31 17:51:13 +0300 |
---|---|---|
committer | Roman Kuznetsov <r.kuznetsow@gmail.com> | 2017-08-31 18:22:22 +0300 |
commit | 4cfe4604c68ed70400192ffb0ddb2e35d8f61652 (patch) | |
tree | bede8a94c246549bb4b1c29f3fb9a0c5b30edb33 | |
parent | 4b2064f98d535083917459916e4d81fe32828896 (diff) |
Remove the "my position" route mark before inserting of another "my position" mark.beta-986
-rw-r--r-- | map/routing_manager.cpp | 7 | ||||
-rw-r--r-- | map/routing_mark.cpp | 11 | ||||
-rw-r--r-- | map/routing_mark.hpp | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/map/routing_manager.cpp b/map/routing_manager.cpp index f8d52fd255..72abae8360 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<RouteMarkPoint *> RoutePointsLayout::GetRoutePoints() { std::vector<RouteMarkPoint *> 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<RouteMarkPoint *> GetRoutePoints(); size_t GetRoutePointsCount() const; bool RemoveRoutePoint(RouteMarkType type, size_t intermediateIndex = 0); |