[DEV] change LOG element from SVG to ESVG better adapted with the library

This commit is contained in:
Edouard DUPIN 2015-12-09 21:32:44 +01:00
parent 9c5496f857
commit 8415109007
21 changed files with 204 additions and 204 deletions

View File

@ -59,13 +59,13 @@ void esvg::Base::parseTransform(const std::shared_ptr<exml::Element>& _element)
if (inputString.size() == 0) { if (inputString.size() == 0) {
return; return;
} }
SVG_VERBOSE("find transform : \"" << inputString << "\""); ESVG_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] == ',') { if (inputString[iii] == ',') {
inputString[iii] = ' '; inputString[iii] = ' ';
} }
} }
SVG_VERBOSE("find transform : \"" << inputString << "\""); ESVG_VERBOSE("find transform : \"" << inputString << "\"");
double matrix[6]; double matrix[6];
float angle, xxx, yyy; float angle, xxx, yyy;
int32_t n; int32_t n;
@ -75,16 +75,16 @@ void esvg::Base::parseTransform(const std::shared_ptr<exml::Element>& _element)
m_transformMatrix = mat2(matrix); m_transformMatrix = mat2(matrix);
} else if (sscanf(pointerOnData, "translate (%f %f) %n", &xxx, &yyy, &n) == 2) { } else if (sscanf(pointerOnData, "translate (%f %f) %n", &xxx, &yyy, &n) == 2) {
m_transformMatrix *= etk::mat2Translate(vec2(xxx, yyy)); m_transformMatrix *= etk::mat2Translate(vec2(xxx, yyy));
SVG_VERBOSE("Translate : " << xxx << ", " << yyy); ESVG_VERBOSE("Translate : " << xxx << ", " << yyy);
} else if (sscanf(pointerOnData, "translate (%f) %n", &xxx, &n) == 1) { } else if (sscanf(pointerOnData, "translate (%f) %n", &xxx, &n) == 1) {
m_transformMatrix *= etk::mat2Translate(vec2(xxx, 0)); m_transformMatrix *= etk::mat2Translate(vec2(xxx, 0));
SVG_VERBOSE("Translate : " << xxx << ", " << 0); ESVG_VERBOSE("Translate : " << xxx << ", " << 0);
} else if (sscanf(pointerOnData, "scale (%f %f) %n", &xxx, &yyy, &n) == 2) { } else if (sscanf(pointerOnData, "scale (%f %f) %n", &xxx, &yyy, &n) == 2) {
m_transformMatrix *= etk::mat2Scale(vec2(xxx, yyy)); m_transformMatrix *= etk::mat2Scale(vec2(xxx, yyy));
SVG_VERBOSE("Scale : " << xxx << ", " << yyy); ESVG_VERBOSE("Scale : " << xxx << ", " << yyy);
} else if (sscanf(pointerOnData, "scale (%f) %n", &xxx, &n) == 1) { } else if (sscanf(pointerOnData, "scale (%f) %n", &xxx, &n) == 1) {
m_transformMatrix *= etk::mat2Scale(xxx); m_transformMatrix *= etk::mat2Scale(xxx);
SVG_VERBOSE("Scale : " << xxx << ", " << xxx); ESVG_VERBOSE("Scale : " << xxx << ", " << xxx);
} else if (sscanf(pointerOnData, "rotate (%f %f %f) %n", &angle, &xxx, &yyy, &n) == 3) { } else if (sscanf(pointerOnData, "rotate (%f %f %f) %n", &angle, &xxx, &yyy, &n) == 3) {
angle = angle / 180 * M_PI; angle = angle / 180 * M_PI;
m_transformMatrix *= etk::mat2Translate(vec2(-xxx, -yyy)); m_transformMatrix *= etk::mat2Translate(vec2(-xxx, -yyy));
@ -92,15 +92,15 @@ void esvg::Base::parseTransform(const std::shared_ptr<exml::Element>& _element)
m_transformMatrix *= etk::mat2Translate(vec2(xxx, yyy)); m_transformMatrix *= etk::mat2Translate(vec2(xxx, yyy));
} else if (sscanf(pointerOnData, "rotate (%f) %n", &angle, &n) == 1) { } else if (sscanf(pointerOnData, "rotate (%f) %n", &angle, &n) == 1) {
angle = angle / 180 * M_PI; angle = angle / 180 * M_PI;
SVG_VERBOSE("rotate : " << angle << "rad, " << (angle/M_PI*180) << "°"); ESVG_VERBOSE("rotate : " << angle << "rad, " << (angle/M_PI*180) << "°");
m_transformMatrix *= etk::mat2Rotate(angle); m_transformMatrix *= etk::mat2Rotate(angle);
} else if (sscanf(pointerOnData, "skewX (%f) %n", &angle, &n) == 1) { } else if (sscanf(pointerOnData, "skewX (%f) %n", &angle, &n) == 1) {
angle = angle / 180 * M_PI; angle = angle / 180 * M_PI;
SVG_VERBOSE("skewX : " << angle << "rad, " << (angle/M_PI*180) << "°"); ESVG_VERBOSE("skewX : " << angle << "rad, " << (angle/M_PI*180) << "°");
m_transformMatrix *= etk::mat2Skew(vec2(angle, 0.0f)); m_transformMatrix *= etk::mat2Skew(vec2(angle, 0.0f));
} else if (sscanf(pointerOnData, "skewY (%f) %n", &angle, &n) == 1) { } else if (sscanf(pointerOnData, "skewY (%f) %n", &angle, &n) == 1) {
angle = angle / 180 * M_PI; angle = angle / 180 * M_PI;
SVG_VERBOSE("skewY : " << angle << "rad, " << (angle/M_PI*180) << "°"); ESVG_VERBOSE("skewY : " << angle << "rad, " << (angle/M_PI*180) << "°");
m_transformMatrix *= etk::mat2Skew(vec2(0.0f, angle)); m_transformMatrix *= etk::mat2Skew(vec2(0.0f, angle));
} else { } else {
break; break;
@ -136,7 +136,7 @@ void esvg::Base::parsePosition(const std::shared_ptr<const exml::Element>& _elem
std::pair<float, enum esvg::distance> esvg::Base::parseLength2(const std::string& _dataInput) { std::pair<float, enum esvg::distance> esvg::Base::parseLength2(const std::string& _dataInput) {
SVG_VERBOSE(" lenght : '" << _dataInput << "'"); ESVG_VERBOSE(" lenght : '" << _dataInput << "'");
float n = stof(_dataInput); float n = stof(_dataInput);
std::string unit; std::string unit;
for (int32_t iii=0; iii<_dataInput.size(); ++iii) { for (int32_t iii=0; iii<_dataInput.size(); ++iii) {
@ -149,7 +149,7 @@ std::pair<float, enum esvg::distance> esvg::Base::parseLength2(const std::string
unit = std::string(_dataInput, iii); unit = std::string(_dataInput, iii);
break; break;
} }
SVG_VERBOSE(" lenght : '" << n << "' => unit=" << unit); ESVG_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) {
return std::make_pair(n, esvg::distance_pixel); return std::make_pair(n, esvg::distance_pixel);
@ -186,7 +186,7 @@ std::pair<float, enum esvg::distance> esvg::Base::parseLength2(const std::string
float esvg::Base::parseLength(const std::string& _dataInput) { float esvg::Base::parseLength(const std::string& _dataInput) {
std::pair<float, enum esvg::distance> value = parseLength2(_dataInput); std::pair<float, enum esvg::distance> value = parseLength2(_dataInput);
SVG_VERBOSE(" lenght : '" << value.first << "' => unit=" << value.second); ESVG_VERBOSE(" lenght : '" << value.first << "' => unit=" << value.second);
float font_size = 20.0f; float font_size = 20.0f;
switch (value.second) { switch (value.second) {
case esvg::distance_pourcent: case esvg::distance_pourcent:
@ -248,7 +248,7 @@ void esvg::Base::parsePaintAttr(const std::shared_ptr<const exml::Element>& _ele
if (content == "none" ) { if (content == "none" ) {
// OK, Nothing to do ... // OK, Nothing to do ...
} else { } else {
SVG_TODO(" 'stroke-dasharray' not implemented ..."); ESVG_TODO(" 'stroke-dasharray' not implemented ...");
} }
} }
content = _element->getAttribute("stroke-linecap"); content = _element->getAttribute("stroke-linecap");
@ -261,7 +261,7 @@ void esvg::Base::parsePaintAttr(const std::shared_ptr<const exml::Element>& _ele
m_paint.lineCap = esvg::cap_square; m_paint.lineCap = esvg::cap_square;
} else { } else {
m_paint.lineCap = esvg::cap_butt; m_paint.lineCap = esvg::cap_butt;
SVG_ERROR("not know stroke-linecap value : \"" << content << "\", not in [butt,round,square]"); ESVG_ERROR("not know stroke-linecap value : \"" << content << "\", not in [butt,round,square]");
} }
} }
content = _element->getAttribute("stroke-linejoin"); content = _element->getAttribute("stroke-linejoin");
@ -274,7 +274,7 @@ void esvg::Base::parsePaintAttr(const std::shared_ptr<const exml::Element>& _ele
m_paint.lineJoin = esvg::join_bevel; m_paint.lineJoin = esvg::join_bevel;
} else { } else {
m_paint.lineJoin = esvg::join_miter; m_paint.lineJoin = esvg::join_miter;
SVG_ERROR("not know stroke-linejoin value : \"" << content << "\", not in [miter,round,bevel]"); ESVG_ERROR("not know stroke-linejoin value : \"" << content << "\", not in [miter,round,bevel]");
} }
} }
content = _element->getAttribute("stroke-miterlimit"); content = _element->getAttribute("stroke-miterlimit");
@ -305,7 +305,7 @@ void esvg::Base::parsePaintAttr(const std::shared_ptr<const exml::Element>& _ele
} else if (content == "evenodd" ) { } else if (content == "evenodd" ) {
m_paint.flagEvenOdd = true; m_paint.flagEvenOdd = true;
} else { } else {
SVG_ERROR("not know fill-rule value : \"" << content << "\", not in [nonzero,evenodd]"); ESVG_ERROR("not know fill-rule value : \"" << content << "\", not in [nonzero,evenodd]");
} }
} }
// ---------------- opacity ---------------- // ---------------- opacity ----------------
@ -338,12 +338,12 @@ std::pair<etk::Color<float,4>, std::string> esvg::Base::parseColor(const std::st
std::string color(_inputData.begin() + 5, _inputData.end()-1); std::string color(_inputData.begin() + 5, _inputData.end()-1);
localColor = std::pair<etk::Color<float,4>, std::string>(etk::color::none, color); localColor = std::pair<etk::Color<float,4>, std::string>(etk::color::none, color);
} else { } else {
SVG_ERROR(" pb in parsing the color : \"" << _inputData << "\" == > url(XXX) is not supported now ..."); ESVG_ERROR(" pb in parsing the color : \"" << _inputData << "\" == > url(XXX) is not supported now ...");
} }
} else { } else {
localColor = std::pair<etk::Color<float,4>, std::string>(_inputData, ""); localColor = std::pair<etk::Color<float,4>, std::string>(_inputData, "");
} }
SVG_VERBOSE("Parse color : \"" << _inputData << "\" == > " << localColor.first << " " << localColor.second); ESVG_VERBOSE("Parse color : \"" << _inputData << "\" == > " << localColor.first << " " << localColor.second);
return localColor; return localColor;
} }
@ -365,7 +365,7 @@ const char * esvg::Base::spacingDist(int32_t _spacing) {
} }
void esvg::Base::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Base::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_WARNING(spacingDist(_level) << "DRAW esvg::Base ... ==> No drawing availlable"); ESVG_WARNING(spacingDist(_level) << "DRAW esvg::Base ... ==> No drawing availlable");
} }

