From 8196507988f8d8c4b75195a1b15b10e14038c69e Mon Sep 17 00:00:00 2001 From: rachytski Date: Wed, 14 Sep 2011 20:28:01 +0300 Subject: [PATCH] fixed SymbolElement rendering artefact. --- map/ruler.cpp | 31 +++++++++++++++++++------------ yg/info_layer.cpp | 7 ++++++- yg/symbol_element.cpp | 3 +++ 3 files changed, 28 insertions(+), 13 deletions(-) diff --git a/map/ruler.cpp b/map/ruler.cpp index 3df442d49b..a7e4f20e9b 100644 --- a/map/ruler.cpp +++ b/map/ruler.cpp @@ -51,9 +51,9 @@ void Ruler::setFontDesc(yg::FontDesc const & fontDesc) unsigned Ruler::ceil(double unitsDiff) { /// finding the closest higher metric value - unsigned curVal = (unsigned)m_minUnitsWidth; + double curVal = m_minUnitsWidth; - unsigned curFirstDigit = m_minUnitsWidth; + unsigned curFirstDigit = (unsigned)m_minUnitsWidth; while (curFirstDigit > 10) curFirstDigit /= 10; @@ -65,7 +65,7 @@ unsigned Ruler::ceil(double unitsDiff) else while (true) { - unsigned nextVal = curFirstDigit == 2 ? (curVal * 5 / 2) : curVal * 2; + double nextVal = curFirstDigit == 2 ? (curVal * 5 / 2) : curVal * 2; unsigned nextFirstDigit = curFirstDigit == 2 ? (curFirstDigit * 5 / 2) : curFirstDigit * 2; if (nextFirstDigit >= 10) @@ -82,15 +82,15 @@ unsigned Ruler::ceil(double unitsDiff) curFirstDigit = nextFirstDigit; } - return curVal; + return (unsigned)curVal; } void Ruler::update() { m2::PointD glbPivot = m_screen.PtoG(pivot()); - int rulerHeight = 14 * m_visualScale; - unsigned minPxWidth = m_minPxWidth * m_visualScale; + int rulerHeight = static_cast(14 * m_visualScale); + unsigned minPxWidth = static_cast(m_minPxWidth * m_visualScale); m2::PointD pt0 = m_screen.PtoG(pivot() - m2::PointD(minPxWidth / 2, 0)); m2::PointD pt1 = m_screen.PtoG(pivot() + m2::PointD(minPxWidth / 2, 0)); @@ -112,23 +112,25 @@ void Ruler::update() bool higherThanMax = m_unitsDiff > m_maxUnitsWidth; bool lessThanMin = m_unitsDiff < m_minUnitsWidth; + double textUnitsDiff = m_unitsDiff; + m_scalerText = ""; if (higherThanMax) { m_scalerText = ">"; - m_unitsDiff = m_maxUnitsWidth; + textUnitsDiff = m_maxUnitsWidth; } else if (lessThanMin) { m_scalerText = "<"; - m_unitsDiff = m_minUnitsWidth; + textUnitsDiff = m_minUnitsWidth; } if (m_unitsDiff >= 1000) - m_scalerText += strings::to_string(m_unitsDiff / 1000) + " km"; + m_scalerText += strings::to_string(textUnitsDiff / 1000) + " km"; else - m_scalerText += strings::to_string(m_unitsDiff) + " m"; + m_scalerText += strings::to_string(textUnitsDiff) + " m"; /// translating units into pixels double scalerWidthLatDiff = (double)m_unitsDiff * MercatorBounds::degreeInMetres / lonDiffCorrection; @@ -175,8 +177,13 @@ void Ruler::draw(yg::gl::OverlayRenderer * s, math::Matrix const & { s->drawPath( &m_path[0], m_path.size(), 0, - s->skin()->mapPenInfo(yg::PenInfo(yg::Color(0, 0, 0, 255), 2, 0, 0, 0)), - depth()); + s->skin()->mapPenInfo(yg::PenInfo(yg::Color(255, 255, 255, 255), 2 * m_visualScale, 0, 0, 0)), + depth() - 3); + + s->drawPath( + &m_path[0], m_path.size(), 0, + s->skin()->mapPenInfo(yg::PenInfo(yg::Color(0, 0, 0, 255), 1 * m_visualScale, 0, 0, 0)), + depth() - 2); if (position() & yg::EPosLeft) s->drawText(m_fontDesc, diff --git a/yg/info_layer.cpp b/yg/info_layer.cpp index c710187637..d2faf5bb6f 100644 --- a/yg/info_layer.cpp +++ b/yg/info_layer.cpp @@ -108,7 +108,11 @@ namespace yg { it->offset(offs); m2::AARectD const & r = it->boundRect(); - if (!aaRect.IsIntersect(r) && !aaRect.IsRectInside(r)) + + bool isIntersect = aaRect.IsIntersect(r); + bool isRectInside = aaRect.IsRectInside(r); + + if (!isIntersect && !isRectInside) { list::iterator tempIt = it; ++tempIt; @@ -117,6 +121,7 @@ namespace yg } else { + it->setIsNeedRedraw(isIntersect); isEmpty = false; ++it; } diff --git a/yg/symbol_element.cpp b/yg/symbol_element.cpp index 3480f9645a..59974ab89a 100644 --- a/yg/symbol_element.cpp +++ b/yg/symbol_element.cpp @@ -46,6 +46,9 @@ namespace yg void SymbolElement::draw(gl::OverlayRenderer * r, math::Matrix const & m) const { + if (!isNeedRedraw()) + return; + if (m_styleID == 0) { m_styleID = r->skin()->mapSymbol(m_symbolName.c_str());