[DEV] change LOG element from SVG to ESVG better adapted with the library
This commit is contained in:
parent
9c5496f857
commit
8415109007
@ -59,13 +59,13 @@ void esvg::Base::parseTransform(const std::shared_ptr<exml::Element>& _element)
|
||||
if (inputString.size() == 0) {
|
||||
return;
|
||||
}
|
||||
SVG_VERBOSE("find transform : \"" << inputString << "\"");
|
||||
ESVG_VERBOSE("find transform : \"" << inputString << "\"");
|
||||
for (int32_t iii=0; iii<inputString.size(); iii++) {
|
||||
if (inputString[iii] == ',') {
|
||||
inputString[iii] = ' ';
|
||||
}
|
||||
}
|
||||
SVG_VERBOSE("find transform : \"" << inputString << "\"");
|
||||
ESVG_VERBOSE("find transform : \"" << inputString << "\"");
|
||||
double matrix[6];
|
||||
float angle, xxx, yyy;
|
||||
int32_t n;
|
||||
@ -75,16 +75,16 @@ void esvg::Base::parseTransform(const std::shared_ptr<exml::Element>& _element)
|
||||
m_transformMatrix = mat2(matrix);
|
||||
} else if (sscanf(pointerOnData, "translate (%f %f) %n", &xxx, &yyy, &n) == 2) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
angle = angle / 180 * M_PI;
|
||||
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));
|
||||
} else if (sscanf(pointerOnData, "rotate (%f) %n", &angle, &n) == 1) {
|
||||
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);
|
||||
} else if (sscanf(pointerOnData, "skewX (%f) %n", &angle, &n) == 1) {
|
||||
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));
|
||||
} else if (sscanf(pointerOnData, "skewY (%f) %n", &angle, &n) == 1) {
|
||||
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));
|
||||
} else {
|
||||
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) {
|
||||
SVG_VERBOSE(" lenght : '" << _dataInput << "'");
|
||||
ESVG_VERBOSE(" lenght : '" << _dataInput << "'");
|
||||
float n = stof(_dataInput);
|
||||
std::string unit;
|
||||
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);
|
||||
break;
|
||||
}
|
||||
SVG_VERBOSE(" lenght : '" << n << "' => unit=" << unit);
|
||||
ESVG_VERBOSE(" lenght : '" << n << "' => unit=" << unit);
|
||||
// note : ";" is for the parsing of the style elements ...
|
||||
if(unit.size() == 0) {
|
||||
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) {
|
||||
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;
|
||||
switch (value.second) {
|
||||
case esvg::distance_pourcent:
|
||||
@ -248,7 +248,7 @@ void esvg::Base::parsePaintAttr(const std::shared_ptr<const exml::Element>& _ele
|
||||
if (content == "none" ) {
|
||||
// OK, Nothing to do ...
|
||||
} else {
|
||||
SVG_TODO(" 'stroke-dasharray' not implemented ...");
|
||||
ESVG_TODO(" 'stroke-dasharray' not implemented ...");
|
||||
}
|
||||
}
|
||||
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;
|
||||
} else {
|
||||
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");
|
||||
@ -274,7 +274,7 @@ void esvg::Base::parsePaintAttr(const std::shared_ptr<const exml::Element>& _ele
|
||||
m_paint.lineJoin = esvg::join_bevel;
|
||||
} else {
|
||||
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");
|
||||
@ -305,7 +305,7 @@ void esvg::Base::parsePaintAttr(const std::shared_ptr<const exml::Element>& _ele
|
||||
} else if (content == "evenodd" ) {
|
||||
m_paint.flagEvenOdd = true;
|
||||
} 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 ----------------
|
||||
@ -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);
|
||||
localColor = std::pair<etk::Color<float,4>, std::string>(etk::color::none, color);
|
||||
} 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 {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -365,7 +365,7 @@ const char * esvg::Base::spacingDist(int32_t _spacing) {
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
|
||||
|
@ -46,12 +46,12 @@ bool esvg::Circle::parseXML(const std::shared_ptr<exml::Element>& _element, mat2
|
||||
if (content.size()!=0) {
|
||||
m_radius = parseLength(content);
|
||||
} else {
|
||||
SVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is not present");
|
||||
ESVG_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");
|
||||
ESVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is negative");
|
||||
return false;
|
||||
}
|
||||
_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) {
|
||||
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) {
|
||||
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Circle");
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Circle");
|
||||
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;
|
||||
}
|
||||
esvg::render::Path listElement;
|
||||
|
@ -67,12 +67,12 @@ void esvg::Dimension::set(std::string _config) {
|
||||
type = esvg::distance_meter;
|
||||
_config.erase(_config.size()-1, 1);
|
||||
} else {
|
||||
SVG_CRITICAL("Can not parse dimention : \"" << _config << "\"");
|
||||
ESVG_CRITICAL("Can not parse dimention : \"" << _config << "\"");
|
||||
return;
|
||||
}
|
||||
vec2 tmp = _config;
|
||||
set(tmp, type);
|
||||
SVG_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this );
|
||||
ESVG_VERBOSE(" config dimention : \"" << _config << "\" == > " << *this );
|
||||
}
|
||||
|
||||
static enum esvg::distance parseType(std::string& _config) {
|
||||
@ -102,7 +102,7 @@ static enum esvg::distance parseType(std::string& _config) {
|
||||
type = esvg::distance_meter;
|
||||
_config.erase(_config.size()-1, 1);
|
||||
} else {
|
||||
SVG_CRITICAL("Can not parse dimention : \"" << _config << "\"");
|
||||
ESVG_CRITICAL("Can not parse dimention : \"" << _config << "\"");
|
||||
}
|
||||
return type;
|
||||
}
|
||||
@ -120,7 +120,7 @@ void esvg::Dimension::set(std::string _configX, std::string _configY) {
|
||||
float valueY = etk::string_to_float(_configY);
|
||||
// TODO : Check difference ...
|
||||
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_point:
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -47,14 +47,14 @@ bool esvg::Ellipse::parseXML(const std::shared_ptr<exml::Element>& _element, mat
|
||||
if (content.size()!=0) {
|
||||
m_r.setX(parseLength(content));
|
||||
} else {
|
||||
SVG_ERROR("(l "<<_element->getPos()<<") Ellipse \"rx\" is not present");
|
||||
ESVG_ERROR("(l "<<_element->getPos()<<") Ellipse \"rx\" is not present");
|
||||
return false;
|
||||
}
|
||||
content = _element->getAttribute("ry");
|
||||
if (content.size()!=0) {
|
||||
m_r.setY(parseLength(content));
|
||||
} else {
|
||||
SVG_ERROR("(l "<<_element->getPos()<<") Ellipse \"ry\" is not present");
|
||||
ESVG_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());
|
||||
@ -63,15 +63,15 @@ bool esvg::Ellipse::parseXML(const std::shared_ptr<exml::Element>& _element, mat
|
||||
}
|
||||
|
||||
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) {
|
||||
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Ellipse");
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Ellipse");
|
||||
if ( m_r.x()<=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;
|
||||
}
|
||||
esvg::render::Path listElement;
|
||||
|
@ -41,12 +41,12 @@ bool esvg::Group::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
|
||||
parseTransform(_element);
|
||||
parsePosition(_element, pos, size);
|
||||
parsePaintAttr(_element);
|
||||
SVG_VERBOSE("parsed G1. trans : " << m_transformMatrix);
|
||||
ESVG_VERBOSE("parsed G1. trans : " << m_transformMatrix);
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
SVG_VERBOSE("parsed G2. trans : " << m_transformMatrix);
|
||||
ESVG_VERBOSE("parsed G2. trans : " << m_transformMatrix);
|
||||
|
||||
_sizeMax.setValue(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") {
|
||||
elementParser = std::make_shared<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]");
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
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();
|
||||
continue;
|
||||
}
|
||||
@ -99,7 +99,7 @@ bool esvg::Group::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
|
||||
}
|
||||
|
||||
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-width=" << m_paint.strokeWidth );
|
||||
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);
|
||||
}
|
||||
}
|
||||
SVG_DEBUG(spacingDist(_spacing) << "Group (STOP)");
|
||||
ESVG_DEBUG(spacingDist(_spacing) << "Group (STOP)");
|
||||
}
|
||||
|
||||
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) {
|
||||
if (m_subElementList[iii] != nullptr) {
|
||||
m_subElementList[iii]->draw(_myRenderer, _basicTrans, _level+1);
|
||||
|
@ -57,11 +57,11 @@ bool esvg::Line::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
|
||||
}
|
||||
|
||||
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) {
|
||||
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Line");
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Line");
|
||||
|
||||
esvg::render::Path listElement;
|
||||
listElement.clear();
|
||||
|
@ -61,7 +61,7 @@ bool esvg::LinearGradient::parseXML(const std::shared_ptr<exml::Element>& _eleme
|
||||
if (content.size()!=0) {
|
||||
std::pair<float, enum esvg::distance> tmp = parseLength2(content);
|
||||
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 {
|
||||
offset = tmp.first;
|
||||
}
|
||||
@ -69,32 +69,32 @@ bool esvg::LinearGradient::parseXML(const std::shared_ptr<exml::Element>& _eleme
|
||||
content = child->getAttribute("stop-color");
|
||||
if (content.size()!=0) {
|
||||
stopColor = parseColor(content).first;
|
||||
SVG_VERBOSE(" color : \"" << content << "\" == > " << stopColor);
|
||||
ESVG_VERBOSE(" color : \"" << content << "\" == > " << stopColor);
|
||||
}
|
||||
content = child->getAttribute("stop-opacity");
|
||||
if (content.size()!=0) {
|
||||
float opacity = parseLength(content);
|
||||
opacity = std::avg(0.0f, opacity, 1.0f);
|
||||
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));
|
||||
} 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;
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::LinearGradient");
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::LinearGradient");
|
||||
}
|
||||
|
||||
|
||||
|
@ -35,11 +35,11 @@ const char * extractCmd(const char* _input, char& _cmd, std::vector<float>& _out
|
||||
&& _input[0] >= 'A')
|
||||
|| ( _input[0] <= 'z'
|
||||
&& _input[0] >= 'a') ) ) {
|
||||
SVG_ERROR("Error in the SVG Path : \"" << _input << "\"");
|
||||
ESVG_ERROR("Error in the SVG Path : \"" << _input << "\"");
|
||||
return nullptr;
|
||||
}
|
||||
_cmd = _input[0];
|
||||
SVG_VERBOSE("Find command : " << _cmd);
|
||||
ESVG_VERBOSE("Find command : " << _cmd);
|
||||
if (_input[1] == '\0') {
|
||||
return &_input[1];
|
||||
}
|
||||
@ -50,7 +50,7 @@ const char * extractCmd(const char* _input, char& _cmd, std::vector<float>& _out
|
||||
int32_t nbElementRead;
|
||||
while( sscanf(&_input[iii], "%1[, ]%f%n", spacer, &element, &nbElementRead) == 2
|
||||
|| sscanf(&_input[iii], "%f%n", &element, &nbElementRead) == 1) {
|
||||
SVG_VERBOSE("Find element : " << element);
|
||||
ESVG_VERBOSE("Find element : " << element);
|
||||
_outputList.push_back(element);
|
||||
iii += nbElementRead;
|
||||
}
|
||||
@ -75,10 +75,10 @@ bool esvg::Path::parseXML(const std::shared_ptr<exml::Element>& _element, mat2&
|
||||
|
||||
std::string elementXML1 = _element->getAttribute("d");
|
||||
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;
|
||||
}
|
||||
SVG_VERBOSE("Parse Path : \"" << elementXML1 << "\"");
|
||||
ESVG_VERBOSE("Parse Path : \"" << elementXML1 << "\"");
|
||||
|
||||
char command;
|
||||
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)
|
||||
// 2 Elements ...
|
||||
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;
|
||||
}
|
||||
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)
|
||||
// 2 Elements ...
|
||||
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;
|
||||
}
|
||||
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)
|
||||
// 1 Element ...
|
||||
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;
|
||||
}
|
||||
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)
|
||||
// 1 Element ...
|
||||
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;
|
||||
}
|
||||
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)
|
||||
// 4 Elements ...
|
||||
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;
|
||||
}
|
||||
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)
|
||||
// 2 Elements ...
|
||||
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;
|
||||
}
|
||||
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)
|
||||
// 6 Elements ...
|
||||
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;
|
||||
}
|
||||
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)
|
||||
// 4 Elements ...
|
||||
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;
|
||||
}
|
||||
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)
|
||||
// 7 Elements ...
|
||||
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;
|
||||
}
|
||||
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)
|
||||
// 0 Element ...
|
||||
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;
|
||||
}
|
||||
m_listElement.close(relative);
|
||||
break;
|
||||
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) {
|
||||
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Path");
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Path");
|
||||
|
||||
mat2 mtx = m_transformMatrix;
|
||||
mtx *= _basicTrans;
|
||||
|
@ -29,21 +29,21 @@ bool esvg::Polygon::parseXML(const std::shared_ptr<exml::Element>& _element, mat
|
||||
parseTransform(_element);
|
||||
parsePaintAttr(_element);
|
||||
|
||||
SVG_VERBOSE("parsed P1. trans: " << m_transformMatrix);
|
||||
ESVG_VERBOSE("parsed P1. trans: " << m_transformMatrix);
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
SVG_VERBOSE("parsed P2. trans: " << m_transformMatrix);
|
||||
ESVG_VERBOSE("parsed P2. trans: " << m_transformMatrix);
|
||||
|
||||
const std::string sss1 = _element->getAttribute("points");
|
||||
if (sss1.size() == 0) {
|
||||
SVG_ERROR("(l "/*<<_element->Pos()*/<<") polygon: missing points attribute");
|
||||
ESVG_ERROR("(l "/*<<_element->Pos()*/<<") polygon: missing points attribute");
|
||||
return false;
|
||||
}
|
||||
const char * sss = sss1.c_str();
|
||||
_sizeMax.setValue(0,0);
|
||||
SVG_VERBOSE("Parse polygon : \"" << sss << "\"");
|
||||
ESVG_VERBOSE("Parse polygon : \"" << sss << "\"");
|
||||
while ('\0' != sss[0]) {
|
||||
vec2 pos(0,0);
|
||||
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) {
|
||||
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) {
|
||||
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polygon");
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polygon");
|
||||
|
||||
esvg::render::Path listElement;
|
||||
listElement.moveTo(false, m_listPoint[0]);
|
||||
|
@ -36,11 +36,11 @@ bool esvg::Polyline::parseXML(const std::shared_ptr<exml::Element>& _element, ma
|
||||
|
||||
std::string sss1 = _element->getAttribute("points");
|
||||
if (sss1.size() == 0) {
|
||||
SVG_ERROR("(l "<<_element->getPos()<<") polyline: missing points attribute");
|
||||
ESVG_ERROR("(l "<<_element->getPos()<<") polyline: missing points attribute");
|
||||
return false;
|
||||
}
|
||||
_sizeMax.setValue(0,0);
|
||||
SVG_VERBOSE("Parse polyline : \"" << sss1 << "\"");
|
||||
ESVG_VERBOSE("Parse polyline : \"" << sss1 << "\"");
|
||||
const char* sss = sss1.c_str();
|
||||
while ('\0' != sss[0]) {
|
||||
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) {
|
||||
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) {
|
||||
SVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polyline");
|
||||
ESVG_VERBOSE(spacingDist(_level) << "DRAW esvg::Polyline");
|
||||
|
||||
esvg::render::Path listElement;
|
||||
listElement.clear();
|
||||
|
@ -55,11 +55,11 @@ bool esvg::Rectangle::parseXML(const std::shared_ptr<exml::Element>& _element, m
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
esvg::render::Path listElement;
|
||||
listElement.clear();
|
||||
|
@ -206,7 +206,7 @@ void esvg::Renderer::writePPM(const std::string& _fileName) {
|
||||
}
|
||||
etk::FSNode tmpFile(_fileName);
|
||||
if(tmpFile.fileOpenWrite() == false) {
|
||||
SVG_ERROR("Can not find the file name=\"" << tmpFile << "\"");
|
||||
ESVG_ERROR("Can not find the file name=\"" << tmpFile << "\"");
|
||||
return;
|
||||
}
|
||||
int32_t sizeX = m_size.x();
|
||||
@ -215,7 +215,7 @@ void esvg::Renderer::writePPM(const std::string& _fileName) {
|
||||
sizeX *= m_factor;
|
||||
sizeY *= m_factor;
|
||||
#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];
|
||||
sprintf(tmpValue, "P6 %d %d 255 ", sizeX, sizeY);
|
||||
tmpFile.fileWrite(tmpValue,1,sizeof(tmpValue));
|
||||
@ -268,7 +268,7 @@ void esvg::Renderer::writeBMP(const std::string& _fileName) {
|
||||
etk::FSNode tmpFile(_fileName);
|
||||
|
||||
if(tmpFile.fileOpenWrite() == false) {
|
||||
SVG_ERROR("Can not find the file name=\"" << tmpFile << "\"");
|
||||
ESVG_ERROR("Can not find the file name=\"" << tmpFile << "\"");
|
||||
return;
|
||||
}
|
||||
struct bitmapFileHeader fileHeader;
|
||||
|
@ -22,12 +22,12 @@ esvg::Text::~Text() {
|
||||
|
||||
bool esvg::Text::parse(const std::shared_ptr<exml::Element>& _element, mat2& _parentTrans, vec2& _sizeMax) {
|
||||
_sizeMax.setValue(0,0);
|
||||
SVG_ERROR("NOT IMPLEMENTED");
|
||||
ESVG_ERROR("NOT IMPLEMENTED");
|
||||
return false;
|
||||
}
|
||||
|
||||
void esvg::Text::display(int32_t _spacing) {
|
||||
SVG_DEBUG(spacingDist(_spacing) << "Text");
|
||||
ESVG_DEBUG(spacingDist(_spacing) << "Text");
|
||||
}
|
||||
|
||||
|
||||
|
28
esvg/debug.h
28
esvg/debug.h
@ -14,25 +14,25 @@
|
||||
namespace esvg {
|
||||
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 SVG_CRITICAL(data) SVG_BASE(1, data)
|
||||
#define SVG_ERROR(data) SVG_BASE(2, data)
|
||||
#define SVG_WARNING(data) SVG_BASE(3, data)
|
||||
#define ESVG_PRINT(data) ESVG_BASE(-1, data)
|
||||
#define ESVG_CRITICAL(data) ESVG_BASE(1, data)
|
||||
#define ESVG_ERROR(data) ESVG_BASE(2, data)
|
||||
#define ESVG_WARNING(data) ESVG_BASE(3, data)
|
||||
#ifdef DEBUG
|
||||
#define SVG_INFO(data) SVG_BASE(4, data)
|
||||
#define SVG_DEBUG(data) SVG_BASE(5, data)
|
||||
#define SVG_VERBOSE(data) SVG_BASE(6, data)
|
||||
#define SVG_TODO(data) SVG_BASE(4, "TODO : " << data)
|
||||
#define ESVG_INFO(data) ESVG_BASE(4, data)
|
||||
#define ESVG_DEBUG(data) ESVG_BASE(5, data)
|
||||
#define ESVG_VERBOSE(data) ESVG_BASE(6, data)
|
||||
#define ESVG_TODO(data) ESVG_BASE(4, "TODO : " << data)
|
||||
#else
|
||||
#define SVG_INFO(data) do { } while(false)
|
||||
#define SVG_DEBUG(data) do { } while(false)
|
||||
#define SVG_VERBOSE(data) do { } while(false)
|
||||
#define SVG_TODO(data) do { } while(false)
|
||||
#define ESVG_INFO(data) do { } while(false)
|
||||
#define ESVG_DEBUG(data) do { } while(false)
|
||||
#define ESVG_VERBOSE(data) do { } while(false)
|
||||
#define ESVG_TODO(data) do { } while(false)
|
||||
#endif
|
||||
|
||||
#define SVG_ASSERT(cond,data) \
|
||||
#define ESVG_ASSERT(cond,data) \
|
||||
do { \
|
||||
if (!(cond)) { \
|
||||
SVG_CRITICAL(data); \
|
||||
|
@ -39,14 +39,14 @@ esvg::Document::~Document() {
|
||||
|
||||
|
||||
void esvg::Document::displayDebug() {
|
||||
SVG_DEBUG("Main SVG: size=" << m_size);
|
||||
SVG_DEBUG(" refs:");
|
||||
ESVG_DEBUG("Main SVG: size=" << m_size);
|
||||
ESVG_DEBUG(" refs:");
|
||||
for (int32_t iii=0; iii<m_refList.size(); iii++) {
|
||||
if (m_refList[iii] != nullptr) {
|
||||
m_refList[iii]->display(2);
|
||||
}
|
||||
}
|
||||
SVG_DEBUG(" Nodes:");
|
||||
ESVG_DEBUG(" Nodes:");
|
||||
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
|
||||
if (m_subElementList[iii] != nullptr) {
|
||||
m_subElementList[iii]->display(2);
|
||||
@ -72,7 +72,7 @@ void esvg::Document::generateAnImage(const ivec2& _size, const std::string& _fil
|
||||
if (sizeRender.y() <= 0) {
|
||||
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);
|
||||
// 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) {
|
||||
renderedElement->writeBMP(_fileName);
|
||||
} 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) {
|
||||
_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);
|
||||
// create the first element matrix modification ...
|
||||
mat2 basicTrans;
|
||||
@ -155,18 +155,18 @@ bool esvg::Document::parse(const std::string& _data) {
|
||||
clear();
|
||||
exml::Document doc;
|
||||
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;
|
||||
return m_loadOK;
|
||||
}
|
||||
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;
|
||||
return m_loadOK;
|
||||
}
|
||||
std::shared_ptr<exml::Element> root = doc.getNamed("svg" );
|
||||
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;
|
||||
return m_loadOK;
|
||||
}
|
||||
@ -184,18 +184,18 @@ bool esvg::Document::load(const std::string& _file) {
|
||||
m_fileName = _file;
|
||||
exml::Document doc;
|
||||
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;
|
||||
return m_loadOK;
|
||||
}
|
||||
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;
|
||||
return m_loadOK;
|
||||
}
|
||||
std::shared_ptr<exml::Element> root = doc.getNamed("svg");
|
||||
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;
|
||||
return m_loadOK;
|
||||
}
|
||||
@ -223,7 +223,7 @@ bool esvg::Document::cleanStyleProperty(const std::shared_ptr<exml::Element>& _r
|
||||
for (auto &it : listStyle) {
|
||||
std::vector<std::string> value = etk::split(it, ':');
|
||||
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;
|
||||
}
|
||||
// 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);
|
||||
parsePosition(_root, pos, m_size);
|
||||
parsePaintAttr(_root);
|
||||
SVG_VERBOSE("parsed .ROOT trans: " << m_transformMatrix);
|
||||
ESVG_VERBOSE("parsed .ROOT trans: " << m_transformMatrix);
|
||||
} else {
|
||||
SVG_VERBOSE("Parse Reference section ... (no attibute)");
|
||||
ESVG_VERBOSE("Parse Reference section ... (no attibute)");
|
||||
}
|
||||
vec2 maxSize(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") {
|
||||
elementParser = std::make_shared<esvg::Group>(m_paint);
|
||||
} 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);
|
||||
} else if (child->getValue() == "title") {
|
||||
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);
|
||||
} else if (child->getValue() == "radialGradient") {
|
||||
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;
|
||||
} else {
|
||||
//elementParser = std::make_shared<esvg::RadialGradient>(m_paint);
|
||||
}
|
||||
} else if (child->getValue() == "linearGradient") {
|
||||
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;
|
||||
} else {
|
||||
elementParser = std::make_shared<esvg::LinearGradient>(m_paint);
|
||||
}
|
||||
} else if (child->getValue() == "defs") {
|
||||
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;
|
||||
} else {
|
||||
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
|
||||
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]");
|
||||
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) {
|
||||
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;
|
||||
}
|
||||
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();
|
||||
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) {
|
||||
if (_name == "") {
|
||||
SVG_ERROR("request a reference with no name ... ");
|
||||
ESVG_ERROR("request a reference with no name ... ");
|
||||
return nullptr;
|
||||
}
|
||||
for (auto &it : m_refList) {
|
||||
@ -366,7 +366,7 @@ std::shared_ptr<esvg::Base> esvg::Document::getReference(const std::string& _nam
|
||||
return it;
|
||||
}
|
||||
}
|
||||
SVG_ERROR("Can not find reference name : '" << _name << "'");
|
||||
ESVG_ERROR("Can not find reference name : '" << _name << "'");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -25,20 +25,20 @@ etk::Color<float,4> esvg::render::DynamicColorLinear::getColor(const ivec2& _pos
|
||||
|
||||
void esvg::render::DynamicColorLinear::generate(esvg::Document* _document) {
|
||||
if (_document == nullptr) {
|
||||
SVG_ERROR("Get nullptr input for document");
|
||||
ESVG_ERROR("Get nullptr input for document");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<esvg::Base> base = _document->getReference(m_colorName);
|
||||
if (base == nullptr) {
|
||||
SVG_ERROR("Can not get base : '" << m_colorName << "'");
|
||||
ESVG_ERROR("Can not get base : '" << m_colorName << "'");
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<esvg::LinearGradient> gradient = std::dynamic_pointer_cast<esvg::LinearGradient>(base);
|
||||
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;
|
||||
}
|
||||
SVG_INFO("get for color linear:");
|
||||
ESVG_INFO("get for color linear:");
|
||||
gradient->display(2);
|
||||
}
|
||||
|
||||
|
@ -74,12 +74,12 @@ static const char* spacingDist(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) {
|
||||
if (it == nullptr) {
|
||||
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) {
|
||||
SVG_VERBOSE(spacingDist(_level) << "Generate List Points ... from a path");
|
||||
ESVG_VERBOSE(spacingDist(_level) << "Generate List Points ... from a path");
|
||||
esvg::render::PointList out;
|
||||
std::vector<esvg::render::Point> tmpListPoint;
|
||||
vec2 lastPosition(0.0f, 0.0f);
|
||||
@ -134,12 +134,12 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
if (it == nullptr) {
|
||||
continue;
|
||||
}
|
||||
SVG_VERBOSE(spacingDist(_level+1) << " Draw : " << *it);
|
||||
ESVG_VERBOSE(spacingDist(_level+1) << " Draw : " << *it);
|
||||
switch (it->getType()) {
|
||||
case esvg::render::path_stop:
|
||||
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 {
|
||||
tmpListPoint.back().setEndPath();
|
||||
out.addList(tmpListPoint);
|
||||
@ -152,7 +152,7 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
case esvg::render::path_close:
|
||||
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 {
|
||||
// find the previous tart of the path ...
|
||||
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
|
||||
&& delta.y() <= 0.00001) {
|
||||
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);
|
||||
tmpListPoint.clear();
|
||||
@ -331,9 +331,9 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
}
|
||||
break;
|
||||
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(),
|
||||
it->m_element[0],
|
||||
it->m_element[1],
|
||||
@ -345,13 +345,13 @@ esvg::render::PointList esvg::render::Path::generateListPoints(int32_t _level, i
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
SVG_ERROR(spacingDist(_level+1) << " Unknow PATH commant (internal error)");
|
||||
ESVG_ERROR(spacingDist(_level+1) << " Unknow PATH commant (internal error)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
// special case : No request end of path ==> open path:
|
||||
if (tmpListPoint.size() != 0) {
|
||||
SVG_VERBOSE("Auto-end PATH");
|
||||
ESVG_VERBOSE("Auto-end PATH");
|
||||
tmpListPoint.back().setEndPath();
|
||||
out.addList(tmpListPoint);
|
||||
tmpListPoint.clear();
|
||||
|
@ -14,12 +14,12 @@
|
||||
|
||||
void esvg::render::Point::setEndPath() {
|
||||
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;
|
||||
return;
|
||||
}
|
||||
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;
|
||||
}
|
||||
if (m_type == esvg::render::Point::type_start) {
|
||||
|
@ -28,27 +28,27 @@ void esvg::render::PointList::applyMatrix(const mat2& _transformationMatrix) {
|
||||
|
||||
|
||||
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) {
|
||||
SVG_VERBOSE(" Find List " << it.size() << " members");
|
||||
ESVG_VERBOSE(" Find List " << it.size() << " members");
|
||||
for (int32_t iii=0;
|
||||
iii < it.size();
|
||||
++iii) {
|
||||
switch (it[iii].m_type) {
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ static vec2 getIntersect(const vec2& _point1,
|
||||
) / diviseur;
|
||||
return vec2(_point2 + _vect2 * mmm);
|
||||
}
|
||||
SVG_ERROR("Get divider / 0.0f");
|
||||
ESVG_ERROR("Get divider / 0.0f");
|
||||
return _point2;
|
||||
}
|
||||
|
||||
@ -83,19 +83,19 @@ void esvg::render::SegmentList::createSegmentListStroke(const vec2& _point1,
|
||||
+ axeRotate*_width*0.5f;
|
||||
if (_isStart == true) {
|
||||
addSegment(ppp2, ppp1);
|
||||
SVG_VERBOSE(" segment :" << ppp2 << " -> " << ppp1);
|
||||
ESVG_VERBOSE(" segment :" << ppp2 << " -> " << ppp1);
|
||||
} else {
|
||||
addSegment(ppp1, ppp2);
|
||||
SVG_VERBOSE(" segment :" << ppp1 << " -> " << ppp2);
|
||||
ESVG_VERBOSE(" segment :" << ppp1 << " -> " << ppp2);
|
||||
}
|
||||
ppp1 = ppp2;
|
||||
}
|
||||
if (_isStart == true) {
|
||||
addSegment(_point2, ppp1);
|
||||
SVG_VERBOSE(" segment :" << _point2 << " -> " << ppp1);
|
||||
ESVG_VERBOSE(" segment :" << _point2 << " -> " << ppp1);
|
||||
} else {
|
||||
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
|
||||
|| itListPoint[idCurrent].m_type == esvg::render::Point::type_interpolation) {
|
||||
if (idPevious < 0 ) {
|
||||
SVG_ERROR("an error occure a previous ID is < 0.... ");
|
||||
ESVG_ERROR("an error occure a previous ID is < 0.... ");
|
||||
continue;
|
||||
}
|
||||
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;
|
||||
}
|
||||
//SVG_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 : id : prev/curr/next : " << idPevious << "/" << idCurrent << "/" << idNext);
|
||||
//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;
|
||||
//SVG_DEBUG("JOIN : vecA : " << vecA);
|
||||
//ESVG_DEBUG("JOIN : vecA : " << vecA);
|
||||
vecA.safeNormalize();
|
||||
vec2 vecB = itListPoint[idNext].m_pos - itListPoint[idCurrent].m_pos;
|
||||
//SVG_DEBUG("JOIN : vecB : " << vecB);
|
||||
//ESVG_DEBUG("JOIN : vecB : " << vecB);
|
||||
vecB.safeNormalize();
|
||||
vec2 vecC = vecA - vecB;
|
||||
//SVG_DEBUG("JOIN : vecC : " << vecC);
|
||||
//ESVG_DEBUG("JOIN : vecC : " << vecC);
|
||||
if (vecC == vec2(0.0f, 0.0f)) {
|
||||
// special case: 1 line ...
|
||||
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.safeNormalize();
|
||||
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) {
|
||||
itListPoint[idCurrent].m_posNext = itListPoint[idNext].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;
|
||||
} else if (itListPoint[idCurrent].m_type == esvg::render::Point::type_stop) {
|
||||
if (idPevious < 0 ) {
|
||||
SVG_ERROR("an error occure a previous ID is < 0.... ");
|
||||
ESVG_ERROR("an error occure a previous ID is < 0.... ");
|
||||
continue;
|
||||
}
|
||||
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_orthoAxeNext = itListPoint[idCurrent].m_miterAxe;
|
||||
} else {
|
||||
SVG_TODO("Unsupported type of point ....");
|
||||
ESVG_TODO("Unsupported type of point ....");
|
||||
}
|
||||
}
|
||||
// create segment list:
|
||||
@ -214,7 +214,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
||||
// Check the miter limit:
|
||||
float limitRight = (left - 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
|
||||
&& limitLeft <= _miterLimit) {
|
||||
leftPoint = left;
|
||||
@ -243,7 +243,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
||||
}
|
||||
}
|
||||
} 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) {
|
||||
case esvg::render::Point::type_single:
|
||||
// just do nothing ....
|
||||
SVG_VERBOSE("Find Single " << it.m_pos);
|
||||
ESVG_VERBOSE("Find Single " << it.m_pos);
|
||||
break;
|
||||
case esvg::render::Point::type_start:
|
||||
SVG_VERBOSE("Find Start " << it.m_pos);
|
||||
ESVG_VERBOSE("Find Start " << it.m_pos);
|
||||
if (haveStartLine == true) {
|
||||
// close previous :
|
||||
SVG_WARNING(" find a non close path ...");
|
||||
ESVG_WARNING(" find a non close path ...");
|
||||
addSegment(leftPoint, rightPoint);
|
||||
}
|
||||
haveStartLine = true;
|
||||
startStopPoint(leftPoint, rightPoint, it, _cap, _width, true);
|
||||
break;
|
||||
case esvg::render::Point::type_stop:
|
||||
SVG_VERBOSE("Find Stop " << it.m_pos);
|
||||
ESVG_VERBOSE("Find Stop " << it.m_pos);
|
||||
if (haveStartLine == false) {
|
||||
SVG_WARNING("find close path without start part ...");
|
||||
ESVG_WARNING("find close path without start part ...");
|
||||
break;
|
||||
}
|
||||
haveStartLine = false;
|
||||
@ -274,20 +274,20 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
||||
break;
|
||||
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 right = getIntersect(rightPoint, it.m_pos-it.m_posPrevious, it.m_pos, it.m_miterAxe);
|
||||
//Draw from previous point:
|
||||
addSegment(leftPoint, left);
|
||||
SVG_VERBOSE(" segment :" << leftPoint << " -> " << left);
|
||||
ESVG_VERBOSE(" segment :" << leftPoint << " -> " << left);
|
||||
addSegment(right, rightPoint);
|
||||
SVG_VERBOSE(" segment :" << right << " -> " << rightPoint);
|
||||
ESVG_VERBOSE(" segment :" << right << " -> " << rightPoint);
|
||||
leftPoint = left;
|
||||
rightPoint = right;
|
||||
}
|
||||
break;
|
||||
case esvg::render::Point::type_join:
|
||||
SVG_VERBOSE("Find join " << it.m_pos);
|
||||
ESVG_VERBOSE("Find join " << it.m_pos);
|
||||
switch (_join) {
|
||||
case esvg::join_miter:
|
||||
{
|
||||
@ -296,20 +296,20 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
||||
// Check the miter limit:
|
||||
float limitRight = (left - 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
|
||||
&& limitLeft <= _miterLimit) {
|
||||
//Draw from previous point:
|
||||
addSegment(leftPoint, left);
|
||||
SVG_VERBOSE(" segment :" << leftPoint << " -> " << left);
|
||||
ESVG_VERBOSE(" segment :" << leftPoint << " -> " << left);
|
||||
addSegment(right, rightPoint);
|
||||
SVG_VERBOSE(" segment :" << right << " -> " << rightPoint);
|
||||
ESVG_VERBOSE(" segment :" << right << " -> " << rightPoint);
|
||||
leftPoint = left;
|
||||
rightPoint = right;
|
||||
break;
|
||||
} else {
|
||||
// We do a bevel join ...
|
||||
SVG_VERBOSE(" Find miter Limit ... ==> create BEVEL");
|
||||
ESVG_VERBOSE(" Find miter Limit ... ==> create BEVEL");
|
||||
}
|
||||
}
|
||||
case esvg::join_round:
|
||||
@ -326,11 +326,11 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
||||
+ it.m_orthoAxeNext*_width*0.5f;
|
||||
//Draw from previous point:
|
||||
addSegment(leftPoint, left1);
|
||||
SVG_VERBOSE(" segment :" << leftPoint << " -> " << left1);
|
||||
ESVG_VERBOSE(" segment :" << leftPoint << " -> " << left1);
|
||||
if (_join != esvg::join_round) {
|
||||
// Miter and bevel:
|
||||
addSegment(left1, left2);
|
||||
SVG_VERBOSE(" segment :" << left1 << " -> " << left2);
|
||||
ESVG_VERBOSE(" segment :" << left1 << " -> " << left2);
|
||||
}else {
|
||||
createSegmentListStroke(left1,
|
||||
left2,
|
||||
@ -339,7 +339,7 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
||||
false);
|
||||
}
|
||||
addSegment(right, rightPoint);
|
||||
SVG_VERBOSE(" segment :" << right << " -> " << rightPoint);
|
||||
ESVG_VERBOSE(" segment :" << right << " -> " << rightPoint);
|
||||
leftPoint = left2;
|
||||
rightPoint = right;
|
||||
} else {
|
||||
@ -349,13 +349,13 @@ void esvg::render::SegmentList::createSegmentListStroke(esvg::render::PointList&
|
||||
vec2 right2 = it.m_pos
|
||||
- it.m_orthoAxeNext*_width*0.5f;//Draw from previous point:
|
||||
addSegment(leftPoint, left);
|
||||
SVG_VERBOSE(" segment :" << leftPoint << " -> " << left);
|
||||
ESVG_VERBOSE(" segment :" << leftPoint << " -> " << left);
|
||||
addSegment(right1, rightPoint);
|
||||
SVG_VERBOSE(" segment :" << right1 << " -> " << rightPoint);
|
||||
ESVG_VERBOSE(" segment :" << right1 << " -> " << rightPoint);
|
||||
if (_join != esvg::join_round) {
|
||||
// Miter and bevel:
|
||||
addSegment(right2, right1);
|
||||
SVG_VERBOSE(" segment :" << right2 << " -> " << right1);
|
||||
ESVG_VERBOSE(" segment :" << right2 << " -> " << right1);
|
||||
} else {
|
||||
createSegmentListStroke(right1,
|
||||
right2,
|
||||
@ -391,19 +391,19 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
|
||||
if (_isStart == false) {
|
||||
//Draw from previous point:
|
||||
addSegment(_leftPoint, left);
|
||||
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << left);
|
||||
ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << left);
|
||||
addSegment(right, _rightPoint);
|
||||
SVG_VERBOSE(" segment :" << right << " -> " << _rightPoint);
|
||||
ESVG_VERBOSE(" segment :" << right << " -> " << _rightPoint);
|
||||
}
|
||||
_leftPoint = left;
|
||||
_rightPoint = right;
|
||||
}
|
||||
if (_isStart == false) {
|
||||
addSegment(_leftPoint, _rightPoint);
|
||||
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint);
|
||||
ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint);
|
||||
} else {
|
||||
addSegment(_rightPoint, _leftPoint);
|
||||
SVG_VERBOSE(" segment :" << _rightPoint << " -> " << _leftPoint);
|
||||
ESVG_VERBOSE(" segment :" << _rightPoint << " -> " << _leftPoint);
|
||||
}
|
||||
break;
|
||||
case esvg::cap_round:
|
||||
@ -416,9 +416,9 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
|
||||
if (_isStart == false) {
|
||||
//Draw from previous point:
|
||||
addSegment(_leftPoint, left);
|
||||
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << left);
|
||||
ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << left);
|
||||
addSegment(right, _rightPoint);
|
||||
SVG_VERBOSE(" segment :" << right << " -> " << _rightPoint);
|
||||
ESVG_VERBOSE(" segment :" << right << " -> " << _rightPoint);
|
||||
}
|
||||
_leftPoint = left;
|
||||
_rightPoint = right;
|
||||
@ -459,25 +459,25 @@ void esvg::render::SegmentList::startStopPoint(vec2& _leftPoint,
|
||||
if (_isStart == false) {
|
||||
//Draw from previous point:
|
||||
addSegment(_leftPoint, left);
|
||||
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << left);
|
||||
ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << left);
|
||||
addSegment(right, _rightPoint);
|
||||
SVG_VERBOSE(" segment :" << right << " -> " << _rightPoint);
|
||||
ESVG_VERBOSE(" segment :" << right << " -> " << _rightPoint);
|
||||
}
|
||||
}
|
||||
_leftPoint = left;
|
||||
_rightPoint = right;
|
||||
if (_isStart == false) {
|
||||
addSegment(_leftPoint, _rightPoint);
|
||||
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint);
|
||||
ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint);
|
||||
} else {
|
||||
addSegment(_rightPoint, _leftPoint);
|
||||
SVG_VERBOSE(" segment :" << _rightPoint << " -> " << _leftPoint);
|
||||
ESVG_VERBOSE(" segment :" << _rightPoint << " -> " << _leftPoint);
|
||||
}
|
||||
SVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint);
|
||||
ESVG_VERBOSE(" segment :" << _leftPoint << " -> " << _rightPoint);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
SVG_ERROR(" Undefined CAP TYPE");
|
||||
ESVG_ERROR(" Undefined CAP TYPE");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ void esvg::render::Weight::resize(const ivec2& _size) {
|
||||
float tmp(0);
|
||||
m_data.resize(m_size.x()*m_size.y(), tmp);
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -97,7 +97,7 @@ void esvg::render::Weight::generate(ivec2 _size, int32_t _subSamplingCount, cons
|
||||
resize(_size);
|
||||
// for each lines:
|
||||
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:
|
||||
std::vector<Segment> availlableSegmentPixel;
|
||||
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) {
|
||||
continue;
|
||||
}
|
||||
SVG_VERBOSE(" Find Basic segments " << availlableSegmentPixel.size());
|
||||
ESVG_VERBOSE(" Find Basic segments " << availlableSegmentPixel.size());
|
||||
// This represent the pondaration on the subSampling
|
||||
float deltaSize = 1.0f/_subSamplingCount;
|
||||
for (int32_t kkk=0; kkk<_subSamplingCount ; ++kkk) {
|
||||
SVG_VERBOSE(" Scanline ... " << kkk << " / " << _subSamplingCount);
|
||||
ESVG_VERBOSE(" Scanline ... " << kkk << " / " << _subSamplingCount);
|
||||
Scanline scanline(_size.x());
|
||||
//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;
|
||||
@ -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) {
|
||||
continue;
|
||||
}
|
||||
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
|
||||
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;
|
||||
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:
|
||||
std::sort(listPosition.begin(), listPosition.end(), sortXPosFunction);
|
||||
// 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 (lastState != 0) {
|
||||
// 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) {
|
||||
scanline.set(xxx, 100.0);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user