View File

@ -46,12 +46,12 @@ bool esvg::Circle::parseXML(const std::shared_ptr<exml::Element>& _element, mat2
if (content.size()!=0) { if (content.size()!=0) {
m_radius = parseLength(content); m_radius = parseLength(content);
} else { } else {
SVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is not present"); ESVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is not present");
return false; return false;
} }
if (0 > m_radius) { if (0 > m_radius) {
m_radius = 0; m_radius = 0;
SVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is negative"); ESVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is negative");
return false; return false;
} }
_sizeMax.setValue(m_position.x() + m_radius, m_position.y() + m_radius); _sizeMax.setValue(m_position.x() + m_radius, m_position.y() + m_radius);
@ -59,14 +59,14 @@ bool esvg::Circle::parseXML(const std::shared_ptr<exml::Element>& _element, mat2
} }
void esvg::Circle::display(int32_t _spacing) { void esvg::Circle::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Circle " << m_position << " radius=" << m_radius); ESVG_DEBUG(spacingDist(_spacing) << "Circle " << m_position << " radius=" << m_radius);
} }
void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Circle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Circle"); ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Circle");
if (m_radius <= 0.0f) { if (m_radius <= 0.0f) {
SVG_VERBOSE(spacingDist(_level+1) << "Too small radius" << m_radius); ESVG_VERBOSE(spacingDist(_level+1) << "Too small radius" << m_radius);
return; return;
} }
esvg::render::Path listElement; esvg::render::Path listElement;

View File

@ -67,12 +67,12 @@ void esvg::Dimension::set(std::string _config) {
type = esvg::distance_meter; type = esvg::distance_meter;
_config.erase(_config.size()-1, 1); _config.erase(_config.size()-1, 1);
} else { } else {
SVG_CRITICAL("Can not parse dimention : \"" << _config << "\""); ESVG_CRITICAL("Can not parse dimention : \"" << _config << "\"");
return; return;
} }
vec2 tmp = _config; vec2 tmp = _config;
set(tmp, type); set(tmp, type);
SVG_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this ); ESVG_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this );
} }
static enum esvg::distance parseType(std::string& _config) { static enum esvg::distance parseType(std::string& _config) {
@ -102,7 +102,7 @@ static enum esvg::distance parseType(std::string& _config) {
type = esvg::distance_meter; type = esvg::distance_meter;
_config.erase(_config.size()-1, 1); _config.erase(_config.size()-1, 1);
} else { } else {
SVG_CRITICAL("Can not parse dimention : \"" << _config << "\""); ESVG_CRITICAL("Can not parse dimention : \"" << _config << "\"");
} }
return type; return type;
} }
@ -120,7 +120,7 @@ void esvg::Dimension::set(std::string _configX, std::string _configY) {
float valueY = etk::string_to_float(_configY); float valueY = etk::string_to_float(_configY);
// TODO : Check difference ... // TODO : Check difference ...
set(vec2(valueX, valueY), typeX); set(vec2(valueX, valueY), typeX);
SVG_VERBOSE(" config dimention : '" << _configX << "' '" << _configY << "' == > " << *this ); ESVG_VERBOSE(" config dimention : '" << _configX << "' '" << _configY << "' == > " << *this );
} }
@ -190,7 +190,7 @@ void esvg::Dimension::set(const vec2& _size, enum esvg::distance _type) {
case esvg::distance_ex: case esvg::distance_ex:
case esvg::distance_point: case esvg::distance_point:
case esvg::distance_pc: case esvg::distance_pc:
SVG_ERROR("Does not support other than Px and % type of dimention : " << _type << " automaticly convert with {72,72} pixel/inch"); ESVG_ERROR("Does not support other than Px and % type of dimention : " << _type << " automaticly convert with {72,72} pixel/inch");
break; break;
} }
} }

View File

@ -47,14 +47,14 @@ bool esvg::Ellipse::parseXML(const std::shared_ptr<exml::Element>& _element, mat
if (content.size()!=0) { if (content.size()!=0) {
m_r.setX(parseLength(content)); m_r.setX(parseLength(content));
} else { } else {
SVG_ERROR("(l "<<_element->getPos()<<") Ellipse \"rx\" is not present"); ESVG_ERROR("(l "<<_element->getPos()<<") Ellipse \"rx\" is not present");
return false; return false;
} }
content = _element->getAttribute("ry"); content = _element->getAttribute("ry");
if (content.size()!=0) { if (content.size()!=0) {
m_r.setY(parseLength(content)); m_r.setY(parseLength(content));
} else { } else {
SVG_ERROR("(l "<<_element->getPos()<<") Ellipse \"ry\" is not present"); ESVG_ERROR("(l "<<_element->getPos()<<") Ellipse \"ry\" is not present");
return false; return false;
} }
_sizeMax.setValue(m_c.x() + m_r.x(), m_c.y() + m_r.y()); _sizeMax.setValue(m_c.x() + m_r.x(), m_c.y() + m_r.y());
@ -63,15 +63,15 @@ bool esvg::Ellipse::parseXML(const std::shared_ptr<exml::Element>& _element, mat
} }
void esvg::Ellipse::display(int32_t _spacing) { void esvg::Ellipse::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Ellipse c=" << m_c << " r=" << m_r); ESVG_DEBUG(spacingDist(_spacing) << "Ellipse c=" << m_c << " r=" << m_r);
} }
void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Ellipse::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Ellipse"); ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Ellipse");
if ( m_r.x()<=0.0f if ( m_r.x()<=0.0f
|| m_r.y()<=0.0f) { || m_r.y()<=0.0f) {
SVG_VERBOSE(spacingDist(_level+1) << "Too small radius" << m_r); ESVG_VERBOSE(spacingDist(_level+1) << "Too small radius" << m_r);
return; return;
} }
esvg::render::Path listElement; esvg::render::Path listElement;

View File

@ -41,12 +41,12 @@ bool esvg::Group::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
parseTransform(_element); parseTransform(_element);
parsePosition(_element, pos, size); parsePosition(_element, pos, size);
parsePaintAttr(_element); parsePaintAttr(_element);
SVG_VERBOSE("parsed G1. trans : " << m_transformMatrix); ESVG_VERBOSE("parsed G1. trans : " << m_transformMatrix);
// add the property of the parrent modifications ... // add the property of the parrent modifications ...
m_transformMatrix *= _parentTrans; m_transformMatrix *= _parentTrans;
SVG_VERBOSE("parsed G2. trans : " << m_transformMatrix); ESVG_VERBOSE("parsed G2. trans : " << m_transformMatrix);
_sizeMax.setValue(0,0); _sizeMax.setValue(0,0);
vec2 tmpPos(0,0); vec2 tmpPos(0,0);
@ -79,14 +79,14 @@ bool esvg::Group::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
} else if (child->getValue() == "text") { } else if (child->getValue() == "text") {
elementParser = std::make_shared<esvg::Text>(m_paint); elementParser = std::make_shared<esvg::Text>(m_paint);
} else { } else {
SVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->getValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]"); ESVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->getValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
} }
if (elementParser == nullptr) { if (elementParser == nullptr) {
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" allocation error or not supported ..."); ESVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" allocation error or not supported ...");
continue; continue;
} }
if (elementParser->parseXML(child, m_transformMatrix, tmpPos) == false) { if (elementParser->parseXML(child, m_transformMatrix, tmpPos) == false) {
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" Sub Parsing ERROR"); ESVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" Sub Parsing ERROR");
elementParser.reset(); elementParser.reset();
continue; continue;
} }
@ -99,7 +99,7 @@ bool esvg::Group::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
} }
void esvg::Group::display(int32_t _spacing) { void esvg::Group::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Group (START) fill=" << m_paint.fill.first << "/" << m_paint.fill.second ESVG_DEBUG(spacingDist(_spacing) << "Group (START) fill=" << m_paint.fill.first << "/" << m_paint.fill.second
<< " stroke=" << m_paint.stroke.first << "/" << m_paint.stroke.second << " stroke=" << m_paint.stroke.first << "/" << m_paint.stroke.second
<< " stroke-width=" << m_paint.strokeWidth ); << " stroke-width=" << m_paint.strokeWidth );
for (size_t iii=0; iii<m_subElementList.size(); ++iii) { for (size_t iii=0; iii<m_subElementList.size(); ++iii) {
@ -107,11 +107,11 @@ void esvg::Group::display(int32_t _spacing) {
m_subElementList[iii]->display(_spacing+1); m_subElementList[iii]->display(_spacing+1);
} }
} }
SVG_DEBUG(spacingDist(_spacing) << "Group (STOP)"); ESVG_DEBUG(spacingDist(_spacing) << "Group (STOP)");
} }
void esvg::Group::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Group::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::group"); ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::group");
for (size_t iii=0; iii<m_subElementList.size(); ++iii) { for (size_t iii=0; iii<m_subElementList.size(); ++iii) {
if (m_subElementList[iii] != nullptr) { if (m_subElementList[iii] != nullptr) {
m_subElementList[iii]->draw(_myRenderer, _basicTrans, _level+1); m_subElementList[iii]->draw(_myRenderer, _basicTrans, _level+1);

View File

@ -57,11 +57,11 @@ bool esvg::Line::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
} }
void esvg::Line::display(int32_t _spacing) { void esvg::Line::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Line " << m_startPos << " to " << m_stopPos); ESVG_DEBUG(spacingDist(_spacing) << "Line " << m_startPos << " to " << m_stopPos);
} }
void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Line::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Line"); ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Line");
esvg::render::Path listElement; esvg::render::Path listElement;
listElement.clear(); listElement.clear();

