[DEV] coding style ended

This commit is contained in:
Edouard DUPIN 2013-10-04 21:43:29 +02:00
parent b80dbfd298
commit ce05b596af
25 changed files with 377 additions and 474 deletions

View File

@ -15,18 +15,15 @@
#undef __class__
#define __class__ "Base"
esvg::Base::Base(PaintState _parentPaintState)
{
esvg::Base::Base(PaintState _parentPaintState) {
// copy the parent painting properties ...
m_paint = _parentPaintState;
}
void esvg::Base::parseTransform(exml::Element* _element)
{
void esvg::Base::parseTransform(exml::Element* _element) {
if (NULL == _element) {
return;
}
etk::UString inputString = _element->getAttribute("transform");
if (inputString.size() == 0) {
return;
@ -89,8 +86,7 @@ void esvg::Base::parseTransform(exml::Element* _element)
* @param[out] _pos parsed position
* @param[out] _size parsed dimention
*/
void esvg::Base::parsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size)
{
void esvg::Base::parsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size) {
_pos.setValue(0,0);
_size.setValue(0,0);
@ -121,8 +117,7 @@ void esvg::Base::parsePosition(const exml::Element *_element, etk::Vector2D<floa
* @param[in] _dataInput Data C String with the printed lenght
* @return standart number of pixels
*/
float esvg::Base::parseLength(const etk::UString& _dataInput)
{
float esvg::Base::parseLength(const etk::UString& _dataInput) {
SVG_VERBOSE(" lenght : '" << _dataInput << "'");
float n = _dataInput.toFloat();
etk::UString unit;
@ -166,8 +161,7 @@ float esvg::Base::parseLength(const etk::UString& _dataInput)
}
// return the next char position ... (after ';' or NULL)
int32_t extractPartOfStyle(const etk::UString& _data, etk::UString& _outputType, etk::UString& _outputData, int32_t _pos)
{
int32_t extractPartOfStyle(const etk::UString& _data, etk::UString& _outputType, etk::UString& _outputData, int32_t _pos) {
_outputType = "";
_outputData = "";
if (_pos == -1) {
@ -205,8 +199,7 @@ int32_t extractPartOfStyle(const etk::UString& _data, etk::UString& _outputType,
* @brief parse a Painting attribute of a specific node
* @param[in] _element Basic node of the XML that might be parsed
*/
void esvg::Base::parsePaintAttr(const exml::Element *_element)
{
void esvg::Base::parsePaintAttr(const exml::Element *_element) {
if (_element == NULL) {
return;
}
@ -262,26 +255,26 @@ void esvg::Base::parsePaintAttr(const exml::Element *_element)
content = _element->getAttribute("stroke-linecap");
if (content.size()!=0) {
if (content == "butt" ) {
m_paint.lineCap = esvg::LINECAP_BUTT;
m_paint.lineCap = esvg::lineCapButt;
} else if (content == "round" ) {
m_paint.lineCap = esvg::LINECAP_ROUND;
m_paint.lineCap = esvg::lineCapRound;
} else if (content == "square" ) {
m_paint.lineCap = esvg::LINECAP_SQUARE;
m_paint.lineCap = esvg::lineCapSquare;
} else {
m_paint.lineCap = esvg::LINECAP_BUTT;
m_paint.lineCap = esvg::lineCapButt;
SVG_ERROR("not know stroke-linecap value : \"" << content << "\", not in [butt,round,square]");
}
}
content = _element->getAttribute("stroke-linejoin");
if (content.size()!=0) {
if (content == "miter" ) {
m_paint.lineJoin = esvg::LINEJOIN_MITER;
m_paint.lineJoin = esvg::lineJoinMiter;
} else if (content == "round" ) {
m_paint.lineJoin = esvg::LINEJOIN_ROUND;
m_paint.lineJoin = esvg::lineJoinRound;
} else if (content == "bevel" ) {
m_paint.lineJoin = esvg::LINEJOIN_BEVEL;
m_paint.lineJoin = esvg::lineJoinBevel;
} else {
m_paint.lineJoin = esvg::LINEJOIN_MITER;
m_paint.lineJoin = esvg::lineJoinMiter;
SVG_ERROR("not know stroke-linejoin value : \"" << content << "\", not in [miter,round,bevel]");
}
}
@ -335,24 +328,24 @@ void esvg::Base::parsePaintAttr(const exml::Element *_element)
}
} else if (outputType == "stroke-linecap") {
if (outputValue == "butt") {
m_paint.lineCap = esvg::LINECAP_BUTT;
m_paint.lineCap = esvg::lineCapButt;
} else if (outputValue == "round") {
m_paint.lineCap = esvg::LINECAP_ROUND;
m_paint.lineCap = esvg::lineCapRound;
} else if (outputValue == "square") {
m_paint.lineCap = esvg::LINECAP_SQUARE;
m_paint.lineCap = esvg::lineCapSquare;
} else {
m_paint.lineCap = esvg::LINECAP_BUTT;
m_paint.lineCap = esvg::lineCapButt;
SVG_ERROR("not know " << outputType << " value : \"" << outputValue << "\", not in [butt,round,square]");
}
} else if (outputType == "stroke-linejoin") {
if (outputValue == "miter") {
m_paint.lineJoin = esvg::LINEJOIN_MITER;
m_paint.lineJoin = esvg::lineJoinMiter;
} else if (outputValue == "round") {
m_paint.lineJoin = esvg::LINEJOIN_ROUND;
m_paint.lineJoin = esvg::lineJoinRound;
} else if (outputValue == "bevel") {
m_paint.lineJoin = esvg::LINEJOIN_BEVEL;
m_paint.lineJoin = esvg::lineJoinBevel;
} else {
m_paint.lineJoin = esvg::LINEJOIN_MITER;
m_paint.lineJoin = esvg::lineJoinMiter;
SVG_ERROR("not know " << outputType << " value : \"" << outputValue << "\", not in [miter,round,bevel]");
}
} else if (outputType == "marker-start") {
@ -376,8 +369,7 @@ void esvg::Base::parsePaintAttr(const exml::Element *_element)
* @param[in] _inputData Data C String with the xml definition
* @return the parsed color
*/
draw::Color esvg::Base::parseColor(const etk::UString& _inputData)
{
draw::Color esvg::Base::parseColor(const etk::UString& _inputData) {
draw::Color localColor = draw::color::white;
if( _inputData.size() > 4
@ -402,16 +394,14 @@ draw::Color esvg::Base::parseColor(const etk::UString& _inputData)
* @param[in] _element standart XML node
* @return true if no problem arrived
*/
bool esvg::Base::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
bool esvg::Base::parse(exml::Element* _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
SVG_ERROR("NOT IMPLEMENTED");
_sizeMax.setValue(0,0);
return false;
}
const char * esvg::Base::SpacingDist(int32_t _spacing)
{
const char * esvg::Base::spacingDist(int32_t _spacing) {
static const char *tmpValue = " ";
if (_spacing>20) {
_spacing = 20;

View File

@ -28,23 +28,21 @@
#include <agg/agg_color_rgba.h>
#include <agg/agg_pixfmt_rgba.h>
namespace esvg
{
class Base
{
namespace esvg {
class Base {
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);
virtual ~Base(void) { };
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
//specific drawing for AAG librairy ...
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans) { };
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans) { };
virtual void Display(int32_t _spacing) { };
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);

View File

@ -14,18 +14,15 @@
#undef __class__
#define __class__ "Circle"
esvg::Circle::Circle(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{
esvg::Circle::Circle(PaintState _parentPaintState) : esvg::Base(_parentPaintState) {
}
esvg::Circle::~Circle(void)
{
esvg::Circle::~Circle(void) {
}
bool esvg::Circle::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
bool esvg::Circle::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
m_radius = 0.0;
m_position.setValue(0,0);
if (NULL == _element) {
@ -52,7 +49,6 @@ bool esvg::Circle::parse(exml::Element * _element, agg::trans_affine& _parentTra
SVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is not present");
return false;
}
if (0 > m_radius) {
m_radius = 0;
SVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is negative");
@ -62,13 +58,13 @@ bool esvg::Circle::parse(exml::Element * _element, agg::trans_affine& _parentTra
return true;
}
void esvg::Circle::Display(int32_t _spacing)
void esvg::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 esvg::Circle::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
void esvg::Circle::aggDraw(esvg::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));
// Creating an ellipse

View File

@ -11,10 +11,8 @@
#include <esvg/Base.h>
namespace esvg
{
class Circle : public esvg::Base
{
namespace esvg {
class Circle : public esvg::Base {
private:
etk::Vector2D<float> m_position; //!< Position of the Circle
float m_radius; //!< Radius of the Circle
@ -22,8 +20,8 @@ namespace esvg
Circle(PaintState _parentPaintState);
~Circle(void);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
virtual void display(int32_t _spacing);
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};
};

View File

@ -14,18 +14,15 @@
#undef __class__
#define __class__ "Ellipse"
esvg::Ellipse::Ellipse(PaintState parentPaintState) : esvg::Base(parentPaintState)
{
esvg::Ellipse::Ellipse(PaintState _parentPaintState) : esvg::Base(_parentPaintState) {
}
esvg::Ellipse::~Ellipse(void)
{
esvg::Ellipse::~Ellipse(void) {
}
bool esvg::Ellipse::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
bool esvg::Ellipse::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
if (NULL == _element) {
return false;
}
@ -65,14 +62,12 @@ bool esvg::Ellipse::parse(exml::Element * _element, agg::trans_affine& _parentTr
return true;
}
void esvg::Ellipse::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Ellipse c=" << m_c << " r=" << m_r);
void esvg::Ellipse::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Ellipse c=" << m_c << " r=" << m_r);
}
void esvg::Ellipse::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
{
void esvg::Ellipse::aggDraw(esvg::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));
// Creating an ellipse
agg::ellipse myEllipse(m_c.x(), m_c.y(), m_r.x(), m_r.y(), 0);
@ -89,7 +84,6 @@ void esvg::Ellipse::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _bas
_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));
// drawing as an outline
@ -101,7 +95,6 @@ void esvg::Ellipse::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _bas
_myRenderer.m_rasterizer.add_path(transStroke);
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
}
}

View File

@ -11,10 +11,8 @@
#include <esvg/Base.h>
namespace esvg
{
class Ellipse : public esvg::Base
{
namespace esvg {
class Ellipse : public esvg::Base {
private:
etk::Vector2D<float> m_c; //!< Center property of the ellipse
etk::Vector2D<float> m_r; //!< Radius property of the ellipse
@ -22,8 +20,8 @@ namespace esvg
Ellipse(PaintState _parentPaintState);
~Ellipse(void);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
virtual void display(int32_t _spacing);
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};
};

View File

@ -23,18 +23,15 @@
#undef __class__
#define __class__ "Group"
esvg::Group::Group(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{
esvg::Group::Group(PaintState _parentPaintState) : esvg::Base(_parentPaintState) {
}
esvg::Group::~Group(void)
{
esvg::Group::~Group(void) {
}
bool esvg::Group::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
bool esvg::Group::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
if (NULL == _element) {
return false;
}
@ -82,13 +79,13 @@ bool esvg::Group::parse(exml::Element * _element, agg::trans_affine& _parentTran
} else if (child->getValue() == "text") {
elementParser = new esvg::Text(m_paint);
} else {
SVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->GetValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
SVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->getValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
}
if (NULL == elementParser) {
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ...");
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" allocation error or not supported ...");
} else {
if (false == elementParser->parse(child, m_transformMatrix, tmpPos)) {
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR");
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" Sub Parsing ERROR");
delete(elementParser);
elementParser = NULL;
} else {
@ -102,22 +99,21 @@ bool esvg::Group::parse(exml::Element * _element, agg::trans_affine& _parentTran
return true;
}
void esvg::Group::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Group (START) fill=" << m_paint.fill << " stroke=" << m_paint.stroke << " stroke-width=" << m_paint.strokeWidth );
void esvg::Group::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Group (START) fill=" << m_paint.fill << " stroke=" << m_paint.stroke << " stroke-width=" << m_paint.strokeWidth );
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
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 esvg::Group::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
void esvg::Group::aggDraw(esvg::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);
}
}
}

View File

@ -12,18 +12,16 @@
#include <esvg/Base.h>
#include <etk/Vector.h>
namespace esvg
{
class Group : public esvg::Base
{
namespace esvg {
class Group : public esvg::Base {
private:
etk::Vector<esvg::Base *> m_subElementList; //!< group sub elements ...
public:
Group(PaintState _parentPaintState);
~Group(void);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
virtual void display(int32_t spacing);
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};
};

View File

@ -14,19 +14,16 @@
#undef __class__
#define __class__ "Line"
esvg::Line::Line(PaintState parentPaintState) : esvg::Base(parentPaintState)
{
esvg::Line::Line(PaintState _parentPaintState) : esvg::Base(_parentPaintState) {
m_startPos.setValue(0,0);
m_stopPos.setValue(0,0);
}
esvg::Line::~Line(void)
{
esvg::Line::~Line(void) {
}
bool esvg::Line::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
bool esvg::Line::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
// line must have a minimum size...
m_paint.strokeWidth = 1;
if (NULL == _element) {
@ -59,14 +56,11 @@ bool esvg::Line::parse(exml::Element * _element, agg::trans_affine& _parentTrans
return true;
}
void esvg::Line::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Line " << m_startPos << " to " << m_stopPos);
void esvg::Line::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Line " << m_startPos << " to " << m_stopPos);
}
void esvg::Line::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
{
void esvg::Line::aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans) {
agg::path_storage path;
path.start_new_path();
path.move_to(m_startPos.x(), m_startPos.y());

View File

@ -11,19 +11,17 @@
#include <esvg/Base.h>
namespace esvg
{
class Line : public esvg::Base
{
namespace esvg {
class Line : public esvg::Base {
private:
etk::Vector2D<float> m_startPos; //!< Start line position
etk::Vector2D<float> m_stopPos; //!< Stop line position
public:
Line(PaintState parentPaintState);
Line(PaintState _parentPaintState);
~Line(void);
virtual bool parse(exml::Element * _element, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
virtual void Display(int32_t spacing);
virtual void AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void display(int32_t _spacing);
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};
};

View File

@ -17,47 +17,44 @@
#undef __class__
#define __class__ "Path"
esvg::Path::Path(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{
esvg::Path::Path(PaintState _parentPaintState) : esvg::Base(_parentPaintState) {
}
esvg::Path::~Path(void)
{
esvg::Path::~Path(void) {
}
// return the next char position ... (after 'X' or NULL)
const char * extractCmd(const char* input, char& cmd, etk::Vector<float>& outputList)
{
if (*input == '\0') {
const char * extractCmd(const char* _input, char& _cmd, etk::Vector<float>& _outputList) {
if (*_input == '\0') {
return NULL;
}
outputList.clear();
cmd = '\0';
_outputList.clear();
_cmd = '\0';
const char * outputPointer = NULL;
if (!( (input[0] <= 'Z' && input[0] >= 'A') || (input[0] <= 'z' && input[0] >= 'a') ) ) {
SVG_ERROR("Error in the SVG Path : \"" << input << "\"");
if (!( (_input[0] <= 'Z' && _input[0] >= 'A') || (_input[0] <= 'z' && _input[0] >= 'a') ) ) {
SVG_ERROR("Error in the SVG Path : \"" << _input << "\"");
return NULL;
}
cmd = input[0];
SVG_VERBOSE("Find command : " << cmd);
if (input[1] == '\0') {
return &input[1];
_cmd = _input[0];
SVG_VERBOSE("Find command : " << _cmd);
if (_input[1] == '\0') {
return &_input[1];
}
int32_t iii=1;
// extract every float separated by a ' ' or a ','
float element;
char spacer[10];
int32_t nbElementRead;
while( sscanf(&input[iii], "%1[, ]%f%n", spacer, &element, &nbElementRead) == 2
|| sscanf(&input[iii], "%f%n", &element, &nbElementRead) == 1) {
while( sscanf(&_input[iii], "%1[, ]%f%n", spacer, &element, &nbElementRead) == 2
|| sscanf(&_input[iii], "%f%n", &element, &nbElementRead) == 1) {
SVG_VERBOSE("Find element : " << element);
outputList.pushBack(element);
_outputList.pushBack(element);
iii += nbElementRead;
}
outputPointer = &input[iii];
outputPointer = &_input[iii];
while(*outputPointer!= '\0' && *outputPointer == ' ') {
outputPointer++;
}
@ -65,8 +62,7 @@ const char * extractCmd(const char* input, char& cmd, etk::Vector<float>& output
return outputPointer;
}
bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
if (NULL == _element) {
return false;
}
@ -93,8 +89,7 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
for( const char *sss=extractCmd(elementXML, command, listDot);
NULL != sss;
sss=extractCmd(sss, command, listDot) ) {
pathBasic_ts pathElement;
memset(&pathElement, 0, 1*sizeof(pathBasic_ts));
PathBasic pathElement;
switch(command) {
case 'M': // Move to (absolute)
case 'L': // Line to (absolute)
@ -106,10 +101,10 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
case 'S': // smooth curve to (absolute)
case 'A': // elliptical Arc (absolute)
case 'Z': // closepath (absolute)
pathElement.relative = false;
pathElement.m_relative = false;
break;
default : // else (relative)
pathElement.relative = true;
pathElement.m_relative = true;
break;
}
switch(command) {
@ -120,16 +115,16 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_MOVETO;
pathElement.m_cmd = esvg::pathMoveTo;
if (listDot.size() >= 2) {
pathElement.element[0] = listDot[0];
pathElement.element[1] = listDot[1];
pathElement.m_element[0] = listDot[0];
pathElement.m_element[1] = listDot[1];
m_listElement.pushBack(pathElement);
}
pathElement.cmd = esvg::PATH_ENUM_LINETO;
pathElement.m_cmd = esvg::pathLineTo;
for(int32_t iii=2; iii<listDot.size(); iii+=2) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.m_element[0] = listDot[iii];
pathElement.m_element[1] = listDot[iii+1];
m_listElement.pushBack(pathElement);
}
break;
@ -141,10 +136,10 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_LINETO;
pathElement.m_cmd = esvg::pathLineTo;
for(int32_t iii=0; iii<listDot.size(); iii+=2) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.m_element[0] = listDot[iii];
pathElement.m_element[1] = listDot[iii+1];
m_listElement.pushBack(pathElement);
}
break;
@ -156,9 +151,9 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_LINETO_V;
pathElement.m_cmd = esvg::pathLineToV;
for(int32_t iii=0; iii<listDot.size(); iii+=1) {
pathElement.element[0] = listDot[iii];
pathElement.m_element[0] = listDot[iii];
m_listElement.pushBack(pathElement);
}
break;
@ -170,9 +165,9 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_LINETO_H;
pathElement.m_cmd = esvg::pathLineToH;
for(int32_t iii=0; iii<listDot.size(); iii+=1) {
pathElement.element[0] = listDot[iii];
pathElement.m_element[0] = listDot[iii];
m_listElement.pushBack(pathElement);
}
break;
@ -184,12 +179,12 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_BEZIER_CURVETO;
pathElement.m_cmd = esvg::pathBesizeCurveTo;
for(int32_t iii=0; iii<listDot.size(); iii+=4) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.element[2] = listDot[iii+2];
pathElement.element[3] = listDot[iii+3];
pathElement.m_element[0] = listDot[iii];
pathElement.m_element[1] = listDot[iii+1];
pathElement.m_element[2] = listDot[iii+2];
pathElement.m_element[3] = listDot[iii+3];
m_listElement.pushBack(pathElement);
}
break;
@ -201,10 +196,10 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_BEZIER_SMOTH_CURVETO;
pathElement.m_cmd = esvg::pathBesizeSmothCurveTo;
for(int32_t iii=0; iii<listDot.size(); iii+=2) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.m_element[0] = listDot[iii];
pathElement.m_element[1] = listDot[iii+1];
m_listElement.pushBack(pathElement);
}
break;
@ -216,14 +211,14 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_CURVETO;
pathElement.m_cmd = esvg::pathCurveTo;
for(int32_t iii=0; iii<listDot.size(); iii+=6) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.element[2] = listDot[iii+2];
pathElement.element[3] = listDot[iii+3];
pathElement.element[4] = listDot[iii+4];
pathElement.element[5] = listDot[iii+5];
pathElement.m_element[0] = listDot[iii];
pathElement.m_element[1] = listDot[iii+1];
pathElement.m_element[2] = listDot[iii+2];
pathElement.m_element[3] = listDot[iii+3];
pathElement.m_element[4] = listDot[iii+4];
pathElement.m_element[5] = listDot[iii+5];
m_listElement.pushBack(pathElement);
}
break;
@ -235,12 +230,12 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_SMOTH_CURVETO;
pathElement.m_cmd = esvg::pathSmothCurveTo;
for(int32_t iii=0; iii<listDot.size(); iii+=4) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.element[2] = listDot[iii+2];
pathElement.element[3] = listDot[iii+3];
pathElement.m_element[0] = listDot[iii];
pathElement.m_element[1] = listDot[iii+1];
pathElement.m_element[2] = listDot[iii+2];
pathElement.m_element[3] = listDot[iii+3];
m_listElement.pushBack(pathElement);
}
break;
@ -252,15 +247,15 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_ELLIPTIC;
pathElement.m_cmd = esvg::pathElliptic;
for(int32_t iii=0; iii<listDot.size(); iii+=7) {
pathElement.element[0] = listDot[iii];
pathElement.element[1] = listDot[iii+1];
pathElement.element[2] = listDot[iii+2];
pathElement.element[3] = listDot[iii+3];
pathElement.element[4] = listDot[iii+4];
pathElement.element[5] = listDot[iii+5];
pathElement.element[6] = listDot[iii+6];
pathElement.m_element[0] = listDot[iii];
pathElement.m_element[1] = listDot[iii+1];
pathElement.m_element[2] = listDot[iii+2];
pathElement.m_element[3] = listDot[iii+3];
pathElement.m_element[4] = listDot[iii+4];
pathElement.m_element[5] = listDot[iii+5];
pathElement.m_element[6] = listDot[iii+6];
m_listElement.pushBack(pathElement);
}
break;
@ -271,7 +266,7 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
break;
}
pathElement.cmd = esvg::PATH_ENUM_STOP;
pathElement.m_cmd = esvg::pathStop;
m_listElement.pushBack(pathElement);
break;
default:
@ -282,64 +277,60 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
return true;
}
void esvg::Path::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Path");
void esvg::Path::display(int32_t _spacing) {
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");
switch (m_listElement[iii].m_cmd) {
case esvg::pathStop:
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] << ")" );
case esvg::pathMoveTo:
SVG_DEBUG(spacingDist(_spacing+4) << "MOVETO (" << m_listElement[iii].m_element[0] << "," << m_listElement[iii].m_element[1] << ")" );
break;
case PATH_ENUM_LINETO:
SVG_DEBUG(SpacingDist(_spacing+4) << "LINETO (" << m_listElement[iii].element[0] << "," << m_listElement[iii].element[1] << ")" );
case esvg::pathLineTo:
SVG_DEBUG(spacingDist(_spacing+4) << "LINETO (" << m_listElement[iii].m_element[0] << "," << m_listElement[iii].m_element[1] << ")" );
break;
case PATH_ENUM_LINETO_H:
SVG_DEBUG(SpacingDist(_spacing+4) << "LINETO_H (" << m_listElement[iii].element[0] << ")" );
case esvg::pathLineToH:
SVG_DEBUG(spacingDist(_spacing+4) << "LINETO_H (" << m_listElement[iii].m_element[0] << ")" );
break;
case PATH_ENUM_LINETO_V:
SVG_DEBUG(SpacingDist(_spacing+4) << "LINETO_V (" << m_listElement[iii].element[0] << ")" );
case esvg::pathLineToV:
SVG_DEBUG(spacingDist(_spacing+4) << "LINETO_V (" << m_listElement[iii].m_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] << ")" );
case esvg::pathCurveTo:
SVG_DEBUG(spacingDist(_spacing+4) << "CURVETO (" << m_listElement[iii].m_element[0] <<
"," << m_listElement[iii].m_element[1] <<
"," << m_listElement[iii].m_element[2] <<
"," << m_listElement[iii].m_element[3] <<
"," << m_listElement[iii].m_element[4] <<
"," << m_listElement[iii].m_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] << ")" );
case esvg::pathSmothCurveTo:
SVG_DEBUG(spacingDist(_spacing+4) << "SMOTH_CURVETO (" << m_listElement[iii].m_element[0] <<
"," << m_listElement[iii].m_element[1] <<
"," << m_listElement[iii].m_element[2] <<
"," << m_listElement[iii].m_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] << ")" );
case esvg::pathBesizeCurveTo:
SVG_DEBUG(spacingDist(_spacing+4) << "BEZIER_CURVETO (" << m_listElement[iii].m_element[0] <<
"," << m_listElement[iii].m_element[1] <<
"," << m_listElement[iii].m_element[2] <<
"," << m_listElement[iii].m_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] << ")" );
case esvg::pathBesizeSmothCurveTo:
SVG_DEBUG(spacingDist(_spacing+4) << "BEZIER_SMOTH_CURVETO (" << m_listElement[iii].m_element[0] << "," << m_listElement[iii].m_element[1] << ")" );
break;
case PATH_ENUM_ELLIPTIC:
SVG_DEBUG(SpacingDist(_spacing+4) << "ELLIPTIC (TODO...)" );
case esvg::pathElliptic:
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;
}
}
}
void esvg::Path::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
{
void esvg::Path::aggDraw(esvg::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));
agg::path_storage path;
@ -347,61 +338,61 @@ void esvg::Path::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicT
for(int32_t iii=0; iii<m_listElement.size(); iii++) {
switch (m_listElement[iii].cmd) {
case PATH_ENUM_STOP:
AbstractCloseSubpath(path);
switch (m_listElement[iii].m_cmd) {
case esvg::pathStop:
abstractCloseSubpath(path);
break;
case PATH_ENUM_MOVETO:
AbstractMoveTo(path, m_listElement[iii].relative,
m_listElement[iii].element[0],
m_listElement[iii].element[1] );
case esvg::pathMoveTo:
abstractMoveTo(path, m_listElement[iii].m_relative,
m_listElement[iii].m_element[0],
m_listElement[iii].m_element[1] );
break;
case PATH_ENUM_LINETO:
AbstractLineTo(path, m_listElement[iii].relative,
m_listElement[iii].element[0],
m_listElement[iii].element[1] );
case esvg::pathLineTo:
abstractLineTo(path, m_listElement[iii].m_relative,
m_listElement[iii].m_element[0],
m_listElement[iii].m_element[1] );
break;
case PATH_ENUM_LINETO_H:
AbstractHLineTo(path, m_listElement[iii].relative,
m_listElement[iii].element[0] );
case esvg::pathLineToH:
abstractHLineTo(path, m_listElement[iii].m_relative,
m_listElement[iii].m_element[0] );
break;
case PATH_ENUM_LINETO_V:
AbstractVLineTo(path, m_listElement[iii].relative,
m_listElement[iii].element[0] );
case esvg::pathLineToV:
abstractVLineTo(path, m_listElement[iii].m_relative,
m_listElement[iii].m_element[0] );
break;
case PATH_ENUM_CURVETO:
AbstractCurve4(path, m_listElement[iii].relative,
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_INFO(" draw : PATH_ENUM_CURVETO");
case esvg::pathCurveTo:
abstractCurve4(path, m_listElement[iii].m_relative,
m_listElement[iii].m_element[0],
m_listElement[iii].m_element[1],
m_listElement[iii].m_element[2],
m_listElement[iii].m_element[3],
m_listElement[iii].m_element[4],
m_listElement[iii].m_element[5] );
//SVG_INFO(" draw : esvg::pathCurveTo");
break;
case PATH_ENUM_SMOTH_CURVETO:
AbstractCurve4(path, m_listElement[iii].relative,
m_listElement[iii].element[0],
m_listElement[iii].element[1],
m_listElement[iii].element[2],
m_listElement[iii].element[3] );
//SVG_INFO(" draw : PATH_ENUM_SMOTH_CURVETO");
case esvg::pathSmothCurveTo:
abstractCurve4(path, m_listElement[iii].m_relative,
m_listElement[iii].m_element[0],
m_listElement[iii].m_element[1],
m_listElement[iii].m_element[2],
m_listElement[iii].m_element[3] );
//SVG_INFO(" draw : esvg::pathSmothCurveTo");
break;
case PATH_ENUM_BEZIER_CURVETO:
AbstractCurve3(path, m_listElement[iii].relative,
m_listElement[iii].element[0],
m_listElement[iii].element[1],
m_listElement[iii].element[2],
m_listElement[iii].element[3] );
//SVG_INFO(" draw : PATH_ENUM_BEZIER_CURVETO");
case esvg::pathBesizeCurveTo:
abstractCurve3(path, m_listElement[iii].m_relative,
m_listElement[iii].m_element[0],
m_listElement[iii].m_element[1],
m_listElement[iii].m_element[2],
m_listElement[iii].m_element[3] );
//SVG_INFO(" draw : esvg::pathBesizeCurveTo");
break;
case PATH_ENUM_BEZIER_SMOTH_CURVETO:
AbstractCurve3(path, m_listElement[iii].relative,
m_listElement[iii].element[0],
m_listElement[iii].element[1] );
//SVG_INFO(" draw : PATH_ENUM_BEZIER_SMOTH_CURVETO");
case esvg::pathBesizeSmothCurveTo:
abstractCurve3(path, m_listElement[iii].m_relative,
m_listElement[iii].m_element[0],
m_listElement[iii].m_element[1] );
//SVG_INFO(" draw : esvg::pathBesizeSmothCurveTo");
break;
case PATH_ENUM_ELLIPTIC:
case esvg::pathElliptic:
SVG_TODO("Elliptic arc is not implemented NOW ...");
break;
default:
@ -435,24 +426,21 @@ void esvg::Path::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicT
}
void esvg::Path::AbstractMoveTo(agg::path_storage& _path, bool _rel, double _x, double _y)
{
void esvg::Path::abstractMoveTo(agg::path_storage& _path, bool _rel, double _x, double _y) {
if(true == _rel) {
_path.rel_to_abs(&_x, &_y);
}
_path.move_to(_x, _y);
}
void esvg::Path::AbstractLineTo(agg::path_storage& _path, bool _rel, double _x, double _y)
{
void esvg::Path::abstractLineTo(agg::path_storage& _path, bool _rel, double _x, double _y) {
if(true == _rel) {
_path.rel_to_abs(&_x, &_y);
}
_path.line_to(_x, _y);
}
void esvg::Path::AbstractHLineTo(agg::path_storage& _path, bool _rel, double _x)
{
void esvg::Path::abstractHLineTo(agg::path_storage& _path, bool _rel, double _x) {
double x2 = 0.0;
double y2 = 0.0;
if(0!=_path.total_vertices()) {
@ -464,8 +452,7 @@ void esvg::Path::AbstractHLineTo(agg::path_storage& _path, bool _rel, double _x)
}
}
void esvg::Path::AbstractVLineTo(agg::path_storage& _path, bool _rel, double _y)
{
void esvg::Path::abstractVLineTo(agg::path_storage& _path, bool _rel, double _y) {
double x2 = 0.0;
double y2 = 0.0;
if(_path.total_vertices()) {
@ -477,8 +464,7 @@ void esvg::Path::AbstractVLineTo(agg::path_storage& _path, bool _rel, double _y)
}
}
void esvg::Path::AbstractCurve3(agg::path_storage& _path, bool _rel, double _x1, double _y1, double _x, double _y)
{
void esvg::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);
@ -486,8 +472,7 @@ void esvg::Path::AbstractCurve3(agg::path_storage& _path, bool _rel, double _x1,
_path.curve3(_x1, _y1, _x, _y);
}
void esvg::Path::AbstractCurve3(agg::path_storage& _path, bool _rel, double _x, double _y)
{
void esvg::Path::abstractCurve3(agg::path_storage& _path, bool _rel, double _x, double _y) {
if(true == _rel) {
_path.curve3_rel(_x, _y);
} else {
@ -495,8 +480,7 @@ void esvg::Path::AbstractCurve3(agg::path_storage& _path, bool _rel, double _x,
}
}
void esvg::Path::AbstractCurve4(agg::path_storage& _path, bool _rel, double _x1, double _y1, double _x2, double _y2, double _x, double _y)
{
void esvg::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);
@ -505,8 +489,7 @@ void esvg::Path::AbstractCurve4(agg::path_storage& _path, bool _rel, double _x1,
_path.curve4(_x1, _y1, _x2, _y2, _x, _y);
}
void esvg::Path::AbstractCurve4(agg::path_storage& _path, bool _rel, double _x2, double _y2, double _x, double _y)
{
void esvg::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);
} else {
@ -514,7 +497,6 @@ void esvg::Path::AbstractCurve4(agg::path_storage& _path, bool _rel, double _x2,
}
}
void esvg::Path::AbstractCloseSubpath(agg::path_storage& _path)
{
void esvg::Path::abstractCloseSubpath(agg::path_storage& _path) {
_path.end_poly(agg::path_flags_close);
}

View File

@ -12,47 +12,49 @@
#include <esvg/Base.h>
#include <agg/agg_path_storage.h>
namespace esvg
{
typedef enum {
PATH_ENUM_STOP,
PATH_ENUM_MOVETO,
PATH_ENUM_LINETO,
PATH_ENUM_LINETO_H,
PATH_ENUM_LINETO_V,
PATH_ENUM_CURVETO,
PATH_ENUM_SMOTH_CURVETO,
PATH_ENUM_BEZIER_CURVETO,
PATH_ENUM_BEZIER_SMOTH_CURVETO,
PATH_ENUM_ELLIPTIC,
} pathEnum_te;
typedef struct {
pathEnum_te cmd;
bool relative;
float element[7];
}pathBasic_ts;
class Path : public esvg::Base
{
namespace esvg {
enum pathProperty{
pathStop,
pathMoveTo,
pathLineTo,
pathLineToH,
pathLineToV,
pathCurveTo,
pathSmothCurveTo,
pathBesizeCurveTo,
pathBesizeSmothCurveTo,
pathElliptic
};
class PathBasic {
public:
PathBasic(void) : m_cmd(esvg::pathStop), m_relative(false) {
for(int32_t iii=0; iii<7; ++iii) {
m_element[iii] = 0;
}
}
enum pathProperty m_cmd;
bool m_relative;
float m_element[7];
};
class Path : public esvg::Base {
private:
etk::Vector<pathBasic_ts> m_listElement;
etk::Vector<PathBasic> m_listElement;
public:
Path(PaintState _parentPaintState);
~Path(void);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
virtual void display(int32_t _spacing);
virtual void aggDraw(esvg::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);
};
};

View File

@ -14,18 +14,15 @@
#undef __class__
#define __class__ "Polygon"
esvg::Polygon::Polygon(PaintState parentPaintState) : esvg::Base(parentPaintState)
{
esvg::Polygon::Polygon(PaintState parentPaintState) : esvg::Base(parentPaintState) {
}
esvg::Polygon::~Polygon(void)
{
esvg::Polygon::~Polygon(void) {
}
bool esvg::Polygon::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
bool esvg::Polygon::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
if (NULL == _element) {
return false;
}
@ -66,13 +63,11 @@ bool esvg::Polygon::parse(exml::Element * _element, agg::trans_affine& _parentTr
return true;
}
void esvg::Polygon::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Polygon nbPoint=" << m_listPoint.size());
void esvg::Polygon::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Polygon nbPoint=" << m_listPoint.size());
}
void esvg::Polygon::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
{
void esvg::Polygon::aggDraw(esvg::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));
agg::path_storage path;

View File

@ -12,23 +12,21 @@
#include <esvg/Base.h>
#include <etk/Vector.h>
namespace esvg
{
typedef enum {
POLYGONE_MODE__NON_ZERO,
POLYGONE_MODE__EVEN_ODD,
} PolygonMode_te;
class Polygon : public esvg::Base
{
namespace esvg {
enum polygonMode {
polygoneModeNonZero,
polygoneModeEvenOdd
};
class Polygon : public esvg::Base {
private:
etk::Vector<etk::Vector2D<float> > m_listPoint; //!< list of all point of the polygone
PolygonMode_te m_diplayMode; //!< polygone specific display mode
enum esvg::polygonMode m_diplayMode; //!< polygone specific display mode
public:
Polygon(PaintState parentPaintState);
~Polygon(void);
virtual bool parse(exml::Element * _element, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
virtual void Display(int32_t spacing);
virtual void AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
virtual void display(int32_t spacing);
virtual void aggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
};
};

View File

@ -11,18 +11,15 @@
#include <agg/agg_conv_stroke.h>
#include <agg/agg_path_storage.h>
esvg::Polyline::Polyline(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{
esvg::Polyline::Polyline(PaintState _parentPaintState) : esvg::Base(_parentPaintState) {
}
esvg::Polyline::~Polyline(void)
{
esvg::Polyline::~Polyline(void) {
}
bool esvg::Polyline::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
bool esvg::Polyline::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
// line must have a minimum size...
m_paint.strokeWidth = 1;
if (NULL == _element) {
@ -58,14 +55,12 @@ bool esvg::Polyline::parse(exml::Element * _element, agg::trans_affine& _parentT
return true;
}
void esvg::Polyline::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Polyline nbPoint=" << m_listPoint.size());
void esvg::Polyline::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Polyline nbPoint=" << m_listPoint.size());
}
void esvg::Polyline::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
{
void esvg::Polyline::aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans) {
agg::path_storage path;
path.start_new_path();
path.move_to(m_listPoint[0].x(), m_listPoint[0].y());

View File

@ -12,18 +12,16 @@
#include <esvg/Base.h>
#include <etk/Vector.h>
namespace esvg
{
class Polyline : public esvg::Base
{
namespace esvg {
class Polyline : public esvg::Base {
private:
etk::Vector<etk::Vector2D<float> > m_listPoint; //!< list of all point of the polyline
public:
Polyline(PaintState _parentPaintState);
~Polyline(void);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
virtual void display(int32_t _spacing);
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};
};

View File

@ -15,20 +15,17 @@
#define __class__ "Rectangle"
esvg::Rectangle::Rectangle(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{
esvg::Rectangle::Rectangle(PaintState _parentPaintState) : esvg::Base(_parentPaintState) {
m_position.setValue(0,0);
m_size.setValue(0,0);
m_roundedCorner.setValue(0,0);
}
esvg::Rectangle::~Rectangle(void)
{
esvg::Rectangle::~Rectangle(void) {
}
bool esvg::Rectangle::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
bool esvg::Rectangle::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
if (NULL == _element) {
return false;
}
@ -57,13 +54,11 @@ bool esvg::Rectangle::parse(exml::Element * _element, agg::trans_affine& _parent
return true;
}
void esvg::Rectangle::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Rectangle : pos=" << m_position << " size=" << m_size << " corner=" << m_roundedCorner);
void esvg::Rectangle::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Rectangle : pos=" << m_position << " size=" << m_size << " corner=" << m_roundedCorner);
}
void esvg::Rectangle::AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans)
{
void esvg::Rectangle::aggDraw(esvg::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));
// 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());

View File

@ -11,10 +11,8 @@
#include <esvg/Base.h>
namespace esvg
{
class Rectangle : public esvg::Base
{
namespace esvg {
class Rectangle : public esvg::Base {
private:
etk::Vector2D<float> m_position; //!< position of the rectangle
etk::Vector2D<float> m_size; //!< size of the rectangle
@ -23,8 +21,8 @@ namespace esvg
Rectangle(PaintState _parentPaintState);
~Rectangle(void);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
virtual void display(int32_t _spacing);
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
};
};

View File

@ -15,8 +15,7 @@
#undef __class__
#define __class__ "Renderer"
esvg::Renderer::Renderer(uint32_t width, uint32_t height)
{
esvg::Renderer::Renderer(uint32_t width, uint32_t height) {
m_allocatedSize = 0;
m_size.setValue(width, height);
@ -66,8 +65,7 @@ esvg::Renderer::Renderer(uint32_t width, uint32_t height)
//m_basicMatrix *= agg::trans_affine_translation(m_size.x*0.7, m_size.y/2);
}
esvg::Renderer::~Renderer(void)
{
esvg::Renderer::~Renderer(void) {
if (NULL != m_buffer) {
delete[] m_buffer;
m_buffer = NULL;
@ -77,8 +75,7 @@ esvg::Renderer::~Renderer(void)
// Writing the buffer to a .PPM file, assuming it has
// RGB-structure, one byte per color component
//--------------------------------------------------
void esvg::Renderer::WritePpm(etk::UString fileName)
{
void esvg::Renderer::writePpm(etk::UString fileName) {
if (NULL == m_buffer) {
return;
}

View File

@ -24,18 +24,17 @@
#include <agg/agg_color_rgba.h>
#include <agg/agg_pixfmt_rgba.h>
namespace esvg
{
typedef enum {
LINECAP_BUTT,
LINECAP_ROUND,
LINECAP_SQUARE,
} lineCap_te;
typedef enum {
LINEJOIN_MITER,
LINEJOIN_ROUND,
LINEJOIN_BEVEL,
} lineJoin_te;
namespace esvg {
enum lineCap{
lineCapButt,
lineCapRound,
lineCapSquare
};
enum lineJoin{
lineJoinMiter,
lineJoinRound,
lineJoinBevel
};
class PaintState {
public:
@ -43,8 +42,8 @@ namespace esvg
draw::Color stroke;
float strokeWidth;
bool flagEvenOdd;
lineCap_te lineCap;
lineJoin_te lineJoin;
enum esvg::lineCap lineCap;
enum esvg::lineJoin lineJoin;
etk::Vector2D<float> viewPort;
};
@ -59,7 +58,7 @@ namespace esvg
public:
Renderer(uint32_t width, uint32_t height);
~Renderer(void);
void WritePpm(etk::UString fileName);
void writePpm(etk::UString fileName);
etk::Vector2D<float> m_size;
agg::rendering_buffer * m_renderingBuffer;
agg::pixfmt_rgba32 * m_pixFrame;

View File

@ -11,8 +11,7 @@
#include <esvg/Base.h>
namespace esvg
{
namespace esvg {
};

View File

@ -12,26 +12,22 @@
#undef __class__
#define __class__ "Text"
esvg::Text::Text(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
{
esvg::Text::Text(PaintState _parentPaintState) : esvg::Base(_parentPaintState) {
}
esvg::Text::~Text(void)
{
esvg::Text::~Text(void) {
}
bool esvg::Text::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
{
bool esvg::Text::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
_sizeMax.setValue(0,0);
SVG_ERROR("NOT IMPLEMENTED");
return false;
}
void esvg::Text::Display(int32_t _spacing)
{
SVG_DEBUG(SpacingDist(_spacing) << "Text");
void esvg::Text::display(int32_t _spacing) {
SVG_DEBUG(spacingDist(_spacing) << "Text");
}

View File

@ -11,17 +11,13 @@
#include <esvg/Base.h>
namespace esvg
{
class Text : public esvg::Base
{
private:
namespace esvg {
class Text : public esvg::Base {
public:
Text(PaintState _parentPaintState);
~Text(void);
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
virtual void Display(int32_t _spacing);
virtual void display(int32_t _spacing);
};
};

View File

@ -35,8 +35,7 @@
#define __class__ "Document"
esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL)
{
esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL) {
m_fileName = _fileName;
m_version = "0.0";
m_loadOK = true;
@ -46,12 +45,12 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
m_paint.strokeWidth = 1.0;
m_paint.viewPort.setValue(255,255);
m_paint.flagEvenOdd = false;
m_paint.lineJoin = esvg::LINEJOIN_MITER;
m_paint.lineCap = esvg::LINECAP_BUTT;
m_paint.lineJoin = esvg::lineJoinMiter;
m_paint.lineCap = esvg::lineCapButt;
m_size.setValue(0,0);
exml::Document doc;
if (false == doc.Load(m_fileName)) {
if (false == doc.load(m_fileName)) {
SVG_ERROR("Error occured when loading XML : " << m_fileName);
m_loadOK = false;
return;
@ -121,14 +120,14 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
// Node ignore : generaly inkscape data
continue;
} else {
SVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->GetValue()<<"\" must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
SVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->getValue()<<"\" must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
}
if (NULL == elementParser) {
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->GetValue()<<"\" allocation error or not supported ...");
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" allocation error or not supported ...");
continue;
}
if (false == elementParser->parse(child, m_transformMatrix, size)) {
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->GetValue()<<"\" Sub Parsing ERROR");
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" Sub Parsing ERROR");
delete(elementParser);
elementParser = NULL;
continue;
@ -150,8 +149,7 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
//DisplayDebug();
}
esvg::Document::~Document(void)
{
esvg::Document::~Document(void) {
if(NULL != m_renderedElement) {
delete(m_renderedElement);
m_renderedElement = NULL;
@ -160,22 +158,21 @@ esvg::Document::~Document(void)
void esvg::Document::DisplayDebug(void)
{
void esvg::Document::displayDebug(void) {
SVG_DEBUG("Main SVG node : size=" << m_size);
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
if (NULL != m_subElementList[iii]) {
m_subElementList[iii]->Display(1);
m_subElementList[iii]->display(1);
}
}
}
void esvg::Document::AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans)
void esvg::Document::aggDraw(esvg::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);
}
}
}
@ -184,18 +181,18 @@ void esvg::Document::AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basi
void esvg::Document::generateTestFile(void)
{
int32_t sizeX = m_size.x();
if (SizeX == 0) {
if (sizeX == 0) {
sizeX = 64;
}
int32_t sizeY = m_size.y();
if (SizeY == 0) {
if (sizeY == 0) {
sizeY = 64;
}
if(NULL != m_renderedElement) {
delete(m_renderedElement);
m_renderedElement = NULL;
}
m_renderedElement = new esvg::Renderer(SizeX, sizeY);
m_renderedElement = new esvg::Renderer(sizeX, sizeY);
// create the first element matrix modification ...
agg::trans_affine basicTrans;
//basicTrans *= agg::trans_affine_translation(-g_base_dx, -g_base_dy);
@ -206,67 +203,67 @@ void esvg::Document::generateTestFile(void)
//basicTrans *= agg::trans_affine_translation(width/3, height/3);
AggDraw(*m_renderedElement, basicTrans);
aggDraw(*m_renderedElement, basicTrans);
etk::UString tmpFileOut = "yyy_out_";
tmpFileOut += m_fileName;
tmpFileOut += ".ppm";
m_renderedElement->WritePpm(tmpFileOut);
m_renderedElement->writePpm(tmpFileOut);
}
void esvg::Document::generateAnImage(int32_t sizeX, int32_t sizeY)
void esvg::Document::generateAnImage(int32_t _sizeX, int32_t _sizeY)
{
int32_t sizeX = sizeX;
if (SizeX == 0) {
int32_t sizeX = _sizeX;
if (sizeX == 0) {
SVG_ERROR("SizeX == 0 ==> set 64");
sizeX = 64;
}
int32_t sizeY = sizeY;
if (SizeY == 0) {
int32_t sizeY = _sizeY;
if (sizeY == 0) {
SVG_ERROR("SizeY == 0 ==> set 64");
sizeY = 64;
}
SVG_INFO("Generate size (" << sizeX << "," << SizeY << ")");
SVG_INFO("Generate size (" << sizeX << "," << sizeY << ")");
if(NULL != m_renderedElement) {
delete(m_renderedElement);
m_renderedElement = NULL;
}
m_renderedElement = new esvg::Renderer(SizeX, sizeY);
m_renderedElement = new esvg::Renderer(sizeX, sizeY);
// create the first element matrix modification ...
agg::trans_affine basicTrans;
//basicTrans *= agg::trans_affine_translation(-g_base_dx, -g_base_dy);
basicTrans *= agg::trans_affine_scaling(SizeX/m_size.x(), sizeY/m_size.y());
basicTrans *= agg::trans_affine_scaling(sizeX/m_size.x(), sizeY/m_size.y());
//basicTrans *= agg::trans_affine_rotation(g_angle);// + agg::pi);
//basicTrans *= agg::trans_affine_skewing(2.0, 5.0);
//basicTrans *= agg::trans_affine_translation(width*0.3, height/2);
//basicTrans *= agg::trans_affine_translation(width/3, height/3);
AggDraw(*m_renderedElement, basicTrans);
aggDraw(*m_renderedElement, basicTrans);
/*
etk::UString tmpFileOut = "zzz_out_test.ppm";
m_renderedElement->WritePpm(tmpFileOut);
*/
}
void esvg::Document::generateAnImage(draw::Image& output)
void esvg::Document::generateAnImage(draw::Image& _output)
{
generateAnImage(ivec2(m_size.x(),m_size.y()), output);
generateAnImage(ivec2(m_size.x(),m_size.y()), _output);
}
void esvg::Document::generateAnImage(ivec2 size, draw::Image& output)
void esvg::Document::generateAnImage(ivec2 _size, draw::Image& _output)
{
generateAnImage(size.x(), size.y());
output.Resize(size);
generateAnImage(_size.x(), _size.y());
_output.resize(_size);
draw::Color tmpp(0,0,0,0);
output.setFillColor(tmpp);
output.clear();
_output.setFillColor(tmpp);
_output.clear();
if(NULL != m_renderedElement) {
uint8_t* pointerOnData = m_renderedElement->getDataPointer();
int32_t sizeData = m_renderedElement->getDataSize();
uint8_t* tmpOut = (uint8_t*)output.getTextureDataPointer();
uint8_t* tmpOut = (uint8_t*)_output.getTextureDataPointer();
memcpy(tmpOut, pointerOnData, sizeData);
}
}

View File

@ -17,10 +17,8 @@
#include <esvg/Base.h>
#include <draw/Image.h>
namespace esvg
{
class Document : public esvg::Base
{
namespace esvg {
class Document : public esvg::Base {
private:
etk::UString m_fileName;
bool m_loadOK;
@ -29,17 +27,16 @@ namespace esvg
etk::Vector<esvg::Base *> m_subElementList;
vec2 m_size;
esvg::Renderer* m_renderedElement;
public:
Document(const etk::UString& _fileName);
~Document(void);
bool isLoadOk(void) { return m_loadOK; };
void DisplayDebug(void);
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(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
uint8_t* getPointerOnData(void);
uint32_t getSizeOnData(void);
vec2 getDefinedSize(void) { return m_size;};