[DEV] rework lib to update at exml
This commit is contained in:
parent
4c0e4fb836
commit
521843f38f
@ -5,7 +5,7 @@ import lutinTools
|
||||
def Create(target):
|
||||
myModule = lutinModule.module(__file__, 'parsersvg', 'LIBRARY')
|
||||
|
||||
myModule.AddModuleDepend(['etk', 'agg', 'tinyxml'])
|
||||
myModule.AddModuleDepend(['etk', 'agg', 'exml'])
|
||||
|
||||
myModule.AddSrcFile([
|
||||
'parserSVG/Base.cpp',
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Base.cpp
|
||||
* @brief basic Element parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
@ -27,41 +11,34 @@
|
||||
#include <parserSVG/Base.h>
|
||||
#include <math.h>
|
||||
|
||||
svg::Base::Base(PaintState parentPaintState)
|
||||
svg::Base::Base(PaintState _parentPaintState)
|
||||
{
|
||||
// copy the parent painting properties ...
|
||||
m_paint = parentPaintState;
|
||||
m_paint = _parentPaintState;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Parse the transform balise C String.
|
||||
* @param[in] inputString String data inside the transform attribute
|
||||
* @param[in,out] baseMatrice matrice that must be update
|
||||
* @return ---
|
||||
*/
|
||||
void svg::Base::ParseTransform(TiXmlNode *node)
|
||||
void svg::Base::ParseTransform(exml::Element* _element)
|
||||
{
|
||||
SVG_CHECK_INOUT(node);
|
||||
const char * inputString = (char*)node->ToElement()->Attribute("transform");
|
||||
if (NULL == inputString) {
|
||||
if (NULL == _element) {
|
||||
return;
|
||||
}
|
||||
|
||||
etk::UString inputString = _element->GetAttribute("transform");
|
||||
if (inputString.Size()==0) {
|
||||
return;
|
||||
}
|
||||
SVG_VERBOSE("find transform : \"" << inputString << "\"");
|
||||
char tmpData[2048];
|
||||
for (int32_t iii=0; inputString[iii]!='\0' && iii<2047; iii++) {
|
||||
for (int32_t iii=0; iii<inputString.Size(); iii++) {
|
||||
if (inputString[iii] == ',') {
|
||||
tmpData[iii] = ' ';
|
||||
} else {
|
||||
tmpData[iii] = inputString[iii];
|
||||
inputString[iii] = ' ';
|
||||
}
|
||||
// end of the string ...
|
||||
tmpData[iii+1] = '\0';
|
||||
}
|
||||
SVG_VERBOSE("find transform : \"" << tmpData << "\"");
|
||||
SVG_VERBOSE("find transform : \"" << inputString << "\"");
|
||||
double matrix[6];
|
||||
float angle, xxx, yyy;
|
||||
int32_t n;
|
||||
char * pointerOnData = tmpData;
|
||||
etk::Char myData = inputString.c_str();
|
||||
const char * pointerOnData = myData;
|
||||
while (*pointerOnData) {
|
||||
if (sscanf(pointerOnData, "matrix (%lf %lf %lf %lf %lf %lf) %n", &matrix[0], &matrix[1], &matrix[2], &matrix[3], &matrix[4], &matrix[5], &n) == 6) {
|
||||
m_transformMatrix.load_from(matrix);
|
||||
@ -104,262 +81,269 @@ void svg::Base::ParseTransform(TiXmlNode *node)
|
||||
|
||||
/**
|
||||
* @brief Parse x, y, width, height attribute of the xml node
|
||||
* @param[in] node XML node
|
||||
* @param[out] pos parsed position
|
||||
* @param[out] size parsed dimention
|
||||
* @return ---
|
||||
* @param[in] _element XML node
|
||||
* @param[out] _pos parsed position
|
||||
* @param[out] _size parsed dimention
|
||||
*/
|
||||
void svg::Base::ParsePosition(const TiXmlNode *node, etk::Vector2D<float> &pos, etk::Vector2D<float> &size)
|
||||
void svg::Base::ParsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size)
|
||||
{
|
||||
pos.setValue(0,0);
|
||||
size.setValue(0,0);
|
||||
|
||||
const char * content = node->ToElement()->Attribute("x");
|
||||
if (NULL != content) {
|
||||
pos.setX(ParseLength(content));
|
||||
_pos.setValue(0,0);
|
||||
_size.setValue(0,0);
|
||||
|
||||
if (NULL == _element) {
|
||||
return;
|
||||
}
|
||||
content = node->ToElement()->Attribute("y");
|
||||
if (NULL != content) {
|
||||
pos.setX(ParseLength(content));
|
||||
etk::UString content = _element->GetAttribute("x");
|
||||
if (content.Size()!=0) {
|
||||
_pos.setX(ParseLength(content));
|
||||
}
|
||||
content = node->ToElement()->Attribute("width");
|
||||
if (NULL != content) {
|
||||
size.setX(ParseLength(content));
|
||||
content = _element->GetAttribute("y");
|
||||
if (content.Size()!=0) {
|
||||
_pos.setX(ParseLength(content));
|
||||
}
|
||||
content = node->ToElement()->Attribute("height");
|
||||
if (NULL != content) {
|
||||
size.setY(ParseLength(content));
|
||||
content = _element->GetAttribute("width");
|
||||
if (content.Size()!=0) {
|
||||
_size.setX(ParseLength(content));
|
||||
}
|
||||
content = _element->GetAttribute("height");
|
||||
if (content.Size()!=0) {
|
||||
_size.setY(ParseLength(content));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parse a lenght of the xml element
|
||||
* @param[in] dataInput Data C String with the printed lenght
|
||||
* @param[in] _dataInput Data C String with the printed lenght
|
||||
* @return standart number of pixels
|
||||
*/
|
||||
float svg::Base::ParseLength(const char *dataInput)
|
||||
float svg::Base::ParseLength(const etk::UString& _dataInput)
|
||||
{
|
||||
int32_t numLength = strspn(dataInput, "0123456789+-.");
|
||||
const char *unit = dataInput + numLength;
|
||||
//SVG_INFO(" ==> \"" << dataInput << "\"");
|
||||
float n = atof(dataInput);
|
||||
float n = _dataInput.ToFloat();
|
||||
etk::UString unit;
|
||||
for (int32_t iii=0; iii<_dataInput.Size(); iii++) {
|
||||
if( (_dataInput[iii]>='0' && _dataInput[iii]<='9')
|
||||
|| _dataInput[iii]<='+'
|
||||
|| _dataInput[iii]<='-'
|
||||
|| _dataInput[iii]<='.') {
|
||||
continue;
|
||||
}
|
||||
unit = _dataInput.Extract(iii);
|
||||
}
|
||||
//SVG_INFO(" ==> ?? = " << n );
|
||||
float font_size = 20.0;
|
||||
float font_size = 20.0f;
|
||||
|
||||
// note : ";" is for the parsing of the style elements ...
|
||||
if (unit[0] == '\0' || unit[0] == ';' ) {
|
||||
if( unit.Size()==0
|
||||
|| unit[0] == ';' ) {
|
||||
return n;
|
||||
} else if (unit[0] == '%') { // xxx %
|
||||
return n / 100.0 * m_paint.viewPort.x();
|
||||
} else if (unit[0] == 'e' && unit[1] == 'm') { // xxx em
|
||||
return n * font_size;
|
||||
} else if (unit[0] == 'e' && unit[1] == 'x') { // xxx ex
|
||||
return n / 2.0 * font_size;
|
||||
return n / 2.0f * font_size;
|
||||
} else if (unit[0] == 'p' && unit[1] == 'x') { // xxx px
|
||||
return n;
|
||||
} else if (unit[0] == 'p' && unit[1] == 't') { // xxx pt
|
||||
return n * 1.25;
|
||||
return n * 1.25f;
|
||||
} else if (unit[0] == 'p' && unit[1] == 'c') { // xxx pc
|
||||
return n * 15.0;
|
||||
return n * 15.0f;
|
||||
} else if (unit[0] == 'm' && unit[1] == 'm') { // xxx mm
|
||||
return n * 3.543307;
|
||||
return n * 3.543307f;
|
||||
} else if (unit[0] == 'c' && unit[1] == 'm') { // xxx cm
|
||||
return n * 35.43307;
|
||||
return n * 35.43307f;
|
||||
} else if (unit[0] == 'i' && unit[1] == 'n') { // xxx in
|
||||
return n * 90;
|
||||
return n * 90.0f;
|
||||
}
|
||||
return 0;
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
// return the next char position ... (after ';' or NULL)
|
||||
const char * extractPartOfStyle(const char * input, char * outputType, char * outputData, int32_t maxLen)
|
||||
int32_t extractPartOfStyle(const etk::UString& _data, etk::UString& _outputType, etk::UString& _outputData, int32_t _pos)
|
||||
{
|
||||
if (*input == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
int32_t jjj = 0;
|
||||
const char * outputPointer = NULL;
|
||||
outputType[maxLen-1] = '\0';
|
||||
outputType[0] = '\0';
|
||||
outputData[maxLen-1] = '\0';
|
||||
outputData[0] = '\0';
|
||||
char * output = outputType;
|
||||
for( int32_t iii=0; iii<maxLen-1 && input[iii]!='\0'; iii++) {
|
||||
outputPointer = &input[iii];
|
||||
if (input[iii] != ';') {
|
||||
if (input[iii] == ' ') {
|
||||
// nothing to do ... we do not copy espaces ...
|
||||
} else if (input[iii] == ':') {
|
||||
// change the output ...
|
||||
output = outputData;
|
||||
jjj = 0;
|
||||
} else {
|
||||
output[jjj] = input[iii];
|
||||
output[jjj+1] = '\0';
|
||||
jjj++;
|
||||
}
|
||||
_outputType = "";
|
||||
_outputData = "";
|
||||
int32_t typeStart = _pos;
|
||||
int32_t typeStop = _pos;
|
||||
int32_t dataStart = _pos;
|
||||
int32_t dataStop = _pos;
|
||||
bool processFirst=true;
|
||||
for( int32_t iii=_pos; iii<_data.Size(); iii++) {
|
||||
if (_data[iii] == ';') {
|
||||
// end of the element
|
||||
return iii+1;
|
||||
}
|
||||
if (_data[iii] == ' ') {
|
||||
// nothing to do ... we do not copy espaces ...
|
||||
} else if (_data[iii] == ':') {
|
||||
processFirst = false;
|
||||
} else {
|
||||
break;
|
||||
if (processFirst) {
|
||||
_outputType += _data[iii];
|
||||
} else {
|
||||
_outputData += _data[iii];
|
||||
}
|
||||
}
|
||||
}
|
||||
outputPointer++;
|
||||
return outputPointer;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Parse a Painting attribute of a specific node
|
||||
* @param[in] node : basic node of the XML that might be parsed
|
||||
* @return ---
|
||||
* @param[in] _element Basic node of the XML that might be parsed
|
||||
*/
|
||||
void svg::Base::ParsePaintAttr(const TiXmlNode *node)
|
||||
void svg::Base::ParsePaintAttr(const exml::Element *_element)
|
||||
{
|
||||
if (_element==NULL) {
|
||||
return;
|
||||
}
|
||||
bool fillNone = false;
|
||||
bool strokeNone = false;
|
||||
const char * content = node->ToElement()->Attribute("fill");
|
||||
if (NULL != content) {
|
||||
etk::UString content = _element->GetAttribute("fill");
|
||||
if (content.Size()!=0) {
|
||||
m_paint.fill = ParseColor(content);
|
||||
if (m_paint.fill.a == 0) {
|
||||
fillNone = true;
|
||||
}
|
||||
}
|
||||
content = node->ToElement()->Attribute("stroke");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("stroke");
|
||||
if (content.Size()!=0) {
|
||||
m_paint.stroke = ParseColor(content);
|
||||
if (m_paint.stroke.a == 0) {
|
||||
strokeNone = true;
|
||||
}
|
||||
}
|
||||
content = node->ToElement()->Attribute("stroke-width");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("stroke-width");
|
||||
if (content.Size()!=0) {
|
||||
m_paint.strokeWidth = ParseLength(content);
|
||||
}
|
||||
content = node->ToElement()->Attribute("opacity");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("opacity");
|
||||
if (content.Size()!=0) {
|
||||
float opacity = ParseLength(content);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.fill.a = opacity*0xFF;
|
||||
m_paint.stroke.a = opacity*0xFF;
|
||||
}
|
||||
content = node->ToElement()->Attribute("fill-opacity");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("fill-opacity");
|
||||
if (content.Size()!=0) {
|
||||
float opacity = ParseLength(content);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.fill.a = opacity*0xFF;
|
||||
}
|
||||
content = node->ToElement()->Attribute("stroke-opacity");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("stroke-opacity");
|
||||
if (content.Size()!=0) {
|
||||
float opacity = ParseLength(content);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.stroke.a = opacity*0xFF;
|
||||
}
|
||||
content = node->ToElement()->Attribute("fill-rule");
|
||||
if (NULL != content) {
|
||||
if (0 == strcmp(content, "nonzero") ) {
|
||||
content = _element->GetAttribute("fill-rule");
|
||||
if (content.Size()!=0) {
|
||||
if (content == "nonzero") {
|
||||
m_paint.flagEvenOdd = false;
|
||||
} else if (0 == strcmp(content, "evenodd") ) {
|
||||
} else if (content == "evenodd" ) {
|
||||
m_paint.flagEvenOdd = true;
|
||||
} else {
|
||||
SVG_ERROR("not know fill-rule value : \"" << content << "\", not in [nonzero,evenodd]");
|
||||
}
|
||||
}
|
||||
content = node->ToElement()->Attribute("stroke-linecap");
|
||||
if (NULL != content) {
|
||||
if (0 == strcmp(content, "butt") ) {
|
||||
content = _element->GetAttribute("stroke-linecap");
|
||||
if (content.Size()!=0) {
|
||||
if (content == "butt" ) {
|
||||
m_paint.lineCap = svg::LINECAP_BUTT;
|
||||
} else if (0 == strcmp(content, "round") ) {
|
||||
} else if (content == "round" ) {
|
||||
m_paint.lineCap = svg::LINECAP_ROUND;
|
||||
} else if (0 == strcmp(content, "square") ) {
|
||||
} else if (content == "square" ) {
|
||||
m_paint.lineCap = svg::LINECAP_SQUARE;
|
||||
} else {
|
||||
m_paint.lineCap = svg::LINECAP_BUTT;
|
||||
SVG_ERROR("not know stroke-linecap value : \"" << content << "\", not in [butt,round,square]");
|
||||
}
|
||||
}
|
||||
content = node->ToElement()->Attribute("stroke-linejoin");
|
||||
if (NULL != content) {
|
||||
if (0 == strcmp(content, "miter") ) {
|
||||
content = _element->GetAttribute("stroke-linejoin");
|
||||
if (content.Size()!=0) {
|
||||
if (content == "miter" ) {
|
||||
m_paint.lineJoin = svg::LINEJOIN_MITER;
|
||||
} else if (0 == strcmp(content, "round") ) {
|
||||
} else if (content == "round" ) {
|
||||
m_paint.lineJoin = svg::LINEJOIN_ROUND;
|
||||
} else if (0 == strcmp(content, "bevel") ) {
|
||||
} else if (content == "bevel" ) {
|
||||
m_paint.lineJoin = svg::LINEJOIN_BEVEL;
|
||||
} else {
|
||||
m_paint.lineJoin = svg::LINEJOIN_MITER;
|
||||
SVG_ERROR("not know stroke-linejoin value : \"" << content << "\", not in [miter,round,bevel]");
|
||||
}
|
||||
}
|
||||
content = node->ToElement()->Attribute("style");
|
||||
if (NULL != content) {
|
||||
char outputType[1024] = "";
|
||||
char outputValue[1024] = "";
|
||||
content = _element->GetAttribute("style");
|
||||
if (content.Size()!=0) {
|
||||
etk::UString outputType;
|
||||
etk::UString outputValue;
|
||||
|
||||
for( const char *sss=extractPartOfStyle(content, outputType, outputValue, 1024);
|
||||
NULL != sss;
|
||||
sss=extractPartOfStyle(sss, outputType, outputValue, 1024) ) {
|
||||
for( int32_t sss=extractPartOfStyle(content, outputType, outputValue, 1024);
|
||||
-1 != sss;
|
||||
sss=extractPartOfStyle(content, outputType, outputValue, sss) ) {
|
||||
SVG_VERBOSE(" style parse : \"" << outputType << "\" with value : \"" << outputValue << "\"");
|
||||
if (0 == strcmp(outputType, "fill") ) {
|
||||
if (outputType == "fill") {
|
||||
m_paint.fill = ParseColor(outputValue);
|
||||
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.fill);
|
||||
if (m_paint.fill.a == 0) {
|
||||
fillNone = true;
|
||||
}
|
||||
} else if (0 == strcmp(outputType, "stroke") ) {
|
||||
} else if (outputType == "stroke") {
|
||||
m_paint.stroke = ParseColor(outputValue);
|
||||
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.stroke);
|
||||
if (m_paint.stroke.a == 0) {
|
||||
strokeNone = true;
|
||||
}
|
||||
} else if (0 == strcmp(outputType, "stroke-width") ) {
|
||||
} else if (outputType == "stroke-width" ) {
|
||||
m_paint.strokeWidth = ParseLength(outputValue);
|
||||
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.strokeWidth);
|
||||
} else if (0 == strcmp(outputType, "opacity") ) {
|
||||
} else if (outputType == "opacity" ) {
|
||||
float opacity = ParseLength(outputValue);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.fill.a = opacity*0xFF;
|
||||
m_paint.stroke.a = opacity*0xFF;
|
||||
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.fill);
|
||||
} else if (0 == strcmp(outputType, "fill-opacity") ) {
|
||||
} else if (outputType == "fill-opacity") {
|
||||
float opacity = ParseLength(outputValue);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.fill.a = opacity*0xFF;
|
||||
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.fill);
|
||||
} else if (0 == strcmp(outputType, "stroke-opacity") ) {
|
||||
} else if (outputType == "stroke-opacity") {
|
||||
float opacity = ParseLength(outputValue);
|
||||
opacity = etk_max(0.0, etk_min(1.0, opacity));
|
||||
m_paint.stroke.a = opacity*0xFF;
|
||||
SVG_VERBOSE(" input : \"" << outputValue << "\" ==> " << m_paint.stroke);
|
||||
} else if (0 == strcmp(outputType, "fill-rule") ) {
|
||||
if (0 == strcmp(outputValue, "nonzero") ) {
|
||||
} else if (outputType == "fill-rule" ) {
|
||||
if (outputValue == "nonzero" ) {
|
||||
m_paint.flagEvenOdd = false;
|
||||
} else if (0 == strcmp(outputValue, "evenodd") ) {
|
||||
} else if (outputValue == "evenodd") {
|
||||
m_paint.flagEvenOdd = true;
|
||||
} else {
|
||||
SVG_ERROR("not know " << outputType << " value : \"" << outputValue << "\", not in [nonzero,evenodd]");
|
||||
}
|
||||
} else if (0 == strcmp(outputType, "stroke-linecap") ) {
|
||||
if (0 == strcmp(outputValue, "butt") ) {
|
||||
} else if (outputType == "stroke-linecap") {
|
||||
if (outputValue == "butt") {
|
||||
m_paint.lineCap = svg::LINECAP_BUTT;
|
||||
} else if (0 == strcmp(outputValue, "round") ) {
|
||||
} else if (outputValue == "round") {
|
||||
m_paint.lineCap = svg::LINECAP_ROUND;
|
||||
} else if (0 == strcmp(outputValue, "square") ) {
|
||||
} else if (outputValue == "square") {
|
||||
m_paint.lineCap = svg::LINECAP_SQUARE;
|
||||
} else {
|
||||
m_paint.lineCap = svg::LINECAP_BUTT;
|
||||
SVG_ERROR("not know " << outputType << " value : \"" << outputValue << "\", not in [butt,round,square]");
|
||||
}
|
||||
} else if (0 == strcmp(outputType, "stroke-linejoin") ) {
|
||||
if (0 == strcmp(outputValue, "miter") ) {
|
||||
} else if (outputType == "stroke-linejoin") {
|
||||
if (outputValue == "miter") {
|
||||
m_paint.lineJoin = svg::LINEJOIN_MITER;
|
||||
} else if (0 == strcmp(outputValue, "round") ) {
|
||||
} else if (outputValue == "round") {
|
||||
m_paint.lineJoin = svg::LINEJOIN_ROUND;
|
||||
} else if (0 == strcmp(outputValue, "bevel") ) {
|
||||
} else if (outputValue == "bevel") {
|
||||
m_paint.lineJoin = svg::LINEJOIN_BEVEL;
|
||||
} else {
|
||||
m_paint.lineJoin = svg::LINEJOIN_MITER;
|
||||
SVG_ERROR("not know " << outputType << " value : \"" << outputValue << "\", not in [miter,round,bevel]");
|
||||
}
|
||||
} else if (0 == strcmp(outputType, "marker-start") ) {
|
||||
} else if (outputType == "marker-start") {
|
||||
// TODO : ...
|
||||
} else {
|
||||
SVG_ERROR("not know painting element in style balise : \"" << outputType << "\" with value : \"" << outputValue << "\"");
|
||||
@ -375,92 +359,51 @@ void svg::Base::ParsePaintAttr(const TiXmlNode *node)
|
||||
}
|
||||
}
|
||||
|
||||
bool strnCmpNoCase(const char * input1, const char * input2, int32_t maxLen)
|
||||
{
|
||||
int32_t iii=0;
|
||||
while ('\0' != *input1 && '\0' != *input2 && iii < maxLen) {
|
||||
char in1 = *input1;
|
||||
char in2 = *input2;
|
||||
if (in1 != in2) {
|
||||
if (in1 <= 'Z' && in1 >= 'A') {
|
||||
in1 = in1 - 'A' + 'a';
|
||||
}
|
||||
if (in2 <= 'Z' && in2 >= 'A') {
|
||||
in2 = in2 - 'A' + 'a';
|
||||
}
|
||||
if (in1 != in2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
iii++;
|
||||
input1++;
|
||||
input2++;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parse a color specification from the svg file
|
||||
* @param[in] inputData Data C String with the xml definition
|
||||
* @param[in] _inputData Data C String with the xml definition
|
||||
* @return the parsed color
|
||||
*/
|
||||
draw::Color svg::Base::ParseColor(const char *inputData)
|
||||
draw::Color svg::Base::ParseColor(const etk::UString& _inputData)
|
||||
{
|
||||
draw::Color localColor = draw::color::white;
|
||||
|
||||
size_t len = strlen(inputData);
|
||||
|
||||
if( 4 < len
|
||||
&& inputData[0] == 'u'
|
||||
&& inputData[1] == 'r'
|
||||
&& inputData[2] == 'l'
|
||||
&& inputData[3] == '(') {
|
||||
if (inputData[4] == '#') {
|
||||
if( _inputData.Size() > 4
|
||||
&& _inputData[0] == 'u'
|
||||
&& _inputData[1] == 'r'
|
||||
&& _inputData[2] == 'l'
|
||||
&& _inputData[3] == '(') {
|
||||
if (_inputData[4] == '#') {
|
||||
// TODO : parse gradient ...
|
||||
}
|
||||
SVG_ERROR(" pb in parsing the color : \"" << inputData << "\" ==> url(XXX) is not supported now ...");
|
||||
SVG_ERROR(" pb in parsing the color : \"" << _inputData << "\" ==> url(XXX) is not supported now ...");
|
||||
} else {
|
||||
localColor = inputData;
|
||||
localColor = _inputData.c_str();
|
||||
}
|
||||
SVG_VERBOSE("Parse color : \"" << inputData << "\" ==> " << localColor);
|
||||
SVG_INFO("Parse color : \"" << _inputData << "\" ==> " << localColor);
|
||||
return localColor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Parse all the element needed in the basic node
|
||||
* @param[in] node standart XML node
|
||||
* @param[in] _element standart XML node
|
||||
* @return true if no problem arrived
|
||||
*/
|
||||
bool svg::Base::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax)
|
||||
bool svg::Base::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
||||
{
|
||||
SVG_ERROR("NOT IMPLEMENTED");
|
||||
sizeMax.setValue(0,0);
|
||||
_sizeMax.setValue(0,0);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const char * svg::Base::SpacingDist(int32_t spacing)
|
||||
const char * svg::Base::SpacingDist(int32_t _spacing)
|
||||
{
|
||||
static const char *tmpValue = " ";
|
||||
if (spacing>20) {
|
||||
spacing = 20;
|
||||
if (_spacing>20) {
|
||||
_spacing = 20;
|
||||
}
|
||||
return tmpValue + 20*4 - spacing*4;
|
||||
return tmpValue + 20*4 - _spacing*4;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
void svg::Base::AggCheckChange(agg::path_storage& path, etk::Vector<agg::rgba8> &colors, etk::Vector<uint32_t> &pathIdx, PaintState &curentPaintProp)
|
||||
{
|
||||
if (curentPaintProp != m_paint) {
|
||||
SVG_INFO("add path color = " << m_paint.fill);
|
||||
// New color. Every new color creates new path in the path object.
|
||||
colors.PushBack(agg::rgba8(m_paint.fill.red, m_paint.fill.green, m_paint.fill.blue, m_paint.fill.a));
|
||||
uint32_t tmpPathNew = path.start_new_path();
|
||||
pathIdx.PushBack(tmpPathNew);
|
||||
curentPaintProp = m_paint;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Base.h
|
||||
* @brief basic Element parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_BASE_H__
|
||||
@ -30,7 +14,7 @@
|
||||
#include <etk/math/Vector2D.h>
|
||||
#include <draw/Color.h>
|
||||
|
||||
#include <tinyXML/tinyxml.h>
|
||||
#include <exml/exml.h>
|
||||
#include <parserSVG/Renderer.h>
|
||||
|
||||
#include <agg/agg_basics.h>
|
||||
@ -51,21 +35,21 @@ namespace svg
|
||||
protected:
|
||||
PaintState m_paint;
|
||||
agg::trans_affine m_transformMatrix; //!< specific render of the curent element
|
||||
const char * SpacingDist(int32_t spacing);
|
||||
const char * SpacingDist(int32_t _spacing);
|
||||
public:
|
||||
Base(void) {};
|
||||
Base(PaintState parentPaintState);
|
||||
Base(PaintState _parentPaintState);
|
||||
virtual ~Base(void) { };
|
||||
virtual bool Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
//specific drawing for AAG librairy ...
|
||||
virtual void AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans) { };
|
||||
virtual void AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans) { };
|
||||
|
||||
virtual void Display(int32_t spacing) { };
|
||||
void ParseTransform(TiXmlNode *node);
|
||||
void ParsePosition(const TiXmlNode *node, etk::Vector2D<float> &pos, etk::Vector2D<float> &size);
|
||||
float ParseLength(const char *dataInput);
|
||||
void ParsePaintAttr(const TiXmlNode *node);
|
||||
draw::Color ParseColor(const char *inputData);
|
||||
virtual void Display(int32_t _spacing) { };
|
||||
void ParseTransform(exml::Element *_element);
|
||||
void ParsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size);
|
||||
float ParseLength(const etk::UString& _dataInput);
|
||||
void ParsePaintAttr(const exml::Element *_element);
|
||||
draw::Color ParseColor(const etk::UString& _inputData);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Circle.cpp
|
||||
* @brief basic circle parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
@ -28,7 +12,7 @@
|
||||
#include <agg/agg_ellipse.h>
|
||||
|
||||
|
||||
svg::Circle::Circle(PaintState parentPaintState) : svg::Base(parentPaintState)
|
||||
svg::Circle::Circle(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
||||
{
|
||||
|
||||
}
|
||||
@ -38,76 +22,79 @@ svg::Circle::~Circle(void)
|
||||
|
||||
}
|
||||
|
||||
bool svg::Circle::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax)
|
||||
bool svg::Circle::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
||||
{
|
||||
m_radius = 0.0;
|
||||
m_position.setValue(0,0);;
|
||||
ParseTransform(node);
|
||||
ParsePaintAttr(node);
|
||||
m_position.setValue(0,0);
|
||||
if (NULL==_element) {
|
||||
return false;
|
||||
}
|
||||
ParseTransform(_element);
|
||||
ParsePaintAttr(_element);
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= parentTrans;
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
const char * content = node->ToElement()->Attribute("cx");
|
||||
if (NULL != content) {
|
||||
etk::UString content = _element->GetAttribute("cx");
|
||||
if (content.Size()!=0) {
|
||||
m_position.setX(ParseLength(content));
|
||||
}
|
||||
content = node->ToElement()->Attribute("cy");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("cy");
|
||||
if (content.Size()!=0) {
|
||||
m_position.setY(ParseLength(content));
|
||||
}
|
||||
content = node->ToElement()->Attribute("r");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("r");
|
||||
if (content.Size()!=0) {
|
||||
m_radius = ParseLength(content);
|
||||
} else {
|
||||
SVG_ERROR("(l "<<node->Row()<<") Circle \"r\" is not present");
|
||||
SVG_ERROR("(l "<<_element->Pos()<<") Circle \"r\" is not present");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (0 > m_radius) {
|
||||
m_radius = 0;
|
||||
SVG_ERROR("(l "<<node->Row()<<") Circle \"r\" is negative");
|
||||
SVG_ERROR("(l "<<_element->Pos()<<") Circle \"r\" is negative");
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
void svg::Circle::Display(int32_t spacing)
|
||||
void svg::Circle::Display(int32_t _spacing)
|
||||
{
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Circle " << m_position << " radius=" << m_radius);
|
||||
SVG_DEBUG(SpacingDist(_spacing) << "Circle " << m_position << " radius=" << m_radius);
|
||||
}
|
||||
|
||||
|
||||
void svg::Circle::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans)
|
||||
void svg::Circle::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
|
||||
{
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.fill.r, m_paint.fill.g, m_paint.fill.b, m_paint.fill.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.fill.r, m_paint.fill.g, m_paint.fill.b, m_paint.fill.a));
|
||||
// Creating an ellipse
|
||||
agg::ellipse myCircle(m_position.x(), m_position.y(), m_radius, m_radius, 0);
|
||||
|
||||
// Calculate transformation matrix ...
|
||||
agg::trans_affine mtx = m_transformMatrix;
|
||||
mtx *= basicTrans;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule((m_paint.flagEvenOdd)?agg::fill_even_odd:agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.filling_rule((m_paint.flagEvenOdd)?agg::fill_even_odd:agg::fill_non_zero);
|
||||
|
||||
if (m_paint.fill.a != 0x00) {
|
||||
agg::conv_transform<agg::ellipse, agg::trans_affine> trans(myCircle, mtx);
|
||||
myRenderer.m_rasterizer.add_path(trans);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.add_path(trans);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
|
||||
|
||||
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
// Drawing as an outline
|
||||
agg::conv_stroke<agg::ellipse> myCircleStroke(myCircle);
|
||||
myCircleStroke.width(m_paint.strokeWidth);
|
||||
agg::conv_transform<agg::conv_stroke<agg::ellipse>, agg::trans_affine> transStroke(myCircleStroke, mtx);
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Circle.h
|
||||
* @brief basic circle parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_CIRCLE_H__
|
||||
@ -32,14 +16,14 @@ namespace svg
|
||||
class Circle : public svg::Base
|
||||
{
|
||||
private:
|
||||
etk::Vector2D<float> m_position; //!< Position of the Circle
|
||||
float m_radius; //!< Radius of the Circle
|
||||
etk::Vector2D<float> m_position; //!< Position of the Circle
|
||||
float m_radius; //!< Radius of the Circle
|
||||
public:
|
||||
Circle(PaintState parentPaintState);
|
||||
Circle(PaintState _parentPaintState);
|
||||
~Circle(void);
|
||||
virtual bool Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual void Display(int32_t spacing);
|
||||
virtual void AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void Display(int32_t _spacing);
|
||||
virtual void AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Debug.h
|
||||
* @brief parserSVG : log wrapper (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 18/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file tinySVG/Debug.h
|
||||
* @brief SVG : log wrapper (header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 18/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __PARSER_SVG_DEBUG_H__
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Ellipse.cpp
|
||||
* @brief basic ellipse parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
@ -37,79 +21,82 @@ svg::Ellipse::~Ellipse(void)
|
||||
|
||||
}
|
||||
|
||||
bool svg::Ellipse::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax)
|
||||
bool svg::Ellipse::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
||||
{
|
||||
ParseTransform(node);
|
||||
ParsePaintAttr(node);
|
||||
if (NULL==_element) {
|
||||
return false;
|
||||
}
|
||||
ParseTransform(_element);
|
||||
ParsePaintAttr(_element);
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= parentTrans;
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
m_c.setValue(0,0);
|
||||
m_r.setValue(0,0);
|
||||
|
||||
const char * content = node->ToElement()->Attribute("cx");
|
||||
if (NULL != content) {
|
||||
etk::UString content = _element->GetAttribute("cx");
|
||||
if (content.Size()!=0) {
|
||||
m_c.setX(ParseLength(content));
|
||||
}
|
||||
content = node->ToElement()->Attribute("cy");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("cy");
|
||||
if (content.Size()!=0) {
|
||||
m_c.setY(ParseLength(content));
|
||||
}
|
||||
content = node->ToElement()->Attribute("rx");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("rx");
|
||||
if (content.Size()!=0) {
|
||||
m_r.setX(ParseLength(content));
|
||||
} else {
|
||||
SVG_ERROR("(l "<<node->Row()<<") Ellipse \"rx\" is not present");
|
||||
SVG_ERROR("(l "<<_element->Pos()<<") Ellipse \"rx\" is not present");
|
||||
return false;
|
||||
}
|
||||
content = node->ToElement()->Attribute("ry");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("ry");
|
||||
if (content.Size()!=0) {
|
||||
m_r.setY(ParseLength(content));
|
||||
} else {
|
||||
SVG_ERROR("(l "<<node->Row()<<") Ellipse \"ry\" is not present");
|
||||
SVG_ERROR("(l "<<_element->Pos()<<") Ellipse \"ry\" is not present");
|
||||
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());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void svg::Ellipse::Display(int32_t spacing)
|
||||
void svg::Ellipse::Display(int32_t _spacing)
|
||||
{
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Ellipse c=" << m_c << " r=" << m_r);
|
||||
SVG_DEBUG(SpacingDist(_spacing) << "Ellipse c=" << m_c << " r=" << m_r);
|
||||
}
|
||||
|
||||
|
||||
void svg::Ellipse::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans)
|
||||
void svg::Ellipse::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
|
||||
{
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.fill.r, m_paint.fill.g, m_paint.fill.b, m_paint.fill.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.fill.r, m_paint.fill.g, m_paint.fill.b, m_paint.fill.a));
|
||||
// Creating an ellipse
|
||||
agg::ellipse myEllipse(m_c.x(), m_c.y(), m_r.x(), m_r.y(), 0);
|
||||
|
||||
// Calculate transformation matrix ...
|
||||
agg::trans_affine mtx = m_transformMatrix;
|
||||
mtx *= basicTrans;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule((m_paint.flagEvenOdd)?agg::fill_even_odd:agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.filling_rule((m_paint.flagEvenOdd)?agg::fill_even_odd:agg::fill_non_zero);
|
||||
|
||||
if (m_paint.fill.a != 0x00) {
|
||||
agg::conv_transform<agg::ellipse, agg::trans_affine> trans(myEllipse, mtx);
|
||||
myRenderer.m_rasterizer.add_path(trans);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.add_path(trans);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
|
||||
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
// Drawing as an outline
|
||||
agg::conv_stroke<agg::ellipse> myEllipseStroke(myEllipse);
|
||||
myEllipseStroke.width(m_paint.strokeWidth);
|
||||
agg::conv_transform<agg::conv_stroke<agg::ellipse>, agg::trans_affine> transStroke(myEllipseStroke, mtx);
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Ellipse.h
|
||||
* @brief basic ellipse parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_ELLIPSE_H__
|
||||
@ -35,11 +19,11 @@ namespace svg
|
||||
etk::Vector2D<float> m_c; //!< Center property of the ellipse
|
||||
etk::Vector2D<float> m_r; //!< Radius property of the ellipse
|
||||
public:
|
||||
Ellipse(PaintState parentPaintState);
|
||||
Ellipse(PaintState _parentPaintState);
|
||||
~Ellipse(void);
|
||||
virtual bool Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual void Display(int32_t spacing);
|
||||
virtual void AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void Display(int32_t _spacing);
|
||||
virtual void AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Group.cpp
|
||||
* @brief Basic Group parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 21/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
@ -36,7 +20,7 @@
|
||||
#include <parserSVG/Text.h>
|
||||
#include <parserSVG/Group.h>
|
||||
|
||||
svg::Group::Group(PaintState parentPaintState) : svg::Base(parentPaintState)
|
||||
svg::Group::Group(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
||||
{
|
||||
|
||||
}
|
||||
@ -46,88 +30,94 @@ svg::Group::~Group(void)
|
||||
|
||||
}
|
||||
|
||||
bool svg::Group::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax)
|
||||
bool svg::Group::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
||||
{
|
||||
if (NULL==_element) {
|
||||
return false;
|
||||
}
|
||||
// parse ...
|
||||
etk::Vector2D<float> pos(0,0);
|
||||
etk::Vector2D<float> size(0,0);
|
||||
ParseTransform(node);
|
||||
ParsePosition(node, pos, size);
|
||||
ParsePaintAttr(node);
|
||||
ParseTransform(_element);
|
||||
ParsePosition(_element, pos, size);
|
||||
ParsePaintAttr(_element);
|
||||
SVG_VERBOSE("parsed G1. trans : (" << m_transformMatrix.sx << "," << m_transformMatrix.shy << "," << m_transformMatrix.shx << "," << m_transformMatrix.sy << "," << m_transformMatrix.tx << "," << m_transformMatrix.ty << ")");
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= parentTrans;
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
SVG_VERBOSE("parsed G2. trans : (" << m_transformMatrix.sx << "," << m_transformMatrix.shy << "," << m_transformMatrix.shx << "," << m_transformMatrix.sy << "," << m_transformMatrix.tx << "," << m_transformMatrix.ty << ")");
|
||||
|
||||
sizeMax.setValue(0,0);
|
||||
_sizeMax.setValue(0,0);
|
||||
vec2 tmpPos(0,0);
|
||||
// parse all sub node :
|
||||
for(TiXmlNode * child = node->FirstChild(); NULL != child; child = child->NextSibling() ) {
|
||||
svg::Base *elementParser = NULL;
|
||||
if (child->Type()==TiXmlNode::TINYXML_COMMENT) {
|
||||
for(int32_t iii=0; iii<_element->Size() ; iii++) {
|
||||
exml::Node* child = _element->Get(iii);
|
||||
if (NULL == child) {
|
||||
continue;
|
||||
}
|
||||
if (!child->IsElement()) {
|
||||
// nothing to do, just proceed to next step
|
||||
continue;
|
||||
}
|
||||
svg::Base *elementParser = NULL;
|
||||
if (child->GetValue() == "g") {
|
||||
elementParser = new svg::Group(m_paint);
|
||||
} else if (child->GetValue() == "a") {
|
||||
// TODO ...
|
||||
} else if (child->GetValue() == "path") {
|
||||
elementParser = new svg::Path(m_paint);
|
||||
} else if (child->GetValue() == "rect") {
|
||||
elementParser = new svg::Rectangle(m_paint);
|
||||
} else if (child->GetValue() == "circle") {
|
||||
elementParser = new svg::Circle(m_paint);
|
||||
} else if (child->GetValue() == "ellipse") {
|
||||
elementParser = new svg::Ellipse(m_paint);
|
||||
} else if (child->GetValue() == "line") {
|
||||
elementParser = new svg::Line(m_paint);
|
||||
} else if (child->GetValue() == "polyline") {
|
||||
elementParser = new svg::Polyline(m_paint);
|
||||
} else if (child->GetValue() == "polygon") {
|
||||
elementParser = new svg::Polygon(m_paint);
|
||||
} else if (child->GetValue() == "text") {
|
||||
elementParser = new svg::Text(m_paint);
|
||||
} else {
|
||||
etk::UString localValue = child->Value();
|
||||
if (localValue == "g") {
|
||||
elementParser = new svg::Group(m_paint);
|
||||
} else if (localValue == "a") {
|
||||
// TODO ...
|
||||
} else if (localValue == "path") {
|
||||
elementParser = new svg::Path(m_paint);
|
||||
} else if (localValue == "rect") {
|
||||
elementParser = new svg::Rectangle(m_paint);
|
||||
} else if (localValue == "circle") {
|
||||
elementParser = new svg::Circle(m_paint);
|
||||
} else if (localValue == "ellipse") {
|
||||
elementParser = new svg::Ellipse(m_paint);
|
||||
} else if (localValue == "line") {
|
||||
elementParser = new svg::Line(m_paint);
|
||||
} else if (localValue == "polyline") {
|
||||
elementParser = new svg::Polyline(m_paint);
|
||||
} else if (localValue == "polygon") {
|
||||
elementParser = new svg::Polygon(m_paint);
|
||||
} else if (localValue == "text") {
|
||||
elementParser = new svg::Text(m_paint);
|
||||
SVG_ERROR("(l "<<child->Pos()<<") node not suported : \""<<child->GetValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
|
||||
}
|
||||
if (NULL == elementParser) {
|
||||
SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ...");
|
||||
} else {
|
||||
if (false == elementParser->Parse((exml::Element*)child, m_transformMatrix, tmpPos)) {
|
||||
SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR");
|
||||
delete(elementParser);
|
||||
elementParser = NULL;
|
||||
} else {
|
||||
SVG_ERROR("(l "<<child->Row()<<") node not suported : \""<<localValue<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
|
||||
}
|
||||
if (NULL == elementParser) {
|
||||
SVG_ERROR("(l "<<child->Row()<<") error on node: \""<<localValue<<"\" allocation error or not supported ...");
|
||||
} else {
|
||||
if (false == elementParser->Parse(child, m_transformMatrix, tmpPos)) {
|
||||
SVG_ERROR("(l "<<child->Row()<<") error on node: \""<<localValue<<"\" Sub Parsing ERROR");
|
||||
delete(elementParser);
|
||||
elementParser = NULL;
|
||||
} else {
|
||||
sizeMax.setValue(etk_max(sizeMax.x(), tmpPos.x()),
|
||||
etk_max(sizeMax.y(), tmpPos.y()));
|
||||
// add element in the system
|
||||
m_subElementList.PushBack(elementParser);
|
||||
}
|
||||
_sizeMax.setValue(etk_max(_sizeMax.x(), tmpPos.x()),
|
||||
etk_max(_sizeMax.y(), tmpPos.y()));
|
||||
// add element in the system
|
||||
m_subElementList.PushBack(elementParser);
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void svg::Group::Display(int32_t spacing)
|
||||
void svg::Group::Display(int32_t _spacing)
|
||||
{
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Group (START) fill=" << m_paint.fill << " stroke=" << m_paint.stroke << " stroke-width=" << m_paint.strokeWidth );
|
||||
SVG_DEBUG(SpacingDist(_spacing) << "Group (START) fill=" << m_paint.fill << " stroke=" << m_paint.stroke << " stroke-width=" << m_paint.strokeWidth );
|
||||
for (int32_t iii=0; iii<m_subElementList.Size(); iii++) {
|
||||
if (NULL != m_subElementList[iii]) {
|
||||
m_subElementList[iii]->Display(spacing+1);
|
||||
m_subElementList[iii]->Display(_spacing+1);
|
||||
}
|
||||
}
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Group (STOP)");
|
||||
SVG_DEBUG(SpacingDist(_spacing) << "Group (STOP)");
|
||||
}
|
||||
|
||||
void svg::Group::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans)
|
||||
void svg::Group::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
|
||||
{
|
||||
for (int32_t iii=0; iii<m_subElementList.Size(); iii++) {
|
||||
if (NULL != m_subElementList[iii]) {
|
||||
m_subElementList[iii]->AggDraw(myRenderer, basicTrans);
|
||||
m_subElementList[iii]->AggDraw(_myRenderer, _basicTrans);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Group.h
|
||||
* @brief basic group parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 21/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_GROUP_H__
|
||||
@ -35,11 +19,11 @@ namespace svg
|
||||
private:
|
||||
etk::Vector<svg::Base *> m_subElementList; //!< group sub elements ...
|
||||
public:
|
||||
Group(PaintState parentPaintState);
|
||||
Group(PaintState _parentPaintState);
|
||||
~Group(void);
|
||||
virtual bool Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void Display(int32_t spacing);
|
||||
virtual void AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||
virtual void AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Line.cpp
|
||||
* @brief basic line parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
@ -38,44 +22,47 @@ svg::Line::~Line(void)
|
||||
|
||||
}
|
||||
|
||||
bool svg::Line::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax)
|
||||
bool svg::Line::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
||||
{
|
||||
// line must have a minimum size...
|
||||
m_paint.strokeWidth = 1;
|
||||
ParseTransform(node);
|
||||
ParsePaintAttr(node);
|
||||
if (NULL==_element) {
|
||||
return false;
|
||||
}
|
||||
ParseTransform(_element);
|
||||
ParsePaintAttr(_element);
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= parentTrans;
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
const char * content = node->ToElement()->Attribute("x1");
|
||||
if (NULL != content) {
|
||||
etk::UString content = _element->GetAttribute("x1");
|
||||
if (content.Size()!=0) {
|
||||
m_startPos.setX(ParseLength(content));
|
||||
}
|
||||
content = node->ToElement()->Attribute("y1");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("y1");
|
||||
if (content.Size()!=0) {
|
||||
m_startPos.setY(ParseLength(content));
|
||||
}
|
||||
content = node->ToElement()->Attribute("x2");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("x2");
|
||||
if (content.Size()!=0) {
|
||||
m_stopPos.setX(ParseLength(content));
|
||||
}
|
||||
content = node->ToElement()->Attribute("y2");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("y2");
|
||||
if (content.Size()!=0) {
|
||||
m_stopPos.setY(ParseLength(content));
|
||||
}
|
||||
sizeMax.setValue(etk_max(m_startPos.x(), m_stopPos.x()),
|
||||
etk_max(m_startPos.y(), m_stopPos.y()));
|
||||
_sizeMax.setValue(etk_max(m_startPos.x(), m_stopPos.x()),
|
||||
etk_max(m_startPos.y(), m_stopPos.y()));
|
||||
return true;
|
||||
}
|
||||
|
||||
void svg::Line::Display(int32_t spacing)
|
||||
void svg::Line::Display(int32_t _spacing)
|
||||
{
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Line " << m_startPos << " to " << m_stopPos);
|
||||
SVG_DEBUG(SpacingDist(_spacing) << "Line " << m_startPos << " to " << m_stopPos);
|
||||
}
|
||||
|
||||
|
||||
void svg::Line::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans)
|
||||
void svg::Line::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
|
||||
{
|
||||
agg::path_storage path;
|
||||
path.start_new_path();
|
||||
@ -107,18 +94,18 @@ void svg::Line::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans
|
||||
}
|
||||
*/
|
||||
agg::trans_affine mtx = m_transformMatrix;
|
||||
mtx *= basicTrans;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
if (m_paint.strokeWidth > 0) {
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
// Drawing as an outline
|
||||
agg::conv_stroke<agg::path_storage> myPolygonStroke(path);
|
||||
myPolygonStroke.width(m_paint.strokeWidth);
|
||||
agg::conv_transform<agg::conv_stroke<agg::path_storage>, agg::trans_affine> transStroke(myPolygonStroke, mtx);
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Line.h
|
||||
* @brief basic line parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_LINE_H__
|
||||
@ -37,7 +21,7 @@ namespace svg
|
||||
public:
|
||||
Line(PaintState parentPaintState);
|
||||
~Line(void);
|
||||
virtual bool Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual bool Parse(exml::Element * _element, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual void Display(int32_t spacing);
|
||||
virtual void AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||
};
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Path.cpp
|
||||
* @brief basic path parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
@ -30,7 +14,7 @@
|
||||
#include <agg/agg_conv_contour.h>
|
||||
#include <agg/agg_conv_smooth_poly1.h>
|
||||
|
||||
svg::Path::Path(PaintState parentPaintState) : svg::Base(parentPaintState)
|
||||
svg::Path::Path(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
||||
{
|
||||
|
||||
}
|
||||
@ -42,7 +26,7 @@ svg::Path::~Path(void)
|
||||
|
||||
|
||||
// return the next char position ... (after 'X' or NULL)
|
||||
const char * extractCmd(const char * input, char& cmd, etk::Vector<float>& outputList)
|
||||
const char * extractCmd(const char* input, char& cmd, etk::Vector<float>& outputList)
|
||||
{
|
||||
if (*input == '\0') {
|
||||
return NULL;
|
||||
@ -78,18 +62,21 @@ const char * extractCmd(const char * input, char& cmd, etk::Vector<float>& outpu
|
||||
return outputPointer;
|
||||
}
|
||||
|
||||
bool svg::Path::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax)
|
||||
bool svg::Path::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
||||
{
|
||||
ParseTransform(node);
|
||||
ParsePaintAttr(node);
|
||||
if (NULL==_element) {
|
||||
return false;
|
||||
}
|
||||
ParseTransform(_element);
|
||||
ParsePaintAttr(_element);
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= parentTrans;
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
|
||||
const char *elementXML = node->ToElement()->Attribute("d");
|
||||
if (NULL == elementXML) {
|
||||
SVG_ERROR("(l "<<node->Row()<<") path: missing 'p' attribute");
|
||||
etk::UString elementXML1 = _element->GetAttribute("d");
|
||||
if (elementXML1.Size()==0) {
|
||||
SVG_ERROR("(l "<<_element->Pos()<<") path: missing 'p' attribute");
|
||||
return false;
|
||||
}
|
||||
SVG_VERBOSE("Parse Path : \"" << elementXML << "\"");
|
||||
@ -97,6 +84,9 @@ bool svg::Path::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vec
|
||||
char command;
|
||||
etk::Vector<float> listDot;
|
||||
|
||||
etk::Char plop = elementXML1.c_str();
|
||||
const char* elementXML = plop;
|
||||
|
||||
for( const char *sss=extractCmd(elementXML, command, listDot);
|
||||
NULL != sss;
|
||||
sss=extractCmd(sss, command, listDot) ) {
|
||||
@ -289,55 +279,55 @@ bool svg::Path::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vec
|
||||
return true;
|
||||
}
|
||||
|
||||
void svg::Path::Display(int32_t spacing)
|
||||
void svg::Path::Display(int32_t _spacing)
|
||||
{
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Path");
|
||||
SVG_DEBUG(SpacingDist(_spacing) << "Path");
|
||||
for(int32_t iii=0; iii<m_listElement.Size(); iii++) {
|
||||
switch (m_listElement[iii].cmd) {
|
||||
case PATH_ENUM_STOP:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "STOP");
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "STOP");
|
||||
break;
|
||||
case PATH_ENUM_MOVETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "MOVETO (" << m_listElement[iii].element[0] << "," << m_listElement[iii].element[1] << ")" );
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "MOVETO (" << m_listElement[iii].element[0] << "," << m_listElement[iii].element[1] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_LINETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "LINETO (" << m_listElement[iii].element[0] << "," << m_listElement[iii].element[1] << ")" );
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "LINETO (" << m_listElement[iii].element[0] << "," << m_listElement[iii].element[1] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_LINETO_H:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "LINETO_H (" << m_listElement[iii].element[0] << ")" );
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "LINETO_H (" << m_listElement[iii].element[0] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_LINETO_V:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "LINETO_V (" << m_listElement[iii].element[0] << ")" );
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "LINETO_V (" << m_listElement[iii].element[0] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_CURVETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "CURVETO (" << m_listElement[iii].element[0] <<
|
||||
"," << m_listElement[iii].element[1] <<
|
||||
"," << m_listElement[iii].element[2] <<
|
||||
"," << m_listElement[iii].element[3] <<
|
||||
"," << m_listElement[iii].element[4] <<
|
||||
"," << m_listElement[iii].element[5] << ")" );
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "CURVETO (" << m_listElement[iii].element[0] <<
|
||||
"," << m_listElement[iii].element[1] <<
|
||||
"," << m_listElement[iii].element[2] <<
|
||||
"," << m_listElement[iii].element[3] <<
|
||||
"," << m_listElement[iii].element[4] <<
|
||||
"," << m_listElement[iii].element[5] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_SMOTH_CURVETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "SMOTH_CURVETO (" << m_listElement[iii].element[0] <<
|
||||
"," << m_listElement[iii].element[1] <<
|
||||
"," << m_listElement[iii].element[2] <<
|
||||
"," << m_listElement[iii].element[3] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_BEZIER_CURVETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "BEZIER_CURVETO (" << m_listElement[iii].element[0] <<
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "SMOTH_CURVETO (" << m_listElement[iii].element[0] <<
|
||||
"," << m_listElement[iii].element[1] <<
|
||||
"," << m_listElement[iii].element[2] <<
|
||||
"," << m_listElement[iii].element[3] << ")" );
|
||||
"," << m_listElement[iii].element[3] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_BEZIER_CURVETO:
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "BEZIER_CURVETO (" << m_listElement[iii].element[0] <<
|
||||
"," << m_listElement[iii].element[1] <<
|
||||
"," << m_listElement[iii].element[2] <<
|
||||
"," << m_listElement[iii].element[3] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_BEZIER_SMOTH_CURVETO:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "BEZIER_SMOTH_CURVETO (" << m_listElement[iii].element[0] << "," << m_listElement[iii].element[1] << ")" );
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "BEZIER_SMOTH_CURVETO (" << m_listElement[iii].element[0] << "," << m_listElement[iii].element[1] << ")" );
|
||||
break;
|
||||
case PATH_ENUM_ELLIPTIC:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "ELLIPTIC (TODO...)" );
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "ELLIPTIC (TODO...)" );
|
||||
// show explanation at : http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
|
||||
break;
|
||||
default:
|
||||
SVG_DEBUG(SpacingDist(spacing+4) << "????" );
|
||||
SVG_DEBUG(SpacingDist(_spacing+4) << "????" );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -345,9 +335,9 @@ void svg::Path::Display(int32_t spacing)
|
||||
|
||||
|
||||
|
||||
void svg::Path::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans)
|
||||
void svg::Path::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
|
||||
{
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.fill.r, m_paint.fill.g, m_paint.fill.b, m_paint.fill.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.fill.r, m_paint.fill.g, m_paint.fill.b, m_paint.fill.a));
|
||||
|
||||
agg::path_storage path;
|
||||
path.start_new_path();
|
||||
@ -418,110 +408,110 @@ void svg::Path::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans
|
||||
}
|
||||
|
||||
agg::trans_affine mtx = m_transformMatrix;
|
||||
mtx *= basicTrans;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
agg::conv_curve<agg::path_storage> curve(path);
|
||||
if (m_paint.fill.a != 0x00) {
|
||||
agg::conv_transform<agg::conv_curve<agg::path_storage>, agg::trans_affine> trans(curve, mtx);
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule((m_paint.flagEvenOdd)?agg::fill_even_odd:agg::fill_non_zero);
|
||||
myRenderer.m_rasterizer.add_path(trans);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.filling_rule((m_paint.flagEvenOdd)?agg::fill_even_odd:agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.add_path(trans);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
// Drawing as an outline
|
||||
agg::conv_stroke<agg::conv_curve<agg::path_storage> > myPolygonStroke(curve);
|
||||
myPolygonStroke.width(m_paint.strokeWidth);
|
||||
agg::conv_transform<agg::conv_stroke<agg::conv_curve<agg::path_storage> >, agg::trans_affine> transStroke(myPolygonStroke, mtx);
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void svg::Path::AbstractMoveTo(agg::path_storage& path, bool rel, double x, double y)
|
||||
void svg::Path::AbstractMoveTo(agg::path_storage& _path, bool _rel, double _x, double _y)
|
||||
{
|
||||
if(true == rel) {
|
||||
path.rel_to_abs(&x, &y);
|
||||
if(true == _rel) {
|
||||
_path.rel_to_abs(&_x, &_y);
|
||||
}
|
||||
path.move_to(x, y);
|
||||
_path.move_to(_x, _y);
|
||||
}
|
||||
|
||||
void svg::Path::AbstractLineTo(agg::path_storage& path, bool rel, double x, double y)
|
||||
void svg::Path::AbstractLineTo(agg::path_storage& _path, bool _rel, double _x, double _y)
|
||||
{
|
||||
if(true == rel) {
|
||||
path.rel_to_abs(&x, &y);
|
||||
if(true == _rel) {
|
||||
_path.rel_to_abs(&_x, &_y);
|
||||
}
|
||||
path.line_to(x, y);
|
||||
_path.line_to(_x, _y);
|
||||
}
|
||||
|
||||
void svg::Path::AbstractHLineTo(agg::path_storage& path, bool rel, double x)
|
||||
void svg::Path::AbstractHLineTo(agg::path_storage& _path, bool _rel, double _x)
|
||||
{
|
||||
double x2 = 0.0;
|
||||
double y2 = 0.0;
|
||||
if(0!=path.total_vertices()) {
|
||||
path.vertex(path.total_vertices() - 1, &x2, &y2);
|
||||
if(true == rel) {
|
||||
x += x2;
|
||||
if(0!=_path.total_vertices()) {
|
||||
_path.vertex(_path.total_vertices() - 1, &x2, &y2);
|
||||
if(true == _rel) {
|
||||
_x += x2;
|
||||
}
|
||||
path.line_to(x, y2);
|
||||
_path.line_to(_x, y2);
|
||||
}
|
||||
}
|
||||
|
||||
void svg::Path::AbstractVLineTo(agg::path_storage& path, bool rel, double y)
|
||||
void svg::Path::AbstractVLineTo(agg::path_storage& _path, bool _rel, double _y)
|
||||
{
|
||||
double x2 = 0.0;
|
||||
double y2 = 0.0;
|
||||
if(path.total_vertices()) {
|
||||
path.vertex(path.total_vertices() - 1, &x2, &y2);
|
||||
if(true == rel) {
|
||||
y += y2;
|
||||
if(_path.total_vertices()) {
|
||||
_path.vertex(_path.total_vertices() - 1, &x2, &y2);
|
||||
if(true == _rel) {
|
||||
_y += y2;
|
||||
}
|
||||
path.line_to(x2, y);
|
||||
_path.line_to(x2, _y);
|
||||
}
|
||||
}
|
||||
|
||||
void svg::Path::AbstractCurve3(agg::path_storage& path, bool rel, double x1, double y1, double x, double y)
|
||||
void svg::Path::AbstractCurve3(agg::path_storage& _path, bool _rel, double _x1, double _y1, double _x, double _y)
|
||||
{
|
||||
if(true == rel) {
|
||||
path.rel_to_abs(&x1, &y1);
|
||||
path.rel_to_abs(&x, &y);
|
||||
if(true == _rel) {
|
||||
_path.rel_to_abs(&_x1, &_y1);
|
||||
_path.rel_to_abs(&_x, &_y);
|
||||
}
|
||||
path.curve3(x1, y1, x, y);
|
||||
_path.curve3(_x1, _y1, _x, _y);
|
||||
}
|
||||
|
||||
void svg::Path::AbstractCurve3(agg::path_storage& path, bool rel, double x, double y)
|
||||
void svg::Path::AbstractCurve3(agg::path_storage& _path, bool _rel, double _x, double _y)
|
||||
{
|
||||
if(true == rel) {
|
||||
path.curve3_rel(x, y);
|
||||
if(true == _rel) {
|
||||
_path.curve3_rel(_x, _y);
|
||||
} else {
|
||||
path.curve3(x, y);
|
||||
_path.curve3(_x, _y);
|
||||
}
|
||||
}
|
||||
|
||||
void svg::Path::AbstractCurve4(agg::path_storage& path, bool rel, double x1, double y1, double x2, double y2, double x, double y)
|
||||
void svg::Path::AbstractCurve4(agg::path_storage& _path, bool _rel, double _x1, double _y1, double _x2, double _y2, double _x, double _y)
|
||||
{
|
||||
if(true == rel) {
|
||||
path.rel_to_abs(&x1, &y1);
|
||||
path.rel_to_abs(&x2, &y2);
|
||||
path.rel_to_abs(&x, &y);
|
||||
if(true == _rel) {
|
||||
_path.rel_to_abs(&_x1, &_y1);
|
||||
_path.rel_to_abs(&_x2, &_y2);
|
||||
_path.rel_to_abs(&_x, &_y);
|
||||
}
|
||||
path.curve4(x1, y1, x2, y2, x, y);
|
||||
_path.curve4(_x1, _y1, _x2, _y2, _x, _y);
|
||||
}
|
||||
|
||||
void svg::Path::AbstractCurve4(agg::path_storage& path, bool rel, double x2, double y2, double x, double y)
|
||||
void svg::Path::AbstractCurve4(agg::path_storage& _path, bool _rel, double _x2, double _y2, double _x, double _y)
|
||||
{
|
||||
if(true == rel) {
|
||||
path.curve4_rel(x2, y2, x, y);
|
||||
if(true == _rel) {
|
||||
_path.curve4_rel(_x2, _y2, _x, _y);
|
||||
} else {
|
||||
path.curve4(x2, y2, x, y);
|
||||
_path.curve4(_x2, _y2, _x, _y);
|
||||
}
|
||||
}
|
||||
|
||||
void svg::Path::AbstractCloseSubpath(agg::path_storage& path)
|
||||
void svg::Path::AbstractCloseSubpath(agg::path_storage& _path)
|
||||
{
|
||||
path.end_poly(agg::path_flags_close);
|
||||
_path.end_poly(agg::path_flags_close);
|
||||
}
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Path.h
|
||||
* @brief basic path parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_PATH_H__
|
||||
@ -54,21 +38,21 @@ namespace svg
|
||||
private:
|
||||
etk::Vector<pathBasic_ts> m_listElement;
|
||||
public:
|
||||
Path(PaintState parentPaintState);
|
||||
Path(PaintState _parentPaintState);
|
||||
~Path(void);
|
||||
virtual bool Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual void Display(int32_t spacing);
|
||||
virtual void AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void Display(int32_t _spacing);
|
||||
virtual void AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
private:
|
||||
void AbstractMoveTo(agg::path_storage& path, bool rel, double x, double y);
|
||||
void AbstractLineTo(agg::path_storage& path, bool rel, double x, double y);
|
||||
void AbstractHLineTo(agg::path_storage& path, bool rel, double x);
|
||||
void AbstractVLineTo(agg::path_storage& path, bool rel, double y);
|
||||
void AbstractCurve3(agg::path_storage& path, bool rel, double x1, double y1, double x, double y);
|
||||
void AbstractCurve3(agg::path_storage& path, bool rel, double x, double y);
|
||||
void AbstractCurve4(agg::path_storage& path, bool rel, double x1, double y1, double x2, double y2, double x, double y);
|
||||
void AbstractCurve4(agg::path_storage& path, bool rel, double x2, double y2, double x, double y);
|
||||
void AbstractCloseSubpath(agg::path_storage& path);
|
||||
void AbstractMoveTo(agg::path_storage& _path, bool _rel, double _x, double _y);
|
||||
void AbstractLineTo(agg::path_storage& _path, bool _rel, double _x, double _y);
|
||||
void AbstractHLineTo(agg::path_storage& _path, bool _rel, double _x);
|
||||
void AbstractVLineTo(agg::path_storage& _path, bool _rel, double _y);
|
||||
void AbstractCurve3(agg::path_storage& _path, bool _rel, double _x1, double _y1, double _x, double _y);
|
||||
void AbstractCurve3(agg::path_storage& _path, bool _rel, double _x, double _y);
|
||||
void AbstractCurve4(agg::path_storage& _path, bool _rel, double _x1, double _y1, double _x2, double _y2, double _x, double _y);
|
||||
void AbstractCurve4(agg::path_storage& _path, bool _rel, double _x2, double _y2, double _x, double _y);
|
||||
void AbstractCloseSubpath(agg::path_storage& _path);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Polygon.cpp
|
||||
* @brief basic poligon parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
@ -37,24 +21,29 @@ svg::Polygon::~Polygon(void)
|
||||
|
||||
}
|
||||
|
||||
bool svg::Polygon::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax)
|
||||
bool svg::Polygon::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
||||
{
|
||||
ParseTransform(node);
|
||||
ParsePaintAttr(node);
|
||||
if (NULL==_element) {
|
||||
return false;
|
||||
}
|
||||
ParseTransform(_element);
|
||||
ParsePaintAttr(_element);
|
||||
|
||||
SVG_VERBOSE("parsed P1. trans : (" << m_transformMatrix.sx << "," << m_transformMatrix.shy << "," << m_transformMatrix.shx << "," << m_transformMatrix.sy << "," << m_transformMatrix.tx << "," << m_transformMatrix.ty << ")");
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= parentTrans;
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
SVG_VERBOSE("parsed P2. trans : (" << m_transformMatrix.sx << "," << m_transformMatrix.shy << "," << m_transformMatrix.shx << "," << m_transformMatrix.sy << "," << m_transformMatrix.tx << "," << m_transformMatrix.ty << ")");
|
||||
|
||||
const char *sss = node->ToElement()->Attribute("points");
|
||||
if (NULL == sss) {
|
||||
SVG_ERROR("(l "<<node->Row()<<") polygon: missing points attribute");
|
||||
const etk::UString sss1 = _element->GetAttribute("points");
|
||||
if (sss1.Size()==0) {
|
||||
SVG_ERROR("(l "/*<<_element->Pos()*/<<") polygon: missing points attribute");
|
||||
return false;
|
||||
}
|
||||
sizeMax.setValue(0,0);
|
||||
etk::Char sss2 = sss1.c_str();
|
||||
const char * sss = sss2;
|
||||
_sizeMax.setValue(0,0);
|
||||
SVG_VERBOSE("Parse polygon : \"" << sss << "\"");
|
||||
while ('\0' != sss[0]) {
|
||||
vec2 pos(0,0);
|
||||
@ -62,8 +51,8 @@ bool svg::Polygon::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::
|
||||
if (sscanf(sss, "%f,%f%n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
|
||||
m_listPoint.PushBack(pos);
|
||||
sss += n;
|
||||
sizeMax.setValue(etk_max(sizeMax.x(), pos.x()),
|
||||
etk_max(sizeMax.y(), pos.y()));
|
||||
_sizeMax.setValue(etk_max(_sizeMax.x(), pos.x()),
|
||||
etk_max(_sizeMax.y(), pos.y()));
|
||||
if(sss[0] == ' ' || sss[0] == ',') {
|
||||
sss++;
|
||||
}
|
||||
@ -74,14 +63,14 @@ bool svg::Polygon::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::
|
||||
return true;
|
||||
}
|
||||
|
||||
void svg::Polygon::Display(int32_t spacing)
|
||||
void svg::Polygon::Display(int32_t _spacing)
|
||||
{
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Polygon nbPoint=" << m_listPoint.Size());
|
||||
SVG_DEBUG(SpacingDist(_spacing) << "Polygon nbPoint=" << m_listPoint.Size());
|
||||
}
|
||||
|
||||
void svg::Polygon::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans)
|
||||
void svg::Polygon::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
|
||||
{
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.fill.r, m_paint.fill.g, m_paint.fill.b, m_paint.fill.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.fill.r, m_paint.fill.g, m_paint.fill.b, m_paint.fill.a));
|
||||
|
||||
agg::path_storage path;
|
||||
path.start_new_path();
|
||||
@ -118,26 +107,26 @@ void svg::Polygon::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTr
|
||||
*/
|
||||
|
||||
agg::trans_affine mtx = m_transformMatrix;
|
||||
mtx *= basicTrans;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
if (m_paint.fill.a != 0x00) {
|
||||
agg::conv_transform<agg::path_storage, agg::trans_affine> trans(path, mtx);
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule((m_paint.flagEvenOdd)?agg::fill_even_odd:agg::fill_non_zero);
|
||||
myRenderer.m_rasterizer.add_path(trans);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.filling_rule((m_paint.flagEvenOdd)?agg::fill_even_odd:agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.add_path(trans);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
|
||||
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
// Drawing as an outline
|
||||
agg::conv_stroke<agg::path_storage> myPolygonStroke(path);
|
||||
myPolygonStroke.width(m_paint.strokeWidth);
|
||||
agg::conv_transform<agg::conv_stroke<agg::path_storage>, agg::trans_affine> transStroke(myPolygonStroke, mtx);
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Polygon.h
|
||||
* @brief basic poligon parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_POLYGON_H__
|
||||
@ -42,7 +26,7 @@ namespace svg
|
||||
public:
|
||||
Polygon(PaintState parentPaintState);
|
||||
~Polygon(void);
|
||||
virtual bool Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual bool Parse(exml::Element * _element, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual void Display(int32_t spacing);
|
||||
virtual void AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||
};
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Polyline.cpp
|
||||
* @brief basic Poliline parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
@ -27,7 +11,7 @@
|
||||
#include <agg/agg_conv_stroke.h>
|
||||
#include <agg/agg_path_storage.h>
|
||||
|
||||
svg::Polyline::Polyline(PaintState parentPaintState) : svg::Base(parentPaintState)
|
||||
svg::Polyline::Polyline(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
||||
{
|
||||
|
||||
}
|
||||
@ -37,30 +21,35 @@ svg::Polyline::~Polyline(void)
|
||||
|
||||
}
|
||||
|
||||
bool svg::Polyline::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax)
|
||||
bool svg::Polyline::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
||||
{
|
||||
// line must have a minimum size...
|
||||
m_paint.strokeWidth = 1;
|
||||
ParseTransform(node);
|
||||
ParsePaintAttr(node);
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= parentTrans;
|
||||
|
||||
const char *sss = node->ToElement()->Attribute("points");
|
||||
if (NULL == sss) {
|
||||
SVG_ERROR("(l "<<node->Row()<<") polyline: missing points attribute");
|
||||
if (NULL==_element) {
|
||||
return false;
|
||||
}
|
||||
sizeMax.setValue(0,0);
|
||||
SVG_VERBOSE("Parse polyline : \"" << sss << "\"");
|
||||
ParseTransform(_element);
|
||||
ParsePaintAttr(_element);
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
etk::UString sss1 = _element->GetAttribute("points");
|
||||
if (sss1.Size()==0) {
|
||||
SVG_ERROR("(l "<<_element->Pos()<<") polyline: missing points attribute");
|
||||
return false;
|
||||
}
|
||||
_sizeMax.setValue(0,0);
|
||||
SVG_VERBOSE("Parse polyline : \"" << sss1 << "\"");
|
||||
etk::Char sss2 = sss1.c_str();
|
||||
const char* sss = sss2;
|
||||
while ('\0' != sss[0]) {
|
||||
etk::Vector2D<float> pos;
|
||||
int32_t n;
|
||||
if (sscanf(sss, "%f,%f %n", &pos.m_floats[0], &pos.m_floats[1], &n) == 2) {
|
||||
m_listPoint.PushBack(pos);
|
||||
sizeMax.setValue(etk_max(sizeMax.x(), pos.x()),
|
||||
etk_max(sizeMax.y(), pos.y()));
|
||||
_sizeMax.setValue(etk_max(_sizeMax.x(), pos.x()),
|
||||
etk_max(_sizeMax.y(), pos.y()));
|
||||
sss += n;
|
||||
} else {
|
||||
break;
|
||||
@ -69,13 +58,13 @@ bool svg::Polyline::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk:
|
||||
return true;
|
||||
}
|
||||
|
||||
void svg::Polyline::Display(int32_t spacing)
|
||||
void svg::Polyline::Display(int32_t _spacing)
|
||||
{
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Polyline nbPoint=" << m_listPoint.Size());
|
||||
SVG_DEBUG(SpacingDist(_spacing) << "Polyline nbPoint=" << m_listPoint.Size());
|
||||
}
|
||||
|
||||
|
||||
void svg::Polyline::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans)
|
||||
void svg::Polyline::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
|
||||
{
|
||||
agg::path_storage path;
|
||||
path.start_new_path();
|
||||
@ -110,18 +99,18 @@ void svg::Polyline::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicT
|
||||
*/
|
||||
|
||||
agg::trans_affine mtx = m_transformMatrix;
|
||||
mtx *= basicTrans;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
if (m_paint.strokeWidth > 0) {
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
// Drawing as an outline
|
||||
agg::conv_stroke<agg::path_storage> myPolygonStroke(path);
|
||||
myPolygonStroke.width(m_paint.strokeWidth);
|
||||
agg::conv_transform<agg::conv_stroke<agg::path_storage>, agg::trans_affine> transStroke(myPolygonStroke, mtx);
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Polyline.h
|
||||
* @brief basic Poliline parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_POLYLINE_H__
|
||||
@ -35,11 +19,11 @@ namespace svg
|
||||
private:
|
||||
etk::Vector<etk::Vector2D<float> > m_listPoint; //!< list of all point of the polyline
|
||||
public:
|
||||
Polyline(PaintState parentPaintState);
|
||||
Polyline(PaintState _parentPaintState);
|
||||
~Polyline(void);
|
||||
virtual bool Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual void Display(int32_t spacing);
|
||||
virtual void AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void Display(int32_t _spacing);
|
||||
virtual void AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Rectangle.cpp
|
||||
* @brief basic rectangle parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
@ -27,7 +11,7 @@
|
||||
#include <agg/agg_rounded_rect.h>
|
||||
#include <agg/agg_conv_stroke.h>
|
||||
|
||||
svg::Rectangle::Rectangle(PaintState parentPaintState) : svg::Base(parentPaintState)
|
||||
svg::Rectangle::Rectangle(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
||||
{
|
||||
m_position.setValue(0,0);
|
||||
m_size.setValue(0,0);
|
||||
@ -39,41 +23,44 @@ svg::Rectangle::~Rectangle(void)
|
||||
|
||||
}
|
||||
|
||||
bool svg::Rectangle::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax)
|
||||
bool svg::Rectangle::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
||||
{
|
||||
if (NULL==_element) {
|
||||
return false;
|
||||
}
|
||||
m_position.setValue(0,0);
|
||||
m_size.setValue(0,0);
|
||||
m_roundedCorner.setValue(0,0);
|
||||
|
||||
ParseTransform(node);
|
||||
ParsePaintAttr(node);
|
||||
ParseTransform(_element);
|
||||
ParsePaintAttr(_element);
|
||||
|
||||
// add the property of the parrent modifications ...
|
||||
m_transformMatrix *= parentTrans;
|
||||
m_transformMatrix *= _parentTrans;
|
||||
|
||||
ParsePosition(node, m_position, m_size);
|
||||
ParsePosition(_element, m_position, m_size);
|
||||
|
||||
const char * content = node->ToElement()->Attribute("rx");
|
||||
if (NULL != content) {
|
||||
etk::UString content = _element->GetAttribute("rx");
|
||||
if (content.Size()!=0) {
|
||||
m_roundedCorner.setX(ParseLength(content));
|
||||
}
|
||||
content = node->ToElement()->Attribute("ry");
|
||||
if (NULL != content) {
|
||||
content = _element->GetAttribute("ry");
|
||||
if (content.Size()!=0) {
|
||||
m_roundedCorner.setY(ParseLength(content));
|
||||
}
|
||||
sizeMax.setValue(m_position.x() + m_size.x() + m_paint.strokeWidth,
|
||||
m_position.y() + m_size.y() + m_paint.strokeWidth);
|
||||
_sizeMax.setValue(m_position.x() + m_size.x() + m_paint.strokeWidth,
|
||||
m_position.y() + m_size.y() + m_paint.strokeWidth);
|
||||
return true;
|
||||
}
|
||||
|
||||
void svg::Rectangle::Display(int32_t spacing)
|
||||
void svg::Rectangle::Display(int32_t _spacing)
|
||||
{
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Rectangle : pos=" << m_position << " size=" << m_size << " corner=" << m_roundedCorner);
|
||||
SVG_DEBUG(SpacingDist(_spacing) << "Rectangle : pos=" << m_position << " size=" << m_size << " corner=" << m_roundedCorner);
|
||||
}
|
||||
|
||||
void svg::Rectangle::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans)
|
||||
void svg::Rectangle::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
|
||||
{
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.fill.r, m_paint.fill.g, m_paint.fill.b, m_paint.fill.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.fill.r, m_paint.fill.g, m_paint.fill.b, m_paint.fill.a));
|
||||
// Creating a rounded rectangle
|
||||
agg::rounded_rect rect_r(m_position.x(), m_position.y(), m_position.x()+m_size.x(), m_position.y()+m_size.y(), m_roundedCorner.x());
|
||||
rect_r.radius(m_roundedCorner.x(), m_roundedCorner.y());
|
||||
@ -81,26 +68,26 @@ void svg::Rectangle::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basic
|
||||
|
||||
agg::trans_affine mtx = m_transformMatrix;
|
||||
// herited modifications ...
|
||||
mtx *= basicTrans;
|
||||
mtx *= _basicTrans;
|
||||
|
||||
if (m_paint.fill.a != 0x00) {
|
||||
agg::conv_transform<agg::rounded_rect, agg::trans_affine> trans(rect_r, mtx);
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule((m_paint.flagEvenOdd)?agg::fill_even_odd:agg::fill_non_zero);
|
||||
myRenderer.m_rasterizer.add_path(trans);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.filling_rule((m_paint.flagEvenOdd)?agg::fill_even_odd:agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.add_path(trans);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
|
||||
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
|
||||
myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
_myRenderer.m_renderArea->color(agg::rgba8(m_paint.stroke.r, m_paint.stroke.g, m_paint.stroke.b, m_paint.stroke.a));
|
||||
// Drawing as an outline
|
||||
agg::conv_stroke<agg::rounded_rect> rect_p(rect_r);
|
||||
// set the filling mode :
|
||||
myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
_myRenderer.m_rasterizer.filling_rule(agg::fill_non_zero);
|
||||
rect_p.width(m_paint.strokeWidth);
|
||||
agg::conv_transform<agg::conv_stroke<agg::rounded_rect>, agg::trans_affine> transStroke(rect_p, mtx);
|
||||
myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(myRenderer.m_rasterizer, myRenderer.m_scanLine, *myRenderer.m_renderArea);
|
||||
_myRenderer.m_rasterizer.add_path(transStroke);
|
||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Rectangle.h
|
||||
* @brief basic rectangle parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_RECTANGLE_H__
|
||||
@ -36,11 +20,11 @@ namespace svg
|
||||
etk::Vector2D<float> m_size; //!< size of the rectangle
|
||||
etk::Vector2D<float> m_roundedCorner; //!< property of the rounded corner
|
||||
public:
|
||||
Rectangle(PaintState parentPaintState);
|
||||
Rectangle(PaintState _parentPaintState);
|
||||
~Rectangle(void);
|
||||
virtual bool Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual void Display(int32_t spacing);
|
||||
virtual void AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void Display(int32_t _spacing);
|
||||
virtual void AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Renderer.cpp
|
||||
* @brief Basic SVG renderer for the AGG librairy (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 23/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Renderer.h
|
||||
* @brief Basic SVG renderer for the AGG librairy (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 23/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_RENDERER_H__
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Stroking.cpp
|
||||
* @brief basic stroking parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Stroking.h
|
||||
* @brief basic stroking parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_STROKING_H__
|
||||
|
@ -1,31 +1,15 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Text.cpp
|
||||
* @brief Basic Text parsing (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
#include <parserSVG/Text.h>
|
||||
|
||||
svg::Text::Text(PaintState parentPaintState) : svg::Base(parentPaintState)
|
||||
svg::Text::Text(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
||||
{
|
||||
|
||||
}
|
||||
@ -35,16 +19,16 @@ svg::Text::~Text(void)
|
||||
|
||||
}
|
||||
|
||||
bool svg::Text::Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax)
|
||||
bool svg::Text::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
||||
{
|
||||
sizeMax.setValue(0,0);
|
||||
_sizeMax.setValue(0,0);
|
||||
SVG_ERROR("NOT IMPLEMENTED");
|
||||
return false;
|
||||
}
|
||||
|
||||
void svg::Text::Display(int32_t spacing)
|
||||
void svg::Text::Display(int32_t _spacing)
|
||||
{
|
||||
SVG_DEBUG(SpacingDist(spacing) << "Text");
|
||||
SVG_DEBUG(SpacingDist(_spacing) << "Text");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/Text.h
|
||||
* @brief Basic Text parsing (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_TEXT_H__
|
||||
@ -34,10 +18,10 @@ namespace svg
|
||||
private:
|
||||
|
||||
public:
|
||||
Text(PaintState parentPaintState);
|
||||
Text(PaintState _parentPaintState);
|
||||
~Text(void);
|
||||
virtual bool Parse(TiXmlNode * node, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual void Display(int32_t spacing);
|
||||
virtual bool Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void Display(int32_t _spacing);
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -1,30 +1,13 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/parserSVG.cpp
|
||||
* @brief parserSVG : basic header of the SVG parser (Sources)
|
||||
* @author Edouard DUPIN
|
||||
* @date 18/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#include <parserSVG/Debug.h>
|
||||
#include <parserSVG/parserSVG.h>
|
||||
#include <tinyXML/tinyxml.h>
|
||||
#include <parserSVG/Base.h>
|
||||
#include <parserSVG/Circle.h>
|
||||
#include <parserSVG/Ellipse.h>
|
||||
@ -47,9 +30,9 @@
|
||||
#include <agg/agg_color_rgba.h>
|
||||
#include <agg/agg_pixfmt_rgba.h>
|
||||
|
||||
svg::Parser::Parser(etk::UString fileName) : m_renderedElement(NULL)
|
||||
svg::Parser::Parser(etk::UString _fileName) : m_renderedElement(NULL)
|
||||
{
|
||||
m_fileName = fileName;
|
||||
m_fileName = _fileName;
|
||||
m_version = "0.0";
|
||||
m_loadOK = true;
|
||||
m_paint.fill = (int32_t)0xFF0000FF;
|
||||
@ -62,137 +45,109 @@ svg::Parser::Parser(etk::UString fileName) : m_renderedElement(NULL)
|
||||
m_paint.lineCap = svg::LINECAP_BUTT;
|
||||
m_size.setValue(0,0);
|
||||
|
||||
// Start loading the XML :
|
||||
SVG_DEBUG("open file (SVG) \"" << m_fileName << "\"");
|
||||
etk::FSNode tmpFile(m_fileName);
|
||||
exml::Document doc;
|
||||
|
||||
// allocate the document in the stack
|
||||
TiXmlDocument XmlDocument;
|
||||
if (false == tmpFile.Exist()) {
|
||||
SVG_ERROR("File Does not exist : " << m_fileName);
|
||||
bool Load(const etk::UString& _file);
|
||||
if (false == doc.Load(m_fileName)) {
|
||||
SVG_ERROR("Error occured when loading XML : " << m_fileName);
|
||||
m_loadOK = false;
|
||||
return;
|
||||
}
|
||||
int64_t fileSize = tmpFile.FileSize();
|
||||
if (0==fileSize) {
|
||||
SVG_ERROR("This file is empty : " << m_fileName);
|
||||
|
||||
if (0 == doc.Size() ) {
|
||||
SVG_ERROR("(l ?) No nodes in the xml file ... \"" << m_fileName << "\"");
|
||||
m_loadOK = false;
|
||||
return;
|
||||
}
|
||||
if (false == tmpFile.FileOpenRead()) {
|
||||
SVG_ERROR("Can not open the file : " << m_fileName);
|
||||
m_loadOK = false;
|
||||
return;
|
||||
}
|
||||
// allocate data
|
||||
char * fileBuffer = new char[fileSize+5];
|
||||
if (NULL == fileBuffer) {
|
||||
SVG_ERROR("Error Memory allocation size=" << fileSize);
|
||||
m_loadOK = false;
|
||||
return;
|
||||
}
|
||||
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
|
||||
// load data from the file :
|
||||
tmpFile.FileRead(fileBuffer, 1, fileSize);
|
||||
// close the file:
|
||||
tmpFile.FileClose();
|
||||
// load the XML from the memory
|
||||
XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
|
||||
|
||||
TiXmlElement* root = XmlDocument.FirstChildElement( "svg" );
|
||||
|
||||
exml::Element* root = (exml::Element*)doc.GetNamed( "svg" );
|
||||
if (NULL == root ) {
|
||||
SVG_ERROR("(l ?) main node not find: \"svg\" in \"" << m_fileName << "\"");
|
||||
m_loadOK = false;
|
||||
} else {
|
||||
// get the svg version :
|
||||
const char *version = root->ToElement()->Attribute("version");
|
||||
if (NULL != version) {
|
||||
m_version = version;
|
||||
return;
|
||||
}
|
||||
// get the svg version :
|
||||
m_version = root->GetAttribute("version");
|
||||
// parse ...
|
||||
vec2 pos(0,0);
|
||||
ParseTransform(root);
|
||||
ParsePosition(root, pos, m_size);
|
||||
ParsePaintAttr(root);
|
||||
SVG_VERBOSE("parsed .ROOT trans : (" << m_transformMatrix.sx << "," << m_transformMatrix.shy << "," << m_transformMatrix.shx << "," << m_transformMatrix.sy << "," << m_transformMatrix.tx << "," << m_transformMatrix.ty << ")");
|
||||
vec2 maxSize(0,0);
|
||||
vec2 size(0,0);
|
||||
// parse all sub node :
|
||||
for(int32_t iii=0; iii< root->Size(); iii++) {
|
||||
exml::Node* child = root->Get(iii);
|
||||
if (child==NULL) {
|
||||
continue;
|
||||
}
|
||||
// parse ...
|
||||
vec2 pos(0,0);
|
||||
ParseTransform(root);
|
||||
ParsePosition(root, pos, m_size);
|
||||
ParsePaintAttr(root);
|
||||
SVG_VERBOSE("parsed .ROOT trans : (" << m_transformMatrix.sx << "," << m_transformMatrix.shy << "," << m_transformMatrix.shx << "," << m_transformMatrix.sy << "," << m_transformMatrix.tx << "," << m_transformMatrix.ty << ")");
|
||||
vec2 maxSize(0,0);
|
||||
vec2 size(0,0);
|
||||
// parse all sub node :
|
||||
for(TiXmlNode * child = root->FirstChild(); NULL != child; child = child->NextSibling() ) {
|
||||
svg::Base *elementParser = NULL;
|
||||
if (child->Type()==TiXmlNode::TINYXML_COMMENT) {
|
||||
// nothing to do, just proceed to next step
|
||||
} else {
|
||||
etk::UString localValue = child->Value();
|
||||
bool normalNoElement = false;
|
||||
if (localValue == "g") {
|
||||
elementParser = new svg::Group(m_paint);
|
||||
} else if (localValue == "a") {
|
||||
SVG_INFO("Note : 'a' balise is parsed like a g balise ...");
|
||||
elementParser = new svg::Group(m_paint);
|
||||
} else if (localValue == "title") {
|
||||
m_title = "TODO : set the title here ...";
|
||||
normalNoElement = true;
|
||||
} else if (localValue == "path") {
|
||||
elementParser = new svg::Path(m_paint);
|
||||
} else if (localValue == "rect") {
|
||||
elementParser = new svg::Rectangle(m_paint);
|
||||
} else if (localValue == "circle") {
|
||||
elementParser = new svg::Circle(m_paint);
|
||||
} else if (localValue == "ellipse") {
|
||||
elementParser = new svg::Ellipse(m_paint);
|
||||
} else if (localValue == "line") {
|
||||
elementParser = new svg::Line(m_paint);
|
||||
} else if (localValue == "polyline") {
|
||||
elementParser = new svg::Polyline(m_paint);
|
||||
} else if (localValue == "polygon") {
|
||||
elementParser = new svg::Polygon(m_paint);
|
||||
} else if (localValue == "text") {
|
||||
elementParser = new svg::Text(m_paint);
|
||||
} else if (localValue == "defs") {
|
||||
// Node ignore : must implement it later ...
|
||||
normalNoElement = true;
|
||||
} else if (localValue == "sodipodi:namedview") {
|
||||
// Node ignore : generaly inkscape data
|
||||
normalNoElement = true;
|
||||
} else if (localValue == "metadata") {
|
||||
// Node ignore : generaly inkscape data
|
||||
normalNoElement = true;
|
||||
} else {
|
||||
SVG_ERROR("(l "<<child->Row()<<") node not suported : \""<<localValue<<"\" must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
|
||||
}
|
||||
if (false == normalNoElement) {
|
||||
if (NULL == elementParser) {
|
||||
SVG_ERROR("(l "<<child->Row()<<") error on node: \""<<localValue<<"\" allocation error or not supported ...");
|
||||
} else {
|
||||
if (false == elementParser->Parse(child, m_transformMatrix, size)) {
|
||||
SVG_ERROR("(l "<<child->Row()<<") error on node: \""<<localValue<<"\" Sub Parsing ERROR");
|
||||
delete(elementParser);
|
||||
elementParser = NULL;
|
||||
} else {
|
||||
if (maxSize.x()<size.x()) {
|
||||
maxSize.setX(size.x());
|
||||
}
|
||||
if (maxSize.y()<size.y()) {
|
||||
maxSize.setY(size.y());
|
||||
}
|
||||
// add element in the system
|
||||
m_subElementList.PushBack(elementParser);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
svg::Base *elementParser = NULL;
|
||||
if (!child->IsElement()) {
|
||||
// nothing to do, just proceed to next step
|
||||
continue;
|
||||
}
|
||||
if (m_size.x()==0 || m_size.y()==0) {
|
||||
m_size.setValue((int32_t)maxSize.x(), (int32_t)maxSize.y());
|
||||
if (child->GetValue() == "g") {
|
||||
elementParser = new svg::Group(m_paint);
|
||||
} else if (child->GetValue() == "a") {
|
||||
SVG_INFO("Note : 'a' balise is parsed like a g balise ...");
|
||||
elementParser = new svg::Group(m_paint);
|
||||
} else if (child->GetValue() == "title") {
|
||||
m_title = "TODO : set the title here ...";
|
||||
continue;
|
||||
} else if (child->GetValue() == "path") {
|
||||
elementParser = new svg::Path(m_paint);
|
||||
} else if (child->GetValue() == "rect") {
|
||||
elementParser = new svg::Rectangle(m_paint);
|
||||
} else if (child->GetValue() == "circle") {
|
||||
elementParser = new svg::Circle(m_paint);
|
||||
} else if (child->GetValue() == "ellipse") {
|
||||
elementParser = new svg::Ellipse(m_paint);
|
||||
} else if (child->GetValue() == "line") {
|
||||
elementParser = new svg::Line(m_paint);
|
||||
} else if (child->GetValue() == "polyline") {
|
||||
elementParser = new svg::Polyline(m_paint);
|
||||
} else if (child->GetValue() == "polygon") {
|
||||
elementParser = new svg::Polygon(m_paint);
|
||||
} else if (child->GetValue() == "text") {
|
||||
elementParser = new svg::Text(m_paint);
|
||||
} else if (child->GetValue() == "defs") {
|
||||
// Node ignore : must implement it later ...
|
||||
continue;
|
||||
} else if (child->GetValue() == "sodipodi:namedview") {
|
||||
// Node ignore : generaly inkscape data
|
||||
continue;
|
||||
} else if (child->GetValue() == "metadata") {
|
||||
// Node ignore : generaly inkscape data
|
||||
continue;
|
||||
} else {
|
||||
m_size.setValue((int32_t)m_size.x(), (int32_t)m_size.y());
|
||||
SVG_ERROR("(l "<<child->Pos()<<") node not suported : \""<<child->GetValue()<<"\" must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
|
||||
}
|
||||
if (NULL == elementParser) {
|
||||
SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ...");
|
||||
continue;
|
||||
}
|
||||
if (false == elementParser->Parse((exml::Element*)child, m_transformMatrix, size)) {
|
||||
SVG_ERROR("(l "<<child->Pos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR");
|
||||
delete(elementParser);
|
||||
elementParser = NULL;
|
||||
continue;
|
||||
}
|
||||
if (maxSize.x()<size.x()) {
|
||||
maxSize.setX(size.x());
|
||||
}
|
||||
if (maxSize.y()<size.y()) {
|
||||
maxSize.setY(size.y());
|
||||
}
|
||||
// add element in the system
|
||||
m_subElementList.PushBack(elementParser);
|
||||
}
|
||||
if (NULL != fileBuffer) {
|
||||
delete[] fileBuffer;
|
||||
if (m_size.x()==0 || m_size.y()==0) {
|
||||
m_size.setValue((int32_t)maxSize.x(), (int32_t)maxSize.y());
|
||||
} else {
|
||||
m_size.setValue((int32_t)m_size.x(), (int32_t)m_size.y());
|
||||
}
|
||||
//DisplayDebug();
|
||||
DisplayDebug();
|
||||
}
|
||||
|
||||
svg::Parser::~Parser(void)
|
||||
|
@ -1,25 +1,9 @@
|
||||
/**
|
||||
*******************************************************************************
|
||||
* @file parserSVG/parserSVG.h
|
||||
* @brief parserSVG : basic header of the SVG parser (Header)
|
||||
* @author Edouard DUPIN
|
||||
* @date 20/03/2012
|
||||
* @par Project
|
||||
* parserSVG
|
||||
*
|
||||
* @par Copyright
|
||||
* Copyright 2011 Edouard DUPIN, all right reserved
|
||||
*
|
||||
* This software is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY.
|
||||
*
|
||||
* Licence summary :
|
||||
* You can modify and redistribute the sources code and binaries.
|
||||
* You can send me the bug-fix
|
||||
*
|
||||
* Term of the licence in in the file licence.txt.
|
||||
*
|
||||
*******************************************************************************
|
||||
*
|
||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||
*
|
||||
* @license BSD v3 (see license file)
|
||||
*/
|
||||
|
||||
#ifndef __SVG_PARSER_H__
|
||||
@ -47,15 +31,15 @@ namespace svg
|
||||
svg::Renderer* m_renderedElement;
|
||||
|
||||
public:
|
||||
Parser(etk::UString fileName);
|
||||
Parser(etk::UString _fileName);
|
||||
~Parser(void);
|
||||
bool IsLoadOk(void) { return m_loadOK; };
|
||||
void DisplayDebug(void);
|
||||
void GenerateTestFile(void);
|
||||
void GenerateAnImage(int32_t sizeX, int32_t sizeY);
|
||||
void GenerateAnImage(ivec2 size, draw::Image& output);
|
||||
void GenerateAnImage(draw::Image& output);
|
||||
virtual void AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||
void GenerateAnImage(int32_t _sizeX, int32_t _sizeY);
|
||||
void GenerateAnImage(ivec2 _size, draw::Image& _output);
|
||||
void GenerateAnImage(draw::Image& _output);
|
||||
virtual void AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
uint8_t* GetPointerOnData(void);
|
||||
uint32_t GetSizeOnData(void);
|
||||
vec2 GetDefinedSize(void) { return m_size;};
|
||||
|
Loading…
Reference in New Issue
Block a user