View File

@ -61,7 +61,7 @@ bool esvg::LinearGradient::parseXML(const std::shared_ptr<exml::Element>& _eleme
if (content.size()!=0) { if (content.size()!=0) {
std::pair<float, enum esvg::distance> tmp = parseLength2(content); std::pair<float, enum esvg::distance> tmp = parseLength2(content);
if (tmp.second != esvg::distance_pourcent) { if (tmp.second != esvg::distance_pourcent) {
SVG_ERROR("offset : " << content << " res=" << tmp.first << "," << tmp.second << " Not support other than pourcent %"); ESVG_ERROR("offset : " << content << " res=" << tmp.first << "," << tmp.second << " Not support other than pourcent %");
} else { } else {
offset = tmp.first; offset = tmp.first;
} }
@ -69,32 +69,32 @@ bool esvg::LinearGradient::parseXML(const std::shared_ptr<exml::Element>& _eleme
content = child->getAttribute("stop-color"); content = child->getAttribute("stop-color");
if (content.size()!=0) { if (content.size()!=0) {
stopColor = parseColor(content).first; stopColor = parseColor(content).first;
SVG_VERBOSE(" color : \"" << content << "\" == > " << stopColor); ESVG_VERBOSE(" color : \"" << content << "\" == > " << stopColor);
} }
content = child->getAttribute("stop-opacity"); content = child->getAttribute("stop-opacity");
if (content.size()!=0) { if (content.size()!=0) {
float opacity = parseLength(content); float opacity = parseLength(content);
opacity = std::avg(0.0f, opacity, 1.0f); opacity = std::avg(0.0f, opacity, 1.0f);
stopColor.setA(opacity); stopColor.setA(opacity);
SVG_VERBOSE(" opacity : \"" << content << "\" == > " << stopColor); ESVG_VERBOSE(" opacity : \"" << content << "\" == > " << stopColor);
} }
m_data.push_back(std::pair<float, etk::Color<float,4>>(offset, stopColor)); m_data.push_back(std::pair<float, etk::Color<float,4>>(offset, stopColor));
} else { } else {
SVG_ERROR("(l " << child->getPos() << ") node not suported : \"" << child->getValue() << "\" must be [stop]"); ESVG_ERROR("(l " << child->getPos() << ") node not suported : \"" << child->getValue() << "\" must be [stop]");
} }
} }
return true; return true;
} }
void esvg::LinearGradient::display(int32_t _spacing) { void esvg::LinearGradient::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "LinearGradient " << m_pos1 << " to " << m_pos2); ESVG_DEBUG(spacingDist(_spacing) << "LinearGradient " << m_pos1 << " to " << m_pos2);
for (auto &it : m_data) { for (auto &it : m_data) {
SVG_DEBUG(spacingDist(_spacing+1) << "STOP: offset=" << it.first << " color=" << it.second); ESVG_DEBUG(spacingDist(_spacing+1) << "STOP: offset=" << it.first << " color=" << it.second);
} }
} }
void esvg::LinearGradient::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::LinearGradient::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::LinearGradient"); ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::LinearGradient");
} }

View File

@ -35,11 +35,11 @@ const char * extractCmd(const char* _input, char& _cmd, std::vector<float>& _out
&& _input[0] >= 'A') && _input[0] >= 'A')
|| ( _input[0] <= 'z' || ( _input[0] <= 'z'
&& _input[0] >= 'a') ) ) { && _input[0] >= 'a') ) ) {
SVG_ERROR("Error in the SVG Path : \"" << _input << "\""); ESVG_ERROR("Error in the SVG Path : \"" << _input << "\"");
return nullptr; return nullptr;
} }
_cmd = _input[0]; _cmd = _input[0];
SVG_VERBOSE("Find command : " << _cmd); ESVG_VERBOSE("Find command : " << _cmd);
if (_input[1] == '\0') { if (_input[1] == '\0') {
return &_input[1]; return &_input[1];
} }
@ -50,7 +50,7 @@ const char * extractCmd(const char* _input, char& _cmd, std::vector<float>& _out
int32_t nbElementRead; int32_t nbElementRead;
while( sscanf(&_input[iii], "%1[, ]%f%n", spacer, &element, &nbElementRead) == 2 while( sscanf(&_input[iii], "%1[, ]%f%n", spacer, &element, &nbElementRead) == 2
|| sscanf(&_input[iii], "%f%n", &element, &nbElementRead) == 1) { || sscanf(&_input[iii], "%f%n", &element, &nbElementRead) == 1) {
SVG_VERBOSE("Find element : " << element); ESVG_VERBOSE("Find element : " << element);
_outputList.push_back(element); _outputList.push_back(element);
iii += nbElementRead; iii += nbElementRead;
} }
@ -75,10 +75,10 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
std::string elementXML1 = _element->getAttribute("d"); std::string elementXML1 = _element->getAttribute("d");
if (elementXML1.size() == 0) { if (elementXML1.size() == 0) {
SVG_WARNING("(l "<<_element->getPos()<<") path: missing 'd' attribute or empty"); ESVG_WARNING("(l "<<_element->getPos()<<") path: missing 'd' attribute or empty");
return false; return false;
} }
SVG_VERBOSE("Parse Path : \"" << elementXML1 << "\""); ESVG_VERBOSE("Parse Path : \"" << elementXML1 << "\"");
char command; char command;
std::vector<float> listDot; std::vector<float> listDot;
@ -95,7 +95,7 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
case 'M': // Move to (absolute) case 'M': // Move to (absolute)
// 2 Elements ... // 2 Elements ...
if(listDot.size()%2 != 0) { if(listDot.size()%2 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() ); ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break; break;
} }
if (listDot.size() >= 2) { if (listDot.size() >= 2) {
@ -112,7 +112,7 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
case 'L': // Line to (absolute) case 'L': // Line to (absolute)
// 2 Elements ... // 2 Elements ...
if(listDot.size()%2 != 0) { if(listDot.size()%2 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() ); ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break; break;
} }
for(int32_t iii=0; iii<listDot.size(); iii+=2) { for(int32_t iii=0; iii<listDot.size(); iii+=2) {
@ -126,7 +126,7 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
case 'V': // Vertical Line to (absolute) case 'V': // Vertical Line to (absolute)
// 1 Element ... // 1 Element ...
if(listDot.size() == 0) { if(listDot.size() == 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() ); ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break; break;
} }
for(int32_t iii=0; iii<listDot.size(); iii+=1) { for(int32_t iii=0; iii<listDot.size(); iii+=1) {
@ -140,7 +140,7 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
case 'H': // Horizantal Line to (absolute) case 'H': // Horizantal Line to (absolute)
// 1 Element ... // 1 Element ...
if(listDot.size() == 0) { if(listDot.size() == 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() ); ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break; break;
} }
for(int32_t iii=0; iii<listDot.size(); iii+=1) { for(int32_t iii=0; iii<listDot.size(); iii+=1) {
@ -154,7 +154,7 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
case 'Q': // Quadratic Bezier curve (absolute) case 'Q': // Quadratic Bezier curve (absolute)
// 4 Elements ... // 4 Elements ...
if(listDot.size()%4 != 0) { if(listDot.size()%4 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() ); ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break; break;
} }
for(int32_t iii=0; iii<listDot.size(); iii+=4) { for(int32_t iii=0; iii<listDot.size(); iii+=4) {
@ -169,7 +169,7 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
case 'T': // smooth quadratic Bezier curve to (absolute) case 'T': // smooth quadratic Bezier curve to (absolute)
// 2 Elements ... // 2 Elements ...
if(listDot.size()%2 != 0) { if(listDot.size()%2 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() ); ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break; break;
} }
for(int32_t iii=0; iii<listDot.size(); iii+=2) { for(int32_t iii=0; iii<listDot.size(); iii+=2) {
@ -183,7 +183,7 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
case 'C': // curve to (absolute) case 'C': // curve to (absolute)
// 6 Elements ... // 6 Elements ...
if(listDot.size()%6 != 0) { if(listDot.size()%6 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() ); ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break; break;
} }
for(int32_t iii=0; iii<listDot.size(); iii+=6) { for(int32_t iii=0; iii<listDot.size(); iii+=6) {
@ -199,7 +199,7 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
case 'S': // smooth curve to (absolute) case 'S': // smooth curve to (absolute)
// 4 Elements ... // 4 Elements ...
if(listDot.size()%4 != 0) { if(listDot.size()%4 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() ); ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break; break;
} }
for(int32_t iii=0; iii<listDot.size(); iii+=4) { for(int32_t iii=0; iii<listDot.size(); iii+=4) {
@ -214,7 +214,7 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
case 'A': // elliptical Arc (absolute) case 'A': // elliptical Arc (absolute)
// 7 Elements ... // 7 Elements ...
if(listDot.size()%7 != 0) { if(listDot.size()%7 != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() ); ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break; break;
} }
for(int32_t iii=0; iii<listDot.size(); iii+=7) { for(int32_t iii=0; iii<listDot.size(); iii+=7) {
@ -239,13 +239,13 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
case 'Z': // closepath (absolute) case 'Z': // closepath (absolute)
// 0 Element ... // 0 Element ...
if(listDot.size() != 0) { if(listDot.size() != 0) {
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() ); ESVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break; break;
} }
m_listElement.close(relative); m_listElement.close(relative);
break; break;
default: default:
SVG_ERROR ("Unknow error : \"" << command << "\""); ESVG_ERROR ("Unknow error : \"" << command << "\"");
} }
} }
@ -257,7 +257,7 @@ void esvg::Path::display(int32_t _spacing) {
} }
void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Path::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Path"); ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Path");
mat2 mtx = m_transformMatrix; mat2 mtx = m_transformMatrix;
mtx *= _basicTrans; mtx *= _basicTrans;

View File

@ -29,21 +29,21 @@ bool esvg::Polygon::parseXML(const std::shared_ptr<exml::Element>& _element, mat
parseTransform(_element); parseTransform(_element);
parsePaintAttr(_element); parsePaintAttr(_element);
SVG_VERBOSE("parsed P1. trans: " << m_transformMatrix); ESVG_VERBOSE("parsed P1. trans: " << m_transformMatrix);
// add the property of the parrent modifications ... // add the property of the parrent modifications ...
m_transformMatrix *= _parentTrans; m_transformMatrix *= _parentTrans;
SVG_VERBOSE("parsed P2. trans: " << m_transformMatrix); ESVG_VERBOSE("parsed P2. trans: " << m_transformMatrix);
const std::string sss1 = _element->getAttribute("points"); const std::string sss1 = _element->getAttribute("points");
if (sss1.size() == 0) { if (sss1.size() == 0) {
SVG_ERROR("(l "/*<<_element->Pos()*/<<") polygon: missing points attribute"); ESVG_ERROR("(l "/*<<_element->Pos()*/<<") polygon: missing points attribute");
return false; return false;
} }
const char * sss = sss1.c_str(); const char * sss = sss1.c_str();
_sizeMax.setValue(0,0); _sizeMax.setValue(0,0);
SVG_VERBOSE("Parse polygon : \"" << sss << "\""); ESVG_VERBOSE("Parse polygon : \"" << sss << "\"");
while ('\0' != sss[0]) { while ('\0' != sss[0]) {
vec2 pos(0,0); vec2 pos(0,0);
int32_t n; int32_t n;
@ -63,11 +63,11 @@ bool esvg::Polygon::parseXML(const std::shared_ptr<exml::Element>& _element, mat
} }
void esvg::Polygon::display(int32_t _spacing) { void esvg::Polygon::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Polygon nbPoint=" << m_listPoint.size()); ESVG_DEBUG(spacingDist(_spacing) << "Polygon nbPoint=" << m_listPoint.size());
} }
void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Polygon::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polygon"); ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polygon");
esvg::render::Path listElement; esvg::render::Path listElement;
listElement.moveTo(false, m_listPoint[0]); listElement.moveTo(false, m_listPoint[0]);

View File

@ -36,11 +36,11 @@ bool esvg::Polyline::parseXML(const std::shared_ptr<exml::Element>& _element, ma
std::string sss1 = _element->getAttribute("points"); std::string sss1 = _element->getAttribute("points");
if (sss1.size() == 0) { if (sss1.size() == 0) {
SVG_ERROR("(l "<<_element->getPos()<<") polyline: missing points attribute"); ESVG_ERROR("(l "<<_element->getPos()<<") polyline: missing points attribute");
return false; return false;
} }
_sizeMax.setValue(0,0); _sizeMax.setValue(0,0);
SVG_VERBOSE("Parse polyline : \"" << sss1 << "\""); ESVG_VERBOSE("Parse polyline : \"" << sss1 << "\"");
const char* sss = sss1.c_str(); const char* sss = sss1.c_str();
while ('\0' != sss[0]) { while ('\0' != sss[0]) {
vec2 pos; vec2 pos;
@ -58,12 +58,12 @@ bool esvg::Polyline::parseXML(const std::shared_ptr<exml::Element>& _element, ma
} }
void esvg::Polyline::display(int32_t _spacing) { void esvg::Polyline::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Polyline nbPoint=" << m_listPoint.size()); ESVG_DEBUG(spacingDist(_spacing) << "Polyline nbPoint=" << m_listPoint.size());
} }
void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Polyline::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polyline"); ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polyline");
esvg::render::Path listElement; esvg::render::Path listElement;
listElement.clear(); listElement.clear();

View File

@ -55,12 +55,12 @@ bool esvg::Rectangle::parseXML(const std::shared_ptr<exml::Element>& _element, m
} }
void esvg::Rectangle::display(int32_t _spacing) { void esvg::Rectangle::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Rectangle : pos=" << m_position << " size=" << m_size << " corner=" << m_roundedCorner); ESVG_DEBUG(spacingDist(_spacing) << "Rectangle : pos=" << m_position << " size=" << m_size << " corner=" << m_roundedCorner);
} }
void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) { void esvg::Rectangle::draw(esvg::Renderer& _myRenderer, mat2& _basicTrans, int32_t _level) {
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Rectangle: fill=" << m_paint.fill.first << "/" << m_paint.fill.second ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Rectangle: fill=" << m_paint.fill.first << "/" << m_paint.fill.second
<< " stroke=" << m_paint.stroke.first << "/" << m_paint.stroke.second); << " stroke=" << m_paint.stroke.first << "/" << m_paint.stroke.second);
esvg::render::Path listElement; esvg::render::Path listElement;
listElement.clear(); listElement.clear();
if ( m_roundedCorner.x() == 0.0f if ( m_roundedCorner.x() == 0.0f

View File

@ -206,7 +206,7 @@ void esvg::Renderer::writePPM(const std::string& _fileName) {
} }
etk::FSNode tmpFile(_fileName); etk::FSNode tmpFile(_fileName);
if(tmpFile.fileOpenWrite() == false) { if(tmpFile.fileOpenWrite() == false) {
SVG_ERROR("Can not find the file name=\"" << tmpFile << "\""); ESVG_ERROR("Can not find the file name=\"" << tmpFile << "\"");
return; return;
} }
int32_t sizeX = m_size.x(); int32_t sizeX = m_size.x();
@ -215,7 +215,7 @@ void esvg::Renderer::writePPM(const std::string& _fileName) {
sizeX *= m_factor; sizeX *= m_factor;
sizeY *= m_factor; sizeY *= m_factor;
#endif #endif
SVG_DEBUG("Generate ppm : " << m_size << " debug size=" << ivec2(sizeX,sizeY)); ESVG_DEBUG("Generate ppm : " << m_size << " debug size=" << ivec2(sizeX,sizeY));
char tmpValue[1024]; char tmpValue[1024];
sprintf(tmpValue, "P6 %d %d 255 ", sizeX, sizeY); sprintf(tmpValue, "P6 %d %d 255 ", sizeX, sizeY);
tmpFile.fileWrite(tmpValue,1,sizeof(tmpValue)); tmpFile.fileWrite(tmpValue,1,sizeof(tmpValue));
@ -268,7 +268,7 @@ void esvg::Renderer::writeBMP(const std::string& _fileName) {
etk::FSNode tmpFile(_fileName); etk::FSNode tmpFile(_fileName);
if(tmpFile.fileOpenWrite() == false) { if(tmpFile.fileOpenWrite() == false) {
SVG_ERROR("Can not find the file name=\"" << tmpFile << "\""); ESVG_ERROR("Can not find the file name=\"" << tmpFile << "\"");
return; return;
} }
struct bitmapFileHeader fileHeader; struct bitmapFileHeader fileHeader;

View File

@ -22,12 +22,12 @@ esvg::Text::~Text() {
bool esvg::Text::parse(const std::shared_ptr<exml::Element>& _element, mat2& _parentTrans, vec2& _sizeMax) { bool esvg::Text::parse(const std::shared_ptr<exml::Element>& _element, mat2& _parentTrans, vec2& _sizeMax) {
_sizeMax.setValue(0,0); _sizeMax.setValue(0,0);
SVG_ERROR("NOT IMPLEMENTED"); ESVG_ERROR("NOT IMPLEMENTED");
return false; return false;
} }
void esvg::Text::display(int32_t _spacing) { void esvg::Text::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Text"); ESVG_DEBUG(spacingDist(_spacing) << "Text");
} }

View File

@ -14,25 +14,25 @@
namespace esvg { namespace esvg {
int32_t getLogId(); int32_t getLogId();
}; };
#define SVG_BASE(info,data) TK_LOG_BASE(esvg::getLogId(),info,data) #define ESVG_BASE(info,data) TK_LOG_BASE(esvg::getLogId(),info,data)
#define SVG_PRINT(data) SVG_BASE(-1, data) #define ESVG_PRINT(data) ESVG_BASE(-1, data)
#define SVG_CRITICAL(data) SVG_BASE(1, data) #define ESVG_CRITICAL(data) ESVG_BASE(1, data)
#define SVG_ERROR(data) SVG_BASE(2, data) #define ESVG_ERROR(data) ESVG_BASE(2, data)
#define SVG_WARNING(data) SVG_BASE(3, data) #define ESVG_WARNING(data) ESVG_BASE(3, data)
#ifdef DEBUG #ifdef DEBUG
#define SVG_INFO(data) SVG_BASE(4, data) #define ESVG_INFO(data) ESVG_BASE(4, data)
#define SVG_DEBUG(data) SVG_BASE(5, data) #define ESVG_DEBUG(data) ESVG_BASE(5, data)
#define SVG_VERBOSE(data) SVG_BASE(6, data) #define ESVG_VERBOSE(data) ESVG_BASE(6, data)
#define SVG_TODO(data) SVG_BASE(4, "TODO : " << data) #define ESVG_TODO(data) ESVG_BASE(4, "TODO : " << data)
#else #else
#define SVG_INFO(data) do { } while(false) #define ESVG_INFO(data) do { } while(false)
#define SVG_DEBUG(data) do { } while(false) #define ESVG_DEBUG(data) do { } while(false)
#define SVG_VERBOSE(data) do { } while(false) #define ESVG_VERBOSE(data) do { } while(false)
#define SVG_TODO(data) do { } while(false) #define ESVG_TODO(data) do { } while(false)
#endif #endif
#define SVG_ASSERT(cond,data) \ #define ESVG_ASSERT(cond,data) \
do { \ do { \
if (!(cond)) { \ if (!(cond)) { \
SVG_CRITICAL(data); \ SVG_CRITICAL(data); \

View File

@ -39,14 +39,14 @@ esvg::Document::~Document() {
void esvg::Document::displayDebug() { void esvg::Document::displayDebug() {
SVG_DEBUG("Main SVG: size=" << m_size); ESVG_DEBUG("Main SVG: size=" << m_size);
SVG_DEBUG(" refs:"); ESVG_DEBUG(" refs:");
for (int32_t iii=0; iii<m_refList.size(); iii++) { for (int32_t iii=0; iii<m_refList.size(); iii++) {
if (m_refList[iii] != nullptr) { if (m_refList[iii] != nullptr) {
m_refList[iii]->display(2); m_refList[iii]->display(2);
} }
} }
SVG_DEBUG(" Nodes:"); ESVG_DEBUG(" Nodes:");
for (int32_t iii=0; iii<m_subElementList.size(); iii++) { for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
if (m_subElementList[iii] != nullptr) { if (m_subElementList[iii] != nullptr) {
m_subElementList[iii]->display(2); m_subElementList[iii]->display(2);
@ -72,7 +72,7 @@ void esvg::Document::generateAnImage(const ivec2& _size, const std::string& _fil
if (sizeRender.y() <= 0) { if (sizeRender.y() <= 0) {
sizeRender.setY(m_size.y()); sizeRender.setY(m_size.y());
} }
SVG_DEBUG("Generate size " << sizeRender); ESVG_DEBUG("Generate size " << sizeRender);
std::shared_ptr<esvg::Renderer> renderedElement = std::make_shared<esvg::Renderer>(sizeRender, this, _visualDebug); std::shared_ptr<esvg::Renderer> renderedElement = std::make_shared<esvg::Renderer>(sizeRender, this, _visualDebug);
// create the first element matrix modification ... // create the first element matrix modification ...
@ -86,7 +86,7 @@ void esvg::Document::generateAnImage(const ivec2& _size, const std::string& _fil
} else if (etk::end_with(_fileName, ".bmp") == true) { } else if (etk::end_with(_fileName, ".bmp") == true) {
renderedElement->writeBMP(_fileName); renderedElement->writeBMP(_fileName);
} else { } else {
SVG_ERROR("Can not store with this extention : " << _fileName << " not in .bmp/.ppm"); ESVG_ERROR("Can not store with this extention : " << _fileName << " not in .bmp/.ppm");
} }
} }
@ -98,7 +98,7 @@ std::vector<etk::Color<float,4>> esvg::Document::renderImageFloatRGBA(ivec2& _si
if (_size.y() <= 0) { if (_size.y() <= 0) {
_size.setY(m_size.y()); _size.setY(m_size.y());
} }
SVG_DEBUG("Generate size " << _size); ESVG_DEBUG("Generate size " << _size);
std::shared_ptr<esvg::Renderer> renderedElement = std::make_shared<esvg::Renderer>(_size, this); std::shared_ptr<esvg::Renderer> renderedElement = std::make_shared<esvg::Renderer>(_size, this);
// create the first element matrix modification ... // create the first element matrix modification ...
mat2 basicTrans; mat2 basicTrans;
@ -155,18 +155,18 @@ bool esvg::Document::parse(const std::string& _data) {
clear(); clear();
exml::Document doc; exml::Document doc;
if (doc.parse(_data) == false) { if (doc.parse(_data) == false) {
SVG_ERROR("Error occured when loading SVG : " << m_fileName); ESVG_ERROR("Error occured when loading SVG : " << m_fileName);
m_loadOK = false; m_loadOK = false;
return m_loadOK; return m_loadOK;
} }
if (doc.size() == 0) { if (doc.size() == 0) {
SVG_ERROR("(l ?) No nodes in the SVG file ... \"" << m_fileName << "\""); ESVG_ERROR("(l ?) No nodes in the SVG file ... \"" << m_fileName << "\"");
m_loadOK = false; m_loadOK = false;
return m_loadOK; return m_loadOK;
} }
std::shared_ptr<exml::Element> root = doc.getNamed("svg" ); std::shared_ptr<exml::Element> root = doc.getNamed("svg" );
if (root == nullptr) { if (root == nullptr) {
SVG_ERROR("(l ?) main node not find: \"svg\" in \"" << m_fileName << "\""); ESVG_ERROR("(l ?) main node not find: \"svg\" in \"" << m_fileName << "\"");
m_loadOK = false; m_loadOK = false;
return m_loadOK; return m_loadOK;
} }
@ -184,18 +184,18 @@ bool esvg::Document::load(const std::string& _file) {
m_fileName = _file; m_fileName = _file;
exml::Document doc; exml::Document doc;
if (doc.load(m_fileName) == false) { if (doc.load(m_fileName) == false) {
SVG_ERROR("Error occured when loading SVG : " << m_fileName); ESVG_ERROR("Error occured when loading SVG : " << m_fileName);
m_loadOK = false; m_loadOK = false;
return m_loadOK; return m_loadOK;
} }
if (doc.size() == 0) { if (doc.size() == 0) {
SVG_ERROR("(l ?) No nodes in the SVG file ... \"" << m_fileName << "\""); ESVG_ERROR("(l ?) No nodes in the SVG file ... \"" << m_fileName << "\"");
m_loadOK = false; m_loadOK = false;
return m_loadOK; return m_loadOK;
} }
std::shared_ptr<exml::Element> root = doc.getNamed("svg"); std::shared_ptr<exml::Element> root = doc.getNamed("svg");
if (root == nullptr) { if (root == nullptr) {
SVG_ERROR("(l ?) main node not find: \"svg\" in \"" << m_fileName << "\""); ESVG_ERROR("(l ?) main node not find: \"svg\" in \"" << m_fileName << "\"");
m_loadOK = false; m_loadOK = false;
return m_loadOK; return m_loadOK;
} }
@ -223,7 +223,7 @@ bool esvg::Document::cleanStyleProperty(const std::shared_ptr<exml::Element>& _r
for (auto &it : listStyle) { for (auto &it : listStyle) {
std::vector<std::string> value = etk::split(it, ':'); std::vector<std::string> value = etk::split(it, ':');
if (value.size() != 2) { if (value.size() != 2) {
SVG_ERROR("parsing style with a wrong patern : " << it << " missing ':'"); ESVG_ERROR("parsing style with a wrong patern : " << it << " missing ':'");
continue; continue;
} }
// TODO : Check if the attibute already exist ... // TODO : Check if the attibute already exist ...
@ -248,9 +248,9 @@ bool esvg::Document::parseXMLData(const std::shared_ptr<exml::Element>& _root, b
parseTransform(_root); parseTransform(_root);
parsePosition(_root, pos, m_size); parsePosition(_root, pos, m_size);
parsePaintAttr(_root); parsePaintAttr(_root);
SVG_VERBOSE("parsed .ROOT trans: " << m_transformMatrix); ESVG_VERBOSE("parsed .ROOT trans: " << m_transformMatrix);
} else { } else {
SVG_VERBOSE("Parse Reference section ... (no attibute)"); ESVG_VERBOSE("Parse Reference section ... (no attibute)");
} }
vec2 maxSize(0,0); vec2 maxSize(0,0);
vec2 size(0,0); vec2 size(0,0);
@ -265,7 +265,7 @@ bool esvg::Document::parseXMLData(const std::shared_ptr<exml::Element>& _root, b
if (child->getValue() == "g") { if (child->getValue() == "g") {
elementParser = std::make_shared<esvg::Group>(m_paint); elementParser = std::make_shared<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 ..."); ESVG_INFO("Note : 'a' balise is parsed like a g balise ...");
elementParser = std::make_shared<esvg::Group>(m_paint); elementParser = std::make_shared<esvg::Group>(m_paint);
} else if (child->getValue() == "title") { } else if (child->getValue() == "title") {
m_title = "TODO : set the title here ..."; m_title = "TODO : set the title here ...";
@ -288,21 +288,21 @@ bool esvg::Document::parseXMLData(const std::shared_ptr<exml::Element>& _root, b
elementParser = std::make_shared<esvg::Text>(m_paint); elementParser = std::make_shared<esvg::Text>(m_paint);
} else if (child->getValue() == "radialGradient") { } else if (child->getValue() == "radialGradient") {
if (_isReference == false) { if (_isReference == false) {
SVG_ERROR("'" << child->getValue() << "' node must not be defined outside a defs Section"); ESVG_ERROR("'" << child->getValue() << "' node must not be defined outside a defs Section");
continue; continue;
} else { } else {
//elementParser = std::make_shared<esvg::RadialGradient>(m_paint); //elementParser = std::make_shared<esvg::RadialGradient>(m_paint);
} }
} else if (child->getValue() == "linearGradient") { } else if (child->getValue() == "linearGradient") {
if (_isReference == false) { if (_isReference == false) {
SVG_ERROR("'" << child->getValue() << "' node must not be defined outside a defs Section"); ESVG_ERROR("'" << child->getValue() << "' node must not be defined outside a defs Section");
continue; continue;
} else { } else {
elementParser = std::make_shared<esvg::LinearGradient>(m_paint); elementParser = std::make_shared<esvg::LinearGradient>(m_paint);
} }
} else if (child->getValue() == "defs") { } else if (child->getValue() == "defs") {
if (_isReference == true) { if (_isReference == true) {
SVG_ERROR("'" << child->getValue() << "' node must not be defined in a defs Section"); ESVG_ERROR("'" << child->getValue() << "' node must not be defined in a defs Section");
continue; continue;
} else { } else {
bool retRefs = parseXMLData(child, true); bool retRefs = parseXMLData(child, true);
@ -316,14 +316,14 @@ bool esvg::Document::parseXMLData(const std::shared_ptr<exml::Element>& _root, b
// Node ignore : generaly inkscape data // Node ignore : generaly inkscape data
continue; continue;
} else { } 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]"); ESVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->getValue()<<"\" must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
} }
if (elementParser == nullptr) { if (elementParser == nullptr) {
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" allocation error or not supported ..."); ESVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" allocation error or not supported ...");
continue; continue;
} }
if (elementParser->parseXML(child, m_transformMatrix, size) == false) { if (elementParser->parseXML(child, m_transformMatrix, size) == false) {
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" Sub Parsing ERROR"); ESVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" Sub Parsing ERROR");
elementParser.reset(); elementParser.reset();
continue; continue;
} }
@ -355,7 +355,7 @@ bool esvg::Document::parseXMLData(const std::shared_ptr<exml::Element>& _root, b
std::shared_ptr<esvg::Base> esvg::Document::getReference(const std::string& _name) { std::shared_ptr<esvg::Base> esvg::Document::getReference(const std::string& _name) {
if (_name == "") { if (_name == "") {
SVG_ERROR("request a reference with no name ... "); ESVG_ERROR("request a reference with no name ... ");
return nullptr; return nullptr;
} }
for (auto &it : m_refList) { for (auto &it : m_refList) {
@ -366,7 +366,7 @@ std::shared_ptr<esvg::Base> esvg::Document::getReference(const std::string& _nam
return it; return it;
} }
} }
SVG_ERROR("Can not find reference name : '" << _name << "'"); ESVG_ERROR("Can not find reference name : '" << _name << "'");
return nullptr; return nullptr;
} }

View File

@ -25,20 +25,20 @@ etk::Color<float,4> esvg::render::DynamicColorLinear::getColor(const ivec2& _pos
void esvg::render::DynamicColorLinear::generate(esvg::Document* _document) { void esvg::render::DynamicColorLinear::generate(esvg::Document* _document) {
if (_document == nullptr) { if (_document == nullptr) {
SVG_ERROR("Get nullptr input for document"); ESVG_ERROR("Get nullptr input for document");
return; return;
} }
std::shared_ptr<esvg::Base> base = _document->getReference(m_colorName); std::shared_ptr<esvg::Base> base = _document->getReference(m_colorName);
if (base == nullptr) { if (base == nullptr) {
SVG_ERROR("Can not get base : '" << m_colorName << "'"); ESVG_ERROR("Can not get base : '" << m_colorName << "'");
return; return;
} }
std::shared_ptr<esvg::LinearGradient> gradient = std::dynamic_pointer_cast<esvg::LinearGradient>(base); std::shared_ptr<esvg::LinearGradient> gradient = std::dynamic_pointer_cast<esvg::LinearGradient>(base);
if (gradient == nullptr) { if (gradient == nullptr) {
SVG_ERROR("Can not cast in a linear gradient: '" << m_colorName << "' ==> wrong type"); ESVG_ERROR("Can not cast in a linear gradient: '" << m_colorName << "' ==> wrong type");
return; return;
} }
SVG_INFO("get for color linear:"); ESVG_INFO("get for color linear:");
gradient->display(2); gradient->display(2);
} }

View File

@ -74,12 +74,12 @@ static const char* spacingDist(int32_t _spacing) {
} }
void esvg::render::Path::display(int32_t _spacing) { void esvg::render::Path::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Path"); ESVG_DEBUG(spacingDist(_spacing) << "Path");
for(auto &it : m_listElement) { for(auto &it : m_listElement) {
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }
SVG_DEBUG(spacingDist(_spacing+1) << *it); ESVG_DEBUG(spacingDist(_spacing+1) << *it);
} }
} }
@ -122,7 +122,7 @@ void interpolateCubicBezier(std::vector<esvg::render::Point>& _listPoint,
} }
esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, int32_t _recurtionMax, float _threshold) { esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, int32_t _recurtionMax, float _threshold) {
SVG_VERBOSE(spacingDist(_level) << "Generate List Points ... from a path"); ESVG_VERBOSE(spacingDist(_level) << "Generate List Points ... from a path");
esvg::render::PointList out; esvg::render::PointList out;
std::vector<esvg::render::Point> tmpListPoint; std::vector<esvg::render::Point> tmpListPoint;
vec2 lastPosition(0.0f, 0.0f); vec2 lastPosition(0.0f, 0.0f);
@ -134,12 +134,12 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
if (it == nullptr) { if (it == nullptr) {
continue; continue;
} }
SVG_VERBOSE(spacingDist(_level+1) << " Draw : " << *it); ESVG_VERBOSE(spacingDist(_level+1) << " Draw : " << *it);
switch (it->getType()) { switch (it->getType()) {
case esvg::render::path_stop: case esvg::render::path_stop:
if (tmpListPoint.size() != 0) { if (tmpListPoint.size() != 0) {
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
SVG_WARNING(spacingDist(_level+1) << " Request path stop of not starting path ..."); ESVG_WARNING(spacingDist(_level+1) << " Request path stop of not starting path ...");
} else { } else {
tmpListPoint.back().setEndPath(); tmpListPoint.back().setEndPath();
out.addList(tmpListPoint); out.addList(tmpListPoint);
@ -152,7 +152,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
case esvg::render::path_close: case esvg::render::path_close:
if (tmpListPoint.size() != 0) { if (tmpListPoint.size() != 0) {
if (tmpListPoint.size() == 0) { if (tmpListPoint.size() == 0) {
SVG_WARNING(spacingDist(_level+1) << " Request path close of not starting path ..."); ESVG_WARNING(spacingDist(_level+1) << " Request path close of not starting path ...");
} else { } else {
// find the previous tart of the path ... // find the previous tart of the path ...
tmpListPoint.front().m_type = esvg::render::Point::type_join; tmpListPoint.front().m_type = esvg::render::Point::type_join;
@ -161,7 +161,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
if ( delta.x() <= 0.00001 if ( delta.x() <= 0.00001
&& delta.y() <= 0.00001) { && delta.y() <= 0.00001) {
tmpListPoint.pop_back(); tmpListPoint.pop_back();
SVG_VERBOSE(" Remove point Z property : " << tmpListPoint.back().m_pos << " with delta=" << delta); ESVG_VERBOSE(" Remove point Z property : " << tmpListPoint.back().m_pos << " with delta=" << delta);
} }
out.addList(tmpListPoint); out.addList(tmpListPoint);
tmpListPoint.clear(); tmpListPoint.clear();
@ -331,9 +331,9 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
} }
break; break;
case esvg::render::path_elliptic: case esvg::render::path_elliptic:
SVG_TODO(spacingDist(_level+1) << " Elliptic arc not supported now ..."); ESVG_TODO(spacingDist(_level+1) << " Elliptic arc not supported now ...");
/* /*
SVG_VERBOSE(spacingDist(_level+1) << " Draw : " << *it); ESVG_VERBOSE(spacingDist(_level+1) << " Draw : " << *it);
path.ellipticTo(it->getRelative(), path.ellipticTo(it->getRelative(),
it->m_element[0], it->m_element[0],
it->m_element[1], it->m_element[1],
@ -345,13 +345,13 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
*/ */
break; break;
default: default:
SVG_ERROR(spacingDist(_level+1) << " Unknow PATH commant (internal error)"); ESVG_ERROR(spacingDist(_level+1) << " Unknow PATH commant (internal error)");
break; break;
} }
} }
// special case : No request end of path ==> open path: // special case : No request end of path ==> open path:
if (tmpListPoint.size() != 0) { if (tmpListPoint.size() != 0) {
SVG_VERBOSE("Auto-end PATH"); ESVG_VERBOSE("Auto-end PATH");
tmpListPoint.back().setEndPath(); tmpListPoint.back().setEndPath();
out.addList(tmpListPoint); out.addList(tmpListPoint);
tmpListPoint.clear(); tmpListPoint.clear();

View File

@ -14,12 +14,12 @@
void esvg::render::Point::setEndPath() { void esvg::render::Point::setEndPath() {
if (m_type == esvg::render::Point::type_interpolation) { if (m_type == esvg::render::Point::type_interpolation) {
SVG_WARNING("Request stop path of an interpolate Point"); ESVG_WARNING("Request stop path of an interpolate Point");
m_type = esvg::render::Point::type_stop; m_type = esvg::render::Point::type_stop;
return; return;
} }
if (m_type == esvg::render::Point::type_stop) { if (m_type == esvg::render::Point::type_stop) {
SVG_WARNING("Request stop path of an STOP Point"); ESVG_WARNING("Request stop path of an STOP Point");
return; return;
} }
if (m_type == esvg::render::Point::type_start) { if (m_type == esvg::render::Point::type_start) {

View File

@ -28,27 +28,27 @@ void esvg::render::PointList::applyMatrix(const mat2& _transformationMatrix) {
void esvg::render::PointList::display() { void esvg::render::PointList::display() {
SVG_VERBOSE(" Display list of points : size=" << m_data.size()); ESVG_VERBOSE(" Display list of points : size=" << m_data.size());
for (auto &it : m_data) { for (auto &it : m_data) {
SVG_VERBOSE(" Find List " << it.size() << " members"); ESVG_VERBOSE(" Find List " << it.size() << " members");
for (int32_t iii=0; for (int32_t iii=0;
iii < it.size(); iii < it.size();
++iii) { ++iii) {
switch (it[iii].m_type) { switch (it[iii].m_type) {
case esvg::render::Point::type_single: case esvg::render::Point::type_single:
SVG_VERBOSE(" [" << iii << "] Find Single " << it[iii].m_pos); ESVG_VERBOSE(" [" << iii << "] Find Single " << it[iii].m_pos);
break; break;
case esvg::render::Point::type_start: case esvg::render::Point::type_start:
SVG_VERBOSE(" [" << iii << "] Find Start " << it[iii].m_pos); ESVG_VERBOSE(" [" << iii << "] Find Start " << it[iii].m_pos);
break; break;
case esvg::render::Point::type_stop: case esvg::render::Point::type_stop:
SVG_VERBOSE(" [" << iii << "] Find Stop " << it[iii].m_pos); ESVG_VERBOSE(" [" << iii << "] Find Stop " << it[iii].m_pos);
break; break;
case esvg::render::Point::type_interpolation: case esvg::render::Point::type_interpolation:
SVG_VERBOSE(" [" << iii << "] Find interpolation " << it[iii].m_pos); ESVG_VERBOSE(" [" << iii << "] Find interpolation " << it[iii].m_pos);
break; break;
case esvg::render::Point::type_join: case esvg::render::Point::type_join:
SVG_VERBOSE(" [" << iii << "] Find Join " << it[iii].m_pos); ESVG_VERBOSE(" [" << iii << "] Find Join " << it[iii].m_pos);
break; break;
} }
} }

View File

@ -52,7 +52,7 @@ static vec2 getIntersect(const vec2& _point1,
) / diviseur; ) / diviseur;
return vec2(_point2 + _vect2 * mmm); return vec2(_point2 + _vect2 * mmm);
} }
SVG_ERROR("Get divider / 0.0f"); ESVG_ERROR("Get divider / 0.0f");
return _point2; return _point2;
} }
@ -83,19 +83,19 @@ void esvg::render::SegmentList::createSegmentListStroke(const vec2& _point1,
+ axeRotate*_width*0.5f; + axeRotate*_width*0.5f;
if (_isStart == true) { if (_isStart == true) {
addSegment(ppp2, ppp1); addSegment(ppp2, ppp1);
SVG_VERBOSE(" segment :" << ppp2 << " -> " << ppp1); ESVG_VERBOSE(" segment :" << ppp2 << " -> " << ppp1);
} else { } else {
addSegment(ppp1, ppp2); addSegment(ppp1, ppp2);
SVG_VERBOSE(" segment :" << ppp1 << " -> " << ppp2); ESVG_VERBOSE(" segment :" << ppp1 << " -> " << ppp2);
} }
ppp1 = ppp2; ppp1 = ppp2;
} }
if (_isStart == true) { if (_isStart == true) {
addSegment(_point2, ppp1); addSegment(_point2, ppp1);
SVG_VERBOSE(" segment :" << _point2 << " -> " << ppp1); ESVG_VERBOSE(" segment :" << _point2 << " -> " << ppp1);
} else { } else {
addSegment(ppp1, _point2); addSegment(ppp1, _point2);
SVG_VERBOSE(" segment :" << ppp1 << " -> " << _point2); ESVG_VERBOSE(" segment :" << ppp1 << " -> " << _point2);
} }
} }
@ -128,23 +128,23 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
if ( itListPoint[idCurrent].m_type == esvg::render::Point::type_join if ( itListPoint[idCurrent].m_type == esvg::render::Point::type_join
|| itListPoint[idCurrent].m_type == esvg::render::Point::type_interpolation) { || itListPoint[idCurrent].m_type == esvg::render::Point::type_interpolation) {
if (idPevious < 0 ) { if (idPevious < 0 ) {
SVG_ERROR("an error occure a previous ID is < 0.... "); ESVG_ERROR("an error occure a previous ID is < 0.... ");
continue; continue;
} }
if (idNext >= itListPoint.size()) { if (idNext >= itListPoint.size()) {
SVG_ERROR("an error occure a next ID is >= nbPoint len .... "); ESVG_ERROR("an error occure a next ID is >= nbPoint len .... ");
continue; continue;
} }
//SVG_DEBUG("JOIN : id : prev/curr/next : " << idPevious << "/" << idCurrent << "/" << idNext); //ESVG_DEBUG("JOIN : id : prev/curr/next : " << idPevious << "/" << idCurrent << "/" << idNext);
//SVG_DEBUG("JOIN : val : prev/curr/next : " << itListPoint[idPevious].m_pos << "/" << itListPoint[idCurrent].m_pos << "/" << itListPoint[idNext].m_pos); //ESVG_DEBUG("JOIN : val : prev/curr/next : " << itListPoint[idPevious].m_pos << "/" << itListPoint[idCurrent].m_pos << "/" << itListPoint[idNext].m_pos);
vec2 vecA = itListPoint[idCurrent].m_pos - itListPoint[idPevious].m_pos; vec2 vecA = itListPoint[idCurrent].m_pos - itListPoint[idPevious].m_pos;
//SVG_DEBUG("JOIN : vecA : " << vecA); //ESVG_DEBUG("JOIN : vecA : " << vecA);
vecA.safeNormalize(); vecA.safeNormalize();
vec2 vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos; vec2 vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos;
//SVG_DEBUG("JOIN : vecB : " << vecB); //ESVG_DEBUG("JOIN : vecB : " << vecB);
vecB.safeNormalize(); vecB.safeNormalize();
vec2 vecC = vecA - vecB; vec2 vecC = vecA - vecB;
//SVG_DEBUG("JOIN : vecC : " << vecC); //ESVG_DEBUG("JOIN : vecC : " << vecC);
if (vecC == vec2(0.0f, 0.0f)) { if (vecC == vec2(0.0f, 0.0f)) {
// special case: 1 line ... // special case: 1 line ...
itListPoint[idCurrent].m_miterAxe = vec2(vecA.y(), vecA.x()); itListPoint[idCurrent].m_miterAxe = vec2(vecA.y(), vecA.x());
@ -160,7 +160,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
vecB = itListPoint[idCurrent].m_pos - itListPoint[idPevious].m_pos; vecB = itListPoint[idCurrent].m_pos - itListPoint[idPevious].m_pos;
vecB.safeNormalize(); vecB.safeNormalize();
itListPoint[idCurrent].m_orthoAxePrevious = vec2(vecB.y(), -vecB.x()); itListPoint[idCurrent].m_orthoAxePrevious = vec2(vecB.y(), -vecB.x());
//SVG_DEBUG("JOIN : miterAxe " << itListPoint[idCurrent].m_miterAxe); //ESVG_DEBUG("JOIN : miterAxe " << itListPoint[idCurrent].m_miterAxe);
} else if (itListPoint[idCurrent].m_type == esvg::render::Point::type_start) { } else if (itListPoint[idCurrent].m_type == esvg::render::Point::type_start) {
itListPoint[idCurrent].m_posNext = itListPoint[idNext].m_pos; itListPoint[idCurrent].m_posNext = itListPoint[idNext].m_pos;
vec2 vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos; vec2 vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos;
@ -170,7 +170,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
itListPoint[idCurrent].m_orthoAxeNext = itListPoint[idCurrent].m_miterAxe; itListPoint[idCurrent].m_orthoAxeNext = itListPoint[idCurrent].m_miterAxe;
} else if (itListPoint[idCurrent].m_type == esvg::render::Point::type_stop) { } else if (itListPoint[idCurrent].m_type == esvg::render::Point::type_stop) {
if (idPevious < 0 ) { if (idPevious < 0 ) {
SVG_ERROR("an error occure a previous ID is < 0.... "); ESVG_ERROR("an error occure a previous ID is < 0.... ");
continue; continue;
} }
itListPoint[idCurrent].m_posPrevious = itListPoint[idPevious].m_pos; itListPoint[idCurrent].m_posPrevious = itListPoint[idPevious].m_pos;
@ -180,7 +180,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
itListPoint[idCurrent].m_orthoAxePrevious = itListPoint[idCurrent].m_miterAxe; itListPoint[idCurrent].m_orthoAxePrevious = itListPoint[idCurrent].m_miterAxe;
itListPoint[idCurrent].m_orthoAxeNext = itListPoint[idCurrent].m_miterAxe; itListPoint[idCurrent].m_orthoAxeNext = itListPoint[idCurrent].m_miterAxe;
} else { } else {
SVG_TODO("Unsupported type of point ...."); ESVG_TODO("Unsupported type of point ....");
} }
} }
// create segment list: // create segment list:
@ -214,7 +214,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
// Check the miter limit: // Check the miter limit:
float limitRight = (left - it.m_pos).length() / _width * 2.0f; float limitRight = (left - it.m_pos).length() / _width * 2.0f;
float limitLeft = (right - it.m_pos).length() / _width * 2.0f; float limitLeft = (right - it.m_pos).length() / _width * 2.0f;
SVG_VERBOSE(" miter Limit: " << limitRight << " " << limitLeft << " <= " << _miterLimit); ESVG_VERBOSE(" miter Limit: " << limitRight << " " << limitLeft << " <= " << _miterLimit);
if ( limitRight <= _miterLimit if ( limitRight <= _miterLimit
&& limitLeft <= _miterLimit) { && limitLeft <= _miterLimit) {
leftPoint = left; leftPoint = left;
@ -243,7 +243,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
} }
} }
} else { } else {
SVG_ERROR("Start list point with a join, but last lement is not a join"); ESVG_ERROR("Start list point with a join, but last lement is not a join");
} }
} }
} }
@ -251,22 +251,22 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
switch (it.m_type) { switch (it.m_type) {
case esvg::render::Point::type_single: case esvg::render::Point::type_single:
// just do nothing .... // just do nothing ....
SVG_VERBOSE("Find Single " << it.m_pos); ESVG_VERBOSE("Find Single " << it.m_pos);
break; break;
case esvg::render::Point::type_start: case esvg::render::Point::type_start:
SVG_VERBOSE("Find Start " << it.m_pos); ESVG_VERBOSE("Find Start " << it.m_pos);
if (haveStartLine == true) { if (haveStartLine == true) {
// close previous : // close previous :
SVG_WARNING(" find a non close path ..."); ESVG_WARNING(" find a non close path ...");
addSegment(leftPoint, rightPoint); addSegment(leftPoint, rightPoint);
} }
haveStartLine = true; haveStartLine = true;
startStopPoint(leftPoint, rightPoint, it, _cap, _width, true); startStopPoint(leftPoint, rightPoint, it, _cap, _width, true);
break; break;
case esvg::render::Point::type_stop: case esvg::render::Point::type_stop:
SVG_VERBOSE("Find Stop " << it.m_pos); ESVG_VERBOSE("Find Stop " << it.m_pos);
if (haveStartLine == false) { if (haveStartLine == false) {
SVG_WARNING("find close path without start part ..."); ESVG_WARNING("find close path without start part ...");
break; break;
} }
haveStartLine = false; haveStartLine = false;
@ -274,20 +274,20 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
break; break;
case esvg::render::Point::type_interpolation: case esvg::render::Point::type_interpolation:
{ {
SVG_VERBOSE("Find interpolation " << it.m_pos); ESVG_VERBOSE("Find interpolation " << it.m_pos);
vec2 left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe); vec2 left = getIntersect(leftPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
vec2 right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe); vec2 right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
//Draw from previous point: //Draw from previous point:
addSegment(leftPoint, left); addSegment(leftPoint, left);
SVG_VERBOSE(" segment :" << leftPoint << " -> " << left); ESVG_VERBOSE(" segment :" << leftPoint << " -> " << left);
addSegment(right, rightPoint); addSegment(right, rightPoint);
SVG_VERBOSE(" segment :" << right << " -> " << rightPoint); ESVG_VERBOSE(" segment :" << right << " -> " << rightPoint);
leftPoint = left; leftPoint = left;
rightPoint = right; rightPoint = right;
} }
break; break;
case esvg::render::Point::type_join: case esvg::render::Point::type_join:
SVG_VERBOSE("Find join " << it.m_pos); ESVG_VERBOSE("Find join " << it.m_pos);
switch (_join) { switch (_join) {
case esvg::join_miter: case esvg::join_miter:
{ {
@ -296,20 +296,20 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
// Check the miter limit: // Check the miter limit:
float limitRight = (left - it.m_pos).length() / _width * 2.0f; float limitRight = (left - it.m_pos).length() / _width * 2.0f;
float limitLeft = (right - it.m_pos).length() / _width * 2.0f; float limitLeft = (right - it.m_pos).length() / _width * 2.0f;
SVG_VERBOSE(" miter Limit: " << limitRight << " " << limitLeft << " <= " << _miterLimit); ESVG_VERBOSE(" miter Limit: " << limitRight << " " << limitLeft << " <= " << _miterLimit);
if ( limitRight <= _miterLimit if ( limitRight <= _miterLimit
&& limitLeft <= _miterLimit) { && limitLeft <= _miterLimit) {
//Draw from previous point: //Draw from previous point:
addSegment(leftPoint, left); addSegment(leftPoint, left);
SVG_VERBOSE(" segment :" << leftPoint << " -> " << left); ESVG_VERBOSE(" segment :" << leftPoint << " -> " << left);
addSegment(right, rightPoint); addSegment(right, rightPoint);
SVG_VERBOSE(" segment :" << right << " -> " << rightPoint); ESVG_VERBOSE(" segment :" << right << " -> " << rightPoint);
leftPoint = left; leftPoint = left;
rightPoint = right; rightPoint = right;
break; break;
} else { } else {
// We do a bevel join ... // We do a bevel join ...
SVG_VERBOSE(" Find miter Limit ... ==> create BEVEL"); ESVG_VERBOSE(" Find miter Limit ... ==> create BEVEL");
} }
} }
case esvg::join_round: case esvg::join_round:
@ -326,11 +326,11 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
+ it.m_orthoAxeNext*_width*0.5f; + it.m_orthoAxeNext*_width*0.5f;
//Draw from previous point: //Draw from previous point:
addSegment(leftPoint, left1); addSegment(leftPoint, left1);
SVG_VERBOSE(" segment :" << leftPoint << " -> " << left1); ESVG_VERBOSE(" segment :" << leftPoint << " -> " << left1);
if (_join != esvg::join_round) { if (_join != esvg::join_round) {
// Miter and bevel: // Miter and bevel:
addSegment(left1, left2); addSegment(left1, left2);
SVG_VERBOSE(" segment :" << left1 << " -> " << left2); ESVG_VERBOSE(" segment :" << left1 << " -> " << left2);
}else { }else {
createSegmentListStroke(left1, createSegmentListStroke(left1,
left2, left2,
@ -339,7 +339,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
false); false);
} }
addSegment(right, rightPoint); addSegment(right, rightPoint);
SVG_VERBOSE(" segment :" << right << " -> " << rightPoint); ESVG_VERBOSE(" segment :" << right << " -> " << rightPoint);
leftPoint = left2; leftPoint = left2;
rightPoint = right; rightPoint = right;
} else { } else {
@ -349,13 +349,13 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
vec2 right2 = it.m_pos vec2 right2 = it.m_pos
- it.m_orthoAxeNext*_width*0.5f;//Draw from previous point: - it.m_orthoAxeNext*_width*0.5f;//Draw from previous point:
addSegment(leftPoint, left); addSegment(leftPoint, left);
SVG_VERBOSE(" segment :" << leftPoint << " -> " << left); ESVG_VERBOSE(" segment :" << leftPoint << " -> " << left);
addSegment(right1, rightPoint); addSegment(right1, rightPoint);
SVG_VERBOSE(" segment :" << right1 << " -> " << rightPoint); ESVG_VERBOSE(" segment :" << right1 << " -> " << rightPoint);
if (_join != esvg::join_round) { if (_join != esvg::join_round) {
// Miter and bevel: // Miter and bevel:
addSegment(right2, right1); addSegment(right2, right1);
SVG_VERBOSE(" segment :" << right2 << " -> " << right1); ESVG_VERBOSE(" segment :" << right2 << " -> " << right1);
} else { } else {
createSegmentListStroke(right1, createSegmentListStroke(right1,
right2, right2,
@ -391,19 +391,19 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
if (_isStart == false) { if (_isStart == false) {
//Draw from previous point: //Draw from previous point:
addSegment(_leftPoint, left); addSegment(_leftPoint, left);
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << left); ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << left);
addSegment(right, _rightPoint); addSegment(right, _rightPoint);
SVG_VERBOSE(" segment :" << right << " -> " << _rightPoint); ESVG_VERBOSE(" segment :" << right << " -> " << _rightPoint);
} }
_leftPoint = left; _leftPoint = left;
_rightPoint = right; _rightPoint = right;
} }
if (_isStart == false) { if (_isStart == false) {
addSegment(_leftPoint, _rightPoint); addSegment(_leftPoint, _rightPoint);
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint); ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint);
} else { } else {
addSegment(_rightPoint, _leftPoint); addSegment(_rightPoint, _leftPoint);
SVG_VERBOSE(" segment :" << _rightPoint << " -> " << _leftPoint); ESVG_VERBOSE(" segment :" << _rightPoint << " -> " << _leftPoint);
} }
break; break;
case esvg::cap_round: case esvg::cap_round:
@ -416,9 +416,9 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
if (_isStart == false) { if (_isStart == false) {
//Draw from previous point: //Draw from previous point:
addSegment(_leftPoint, left); addSegment(_leftPoint, left);
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << left); ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << left);
addSegment(right, _rightPoint); addSegment(right, _rightPoint);
SVG_VERBOSE(" segment :" << right << " -> " << _rightPoint); ESVG_VERBOSE(" segment :" << right << " -> " << _rightPoint);
} }
_leftPoint = left; _leftPoint = left;
_rightPoint = right; _rightPoint = right;
@ -459,25 +459,25 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
if (_isStart == false) { if (_isStart == false) {
//Draw from previous point: //Draw from previous point:
addSegment(_leftPoint, left); addSegment(_leftPoint, left);
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << left); ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << left);
addSegment(right, _rightPoint); addSegment(right, _rightPoint);
SVG_VERBOSE(" segment :" << right << " -> " << _rightPoint); ESVG_VERBOSE(" segment :" << right << " -> " << _rightPoint);
} }
} }
_leftPoint = left; _leftPoint = left;
_rightPoint = right; _rightPoint = right;
if (_isStart == false) { if (_isStart == false) {
addSegment(_leftPoint, _rightPoint); addSegment(_leftPoint, _rightPoint);
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint); ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint);
} else { } else {
addSegment(_rightPoint, _leftPoint); addSegment(_rightPoint, _leftPoint);
SVG_VERBOSE(" segment :" << _rightPoint << " -> " << _leftPoint); ESVG_VERBOSE(" segment :" << _rightPoint << " -> " << _leftPoint);
} }
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint); ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint);
} }
break; break;
default: default:
SVG_ERROR(" Undefined CAP TYPE"); ESVG_ERROR(" Undefined CAP TYPE");
break; break;
} }
} }

