/** ******************************************************************************* * @file parserSVG/Group.cpp * @brief Basic Group parsing (Sources) * @author Edouard DUPIN * @date 21/03/2012 * @par Project * parserSVG * * @par Copyright * Copyright 2011 Edouard DUPIN, all right reserved * * This software is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. * * Licence summary : * You can modify and redistribute the sources code and binaries. * You can send me the bug-fix * * Term of the licence in in the file licence.txt. * ******************************************************************************* */ #include #include #include #include #include #include #include #include #include #include #include #include #include svg::Group::Group(paintState_ts parentPaintState) : svg::Base(parentPaintState) { } svg::Group::~Group(void) { } bool svg::Group::Parse(TiXmlNode * node) { // parse ... coord2D_ts pos; coord2D_ts size; ParseTransform(node); ParsePosition(node, pos, size); ParsePaintAttr(node); // parse all sub node : for(TiXmlNode * child = node->FirstChild(); NULL != child; child = child->NextSibling() ) { svg::Base *elementParser = NULL; if (child->Type()==TiXmlNode::TINYXML_COMMENT) { // nothing to do, just proceed to next step } else { etk::UString localValue = child->Value(); if (localValue == "g") { elementParser = new svg::Group(m_paint); } else if (localValue == "a") { // TODO ... } else if (localValue == "path") { elementParser = new svg::Path(m_paint); } else if (localValue == "rect") { elementParser = new svg::Rectangle(m_paint); } else if (localValue == "circle") { elementParser = new svg::Circle(m_paint); } else if (localValue == "ellipse") { elementParser = new svg::Ellipse(m_paint); } else if (localValue == "line") { elementParser = new svg::Line(m_paint); } else if (localValue == "polyline") { elementParser = new svg::Polyline(m_paint); } else if (localValue == "polygon") { elementParser = new svg::Polygon(m_paint); } else if (localValue == "text") { elementParser = new svg::Text(m_paint); } else { SVG_ERROR("(l "<Row()<<") node not suported : \""<Row()<<") error on node: \""<Parse(child)) { SVG_ERROR("(l "<Row()<<") error on node: \""<Display(spacing+1); } } SVG_DEBUG(SpacingDist(spacing) << "Group (STOP)"); } void svg::Group::AggDraw(agg::path_storage& path, etk::VectorType &colors, etk::VectorType &pathIdx) { uint32_t tmpColor = 0; tmpColor = ((int32_t)(m_paint.fill.red*256.))<<24; tmpColor += ((int32_t)(m_paint.fill.green*256.))<<16; tmpColor += ((int32_t)(m_paint.fill.blue*256.))<<8; tmpColor += ((int32_t)(m_paint.fill.alpha*256.)); // New color. Every new color creates new path in the path object. colors.PushBack(agg::rgb8_packed(tmpColor)); uint32_t tmpPathNew = path.start_new_path(); pathIdx.PushBack(tmpPathNew); for (int32_t iii=0; iiiAggDraw(path, colors, pathIdx); } } }