[DEV] coding style ended
This commit is contained in:
parent
b80dbfd298
commit
ce05b596af
@ -15,18 +15,15 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Base"
|
#define __class__ "Base"
|
||||||
|
|
||||||
esvg::Base::Base(PaintState _parentPaintState)
|
esvg::Base::Base(PaintState _parentPaintState) {
|
||||||
{
|
|
||||||
// copy the parent painting properties ...
|
// copy the parent painting properties ...
|
||||||
m_paint = _parentPaintState;
|
m_paint = _parentPaintState;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Base::parseTransform(exml::Element* _element)
|
void esvg::Base::parseTransform(exml::Element* _element) {
|
||||||
{
|
|
||||||
if (NULL == _element) {
|
if (NULL == _element) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
etk::UString inputString = _element->getAttribute("transform");
|
etk::UString inputString = _element->getAttribute("transform");
|
||||||
if (inputString.size() == 0) {
|
if (inputString.size() == 0) {
|
||||||
return;
|
return;
|
||||||
@ -89,8 +86,7 @@ void esvg::Base::parseTransform(exml::Element* _element)
|
|||||||
* @param[out] _pos parsed position
|
* @param[out] _pos parsed position
|
||||||
* @param[out] _size parsed dimention
|
* @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);
|
_pos.setValue(0,0);
|
||||||
_size.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
|
* @param[in] _dataInput Data C String with the printed lenght
|
||||||
* @return standart number of pixels
|
* @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 << "'");
|
SVG_VERBOSE(" lenght : '" << _dataInput << "'");
|
||||||
float n = _dataInput.toFloat();
|
float n = _dataInput.toFloat();
|
||||||
etk::UString unit;
|
etk::UString unit;
|
||||||
@ -166,8 +161,7 @@ float esvg::Base::parseLength(const etk::UString& _dataInput)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return the next char position ... (after ';' or NULL)
|
// 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 = "";
|
_outputType = "";
|
||||||
_outputData = "";
|
_outputData = "";
|
||||||
if (_pos == -1) {
|
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
|
* @brief parse a Painting attribute of a specific node
|
||||||
* @param[in] _element Basic node of the XML that might be parsed
|
* @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) {
|
if (_element == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -262,26 +255,26 @@ void esvg::Base::parsePaintAttr(const exml::Element *_element)
|
|||||||
content = _element->getAttribute("stroke-linecap");
|
content = _element->getAttribute("stroke-linecap");
|
||||||
if (content.size()!=0) {
|
if (content.size()!=0) {
|
||||||
if (content == "butt" ) {
|
if (content == "butt" ) {
|
||||||
m_paint.lineCap = esvg::LINECAP_BUTT;
|
m_paint.lineCap = esvg::lineCapButt;
|
||||||
} else if (content == "round" ) {
|
} else if (content == "round" ) {
|
||||||
m_paint.lineCap = esvg::LINECAP_ROUND;
|
m_paint.lineCap = esvg::lineCapRound;
|
||||||
} else if (content == "square" ) {
|
} else if (content == "square" ) {
|
||||||
m_paint.lineCap = esvg::LINECAP_SQUARE;
|
m_paint.lineCap = esvg::lineCapSquare;
|
||||||
} else {
|
} 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]");
|
SVG_ERROR("not know stroke-linecap value : \"" << content << "\", not in [butt,round,square]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
content = _element->getAttribute("stroke-linejoin");
|
content = _element->getAttribute("stroke-linejoin");
|
||||||
if (content.size()!=0) {
|
if (content.size()!=0) {
|
||||||
if (content == "miter" ) {
|
if (content == "miter" ) {
|
||||||
m_paint.lineJoin = esvg::LINEJOIN_MITER;
|
m_paint.lineJoin = esvg::lineJoinMiter;
|
||||||
} else if (content == "round" ) {
|
} else if (content == "round" ) {
|
||||||
m_paint.lineJoin = esvg::LINEJOIN_ROUND;
|
m_paint.lineJoin = esvg::lineJoinRound;
|
||||||
} else if (content == "bevel" ) {
|
} else if (content == "bevel" ) {
|
||||||
m_paint.lineJoin = esvg::LINEJOIN_BEVEL;
|
m_paint.lineJoin = esvg::lineJoinBevel;
|
||||||
} else {
|
} 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]");
|
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") {
|
} else if (outputType == "stroke-linecap") {
|
||||||
if (outputValue == "butt") {
|
if (outputValue == "butt") {
|
||||||
m_paint.lineCap = esvg::LINECAP_BUTT;
|
m_paint.lineCap = esvg::lineCapButt;
|
||||||
} else if (outputValue == "round") {
|
} else if (outputValue == "round") {
|
||||||
m_paint.lineCap = esvg::LINECAP_ROUND;
|
m_paint.lineCap = esvg::lineCapRound;
|
||||||
} else if (outputValue == "square") {
|
} else if (outputValue == "square") {
|
||||||
m_paint.lineCap = esvg::LINECAP_SQUARE;
|
m_paint.lineCap = esvg::lineCapSquare;
|
||||||
} else {
|
} else {
|
||||||
m_paint.lineCap = esvg::LINECAP_BUTT;
|
m_paint.lineCap = esvg::lineCapButt;
|
||||||
SVG_ERROR("not know " << outputType << " value : \"" << outputValue << "\", not in [butt,round,square]");
|
SVG_ERROR("not know " << outputType << " value : \"" << outputValue << "\", not in [butt,round,square]");
|
||||||
}
|
}
|
||||||
} else if (outputType == "stroke-linejoin") {
|
} else if (outputType == "stroke-linejoin") {
|
||||||
if (outputValue == "miter") {
|
if (outputValue == "miter") {
|
||||||
m_paint.lineJoin = esvg::LINEJOIN_MITER;
|
m_paint.lineJoin = esvg::lineJoinMiter;
|
||||||
} else if (outputValue == "round") {
|
} else if (outputValue == "round") {
|
||||||
m_paint.lineJoin = esvg::LINEJOIN_ROUND;
|
m_paint.lineJoin = esvg::lineJoinRound;
|
||||||
} else if (outputValue == "bevel") {
|
} else if (outputValue == "bevel") {
|
||||||
m_paint.lineJoin = esvg::LINEJOIN_BEVEL;
|
m_paint.lineJoin = esvg::lineJoinBevel;
|
||||||
} else {
|
} else {
|
||||||
m_paint.lineJoin = esvg::LINEJOIN_MITER;
|
m_paint.lineJoin = esvg::lineJoinMiter;
|
||||||
SVG_ERROR("not know " << outputType << " value : \"" << outputValue << "\", not in [miter,round,bevel]");
|
SVG_ERROR("not know " << outputType << " value : \"" << outputValue << "\", not in [miter,round,bevel]");
|
||||||
}
|
}
|
||||||
} else if (outputType == "marker-start") {
|
} 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
|
* @param[in] _inputData Data C String with the xml definition
|
||||||
* @return the parsed color
|
* @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;
|
draw::Color localColor = draw::color::white;
|
||||||
|
|
||||||
if( _inputData.size() > 4
|
if( _inputData.size() > 4
|
||||||
@ -402,16 +394,14 @@ draw::Color esvg::Base::parseColor(const etk::UString& _inputData)
|
|||||||
* @param[in] _element standart XML node
|
* @param[in] _element standart XML node
|
||||||
* @return true if no problem arrived
|
* @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");
|
SVG_ERROR("NOT IMPLEMENTED");
|
||||||
_sizeMax.setValue(0,0);
|
_sizeMax.setValue(0,0);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * esvg::Base::SpacingDist(int32_t _spacing)
|
const char * esvg::Base::spacingDist(int32_t _spacing) {
|
||||||
{
|
|
||||||
static const char *tmpValue = " ";
|
static const char *tmpValue = " ";
|
||||||
if (_spacing>20) {
|
if (_spacing>20) {
|
||||||
_spacing = 20;
|
_spacing = 20;
|
||||||
|
16
esvg/Base.h
16
esvg/Base.h
@ -28,23 +28,21 @@
|
|||||||
#include <agg/agg_color_rgba.h>
|
#include <agg/agg_color_rgba.h>
|
||||||
#include <agg/agg_pixfmt_rgba.h>
|
#include <agg/agg_pixfmt_rgba.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
class Base {
|
||||||
class Base
|
|
||||||
{
|
|
||||||
protected:
|
protected:
|
||||||
PaintState m_paint;
|
PaintState m_paint;
|
||||||
agg::trans_affine m_transformMatrix; //!< specific render of the curent element
|
agg::trans_affine m_transformMatrix; //!< specific render of the curent element
|
||||||
const char * SpacingDist(int32_t _spacing);
|
const char * spacingDist(int32_t _spacing);
|
||||||
public:
|
public:
|
||||||
Base(void) {};
|
Base(void) {};
|
||||||
Base(PaintState _parentPaintState);
|
Base(PaintState _parentPaintState);
|
||||||
virtual ~Base(void) { };
|
virtual ~Base(void) { };
|
||||||
virtual bool parse(exml::Element * _element, 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 ...
|
//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 parseTransform(exml::Element *_element);
|
||||||
void parsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size);
|
void parsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size);
|
||||||
float parseLength(const etk::UString& _dataInput);
|
float parseLength(const etk::UString& _dataInput);
|
||||||
|
@ -14,18 +14,15 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Circle"
|
#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_radius = 0.0;
|
||||||
m_position.setValue(0,0);
|
m_position.setValue(0,0);
|
||||||
if (NULL == _element) {
|
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");
|
SVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is not present");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 > m_radius) {
|
if (0 > m_radius) {
|
||||||
m_radius = 0;
|
m_radius = 0;
|
||||||
SVG_ERROR("(l "<<_element->getPos()<<") Circle \"r\" is negative");
|
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;
|
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));
|
_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
|
// Creating an ellipse
|
||||||
|
@ -11,10 +11,8 @@
|
|||||||
|
|
||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
class Circle : public esvg::Base {
|
||||||
class Circle : public esvg::Base
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
etk::Vector2D<float> m_position; //!< Position of the Circle
|
etk::Vector2D<float> m_position; //!< Position of the Circle
|
||||||
float m_radius; //!< Radius of the Circle
|
float m_radius; //!< Radius of the Circle
|
||||||
@ -22,8 +20,8 @@ namespace esvg
|
|||||||
Circle(PaintState _parentPaintState);
|
Circle(PaintState _parentPaintState);
|
||||||
~Circle(void);
|
~Circle(void);
|
||||||
virtual bool parse(exml::Element * _element, 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 display(int32_t _spacing);
|
||||||
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,18 +14,15 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Ellipse"
|
#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) {
|
if (NULL == _element) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -65,14 +62,12 @@ bool esvg::Ellipse::parse(exml::Element * _element, agg::trans_affine& _parentTr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Ellipse::Display(int32_t _spacing)
|
void esvg::Ellipse::display(int32_t _spacing) {
|
||||||
{
|
SVG_DEBUG(spacingDist(_spacing) << "Ellipse c=" << m_c << " r=" << m_r);
|
||||||
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));
|
_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
|
// Creating an ellipse
|
||||||
agg::ellipse myEllipse(m_c.x(), m_c.y(), m_r.x(), m_r.y(), 0);
|
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);
|
_myRenderer.m_rasterizer.add_path(trans);
|
||||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_paint.strokeWidth > 0 && m_paint.stroke.a!=0x00 ) {
|
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
|
// 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);
|
_myRenderer.m_rasterizer.add_path(transStroke);
|
||||||
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
agg::render_scanlines(_myRenderer.m_rasterizer, _myRenderer.m_scanLine, *_myRenderer.m_renderArea);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,19 +11,17 @@
|
|||||||
|
|
||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
class Ellipse : public esvg::Base {
|
||||||
class Ellipse : public esvg::Base
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
etk::Vector2D<float> m_c; //!< Center property of the ellipse
|
etk::Vector2D<float> m_c; //!< Center property of the ellipse
|
||||||
etk::Vector2D<float> m_r; //!< Radius property of the ellipse
|
etk::Vector2D<float> m_r; //!< Radius property of the ellipse
|
||||||
public:
|
public:
|
||||||
Ellipse(PaintState _parentPaintState);
|
Ellipse(PaintState _parentPaintState);
|
||||||
~Ellipse(void);
|
~Ellipse(void);
|
||||||
virtual bool parse(exml::Element * _element, 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 display(int32_t _spacing);
|
||||||
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,18 +23,15 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Group"
|
#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) {
|
if (NULL == _element) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -82,13 +79,13 @@ bool esvg::Group::parse(exml::Element * _element, agg::trans_affine& _parentTran
|
|||||||
} else if (child->getValue() == "text") {
|
} else if (child->getValue() == "text") {
|
||||||
elementParser = new esvg::Text(m_paint);
|
elementParser = new esvg::Text(m_paint);
|
||||||
} else {
|
} else {
|
||||||
SVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->GetValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
|
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) {
|
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 {
|
} else {
|
||||||
if (false == elementParser->parse(child, m_transformMatrix, tmpPos)) {
|
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);
|
delete(elementParser);
|
||||||
elementParser = NULL;
|
elementParser = NULL;
|
||||||
} else {
|
} else {
|
||||||
@ -102,22 +99,21 @@ bool esvg::Group::parse(exml::Element * _element, agg::trans_affine& _parentTran
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Group::Display(int32_t _spacing)
|
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 );
|
||||||
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++) {
|
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
|
||||||
if (NULL != m_subElementList[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++) {
|
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
|
||||||
if (NULL != m_subElementList[iii]) {
|
if (NULL != m_subElementList[iii]) {
|
||||||
m_subElementList[iii]->AggDraw(_myRenderer, _basicTrans);
|
m_subElementList[iii]->aggDraw(_myRenderer, _basicTrans);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
10
esvg/Group.h
10
esvg/Group.h
@ -12,18 +12,16 @@
|
|||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <etk/Vector.h>
|
#include <etk/Vector.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
class Group : public esvg::Base {
|
||||||
class Group : public esvg::Base
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
etk::Vector<esvg::Base *> m_subElementList; //!< group sub elements ...
|
etk::Vector<esvg::Base *> m_subElementList; //!< group sub elements ...
|
||||||
public:
|
public:
|
||||||
Group(PaintState _parentPaintState);
|
Group(PaintState _parentPaintState);
|
||||||
~Group(void);
|
~Group(void);
|
||||||
virtual bool parse(exml::Element * _element, 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 display(int32_t spacing);
|
||||||
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,19 +14,16 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Line"
|
#define __class__ "Line"
|
||||||
|
|
||||||
esvg::Line::Line(PaintState parentPaintState) : esvg::Base(parentPaintState)
|
esvg::Line::Line(PaintState _parentPaintState) : esvg::Base(_parentPaintState) {
|
||||||
{
|
|
||||||
m_startPos.setValue(0,0);
|
m_startPos.setValue(0,0);
|
||||||
m_stopPos.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...
|
// line must have a minimum size...
|
||||||
m_paint.strokeWidth = 1;
|
m_paint.strokeWidth = 1;
|
||||||
if (NULL == _element) {
|
if (NULL == _element) {
|
||||||
@ -59,14 +56,11 @@ bool esvg::Line::parse(exml::Element * _element, agg::trans_affine& _parentTrans
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Line::Display(int32_t _spacing)
|
void esvg::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 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;
|
agg::path_storage path;
|
||||||
path.start_new_path();
|
path.start_new_path();
|
||||||
path.move_to(m_startPos.x(), m_startPos.y());
|
path.move_to(m_startPos.x(), m_startPos.y());
|
||||||
|
18
esvg/Line.h
18
esvg/Line.h
@ -11,19 +11,17 @@
|
|||||||
|
|
||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
class Line : public esvg::Base {
|
||||||
class Line : public esvg::Base
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
etk::Vector2D<float> m_startPos; //!< Start line position
|
etk::Vector2D<float> m_startPos; //!< Start line position
|
||||||
etk::Vector2D<float> m_stopPos; //!< Stop line position
|
etk::Vector2D<float> m_stopPos; //!< Stop line position
|
||||||
public:
|
public:
|
||||||
Line(PaintState parentPaintState);
|
Line(PaintState _parentPaintState);
|
||||||
~Line(void);
|
~Line(void);
|
||||||
virtual bool parse(exml::Element * _element, 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 display(int32_t _spacing);
|
||||||
virtual void AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
324
esvg/Path.cpp
324
esvg/Path.cpp
@ -17,47 +17,44 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Path"
|
#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)
|
// 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') {
|
||||||
if (*input == '\0') {
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
outputList.clear();
|
_outputList.clear();
|
||||||
cmd = '\0';
|
_cmd = '\0';
|
||||||
const char * outputPointer = NULL;
|
const char * outputPointer = NULL;
|
||||||
if (!( (input[0] <= 'Z' && input[0] >= 'A') || (input[0] <= 'z' && input[0] >= 'a') ) ) {
|
if (!( (_input[0] <= 'Z' && _input[0] >= 'A') || (_input[0] <= 'z' && _input[0] >= 'a') ) ) {
|
||||||
SVG_ERROR("Error in the SVG Path : \"" << input << "\"");
|
SVG_ERROR("Error in the SVG Path : \"" << _input << "\"");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
cmd = input[0];
|
_cmd = _input[0];
|
||||||
SVG_VERBOSE("Find command : " << cmd);
|
SVG_VERBOSE("Find command : " << _cmd);
|
||||||
if (input[1] == '\0') {
|
if (_input[1] == '\0') {
|
||||||
return &input[1];
|
return &_input[1];
|
||||||
}
|
}
|
||||||
int32_t iii=1;
|
int32_t iii=1;
|
||||||
// extract every float separated by a ' ' or a ','
|
// extract every float separated by a ' ' or a ','
|
||||||
float element;
|
float element;
|
||||||
char spacer[10];
|
char spacer[10];
|
||||||
int32_t nbElementRead;
|
int32_t nbElementRead;
|
||||||
while( sscanf(&input[iii], "%1[, ]%f%n", spacer, &element, &nbElementRead) == 2
|
while( sscanf(&_input[iii], "%1[, ]%f%n", spacer, &element, &nbElementRead) == 2
|
||||||
|| sscanf(&input[iii], "%f%n", &element, &nbElementRead) == 1) {
|
|| sscanf(&_input[iii], "%f%n", &element, &nbElementRead) == 1) {
|
||||||
SVG_VERBOSE("Find element : " << element);
|
SVG_VERBOSE("Find element : " << element);
|
||||||
outputList.pushBack(element);
|
_outputList.pushBack(element);
|
||||||
iii += nbElementRead;
|
iii += nbElementRead;
|
||||||
}
|
}
|
||||||
outputPointer = &input[iii];
|
outputPointer = &_input[iii];
|
||||||
while(*outputPointer!= '\0' && *outputPointer == ' ') {
|
while(*outputPointer!= '\0' && *outputPointer == ' ') {
|
||||||
outputPointer++;
|
outputPointer++;
|
||||||
}
|
}
|
||||||
@ -65,8 +62,7 @@ const char * extractCmd(const char* input, char& cmd, etk::Vector<float>& output
|
|||||||
return outputPointer;
|
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) {
|
if (NULL == _element) {
|
||||||
return false;
|
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);
|
for( const char *sss=extractCmd(elementXML, command, listDot);
|
||||||
NULL != sss;
|
NULL != sss;
|
||||||
sss=extractCmd(sss, command, listDot) ) {
|
sss=extractCmd(sss, command, listDot) ) {
|
||||||
pathBasic_ts pathElement;
|
PathBasic pathElement;
|
||||||
memset(&pathElement, 0, 1*sizeof(pathBasic_ts));
|
|
||||||
switch(command) {
|
switch(command) {
|
||||||
case 'M': // Move to (absolute)
|
case 'M': // Move to (absolute)
|
||||||
case 'L': // Line 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 'S': // smooth curve to (absolute)
|
||||||
case 'A': // elliptical Arc (absolute)
|
case 'A': // elliptical Arc (absolute)
|
||||||
case 'Z': // closepath (absolute)
|
case 'Z': // closepath (absolute)
|
||||||
pathElement.relative = false;
|
pathElement.m_relative = false;
|
||||||
break;
|
break;
|
||||||
default : // else (relative)
|
default : // else (relative)
|
||||||
pathElement.relative = true;
|
pathElement.m_relative = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch(command) {
|
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() );
|
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pathElement.cmd = esvg::PATH_ENUM_MOVETO;
|
pathElement.m_cmd = esvg::pathMoveTo;
|
||||||
if (listDot.size() >= 2) {
|
if (listDot.size() >= 2) {
|
||||||
pathElement.element[0] = listDot[0];
|
pathElement.m_element[0] = listDot[0];
|
||||||
pathElement.element[1] = listDot[1];
|
pathElement.m_element[1] = listDot[1];
|
||||||
m_listElement.pushBack(pathElement);
|
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) {
|
for(int32_t iii=2; iii<listDot.size(); iii+=2) {
|
||||||
pathElement.element[0] = listDot[iii];
|
pathElement.m_element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.m_element[1] = listDot[iii+1];
|
||||||
m_listElement.pushBack(pathElement);
|
m_listElement.pushBack(pathElement);
|
||||||
}
|
}
|
||||||
break;
|
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() );
|
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pathElement.cmd = esvg::PATH_ENUM_LINETO;
|
pathElement.m_cmd = esvg::pathLineTo;
|
||||||
for(int32_t iii=0; iii<listDot.size(); iii+=2) {
|
for(int32_t iii=0; iii<listDot.size(); iii+=2) {
|
||||||
pathElement.element[0] = listDot[iii];
|
pathElement.m_element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.m_element[1] = listDot[iii+1];
|
||||||
m_listElement.pushBack(pathElement);
|
m_listElement.pushBack(pathElement);
|
||||||
}
|
}
|
||||||
break;
|
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() );
|
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pathElement.cmd = esvg::PATH_ENUM_LINETO_V;
|
pathElement.m_cmd = esvg::pathLineToV;
|
||||||
for(int32_t iii=0; iii<listDot.size(); iii+=1) {
|
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);
|
m_listElement.pushBack(pathElement);
|
||||||
}
|
}
|
||||||
break;
|
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() );
|
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pathElement.cmd = esvg::PATH_ENUM_LINETO_H;
|
pathElement.m_cmd = esvg::pathLineToH;
|
||||||
for(int32_t iii=0; iii<listDot.size(); iii+=1) {
|
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);
|
m_listElement.pushBack(pathElement);
|
||||||
}
|
}
|
||||||
break;
|
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() );
|
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pathElement.cmd = esvg::PATH_ENUM_BEZIER_CURVETO;
|
pathElement.m_cmd = esvg::pathBesizeCurveTo;
|
||||||
for(int32_t iii=0; iii<listDot.size(); iii+=4) {
|
for(int32_t iii=0; iii<listDot.size(); iii+=4) {
|
||||||
pathElement.element[0] = listDot[iii];
|
pathElement.m_element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.m_element[1] = listDot[iii+1];
|
||||||
pathElement.element[2] = listDot[iii+2];
|
pathElement.m_element[2] = listDot[iii+2];
|
||||||
pathElement.element[3] = listDot[iii+3];
|
pathElement.m_element[3] = listDot[iii+3];
|
||||||
m_listElement.pushBack(pathElement);
|
m_listElement.pushBack(pathElement);
|
||||||
}
|
}
|
||||||
break;
|
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() );
|
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pathElement.cmd = esvg::PATH_ENUM_BEZIER_SMOTH_CURVETO;
|
pathElement.m_cmd = esvg::pathBesizeSmothCurveTo;
|
||||||
for(int32_t iii=0; iii<listDot.size(); iii+=2) {
|
for(int32_t iii=0; iii<listDot.size(); iii+=2) {
|
||||||
pathElement.element[0] = listDot[iii];
|
pathElement.m_element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.m_element[1] = listDot[iii+1];
|
||||||
m_listElement.pushBack(pathElement);
|
m_listElement.pushBack(pathElement);
|
||||||
}
|
}
|
||||||
break;
|
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() );
|
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pathElement.cmd = esvg::PATH_ENUM_CURVETO;
|
pathElement.m_cmd = esvg::pathCurveTo;
|
||||||
for(int32_t iii=0; iii<listDot.size(); iii+=6) {
|
for(int32_t iii=0; iii<listDot.size(); iii+=6) {
|
||||||
pathElement.element[0] = listDot[iii];
|
pathElement.m_element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.m_element[1] = listDot[iii+1];
|
||||||
pathElement.element[2] = listDot[iii+2];
|
pathElement.m_element[2] = listDot[iii+2];
|
||||||
pathElement.element[3] = listDot[iii+3];
|
pathElement.m_element[3] = listDot[iii+3];
|
||||||
pathElement.element[4] = listDot[iii+4];
|
pathElement.m_element[4] = listDot[iii+4];
|
||||||
pathElement.element[5] = listDot[iii+5];
|
pathElement.m_element[5] = listDot[iii+5];
|
||||||
m_listElement.pushBack(pathElement);
|
m_listElement.pushBack(pathElement);
|
||||||
}
|
}
|
||||||
break;
|
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() );
|
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pathElement.cmd = esvg::PATH_ENUM_SMOTH_CURVETO;
|
pathElement.m_cmd = esvg::pathSmothCurveTo;
|
||||||
for(int32_t iii=0; iii<listDot.size(); iii+=4) {
|
for(int32_t iii=0; iii<listDot.size(); iii+=4) {
|
||||||
pathElement.element[0] = listDot[iii];
|
pathElement.m_element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.m_element[1] = listDot[iii+1];
|
||||||
pathElement.element[2] = listDot[iii+2];
|
pathElement.m_element[2] = listDot[iii+2];
|
||||||
pathElement.element[3] = listDot[iii+3];
|
pathElement.m_element[3] = listDot[iii+3];
|
||||||
m_listElement.pushBack(pathElement);
|
m_listElement.pushBack(pathElement);
|
||||||
}
|
}
|
||||||
break;
|
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() );
|
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pathElement.cmd = esvg::PATH_ENUM_ELLIPTIC;
|
pathElement.m_cmd = esvg::pathElliptic;
|
||||||
for(int32_t iii=0; iii<listDot.size(); iii+=7) {
|
for(int32_t iii=0; iii<listDot.size(); iii+=7) {
|
||||||
pathElement.element[0] = listDot[iii];
|
pathElement.m_element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.m_element[1] = listDot[iii+1];
|
||||||
pathElement.element[2] = listDot[iii+2];
|
pathElement.m_element[2] = listDot[iii+2];
|
||||||
pathElement.element[3] = listDot[iii+3];
|
pathElement.m_element[3] = listDot[iii+3];
|
||||||
pathElement.element[4] = listDot[iii+4];
|
pathElement.m_element[4] = listDot[iii+4];
|
||||||
pathElement.element[5] = listDot[iii+5];
|
pathElement.m_element[5] = listDot[iii+5];
|
||||||
pathElement.element[6] = listDot[iii+6];
|
pathElement.m_element[6] = listDot[iii+6];
|
||||||
m_listElement.pushBack(pathElement);
|
m_listElement.pushBack(pathElement);
|
||||||
}
|
}
|
||||||
break;
|
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() );
|
SVG_WARNING("the PATH command "<< command << " has not the good number of element = " << listDot.size() );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
pathElement.cmd = esvg::PATH_ENUM_STOP;
|
pathElement.m_cmd = esvg::pathStop;
|
||||||
m_listElement.pushBack(pathElement);
|
m_listElement.pushBack(pathElement);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -282,64 +277,60 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Path::Display(int32_t _spacing)
|
void esvg::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++) {
|
for(int32_t iii=0; iii<m_listElement.size(); iii++) {
|
||||||
switch (m_listElement[iii].cmd) {
|
switch (m_listElement[iii].m_cmd) {
|
||||||
case PATH_ENUM_STOP:
|
case esvg::pathStop:
|
||||||
SVG_DEBUG(SpacingDist(_spacing+4) << "STOP");
|
SVG_DEBUG(spacingDist(_spacing+4) << "STOP");
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_MOVETO:
|
case esvg::pathMoveTo:
|
||||||
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].m_element[0] << "," << m_listElement[iii].m_element[1] << ")" );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_LINETO:
|
case esvg::pathLineTo:
|
||||||
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].m_element[0] << "," << m_listElement[iii].m_element[1] << ")" );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_LINETO_H:
|
case esvg::pathLineToH:
|
||||||
SVG_DEBUG(SpacingDist(_spacing+4) << "LINETO_H (" << m_listElement[iii].element[0] << ")" );
|
SVG_DEBUG(spacingDist(_spacing+4) << "LINETO_H (" << m_listElement[iii].m_element[0] << ")" );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_LINETO_V:
|
case esvg::pathLineToV:
|
||||||
SVG_DEBUG(SpacingDist(_spacing+4) << "LINETO_V (" << m_listElement[iii].element[0] << ")" );
|
SVG_DEBUG(spacingDist(_spacing+4) << "LINETO_V (" << m_listElement[iii].m_element[0] << ")" );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_CURVETO:
|
case esvg::pathCurveTo:
|
||||||
SVG_DEBUG(SpacingDist(_spacing+4) << "CURVETO (" << m_listElement[iii].element[0] <<
|
SVG_DEBUG(spacingDist(_spacing+4) << "CURVETO (" << m_listElement[iii].m_element[0] <<
|
||||||
"," << m_listElement[iii].element[1] <<
|
"," << m_listElement[iii].m_element[1] <<
|
||||||
"," << m_listElement[iii].element[2] <<
|
"," << m_listElement[iii].m_element[2] <<
|
||||||
"," << m_listElement[iii].element[3] <<
|
"," << m_listElement[iii].m_element[3] <<
|
||||||
"," << m_listElement[iii].element[4] <<
|
"," << m_listElement[iii].m_element[4] <<
|
||||||
"," << m_listElement[iii].element[5] << ")" );
|
"," << m_listElement[iii].m_element[5] << ")" );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_SMOTH_CURVETO:
|
case esvg::pathSmothCurveTo:
|
||||||
SVG_DEBUG(SpacingDist(_spacing+4) << "SMOTH_CURVETO (" << m_listElement[iii].element[0] <<
|
SVG_DEBUG(spacingDist(_spacing+4) << "SMOTH_CURVETO (" << m_listElement[iii].m_element[0] <<
|
||||||
"," << m_listElement[iii].element[1] <<
|
"," << m_listElement[iii].m_element[1] <<
|
||||||
"," << m_listElement[iii].element[2] <<
|
"," << m_listElement[iii].m_element[2] <<
|
||||||
"," << m_listElement[iii].element[3] << ")" );
|
"," << m_listElement[iii].m_element[3] << ")" );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_BEZIER_CURVETO:
|
case esvg::pathBesizeCurveTo:
|
||||||
SVG_DEBUG(SpacingDist(_spacing+4) << "BEZIER_CURVETO (" << m_listElement[iii].element[0] <<
|
SVG_DEBUG(spacingDist(_spacing+4) << "BEZIER_CURVETO (" << m_listElement[iii].m_element[0] <<
|
||||||
"," << m_listElement[iii].element[1] <<
|
"," << m_listElement[iii].m_element[1] <<
|
||||||
"," << m_listElement[iii].element[2] <<
|
"," << m_listElement[iii].m_element[2] <<
|
||||||
"," << m_listElement[iii].element[3] << ")" );
|
"," << m_listElement[iii].m_element[3] << ")" );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_BEZIER_SMOTH_CURVETO:
|
case esvg::pathBesizeSmothCurveTo:
|
||||||
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].m_element[0] << "," << m_listElement[iii].m_element[1] << ")" );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_ELLIPTIC:
|
case esvg::pathElliptic:
|
||||||
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
|
// show explanation at : http://www.w3.org/TR/SVG/paths.html#PathDataEllipticalArcCommands
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
SVG_DEBUG(SpacingDist(_spacing+4) << "????" );
|
SVG_DEBUG(spacingDist(_spacing+4) << "????" );
|
||||||
break;
|
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));
|
_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;
|
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++) {
|
for(int32_t iii=0; iii<m_listElement.size(); iii++) {
|
||||||
switch (m_listElement[iii].cmd) {
|
switch (m_listElement[iii].m_cmd) {
|
||||||
case PATH_ENUM_STOP:
|
case esvg::pathStop:
|
||||||
AbstractCloseSubpath(path);
|
abstractCloseSubpath(path);
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_MOVETO:
|
case esvg::pathMoveTo:
|
||||||
AbstractMoveTo(path, m_listElement[iii].relative,
|
abstractMoveTo(path, m_listElement[iii].m_relative,
|
||||||
m_listElement[iii].element[0],
|
m_listElement[iii].m_element[0],
|
||||||
m_listElement[iii].element[1] );
|
m_listElement[iii].m_element[1] );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_LINETO:
|
case esvg::pathLineTo:
|
||||||
AbstractLineTo(path, m_listElement[iii].relative,
|
abstractLineTo(path, m_listElement[iii].m_relative,
|
||||||
m_listElement[iii].element[0],
|
m_listElement[iii].m_element[0],
|
||||||
m_listElement[iii].element[1] );
|
m_listElement[iii].m_element[1] );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_LINETO_H:
|
case esvg::pathLineToH:
|
||||||
AbstractHLineTo(path, m_listElement[iii].relative,
|
abstractHLineTo(path, m_listElement[iii].m_relative,
|
||||||
m_listElement[iii].element[0] );
|
m_listElement[iii].m_element[0] );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_LINETO_V:
|
case esvg::pathLineToV:
|
||||||
AbstractVLineTo(path, m_listElement[iii].relative,
|
abstractVLineTo(path, m_listElement[iii].m_relative,
|
||||||
m_listElement[iii].element[0] );
|
m_listElement[iii].m_element[0] );
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_CURVETO:
|
case esvg::pathCurveTo:
|
||||||
AbstractCurve4(path, m_listElement[iii].relative,
|
abstractCurve4(path, m_listElement[iii].m_relative,
|
||||||
m_listElement[iii].element[0],
|
m_listElement[iii].m_element[0],
|
||||||
m_listElement[iii].element[1],
|
m_listElement[iii].m_element[1],
|
||||||
m_listElement[iii].element[2],
|
m_listElement[iii].m_element[2],
|
||||||
m_listElement[iii].element[3],
|
m_listElement[iii].m_element[3],
|
||||||
m_listElement[iii].element[4],
|
m_listElement[iii].m_element[4],
|
||||||
m_listElement[iii].element[5] );
|
m_listElement[iii].m_element[5] );
|
||||||
//SVG_INFO(" draw : PATH_ENUM_CURVETO");
|
//SVG_INFO(" draw : esvg::pathCurveTo");
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_SMOTH_CURVETO:
|
case esvg::pathSmothCurveTo:
|
||||||
AbstractCurve4(path, m_listElement[iii].relative,
|
abstractCurve4(path, m_listElement[iii].m_relative,
|
||||||
m_listElement[iii].element[0],
|
m_listElement[iii].m_element[0],
|
||||||
m_listElement[iii].element[1],
|
m_listElement[iii].m_element[1],
|
||||||
m_listElement[iii].element[2],
|
m_listElement[iii].m_element[2],
|
||||||
m_listElement[iii].element[3] );
|
m_listElement[iii].m_element[3] );
|
||||||
//SVG_INFO(" draw : PATH_ENUM_SMOTH_CURVETO");
|
//SVG_INFO(" draw : esvg::pathSmothCurveTo");
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_BEZIER_CURVETO:
|
case esvg::pathBesizeCurveTo:
|
||||||
AbstractCurve3(path, m_listElement[iii].relative,
|
abstractCurve3(path, m_listElement[iii].m_relative,
|
||||||
m_listElement[iii].element[0],
|
m_listElement[iii].m_element[0],
|
||||||
m_listElement[iii].element[1],
|
m_listElement[iii].m_element[1],
|
||||||
m_listElement[iii].element[2],
|
m_listElement[iii].m_element[2],
|
||||||
m_listElement[iii].element[3] );
|
m_listElement[iii].m_element[3] );
|
||||||
//SVG_INFO(" draw : PATH_ENUM_BEZIER_CURVETO");
|
//SVG_INFO(" draw : esvg::pathBesizeCurveTo");
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_BEZIER_SMOTH_CURVETO:
|
case esvg::pathBesizeSmothCurveTo:
|
||||||
AbstractCurve3(path, m_listElement[iii].relative,
|
abstractCurve3(path, m_listElement[iii].m_relative,
|
||||||
m_listElement[iii].element[0],
|
m_listElement[iii].m_element[0],
|
||||||
m_listElement[iii].element[1] );
|
m_listElement[iii].m_element[1] );
|
||||||
//SVG_INFO(" draw : PATH_ENUM_BEZIER_SMOTH_CURVETO");
|
//SVG_INFO(" draw : esvg::pathBesizeSmothCurveTo");
|
||||||
break;
|
break;
|
||||||
case PATH_ENUM_ELLIPTIC:
|
case esvg::pathElliptic:
|
||||||
SVG_TODO("Elliptic arc is not implemented NOW ...");
|
SVG_TODO("Elliptic arc is not implemented NOW ...");
|
||||||
break;
|
break;
|
||||||
default:
|
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) {
|
if(true == _rel) {
|
||||||
_path.rel_to_abs(&_x, &_y);
|
_path.rel_to_abs(&_x, &_y);
|
||||||
}
|
}
|
||||||
_path.move_to(_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) {
|
if(true == _rel) {
|
||||||
_path.rel_to_abs(&_x, &_y);
|
_path.rel_to_abs(&_x, &_y);
|
||||||
}
|
}
|
||||||
_path.line_to(_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 x2 = 0.0;
|
||||||
double y2 = 0.0;
|
double y2 = 0.0;
|
||||||
if(0!=_path.total_vertices()) {
|
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 x2 = 0.0;
|
||||||
double y2 = 0.0;
|
double y2 = 0.0;
|
||||||
if(_path.total_vertices()) {
|
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) {
|
if(true == _rel) {
|
||||||
_path.rel_to_abs(&_x1, &_y1);
|
_path.rel_to_abs(&_x1, &_y1);
|
||||||
_path.rel_to_abs(&_x, &_y);
|
_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);
|
_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) {
|
if(true == _rel) {
|
||||||
_path.curve3_rel(_x, _y);
|
_path.curve3_rel(_x, _y);
|
||||||
} else {
|
} 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) {
|
if(true == _rel) {
|
||||||
_path.rel_to_abs(&_x1, &_y1);
|
_path.rel_to_abs(&_x1, &_y1);
|
||||||
_path.rel_to_abs(&_x2, &_y2);
|
_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);
|
_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) {
|
if(true == _rel) {
|
||||||
_path.curve4_rel(_x2, _y2, _x, _y);
|
_path.curve4_rel(_x2, _y2, _x, _y);
|
||||||
} else {
|
} 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);
|
_path.end_poly(agg::path_flags_close);
|
||||||
}
|
}
|
||||||
|
72
esvg/Path.h
72
esvg/Path.h
@ -12,47 +12,49 @@
|
|||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <agg/agg_path_storage.h>
|
#include <agg/agg_path_storage.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
enum pathProperty{
|
||||||
typedef enum {
|
pathStop,
|
||||||
PATH_ENUM_STOP,
|
pathMoveTo,
|
||||||
PATH_ENUM_MOVETO,
|
pathLineTo,
|
||||||
PATH_ENUM_LINETO,
|
pathLineToH,
|
||||||
PATH_ENUM_LINETO_H,
|
pathLineToV,
|
||||||
PATH_ENUM_LINETO_V,
|
pathCurveTo,
|
||||||
PATH_ENUM_CURVETO,
|
pathSmothCurveTo,
|
||||||
PATH_ENUM_SMOTH_CURVETO,
|
pathBesizeCurveTo,
|
||||||
PATH_ENUM_BEZIER_CURVETO,
|
pathBesizeSmothCurveTo,
|
||||||
PATH_ENUM_BEZIER_SMOTH_CURVETO,
|
pathElliptic
|
||||||
PATH_ENUM_ELLIPTIC,
|
};
|
||||||
} pathEnum_te;
|
class PathBasic {
|
||||||
|
public:
|
||||||
typedef struct {
|
PathBasic(void) : m_cmd(esvg::pathStop), m_relative(false) {
|
||||||
pathEnum_te cmd;
|
for(int32_t iii=0; iii<7; ++iii) {
|
||||||
bool relative;
|
m_element[iii] = 0;
|
||||||
float element[7];
|
}
|
||||||
}pathBasic_ts;
|
}
|
||||||
|
enum pathProperty m_cmd;
|
||||||
class Path : public esvg::Base
|
bool m_relative;
|
||||||
{
|
float m_element[7];
|
||||||
|
};
|
||||||
|
class Path : public esvg::Base {
|
||||||
private:
|
private:
|
||||||
etk::Vector<pathBasic_ts> m_listElement;
|
etk::Vector<PathBasic> m_listElement;
|
||||||
public:
|
public:
|
||||||
Path(PaintState _parentPaintState);
|
Path(PaintState _parentPaintState);
|
||||||
~Path(void);
|
~Path(void);
|
||||||
virtual bool parse(exml::Element * _element, 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 display(int32_t _spacing);
|
||||||
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
private:
|
private:
|
||||||
void AbstractMoveTo(agg::path_storage& _path, bool _rel, double _x, double _y);
|
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 abstractLineTo(agg::path_storage& _path, bool _rel, double _x, double _y);
|
||||||
void AbstractHLineTo(agg::path_storage& _path, bool _rel, double _x);
|
void abstractHLineTo(agg::path_storage& _path, bool _rel, double _x);
|
||||||
void AbstractVLineTo(agg::path_storage& _path, bool _rel, double _y);
|
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 _x1, double _y1, double _x, double _y);
|
||||||
void AbstractCurve3(agg::path_storage& _path, bool _rel, 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 _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 abstractCurve4(agg::path_storage& _path, bool _rel, double _x2, double _y2, double _x, double _y);
|
||||||
void AbstractCloseSubpath(agg::path_storage& _path);
|
void abstractCloseSubpath(agg::path_storage& _path);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -14,18 +14,15 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Polygon"
|
#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) {
|
if (NULL == _element) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -66,13 +63,11 @@ bool esvg::Polygon::parse(exml::Element * _element, agg::trans_affine& _parentTr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Polygon::Display(int32_t _spacing)
|
void esvg::Polygon::display(int32_t _spacing) {
|
||||||
{
|
SVG_DEBUG(spacingDist(_spacing) << "Polygon nbPoint=" << m_listPoint.size());
|
||||||
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));
|
_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;
|
agg::path_storage path;
|
||||||
|
@ -12,23 +12,21 @@
|
|||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <etk/Vector.h>
|
#include <etk/Vector.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
enum polygonMode {
|
||||||
typedef enum {
|
polygoneModeNonZero,
|
||||||
POLYGONE_MODE__NON_ZERO,
|
polygoneModeEvenOdd
|
||||||
POLYGONE_MODE__EVEN_ODD,
|
};
|
||||||
} PolygonMode_te;
|
class Polygon : public esvg::Base {
|
||||||
class Polygon : public esvg::Base
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
etk::Vector<etk::Vector2D<float> > m_listPoint; //!< list of all point of the polygone
|
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:
|
public:
|
||||||
Polygon(PaintState parentPaintState);
|
Polygon(PaintState parentPaintState);
|
||||||
~Polygon(void);
|
~Polygon(void);
|
||||||
virtual bool parse(exml::Element * _element, 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 display(int32_t spacing);
|
||||||
virtual void AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
virtual void aggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,18 +11,15 @@
|
|||||||
#include <agg/agg_conv_stroke.h>
|
#include <agg/agg_conv_stroke.h>
|
||||||
#include <agg/agg_path_storage.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...
|
// line must have a minimum size...
|
||||||
m_paint.strokeWidth = 1;
|
m_paint.strokeWidth = 1;
|
||||||
if (NULL == _element) {
|
if (NULL == _element) {
|
||||||
@ -58,14 +55,12 @@ bool esvg::Polyline::parse(exml::Element * _element, agg::trans_affine& _parentT
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Polyline::Display(int32_t _spacing)
|
void esvg::Polyline::display(int32_t _spacing) {
|
||||||
{
|
SVG_DEBUG(spacingDist(_spacing) << "Polyline nbPoint=" << m_listPoint.size());
|
||||||
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;
|
agg::path_storage path;
|
||||||
path.start_new_path();
|
path.start_new_path();
|
||||||
path.move_to(m_listPoint[0].x(), m_listPoint[0].y());
|
path.move_to(m_listPoint[0].x(), m_listPoint[0].y());
|
||||||
|
@ -12,18 +12,16 @@
|
|||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <etk/Vector.h>
|
#include <etk/Vector.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
class Polyline : public esvg::Base {
|
||||||
class Polyline : public esvg::Base
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
etk::Vector<etk::Vector2D<float> > m_listPoint; //!< list of all point of the polyline
|
etk::Vector<etk::Vector2D<float> > m_listPoint; //!< list of all point of the polyline
|
||||||
public:
|
public:
|
||||||
Polyline(PaintState _parentPaintState);
|
Polyline(PaintState _parentPaintState);
|
||||||
~Polyline(void);
|
~Polyline(void);
|
||||||
virtual bool parse(exml::Element * _element, 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 display(int32_t _spacing);
|
||||||
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,20 +15,17 @@
|
|||||||
#define __class__ "Rectangle"
|
#define __class__ "Rectangle"
|
||||||
|
|
||||||
|
|
||||||
esvg::Rectangle::Rectangle(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
|
esvg::Rectangle::Rectangle(PaintState _parentPaintState) : esvg::Base(_parentPaintState) {
|
||||||
{
|
|
||||||
m_position.setValue(0,0);
|
m_position.setValue(0,0);
|
||||||
m_size.setValue(0,0);
|
m_size.setValue(0,0);
|
||||||
m_roundedCorner.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) {
|
if (NULL == _element) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -57,13 +54,11 @@ bool esvg::Rectangle::parse(exml::Element * _element, agg::trans_affine& _parent
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Rectangle::Display(int32_t _spacing)
|
void esvg::Rectangle::display(int32_t _spacing) {
|
||||||
{
|
SVG_DEBUG(spacingDist(_spacing) << "Rectangle : pos=" << m_position << " size=" << m_size << " corner=" << m_roundedCorner);
|
||||||
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));
|
_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
|
// 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());
|
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());
|
||||||
|
@ -11,10 +11,8 @@
|
|||||||
|
|
||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
class Rectangle : public esvg::Base {
|
||||||
class Rectangle : public esvg::Base
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
etk::Vector2D<float> m_position; //!< position of the rectangle
|
etk::Vector2D<float> m_position; //!< position of the rectangle
|
||||||
etk::Vector2D<float> m_size; //!< size of the rectangle
|
etk::Vector2D<float> m_size; //!< size of the rectangle
|
||||||
@ -23,8 +21,8 @@ namespace esvg
|
|||||||
Rectangle(PaintState _parentPaintState);
|
Rectangle(PaintState _parentPaintState);
|
||||||
~Rectangle(void);
|
~Rectangle(void);
|
||||||
virtual bool parse(exml::Element * _element, 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 display(int32_t _spacing);
|
||||||
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -10,13 +10,12 @@
|
|||||||
#include <esvg/Renderer.h>
|
#include <esvg/Renderer.h>
|
||||||
|
|
||||||
// 4 is for the RGBA ...
|
// 4 is for the RGBA ...
|
||||||
#define DATA_ALLOCATION_ELEMENT (4)
|
#define DATA_ALLOCATION_ELEMENT (4)
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Renderer"
|
#define __class__ "Renderer"
|
||||||
|
|
||||||
esvg::Renderer::Renderer(uint32_t width, uint32_t height)
|
esvg::Renderer::Renderer(uint32_t width, uint32_t height) {
|
||||||
{
|
|
||||||
m_allocatedSize = 0;
|
m_allocatedSize = 0;
|
||||||
m_size.setValue(width, height);
|
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);
|
//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) {
|
if (NULL != m_buffer) {
|
||||||
delete[] m_buffer;
|
delete[] m_buffer;
|
||||||
m_buffer = NULL;
|
m_buffer = NULL;
|
||||||
@ -77,8 +75,7 @@ esvg::Renderer::~Renderer(void)
|
|||||||
// Writing the buffer to a .PPM file, assuming it has
|
// Writing the buffer to a .PPM file, assuming it has
|
||||||
// RGB-structure, one byte per color component
|
// 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) {
|
if (NULL == m_buffer) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -24,18 +24,17 @@
|
|||||||
#include <agg/agg_color_rgba.h>
|
#include <agg/agg_color_rgba.h>
|
||||||
#include <agg/agg_pixfmt_rgba.h>
|
#include <agg/agg_pixfmt_rgba.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
enum lineCap{
|
||||||
typedef enum {
|
lineCapButt,
|
||||||
LINECAP_BUTT,
|
lineCapRound,
|
||||||
LINECAP_ROUND,
|
lineCapSquare
|
||||||
LINECAP_SQUARE,
|
};
|
||||||
} lineCap_te;
|
enum lineJoin{
|
||||||
typedef enum {
|
lineJoinMiter,
|
||||||
LINEJOIN_MITER,
|
lineJoinRound,
|
||||||
LINEJOIN_ROUND,
|
lineJoinBevel
|
||||||
LINEJOIN_BEVEL,
|
};
|
||||||
} lineJoin_te;
|
|
||||||
|
|
||||||
class PaintState {
|
class PaintState {
|
||||||
public:
|
public:
|
||||||
@ -43,8 +42,8 @@ namespace esvg
|
|||||||
draw::Color stroke;
|
draw::Color stroke;
|
||||||
float strokeWidth;
|
float strokeWidth;
|
||||||
bool flagEvenOdd;
|
bool flagEvenOdd;
|
||||||
lineCap_te lineCap;
|
enum esvg::lineCap lineCap;
|
||||||
lineJoin_te lineJoin;
|
enum esvg::lineJoin lineJoin;
|
||||||
etk::Vector2D<float> viewPort;
|
etk::Vector2D<float> viewPort;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -59,7 +58,7 @@ namespace esvg
|
|||||||
public:
|
public:
|
||||||
Renderer(uint32_t width, uint32_t height);
|
Renderer(uint32_t width, uint32_t height);
|
||||||
~Renderer(void);
|
~Renderer(void);
|
||||||
void WritePpm(etk::UString fileName);
|
void writePpm(etk::UString fileName);
|
||||||
etk::Vector2D<float> m_size;
|
etk::Vector2D<float> m_size;
|
||||||
agg::rendering_buffer * m_renderingBuffer;
|
agg::rendering_buffer * m_renderingBuffer;
|
||||||
agg::pixfmt_rgba32 * m_pixFrame;
|
agg::pixfmt_rgba32 * m_pixFrame;
|
||||||
|
@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,26 +12,22 @@
|
|||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Text"
|
#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);
|
_sizeMax.setValue(0,0);
|
||||||
SVG_ERROR("NOT IMPLEMENTED");
|
SVG_ERROR("NOT IMPLEMENTED");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void esvg::Text::Display(int32_t _spacing)
|
void esvg::Text::display(int32_t _spacing) {
|
||||||
{
|
SVG_DEBUG(spacingDist(_spacing) << "Text");
|
||||||
SVG_DEBUG(SpacingDist(_spacing) << "Text");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
10
esvg/Text.h
10
esvg/Text.h
@ -11,17 +11,13 @@
|
|||||||
|
|
||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
class Text : public esvg::Base {
|
||||||
class Text : public esvg::Base
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Text(PaintState _parentPaintState);
|
Text(PaintState _parentPaintState);
|
||||||
~Text(void);
|
~Text(void);
|
||||||
virtual bool parse(exml::Element * _element, 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 display(int32_t _spacing);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,11 +32,10 @@
|
|||||||
|
|
||||||
|
|
||||||
#undef __class__
|
#undef __class__
|
||||||
#define __class__ "Document"
|
#define __class__ "Document"
|
||||||
|
|
||||||
|
|
||||||
esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL)
|
esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL) {
|
||||||
{
|
|
||||||
m_fileName = _fileName;
|
m_fileName = _fileName;
|
||||||
m_version = "0.0";
|
m_version = "0.0";
|
||||||
m_loadOK = true;
|
m_loadOK = true;
|
||||||
@ -46,12 +45,12 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
|
|||||||
m_paint.strokeWidth = 1.0;
|
m_paint.strokeWidth = 1.0;
|
||||||
m_paint.viewPort.setValue(255,255);
|
m_paint.viewPort.setValue(255,255);
|
||||||
m_paint.flagEvenOdd = false;
|
m_paint.flagEvenOdd = false;
|
||||||
m_paint.lineJoin = esvg::LINEJOIN_MITER;
|
m_paint.lineJoin = esvg::lineJoinMiter;
|
||||||
m_paint.lineCap = esvg::LINECAP_BUTT;
|
m_paint.lineCap = esvg::lineCapButt;
|
||||||
m_size.setValue(0,0);
|
m_size.setValue(0,0);
|
||||||
|
|
||||||
exml::Document doc;
|
exml::Document doc;
|
||||||
if (false == doc.Load(m_fileName)) {
|
if (false == doc.load(m_fileName)) {
|
||||||
SVG_ERROR("Error occured when loading XML : " << m_fileName);
|
SVG_ERROR("Error occured when loading XML : " << m_fileName);
|
||||||
m_loadOK = false;
|
m_loadOK = false;
|
||||||
return;
|
return;
|
||||||
@ -121,14 +120,14 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
|
|||||||
// Node ignore : generaly inkscape data
|
// Node ignore : generaly inkscape data
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
SVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->GetValue()<<"\" must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
|
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) {
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
if (false == elementParser->parse(child, m_transformMatrix, size)) {
|
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);
|
delete(elementParser);
|
||||||
elementParser = NULL;
|
elementParser = NULL;
|
||||||
continue;
|
continue;
|
||||||
@ -150,8 +149,7 @@ esvg::Document::Document(const etk::UString& _fileName) : m_renderedElement(NULL
|
|||||||
//DisplayDebug();
|
//DisplayDebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
esvg::Document::~Document(void)
|
esvg::Document::~Document(void) {
|
||||||
{
|
|
||||||
if(NULL != m_renderedElement) {
|
if(NULL != m_renderedElement) {
|
||||||
delete(m_renderedElement);
|
delete(m_renderedElement);
|
||||||
m_renderedElement = NULL;
|
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);
|
SVG_DEBUG("Main SVG node : size=" << m_size);
|
||||||
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
|
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
|
||||||
if (NULL != m_subElementList[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++) {
|
for (int32_t iii=0; iii<m_subElementList.size(); iii++) {
|
||||||
if (NULL != m_subElementList[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)
|
void esvg::Document::generateTestFile(void)
|
||||||
{
|
{
|
||||||
int32_t sizeX = m_size.x();
|
int32_t sizeX = m_size.x();
|
||||||
if (SizeX == 0) {
|
if (sizeX == 0) {
|
||||||
sizeX = 64;
|
sizeX = 64;
|
||||||
}
|
}
|
||||||
int32_t sizeY = m_size.y();
|
int32_t sizeY = m_size.y();
|
||||||
if (SizeY == 0) {
|
if (sizeY == 0) {
|
||||||
sizeY = 64;
|
sizeY = 64;
|
||||||
}
|
}
|
||||||
if(NULL != m_renderedElement) {
|
if(NULL != m_renderedElement) {
|
||||||
delete(m_renderedElement);
|
delete(m_renderedElement);
|
||||||
m_renderedElement = NULL;
|
m_renderedElement = NULL;
|
||||||
}
|
}
|
||||||
m_renderedElement = new esvg::Renderer(SizeX, sizeY);
|
m_renderedElement = new esvg::Renderer(sizeX, sizeY);
|
||||||
// create the first element matrix modification ...
|
// create the first element matrix modification ...
|
||||||
agg::trans_affine basicTrans;
|
agg::trans_affine basicTrans;
|
||||||
//basicTrans *= agg::trans_affine_translation(-g_base_dx, -g_base_dy);
|
//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);
|
//basicTrans *= agg::trans_affine_translation(width/3, height/3);
|
||||||
|
|
||||||
|
|
||||||
AggDraw(*m_renderedElement, basicTrans);
|
aggDraw(*m_renderedElement, basicTrans);
|
||||||
etk::UString tmpFileOut = "yyy_out_";
|
etk::UString tmpFileOut = "yyy_out_";
|
||||||
tmpFileOut += m_fileName;
|
tmpFileOut += m_fileName;
|
||||||
tmpFileOut += ".ppm";
|
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;
|
int32_t sizeX = _sizeX;
|
||||||
if (SizeX == 0) {
|
if (sizeX == 0) {
|
||||||
SVG_ERROR("SizeX == 0 ==> set 64");
|
SVG_ERROR("SizeX == 0 ==> set 64");
|
||||||
sizeX = 64;
|
sizeX = 64;
|
||||||
}
|
}
|
||||||
int32_t sizeY = sizeY;
|
int32_t sizeY = _sizeY;
|
||||||
if (SizeY == 0) {
|
if (sizeY == 0) {
|
||||||
SVG_ERROR("SizeY == 0 ==> set 64");
|
SVG_ERROR("SizeY == 0 ==> set 64");
|
||||||
sizeY = 64;
|
sizeY = 64;
|
||||||
}
|
}
|
||||||
SVG_INFO("Generate size (" << sizeX << "," << SizeY << ")");
|
SVG_INFO("Generate size (" << sizeX << "," << sizeY << ")");
|
||||||
if(NULL != m_renderedElement) {
|
if(NULL != m_renderedElement) {
|
||||||
delete(m_renderedElement);
|
delete(m_renderedElement);
|
||||||
m_renderedElement = NULL;
|
m_renderedElement = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_renderedElement = new esvg::Renderer(SizeX, sizeY);
|
m_renderedElement = new esvg::Renderer(sizeX, sizeY);
|
||||||
// create the first element matrix modification ...
|
// create the first element matrix modification ...
|
||||||
agg::trans_affine basicTrans;
|
agg::trans_affine basicTrans;
|
||||||
//basicTrans *= agg::trans_affine_translation(-g_base_dx, -g_base_dy);
|
//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_rotation(g_angle);// + agg::pi);
|
||||||
//basicTrans *= agg::trans_affine_skewing(2.0, 5.0);
|
//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*0.3, height/2);
|
||||||
//basicTrans *= agg::trans_affine_translation(width/3, height/3);
|
//basicTrans *= agg::trans_affine_translation(width/3, height/3);
|
||||||
|
|
||||||
AggDraw(*m_renderedElement, basicTrans);
|
aggDraw(*m_renderedElement, basicTrans);
|
||||||
/*
|
/*
|
||||||
etk::UString tmpFileOut = "zzz_out_test.ppm";
|
etk::UString tmpFileOut = "zzz_out_test.ppm";
|
||||||
m_renderedElement->WritePpm(tmpFileOut);
|
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());
|
generateAnImage(_size.x(), _size.y());
|
||||||
output.Resize(size);
|
_output.resize(_size);
|
||||||
draw::Color tmpp(0,0,0,0);
|
draw::Color tmpp(0,0,0,0);
|
||||||
output.setFillColor(tmpp);
|
_output.setFillColor(tmpp);
|
||||||
output.clear();
|
_output.clear();
|
||||||
if(NULL != m_renderedElement) {
|
if(NULL != m_renderedElement) {
|
||||||
uint8_t* pointerOnData = m_renderedElement->getDataPointer();
|
uint8_t* pointerOnData = m_renderedElement->getDataPointer();
|
||||||
int32_t sizeData = m_renderedElement->getDataSize();
|
int32_t sizeData = m_renderedElement->getDataSize();
|
||||||
uint8_t* tmpOut = (uint8_t*)output.getTextureDataPointer();
|
uint8_t* tmpOut = (uint8_t*)_output.getTextureDataPointer();
|
||||||
memcpy(tmpOut, pointerOnData, sizeData);
|
memcpy(tmpOut, pointerOnData, sizeData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
11
esvg/esvg.h
11
esvg/esvg.h
@ -17,10 +17,8 @@
|
|||||||
#include <esvg/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <draw/Image.h>
|
#include <draw/Image.h>
|
||||||
|
|
||||||
namespace esvg
|
namespace esvg {
|
||||||
{
|
class Document : public esvg::Base {
|
||||||
class Document : public esvg::Base
|
|
||||||
{
|
|
||||||
private:
|
private:
|
||||||
etk::UString m_fileName;
|
etk::UString m_fileName;
|
||||||
bool m_loadOK;
|
bool m_loadOK;
|
||||||
@ -29,17 +27,16 @@ namespace esvg
|
|||||||
etk::Vector<esvg::Base *> m_subElementList;
|
etk::Vector<esvg::Base *> m_subElementList;
|
||||||
vec2 m_size;
|
vec2 m_size;
|
||||||
esvg::Renderer* m_renderedElement;
|
esvg::Renderer* m_renderedElement;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Document(const etk::UString& _fileName);
|
Document(const etk::UString& _fileName);
|
||||||
~Document(void);
|
~Document(void);
|
||||||
bool isLoadOk(void) { return m_loadOK; };
|
bool isLoadOk(void) { return m_loadOK; };
|
||||||
void DisplayDebug(void);
|
void displayDebug(void);
|
||||||
void generateTestFile(void);
|
void generateTestFile(void);
|
||||||
void generateAnImage(int32_t _sizeX, int32_t _sizeY);
|
void generateAnImage(int32_t _sizeX, int32_t _sizeY);
|
||||||
void generateAnImage(ivec2 _size, draw::Image& _output);
|
void generateAnImage(ivec2 _size, draw::Image& _output);
|
||||||
void generateAnImage(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);
|
uint8_t* getPointerOnData(void);
|
||||||
uint32_t getSizeOnData(void);
|
uint32_t getSizeOnData(void);
|
||||||
vec2 getDefinedSize(void) { return m_size;};
|
vec2 getDefinedSize(void) { return m_size;};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user