View File

@ -32,7 +32,7 @@ void esvg::render::Weight::resize(const ivec2& _size) {
float tmp(0); float tmp(0);
m_data.resize(m_size.x()*m_size.y(), tmp); m_data.resize(m_size.x()*m_size.y(), tmp);
if ((uint32_t)m_size.x()*m_size.y() > m_data.size()) { if ((uint32_t)m_size.x()*m_size.y() > m_data.size()) {
SVG_WARNING("Wrong weigth buffer size ..."); ESVG_WARNING("Wrong weigth buffer size ...");
return; return;
} }
} }
@ -97,7 +97,7 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
resize(_size); resize(_size);
// for each lines: // for each lines:
for (int32_t yyy=0; yyy<_size.y(); ++yyy) { for (int32_t yyy=0; yyy<_size.y(); ++yyy) {
SVG_VERBOSE("Weighting ... " << yyy << " / " << _size.y()); ESVG_VERBOSE("Weighting ... " << yyy << " / " << _size.y());
// Reduce the number of lines in the subsampling parsing: // Reduce the number of lines in the subsampling parsing:
std::vector<Segment> availlableSegmentPixel; std::vector<Segment> availlableSegmentPixel;
for (auto &it : _listSegment.m_data) { for (auto &it : _listSegment.m_data) {
@ -109,11 +109,11 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
if (availlableSegmentPixel.size() == 0) { if (availlableSegmentPixel.size() == 0) {
continue; continue;
} }
SVG_VERBOSE(" Find Basic segments " << availlableSegmentPixel.size()); ESVG_VERBOSE(" Find Basic segments " << availlableSegmentPixel.size());
// This represent the pondaration on the subSampling // This represent the pondaration on the subSampling
float deltaSize = 1.0f/_subSamplingCount; float deltaSize = 1.0f/_subSamplingCount;
for (int32_t kkk=0; kkk<_subSamplingCount ; ++kkk) { for (int32_t kkk=0; kkk<_subSamplingCount ; ++kkk) {
SVG_VERBOSE(" Scanline ... " << kkk << " / " << _subSamplingCount); ESVG_VERBOSE(" Scanline ... " << kkk << " / " << _subSamplingCount);
Scanline scanline(_size.x()); Scanline scanline(_size.x());
//find all the segment that cross the middle of the line of the center of the pixel line: //find all the segment that cross the middle of the line of the center of the pixel line:
float subSamplingCenterPos = yyy + deltaSize*0.5f + deltaSize*kkk; float subSamplingCenterPos = yyy + deltaSize*0.5f + deltaSize*kkk;
@ -132,12 +132,12 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
} }
} }
} }
SVG_VERBOSE(" Availlable Segment " << availlableSegment.size()); ESVG_VERBOSE(" Availlable Segment " << availlableSegment.size());
if (availlableSegment.size() == 0) { if (availlableSegment.size() == 0) {
continue; continue;
} }
for (auto &it : availlableSegment) { for (auto &it : availlableSegment) {
SVG_VERBOSE(" Availlable Segment " << it.p0 << " -> " << it.p1 << " dir=" << it.direction); ESVG_VERBOSE(" Availlable Segment " << it.p0 << " -> " << it.p1 << " dir=" << it.direction);
} }
// x position, angle // x position, angle
std::vector<std::pair<float, int32_t>> listPosition; std::vector<std::pair<float, int32_t>> listPosition;
@ -149,7 +149,7 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
float xpos = coefficient * subSamplingCenterPos + bbb; float xpos = coefficient * subSamplingCenterPos + bbb;
listPosition.push_back(std::pair<float,int32_t>(xpos, it.direction)); listPosition.push_back(std::pair<float,int32_t>(xpos, it.direction));
} }
SVG_VERBOSE(" List position " << listPosition.size()); ESVG_VERBOSE(" List position " << listPosition.size());
// now we order position of the xPosition: // now we order position of the xPosition:
std::sort(listPosition.begin(), listPosition.end(), sortXPosFunction); std::sort(listPosition.begin(), listPosition.end(), sortXPosFunction);
// move through all element in the point: // move through all element in the point:
@ -197,7 +197,7 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
// if the counter is not at 0 ==> fill if to the end with full value ... 2.0 // if the counter is not at 0 ==> fill if to the end with full value ... 2.0
if (lastState != 0) { if (lastState != 0) {
// just past the last state to the end of the image ... // just past the last state to the end of the image ...
SVG_ERROR("end of Path whith no end ... " << currentPos << " -> " << _size.x()); ESVG_ERROR("end of Path whith no end ... " << currentPos << " -> " << _size.x());
for (int32_t xxx=currentPos; xxx<_size.x(); ++xxx) { for (int32_t xxx=currentPos; xxx<_size.x(); ++xxx) {
scanline.set(xxx, 100.0); scanline.set(xxx, 100.0);
} }