forked from organicmaps/organicmaps
Don't draw number for roads with visible name.
This commit is contained in:
parent
ffa039a849
commit
409f1a4384
3 changed files with 58 additions and 44 deletions
|
@ -277,6 +277,32 @@ bool DrawerYG::drawPathText(di::PathInfo const & info, string const & name, uint
|
|||
yg::maxDepth);
|
||||
}
|
||||
|
||||
void DrawerYG::drawPathNumber(di::PathInfo const & path, di::DrawInfo const * pInfo)
|
||||
{
|
||||
int const textHeight = 12;
|
||||
m2::PointD pt;
|
||||
double const length = path.GetFullLength();
|
||||
if (length >= (pInfo->m_road.size() + 2)*textHeight)
|
||||
{
|
||||
size_t const count = size_t(length / 1000.0) + 2;
|
||||
|
||||
for (size_t j = 1; j < count; ++j)
|
||||
{
|
||||
if (path.GetSmPoint(double(j) / double(count), pt))
|
||||
{
|
||||
yg::FontDesc fontDesc(
|
||||
false,
|
||||
textHeight,
|
||||
yg::Color(150, 75, 0, 255), // brown
|
||||
true,
|
||||
yg::Color(255, 255, 255, 255));
|
||||
|
||||
m_pScreen->drawText(fontDesc, pt, yg::EPosCenter, 0.0, pInfo->m_road, yg::maxDepth, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
shared_ptr<yg::gl::Screen> DrawerYG::screen() const
|
||||
{
|
||||
return m_pScreen;
|
||||
|
@ -314,37 +340,17 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size
|
|||
|
||||
if (!pathRules.empty())
|
||||
{
|
||||
bool const isNumber = !pInfo->m_road.empty() && m_level >= 12;
|
||||
|
||||
for (list<di::PathInfo>::const_iterator i = pInfo->m_pathes.begin(); i != pInfo->m_pathes.end(); ++i)
|
||||
{
|
||||
drawPath(i->m_path, pathRules.data(), pathRules.size());
|
||||
|
||||
int const textHeight = 12;
|
||||
m2::PointD pt;
|
||||
double const length = i->GetFullLength();
|
||||
if (isNumber && (length >= (pInfo->m_road.size() + 2)*textHeight))
|
||||
{
|
||||
size_t const count = size_t(length / 1000.0) + 2;
|
||||
|
||||
for (size_t j = 1; j < count; ++j)
|
||||
{
|
||||
if (i->GetSmPoint(double(j) / double(count), pt))
|
||||
{
|
||||
yg::FontDesc fontDesc(
|
||||
false,
|
||||
textHeight,
|
||||
yg::Color(150, 75, 0, 255), // brown
|
||||
true,
|
||||
yg::Color(255, 255, 255, 255));
|
||||
|
||||
m_pScreen->drawText(fontDesc, pt, yg::EPosCenter, 0.0, pInfo->m_road, yg::maxDepth, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool const isPath = !pInfo->m_pathes.empty();
|
||||
bool const isArea = !pInfo->m_areas.empty();
|
||||
|
||||
bool isNumber = true;
|
||||
|
||||
for (unsigned i = 0; i < count; ++i)
|
||||
{
|
||||
rule_ptr_t pRule = rules[i].m_rule;
|
||||
|
@ -356,10 +362,6 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size
|
|||
pRule->GetSymbol(symbol);
|
||||
bool const hasSymbol = !symbol.empty();
|
||||
|
||||
bool const isPath = !pInfo->m_pathes.empty();
|
||||
bool const isArea = !pInfo->m_areas.empty();
|
||||
bool const hasName = !pInfo->m_name.empty();
|
||||
|
||||
bool const isCircle = (pRule->GetRadius() != -1);
|
||||
|
||||
if (!isCaption)
|
||||
|
@ -398,7 +400,7 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size
|
|||
}
|
||||
else
|
||||
{
|
||||
if (hasName)
|
||||
if (!pInfo->m_name.empty())
|
||||
{
|
||||
bool isN = ((pRule->GetType() & drule::way) != 0);
|
||||
|
||||
|
@ -410,17 +412,13 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size
|
|||
}
|
||||
|
||||
// draw way name
|
||||
if (isPath && !isArea && isN)
|
||||
if (isPath && !isArea && isN && !filter_text_size(pRule))
|
||||
{
|
||||
uint8_t const fontSize = get_pathtext_font_size(pRule);
|
||||
list<m2::RectD> & lst = m_pathsOrg[pInfo->m_name];
|
||||
|
||||
for (list<di::PathInfo>::const_iterator i = pInfo->m_pathes.begin(); i != pInfo->m_pathes.end(); ++i)
|
||||
{
|
||||
if (filter_text_size(pRule))
|
||||
continue;
|
||||
|
||||
uint8_t const fontSize = get_pathtext_font_size(pRule);
|
||||
|
||||
list<m2::RectD> & lst = m_pathsOrg[pInfo->m_name];
|
||||
|
||||
m2::RectD r = i->GetLimitRect();
|
||||
r.Inflate(-r.SizeX() / 4.0, -r.SizeY() / 4.0);
|
||||
r.Inflate(fontSize, fontSize);
|
||||
|
@ -433,8 +431,16 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size
|
|||
break;
|
||||
}
|
||||
|
||||
if (needDraw && drawPathText(*i, pInfo->m_name, fontSize, depth))
|
||||
lst.push_back(r);
|
||||
if (needDraw)
|
||||
{
|
||||
if (drawPathText(*i, pInfo->m_name, fontSize, depth))
|
||||
{
|
||||
isNumber = false; // text hides number
|
||||
lst.push_back(r);
|
||||
}
|
||||
}
|
||||
else
|
||||
isNumber = false; // neighbor text hides this text and this number
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -445,4 +451,11 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, di::DrawRule const * rules, size
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// draw road numbers
|
||||
if (isNumber && isPath && !pInfo->m_road.empty() && m_level >= 12)
|
||||
{
|
||||
for (list<di::PathInfo>::const_iterator i = pInfo->m_pathes.begin(); i != pInfo->m_pathes.end(); ++i)
|
||||
drawPathNumber(*i, pInfo);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,6 +83,7 @@ protected:
|
|||
|
||||
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);
|
||||
void drawPathNumber(di::PathInfo const & path, di::DrawInfo const * pInfo);
|
||||
|
||||
typedef shared_ptr<yg::gl::BaseTexture> texture_t;
|
||||
typedef shared_ptr<yg::gl::FrameBuffer> frame_buffer_t;
|
||||
|
|
|
@ -173,10 +173,10 @@ namespace fwork
|
|||
|
||||
m_renderState->m_isEmptyModelCurrent = false;
|
||||
|
||||
shared_ptr<di::DrawInfo> ptr(
|
||||
new di::DrawInfo(f.GetPreferredDrawableName(languages::GetCurrentPriorities()),
|
||||
f.GetRoadNumber(),
|
||||
m_zoom > 5 ? f.GetPopulationDrawRank() : 0.0));
|
||||
shared_ptr<di::DrawInfo> ptr(new di::DrawInfo(
|
||||
f.GetPreferredDrawableName(languages::GetCurrentPriorities()),
|
||||
f.GetRoadNumber(),
|
||||
(m_zoom > 5) ? f.GetPopulationDrawRank() : 0.0));
|
||||
|
||||
DrawerYG * pDrawer = GetDrawer();
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue