[DEV] start coding style

This commit is contained in:
Edouard DUPIN 2013-10-03 23:35:28 +02:00
parent 32c4469c12
commit b80dbfd298
23 changed files with 333 additions and 333 deletions

View File

@ -21,18 +21,18 @@ esvg::Base::Base(PaintState _parentPaintState)
m_paint = _parentPaintState;
}
void esvg::Base::ParseTransform(exml::Element* _element)
void esvg::Base::parseTransform(exml::Element* _element)
{
if (NULL == _element) {
return;
}
etk::UString inputString = _element->GetAttribute("transform");
if (inputString.Size()==0) {
etk::UString inputString = _element->getAttribute("transform");
if (inputString.size() == 0) {
return;
}
SVG_VERBOSE("find transform : \"" << inputString << "\"");
for (int32_t iii=0; iii<inputString.Size(); iii++) {
for (int32_t iii=0; iii<inputString.size(); iii++) {
if (inputString[iii] == ',') {
inputString[iii] = ' ';
}
@ -84,12 +84,12 @@ void esvg::Base::ParseTransform(exml::Element* _element)
/**
* @brief Parse x, y, width, height attribute of the xml node
* @brief parse x, y, width, height attribute of the xml node
* @param[in] _element XML node
* @param[out] _pos parsed position
* @param[out] _size parsed dimention
*/
void esvg::Base::ParsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size)
void esvg::Base::parsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size)
{
_pos.setValue(0,0);
_size.setValue(0,0);
@ -97,50 +97,50 @@ void esvg::Base::ParsePosition(const exml::Element *_element, etk::Vector2D<floa
if (NULL == _element) {
return;
}
etk::UString content = _element->GetAttribute("x");
if (content.Size()!=0) {
_pos.setX(ParseLength(content));
etk::UString content = _element->getAttribute("x");
if (content.size()!=0) {
_pos.setX(parseLength(content));
}
content = _element->GetAttribute("y");
if (content.Size()!=0) {
_pos.setX(ParseLength(content));
content = _element->getAttribute("y");
if (content.size()!=0) {
_pos.setX(parseLength(content));
}
content = _element->GetAttribute("width");
if (content.Size()!=0) {
_size.setX(ParseLength(content));
content = _element->getAttribute("width");
if (content.size()!=0) {
_size.setX(parseLength(content));
}
content = _element->GetAttribute("height");
if (content.Size()!=0) {
_size.setY(ParseLength(content));
content = _element->getAttribute("height");
if (content.size()!=0) {
_size.setY(parseLength(content));
}
}
/**
* @brief Parse a lenght of the xml element
* @brief parse a lenght of the xml element
* @param[in] _dataInput Data C String with the printed lenght
* @return standart number of pixels
*/
float esvg::Base::ParseLength(const etk::UString& _dataInput)
float esvg::Base::parseLength(const etk::UString& _dataInput)
{
SVG_VERBOSE(" lenght : '" << _dataInput << "'");
float n = _dataInput.ToFloat();
float n = _dataInput.toFloat();
etk::UString unit;
for (int32_t iii=0; iii<_dataInput.Size(); iii++) {
for (int32_t iii=0; iii<_dataInput.size(); iii++) {
if( (_dataInput[iii]>='0' && _dataInput[iii]<='9')
|| _dataInput[iii]<='+'
|| _dataInput[iii]<='-'
|| _dataInput[iii]<='.') {
continue;
}
unit = _dataInput.Extract(iii-1);
unit = _dataInput.extract(iii-1);
}
//SVG_INFO(" ==> ?? = " << n );
//SVG_INFO(" == > ?? = " << n );
float font_size = 20.0f;
SVG_VERBOSE(" lenght : '" << n << "' => unit=" << unit);
// note : ";" is for the parsing of the style elements ...
if( unit.Size()==0
if( unit.size() == 0
|| unit[0] == ';' ) {
return n;
} else if (unit[0] == '%') { // xxx %
@ -170,7 +170,7 @@ int32_t extractPartOfStyle(const etk::UString& _data, etk::UString& _outputType,
{
_outputType = "";
_outputData = "";
if (_pos==-1) {
if (_pos == -1) {
return -2;
}
int32_t typeStart = _pos;
@ -179,7 +179,7 @@ int32_t extractPartOfStyle(const etk::UString& _data, etk::UString& _outputType,
int32_t dataStop = _pos;
bool processFirst=true;
//SVG_DEBUG("parse : '" << _data.Extract(_pos) << "'");
for( int32_t iii=_pos; iii<_data.Size(); iii++) {
for( int32_t iii=_pos; iii<_data.size(); iii++) {
//SVG_DEBUG(" ? '" << _data[iii] << "'");
if (_data[iii] == ';') {
// end of the element
@ -202,55 +202,55 @@ int32_t extractPartOfStyle(const etk::UString& _data, etk::UString& _outputType,
}
/**
* @brief Parse a Painting attribute of a specific node
* @brief parse a Painting attribute of a specific node
* @param[in] _element Basic node of the XML that might be parsed
*/
void esvg::Base::ParsePaintAttr(const exml::Element *_element)
void esvg::Base::parsePaintAttr(const exml::Element *_element)
{
if (_element==NULL) {
if (_element == NULL) {
return;
}
bool fillNone = false;
bool strokeNone = false;
etk::UString content = _element->GetAttribute("fill");
if (content.Size()!=0) {
m_paint.fill = ParseColor(content);
etk::UString content = _element->getAttribute("fill");
if (content.size()!=0) {
m_paint.fill = parseColor(content);
if (m_paint.fill.a == 0) {
fillNone = true;
}
}
content = _element->GetAttribute("stroke");
if (content.Size()!=0) {
m_paint.stroke = ParseColor(content);
content = _element->getAttribute("stroke");
if (content.size()!=0) {
m_paint.stroke = parseColor(content);
if (m_paint.stroke.a == 0) {
strokeNone = true;
}
}
content = _element->GetAttribute("stroke-width");
if (content.Size()!=0) {
m_paint.strokeWidth = ParseLength(content);
content = _element->getAttribute("stroke-width");
if (content.size()!=0) {
m_paint.strokeWidth = parseLength(content);
}
content = _element->GetAttribute("opacity");
if (content.Size()!=0) {
float opacity = ParseLength(content);
content = _element->getAttribute("opacity");
if (content.size()!=0) {
float opacity = parseLength(content);
opacity = etk_max(0.0, etk_min(1.0, opacity));
m_paint.fill.a = opacity*0xFF;
m_paint.stroke.a = opacity*0xFF;
}
content = _element->GetAttribute("fill-opacity");
if (content.Size()!=0) {
float opacity = ParseLength(content);
content = _element->getAttribute("fill-opacity");
if (content.size()!=0) {
float opacity = parseLength(content);
opacity = etk_max(0.0, etk_min(1.0, opacity));
m_paint.fill.a = opacity*0xFF;
}
content = _element->GetAttribute("stroke-opacity");
if (content.Size()!=0) {
float opacity = ParseLength(content);
content = _element->getAttribute("stroke-opacity");
if (content.size()!=0) {
float opacity = parseLength(content);
opacity = etk_max(0.0, etk_min(1.0, opacity));
m_paint.stroke.a = opacity*0xFF;
}
content = _element->GetAttribute("fill-rule");
if (content.Size()!=0) {
content = _element->getAttribute("fill-rule");
if (content.size()!=0) {
if (content == "nonzero") {
m_paint.flagEvenOdd = false;
} else if (content == "evenodd" ) {
@ -259,8 +259,8 @@ void esvg::Base::ParsePaintAttr(const exml::Element *_element)
SVG_ERROR("not know fill-rule value : \"" << content << "\", not in [nonzero,evenodd]");
}
}
content = _element->GetAttribute("stroke-linecap");
if (content.Size()!=0) {
content = _element->getAttribute("stroke-linecap");
if (content.size()!=0) {
if (content == "butt" ) {
m_paint.lineCap = esvg::LINECAP_BUTT;
} else if (content == "round" ) {
@ -272,8 +272,8 @@ void esvg::Base::ParsePaintAttr(const exml::Element *_element)
SVG_ERROR("not know stroke-linecap value : \"" << content << "\", not in [butt,round,square]");
}
}
content = _element->GetAttribute("stroke-linejoin");
if (content.Size()!=0) {
content = _element->getAttribute("stroke-linejoin");
if (content.size()!=0) {
if (content == "miter" ) {
m_paint.lineJoin = esvg::LINEJOIN_MITER;
} else if (content == "round" ) {
@ -285,8 +285,8 @@ void esvg::Base::ParsePaintAttr(const exml::Element *_element)
SVG_ERROR("not know stroke-linejoin value : \"" << content << "\", not in [miter,round,bevel]");
}
}
content = _element->GetAttribute("style");
if (content.Size()!=0) {
content = _element->getAttribute("style");
if (content.size()!=0) {
etk::UString outputType;
etk::UString outputValue;
@ -295,36 +295,36 @@ void esvg::Base::ParsePaintAttr(const exml::Element *_element)
sss=extractPartOfStyle(content, outputType, outputValue, sss) ) {
SVG_VERBOSE(" style parse : \"" << outputType << "\" with value : \"" << outputValue << "\"");
if (outputType == "fill") {
m_paint.fill = ParseColor(outputValue);
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.fill);
m_paint.fill = parseColor(outputValue);
SVG_VERBOSE(" input : \"" << outputValue << "\" == > " << m_paint.fill);
if (m_paint.fill.a == 0) {
fillNone = true;
}
} else if (outputType == "stroke") {
m_paint.stroke = ParseColor(outputValue);
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.stroke);
m_paint.stroke = parseColor(outputValue);
SVG_VERBOSE(" input : \"" << outputValue << "\" == > " << m_paint.stroke);
if (m_paint.stroke.a == 0) {
strokeNone = true;
}
} else if (outputType == "stroke-width" ) {
m_paint.strokeWidth = ParseLength(outputValue);
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.strokeWidth);
m_paint.strokeWidth = parseLength(outputValue);
SVG_VERBOSE(" input : \"" << outputValue << "\" == > " << m_paint.strokeWidth);
} else if (outputType == "opacity" ) {
float opacity = ParseLength(outputValue);
float opacity = parseLength(outputValue);
opacity = etk_max(0.0, etk_min(1.0, opacity));
m_paint.fill.a = opacity*0xFF;
m_paint.stroke.a = opacity*0xFF;
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.fill);
SVG_VERBOSE(" input : \"" << outputValue << "\" == > " << m_paint.fill);
} else if (outputType == "fill-opacity") {
float opacity = ParseLength(outputValue);
float opacity = parseLength(outputValue);
opacity = etk_max(0.0, etk_min(1.0, opacity));
m_paint.fill.a = opacity*0xFF;
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.fill);
SVG_VERBOSE(" input : \"" << outputValue << "\" == > " << m_paint.fill);
} else if (outputType == "stroke-opacity") {
float opacity = ParseLength(outputValue);
float opacity = parseLength(outputValue);
opacity = etk_max(0.0, etk_min(1.0, opacity));
m_paint.stroke.a = opacity*0xFF;
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.stroke);
SVG_VERBOSE(" input : \"" << outputValue << "\" == > " << m_paint.stroke);
} else if (outputType == "fill-rule" ) {
if (outputValue == "nonzero" ) {
m_paint.flagEvenOdd = false;
@ -372,15 +372,15 @@ void esvg::Base::ParsePaintAttr(const exml::Element *_element)
}
/**
* @brief Parse a color specification from the svg file
* @brief parse a color specification from the svg file
* @param[in] _inputData Data C String with the xml definition
* @return the parsed color
*/
draw::Color esvg::Base::ParseColor(const etk::UString& _inputData)
draw::Color esvg::Base::parseColor(const etk::UString& _inputData)
{
draw::Color localColor = draw::color::white;
if( _inputData.Size() > 4
if( _inputData.size() > 4
&& _inputData[0] == 'u'
&& _inputData[1] == 'r'
&& _inputData[2] == 'l'
@ -388,21 +388,21 @@ draw::Color esvg::Base::ParseColor(const etk::UString& _inputData)
if (_inputData[4] == '#') {
// TODO : parse gradient ...
}
SVG_ERROR(" pb in parsing the color : \"" << _inputData << "\" ==> url(XXX) is not supported now ...");
SVG_ERROR(" pb in parsing the color : \"" << _inputData << "\" == > url(XXX) is not supported now ...");
} else {
localColor = _inputData.c_str();
}
SVG_VERBOSE("Parse color : \"" << _inputData << "\" ==> " << localColor);
SVG_VERBOSE("Parse color : \"" << _inputData << "\" == > " << localColor);
return localColor;
}
/**
* @brief Parse all the element needed in the basic node
* @brief parse all the element needed in the basic node
* @param[in] _element standart XML node
* @return true if no problem arrived
*/
bool esvg::Base::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
bool esvg::Base::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
SVG_ERROR("NOT IMPLEMENTED");
_sizeMax.setValue(0,0);

View File

@ -40,16 +40,16 @@ namespace esvg
Base(void) {};
Base(PaintState _parentPaintState);
virtual ~Base(void) { };
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
//specific drawing for AAG librairy ...
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans) { };
virtual void Display(int32_t _spacing) { };
void ParseTransform(exml::Element *_element);
void ParsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size);
float ParseLength(const etk::UString& _dataInput);
void ParsePaintAttr(const exml::Element *_element);
draw::Color ParseColor(const etk::UString& _inputData);
void parseTransform(exml::Element *_element);
void parsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size);
float parseLength(const etk::UString& _dataInput);
void parsePaintAttr(const exml::Element *_element);
draw::Color parseColor(const etk::UString& _inputData);
};
};

View File

@ -24,38 +24,38 @@ esvg::Circle::~Circle(void)
}
bool esvg::Circle::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
bool esvg::Circle::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
m_radius = 0.0;
m_position.setValue(0,0);
if (NULL==_element) {
if (NULL == _element) {
return false;
}
ParseTransform(_element);
ParsePaintAttr(_element);
parseTransform(_element);
parsePaintAttr(_element);
// add the property of the parrent modifications ...
m_transformMatrix *= _parentTrans;
etk::UString content = _element->GetAttribute("cx");
if (content.Size()!=0) {
m_position.setX(ParseLength(content));
etk::UString content = _element->getAttribute("cx");
if (content.size()!=0) {
m_position.setX(parseLength(content));
}
content = _element->GetAttribute("cy");
if (content.Size()!=0) {
m_position.setY(ParseLength(content));
content = _element->getAttribute("cy");
if (content.size()!=0) {
m_position.setY(parseLength(content));
}
content = _element->GetAttribute("r");
if (content.Size()!=0) {
m_radius = ParseLength(content);
content = _element->getAttribute("r");
if (content.size()!=0) {
m_radius = parseLength(content);
} else {
SVG_ERROR("(l "<<_element->GetPos()<<") Circle \"r\" is not present");
SVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is not present");
return false;
}
if (0 > m_radius) {
m_radius = 0;
SVG_ERROR("(l "<<_element->GetPos()<<") Circle \"r\" is negative");
SVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is negative");
return false;
}
_sizeMax.setValue(m_position.x() + m_radius, m_position.y() + m_radius);
@ -89,7 +89,7 @@ void esvg::Circle::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basi
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
// Drawing as an outline
// drawing as an outline
agg::conv_stroke<agg::ellipse> myCircleStroke(myCircle);
myCircleStroke.width(m_paint.strokeWidth);
agg::conv_transform<agg::conv_stroke<agg::ellipse>, agg::trans_affine> transStroke(myCircleStroke, mtx);

View File

@ -21,7 +21,7 @@ namespace esvg
public:
Circle(PaintState _parentPaintState);
~Circle(void);
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};

View File

@ -24,13 +24,13 @@ esvg::Ellipse::~Ellipse(void)
}
bool esvg::Ellipse::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
bool esvg::Ellipse::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
if (NULL==_element) {
if (NULL == _element) {
return false;
}
ParseTransform(_element);
ParsePaintAttr(_element);
parseTransform(_element);
parsePaintAttr(_element);
// add the property of the parrent modifications ...
m_transformMatrix *= _parentTrans;
@ -38,26 +38,26 @@ bool esvg::Ellipse::Parse(exml::Element * _element, agg::trans_affine& _parentTr
m_c.setValue(0,0);
m_r.setValue(0,0);
etk::UString content = _element->GetAttribute("cx");
if (content.Size()!=0) {
m_c.setX(ParseLength(content));
etk::UString content = _element->getAttribute("cx");
if (content.size()!=0) {
m_c.setX(parseLength(content));
}
content = _element->GetAttribute("cy");
if (content.Size()!=0) {
m_c.setY(ParseLength(content));
content = _element->getAttribute("cy");
if (content.size()!=0) {
m_c.setY(parseLength(content));
}
content = _element->GetAttribute("rx");
if (content.Size()!=0) {
m_r.setX(ParseLength(content));
content = _element->getAttribute("rx");
if (content.size()!=0) {
m_r.setX(parseLength(content));
} else {
SVG_ERROR("(l "<<_element->GetPos()<<") Ellipse \"rx\" is not present");
SVG_ERROR("(l "<<_element->getPos()<<") Ellipse \"rx\" is not present");
return false;
}
content = _element->GetAttribute("ry");
if (content.Size()!=0) {
m_r.setY(ParseLength(content));
content = _element->getAttribute("ry");
if (content.size()!=0) {
m_r.setY(parseLength(content));
} else {
SVG_ERROR("(l "<<_element->GetPos()<<") Ellipse \"ry\" is not present");
SVG_ERROR("(l "<<_element->getPos()<<") Ellipse \"ry\" is not present");
return false;
}
_sizeMax.setValue(m_c.x() + m_r.x(), m_c.y() + m_r.y());
@ -92,7 +92,7 @@ void esvg::Ellipse::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _bas
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
// Drawing as an outline
// drawing as an outline
agg::conv_stroke<agg::ellipse> myEllipseStroke(myEllipse);
myEllipseStroke.width(m_paint.strokeWidth);
agg::conv_transform<agg::conv_stroke<agg::ellipse>, agg::trans_affine> transStroke(myEllipseStroke, mtx);

View File

@ -21,7 +21,7 @@ namespace esvg
public:
Ellipse(PaintState _parentPaintState);
~Ellipse(void);
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};

View File

@ -33,17 +33,17 @@ esvg::Group::~Group(void)
}
bool esvg::Group::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
bool esvg::Group::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
if (NULL==_element) {
if (NULL == _element) {
return false;
}
// parse ...
etk::Vector2D<float> pos(0,0);
etk::Vector2D<float> size(0,0);
ParseTransform(_element);
ParsePosition(_element, pos, size);
ParsePaintAttr(_element);
parseTransform(_element);
parsePosition(_element, pos, size);
parsePaintAttr(_element);
SVG_VERBOSE("parsed G1. trans : (" << m_transformMatrix.sx << "," << m_transformMatrix.shy << "," << m_transformMatrix.shx << "," << m_transformMatrix.sy << "," << m_transformMatrix.tx << "," << m_transformMatrix.ty << ")");
// add the property of the parrent modifications ...
@ -54,48 +54,48 @@ bool esvg::Group::Parse(exml::Element * _element, agg::trans_affine& _parentTran
_sizeMax.setValue(0,0);
vec2 tmpPos(0,0);
// parse all sub node :
for(int32_t iii=0; iii<_element->Size() ; iii++) {
exml::Element* child = _element->GetElement(iii);
for(int32_t iii=0; iii<_element->size() ; iii++) {
exml::Element* child = _element->getElement(iii);
if (NULL == child) {
// can be a comment ...
continue;
}
esvg::Base *elementParser = NULL;
if (child->GetValue() == "g") {
if (child->getValue() == "g") {
elementParser = new esvg::Group(m_paint);
} else if (child->GetValue() == "a") {
} else if (child->getValue() == "a") {
// TODO ...
} else if (child->GetValue() == "path") {
} else if (child->getValue() == "path") {
elementParser = new esvg::Path(m_paint);
} else if (child->GetValue() == "rect") {
} else if (child->getValue() == "rect") {
elementParser = new esvg::Rectangle(m_paint);
} else if (child->GetValue() == "circle") {
} else if (child->getValue() == "circle") {
elementParser = new esvg::Circle(m_paint);
} else if (child->GetValue() == "ellipse") {
} else if (child->getValue() == "ellipse") {
elementParser = new esvg::Ellipse(m_paint);
} else if (child->GetValue() == "line") {
} else if (child->getValue() == "line") {
elementParser = new esvg::Line(m_paint);
} else if (child->GetValue() == "polyline") {
} else if (child->getValue() == "polyline") {
elementParser = new esvg::Polyline(m_paint);
} else if (child->GetValue() == "polygon") {
} else if (child->getValue() == "polygon") {
elementParser = new esvg::Polygon(m_paint);
} else if (child->GetValue() == "text") {
} else if (child->getValue() == "text") {
elementParser = new esvg::Text(m_paint);
} else {
SVG_ERROR("(l "<<child->GetPos()<<") node not suported : \""<<child->GetValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
SVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->GetValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
}
if (NULL == elementParser) {
SVG_ERROR("(l "<<child->GetPos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ...");
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ...");
} else {
if (false == elementParser->Parse(child, m_transformMatrix, tmpPos)) {
SVG_ERROR("(l "<<child->GetPos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR");
if (false == elementParser->parse(child, m_transformMatrix, tmpPos)) {
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR");
delete(elementParser);
elementParser = NULL;
} else {
_sizeMax.setValue(etk_max(_sizeMax.x(), tmpPos.x()),
etk_max(_sizeMax.y(), tmpPos.y()));
// add element in the system
m_subElementList.PushBack(elementParser);
m_subElementList.pushBack(elementParser);
}
}
}
@ -105,7 +105,7 @@ bool esvg::Group::Parse(exml::Element * _element, agg::trans_affine& _parentTran
void esvg::Group::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Group (START) fill=" << m_paint.fill << " stroke=" << m_paint.stroke << " stroke-width=" << m_paint.strokeWidth );
for (int32_t iii=0; iii<m_subElementList.Size(); iii++) {
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
if (NULL != m_subElementList[iii]) {
m_subElementList[iii]->Display(_spacing+1);
}
@ -115,7 +115,7 @@ void esvg::Group::Display(int32_t _spacing)
void esvg::Group::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
{
for (int32_t iii=0; iii<m_subElementList.Size(); iii++) {
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
if (NULL != m_subElementList[iii]) {
m_subElementList[iii]->AggDraw(_myRenderer, _basicTrans);
}

View File

@ -21,7 +21,7 @@ namespace esvg
public:
Group(PaintState _parentPaintState);
~Group(void);
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};

View File

@ -25,34 +25,34 @@ esvg::Line::~Line(void)
}
bool esvg::Line::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
bool esvg::Line::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
// line must have a minimum size...
m_paint.strokeWidth = 1;
if (NULL==_element) {
if (NULL == _element) {
return false;
}
ParseTransform(_element);
ParsePaintAttr(_element);
parseTransform(_element);
parsePaintAttr(_element);
// add the property of the parrent modifications ...
m_transformMatrix *= _parentTrans;
etk::UString content = _element->GetAttribute("x1");
if (content.Size()!=0) {
m_startPos.setX(ParseLength(content));
etk::UString content = _element->getAttribute("x1");
if (content.size()!=0) {
m_startPos.setX(parseLength(content));
}
content = _element->GetAttribute("y1");
if (content.Size()!=0) {
m_startPos.setY(ParseLength(content));
content = _element->getAttribute("y1");
if (content.size()!=0) {
m_startPos.setY(parseLength(content));
}
content = _element->GetAttribute("x2");
if (content.Size()!=0) {
m_stopPos.setX(ParseLength(content));
content = _element->getAttribute("x2");
if (content.size()!=0) {
m_stopPos.setX(parseLength(content));
}
content = _element->GetAttribute("y2");
if (content.Size()!=0) {
m_stopPos.setY(ParseLength(content));
content = _element->getAttribute("y2");
if (content.size()!=0) {
m_stopPos.setY(parseLength(content));
}
_sizeMax.setValue(etk_max(m_startPos.x(), m_stopPos.x()),
etk_max(m_startPos.y(), m_stopPos.y()));
@ -101,7 +101,7 @@ void esvg::Line::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicT
if (m_paint.strokeWidth > 0) {
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
// Drawing as an outline
// drawing as an outline
agg::conv_stroke<agg::path_storage> myPolygonStroke(path);
myPolygonStroke.width(m_paint.strokeWidth);
agg::conv_transform<agg::conv_stroke<agg::path_storage>, agg::trans_affine> transStroke(myPolygonStroke, mtx);

View File

@ -21,7 +21,7 @@ namespace esvg
public:
Line(PaintState parentPaintState);
~Line(void);
virtual bool Parse(exml::Element * _element, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
virtual bool parse(exml::Element * _element, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
virtual void Display(int32_t spacing);
virtual void AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
};

View File

@ -34,7 +34,7 @@ const char * extractCmd(const char* input, char& cmd, etk::Vector<float>& output
if (*input == '\0') {
return NULL;
}
outputList.Clear();
outputList.clear();
cmd = '\0';
const char * outputPointer = NULL;
if (!( (input[0] <= 'Z' && input[0] >= 'A') || (input[0] <= 'z' && input[0] >= 'a') ) ) {
@ -54,7 +54,7 @@ const char * extractCmd(const char* input, char& cmd, etk::Vector<float>& output
while( sscanf(&input[iii], "%1[, ]%f%n", spacer, &element, &nbElementRead) == 2
|| sscanf(&input[iii], "%f%n", &element, &nbElementRead) == 1) {
SVG_VERBOSE("Find element : " << element);
outputList.PushBack(element);
outputList.pushBack(element);
iii += nbElementRead;
}
outputPointer = &input[iii];
@ -65,21 +65,21 @@ const char * extractCmd(const char* input, char& cmd, etk::Vector<float>& output
return outputPointer;
}
bool esvg::Path::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
if (NULL==_element) {
if (NULL == _element) {
return false;
}
ParseTransform(_element);
ParsePaintAttr(_element);
parseTransform(_element);
parsePaintAttr(_element);
// add the property of the parrent modifications ...
m_transformMatrix *= _parentTrans;
etk::UString elementXML1 = _element->GetAttribute("d");
if (elementXML1.Size()==0) {
SVG_ERROR("(l "<<_element->GetPos()<<") path: missing 'p' attribute");
etk::UString elementXML1 = _element->getAttribute("d");
if (elementXML1.size() == 0) {
SVG_ERROR("(l "<<_element->getPos()<<") path: missing 'p' attribute");
return false;
}
SVG_VERBOSE("Parse Path : \"" << elementXML << "\"");
@ -96,10 +96,10 @@ bool esvg::Path::Parse(exml::Element * _element, agg::trans_affine& _parentTrans
pathBasic_ts pathElement;
memset(&pathElement, 0, 1*sizeof(pathBasic_ts));
switch(command) {
case 'M': // Move To (absolute)
case 'L': // Line To (absolute)
case 'V': // Vertical Line To (absolute)
case 'H': // Horizantal Line To (absolute)
case 'M': // Move to (absolute)
case 'L': // Line to (absolute)
case 'V': // Vertical Line to (absolute)
case 'H': // Horizantal Line to (absolute)
case 'Q': // Quadratic Bezier curve (absolute)
case 'T': // smooth quadratic Bezier curve to (absolute)
case 'C': // curve to (absolute)
@ -113,147 +113,147 @@ bool esvg::Path::Parse(exml::Element * _element, agg::trans_affine& _parentTrans
break;
}
switch(command) {
case 'M': // Move To (absolute)
case 'm': // Move To (relative)
case 'M': // Move to (absolute)
case 'm': // Move to (relative)
// 2 Elements ...
if(listDot.Size()%2 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.Size() );
if(listDot.size()%2 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_MOVETO;
if (listDot.Size() >= 2) {
if (listDot.size() >= 2) {
pathElement.element[0] = listDot[0];
pathElement.element[1] = listDot[1];
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
}
pathElement.cmd = esvg::PATH_ENUM_LINETO;
for(int32_t iii=2; iii<listDot.Size(); iii+=2) {
for(int32_t iii=2; iii<listDot.size(); iii+=2) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
}
break;
case 'L': // Line To (absolute)
case 'l': // Line To (relative)
case 'L': // Line to (absolute)
case 'l': // Line to (relative)
// 2 Elements ...
if(listDot.Size()%2 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.Size() );
if(listDot.size()%2 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_LINETO;
for(int32_t iii=0; iii<listDot.Size(); iii+=2) {
for(int32_t iii=0; iii<listDot.size(); iii+=2) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
}
break;
case 'V': // Vertical Line To (absolute)
case 'v': // Vertical Line To (relative)
case 'V': // Vertical Line to (absolute)
case 'v': // Vertical Line to (relative)
// 1 Element ...
if(listDot.Size() == 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.Size() );
if(listDot.size() == 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_LINETO_V;
for(int32_t iii=0; iii<listDot.Size(); iii+=1) {
for(int32_t iii=0; iii<listDot.size(); iii+=1) {
pathElement.element[0] = listDot[iii];
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
}
break;
case 'H': // Horizantal Line To (absolute)
case 'h': // Horizantal Line To (relative)
case 'H': // Horizantal Line to (absolute)
case 'h': // Horizantal Line to (relative)
// 1 Element ...
if(listDot.Size() == 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.Size() );
if(listDot.size() == 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_LINETO_H;
for(int32_t iii=0; iii<listDot.Size(); iii+=1) {
for(int32_t iii=0; iii<listDot.size(); iii+=1) {
pathElement.element[0] = listDot[iii];
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
}
break;
case 'Q': // Quadratic Bezier curve (absolute)
case 'q': // Quadratic Bezier curve (relative)
// 4 Elements ...
if(listDot.Size()%4 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.Size() );
if(listDot.size()%4 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_BEZIER_CURVETO;
for(int32_t iii=0; iii<listDot.Size(); iii+=4) {
for(int32_t iii=0; iii<listDot.size(); iii+=4) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.element[2] = listDot[iii+2];
pathElement.element[3] = listDot[iii+3];
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
}
break;
case 'T': // smooth quadratic Bezier curve to (absolute)
case 't': // smooth quadratic Bezier curve to (relative)
// 2 Elements ...
if(listDot.Size()%2 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.Size() );
if(listDot.size()%2 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_BEZIER_SMOTH_CURVETO;
for(int32_t iii=0; iii<listDot.Size(); iii+=2) {
for(int32_t iii=0; iii<listDot.size(); iii+=2) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
}
break;
case 'C': // curve to (absolute)
case 'c': // curve to (relative)
// 6 Elements ...
if(listDot.Size()%6 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.Size() );
if(listDot.size()%6 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_CURVETO;
for(int32_t iii=0; iii<listDot.Size(); iii+=6) {
for(int32_t iii=0; iii<listDot.size(); iii+=6) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.element[2] = listDot[iii+2];
pathElement.element[3] = listDot[iii+3];
pathElement.element[4] = listDot[iii+4];
pathElement.element[5] = listDot[iii+5];
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
}
break;
case 'S': // smooth curve to (absolute)
case 's': // smooth curve to (relative)
// 4 Elements ...
if(listDot.Size()%4 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.Size() );
if(listDot.size()%4 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_SMOTH_CURVETO;
for(int32_t iii=0; iii<listDot.Size(); iii+=4) {
for(int32_t iii=0; iii<listDot.size(); iii+=4) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.element[2] = listDot[iii+2];
pathElement.element[3] = listDot[iii+3];
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
}
break;
case 'A': // elliptical Arc (absolute)
case 'a': // elliptical Arc (relative)
// 7 Elements ...
if(listDot.Size()%7 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.Size() );
if(listDot.size()%7 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_ELLIPTIC;
for(int32_t iii=0; iii<listDot.Size(); iii+=7) {
for(int32_t iii=0; iii<listDot.size(); iii+=7) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.element[2] = listDot[iii+2];
@ -261,18 +261,18 @@ bool esvg::Path::Parse(exml::Element * _element, agg::trans_affine& _parentTrans
pathElement.element[4] = listDot[iii+4];
pathElement.element[5] = listDot[iii+5];
pathElement.element[6] = listDot[iii+6];
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
}
break;
case 'Z': // closepath (absolute)
case 'z': // closepath (relative)
// 0 Element ...
if(listDot.Size() != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.Size() );
if(listDot.size() != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_STOP;
m_listElement.PushBack(pathElement);
m_listElement.pushBack(pathElement);
break;
default:
SVG_ERROR ("Unknow error : \"" << command << "\"");
@ -285,7 +285,7 @@ bool esvg::Path::Parse(exml::Element * _element, agg::trans_affine& _parentTrans
void esvg::Path::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Path");
for(int32_t iii=0; iii<m_listElement.Size(); iii++) {
for(int32_t iii=0; iii<m_listElement.size(); iii++) {
switch (m_listElement[iii].cmd) {
case PATH_ENUM_STOP:
SVG_DEBUG(SpacingDist(_spacing+4) << "STOP");
@ -346,7 +346,7 @@ void esvg::Path::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicT
path.start_new_path();
for(int32_t iii=0; iii<m_listElement.Size(); iii++) {
for(int32_t iii=0; iii<m_listElement.size(); iii++) {
switch (m_listElement[iii].cmd) {
case PATH_ENUM_STOP:
AbstractCloseSubpath(path);
@ -423,7 +423,7 @@ void esvg::Path::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicT
}
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
// Drawing as an outline
// drawing as an outline
agg::conv_stroke<agg::conv_curve<agg::path_storage> > myPolygonStroke(curve);
myPolygonStroke.width(m_paint.strokeWidth);
agg::conv_transform<agg::conv_stroke<agg::conv_curve<agg::path_storage> >, agg::trans_affine> transStroke(myPolygonStroke, mtx);

View File

@ -40,7 +40,7 @@ namespace esvg
public:
Path(PaintState _parentPaintState);
~Path(void);
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
private:

View File

@ -24,13 +24,13 @@ esvg::Polygon::~Polygon(void)
}
bool esvg::Polygon::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
bool esvg::Polygon::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
if (NULL==_element) {
if (NULL == _element) {
return false;
}
ParseTransform(_element);
ParsePaintAttr(_element);
parseTransform(_element);
parsePaintAttr(_element);
SVG_VERBOSE("parsed P1. trans : (" << m_transformMatrix.sx << "," << m_transformMatrix.shy << "," << m_transformMatrix.shx << "," << m_transformMatrix.sy << "," << m_transformMatrix.tx << "," << m_transformMatrix.ty << ")");
@ -39,8 +39,8 @@ bool esvg::Polygon::Parse(exml::Element * _element, agg::trans_affine& _parentTr
SVG_VERBOSE("parsed P2. trans : (" << m_transformMatrix.sx << "," << m_transformMatrix.shy << "," << m_transformMatrix.shx << "," << m_transformMatrix.sy << "," << m_transformMatrix.tx << "," << m_transformMatrix.ty << ")");
const etk::UString sss1 = _element->GetAttribute("points");
if (sss1.Size()==0) {
const etk::UString sss1 = _element->getAttribute("points");
if (sss1.size() == 0) {
SVG_ERROR("(l "/*<<_element->Pos()*/<<") polygon: missing points attribute");
return false;
}
@ -52,7 +52,7 @@ bool esvg::Polygon::Parse(exml::Element * _element, agg::trans_affine& _parentTr
vec2 pos(0,0);
int32_t n;
if (sscanf(sss, "%f,%f%n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
m_listPoint.PushBack(pos);
m_listPoint.pushBack(pos);
sss += n;
_sizeMax.setValue(etk_max(_sizeMax.x(), pos.x()),
etk_max(_sizeMax.y(), pos.y()));
@ -68,7 +68,7 @@ bool esvg::Polygon::Parse(exml::Element * _element, agg::trans_affine& _parentTr
void esvg::Polygon::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Polygon nbPoint=" << m_listPoint.Size());
SVG_DEBUG(SpacingDist(_spacing) << "Polygon nbPoint=" << m_listPoint.size());
}
void esvg::Polygon::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
@ -79,7 +79,7 @@ void esvg::Polygon::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _bas
path.start_new_path();
path.move_to(m_listPoint[0].x(), m_listPoint[0].y());
for( int32_t iii=1; iii< m_listPoint.Size(); iii++) {
for( int32_t iii=1; iii< m_listPoint.size(); iii++) {
path.line_to(m_listPoint[iii].x(), m_listPoint[iii].y());
}
path.close_polygon();
@ -122,7 +122,7 @@ void esvg::Polygon::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _bas
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
// Drawing as an outline
// drawing as an outline
agg::conv_stroke<agg::path_storage> myPolygonStroke(path);
myPolygonStroke.width(m_paint.strokeWidth);
agg::conv_transform<agg::conv_stroke<agg::path_storage>, agg::trans_affine> transStroke(myPolygonStroke, mtx);

View File

@ -26,7 +26,7 @@ namespace esvg
public:
Polygon(PaintState parentPaintState);
~Polygon(void);
virtual bool Parse(exml::Element * _element, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
virtual bool parse(exml::Element * _element, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
virtual void Display(int32_t spacing);
virtual void AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
};

View File

@ -21,22 +21,22 @@ esvg::Polyline::~Polyline(void)
}
bool esvg::Polyline::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
bool esvg::Polyline::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
// line must have a minimum size...
m_paint.strokeWidth = 1;
if (NULL==_element) {
if (NULL == _element) {
return false;
}
ParseTransform(_element);
ParsePaintAttr(_element);
parseTransform(_element);
parsePaintAttr(_element);
// add the property of the parrent modifications ...
m_transformMatrix *= _parentTrans;
etk::UString sss1 = _element->GetAttribute("points");
if (sss1.Size()==0) {
SVG_ERROR("(l "<<_element->GetPos()<<") polyline: missing points attribute");
etk::UString sss1 = _element->getAttribute("points");
if (sss1.size() == 0) {
SVG_ERROR("(l "<<_element->getPos()<<") polyline: missing points attribute");
return false;
}
_sizeMax.setValue(0,0);
@ -47,7 +47,7 @@ bool esvg::Polyline::Parse(exml::Element * _element, agg::trans_affine& _parentT
etk::Vector2D<float> pos;
int32_t n;
if (sscanf(sss, "%f,%f %n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
m_listPoint.PushBack(pos);
m_listPoint.pushBack(pos);
_sizeMax.setValue(etk_max(_sizeMax.x(), pos.x()),
etk_max(_sizeMax.y(), pos.y()));
sss += n;
@ -60,7 +60,7 @@ bool esvg::Polyline::Parse(exml::Element * _element, agg::trans_affine& _parentT
void esvg::Polyline::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Polyline nbPoint=" << m_listPoint.Size());
SVG_DEBUG(SpacingDist(_spacing) << "Polyline nbPoint=" << m_listPoint.size());
}
@ -69,7 +69,7 @@ void esvg::Polyline::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _ba
agg::path_storage path;
path.start_new_path();
path.move_to(m_listPoint[0].x(), m_listPoint[0].y());
for( int32_t iii=1; iii< m_listPoint.Size(); iii++) {
for( int32_t iii=1; iii< m_listPoint.size(); iii++) {
path.line_to(m_listPoint[iii].x(), m_listPoint[iii].y());
}
/*
@ -103,7 +103,7 @@ void esvg::Polyline::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _ba
if (m_paint.strokeWidth > 0) {
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
// Drawing as an outline
// drawing as an outline
agg::conv_stroke<agg::path_storage> myPolygonStroke(path);
myPolygonStroke.width(m_paint.strokeWidth);
agg::conv_transform<agg::conv_stroke<agg::path_storage>, agg::trans_affine> transStroke(myPolygonStroke, mtx);

View File

@ -21,7 +21,7 @@ namespace esvg
public:
Polyline(PaintState _parentPaintState);
~Polyline(void);
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};

View File

@ -27,30 +27,30 @@ esvg::Rectangle::~Rectangle(void)
}
bool esvg::Rectangle::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
bool esvg::Rectangle::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
if (NULL==_element) {
if (NULL == _element) {
return false;
}
m_position.setValue(0,0);
m_size.setValue(0,0);
m_roundedCorner.setValue(0,0);
ParseTransform(_element);
ParsePaintAttr(_element);
parseTransform(_element);
parsePaintAttr(_element);
// add the property of the parrent modifications ...
m_transformMatrix *= _parentTrans;
ParsePosition(_element, m_position, m_size);
parsePosition(_element, m_position, m_size);
etk::UString content = _element->GetAttribute("rx");
if (content.Size()!=0) {
m_roundedCorner.setX(ParseLength(content));
etk::UString content = _element->getAttribute("rx");
if (content.size()!=0) {
m_roundedCorner.setX(parseLength(content));
}
content = _element->GetAttribute("ry");
if (content.Size()!=0) {
m_roundedCorner.setY(ParseLength(content));
content = _element->getAttribute("ry");
if (content.size()!=0) {
m_roundedCorner.setY(parseLength(content));
}
_sizeMax.setValue(m_position.x() + m_size.x() + m_paint.strokeWidth,
m_position.y() + m_size.y() + m_paint.strokeWidth);
@ -84,7 +84,7 @@ void esvg::Rectangle::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _b
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
// Drawing as an outline
// drawing as an outline
agg::conv_stroke<agg::rounded_rect> rect_p(rect_r);
// set the filling mode :
_myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);

View File

@ -22,7 +22,7 @@ namespace esvg
public:
Rectangle(PaintState _parentPaintState);
~Rectangle(void);
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};

View File

@ -67,8 +67,8 @@ namespace esvg
rendererSolid_t * m_renderArea;
agg::rasterizer_scanline_aa<> m_rasterizer; //!< AGG renderer system
agg::scanline_p8 m_scanLine; //!<
uint8_t* GetDataPointer(void) { return m_buffer; };
uint32_t GetDataSize(void) { return m_allocatedSize; };
uint8_t* getDataPointer(void) { return m_buffer; };
uint32_t getDataSize(void) { return m_allocatedSize; };
};
};

View File

@ -22,7 +22,7 @@ esvg::Text::~Text(void)
}
bool esvg::Text::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
bool esvg::Text::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
_sizeMax.setValue(0,0);
SVG_ERROR("NOT IMPLEMENTED");

View File

@ -20,7 +20,7 @@ namespace esvg
public:
Text(PaintState _parentPaintState);
~Text(void);
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
};
};

View File

@ -57,78 +57,78 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
return;
}
if (0 == doc.Size() ) {
if (0 == doc.size() ) {
SVG_ERROR("(l ?) No nodes in the xml file ... \"" << m_fileName << "\"");
m_loadOK = false;
return;
}
exml::Element* root = (exml::Element*)doc.GetNamed( "svg" );
exml::Element* root = (exml::Element*)doc.getNamed( "svg" );
if (NULL == root ) {
SVG_ERROR("(l ?) main node not find: \"svg\" in \"" << m_fileName << "\"");
m_loadOK = false;
return;
}
// get the svg version :
m_version = root->GetAttribute("version");
m_version = root->getAttribute("version");
// parse ...
vec2 pos(0,0);
ParseTransform(root);
ParsePosition(root, pos, m_size);
ParsePaintAttr(root);
parseTransform(root);
parsePosition(root, pos, m_size);
parsePaintAttr(root);
SVG_VERBOSE("parsed .ROOT trans : (" << m_transformMatrix.sx << "," << m_transformMatrix.shy << "," << m_transformMatrix.shx << "," << m_transformMatrix.sy << "," << m_transformMatrix.tx << "," << m_transformMatrix.ty << ")");
vec2 maxSize(0,0);
vec2 size(0,0);
// parse all sub node :
for(int32_t iii=0; iii< root->Size(); iii++) {
exml::Element* child = root->GetElement(iii);
if (child==NULL) {
for(int32_t iii=0; iii< root->size(); iii++) {
exml::Element* child = root->getElement(iii);
if (child == NULL) {
// comment trsh here...
continue;
}
esvg::Base *elementParser = NULL;
if (child->GetValue() == "g") {
if (child->getValue() == "g") {
elementParser = new esvg::Group(m_paint);
} else if (child->GetValue() == "a") {
} else if (child->getValue() == "a") {
SVG_INFO("Note : 'a' balise is parsed like a g balise ...");
elementParser = new esvg::Group(m_paint);
} else if (child->GetValue() == "title") {
} else if (child->getValue() == "title") {
m_title = "TODO : set the title here ...";
continue;
} else if (child->GetValue() == "path") {
} else if (child->getValue() == "path") {
elementParser = new esvg::Path(m_paint);
} else if (child->GetValue() == "rect") {
} else if (child->getValue() == "rect") {
elementParser = new esvg::Rectangle(m_paint);
} else if (child->GetValue() == "circle") {
} else if (child->getValue() == "circle") {
elementParser = new esvg::Circle(m_paint);
} else if (child->GetValue() == "ellipse") {
} else if (child->getValue() == "ellipse") {
elementParser = new esvg::Ellipse(m_paint);
} else if (child->GetValue() == "line") {
} else if (child->getValue() == "line") {
elementParser = new esvg::Line(m_paint);
} else if (child->GetValue() == "polyline") {
} else if (child->getValue() == "polyline") {
elementParser = new esvg::Polyline(m_paint);
} else if (child->GetValue() == "polygon") {
} else if (child->getValue() == "polygon") {
elementParser = new esvg::Polygon(m_paint);
} else if (child->GetValue() == "text") {
} else if (child->getValue() == "text") {
elementParser = new esvg::Text(m_paint);
} else if (child->GetValue() == "defs") {
} else if (child->getValue() == "defs") {
// Node ignore : must implement it later ...
continue;
} else if (child->GetValue() == "sodipodi:namedview") {
} else if (child->getValue() == "sodipodi:namedview") {
// Node ignore : generaly inkscape data
continue;
} else if (child->GetValue() == "metadata") {
} else if (child->getValue() == "metadata") {
// Node ignore : generaly inkscape data
continue;
} else {
SVG_ERROR("(l "<<child->GetPos()<<") node not suported : \""<<child->GetValue()<<"\" must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
SVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->GetValue()<<"\" must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
}
if (NULL == elementParser) {
SVG_ERROR("(l "<<child->GetPos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ...");
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ...");
continue;
}
if (false == elementParser->Parse(child, m_transformMatrix, size)) {
SVG_ERROR("(l "<<child->GetPos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR");
if (false == elementParser->parse(child, m_transformMatrix, size)) {
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR");
delete(elementParser);
elementParser = NULL;
continue;
@ -140,9 +140,9 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
maxSize.setY(size.y());
}
// add element in the system
m_subElementList.PushBack(elementParser);
m_subElementList.pushBack(elementParser);
}
if (m_size.x()==0 || m_size.y()==0) {
if (m_size.x() == 0 || m_size.y()==0) {
m_size.setValue((int32_t)maxSize.x(), (int32_t)maxSize.y());
} else {
m_size.setValue((int32_t)m_size.x(), (int32_t)m_size.y());
@ -163,7 +163,7 @@ esvg::Document::~Document(void)
void esvg::Document::DisplayDebug(void)
{
SVG_DEBUG("Main SVG node : size=" << m_size);
for (int32_t iii=0; iii<m_subElementList.Size(); iii++) {
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
if (NULL != m_subElementList[iii]) {
m_subElementList[iii]->Display(1);
}
@ -173,7 +173,7 @@ void esvg::Document::DisplayDebug(void)
void esvg::Document::AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans)
{
for (int32_t iii=0; iii<m_subElementList.Size(); iii++) {
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
if (NULL != m_subElementList[iii]) {
m_subElementList[iii]->AggDraw(myRenderer, basicTrans);
}
@ -181,21 +181,21 @@ void esvg::Document::AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basi
}
void esvg::Document::GenerateTestFile(void)
void esvg::Document::generateTestFile(void)
{
int32_t SizeX = m_size.x();
int32_t sizeX = m_size.x();
if (SizeX == 0) {
SizeX = 64;
sizeX = 64;
}
int32_t SizeY = m_size.y();
int32_t sizeY = m_size.y();
if (SizeY == 0) {
SizeY = 64;
sizeY = 64;
}
if(NULL != m_renderedElement) {
delete(m_renderedElement);
m_renderedElement = NULL;
}
m_renderedElement = new esvg::Renderer(SizeX, SizeY);
m_renderedElement = new esvg::Renderer(SizeX, sizeY);
// create the first element matrix modification ...
agg::trans_affine basicTrans;
//basicTrans *= agg::trans_affine_translation(-g_base_dx, -g_base_dy);
@ -216,29 +216,29 @@ void esvg::Document::GenerateTestFile(void)
void esvg::Document::GenerateAnImage(int32_t sizeX, int32_t sizeY)
void esvg::Document::generateAnImage(int32_t sizeX, int32_t sizeY)
{
int32_t SizeX = sizeX;
int32_t sizeX = sizeX;
if (SizeX == 0) {
SVG_ERROR("SizeX == 0 ==> set 64");
SizeX = 64;
sizeX = 64;
}
int32_t SizeY = sizeY;
int32_t sizeY = sizeY;
if (SizeY == 0) {
SVG_ERROR("SizeY == 0 ==> set 64");
SizeY = 64;
sizeY = 64;
}
SVG_INFO("Generate size (" << SizeX << "," << SizeY << ")");
SVG_INFO("Generate size (" << sizeX << "," << SizeY << ")");
if(NULL != m_renderedElement) {
delete(m_renderedElement);
m_renderedElement = NULL;
}
m_renderedElement = new esvg::Renderer(SizeX, SizeY);
m_renderedElement = new esvg::Renderer(SizeX, sizeY);
// create the first element matrix modification ...
agg::trans_affine basicTrans;
//basicTrans *= agg::trans_affine_translation(-g_base_dx, -g_base_dy);
basicTrans *= agg::trans_affine_scaling(SizeX/m_size.x(), SizeY/m_size.y());
basicTrans *= agg::trans_affine_scaling(SizeX/m_size.x(), sizeY/m_size.y());
//basicTrans *= agg::trans_affine_rotation(g_angle);// + agg::pi);
//basicTrans *= agg::trans_affine_skewing(2.0, 5.0);
//basicTrans *= agg::trans_affine_translation(width*0.3, height/2);
@ -251,40 +251,40 @@ void esvg::Document::GenerateAnImage(int32_t sizeX, int32_t sizeY)
*/
}
void esvg::Document::GenerateAnImage(draw::Image& output)
void esvg::Document::generateAnImage(draw::Image& output)
{
GenerateAnImage(ivec2(m_size.x(),m_size.y()), output);
generateAnImage(ivec2(m_size.x(),m_size.y()), output);
}
void esvg::Document::GenerateAnImage(ivec2 size, draw::Image& output)
void esvg::Document::generateAnImage(ivec2 size, draw::Image& output)
{
GenerateAnImage(size.x(), size.y());
generateAnImage(size.x(), size.y());
output.Resize(size);
draw::Color tmpp(0,0,0,0);
output.SetFillColor(tmpp);
output.Clear();
output.setFillColor(tmpp);
output.clear();
if(NULL != m_renderedElement) {
uint8_t* pointerOnData = m_renderedElement->GetDataPointer();
int32_t sizeData = m_renderedElement->GetDataSize();
uint8_t* tmpOut = (uint8_t*)output.GetTextureDataPointer();
uint8_t* pointerOnData = m_renderedElement->getDataPointer();
int32_t sizeData = m_renderedElement->getDataSize();
uint8_t* tmpOut = (uint8_t*)output.getTextureDataPointer();
memcpy(tmpOut, pointerOnData, sizeData);
}
}
uint8_t* esvg::Document::GetPointerOnData(void)
uint8_t* esvg::Document::getPointerOnData(void)
{
if(NULL == m_renderedElement) {
return NULL;
}
return m_renderedElement->GetDataPointer();
return m_renderedElement->getDataPointer();
}
uint32_t esvg::Document::GetSizeOnData(void)
uint32_t esvg::Document::getSizeOnData(void)
{
if(NULL == m_renderedElement) {
return 0;
}
return m_renderedElement->GetDataSize();
return m_renderedElement->getDataSize();
}

View File

@ -33,16 +33,16 @@ namespace esvg
public:
Document(const etk::UString& _fileName);
~Document(void);
bool IsLoadOk(void) { return m_loadOK; };
bool isLoadOk(void) { return m_loadOK; };
void DisplayDebug(void);
void GenerateTestFile(void);
void GenerateAnImage(int32_t _sizeX, int32_t _sizeY);
void GenerateAnImage(ivec2 _size, draw::Image& _output);
void GenerateAnImage(draw::Image& _output);
void generateTestFile(void);
void generateAnImage(int32_t _sizeX, int32_t _sizeY);
void generateAnImage(ivec2 _size, draw::Image& _output);
void generateAnImage(draw::Image& _output);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
uint8_t* GetPointerOnData(void);
uint32_t GetSizeOnData(void);
vec2 GetDefinedSize(void) { return m_size;};
uint8_t* getPointerOnData(void);
uint32_t getSizeOnData(void);
vec2 getDefinedSize(void) { return m_size;};
};
};