Add rank for text height.

This commit is contained in:
vng 2011-05-17 00:35:05 +03:00 committed by Alex Zolotarev
parent 8afd924fbc
commit f3a38af8c4
6 changed files with 25 additions and 7 deletions

View file

@ -374,6 +374,8 @@ public:
string GetPreferredDrawableName() const;
uint8_t GetRank() const { return m_Params.rank; }
/// @name Statistic functions.
//@{
void ParseBeforeStatistic() const

View file

@ -225,7 +225,7 @@ bool DrawerYG::filter_text_size(rule_ptr_t pRule) const
return pRule->GetTextHeight() * m_scale <= min_text_height_filtered;
}
void DrawerYG::drawText(m2::PointD const & pt, string const & name, rule_ptr_t pRule, yg::EPosition pos, int depth)
void DrawerYG::drawText(m2::PointD const & pt, di::DrawInfo const * pInfo, rule_ptr_t pRule, yg::EPosition pos, int depth)
{
int const color = pRule->GetFillColor();
yg::Color textColor(color == -1 ? yg::Color(0, 0, 0, 0) : yg::Color::fromXRGB(color, pRule->GetAlpha()));
@ -237,6 +237,7 @@ void DrawerYG::drawText(m2::PointD const & pt, string const & name, rule_ptr_t p
// bool isMasked = pRule->GetColor() != -1;
bool isMasked = true;
yg::FontDesc fontDesc(false, get_text_font_size(pRule), textColor, isMasked, yg::Color(255, 255, 255, 255));
fontDesc.SetRank(pInfo->m_rank);
if (!filter_text_size(pRule))
m_pScreen->drawText(
@ -244,7 +245,7 @@ void DrawerYG::drawText(m2::PointD const & pt, string const & name, rule_ptr_t p
pt,
pos,
0.0,
name,
pInfo->m_name,
depth,
true);
}
@ -367,7 +368,7 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size
if (isArea && isN)
{
for (list<di::AreaInfo>::const_iterator i = pInfo->m_areas.begin(); i != pInfo->m_areas.end(); ++i)
drawText(i->GetCenter(), pInfo->m_name, pRule, yg::EPosAbove, depth);
drawText(i->GetCenter(), pInfo, pRule, yg::EPosAbove, depth);
}
// draw way name
@ -402,7 +403,7 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size
// draw point text
isN = ((pRule->GetType() & drule::node) != 0);
if (!isPath && !isArea && isN)
drawText(pInfo->m_point, pInfo->m_name, pRule, yg::EPosAbove, depth);
drawText(pInfo->m_point, pInfo, pRule, yg::EPosAbove, depth);
}
}
}

View file

@ -32,13 +32,14 @@ namespace di
class DrawInfo
{
public:
DrawInfo(string const & name) : m_name(name) {}
DrawInfo(string const & name, uint8_t rank) : m_name(name), m_rank(rank) {}
list<di::PathInfo> m_pathes;
list<di::AreaInfo> m_areas;
m2::PointD m_point;
string m_name;
uint8_t m_rank;
};
struct DrawRule
@ -74,7 +75,7 @@ protected:
void drawPath(vector<m2::PointD> const & pts, di::DrawRule const * rules, size_t count);
void drawArea(vector<m2::PointD> const & pts, rule_ptr_t pRule, int depth);
void drawText(m2::PointD const & pt, string const & name, rule_ptr_t pRule, yg::EPosition pos, int depth);
void drawText(m2::PointD const & pt, di::DrawInfo const * pInfo, rule_ptr_t pRule, yg::EPosition pos, int depth);
bool drawPathText(di::PathInfo const & info, string const & name, uint8_t fontSize, int depth);
typedef shared_ptr<yg::gl::BaseTexture> texture_t;

View file

@ -158,7 +158,7 @@ namespace fwork
m_renderState->m_isEmptyModelCurrent = false;
shared_ptr<di::DrawInfo> ptr(new di::DrawInfo(f.GetPreferredDrawableName()));
shared_ptr<di::DrawInfo> ptr(new di::DrawInfo(f.GetPreferredDrawableName(), f.GetRank()));
DrawerYG * pDrawer = GetDrawer();

View file

@ -1,6 +1,11 @@
#include "../base/SRC_FIRST.hpp"
#include "font_desc.hpp"
#include "../std/cmath.hpp"
#include "../std/algorithm.hpp"
namespace yg
{
FontDesc const & FontDesc::defaultFont = FontDesc();
@ -11,6 +16,13 @@ namespace yg
m_isMasked(isMasked), m_maskColor(maskColor)
{}
void FontDesc::SetRank(uint8_t rank)
{
m_size += static_cast<int>(min(4.0E6, std::pow(1.1, double(rank))) / 2.0E6 * m_size);
//m_size += static_cast<int>((double(rank) / 200.0) * m_size);
//m_size += (rank / 20);
}
bool FontDesc::operator ==(FontDesc const & src) const
{
return (m_isStatic == src.m_isStatic)

View file

@ -15,6 +15,8 @@ namespace yg
FontDesc(bool isStatic = true, int size = 10, yg::Color const & color = yg::Color(0, 0, 0, 255),
bool isMasked = true, yg::Color const & maskColor = yg::Color(255, 255, 255, 255));
void SetRank(uint8_t rank);
bool operator != (FontDesc const & src) const;
bool operator == (FontDesc const & src) const;
bool operator < (FontDesc const & src) const;