From 5dbdde53e3b4fa3e176c2bc3272e7f534690df9f Mon Sep 17 00:00:00 2001 From: Konstantin Pastbin Date: Thu, 17 Aug 2023 20:38:21 +0300 Subject: [PATCH] [drape] Remove hardcoded navigation mode pathtexts' and shields' priorities Signed-off-by: Konstantin Pastbin --- drape_frontend/apply_feature_functors.cpp | 43 +++-------------------- drape_frontend/apply_feature_functors.hpp | 1 + drape_frontend/rule_drawer.cpp | 1 + 3 files changed, 7 insertions(+), 38 deletions(-) diff --git a/drape_frontend/apply_feature_functors.cpp b/drape_frontend/apply_feature_functors.cpp index 23036021df..bce01b94a9 100644 --- a/drape_frontend/apply_feature_functors.cpp +++ b/drape_frontend/apply_feature_functors.cpp @@ -217,36 +217,12 @@ m2::PointF GetOffset(int offsetX, int offsetY) return { static_cast(offsetX * vs), static_cast(offsetY * vs) }; } -// TODO : review following exceptions for navigation mode priorities. -// Shields and highway pathtexts could be made the highest in the prios.txt file directly. uint16_t CalculateNavigationPoiPriority() { // All navigation POI have maximum priority in navigation mode. return std::numeric_limits::max(); } -uint16_t CalculateNavigationRoadShieldPriority() -{ - // Road shields have less priority than navigation POI. - static uint16_t constexpr kMask = ~static_cast(0xFF); - uint16_t priority = CalculateNavigationPoiPriority(); - return priority & kMask; -} - -uint16_t CalculateNavigationPathTextPriority(uint32_t textIndex) -{ - // Path texts have more priority than road shields in navigation mode. - static uint16_t constexpr kMask = ~static_cast(0xFF); - uint16_t priority = CalculateNavigationPoiPriority(); - priority &= kMask; - - uint8_t constexpr kMaxTextIndex = std::numeric_limits::max() - 1; - if (textIndex > kMaxTextIndex) - textIndex = kMaxTextIndex; - priority |= static_cast(textIndex); - return priority; -} - bool IsSymbolRoadShield(ftypes::RoadShield const & shield) { return shield.m_type == ftypes::RoadShieldType::US_Interstate || @@ -831,10 +807,12 @@ void ApplyLineFeatureGeometry::ProcessLineRule(Stylist::TRuleWrapper const & rul if (!m_smooth) { + // A line crossing the tile several times will be split in several parts. m_clippedSplines = m2::ClipSplineByRect(m_tileRect, m_spline); } else { + // Isolines smoothing. m2::GuidePointsForSmooth guidePointsForSmooth; std::vector> clippedPaths; auto extTileRect = m_tileRect; @@ -1042,15 +1020,6 @@ void ApplyLineFeatureAdditional::GetRoadShieldsViewParams(ref_ptr texMng, params.m_auxText = m_captions.GetAuxText(); params.m_textFont = fontDecl; params.m_baseGtoPScale = m_currentScaleGtoP; - bool const navigationEnabled = GetStyleReader().IsCarNavigationStyle(); - if (navigationEnabled) - params.m_specialDisplacement = SpecialDisplacement::SpecialMode; uint32_t textIndex = kPathTextBaseTextIndex; for (auto const & spline : m_clippedSplines) { PathTextViewParams p = params; - if (navigationEnabled) - p.m_specialPriority = CalculateNavigationPathTextPriority(textIndex); auto shape = make_unique_dp(spline, p, m_tileKey, textIndex); if (!shape->CalculateLayout(texMng)) continue; + // Position shields inbetween captions. + // If there is only one center position then the shield and the caption will compete for it. if (m_shieldRule != nullptr && !roadShields.empty()) CalculateRoadShieldPositions(shape->GetOffsets(), spline, shieldPositions); @@ -1122,6 +1088,7 @@ void ApplyLineFeatureAdditional::Finish(ref_ptr texMng, } else if (m_shieldRule != nullptr && !roadShields.empty()) { + // Position shields without captions. for (auto const & spline : m_clippedSplines) { double const pixelLength = 300.0 * vs; diff --git a/drape_frontend/apply_feature_functors.hpp b/drape_frontend/apply_feature_functors.hpp index b4fb8ee527..103a2cf2b4 100644 --- a/drape_frontend/apply_feature_functors.hpp +++ b/drape_frontend/apply_feature_functors.hpp @@ -177,6 +177,7 @@ private: #endif }; +// Process pathtext and shield drules. Operates on metalines usually. class ApplyLineFeatureAdditional : public BaseApplyFeature { using TBase = BaseApplyFeature; diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp index 2bd428f6fa..4a0ca4147a 100644 --- a/drape_frontend/rule_drawer.cpp +++ b/drape_frontend/rule_drawer.cpp @@ -438,6 +438,7 @@ void RuleDrawer::ProcessPointStyle(FeatureType & f, Stylist const & s, TInsertSh return; DepthLayer depthLayer = DepthLayer::OverlayLayer; + // TODO: review necessity of the DepthLayer::NavigationLayer. ATM its used for speed cameras icons only. if (isSpeedCamera) depthLayer = DepthLayer::NavigationLayer;