Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--graphics/overlay_renderer.cpp2
-rw-r--r--graphics/overlay_renderer.hpp2
-rw-r--r--indexer/drawing_rule_def.hpp2
-rw-r--r--indexer/feature.cpp15
-rw-r--r--indexer/feature.hpp1
-rw-r--r--indexer/feature_visibility.cpp37
-rw-r--r--indexer/feature_visibility.hpp13
-rw-r--r--map/draw_processor.cpp109
-rw-r--r--map/drawer.cpp14
-rw-r--r--map/drawer.hpp16
-rw-r--r--map/feature_styler.cpp112
-rw-r--r--map/feature_styler.hpp44
-rw-r--r--map/map.pro2
13 files changed, 200 insertions, 169 deletions
diff --git a/graphics/overlay_renderer.cpp b/graphics/overlay_renderer.cpp
index 9e8ecdad0d..e30efae526 100644
--- a/graphics/overlay_renderer.cpp
+++ b/graphics/overlay_renderer.cpp
@@ -56,7 +56,7 @@ namespace graphics
void OverlayRenderer::drawCircle(m2::PointD const & pt,
graphics::Circle::Info const & ci,
EPosition pos,
- int depth)
+ double depth)
{
CircleElement::Params params;
diff --git a/graphics/overlay_renderer.hpp b/graphics/overlay_renderer.hpp
index 10bb891cc2..05aafdf5bb 100644
--- a/graphics/overlay_renderer.hpp
+++ b/graphics/overlay_renderer.hpp
@@ -41,7 +41,7 @@ namespace graphics
void drawCircle(m2::PointD const & pt,
Circle::Info const & ci,
EPosition pos,
- int depth);
+ double depth);
/// drawing straight text
void drawText(FontDesc const & fontDesc,
diff --git a/indexer/drawing_rule_def.hpp b/indexer/drawing_rule_def.hpp
index 385320e2f8..3276506e57 100644
--- a/indexer/drawing_rule_def.hpp
+++ b/indexer/drawing_rule_def.hpp
@@ -34,7 +34,7 @@ namespace drule
/// geo type of rule - can be one combined of ...
enum rule_geo_t { node = 1, way = 2 };
- int const layer_base_priority = 2000;
+ double const layer_base_priority = 2000;
void MakeUnique(vector<Key> & keys);
void SortByScaleTypeDepth(vector<Key> & keys);
diff --git a/indexer/feature.cpp b/indexer/feature.cpp
index dfb406a894..f5fc4f555e 100644
--- a/indexer/feature.cpp
+++ b/indexer/feature.cpp
@@ -311,21 +311,6 @@ uint32_t FeatureType::GetPopulation() const
return (r == 0 ? 1 : static_cast<uint32_t>(pow(1.1, r)));
}
-double FeatureType::GetPopulationDrawRank() const
-{
- uint32_t const n = GetPopulation();
- if (n == 1) return 0.0;
-
- // Do not return rank for countries.
- if (feature::UsePopulationRank(m_Types, m_Types + GetTypesCount()))
- {
- double const upperBound = 3.0E6;
- return min(upperBound, static_cast<double>(n)) / upperBound;
- }
- else
- return 0.0;
-}
-
namespace
{
class DoCalcDistance
diff --git a/indexer/feature.hpp b/indexer/feature.hpp
index a9c3a3b761..1ff1d5deac 100644
--- a/indexer/feature.hpp
+++ b/indexer/feature.hpp
@@ -243,7 +243,6 @@ public:
uint8_t GetRank() const;
uint32_t GetPopulation() const;
- double GetPopulationDrawRank() const;
inline string GetRoadNumber() const { return m_Params.ref; }
diff --git a/indexer/feature_visibility.cpp b/indexer/feature_visibility.cpp
index 5e88bb51cc..0ecaeeb698 100644
--- a/indexer/feature_visibility.cpp
+++ b/indexer/feature_visibility.cpp
@@ -404,43 +404,6 @@ pair<int, int> GetDrawableScaleRangeForRules(FeatureBase const & f, int rules)
return GetDrawableScaleRangeForRules(TypesHolder(f), rules);
}
-bool UsePopulationRank(uint32_t type)
-{
- class CheckerT
- {
- uint32_t m_types[3];
-
- public:
- CheckerT()
- {
- Classificator & c = classif();
-
- vector<string> vec;
- vec.push_back("place");
- vec.push_back("city");
- m_types[0] = c.GetTypeByPath(vec);
-
- vec.push_back("capital");
- m_types[1] = c.GetTypeByPath(vec);
-
- vec.clear();
- vec.push_back("place");
- vec.push_back("town");
- m_types[2] = c.GetTypeByPath(vec);
- }
-
- bool IsMyType(uint32_t t) const
- {
- uint32_t const * e = m_types + ARRAY_SIZE(m_types);
- return (find(m_types, e, t) != e);
- }
- };
-
- static CheckerT checker;
- return (checker.IsMyType(type));
-}
-
-
void TypeSetChecker::SetType(StringT * beg, StringT * end)
{
m_type = classif().GetTypeByPath(vector<string>(beg, end));
diff --git a/indexer/feature_visibility.hpp b/indexer/feature_visibility.hpp
index d5c1ca0586..bc1ad86bd2 100644
--- a/indexer/feature_visibility.hpp
+++ b/indexer/feature_visibility.hpp
@@ -57,19 +57,6 @@ namespace feature
pair<int, bool> GetDrawRule(FeatureBase const & f, int level,
vector<drule::Key> & keys, string & names);
- bool UsePopulationRank(uint32_t type);
-
- template <class IterT>
- inline bool UsePopulationRank(IterT beg, IterT end)
- {
- while (beg != end)
- {
- if (UsePopulationRank(*beg++))
- return true;
- }
- return false;
- }
-
/// Used to check whether user types belong to particular classificator set.
class TypeSetChecker
{
diff --git a/map/draw_processor.cpp b/map/draw_processor.cpp
index 678c7fc83b..0e6fb9452c 100644
--- a/map/draw_processor.cpp
+++ b/map/draw_processor.cpp
@@ -1,6 +1,8 @@
#include "draw_processor.hpp"
#include "drawer.hpp"
+#include "feature_styler.hpp"
+
#include "../platform/preferred_languages.hpp"
#include "../geometry/screenbase.hpp"
@@ -222,22 +224,6 @@ namespace fwork
GetDrawer()->SetScale(m_zoom);
}
- namespace
- {
- struct less_depth
- {
- bool operator() (di::DrawRule const & r1, di::DrawRule const & r2) const
- {
- return (r1.m_depth < r2.m_depth);
- }
- };
- }
-
- void DrawProcessor::PreProcessKeys(vector<drule::Key> & keys) const
- {
- drule::MakeUnique(keys);
- }
-
#define GET_POINTS(f, for_each_fun, fun, assign_fun) \
{ \
f.for_each_fun(fun, m_zoom); \
@@ -253,84 +239,39 @@ namespace fwork
if (m_paintEvent->isCancelled())
throw redraw_operation_cancelled();
- // get drawing rules
- vector<drule::Key> keys;
- string names; // for debug use only, in release it's empty
- pair<int, bool> type = feature::GetDrawRule(f, m_zoom, keys, names);
+ feature::StylesContainer styles;
+ styles.GetStyles(f, m_zoom);
- if (keys.empty())
- {
- // Index can pass here invisible features.
- // During indexing, features are placed at first visible scale bucket.
- // At higher scales it can become invisible - it depends on classificator.
+ if (styles.empty())
return true;
- }
- if (type.second)
+ // Draw coastlines features only once.
+ if (styles.m_isCoastline)
{
- // Draw coastlines features only once.
- string s1, s2;
- f.GetPreferredDrawableNames(s1, s2);
- if (!m_coasts.insert(s1).second)
+ if (!m_coasts.insert(styles.m_primaryText).second)
return true;
}
else
m_hasNonCoast = true;
- // remove duplicating identical drawing keys
- PreProcessKeys(keys);
+ size_t count = styles.m_count;
- // get drawing rules for the m_keys array
- size_t const count = keys.size();
#ifdef PROFILER_DRAWING
m_drawCount += count;
#endif
- buffer_vector<di::DrawRule, 16> rules;
- rules.resize(count);
-
- int layer = f.GetLayer();
- bool isTransparent = false;
- if (layer == feature::LAYER_TRANSPARENT_TUNNEL)
- {
- layer = 0;
- isTransparent = true;
- }
-
- for (size_t i = 0; i < count; ++i)
- {
- int depth = keys[i].m_priority;
- if (layer != 0)
- depth = (layer * drule::layer_base_priority) + (depth % drule::layer_base_priority);
-
- rules[i] = di::DrawRule(drule::rules().Find(keys[i]), depth, isTransparent);
- }
-
- sort(rules.begin(), rules.end(), less_depth());
-
- string defaultName, intName;
- f.GetPreferredDrawableNames(defaultName, intName);
-
- // draw country names and capitals on native language only
- int const worldZoom = 5;
- if (m_zoom <= worldZoom && !intName.empty())
- {
- defaultName.swap(intName);
- intName.clear();
- }
-
scoped_ptr<di::DrawInfo> ptr(new di::DrawInfo(
- defaultName,
- intName,
- f.GetRoadNumber(),
- (m_zoom > worldZoom) ? f.GetPopulationDrawRank() : 0.0));
+ styles.m_primaryText,
+ styles.m_secondaryText,
+ styles.m_refText,
+ styles.m_popRank)); // FIXME
Drawer * pDrawer = GetDrawer();
using namespace get_pts;
bool isExist = false;
- switch (type.first)
+ switch (styles.m_geometryType)
{
case feature::GEOM_POINT:
{
@@ -356,14 +297,11 @@ namespace fwork
functor_t fun(p);
GET_POINTS(f, ForEachTriangleExRef, fun, assign_area)
{
- // if area feature has any line-drawing-rules, than draw it like line
- for (size_t i = 0; i < keys.size(); ++i)
- if (keys[i].m_type == drule::line)
- goto draw_line;
- break;
+ // continue rendering as line if feature has linear styles too
+ if (!styles.m_hasLineStyles)
+ break;
}
}
- draw_line:
case feature::GEOM_LINE:
{
typedef filter_screenpts_adapter<path_points> functor_t;
@@ -371,13 +309,14 @@ namespace fwork
p.m_convertor = &m_convertor;
p.m_rect = &m_rect;
- if (!ptr->m_name.empty())
+ if (styles.m_hasPathText)
{
uint8_t fontSize = 0;
- for (size_t i = 0; i < count; ++i)
+ for (size_t i = 0; i < count; i++)
{
- if (!pDrawer->filter_text_size(rules[i].m_rule))
- fontSize = max(fontSize, pDrawer->get_text_font_size(rules[i].m_rule));
+ if (!pDrawer->filter_text_size(styles.m_rules[i].m_rule))
+ fontSize = max(fontSize, pDrawer->get_text_font_size(styles.m_rules[i].m_rule));
+
}
if (fontSize != 0)
@@ -391,7 +330,7 @@ namespace fwork
f.ForEachPointRef(fun, m_zoom);
- textLength += 50;
+ textLength += 30;
if ((fun.IsExist()) && (fun.m_length > textLength))
{
@@ -410,7 +349,7 @@ namespace fwork
}
if (isExist)
- pDrawer->Draw(ptr.get(), rules.data(), count, f.GetID());
+ pDrawer->Draw(ptr.get(), styles.m_rules.data(), count, f.GetID());
return true;
}
diff --git a/map/drawer.cpp b/map/drawer.cpp
index 4820e1508a..9a923f42f8 100644
--- a/map/drawer.cpp
+++ b/map/drawer.cpp
@@ -106,13 +106,13 @@ void Drawer::onSize(int w, int h)
void Drawer::drawSymbol(m2::PointD const & pt,
string const & symbolName,
graphics::EPosition pos,
- int depth)
+ double depth)
{
m_pScreen->drawSymbol(pt, symbolName, pos, depth);
}
void Drawer::drawCircle(m2::PointD const & pt, rule_ptr_t pRule,
- graphics::EPosition pos, int depth, FeatureID const & id)
+ graphics::EPosition pos, double depth, FeatureID const & id)
{
graphics::Circle::Info ci;
ConvertStyle(pRule->GetCircle(), m_visualScale, ci);
@@ -123,7 +123,7 @@ void Drawer::drawCircle(m2::PointD const & pt, rule_ptr_t pRule,
void Drawer::drawSymbol(m2::PointD const & pt,
rule_ptr_t pRule,
graphics::EPosition pos,
- int depth,
+ double depth,
FeatureID const & id)
{
graphics::Icon::Info info;
@@ -191,7 +191,7 @@ void Drawer::drawPath(di::PathInfo const & info, di::DrawRule const * rules, siz
m_pScreen->drawPath(&info.m_path[0], info.m_path.size(), -info.GetOffset(), rules[i].GetID(ThreadSlot()), rules[i].m_depth);
}
-void Drawer::drawArea(vector<m2::PointD> const & pts, rule_ptr_t pRule, int depth)
+void Drawer::drawArea(vector<m2::PointD> const & pts, rule_ptr_t pRule, double depth)
{
// DO NOT cache 'id' in pRule, because one rule can use in drawPath and drawArea.
// Leave CBaseRule::m_id for drawPath. mapColor working fast enough.
@@ -222,7 +222,7 @@ bool Drawer::filter_text_size(rule_ptr_t pRule) const
}
void Drawer::drawText(m2::PointD const & pt, di::DrawInfo const * pInfo, rule_ptr_t pRule,
- graphics::EPosition pos, int depth, FeatureID const & id)
+ graphics::EPosition pos, double depth, FeatureID const & id)
{
graphics::FontDesc font;
ConvertStyle(pRule->GetCaption(0), m_visualScale, font);
@@ -240,7 +240,7 @@ void Drawer::drawText(m2::PointD const & pt, di::DrawInfo const * pInfo, rule_pt
depth, true, true);
}
-bool Drawer::drawPathText(di::PathInfo const & info, di::DrawInfo const * pInfo, rule_ptr_t pRule, int depth)
+bool Drawer::drawPathText(di::PathInfo const & info, di::DrawInfo const * pInfo, rule_ptr_t pRule, double depth)
{
graphics::FontDesc font;
ConvertStyle(pRule->GetCaption(0), m_visualScale, font);
@@ -326,7 +326,7 @@ void Drawer::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size_t
for (size_t i = 0; i < count; ++i)
{
rule_ptr_t pRule = rules[i].m_rule;
- int const depth = rules[i].m_depth;
+ double const depth = rules[i].m_depth;
bool const isCaption = pRule->GetCaption(0) != 0;
bool const hasSymbol = pRule->GetSymbol() != 0;
diff --git a/map/drawer.hpp b/map/drawer.hpp
index 3c58ca2f24..30199cccac 100644
--- a/map/drawer.hpp
+++ b/map/drawer.hpp
@@ -54,11 +54,11 @@ namespace di
typedef drule::BaseRule const * rule_ptr_t;
rule_ptr_t m_rule;
- int m_depth;
+ double m_depth;
bool m_transparent;
DrawRule() : m_rule(0) {}
- DrawRule(rule_ptr_t p, int d, bool tr) : m_rule(p), m_depth(d), m_transparent(tr) {}
+ DrawRule(rule_ptr_t p, double d, bool tr) : m_rule(p), m_depth(d), m_transparent(tr) {}
uint32_t GetID(size_t threadSlot) const;
void SetID(size_t threadSlot, uint32_t id) const;
@@ -81,15 +81,15 @@ class Drawer
protected:
void drawSymbol(m2::PointD const & pt, rule_ptr_t pRule,
- graphics::EPosition pos, int depth, FeatureID const & id);
+ graphics::EPosition pos, double depth, FeatureID const & id);
void drawCircle(m2::PointD const & pt, rule_ptr_t pRule,
- graphics::EPosition pos, int depth, FeatureID const & id);
+ graphics::EPosition pos, double depth, FeatureID const & id);
void drawPath(di::PathInfo const & info, di::DrawRule const * rules, size_t count);
- void drawArea(vector<m2::PointD> const & pts, rule_ptr_t pRule, int depth);
+ void drawArea(vector<m2::PointD> const & pts, rule_ptr_t pRule, double depth);
void drawText(m2::PointD const & pt, di::DrawInfo const * pInfo, rule_ptr_t pRule,
- graphics::EPosition pos, int depth, FeatureID const & id);
- bool drawPathText(di::PathInfo const & info, di::DrawInfo const * pInfo, rule_ptr_t pRule, int depth);
+ graphics::EPosition pos, double depth, FeatureID const & id);
+ bool drawPathText(di::PathInfo const & info, di::DrawInfo const * pInfo, rule_ptr_t pRule, double depth);
void drawPathNumber(di::PathInfo const & path, di::DrawInfo const * pInfo);
typedef shared_ptr<graphics::gl::BaseTexture> texture_t;
@@ -105,7 +105,7 @@ public:
Drawer(Params const & params = Params());
- void drawSymbol(m2::PointD const & pt, string const & symbolName, graphics::EPosition pos, int depth);
+ void drawSymbol(m2::PointD const & pt, string const & symbolName, graphics::EPosition pos, double depth);
void beginFrame();
void endFrame();
diff --git a/map/feature_styler.cpp b/map/feature_styler.cpp
new file mode 100644
index 0000000000..f4cdeb4b48
--- /dev/null
+++ b/map/feature_styler.cpp
@@ -0,0 +1,112 @@
+#include "feature_styler.hpp"
+
+
+namespace
+{
+ struct less_depth
+ {
+ bool operator() (di::DrawRule const & r1, di::DrawRule const & r2) const
+ {
+ return (r1.m_depth < r2.m_depth);
+ }
+ };
+}
+
+
+
+namespace feature
+{
+ StylesContainer::StylesContainer() {}
+
+ StylesContainer::~StylesContainer()
+ {
+ //for_each(m_rules.begin(), m_rules.end(), DeleteFunctor());
+ }
+
+ void StylesContainer::GetStyles(FeatureType const & f, int const zoom)
+ {
+ // do special stuff
+ vector<drule::Key> keys;
+ string names; // for debug use only, in release it's empty
+ pair<int, bool> type = feature::GetDrawRule(f, zoom, keys, names);
+
+ m_hasLineStyles = false;
+
+ m_geometryType = type.first;
+ m_isCoastline = type.second;
+
+ f.GetPreferredDrawableNames(m_primaryText, m_secondaryText);
+ m_refText = f.GetRoadNumber();
+
+
+
+
+ double const population = static_cast<double>(f.GetPopulation());
+ if (population == 1)
+ m_popRank = 0.0;
+ else
+ {
+ double const upperBound = 3.0E6;
+ m_popRank = min(upperBound, population) / upperBound;
+ }
+
+ // low zoom heuristics
+ if (zoom <= 5)
+ {
+ // draw country names and capitals on native language only
+ if (!m_secondaryText.empty())
+ {
+ m_primaryText.swap(m_secondaryText);
+ m_secondaryText.clear();
+ }
+
+ // don't use population rank on low zoom
+ m_popRank = 0.0;
+
+ // hide superlong names on low zoom
+ if (m_primaryText.size() > 70)
+ m_primaryText.clear();
+ }
+
+ m_priorityModifier = 0;
+
+ if (population != 0){
+ // dividing by planet population to get m_priorityModifier < 1
+ m_priorityModifier = static_cast<double>(population) / 7E9;
+ }
+
+ drule::MakeUnique(keys);
+ size_t const count = keys.size();
+
+ int layer = f.GetLayer();
+ bool isTransparent = false;
+ if (layer == feature::LAYER_TRANSPARENT_TUNNEL)
+ {
+ layer = 0;
+ isTransparent = true;
+ }
+
+ m_rules.resize(count);
+
+ for (size_t i = 0; i < count; ++i)
+ {
+ double depth = keys[i].m_priority;
+ if (layer != 0)
+ depth = (layer * drule::layer_base_priority) + fmod(depth, drule::layer_base_priority);
+ depth += m_priorityModifier;
+
+ m_rules[i] = ( di::DrawRule( drule::rules().Find(keys[i]), depth, isTransparent) );
+
+ if (!m_hasLineStyles && (keys[i].m_type == drule::line))
+ m_hasLineStyles = true;
+
+ if (m_hasLineStyles && !m_hasPathText && !m_primaryText.empty())
+ if (m_rules[i].m_rule->GetCaption(0) != 0)
+ m_hasPathText = true;
+
+ }
+
+ sort(m_rules.begin(), m_rules.end(), less_depth());
+ m_count = m_rules.size();
+ }
+}
diff --git a/map/feature_styler.hpp b/map/feature_styler.hpp
new file mode 100644
index 0000000000..ff9eb27336
--- /dev/null
+++ b/map/feature_styler.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include "../std/vector.hpp"
+#include "../indexer/drawing_rules.hpp"
+#include "drawer.hpp"
+#include "../indexer/feature.hpp"
+#include "../indexer/feature_visibility.hpp"
+
+namespace feature
+{
+ class StylesContainer
+ {
+
+ //buffer_vector<di::DrawRule, 16> rules;
+
+
+ public:
+ StylesContainer();
+ ~StylesContainer();
+
+ typedef buffer_vector<di::DrawRule, 16> StylesContainerT;
+ StylesContainerT m_rules;
+ bool m_isCoastline;
+ bool m_hasLineStyles;
+ bool m_hasPathText;
+ int m_geometryType;
+ size_t m_count;
+
+ string m_primaryText;
+ string m_secondaryText;
+ string m_refText;
+
+ double m_popRank;
+ double m_priorityModifier;
+
+ void GetStyles(FeatureType const & f, int const zoom);
+ bool empty()
+ {
+ return m_rules.empty();
+ }
+
+// void Assign(buffer_vector<di::DrawRule, 16> & rules);
+ };
+}
diff --git a/map/map.pro b/map/map.pro
index 884cc3cd7a..e20284eb34 100644
--- a/map/map.pro
+++ b/map/map.pro
@@ -50,6 +50,7 @@ HEADERS += \
change_viewport_task.hpp \
dialog_settings.hpp \
mwm_url.hpp \
+ feature_styler.hpp \
SOURCES += \
feature_vec_model.cpp \
@@ -91,6 +92,7 @@ SOURCES += \
change_viewport_task.cpp \
dialog_settings.cpp \
mwm_url.cpp \
+ feature_styler.cpp \
!iphone*:!bada*:!android* {
HEADERS += qgl_render_context.hpp