[DEV] rename big and corect use of exml
This commit is contained in:
parent
521843f38f
commit
7081b72812
@ -7,17 +7,17 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
svg::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 svg::Base::ParseTransform(exml::Element* _element)
|
void esvg::Base::ParseTransform(exml::Element* _element)
|
||||||
{
|
{
|
||||||
if (NULL == _element) {
|
if (NULL == _element) {
|
||||||
return;
|
return;
|
||||||
@ -85,7 +85,7 @@ void svg::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 svg::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);
|
||||||
@ -117,8 +117,9 @@ void svg::Base::ParsePosition(const exml::Element *_element, etk::Vector2D<float
|
|||||||
* @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 svg::Base::ParseLength(const etk::UString& _dataInput)
|
float esvg::Base::ParseLength(const etk::UString& _dataInput)
|
||||||
{
|
{
|
||||||
|
SVG_DEBUG(" lenght : '" << _dataInput << "'");
|
||||||
float n = _dataInput.ToFloat();
|
float n = _dataInput.ToFloat();
|
||||||
etk::UString unit;
|
etk::UString unit;
|
||||||
for (int32_t iii=0; iii<_dataInput.Size(); iii++) {
|
for (int32_t iii=0; iii<_dataInput.Size(); iii++) {
|
||||||
@ -128,11 +129,12 @@ float svg::Base::ParseLength(const etk::UString& _dataInput)
|
|||||||
|| _dataInput[iii]<='.') {
|
|| _dataInput[iii]<='.') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
unit = _dataInput.Extract(iii);
|
unit = _dataInput.Extract(iii-1);
|
||||||
}
|
}
|
||||||
//SVG_INFO(" ==> ?? = " << n );
|
//SVG_INFO(" ==> ?? = " << n );
|
||||||
float font_size = 20.0f;
|
float font_size = 20.0f;
|
||||||
|
|
||||||
|
SVG_DEBUG(" lenght : '" << n << "' => unit=" << unit);
|
||||||
// note : ";" is for the parsing of the style elements ...
|
// note : ";" is for the parsing of the style elements ...
|
||||||
if( unit.Size()==0
|
if( unit.Size()==0
|
||||||
|| unit[0] == ';' ) {
|
|| unit[0] == ';' ) {
|
||||||
@ -164,12 +166,17 @@ int32_t extractPartOfStyle(const etk::UString& _data, etk::UString& _outputType,
|
|||||||
{
|
{
|
||||||
_outputType = "";
|
_outputType = "";
|
||||||
_outputData = "";
|
_outputData = "";
|
||||||
|
if (_pos==-1) {
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
int32_t typeStart = _pos;
|
int32_t typeStart = _pos;
|
||||||
int32_t typeStop = _pos;
|
int32_t typeStop = _pos;
|
||||||
int32_t dataStart = _pos;
|
int32_t dataStart = _pos;
|
||||||
int32_t dataStop = _pos;
|
int32_t dataStop = _pos;
|
||||||
bool processFirst=true;
|
bool processFirst=true;
|
||||||
|
//SVG_DEBUG("parse : '" << _data.Extract(_pos) << "'");
|
||||||
for( int32_t iii=_pos; iii<_data.Size(); iii++) {
|
for( int32_t iii=_pos; iii<_data.Size(); iii++) {
|
||||||
|
//SVG_DEBUG(" ? '" << _data[iii] << "'");
|
||||||
if (_data[iii] == ';') {
|
if (_data[iii] == ';') {
|
||||||
// end of the element
|
// end of the element
|
||||||
return iii+1;
|
return iii+1;
|
||||||
@ -186,6 +193,7 @@ int32_t extractPartOfStyle(const etk::UString& _data, etk::UString& _outputType,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
SVG_DEBUG(" extract : '" << _outputType << "':'" << _outputData << "'");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,7 +201,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 svg::Base::ParsePaintAttr(const exml::Element *_element)
|
void esvg::Base::ParsePaintAttr(const exml::Element *_element)
|
||||||
{
|
{
|
||||||
if (_element==NULL) {
|
if (_element==NULL) {
|
||||||
return;
|
return;
|
||||||
@ -250,26 +258,26 @@ void svg::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 = svg::LINECAP_BUTT;
|
m_paint.lineCap = esvg::LINECAP_BUTT;
|
||||||
} else if (content == "round" ) {
|
} else if (content == "round" ) {
|
||||||
m_paint.lineCap = svg::LINECAP_ROUND;
|
m_paint.lineCap = esvg::LINECAP_ROUND;
|
||||||
} else if (content == "square" ) {
|
} else if (content == "square" ) {
|
||||||
m_paint.lineCap = svg::LINECAP_SQUARE;
|
m_paint.lineCap = esvg::LINECAP_SQUARE;
|
||||||
} else {
|
} else {
|
||||||
m_paint.lineCap = svg::LINECAP_BUTT;
|
m_paint.lineCap = esvg::LINECAP_BUTT;
|
||||||
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 = svg::LINEJOIN_MITER;
|
m_paint.lineJoin = esvg::LINEJOIN_MITER;
|
||||||
} else if (content == "round" ) {
|
} else if (content == "round" ) {
|
||||||
m_paint.lineJoin = svg::LINEJOIN_ROUND;
|
m_paint.lineJoin = esvg::LINEJOIN_ROUND;
|
||||||
} else if (content == "bevel" ) {
|
} else if (content == "bevel" ) {
|
||||||
m_paint.lineJoin = svg::LINEJOIN_BEVEL;
|
m_paint.lineJoin = esvg::LINEJOIN_BEVEL;
|
||||||
} else {
|
} else {
|
||||||
m_paint.lineJoin = svg::LINEJOIN_MITER;
|
m_paint.lineJoin = esvg::LINEJOIN_MITER;
|
||||||
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]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -278,8 +286,8 @@ void svg::Base::ParsePaintAttr(const exml::Element *_element)
|
|||||||
etk::UString outputType;
|
etk::UString outputType;
|
||||||
etk::UString outputValue;
|
etk::UString outputValue;
|
||||||
|
|
||||||
for( int32_t sss=extractPartOfStyle(content, outputType, outputValue, 1024);
|
for( int32_t sss=extractPartOfStyle(content, outputType, outputValue, 0);
|
||||||
-1 != sss;
|
-2 != sss;
|
||||||
sss=extractPartOfStyle(content, outputType, outputValue, sss) ) {
|
sss=extractPartOfStyle(content, outputType, outputValue, sss) ) {
|
||||||
SVG_VERBOSE(" style parse : \"" << outputType << "\" with value : \"" << outputValue << "\"");
|
SVG_VERBOSE(" style parse : \"" << outputType << "\" with value : \"" << outputValue << "\"");
|
||||||
if (outputType == "fill") {
|
if (outputType == "fill") {
|
||||||
@ -323,24 +331,24 @@ void svg::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 = svg::LINECAP_BUTT;
|
m_paint.lineCap = esvg::LINECAP_BUTT;
|
||||||
} else if (outputValue == "round") {
|
} else if (outputValue == "round") {
|
||||||
m_paint.lineCap = svg::LINECAP_ROUND;
|
m_paint.lineCap = esvg::LINECAP_ROUND;
|
||||||
} else if (outputValue == "square") {
|
} else if (outputValue == "square") {
|
||||||
m_paint.lineCap = svg::LINECAP_SQUARE;
|
m_paint.lineCap = esvg::LINECAP_SQUARE;
|
||||||
} else {
|
} else {
|
||||||
m_paint.lineCap = svg::LINECAP_BUTT;
|
m_paint.lineCap = esvg::LINECAP_BUTT;
|
||||||
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 = svg::LINEJOIN_MITER;
|
m_paint.lineJoin = esvg::LINEJOIN_MITER;
|
||||||
} else if (outputValue == "round") {
|
} else if (outputValue == "round") {
|
||||||
m_paint.lineJoin = svg::LINEJOIN_ROUND;
|
m_paint.lineJoin = esvg::LINEJOIN_ROUND;
|
||||||
} else if (outputValue == "bevel") {
|
} else if (outputValue == "bevel") {
|
||||||
m_paint.lineJoin = svg::LINEJOIN_BEVEL;
|
m_paint.lineJoin = esvg::LINEJOIN_BEVEL;
|
||||||
} else {
|
} else {
|
||||||
m_paint.lineJoin = svg::LINEJOIN_MITER;
|
m_paint.lineJoin = esvg::LINEJOIN_MITER;
|
||||||
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") {
|
||||||
@ -364,7 +372,7 @@ void svg::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 svg::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;
|
||||||
|
|
||||||
@ -390,7 +398,7 @@ draw::Color svg::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 svg::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);
|
||||||
@ -398,7 +406,7 @@ bool svg::Base::Parse(exml::Element * _element, agg::trans_affine& _parentTrans,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char * svg::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) {
|
@ -6,8 +6,8 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_BASE_H__
|
#ifndef __ESVG_BASE_H__
|
||||||
#define __SVG_BASE_H__
|
#define __ESVG_BASE_H__
|
||||||
|
|
||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <etk/Vector.h>
|
#include <etk/Vector.h>
|
||||||
@ -15,7 +15,7 @@
|
|||||||
#include <draw/Color.h>
|
#include <draw/Color.h>
|
||||||
|
|
||||||
#include <exml/exml.h>
|
#include <exml/exml.h>
|
||||||
#include <parserSVG/Renderer.h>
|
#include <esvg/Renderer.h>
|
||||||
|
|
||||||
#include <agg/agg_basics.h>
|
#include <agg/agg_basics.h>
|
||||||
#include <agg/agg_rendering_buffer.h>
|
#include <agg/agg_rendering_buffer.h>
|
||||||
@ -28,7 +28,7 @@
|
|||||||
#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 svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
class Base
|
class Base
|
||||||
{
|
{
|
||||||
@ -42,7 +42,7 @@ namespace svg
|
|||||||
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(svg::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);
|
@ -6,23 +6,23 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/Circle.h>
|
#include <esvg/Circle.h>
|
||||||
#include <agg/agg_conv_stroke.h>
|
#include <agg/agg_conv_stroke.h>
|
||||||
#include <agg/agg_ellipse.h>
|
#include <agg/agg_ellipse.h>
|
||||||
|
|
||||||
|
|
||||||
svg::Circle::Circle(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
esvg::Circle::Circle(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
svg::Circle::~Circle(void)
|
esvg::Circle::~Circle(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool svg::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);
|
||||||
@ -60,13 +60,13 @@ bool svg::Circle::Parse(exml::Element * _element, agg::trans_affine& _parentTran
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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 svg::Circle::AggDraw(svg::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
|
@ -6,14 +6,14 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_CIRCLE_H__
|
#ifndef __ESVG_CIRCLE_H__
|
||||||
#define __SVG_CIRCLE_H__
|
#define __ESVG_CIRCLE_H__
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
class Circle : public svg::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
|
||||||
@ -23,7 +23,7 @@ namespace svg
|
|||||||
~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(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -6,6 +6,6 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
|
|
||||||
const char * parserSVGLibName = "parserSVG";
|
const char * esvgLibName = "esvg ";
|
28
esvg/Debug.h
Normal file
28
esvg/Debug.h
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license BSD v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __EPARSER_SVG_DEBUG_H__
|
||||||
|
#define __EPARSER_SVG_DEBUG_H__
|
||||||
|
|
||||||
|
#include <etk/types.h>
|
||||||
|
#include <etk/Debug.h>
|
||||||
|
|
||||||
|
extern const char * esvgLibName;
|
||||||
|
|
||||||
|
#define SVG_CRITICAL(data) ETK_CRITICAL(esvgLibName, data)
|
||||||
|
#define SVG_WARNING(data) ETK_WARNING(esvgLibName, data)
|
||||||
|
#define SVG_ERROR(data) ETK_ERROR(esvgLibName, data)
|
||||||
|
#define SVG_INFO(data) ETK_INFO(esvgLibName, data)
|
||||||
|
#define SVG_DEBUG(data) ETK_DEBUG(esvgLibName, data)
|
||||||
|
#define SVG_VERBOSE(data) ETK_VERBOSE(esvgLibName, data)
|
||||||
|
#define SVG_ASSERT(cond, data) ETK_ASSERT(esvgLibName, cond, data)
|
||||||
|
#define SVG_CHECK_INOUT(cond) ETK_CHECK_INOUT(esvgLibName, cond)
|
||||||
|
#define SVG_TODO(cond) ETK_TODO(esvgLibName, cond)
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -6,22 +6,22 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/Ellipse.h>
|
#include <esvg/Ellipse.h>
|
||||||
#include <agg/agg_conv_stroke.h>
|
#include <agg/agg_conv_stroke.h>
|
||||||
#include <agg/agg_ellipse.h>
|
#include <agg/agg_ellipse.h>
|
||||||
|
|
||||||
svg::Ellipse::Ellipse(PaintState parentPaintState) : svg::Base(parentPaintState)
|
esvg::Ellipse::Ellipse(PaintState parentPaintState) : esvg::Base(parentPaintState)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
svg::Ellipse::~Ellipse(void)
|
esvg::Ellipse::~Ellipse(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool svg::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;
|
||||||
@ -62,13 +62,13 @@ bool svg::Ellipse::Parse(exml::Element * _element, agg::trans_affine& _parentTra
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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 svg::Ellipse::AggDraw(svg::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
|
@ -6,14 +6,14 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_ELLIPSE_H__
|
#ifndef __ESVG_ELLIPSE_H__
|
||||||
#define __SVG_ELLIPSE_H__
|
#define __ESVG_ELLIPSE_H__
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
class Ellipse : public svg::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
|
||||||
@ -23,7 +23,7 @@ namespace svg
|
|||||||
~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(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -6,31 +6,31 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/Group.h>
|
#include <esvg/Group.h>
|
||||||
#include <etk/UString.h>
|
#include <etk/UString.h>
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <parserSVG/Circle.h>
|
#include <esvg/Circle.h>
|
||||||
#include <parserSVG/Ellipse.h>
|
#include <esvg/Ellipse.h>
|
||||||
#include <parserSVG/Line.h>
|
#include <esvg/Line.h>
|
||||||
#include <parserSVG/Path.h>
|
#include <esvg/Path.h>
|
||||||
#include <parserSVG/Polygon.h>
|
#include <esvg/Polygon.h>
|
||||||
#include <parserSVG/Polyline.h>
|
#include <esvg/Polyline.h>
|
||||||
#include <parserSVG/Rectangle.h>
|
#include <esvg/Rectangle.h>
|
||||||
#include <parserSVG/Text.h>
|
#include <esvg/Text.h>
|
||||||
#include <parserSVG/Group.h>
|
#include <esvg/Group.h>
|
||||||
|
|
||||||
svg::Group::Group(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
esvg::Group::Group(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
svg::Group::~Group(void)
|
esvg::Group::~Group(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool svg::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;
|
||||||
@ -60,27 +60,27 @@ bool svg::Group::Parse(exml::Element * _element, agg::trans_affine& _parentTrans
|
|||||||
// nothing to do, just proceed to next step
|
// nothing to do, just proceed to next step
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
svg::Base *elementParser = NULL;
|
esvg::Base *elementParser = NULL;
|
||||||
if (child->GetValue() == "g") {
|
if (child->GetValue() == "g") {
|
||||||
elementParser = new svg::Group(m_paint);
|
elementParser = new esvg::Group(m_paint);
|
||||||
} else if (child->GetValue() == "a") {
|
} else if (child->GetValue() == "a") {
|
||||||
// TODO ...
|
// TODO ...
|
||||||
} else if (child->GetValue() == "path") {
|
} else if (child->GetValue() == "path") {
|
||||||
elementParser = new svg::Path(m_paint);
|
elementParser = new esvg::Path(m_paint);
|
||||||
} else if (child->GetValue() == "rect") {
|
} else if (child->GetValue() == "rect") {
|
||||||
elementParser = new svg::Rectangle(m_paint);
|
elementParser = new esvg::Rectangle(m_paint);
|
||||||
} else if (child->GetValue() == "circle") {
|
} else if (child->GetValue() == "circle") {
|
||||||
elementParser = new svg::Circle(m_paint);
|
elementParser = new esvg::Circle(m_paint);
|
||||||
} else if (child->GetValue() == "ellipse") {
|
} else if (child->GetValue() == "ellipse") {
|
||||||
elementParser = new svg::Ellipse(m_paint);
|
elementParser = new esvg::Ellipse(m_paint);
|
||||||
} else if (child->GetValue() == "line") {
|
} else if (child->GetValue() == "line") {
|
||||||
elementParser = new svg::Line(m_paint);
|
elementParser = new esvg::Line(m_paint);
|
||||||
} else if (child->GetValue() == "polyline") {
|
} else if (child->GetValue() == "polyline") {
|
||||||
elementParser = new svg::Polyline(m_paint);
|
elementParser = new esvg::Polyline(m_paint);
|
||||||
} else if (child->GetValue() == "polygon") {
|
} else if (child->GetValue() == "polygon") {
|
||||||
elementParser = new svg::Polygon(m_paint);
|
elementParser = new esvg::Polygon(m_paint);
|
||||||
} else if (child->GetValue() == "text") {
|
} else if (child->GetValue() == "text") {
|
||||||
elementParser = new svg::Text(m_paint);
|
elementParser = new esvg::Text(m_paint);
|
||||||
} else {
|
} else {
|
||||||
SVG_ERROR("(l "<<child->Pos()<<") node not suported : \""<<child->GetValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
|
SVG_ERROR("(l "<<child->Pos()<<") node not suported : \""<<child->GetValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ bool svg::Group::Parse(exml::Element * _element, agg::trans_affine& _parentTrans
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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++) {
|
||||||
@ -113,7 +113,7 @@ void svg::Group::Display(int32_t _spacing)
|
|||||||
SVG_DEBUG(SpacingDist(_spacing) << "Group (STOP)");
|
SVG_DEBUG(SpacingDist(_spacing) << "Group (STOP)");
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::Group::AggDraw(svg::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]) {
|
@ -6,24 +6,24 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_GROUP_H__
|
#ifndef __ESVG_GROUP_H__
|
||||||
#define __SVG_GROUP_H__
|
#define __ESVG_GROUP_H__
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <etk/Vector.h>
|
#include <etk/Vector.h>
|
||||||
|
|
||||||
namespace svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
class Group : public svg::Base
|
class Group : public esvg::Base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
etk::Vector<svg::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(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -6,23 +6,23 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/Line.h>
|
#include <esvg/Line.h>
|
||||||
#include <agg/agg_conv_stroke.h>
|
#include <agg/agg_conv_stroke.h>
|
||||||
#include <agg/agg_path_storage.h>
|
#include <agg/agg_path_storage.h>
|
||||||
|
|
||||||
svg::Line::Line(PaintState parentPaintState) : svg::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);
|
||||||
}
|
}
|
||||||
|
|
||||||
svg::Line::~Line(void)
|
esvg::Line::~Line(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool svg::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;
|
||||||
@ -56,13 +56,13 @@ bool svg::Line::Parse(exml::Element * _element, agg::trans_affine& _parentTrans,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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 svg::Line::AggDraw(svg::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();
|
||||||
@ -71,24 +71,24 @@ void svg::Line::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTra
|
|||||||
/*
|
/*
|
||||||
// configure the end of the line :
|
// configure the end of the line :
|
||||||
switch (m_paint.lineCap) {
|
switch (m_paint.lineCap) {
|
||||||
case svg::LINECAP_SQUARE:
|
case esvg::LINECAP_SQUARE:
|
||||||
path.line_cap(agg::square_cap);
|
path.line_cap(agg::square_cap);
|
||||||
break;
|
break;
|
||||||
case svg::LINECAP_ROUND:
|
case esvg::LINECAP_ROUND:
|
||||||
path.line_cap(agg::round_cap);
|
path.line_cap(agg::round_cap);
|
||||||
break;
|
break;
|
||||||
default: // svg::LINECAP_BUTT
|
default: // esvg::LINECAP_BUTT
|
||||||
path.line_cap(agg::butt_cap);
|
path.line_cap(agg::butt_cap);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (m_paint.lineJoin) {
|
switch (m_paint.lineJoin) {
|
||||||
case svg::LINEJOIN_BEVEL:
|
case esvg::LINEJOIN_BEVEL:
|
||||||
path.line_join(agg::bevel_join);
|
path.line_join(agg::bevel_join);
|
||||||
break;
|
break;
|
||||||
case svg::LINEJOIN_ROUND:
|
case esvg::LINEJOIN_ROUND:
|
||||||
path.line_join(agg::round_join);
|
path.line_join(agg::round_join);
|
||||||
break;
|
break;
|
||||||
default: // svg::LINEJOIN_MITER
|
default: // esvg::LINEJOIN_MITER
|
||||||
path.line_join(agg::miter_join);
|
path.line_join(agg::miter_join);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
@ -6,14 +6,14 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_LINE_H__
|
#ifndef __ESVG_LINE_H__
|
||||||
#define __SVG_LINE_H__
|
#define __ESVG_LINE_H__
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
class Line : public svg::Base
|
class Line : public esvg::Base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
etk::Vector2D<float> m_startPos; //!< Start line position
|
etk::Vector2D<float> m_startPos; //!< Start line position
|
||||||
@ -23,7 +23,7 @@ namespace svg
|
|||||||
~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(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
virtual void AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -6,20 +6,20 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/Path.h>
|
#include <esvg/Path.h>
|
||||||
#include <agg/agg_conv_stroke.h>
|
#include <agg/agg_conv_stroke.h>
|
||||||
#include <agg/agg_conv_dash.h>
|
#include <agg/agg_conv_dash.h>
|
||||||
#include <agg/agg_conv_curve.h>
|
#include <agg/agg_conv_curve.h>
|
||||||
#include <agg/agg_conv_contour.h>
|
#include <agg/agg_conv_contour.h>
|
||||||
#include <agg/agg_conv_smooth_poly1.h>
|
#include <agg/agg_conv_smooth_poly1.h>
|
||||||
|
|
||||||
svg::Path::Path(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
esvg::Path::Path(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
svg::Path::~Path(void)
|
esvg::Path::~Path(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -62,7 +62,7 @@ const char * extractCmd(const char* input, char& cmd, etk::Vector<float>& output
|
|||||||
return outputPointer;
|
return outputPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool svg::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;
|
||||||
@ -117,13 +117,13 @@ bool svg::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 = svg::PATH_ENUM_MOVETO;
|
pathElement.cmd = esvg::PATH_ENUM_MOVETO;
|
||||||
if (listDot.Size() >= 2) {
|
if (listDot.Size() >= 2) {
|
||||||
pathElement.element[0] = listDot[0];
|
pathElement.element[0] = listDot[0];
|
||||||
pathElement.element[1] = listDot[1];
|
pathElement.element[1] = listDot[1];
|
||||||
m_listElement.PushBack(pathElement);
|
m_listElement.PushBack(pathElement);
|
||||||
}
|
}
|
||||||
pathElement.cmd = svg::PATH_ENUM_LINETO;
|
pathElement.cmd = esvg::PATH_ENUM_LINETO;
|
||||||
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.element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.element[1] = listDot[iii+1];
|
||||||
@ -138,7 +138,7 @@ bool svg::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 = svg::PATH_ENUM_LINETO;
|
pathElement.cmd = esvg::PATH_ENUM_LINETO;
|
||||||
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.element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.element[1] = listDot[iii+1];
|
||||||
@ -153,7 +153,7 @@ bool svg::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 = svg::PATH_ENUM_LINETO_V;
|
pathElement.cmd = esvg::PATH_ENUM_LINETO_V;
|
||||||
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.element[0] = listDot[iii];
|
||||||
m_listElement.PushBack(pathElement);
|
m_listElement.PushBack(pathElement);
|
||||||
@ -167,7 +167,7 @@ bool svg::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 = svg::PATH_ENUM_LINETO_H;
|
pathElement.cmd = esvg::PATH_ENUM_LINETO_H;
|
||||||
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.element[0] = listDot[iii];
|
||||||
m_listElement.PushBack(pathElement);
|
m_listElement.PushBack(pathElement);
|
||||||
@ -181,7 +181,7 @@ bool svg::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 = svg::PATH_ENUM_BEZIER_CURVETO;
|
pathElement.cmd = esvg::PATH_ENUM_BEZIER_CURVETO;
|
||||||
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.element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.element[1] = listDot[iii+1];
|
||||||
@ -198,7 +198,7 @@ bool svg::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 = svg::PATH_ENUM_BEZIER_SMOTH_CURVETO;
|
pathElement.cmd = esvg::PATH_ENUM_BEZIER_SMOTH_CURVETO;
|
||||||
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.element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.element[1] = listDot[iii+1];
|
||||||
@ -213,7 +213,7 @@ bool svg::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 = svg::PATH_ENUM_CURVETO;
|
pathElement.cmd = esvg::PATH_ENUM_CURVETO;
|
||||||
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.element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.element[1] = listDot[iii+1];
|
||||||
@ -232,7 +232,7 @@ bool svg::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 = svg::PATH_ENUM_SMOTH_CURVETO;
|
pathElement.cmd = esvg::PATH_ENUM_SMOTH_CURVETO;
|
||||||
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.element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.element[1] = listDot[iii+1];
|
||||||
@ -249,7 +249,7 @@ bool svg::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 = svg::PATH_ENUM_ELLIPTIC;
|
pathElement.cmd = esvg::PATH_ENUM_ELLIPTIC;
|
||||||
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.element[0] = listDot[iii];
|
||||||
pathElement.element[1] = listDot[iii+1];
|
pathElement.element[1] = listDot[iii+1];
|
||||||
@ -268,7 +268,7 @@ bool svg::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 = svg::PATH_ENUM_STOP;
|
pathElement.cmd = esvg::PATH_ENUM_STOP;
|
||||||
m_listElement.PushBack(pathElement);
|
m_listElement.PushBack(pathElement);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -279,7 +279,7 @@ bool svg::Path::Parse(exml::Element * _element, agg::trans_affine& _parentTrans,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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++) {
|
||||||
@ -335,7 +335,7 @@ void svg::Path::Display(int32_t _spacing)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void svg::Path::AggDraw(svg::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));
|
||||||
|
|
||||||
@ -432,7 +432,7 @@ void svg::Path::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basicTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void svg::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);
|
||||||
@ -440,7 +440,7 @@ void svg::Path::AbstractMoveTo(agg::path_storage& _path, bool _rel, double _x, d
|
|||||||
_path.move_to(_x, _y);
|
_path.move_to(_x, _y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::Path::AbstractLineTo(agg::path_storage& _path, bool _rel, double _x, double _y)
|
void 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);
|
||||||
@ -448,7 +448,7 @@ void svg::Path::AbstractLineTo(agg::path_storage& _path, bool _rel, double _x, d
|
|||||||
_path.line_to(_x, _y);
|
_path.line_to(_x, _y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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;
|
||||||
@ -461,7 +461,7 @@ void svg::Path::AbstractHLineTo(agg::path_storage& _path, bool _rel, double _x)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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;
|
||||||
@ -474,7 +474,7 @@ void svg::Path::AbstractVLineTo(agg::path_storage& _path, bool _rel, double _y)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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);
|
||||||
@ -483,7 +483,7 @@ void svg::Path::AbstractCurve3(agg::path_storage& _path, bool _rel, double _x1,
|
|||||||
_path.curve3(_x1, _y1, _x, _y);
|
_path.curve3(_x1, _y1, _x, _y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::Path::AbstractCurve3(agg::path_storage& _path, bool _rel, double _x, double _y)
|
void 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);
|
||||||
@ -492,7 +492,7 @@ void svg::Path::AbstractCurve3(agg::path_storage& _path, bool _rel, double _x, d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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);
|
||||||
@ -502,7 +502,7 @@ void svg::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 svg::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);
|
||||||
@ -511,7 +511,7 @@ void svg::Path::AbstractCurve4(agg::path_storage& _path, bool _rel, double _x2,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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);
|
||||||
}
|
}
|
@ -6,13 +6,13 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_PATH_H__
|
#ifndef __ESVG_PATH_H__
|
||||||
#define __SVG_PATH_H__
|
#define __ESVG_PATH_H__
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <agg/agg_path_storage.h>
|
#include <agg/agg_path_storage.h>
|
||||||
|
|
||||||
namespace svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
typedef enum {
|
typedef enum {
|
||||||
PATH_ENUM_STOP,
|
PATH_ENUM_STOP,
|
||||||
@ -33,7 +33,7 @@ namespace svg
|
|||||||
float element[7];
|
float element[7];
|
||||||
}pathBasic_ts;
|
}pathBasic_ts;
|
||||||
|
|
||||||
class Path : public svg::Base
|
class Path : public esvg::Base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
etk::Vector<pathBasic_ts> m_listElement;
|
etk::Vector<pathBasic_ts> m_listElement;
|
||||||
@ -42,7 +42,7 @@ namespace svg
|
|||||||
~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(svg::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);
|
@ -6,22 +6,22 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/Polygon.h>
|
#include <esvg/Polygon.h>
|
||||||
#include <agg/agg_conv_stroke.h>
|
#include <agg/agg_conv_stroke.h>
|
||||||
#include <agg/agg_path_storage.h>
|
#include <agg/agg_path_storage.h>
|
||||||
|
|
||||||
svg::Polygon::Polygon(PaintState parentPaintState) : svg::Base(parentPaintState)
|
esvg::Polygon::Polygon(PaintState parentPaintState) : esvg::Base(parentPaintState)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
svg::Polygon::~Polygon(void)
|
esvg::Polygon::~Polygon(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool svg::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;
|
||||||
@ -63,12 +63,12 @@ bool svg::Polygon::Parse(exml::Element * _element, agg::trans_affine& _parentTra
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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 svg::Polygon::AggDraw(svg::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));
|
||||||
|
|
||||||
@ -83,24 +83,24 @@ void svg::Polygon::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basic
|
|||||||
/*
|
/*
|
||||||
// configure the end of the line :
|
// configure the end of the line :
|
||||||
switch (m_paint.lineCap) {
|
switch (m_paint.lineCap) {
|
||||||
case svg::LINECAP_SQUARE:
|
case esvg::LINECAP_SQUARE:
|
||||||
path.line_cap(agg::square_cap);
|
path.line_cap(agg::square_cap);
|
||||||
break;
|
break;
|
||||||
case svg::LINECAP_ROUND:
|
case esvg::LINECAP_ROUND:
|
||||||
path.line_cap(agg::round_cap);
|
path.line_cap(agg::round_cap);
|
||||||
break;
|
break;
|
||||||
default: // svg::LINECAP_BUTT
|
default: // esvg::LINECAP_BUTT
|
||||||
path.line_cap(agg::butt_cap);
|
path.line_cap(agg::butt_cap);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (m_paint.lineJoin) {
|
switch (m_paint.lineJoin) {
|
||||||
case svg::LINEJOIN_BEVEL:
|
case esvg::LINEJOIN_BEVEL:
|
||||||
path.line_join(agg::bevel_join);
|
path.line_join(agg::bevel_join);
|
||||||
break;
|
break;
|
||||||
case svg::LINEJOIN_ROUND:
|
case esvg::LINEJOIN_ROUND:
|
||||||
path.line_join(agg::round_join);
|
path.line_join(agg::round_join);
|
||||||
break;
|
break;
|
||||||
default: // svg::LINEJOIN_MITER
|
default: // esvg::LINEJOIN_MITER
|
||||||
path.line_join(agg::miter_join);
|
path.line_join(agg::miter_join);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
@ -6,19 +6,19 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_POLYGON_H__
|
#ifndef __ESVG_POLYGON_H__
|
||||||
#define __SVG_POLYGON_H__
|
#define __ESVG_POLYGON_H__
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <etk/Vector.h>
|
#include <etk/Vector.h>
|
||||||
|
|
||||||
namespace svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
typedef enum {
|
typedef enum {
|
||||||
POLYGONE_MODE__NON_ZERO,
|
POLYGONE_MODE__NON_ZERO,
|
||||||
POLYGONE_MODE__EVEN_ODD,
|
POLYGONE_MODE__EVEN_ODD,
|
||||||
} PolygonMode_te;
|
} PolygonMode_te;
|
||||||
class Polygon : public svg::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
|
||||||
@ -28,7 +28,7 @@ namespace svg
|
|||||||
~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(svg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
virtual void AggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -6,22 +6,22 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/Polyline.h>
|
#include <esvg/Polyline.h>
|
||||||
#include <agg/agg_conv_stroke.h>
|
#include <agg/agg_conv_stroke.h>
|
||||||
#include <agg/agg_path_storage.h>
|
#include <agg/agg_path_storage.h>
|
||||||
|
|
||||||
svg::Polyline::Polyline(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
esvg::Polyline::Polyline(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
svg::Polyline::~Polyline(void)
|
esvg::Polyline::~Polyline(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool svg::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;
|
||||||
@ -58,13 +58,13 @@ bool svg::Polyline::Parse(exml::Element * _element, agg::trans_affine& _parentTr
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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 svg::Polyline::AggDraw(svg::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();
|
||||||
@ -75,24 +75,24 @@ void svg::Polyline::AggDraw(svg::Renderer& _myRenderer, agg::trans_affine& _basi
|
|||||||
/*
|
/*
|
||||||
// configure the end of the line :
|
// configure the end of the line :
|
||||||
switch (m_paint.lineCap) {
|
switch (m_paint.lineCap) {
|
||||||
case svg::LINECAP_SQUARE:
|
case esvg::LINECAP_SQUARE:
|
||||||
path.line_cap(agg::square_cap);
|
path.line_cap(agg::square_cap);
|
||||||
break;
|
break;
|
||||||
case svg::LINECAP_ROUND:
|
case esvg::LINECAP_ROUND:
|
||||||
path.line_cap(agg::round_cap);
|
path.line_cap(agg::round_cap);
|
||||||
break;
|
break;
|
||||||
default: // svg::LINECAP_BUTT
|
default: // esvg::LINECAP_BUTT
|
||||||
path.line_cap(agg::butt_cap);
|
path.line_cap(agg::butt_cap);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
switch (m_paint.lineJoin) {
|
switch (m_paint.lineJoin) {
|
||||||
case svg::LINEJOIN_BEVEL:
|
case esvg::LINEJOIN_BEVEL:
|
||||||
path.line_join(agg::bevel_join);
|
path.line_join(agg::bevel_join);
|
||||||
break;
|
break;
|
||||||
case svg::LINEJOIN_ROUND:
|
case esvg::LINEJOIN_ROUND:
|
||||||
path.line_join(agg::round_join);
|
path.line_join(agg::round_join);
|
||||||
break;
|
break;
|
||||||
default: // svg::LINEJOIN_MITER
|
default: // esvg::LINEJOIN_MITER
|
||||||
path.line_join(agg::miter_join);
|
path.line_join(agg::miter_join);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
@ -6,15 +6,15 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_POLYLINE_H__
|
#ifndef __ESVG_POLYLINE_H__
|
||||||
#define __SVG_POLYLINE_H__
|
#define __ESVG_POLYLINE_H__
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <etk/Vector.h>
|
#include <etk/Vector.h>
|
||||||
|
|
||||||
namespace svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
class Polyline : public svg::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
|
||||||
@ -23,7 +23,7 @@ namespace svg
|
|||||||
~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(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
virtual void AggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -6,24 +6,24 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/Rectangle.h>
|
#include <esvg/Rectangle.h>
|
||||||
#include <agg/agg_rounded_rect.h>
|
#include <agg/agg_rounded_rect.h>
|
||||||
#include <agg/agg_conv_stroke.h>
|
#include <agg/agg_conv_stroke.h>
|
||||||
|
|
||||||
svg::Rectangle::Rectangle(PaintState _parentPaintState) : svg::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);
|
||||||
}
|
}
|
||||||
|
|
||||||
svg::Rectangle::~Rectangle(void)
|
esvg::Rectangle::~Rectangle(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool svg::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;
|
||||||
@ -53,12 +53,12 @@ bool svg::Rectangle::Parse(exml::Element * _element, agg::trans_affine& _parentT
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::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 svg::Rectangle::AggDraw(svg::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
|
32
esvg/Rectangle.h
Normal file
32
esvg/Rectangle.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license BSD v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __ESVG_RECTANGLE_H__
|
||||||
|
#define __ESVG_RECTANGLE_H__
|
||||||
|
|
||||||
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
|
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
|
||||||
|
etk::Vector2D<float> m_roundedCorner; //!< property of the rounded corner
|
||||||
|
public:
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -6,13 +6,13 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/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)
|
||||||
|
|
||||||
svg::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);
|
||||||
@ -63,7 +63,7 @@ svg::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);
|
||||||
}
|
}
|
||||||
|
|
||||||
svg::Renderer::~Renderer(void)
|
esvg::Renderer::~Renderer(void)
|
||||||
{
|
{
|
||||||
if (NULL != m_buffer) {
|
if (NULL != m_buffer) {
|
||||||
ETK_FREE(m_buffer);
|
ETK_FREE(m_buffer);
|
||||||
@ -74,7 +74,7 @@ svg::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 svg::Renderer::WritePpm(etk::UString fileName)
|
void esvg::Renderer::WritePpm(etk::UString fileName)
|
||||||
{
|
{
|
||||||
if (NULL == m_buffer) {
|
if (NULL == m_buffer) {
|
||||||
return;
|
return;
|
@ -6,8 +6,8 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_RENDERER_H__
|
#ifndef __ESVG_RENDERER_H__
|
||||||
#define __SVG_RENDERER_H__
|
#define __ESVG_RENDERER_H__
|
||||||
|
|
||||||
#include <etk/UString.h>
|
#include <etk/UString.h>
|
||||||
#include <etk/math/Vector2D.h>
|
#include <etk/math/Vector2D.h>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
#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 svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
typedef enum {
|
typedef enum {
|
||||||
LINECAP_BUTT,
|
LINECAP_BUTT,
|
||||||
@ -39,36 +39,36 @@ namespace svg
|
|||||||
|
|
||||||
class PaintState {
|
class PaintState {
|
||||||
public:
|
public:
|
||||||
draw::Color fill;
|
draw::Color fill;
|
||||||
draw::Color stroke;
|
draw::Color stroke;
|
||||||
float strokeWidth;
|
float strokeWidth;
|
||||||
bool flagEvenOdd;
|
bool flagEvenOdd;
|
||||||
lineCap_te lineCap;
|
lineCap_te lineCap;
|
||||||
lineJoin_te lineJoin;
|
lineJoin_te lineJoin;
|
||||||
etk::Vector2D<float> viewPort;
|
etk::Vector2D<float> viewPort;
|
||||||
};
|
};
|
||||||
|
|
||||||
// basic definition type for the renderer
|
// basic definition type for the renderer
|
||||||
typedef agg::renderer_base<agg::pixfmt_rgba32> rendererBase_t;
|
typedef agg::renderer_base<agg::pixfmt_rgba32> rendererBase_t;
|
||||||
typedef agg::renderer_scanline_aa_solid<rendererBase_t> rendererSolid_t;
|
typedef agg::renderer_scanline_aa_solid<rendererBase_t> rendererSolid_t;
|
||||||
|
|
||||||
class Renderer {
|
class Renderer {
|
||||||
private:
|
private:
|
||||||
uint8_t * m_buffer;
|
uint8_t * m_buffer;
|
||||||
uint32_t m_allocatedSize;
|
uint32_t m_allocatedSize;
|
||||||
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;
|
||||||
rendererBase_t * m_renderBase;
|
rendererBase_t * m_renderBase;
|
||||||
rendererSolid_t * m_renderArea;
|
rendererSolid_t * m_renderArea;
|
||||||
agg::rasterizer_scanline_aa<> m_rasterizer; //!< AGG renderer system
|
agg::rasterizer_scanline_aa<> m_rasterizer; //!< AGG renderer system
|
||||||
agg::scanline_p8 m_scanLine; //!<
|
agg::scanline_p8 m_scanLine; //!<
|
||||||
uint8_t* GetDataPointer(void) { return m_buffer; };
|
uint8_t* GetDataPointer(void) { return m_buffer; };
|
||||||
uint32_t GetDataSize(void) { return m_allocatedSize; };
|
uint32_t GetDataSize(void) { return m_allocatedSize; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -6,12 +6,12 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_STROKING_H__
|
#ifndef __ESVG_STROKING_H__
|
||||||
#define __SVG_STROKING_H__
|
#define __ESVG_STROKING_H__
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
|
|
||||||
};
|
};
|
34
esvg/Text.cpp
Normal file
34
esvg/Text.cpp
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/**
|
||||||
|
* @author Edouard DUPIN
|
||||||
|
*
|
||||||
|
* @copyright 2011, Edouard DUPIN, all right reserved
|
||||||
|
*
|
||||||
|
* @license BSD v3 (see license file)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <esvg/Debug.h>
|
||||||
|
#include <esvg/Text.h>
|
||||||
|
|
||||||
|
esvg::Text::Text(PaintState _parentPaintState) : esvg::Base(_parentPaintState)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
esvg::Text::~Text(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -6,14 +6,14 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_TEXT_H__
|
#ifndef __ESVG_TEXT_H__
|
||||||
#define __SVG_TEXT_H__
|
#define __ESVG_TEXT_H__
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
|
|
||||||
namespace svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
class Text : public svg::Base
|
class Text : public esvg::Base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
@ -6,18 +6,18 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
#include <esvg/Debug.h>
|
||||||
#include <parserSVG/parserSVG.h>
|
#include <esvg/esvg.h>
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <parserSVG/Circle.h>
|
#include <esvg/Circle.h>
|
||||||
#include <parserSVG/Ellipse.h>
|
#include <esvg/Ellipse.h>
|
||||||
#include <parserSVG/Line.h>
|
#include <esvg/Line.h>
|
||||||
#include <parserSVG/Path.h>
|
#include <esvg/Path.h>
|
||||||
#include <parserSVG/Polygon.h>
|
#include <esvg/Polygon.h>
|
||||||
#include <parserSVG/Polyline.h>
|
#include <esvg/Polyline.h>
|
||||||
#include <parserSVG/Rectangle.h>
|
#include <esvg/Rectangle.h>
|
||||||
#include <parserSVG/Text.h>
|
#include <esvg/Text.h>
|
||||||
#include <parserSVG/Group.h>
|
#include <esvg/Group.h>
|
||||||
|
|
||||||
#include <agg/agg_basics.h>
|
#include <agg/agg_basics.h>
|
||||||
#include <agg/agg_rendering_buffer.h>
|
#include <agg/agg_rendering_buffer.h>
|
||||||
@ -30,7 +30,7 @@
|
|||||||
#include <agg/agg_color_rgba.h>
|
#include <agg/agg_color_rgba.h>
|
||||||
#include <agg/agg_pixfmt_rgba.h>
|
#include <agg/agg_pixfmt_rgba.h>
|
||||||
|
|
||||||
svg::Parser::Parser(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";
|
||||||
@ -41,13 +41,11 @@ svg::Parser::Parser(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 = svg::LINEJOIN_MITER;
|
m_paint.lineJoin = esvg::LINEJOIN_MITER;
|
||||||
m_paint.lineCap = svg::LINECAP_BUTT;
|
m_paint.lineCap = esvg::LINECAP_BUTT;
|
||||||
m_size.setValue(0,0);
|
m_size.setValue(0,0);
|
||||||
|
|
||||||
exml::Document doc;
|
exml::Document doc;
|
||||||
|
|
||||||
bool Load(const etk::UString& _file);
|
|
||||||
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;
|
||||||
@ -82,35 +80,35 @@ svg::Parser::Parser(etk::UString _fileName) : m_renderedElement(NULL)
|
|||||||
if (child==NULL) {
|
if (child==NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
svg::Base *elementParser = NULL;
|
esvg::Base *elementParser = NULL;
|
||||||
if (!child->IsElement()) {
|
if (!child->IsElement()) {
|
||||||
// nothing to do, just proceed to next step
|
// nothing to do, just proceed to next step
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (child->GetValue() == "g") {
|
if (child->GetValue() == "g") {
|
||||||
elementParser = new svg::Group(m_paint);
|
elementParser = new esvg::Group(m_paint);
|
||||||
} else if (child->GetValue() == "a") {
|
} else if (child->GetValue() == "a") {
|
||||||
SVG_INFO("Note : 'a' balise is parsed like a g balise ...");
|
SVG_INFO("Note : 'a' balise is parsed like a g balise ...");
|
||||||
elementParser = new svg::Group(m_paint);
|
elementParser = new esvg::Group(m_paint);
|
||||||
} else if (child->GetValue() == "title") {
|
} else if (child->GetValue() == "title") {
|
||||||
m_title = "TODO : set the title here ...";
|
m_title = "TODO : set the title here ...";
|
||||||
continue;
|
continue;
|
||||||
} else if (child->GetValue() == "path") {
|
} else if (child->GetValue() == "path") {
|
||||||
elementParser = new svg::Path(m_paint);
|
elementParser = new esvg::Path(m_paint);
|
||||||
} else if (child->GetValue() == "rect") {
|
} else if (child->GetValue() == "rect") {
|
||||||
elementParser = new svg::Rectangle(m_paint);
|
elementParser = new esvg::Rectangle(m_paint);
|
||||||
} else if (child->GetValue() == "circle") {
|
} else if (child->GetValue() == "circle") {
|
||||||
elementParser = new svg::Circle(m_paint);
|
elementParser = new esvg::Circle(m_paint);
|
||||||
} else if (child->GetValue() == "ellipse") {
|
} else if (child->GetValue() == "ellipse") {
|
||||||
elementParser = new svg::Ellipse(m_paint);
|
elementParser = new esvg::Ellipse(m_paint);
|
||||||
} else if (child->GetValue() == "line") {
|
} else if (child->GetValue() == "line") {
|
||||||
elementParser = new svg::Line(m_paint);
|
elementParser = new esvg::Line(m_paint);
|
||||||
} else if (child->GetValue() == "polyline") {
|
} else if (child->GetValue() == "polyline") {
|
||||||
elementParser = new svg::Polyline(m_paint);
|
elementParser = new esvg::Polyline(m_paint);
|
||||||
} else if (child->GetValue() == "polygon") {
|
} else if (child->GetValue() == "polygon") {
|
||||||
elementParser = new svg::Polygon(m_paint);
|
elementParser = new esvg::Polygon(m_paint);
|
||||||
} else if (child->GetValue() == "text") {
|
} else if (child->GetValue() == "text") {
|
||||||
elementParser = new svg::Text(m_paint);
|
elementParser = new esvg::Text(m_paint);
|
||||||
} else if (child->GetValue() == "defs") {
|
} else if (child->GetValue() == "defs") {
|
||||||
// Node ignore : must implement it later ...
|
// Node ignore : must implement it later ...
|
||||||
continue;
|
continue;
|
||||||
@ -150,7 +148,7 @@ svg::Parser::Parser(etk::UString _fileName) : m_renderedElement(NULL)
|
|||||||
DisplayDebug();
|
DisplayDebug();
|
||||||
}
|
}
|
||||||
|
|
||||||
svg::Parser::~Parser(void)
|
esvg::Document::~Document(void)
|
||||||
{
|
{
|
||||||
if(NULL != m_renderedElement) {
|
if(NULL != m_renderedElement) {
|
||||||
delete(m_renderedElement);
|
delete(m_renderedElement);
|
||||||
@ -160,7 +158,7 @@ svg::Parser::~Parser(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void svg::Parser::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++) {
|
||||||
@ -171,7 +169,7 @@ void svg::Parser::DisplayDebug(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void svg::Parser::AggDraw(svg::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]) {
|
||||||
@ -181,7 +179,7 @@ void svg::Parser::AggDraw(svg::Renderer& myRenderer, agg::trans_affine& basicTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void svg::Parser::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) {
|
||||||
@ -195,7 +193,7 @@ void svg::Parser::GenerateTestFile(void)
|
|||||||
delete(m_renderedElement);
|
delete(m_renderedElement);
|
||||||
m_renderedElement = NULL;
|
m_renderedElement = NULL;
|
||||||
}
|
}
|
||||||
m_renderedElement = new svg::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);
|
||||||
@ -216,7 +214,7 @@ void svg::Parser::GenerateTestFile(void)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
void svg::Parser::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) {
|
||||||
@ -234,7 +232,7 @@ void svg::Parser::GenerateAnImage(int32_t sizeX, int32_t sizeY)
|
|||||||
m_renderedElement = NULL;
|
m_renderedElement = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_renderedElement = new svg::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);
|
||||||
@ -251,12 +249,12 @@ void svg::Parser::GenerateAnImage(int32_t sizeX, int32_t sizeY)
|
|||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void svg::Parser::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 svg::Parser::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);
|
||||||
@ -271,7 +269,7 @@ void svg::Parser::GenerateAnImage(ivec2 size, draw::Image& output)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t* svg::Parser::GetPointerOnData(void)
|
uint8_t* esvg::Document::GetPointerOnData(void)
|
||||||
{
|
{
|
||||||
if(NULL == m_renderedElement) {
|
if(NULL == m_renderedElement) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -279,7 +277,7 @@ uint8_t* svg::Parser::GetPointerOnData(void)
|
|||||||
return m_renderedElement->GetDataPointer();
|
return m_renderedElement->GetDataPointer();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t svg::Parser::GetSizeOnData(void)
|
uint32_t esvg::Document::GetSizeOnData(void)
|
||||||
{
|
{
|
||||||
if(NULL == m_renderedElement) {
|
if(NULL == m_renderedElement) {
|
||||||
return 0;
|
return 0;
|
@ -6,40 +6,40 @@
|
|||||||
* @license BSD v3 (see license file)
|
* @license BSD v3 (see license file)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __SVG_PARSER_H__
|
#ifndef __ESVG_H__
|
||||||
#define __SVG_PARSER_H__
|
#define __ESVG_H__
|
||||||
|
|
||||||
#include <etk/types.h>
|
#include <etk/types.h>
|
||||||
#include <etk/Vector.h>
|
#include <etk/Vector.h>
|
||||||
#include <etk/math/Vector2D.h>
|
#include <etk/math/Vector2D.h>
|
||||||
#include <etk/os/FSNode.h>
|
#include <etk/os/FSNode.h>
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
#include <esvg/Base.h>
|
||||||
#include <draw/Image.h>
|
#include <draw/Image.h>
|
||||||
|
|
||||||
namespace svg
|
namespace esvg
|
||||||
{
|
{
|
||||||
class Parser : public svg::Base
|
class Document : public esvg::Base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
etk::UString m_fileName;
|
etk::UString m_fileName;
|
||||||
bool m_loadOK;
|
bool m_loadOK;
|
||||||
etk::UString m_version;
|
etk::UString m_version;
|
||||||
etk::UString m_title;
|
etk::UString m_title;
|
||||||
etk::Vector<svg::Base *> m_subElementList;
|
etk::Vector<esvg::Base *> m_subElementList;
|
||||||
vec2 m_size;
|
vec2 m_size;
|
||||||
svg::Renderer* m_renderedElement;
|
esvg::Renderer* m_renderedElement;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Parser(etk::UString _fileName);
|
Document(const etk::UString& _fileName);
|
||||||
~Parser(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(svg::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;};
|
@ -13,7 +13,7 @@ are met:
|
|||||||
disclaimer in the documentation and/or other materials provided
|
disclaimer in the documentation and/or other materials provided
|
||||||
with the distribution.
|
with the distribution.
|
||||||
|
|
||||||
* Neither the name of the PARSER-SVG nor the names of its contributors
|
* Neither the name of the esvg nor the names of its contributors
|
||||||
may be used to endorse or promote products derived from this
|
may be used to endorse or promote products derived from this
|
||||||
software without specific prior written permission.
|
software without specific prior written permission.
|
||||||
|
|
||||||
|
36
lutin_esvg.py
Normal file
36
lutin_esvg.py
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/python
|
||||||
|
import lutinModule
|
||||||
|
import lutinTools
|
||||||
|
|
||||||
|
def Create(target):
|
||||||
|
myModule = lutinModule.module(__file__, 'esvg', 'LIBRARY')
|
||||||
|
|
||||||
|
myModule.AddModuleDepend(['etk', 'agg', 'exml'])
|
||||||
|
|
||||||
|
myModule.AddSrcFile([
|
||||||
|
'esvg/Base.cpp',
|
||||||
|
'esvg/Circle.cpp',
|
||||||
|
'esvg/Debug.cpp',
|
||||||
|
'esvg/Ellipse.cpp',
|
||||||
|
'esvg/Group.cpp',
|
||||||
|
'esvg/Line.cpp',
|
||||||
|
'esvg/esvg.cpp',
|
||||||
|
'esvg/Path.cpp',
|
||||||
|
'esvg/Polygon.cpp',
|
||||||
|
'esvg/Polyline.cpp',
|
||||||
|
'esvg/Rectangle.cpp',
|
||||||
|
'esvg/Renderer.cpp',
|
||||||
|
'esvg/Stroking.cpp',
|
||||||
|
'esvg/Text.cpp'])
|
||||||
|
|
||||||
|
myModule.AddExportPath(lutinTools.GetCurrentPath(__file__))
|
||||||
|
|
||||||
|
# add the currrent module at the
|
||||||
|
return myModule
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,39 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import lutinModule
|
|
||||||
import lutinTools
|
|
||||||
|
|
||||||
def Create(target):
|
|
||||||
myModule = lutinModule.module(__file__, 'parsersvg', 'LIBRARY')
|
|
||||||
|
|
||||||
myModule.AddModuleDepend(['etk', 'agg', 'exml'])
|
|
||||||
|
|
||||||
myModule.AddSrcFile([
|
|
||||||
'parserSVG/Base.cpp',
|
|
||||||
'parserSVG/Circle.cpp',
|
|
||||||
'parserSVG/Debug.cpp',
|
|
||||||
'parserSVG/Ellipse.cpp',
|
|
||||||
'parserSVG/Group.cpp',
|
|
||||||
'parserSVG/Line.cpp',
|
|
||||||
'parserSVG/parserSVG.cpp',
|
|
||||||
'parserSVG/Path.cpp',
|
|
||||||
'parserSVG/Polygon.cpp',
|
|
||||||
'parserSVG/Polyline.cpp',
|
|
||||||
'parserSVG/Rectangle.cpp',
|
|
||||||
'parserSVG/Renderer.cpp',
|
|
||||||
'parserSVG/Stroking.cpp',
|
|
||||||
'parserSVG/Text.cpp'])
|
|
||||||
|
|
||||||
myModule.CompileFlags_CC([
|
|
||||||
'-DPARSER_SVG_VERSION_TAG_NAME="todo-Tag"'])
|
|
||||||
|
|
||||||
myModule.AddExportPath(lutinTools.GetCurrentPath(__file__))
|
|
||||||
|
|
||||||
# add the currrent module at the
|
|
||||||
return myModule
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __PARSER_SVG_DEBUG_H__
|
|
||||||
#define __PARSER_SVG_DEBUG_H__
|
|
||||||
|
|
||||||
#include <etk/types.h>
|
|
||||||
#include <etk/Debug.h>
|
|
||||||
|
|
||||||
extern const char * parserSVGLibName;
|
|
||||||
|
|
||||||
#define SVG_CRITICAL(data) ETK_CRITICAL(parserSVGLibName, data)
|
|
||||||
#define SVG_WARNING(data) ETK_WARNING(parserSVGLibName, data)
|
|
||||||
#define SVG_ERROR(data) ETK_ERROR(parserSVGLibName, data)
|
|
||||||
#define SVG_INFO(data) ETK_INFO(parserSVGLibName, data)
|
|
||||||
#define SVG_DEBUG(data) ETK_DEBUG(parserSVGLibName, data)
|
|
||||||
#define SVG_VERBOSE(data) ETK_VERBOSE(parserSVGLibName, data)
|
|
||||||
#define SVG_ASSERT(cond, data) ETK_ASSERT(parserSVGLibName, cond, data)
|
|
||||||
#define SVG_CHECK_INOUT(cond) ETK_CHECK_INOUT(parserSVGLibName, cond)
|
|
||||||
#define SVG_TODO(cond) ETK_TODO(parserSVGLibName, cond)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,32 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __SVG_RECTANGLE_H__
|
|
||||||
#define __SVG_RECTANGLE_H__
|
|
||||||
|
|
||||||
#include <parserSVG/Base.h>
|
|
||||||
|
|
||||||
namespace svg
|
|
||||||
{
|
|
||||||
class Rectangle : public svg::Base
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
etk::Vector2D<float> m_position; //!< position of the rectangle
|
|
||||||
etk::Vector2D<float> m_size; //!< size of the rectangle
|
|
||||||
etk::Vector2D<float> m_roundedCorner; //!< property of the rounded corner
|
|
||||||
public:
|
|
||||||
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(svg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
|||||||
/**
|
|
||||||
* @author Edouard DUPIN
|
|
||||||
*
|
|
||||||
* @copyright 2011, Edouard DUPIN, all right reserved
|
|
||||||
*
|
|
||||||
* @license BSD v3 (see license file)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <parserSVG/Debug.h>
|
|
||||||
#include <parserSVG/Text.h>
|
|
||||||
|
|
||||||
svg::Text::Text(PaintState _parentPaintState) : svg::Base(_parentPaintState)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
svg::Text::~Text(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool svg::Text::Parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax)
|
|
||||||
{
|
|
||||||
_sizeMax.setValue(0,0);
|
|
||||||
SVG_ERROR("NOT IMPLEMENTED");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void svg::Text::Display(int32_t _spacing)
|
|
||||||
{
|
|
||||||
SVG_DEBUG(SpacingDist(_spacing) << "Text");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user