[DEV] correction of the exml requested elements

This commit is contained in:
Edouard DUPIN 2013-06-26 22:41:10 +02:00
parent 7081b72812
commit 18832b2305
11 changed files with 46 additions and 16 deletions

View File

@ -11,6 +11,10 @@
#include <esvg/Base.h> #include <esvg/Base.h>
#include <math.h> #include <math.h>
#undef __class__
#define __class__ "Base"
esvg::Base::Base(PaintState _parentPaintState) esvg::Base::Base(PaintState _parentPaintState)
{ {
// copy the parent painting properties ... // copy the parent painting properties ...
@ -119,7 +123,7 @@ void esvg::Base::ParsePosition(const exml::Element *_element, etk::Vector2D<floa
*/ */
float esvg::Base::ParseLength(const etk::UString& _dataInput) float esvg::Base::ParseLength(const etk::UString& _dataInput)
{ {
SVG_DEBUG(" lenght : '" << _dataInput << "'"); SVG_VERBOSE(" lenght : '" << _dataInput << "'");
float n = _dataInput.ToFloat(); float n = _dataInput.ToFloat();
etk::UString unit; etk::UString unit;
for (int32_t iii=0; iii<_dataInput.Size(); iii++) { for (int32_t iii=0; iii<_dataInput.Size(); iii++) {
@ -134,7 +138,7 @@ float esvg::Base::ParseLength(const etk::UString& _dataInput)
//SVG_INFO(" ==> ?? = " << n ); //SVG_INFO(" ==> ?? = " << n );
float font_size = 20.0f; float font_size = 20.0f;
SVG_DEBUG(" lenght : '" << n << "' => unit=" << unit); SVG_VERBOSE(" lenght : '" << n << "' => unit=" << unit);
// note : ";" is for the parsing of the style elements ... // note : ";" is for the parsing of the style elements ...
if( unit.Size()==0 if( unit.Size()==0
|| unit[0] == ';' ) { || unit[0] == ';' ) {
@ -388,7 +392,7 @@ draw::Color esvg::Base::ParseColor(const etk::UString& _inputData)
} else { } else {
localColor = _inputData.c_str(); localColor = _inputData.c_str();
} }
SVG_INFO("Parse color : \"" << _inputData << "\" ==> " << localColor); SVG_VERBOSE("Parse color : \"" << _inputData << "\" ==> " << localColor);
return localColor; return localColor;
} }

View File

@ -11,6 +11,8 @@
#include <agg/agg_conv_stroke.h> #include <agg/agg_conv_stroke.h>
#include <agg/agg_ellipse.h> #include <agg/agg_ellipse.h>
#undef __class__
#define __class__ "Circle"
esvg::Circle::Circle(PaintState _parentPaintState) : esvg::Base(_parentPaintState) esvg::Circle::Circle(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{ {

View File

@ -11,6 +11,9 @@
#include <agg/agg_conv_stroke.h> #include <agg/agg_conv_stroke.h>
#include <agg/agg_ellipse.h> #include <agg/agg_ellipse.h>
#undef __class__
#define __class__ "Ellipse"
esvg::Ellipse::Ellipse(PaintState parentPaintState) : esvg::Base(parentPaintState) esvg::Ellipse::Ellipse(PaintState parentPaintState) : esvg::Base(parentPaintState)
{ {

View File

@ -20,6 +20,9 @@
#include <esvg/Text.h> #include <esvg/Text.h>
#include <esvg/Group.h> #include <esvg/Group.h>
#undef __class__
#define __class__ "Group"
esvg::Group::Group(PaintState _parentPaintState) : esvg::Base(_parentPaintState) esvg::Group::Group(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{ {
@ -52,12 +55,9 @@ bool esvg::Group::Parse(exml::Element * _element, agg::trans_affine& _parentTran
vec2 tmpPos(0,0); vec2 tmpPos(0,0);
// parse all sub node : // parse all sub node :
for(int32_t iii=0; iii<_element->Size() ; iii++) { for(int32_t iii=0; iii<_element->Size() ; iii++) {
exml::Node* child = _element->Get(iii); exml::Element* child = _element->GetElement(iii);
if (NULL == child) { if (NULL == child) {
continue; // can be a comment ...
}
if (!child->IsElement()) {
// nothing to do, just proceed to next step
continue; continue;
} }
esvg::Base *elementParser = NULL; esvg::Base *elementParser = NULL;
@ -87,7 +87,7 @@ bool esvg::Group::Parse(exml::Element * _element, agg::trans_affine& _parentTran
if (NULL == elementParser) { if (NULL == elementParser) {
SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ..."); SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ...");
} else { } else {
if (false == elementParser->Parse((exml::Element*)child, m_transformMatrix, tmpPos)) { if (false == elementParser->Parse(child, m_transformMatrix, tmpPos)) {
SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR"); SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR");
delete(elementParser); delete(elementParser);
elementParser = NULL; elementParser = NULL;

View File

@ -11,6 +11,9 @@
#include <agg/agg_conv_stroke.h> #include <agg/agg_conv_stroke.h>
#include <agg/agg_path_storage.h> #include <agg/agg_path_storage.h>
#undef __class__
#define __class__ "Line"
esvg::Line::Line(PaintState parentPaintState) : esvg::Base(parentPaintState) esvg::Line::Line(PaintState parentPaintState) : esvg::Base(parentPaintState)
{ {
m_startPos.setValue(0,0); m_startPos.setValue(0,0);

View File

@ -14,6 +14,9 @@
#include <agg/agg_conv_contour.h> #include <agg/agg_conv_contour.h>
#include <agg/agg_conv_smooth_poly1.h> #include <agg/agg_conv_smooth_poly1.h>
#undef __class__
#define __class__ "Path"
esvg::Path::Path(PaintState _parentPaintState) : esvg::Base(_parentPaintState) esvg::Path::Path(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{ {

View File

@ -11,6 +11,9 @@
#include <agg/agg_conv_stroke.h> #include <agg/agg_conv_stroke.h>
#include <agg/agg_path_storage.h> #include <agg/agg_path_storage.h>
#undef __class__
#define __class__ "Polygon"
esvg::Polygon::Polygon(PaintState parentPaintState) : esvg::Base(parentPaintState) esvg::Polygon::Polygon(PaintState parentPaintState) : esvg::Base(parentPaintState)
{ {

View File

@ -11,6 +11,10 @@
#include <agg/agg_rounded_rect.h> #include <agg/agg_rounded_rect.h>
#include <agg/agg_conv_stroke.h> #include <agg/agg_conv_stroke.h>
#undef __class__
#define __class__ "Rectangle"
esvg::Rectangle::Rectangle(PaintState _parentPaintState) : esvg::Base(_parentPaintState) esvg::Rectangle::Rectangle(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{ {
m_position.setValue(0,0); m_position.setValue(0,0);

View File

@ -12,6 +12,9 @@
// 4 is for the RGBA ... // 4 is for the RGBA ...
#define DATA_ALLOCATION_ELEMENT (4) #define DATA_ALLOCATION_ELEMENT (4)
#undef __class__
#define __class__ "Renderer"
esvg::Renderer::Renderer(uint32_t width, uint32_t height) esvg::Renderer::Renderer(uint32_t width, uint32_t height)
{ {
m_allocatedSize = 0; m_allocatedSize = 0;

View File

@ -9,6 +9,9 @@
#include <esvg/Debug.h> #include <esvg/Debug.h>
#include <esvg/Text.h> #include <esvg/Text.h>
#undef __class__
#define __class__ "Text"
esvg::Text::Text(PaintState _parentPaintState) : esvg::Base(_parentPaintState) esvg::Text::Text(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{ {

View File

@ -30,6 +30,11 @@
#include <agg/agg_color_rgba.h> #include <agg/agg_color_rgba.h>
#include <agg/agg_pixfmt_rgba.h> #include <agg/agg_pixfmt_rgba.h>
#undef __class__
#define __class__ "Document"
esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL) esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL)
{ {
m_fileName = _fileName; m_fileName = _fileName;
@ -76,15 +81,12 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
vec2 size(0,0); vec2 size(0,0);
// parse all sub node : // parse all sub node :
for(int32_t iii=0; iii< root->Size(); iii++) { for(int32_t iii=0; iii< root->Size(); iii++) {
exml::Node* child = root->Get(iii); exml::Element* child = root->GetElement(iii);
if (child==NULL) { if (child==NULL) {
// comment trsh here...
continue; continue;
} }
esvg::Base *elementParser = NULL; esvg::Base *elementParser = NULL;
if (!child->IsElement()) {
// nothing to do, just proceed to next step
continue;
}
if (child->GetValue() == "g") { if (child->GetValue() == "g") {
elementParser = new esvg::Group(m_paint); elementParser = new esvg::Group(m_paint);
} else if (child->GetValue() == "a") { } else if (child->GetValue() == "a") {
@ -125,7 +127,7 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ..."); SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ...");
continue; continue;
} }
if (false == elementParser->Parse((exml::Element*)child, m_transformMatrix, size)) { if (false == elementParser->Parse(child, m_transformMatrix, size)) {
SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR"); SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR");
delete(elementParser); delete(elementParser);
elementParser = NULL; elementParser = NULL;
@ -145,7 +147,7 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
} else { } else {
m_size.setValue((int32_t)m_size.x(), (int32_t)m_size.y()); m_size.setValue((int32_t)m_size.x(), (int32_t)m_size.y());
} }
DisplayDebug(); //DisplayDebug();
} }
esvg::Document::~Document(void) esvg::Document::~Document(void)