From 868359ba1f2d4b68eecee102c3a768f76892afca Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Thu, 29 Jan 2015 15:31:45 +0300 Subject: [PATCH] Some changes after Colleagues comments --- map/bookmark_manager.cpp | 4 ++-- map/location_state.hpp | 3 +-- map/route_track.cpp | 38 ++++++++++++++++++++------------------ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index 3c2a2d3924..0fd5c49533 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -264,7 +264,7 @@ void BookmarkManager::DrawItems(shared_ptr const & e) const double const visualScale = m_framework.GetVisualScale(); location::RouteMatchingInfo const & matchingInfo = m_framework.GetLocationState()->GetRouteMatchingInfo(); - auto trackUpdateFn = [&matrix, &limitRect, this, drawScale, visualScale, &matchingInfo](Track const * track) + auto trackUpdateFn = [&](Track const * track) { ASSERT(track, ()); if (limitRect.IsIntersect(track->GetLimitRect())) @@ -273,7 +273,7 @@ void BookmarkManager::DrawItems(shared_ptr const & e) const track->DeleteDisplayList(); }; - auto dlUpdateFn = [&matrix, &trackUpdateFn] (BookmarkCategory const * cat) + auto dlUpdateFn = [&trackUpdateFn] (BookmarkCategory const * cat) { if (cat->IsVisible()) { diff --git a/map/location_state.hpp b/map/location_state.hpp index 5fe36331fa..ed0111d0bb 100644 --- a/map/location_state.hpp +++ b/map/location_state.hpp @@ -31,7 +31,6 @@ namespace location size_t m_indexInRoute; bool m_isPositionMatched; - RouteMatchingInfo(RouteMatchingInfo const &) = delete; public: RouteMatchingInfo() : m_matchedPosition(0., 0.), m_indexInRoute(0), m_isPositionMatched(false) {} void SetRouteMatchingInfo(m2::PointD const & matchedPosition, size_t indexInRoute) @@ -41,7 +40,7 @@ namespace location m_isPositionMatched = true; } void ResetRouteMatchingInfo() { m_isPositionMatched = false; } - bool hasRouteMatchingInfo() const { return m_isPositionMatched; } + bool HasRouteMatchingInfo() const { return m_isPositionMatched; } size_t GetIndexInRoute() const { return m_indexInRoute; } m2::PointD GetPosition() const { return m_matchedPosition; } }; diff --git a/map/route_track.cpp b/map/route_track.cpp index 43c71ed867..e1c193dd69 100644 --- a/map/route_track.cpp +++ b/map/route_track.cpp @@ -9,11 +9,24 @@ #include "../indexer/scales.hpp" - -pair shiftArrow(pair const & arrowDirection) +namespace { - return pair(arrowDirection.first - (arrowDirection.second - arrowDirection.first), - arrowDirection.first); + pair shiftArrow(pair const & arrowDirection) + { + return pair(arrowDirection.first - (arrowDirection.second - arrowDirection.first), + arrowDirection.first); + } + + void drawArrowTriangle(graphics::Screen * dlScreen, pair const & arrowDirection, + double arrowWidth, double arrowLength, graphics::Color arrowColor, double arrowDepth) + { + ASSERT(dlScreen, ()); + m2::PointD p1, p2, p3; + + m2::ArrowPoints(arrowDirection.first, arrowDirection.second, arrowWidth, arrowLength, p1, p2, p3); + vector arrow = {p1, p2, p3}; + dlScreen->drawConvexPolygon(&arrow[0], arrow.size(), arrowColor, arrowDepth); + } } bool clipArrowBodyAndGetArrowDirection(vector & ptsTurn, pair & arrowDirection, @@ -113,17 +126,6 @@ bool clipArrowBodyAndGetArrowDirection(vector & ptsTurn, pair const & arrowDirection, - double arrowWidth, double arrowLength, graphics::Color arrowColor, double arrowDepth) -{ - ASSERT(dlScreen, ()); - m2::PointD p1, p2, p3; - - m2::ArrowPoints(arrowDirection.first, arrowDirection.second, arrowWidth, arrowLength, p1, p2, p3); - vector arrow = {p1, p2, p3}; - dlScreen->drawConvexPolygon(&arrow[0], arrow.size(), arrowColor, arrowDepth); -} - void RouteTrack::CreateDisplayListArrows(graphics::Screen * dlScreen, MatrixT const & matrix, double visualScale) const { double const beforeTurn = 13. * visualScale; @@ -175,7 +177,7 @@ void RouteTrack::CreateDisplayList(graphics::Screen * dlScreen, MatrixT const & PolylineD const & fullPoly = GetPolyline(); size_t const formerIndex = m_relevantMatchedInfo.GetIndexInRoute(); - if (matchingInfo.hasRouteMatchingInfo()) + if (matchingInfo.HasRouteMatchingInfo()) m_relevantMatchedInfo = matchingInfo; size_t const currentIndex = m_relevantMatchedInfo.GetIndexInRoute(); @@ -189,7 +191,7 @@ void RouteTrack::CreateDisplayList(graphics::Screen * dlScreen, MatrixT const & auto const curSegIter = fullPoly.Begin() + currentIndex; //the most part of the route and symbols - if (currentIndex == 0 || formerIndex != currentIndex || + if (formerIndex != currentIndex || !HasDisplayList() || isScaleChanged) { DeleteDisplayList(); @@ -220,7 +222,7 @@ void RouteTrack::CreateDisplayList(graphics::Screen * dlScreen, MatrixT const & //closest route segment m_closestSegmentDL = dlScreen->createDisplayList(); dlScreen->setDisplayList(m_closestSegmentDL); - PolylineD closestPoly(m_relevantMatchedInfo.hasRouteMatchingInfo() ? + PolylineD closestPoly(m_relevantMatchedInfo.HasRouteMatchingInfo() ? vector({m_relevantMatchedInfo.GetPosition(), fullPoly.GetPoint(currentIndex + 1)}) : vector({fullPoly.GetPoint(currentIndex), fullPoly.GetPoint(currentIndex + 1)})); PointContainerT pts;