diff --git a/drape_frontend/apply_feature_functors.cpp b/drape_frontend/apply_feature_functors.cpp index 3fdd00e43c..83e4a62d36 100644 --- a/drape_frontend/apply_feature_functors.cpp +++ b/drape_frontend/apply_feature_functors.cpp @@ -9,6 +9,7 @@ #include "poi_symbol_shape.hpp" #include "path_symbol_shape.hpp" #include "circle_shape.hpp" +#include "path_text_shape.hpp" #include "../indexer/drawing_rules.hpp" #include "../indexer/drules_include.hpp" @@ -109,10 +110,12 @@ dp::Anchor GetAnchor(CaptionDefProto const * capRule) } // namespace -BaseApplyFeature::BaseApplyFeature(EngineContext & context, TileKey tileKey, FeatureID const & id) +BaseApplyFeature::BaseApplyFeature(EngineContext & context, TileKey tileKey, + FeatureID const & id, CaptionDescription const & caption) : m_context(context) , m_tileKey(tileKey) , m_id(id) + , m_captions(caption) { } @@ -128,7 +131,7 @@ void BaseApplyFeature::ExtractCaptionParams(CaptionDefProto const * primaryProto params.m_depth = depth; params.m_featureID = m_id; params.m_primaryOffset = GetCaptionOffset(primaryProto); - params.m_primaryText = m_primaryText; + params.m_primaryText = m_captions.GetMainText(); params.m_primaryTextFont = decl; if (secondaryProto) @@ -136,15 +139,16 @@ void BaseApplyFeature::ExtractCaptionParams(CaptionDefProto const * primaryProto FontDecl auxDecl; CaptionDefProtoToFontDecl(secondaryProto, auxDecl); - params.m_secondaryText = m_secondaryText; + params.m_secondaryText = m_captions.GetAuxText(); params.m_secondaryTextFont = auxDecl; } } // ============================================= // -ApplyPointFeature::ApplyPointFeature(EngineContext & context, TileKey tileKey, FeatureID const & id) - : base_t(context, tileKey, id) +ApplyPointFeature::ApplyPointFeature(EngineContext & context, TileKey tileKey, + FeatureID const & id, CaptionDescription const & captions) + : TBase(context, tileKey, id, captions) , m_hasPoint(false) , m_symbolDepth(graphics::minDepth) , m_circleDepth(graphics::minDepth) @@ -225,8 +229,9 @@ void ApplyPointFeature::Finish() // ============================================= // -ApplyAreaFeature::ApplyAreaFeature(EngineContext & context, TileKey tileKey, FeatureID const & id) - : base_t(context, tileKey, id) +ApplyAreaFeature::ApplyAreaFeature(EngineContext & context, TileKey tileKey, + FeatureID const & id, CaptionDescription const & captions) + : TBase(context, tileKey, id, captions) { } @@ -253,13 +258,16 @@ void ApplyAreaFeature::ProcessRule(Stylist::rule_wrapper_t const & rule) m_context.InsertShape(m_tileKey, dp::MovePointer(shape)); } else - base_t::ProcessRule(rule); + TBase::ProcessRule(rule); } // ============================================= // -ApplyLineFeature::ApplyLineFeature(EngineContext & context, TileKey tileKey, FeatureID const & id, double nextModelViewScale) - : base_t(context, tileKey, id), m_nextModelViewScale(nextModelViewScale) +ApplyLineFeature::ApplyLineFeature(EngineContext & context, TileKey tileKey, + FeatureID const & id, CaptionDescription const & captions, + double nextModelViewScale) + : TBase(context, tileKey, id, captions) + , m_nextModelViewScale(nextModelViewScale) { } @@ -290,14 +298,42 @@ bool ApplyLineFeature::HasGeometry() const void ApplyLineFeature::ProcessRule(Stylist::rule_wrapper_t const & rule) { - LineDefProto const * pRule = rule.first->GetLine(); + drule::BaseRule const * pRule = rule.first; float depth = rule.second; - if (pRule != NULL) + //bool isWay = (pRule->GetType() & drule::way) != 0; + CaptionDefProto const * pCaptionRule = pRule->GetCaption(0); + LineDefProto const * pLineRule = pRule->GetLine(); + if (pCaptionRule == NULL && pLineRule == NULL) + return; + + + // TODO Если расскоментить этот код то возникает ASSERT + // в обновлении позиций глифов. Править будет Рома. + +// ASSERT(pCaptionRule == NULL || pLineRule == NULL, ()); +// if (pCaptionRule != NULL && pCaptionRule->height() > 2 && +// !m_primaryText.empty() && isWay) +// { +// FontDecl fontDecl; +// CaptionDefProtoToFontDecl(pCaptionRule, fontDecl); + +// PathTextViewParams params; +// params.m_depth = depth; +// params.m_featureID = m_id; +// params.m_offsetStart = 0; +// params.m_offsetEnd = 300; +// params.m_text = m_primaryText; +// params.m_textFont = fontDecl; + +// m_context.InsertShape(m_tileKey, dp::MovePointer(new PathTextShape(m_path, params))); +// } + + if (pLineRule != NULL) { - if (pRule->has_pathsym()) + if (pLineRule->has_pathsym()) { - PathSymProto const & symRule = pRule->pathsym(); + PathSymProto const & symRule = pLineRule->pathsym(); PathSymbolViewParams params; params.m_depth = depth; params.m_symbolName = symRule.name(); @@ -309,9 +345,9 @@ void ApplyLineFeature::ProcessRule(Stylist::rule_wrapper_t const & rule) } else { - LineViewParams params; - Extract(pRule, params); - params.m_depth = depth; + LineViewParams params; + Extract(pLineRule, params); + params.m_depth = depth; m_context.InsertShape(m_tileKey, dp::MovePointer(new LineShape(m_path, params))); } } diff --git a/drape_frontend/apply_feature_functors.hpp b/drape_frontend/apply_feature_functors.hpp index 9072b02540..024f671cb9 100644 --- a/drape_frontend/apply_feature_functors.hpp +++ b/drape_frontend/apply_feature_functors.hpp @@ -24,10 +24,8 @@ class BaseApplyFeature public: BaseApplyFeature(EngineContext & context, TileKey tileKey, - FeatureID const & id); - - void SetPrimaryText(string const & src) { m_primaryText = src; } - void SetSecondaryText(string const & src) { m_secondaryText = src; } + FeatureID const & id, + CaptionDescription const & captions); protected: void ExtractCaptionParams(CaptionDefProto const * primaryProto, @@ -39,17 +37,17 @@ protected: EngineContext & m_context; TileKey m_tileKey; FeatureID m_id; - string m_primaryText; - string m_secondaryText; + CaptionDescription const & m_captions; }; class ApplyPointFeature : public BaseApplyFeature { - typedef BaseApplyFeature base_t; + typedef BaseApplyFeature TBase; public: ApplyPointFeature(EngineContext & context, TileKey tileKey, - FeatureID const & id); + FeatureID const & id, + CaptionDescription const & captions); void operator()(CoordPointT const & point); void operator()(m2::PointD const & point); @@ -67,13 +65,14 @@ private: class ApplyAreaFeature : public ApplyPointFeature { - typedef ApplyPointFeature base_t; + typedef ApplyPointFeature TBase; public: ApplyAreaFeature(EngineContext & context, TileKey tileKey, - FeatureID const & id); + FeatureID const & id, + CaptionDescription const & captions); - using base_t::operator (); + using TBase::operator (); void operator()(m2::PointD const & p1, m2::PointD const & p2, m2::PointD const & p3); void ProcessRule(Stylist::rule_wrapper_t const & rule); @@ -84,11 +83,12 @@ private: class ApplyLineFeature : public BaseApplyFeature { - typedef BaseApplyFeature base_t; + typedef BaseApplyFeature TBase; public: ApplyLineFeature(EngineContext & context, TileKey tileKey, FeatureID const & id, + CaptionDescription const & captions, double nextModelViewScale); void operator ()(CoordPointT const & point); diff --git a/drape_frontend/rule_drawer.cpp b/drape_frontend/rule_drawer.cpp index 38acf6b5bf..96c3d56f23 100644 --- a/drape_frontend/rule_drawer.cpp +++ b/drape_frontend/rule_drawer.cpp @@ -53,7 +53,7 @@ void RuleDrawer::operator()(FeatureType const & f) if (s.AreaStyleExists()) { - ApplyAreaFeature apply(m_context, m_tileKey, f.GetID()); + ApplyAreaFeature apply(m_context, m_tileKey, f.GetID(), s.GetCaptionDescription()); f.ForEachTriangleRef(apply, m_tileKey.m_zoomLevel); if (s.PointStyleExists()) @@ -64,7 +64,7 @@ void RuleDrawer::operator()(FeatureType const & f) } else if (s.LineStyleExists()) { - ApplyLineFeature apply(m_context, m_tileKey, f.GetID(), m_nextModelViewScale); + ApplyLineFeature apply(m_context, m_tileKey, f.GetID(), s.GetCaptionDescription(), m_nextModelViewScale); f.ForEachPointRef(apply, m_tileKey.m_zoomLevel); if (apply.HasGeometry()) @@ -74,10 +74,9 @@ void RuleDrawer::operator()(FeatureType const & f) else { ASSERT(s.PointStyleExists(), ()); - ApplyPointFeature apply(m_context, m_tileKey, f.GetID()); - apply.SetPrimaryText(s.GetCaptionDescription().GetMainText()); - apply.SetSecondaryText(s.GetCaptionDescription().GetAuxText()); + ApplyPointFeature apply(m_context, m_tileKey, f.GetID(), s.GetCaptionDescription()); f.ForEachPointRef(apply, m_tileKey.m_zoomLevel); + s.ForEachRule(bind(&ApplyPointFeature::ProcessRule, &apply, _1)); apply.Finish(); } diff --git a/drape_frontend/stylist.cpp b/drape_frontend/stylist.cpp index 301d274d08..45b8d9d66d 100644 --- a/drape_frontend/stylist.cpp +++ b/drape_frontend/stylist.cpp @@ -218,6 +218,15 @@ string const & CaptionDescription::GetRoadNumber() const return m_roadNumber; } +string CaptionDescription::GetPathNumber() const +{ + // Always concat names for linear features because we process only one draw rule now. + if (m_mainText.empty()) + return m_mainText; + else + return m_mainText + " " + m_auxText; +} + double CaptionDescription::GetPopulationRank() const { return m_populationRank; diff --git a/drape_frontend/stylist.hpp b/drape_frontend/stylist.hpp index e0d98f6e1d..d3bdf4e168 100644 --- a/drape_frontend/stylist.hpp +++ b/drape_frontend/stylist.hpp @@ -28,6 +28,7 @@ struct CaptionDescription string const & GetMainText() const; string const & GetAuxText() const; string const & GetRoadNumber() const; + string GetPathNumber() const; double GetPopulationRank() const; bool IsNameExists() const;