diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index a41c3fd603..df368d6533 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -1490,8 +1490,8 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView, bool activeFram RenderUserMarksLayer(modelView, DepthLayer::RoutingBottomMarkLayer); RenderUserMarksLayer(modelView, DepthLayer::RoutingMarkLayer); RenderUserMarksLayer(modelView, DepthLayer::GuidesBottomMarkLayer); - RenderUserMarksLayer(modelView, DepthLayer::GuidesMarkLayer); - RenderSearchMarksLayer(modelView); + RenderSearchMarksLayer(modelView, DepthLayer::GuidesMarkLayer); + RenderSearchMarksLayer(modelView, DepthLayer::SearchMarkLayer); } if (!HasRouteData()) @@ -1686,16 +1686,16 @@ void FrontendRenderer::RenderUserMarksLayer(ScreenBase const & modelView, DepthL RenderSingleGroup(m_context, modelView, make_ref(group)); } -void FrontendRenderer::RenderSearchMarksLayer(ScreenBase const & modelView) +void FrontendRenderer::RenderSearchMarksLayer(ScreenBase const & modelView, DepthLayer layerId) { - auto & layer = m_layers[static_cast(DepthLayer::SearchMarkLayer)]; + auto & layer = m_layers[static_cast(layerId)]; layer.Sort(nullptr); for (drape_ptr & group : layer.m_renderGroups) { group->SetOverlayVisibility(true); group->Update(modelView); } - RenderUserMarksLayer(modelView, DepthLayer::SearchMarkLayer); + RenderUserMarksLayer(modelView, layerId); } void FrontendRenderer::RenderEmptyFrame() @@ -1860,8 +1860,7 @@ void FrontendRenderer::BuildOverlayTree(ScreenBase const & modelView) DepthLayer::NavigationLayer, DepthLayer::RoutingBottomMarkLayer, DepthLayer::RoutingMarkLayer, - DepthLayer::GuidesBottomMarkLayer, - DepthLayer::GuidesMarkLayer}; + DepthLayer::GuidesBottomMarkLayer}; BeginUpdateOverlayTree(modelView); for (auto const & layerId : layers) { diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index 8a844f457a..3d2f6464c2 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -186,7 +186,7 @@ private: void RenderTransitSchemeLayer(ScreenBase const & modelView); void RenderTrafficLayer(ScreenBase const & modelView); void RenderRouteLayer(ScreenBase const & modelView); - void RenderSearchMarksLayer(ScreenBase const & modelView); + void RenderSearchMarksLayer(ScreenBase const & modelView, DepthLayer layerId); void RenderTransitBackground(); void RenderEmptyFrame(); diff --git a/drape_frontend/message.cpp b/drape_frontend/message.cpp index 5cc8792a8b..607221ac83 100644 --- a/drape_frontend/message.cpp +++ b/drape_frontend/message.cpp @@ -102,6 +102,7 @@ std::string DebugPrint(Message::Type msgType) case Message::Type::NotifyRenderThread: return "NotifyRenderThread"; case Message::Type::NotifyGraphicsReady: return "NotifyGraphicsReady"; case Message::Type::EnableIsolines: return "EnableIsolines"; + case Message::Type::EnableGuides: return "EnableGuides"; } ASSERT(false, ("Unknown message type.")); return "Unknown type"; diff --git a/map/guides_manager.cpp b/map/guides_manager.cpp index 0dcb5b17ba..091080ff8c 100644 --- a/map/guides_manager.cpp +++ b/map/guides_manager.cpp @@ -338,13 +338,28 @@ void GuidesManager::UpdateGuidesMarks() auto es = m_bmManager->GetEditSession(); es.ClearGroup(UserMark::GUIDE_CLUSTER); es.ClearGroup(UserMark::GUIDE); - for (auto & guide : m_guides.m_nodes) + + std::vector> sortedGuides; + sortedGuides.reserve(m_guides.m_nodes.size()); + for (size_t i = 0; i < m_guides.m_nodes.size(); ++i) + sortedGuides.emplace_back(m_screen.GtoP(m_guides.m_nodes[i].m_point), i); + std::sort(sortedGuides.begin(), sortedGuides.end(), + [](std::pair const & lhs, std::pair const & rhs) + { + if (base::AlmostEqualAbs(lhs.first.y, rhs.first.y, 1e-2)) + return lhs.first.x < rhs.first.x; + return lhs.first.y < rhs.first.y; + }); + + float depth = 0.0f; + for (auto & guidePos : sortedGuides) { + auto const & guide = m_guides.m_nodes[guidePos.second]; if (guide.m_sightsCount + guide.m_outdoorCount > 1) { GuidesClusterMark * mark = es.CreateUserMark(guide.m_point); mark->SetGuidesCount(guide.m_sightsCount, guide.m_outdoorCount); - mark->SetIndex(++m_nextMarkIndex); + mark->SetDepth(depth); } else { @@ -353,9 +368,10 @@ void GuidesManager::UpdateGuidesMarks() : GuideMark::Type::Outdoor); mark->SetGuideId(guide.m_guideInfo.m_id); mark->SetIsDownloaded(IsGuideDownloaded(guide.m_guideInfo.m_id)); - mark->SetIndex(++m_nextMarkIndex); + mark->SetDepth(depth); m_shownGuides.insert(guide.m_guideInfo.m_id); } + depth += 1.0f; } UpdateActiveGuide(); } diff --git a/map/guides_manager.hpp b/map/guides_manager.hpp index 037e7e9363..9ee1e9e63a 100644 --- a/map/guides_manager.hpp +++ b/map/guides_manager.hpp @@ -147,8 +147,6 @@ private: BookmarkManager * m_bmManager = nullptr; df::DrapeEngineSafePtr m_drapeEngine; - uint32_t m_nextMarkIndex = 0; - std::unordered_set m_shownGuides; LayersStatistics m_statistics; }; diff --git a/map/guides_marks.cpp b/map/guides_marks.cpp index cc0a32f22a..031acd1aae 100644 --- a/map/guides_marks.cpp +++ b/map/guides_marks.cpp @@ -17,8 +17,8 @@ float constexpr kGuideMarkSize = 26.0f; float constexpr kGuideMarkTextSize = 14.0f; float constexpr kGuideMarkRadius = 4.0f; float constexpr kGuideSelectionWidth = 10.0f; -m2::PointF const kGuideMarkOffset = {0.0f, 2.0}; -m2::PointF const kGuideDownloadedMarkOffset = {1.5, 0.5}; +m2::PointF const kGuideMarkOffset = {0.0f, 2.0f}; +m2::PointF const kGuideDownloadedMarkOffset = {1.5f, 0.5f}; m2::PointF const kGuideClusterTextOffset = {0.0f, kGuideMarkTextSize + kGuideMarkSize / 2.0f}; int constexpr kMinGuideMarkerZoom = 1; @@ -68,10 +68,10 @@ void GuideMark::SetGuideId(std::string guideId) m_guideId = guideId; } -void GuideMark::SetIndex(uint32_t index) +void GuideMark::SetDepth(float depth) { SetDirty(); - m_index = index; + m_depth = depth; } drape_ptr GuideMark::GetSymbolNames() const @@ -90,10 +90,10 @@ GuidesClusterMark::GuidesClusterMark(m2::PointD const & ptOrg) Update(); } -void GuidesClusterMark::SetIndex(uint32_t index) +void GuidesClusterMark::SetDepth(float depth) { SetDirty(); - m_index = index; + m_depth = depth; } void GuidesClusterMark::Update() diff --git a/map/guides_marks.hpp b/map/guides_marks.hpp index 3b4befb891..f26214a358 100644 --- a/map/guides_marks.hpp +++ b/map/guides_marks.hpp @@ -22,16 +22,11 @@ public: void SetGuideId(std::string guideId); std::string GetGuideId() const { return m_guideId; } - void SetIndex(uint32_t index); + void SetDepth(float depth); // df::UserPointMark overrides. - uint32_t GetIndex() const override { return m_index; } + float GetDepth() const override { return m_depth; } df::DepthLayer GetDepthLayer() const override { return df::DepthLayer::GuidesMarkLayer; } - df::SpecialDisplacement GetDisplacement() const override - { - return df::SpecialDisplacement::SpecialModeUserMark; - } - drape_ptr GetSymbolNames() const override; drape_ptr GetSymbolOffsets() const override; bool SymbolIsPOI() const override { return true; } @@ -39,7 +34,7 @@ public: private: void Update(); - uint32_t m_index = 0; + float m_depth = 0.0f; std::string m_guideId; Type m_type = Type::City; @@ -56,19 +51,14 @@ public: void SetGuidesCount(uint32_t cityGuidesCount, uint32_t outdoorGuidesCount); - void SetIndex(uint32_t index); + void SetDepth(float depth); // df::UserPointMark overrides. - uint32_t GetIndex() const override { return m_index; } + float GetDepth() const override { return m_depth; } df::DepthLayer GetDepthLayer() const override { return df::DepthLayer::GuidesMarkLayer; } - df::SpecialDisplacement GetDisplacement() const override - { - return df::SpecialDisplacement::SpecialModeUserMark; - } - + bool SymbolIsPOI() const override { return true; } drape_ptr GetSymbolNames() const override; drape_ptr GetSymbolOffsets() const override; - bool SymbolIsPOI() const override { return true; } bool HasTitlePriority() const override { return true; } drape_ptr GetTitleDecl() const override; @@ -76,6 +66,7 @@ public: private: void Update(); + float m_depth = 0.0f; uint32_t m_index = 0; uint32_t m_cityGuidesCount = 0;