From b8eb699ad3f15da4fd5d412a4bbd128de7892878 Mon Sep 17 00:00:00 2001 From: rachytski Date: Sat, 5 Feb 2011 22:55:15 +0200 Subject: [PATCH] CircleRule rendering. colors should be fixed at classificator. --- map/drawer_yg.cpp | 14 +++++++++----- map/drawer_yg.hpp | 2 +- yg/circle_info.hpp | 2 +- yg/shape_renderer.cpp | 18 ------------------ yg/shape_renderer.hpp | 2 -- yg/skin_page.cpp | 15 ++++++++++----- yg/symbol_renderer.cpp | 17 +++++++++++++++++ yg/symbol_renderer.hpp | 1 + 8 files changed, 39 insertions(+), 32 deletions(-) diff --git a/map/drawer_yg.cpp b/map/drawer_yg.cpp index 6b0854b47b..7264df6b46 100644 --- a/map/drawer_yg.cpp +++ b/map/drawer_yg.cpp @@ -85,14 +85,18 @@ void DrawerYG::drawSymbol(m2::PointD const & pt, string const & symbolName, yg:: m_pScreen->drawSymbol(pt, m_pSkin->mapSymbol(symbolName.c_str()), pos, depth); } -void DrawerYG::drawCircle(m2::PointD const & pt, rule_ptr_t pRule, int depth) +void DrawerYG::drawCircle(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth) { uint32_t id = pRule->GetID(); if (id == drule::BaseRule::empty_id) { - yg::CircleInfo info(pRule->GetRadius(), + double radius = min(max(pRule->GetRadius(), 3.0), 6.0) * m_visualScale; + + yg::CircleInfo info(radius, yg::Color::fromXRGB(pRule->GetColor(), pRule->GetAlpha()), - true); + true, + m_visualScale, + yg::Color::fromXRGB(pRule->GetStrokeColor(), pRule->GetAlpha())); id = m_pSkin->mapCircleInfo(info); @@ -105,7 +109,7 @@ void DrawerYG::drawCircle(m2::PointD const & pt, rule_ptr_t pRule, int depth) } } - m_pScreen->drawCircle(pt, id, depth); + m_pScreen->drawCircle(pt, id, pos, depth); } void DrawerYG::drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth) @@ -347,7 +351,7 @@ void DrawerYG::Draw(di::DrawInfo const * pInfo, rule_ptr_t * rules, int * depthV if (isSymbol) drawSymbol(pInfo->m_point, pRule, yg::EPosLeft, depth); if (isCircle) - drawCircle(pInfo->m_point, pRule, depth); + drawCircle(pInfo->m_point, pRule, yg::EPosLeft, depth); } } else diff --git a/map/drawer_yg.hpp b/map/drawer_yg.hpp index dd50e1a97a..422a240f57 100644 --- a/map/drawer_yg.hpp +++ b/map/drawer_yg.hpp @@ -63,7 +63,7 @@ private: protected: void drawSymbol(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth); - void drawCircle(m2::PointD const & pt, rule_ptr_t pRule, int depth); + void drawCircle(m2::PointD const & pt, rule_ptr_t pRule, yg::EPosition pos, int depth); void drawPath(vector const & pts, rule_ptr_t pRule, int depth); void drawPath(vector const & pts, rule_ptr_t * rules, int * depthVec, size_t count); void drawArea(vector const & pts, rule_ptr_t pRule, int depth); diff --git a/yg/circle_info.hpp b/yg/circle_info.hpp index d47b14db6b..6193d16866 100644 --- a/yg/circle_info.hpp +++ b/yg/circle_info.hpp @@ -17,7 +17,7 @@ namespace yg unsigned radius, Color const & color = Color(0, 0, 0, 255), bool isOutlined = false, - unsigned outlineWidth = 0, + unsigned outlineWidth = 1, Color const & outlineColor = Color(255, 255, 255, 255)); }; diff --git a/yg/shape_renderer.cpp b/yg/shape_renderer.cpp index 48ba2709ba..2c10a4037e 100644 --- a/yg/shape_renderer.cpp +++ b/yg/shape_renderer.cpp @@ -65,23 +65,5 @@ namespace yg drawTrianglesList(§orPts[0], sectorPts.size(), skin()->mapColor(c), depth); } - void ShapeRenderer::drawCircle(m2::PointD const & center, uint32_t styleID, double depth) - { - ResourceStyle const * style(skin()->fromID(styleID)); - - m2::RectU texRect(style->m_texRect); - texRect.Inflate(-1, -1); - - m2::PointD pt(center - m2::PointD(texRect.SizeX() / 2, texRect.SizeY() / 2)); - pt.x = ceil(pt.x); - pt.y = ceil(pt.y); - - - drawTexturedPolygon(m2::PointD(0, 0), 0, - texRect.minX(), texRect.minY(), texRect.maxX(), texRect.maxY(), - pt.x, pt.y, pt.x + texRect.SizeX(), pt.y + texRect.SizeY(), - depth, - style->m_pageID); - } } } diff --git a/yg/shape_renderer.hpp b/yg/shape_renderer.hpp index 4a00493d26..0e0f8dd6cb 100644 --- a/yg/shape_renderer.hpp +++ b/yg/shape_renderer.hpp @@ -18,8 +18,6 @@ namespace yg void drawArc(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth); void drawSector(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth); void fillSector(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth); - - void drawCircle(m2::PointD const & center, uint32_t styleID, double depth); }; } } diff --git a/yg/skin_page.cpp b/yg/skin_page.cpp index bb466acb05..117c77b0fa 100644 --- a/yg/skin_page.cpp +++ b/yg/skin_page.cpp @@ -434,7 +434,7 @@ namespace yg if (penInfo.m_w > 2) { agg::ellipse ell; - float r = penInfo.m_w / 2.0; + float r = ceil(penInfo.m_w) / 2.0; ell.init(r + 2, r + 2, r, r, 100); rasterizer.add_path(ell); @@ -446,12 +446,18 @@ namespace yg penInfo.m_color.b, penInfo.m_color.a)); -/* /// in non-transparent areas - premultiply color value with alpha and make it opaque + /// pixels that are used to texture inner part of the line should be fully opaque + v(2 + r - 1, 2) = penColor; + v(2 + r , 2) = penColor; + v(2 + r - 1, 2 + r * 2 - 1) = penColor; + v(2 + r , 2 + r * 2 - 1) = penColor; + + /// in non-transparent areas - premultiply color value with alpha and make it opaque for (size_t x = 2; x < v.width() - 2; ++x) for (size_t y = 2; y < v.height() - 2; ++y) { unsigned char alpha = gil::get_color(v(x, y), gil::alpha_t()); - float fAlpha = alpha / (float)TDynamicTexture::maxChannelVal; +// float fAlpha = alpha / (float)TDynamicTexture::maxChannelVal; if (alpha != 0) { // gil::get_color(v(x, y), gil::red_t()) *= fAlpha; @@ -462,12 +468,11 @@ namespace yg v(x, y) = penColor; } } -*/ } else { gil::fill_pixels( - gil::subimage_view(v, 1, 1, rect.SizeX() - 2, rect.SizeY() - 2), + gil::subimage_view(v, 2, 2, rect.SizeX() - 4, rect.SizeY() - 4), penColor ); } diff --git a/yg/symbol_renderer.cpp b/yg/symbol_renderer.cpp index ecefdab0c9..04faaf82af 100644 --- a/yg/symbol_renderer.cpp +++ b/yg/symbol_renderer.cpp @@ -70,6 +70,23 @@ namespace yg style->m_pageID); } + void SymbolRenderer::drawCircle(m2::PointD const & pt, uint32_t styleID, EPosition pos, int depth) + { + ResourceStyle const * style(skin()->fromID(styleID)); + + m2::RectU texRect(style->m_texRect); + texRect.Inflate(-1, -1); + + m2::PointD posPt = getPosPt(pt, m2::RectD(texRect), pos); + + drawTexturedPolygon(m2::PointD(0, 0), 0, + texRect.minX(), texRect.minY(), texRect.maxX(), texRect.maxY(), + posPt.x, posPt.y, posPt.x + texRect.SizeX(), posPt.y + texRect.SizeY(), + depth, + style->m_pageID); + } + + void mark_intersect(bool & flag) { flag = true; diff --git a/yg/symbol_renderer.hpp b/yg/symbol_renderer.hpp index 91eeb5f714..68820c721c 100644 --- a/yg/symbol_renderer.hpp +++ b/yg/symbol_renderer.hpp @@ -39,6 +39,7 @@ namespace yg SymbolRenderer(base_t::Params const & params); void drawSymbol(m2::PointD const & pt, uint32_t styleID, EPosition pos, int depth); + void drawCircle(m2::PointD const & pt, uint32_t styleID, EPosition pos, int depth); void setClipRect(m2::RectI const & rect); void endFrame();