From 538aed57a1cedb2847fb9dc6255620f803a3d995 Mon Sep 17 00:00:00 2001 From: Daria Volvenkova Date: Mon, 30 Mar 2020 13:25:22 +0300 Subject: [PATCH] [bookmarks] Set min visible zoom for track markers. --- map/bookmark_manager.cpp | 5 +++++ map/framework.cpp | 2 +- map/track_mark.cpp | 9 +++++++-- map/track_mark.hpp | 3 +++ 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/map/bookmark_manager.cpp b/map/bookmark_manager.cpp index d9019a4904..6fac44cd48 100644 --- a/map/bookmark_manager.cpp +++ b/map/bookmark_manager.cpp @@ -1224,6 +1224,10 @@ void BookmarkManager::SetTrackSelectionInfo(TrackSelectionInfo const & trackSele { trackSelectionMark = es.CreateUserMark(trackSelectionInfo.m_trackPoint); trackSelectionMark->SetTrackId(trackSelectionInfo.m_trackId); + + auto track = GetTrack(trackSelectionInfo.m_trackId); + auto const zoom = std::min(df::GetDrawTileScale(track->GetLimitRect()), 14); + trackSelectionMark->SetMinVisibleZoom(zoom); } else { @@ -1243,6 +1247,7 @@ void BookmarkManager::SetDefaultTrackSelection(kml::TrackId trackId, bool showIn auto track = GetTrack(trackId); CHECK(track != nullptr, ()); + CHECK(track->IsInteractive(), ()); auto const & points = track->GetPointsWithAltitudes(); auto const pt = points[points.size() / 2].GetPoint(); diff --git a/map/framework.cpp b/map/framework.cpp index a2ad87532f..a2b89dcb05 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2750,7 +2750,7 @@ UserMark const * Framework::FindUserMarkInTapPosition(place_page::BuildInfo cons if (buildInfo.m_source != place_page::BuildInfo::Source::User) return df::TapInfo::GetPreciseSearchRect(buildInfo.m_mercator, kEps); - if (type == UserMark::Type::BOOKMARK) + if (type == UserMark::Type::BOOKMARK || type == UserMark::Type::TRACK_INFO) return df::TapInfo::GetBookmarkSearchRect(buildInfo.m_mercator, m_currentModelView); if (type == UserMark::Type::ROUTING || type == UserMark::Type::ROAD_WARNING) diff --git a/map/track_mark.cpp b/map/track_mark.cpp index 05f7447212..e960238b9f 100644 --- a/map/track_mark.cpp +++ b/map/track_mark.cpp @@ -6,7 +6,6 @@ namespace { std::string const kTrackDeselectedSymbolName = "track_marker_deselected"; std::string const kInfoSignSymbolName = "infosign"; -int constexpr kMinVisibleZoom = 1; int constexpr kMinInfoVisibleZoom = 1; } // namespace @@ -68,6 +67,12 @@ void TrackSelectionMark::SetIsVisible(bool isVisible) m_isVisible = isVisible; } +void TrackSelectionMark::SetMinVisibleZoom(int zoom) +{ + SetDirty(); + m_minVisibleZoom = zoom; +} + void TrackSelectionMark::SetTrackId(kml::TrackId trackId) { m_trackId = trackId; @@ -86,7 +91,7 @@ void TrackSelectionMark::SetMyPositionDistance(double distance) drape_ptr TrackSelectionMark::GetSymbolNames() const { auto symbol = make_unique_dp(); - symbol->insert(std::make_pair(kMinVisibleZoom, kTrackDeselectedSymbolName)); + symbol->insert(std::make_pair(m_minVisibleZoom, kTrackDeselectedSymbolName)); return symbol; } diff --git a/map/track_mark.hpp b/map/track_mark.hpp index 47f8945818..a484d54d53 100644 --- a/map/track_mark.hpp +++ b/map/track_mark.hpp @@ -43,6 +43,7 @@ public: void SetPosition(m2::PointD const & ptOrg); void SetIsVisible(bool isVisible); + void SetMinVisibleZoom(int zoom); void SetTrackId(kml::TrackId trackId); kml::TrackId GetTrackId() const { return m_trackId; } @@ -55,11 +56,13 @@ public: // df::UserPointMark overrides. drape_ptr GetSymbolNames() const override; + int GetMinZoom() const override { return m_minVisibleZoom; } bool IsVisible() const override { return m_isVisible; } static std::string GetInitialSymbolName(); private: + int m_minVisibleZoom = 1; double m_distance = 0.0; double m_myPositionDistance = kInvalidDistance; kml::TrackId m_trackId = kml::kInvalidTrackId;