** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
** Copyright (c) 2007, 2008 Chris Moore
** Copyright (c) 2009 Carlos A. Sosa Navarro
+** Copyright (c) 2009 Nikita Kitaev
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
typedef struct linear_g{
char name[40];
float x1,x2,y1,y2;
- std::list<ColorStop*> *stops; //paradas de color
+ std::list<ColorStop*> *stops;
+ Matrix *transform;
}LinearGradient;
typedef struct radial_g{
char name[40];
float cx,cy;//center point
- //float fx,fy;
- //focus, i dont see it in synfig
- //if this value is omitted then will be = cx,cy
- float r; //radio radius
- std::list<ColorStop*> *stops; //paradas de color
+ //float fx,fy; //not supported by Synfig
+ float r; //radius
+ std::list<ColorStop*> *stops;
+ Matrix *transform;
}RadialGradient;
typedef struct url_t{
void* data;
}URL;
-typedef struct vertice_t{
+typedef struct Vertex_t{
float x,y;
- float radio1,angle1;
- float radio2,angle2;
+ float radius1,angle1;
+ float radius2,angle2;
bool split;
-}Vertice;
+}Vertex;
+
+typedef struct bline_t{
+ std::list<Vertex*> *points;
+ bool loop;
+ String* bline_id;
+ String* offset_id;
+}BLine;
+
class Svg_parser
{
//this is inkscape oriented in some cases
int uid;
int kux,set_canvas;
float ox,oy;
- bool loop;//aux :D
//urls
std::list<LinearGradient*> lg;
std::list<RadialGradient*> rg;
//String get_id();
//void set_id(String source);
-private: //parser bucle
+private:
+ /* === PARSERS ==================================== */
void parser_node(const xmlpp::Node* node);
- void parser_node(const xmlpp::Node* node,xmlpp::Element* root,String parent_style,Matrix* mtx_parent);
//parser headers
void parser_svg(const xmlpp::Node* node);
void parser_canvas(const xmlpp::Node* node);
- //layers
void parser_graphics(const xmlpp::Node* node,xmlpp::Element* root,String parent_style,Matrix* mtx_parent);
+
+ /* === LAYER PARSERS ============================== */
void parser_layer(const xmlpp::Node* node,xmlpp::Element* root,String parent_style,Matrix* mtx);
- void parser_path(const xmlpp::Element* nodeElement,xmlpp::Element* root,String parent_style,Matrix* mtx);
- void parser_polygon(const xmlpp::Element* nodeElement,xmlpp::Element* root,String parent_style,Matrix* mtx);
- void parser_rect(const xmlpp::Element* nodeElement,xmlpp::Element* root,String parent_style,Matrix* mtx);
- //defs
+ void parser_rect(const xmlpp::Element* nodeElement,xmlpp::Element* root,String fill, String fill_opacity, String opacity);
+ /* === CONVERT TO PATH PARSERS ==================== */
+ std::list<BLine *> parser_path_polygon(Glib::ustring polygon_points, Matrix* mtx);
+ std::list<BLine *> parser_path_d(String path_d,Matrix* mtx);
+
+ /* === EFFECTS PARSERS ============================ */
+ void parser_effects(const xmlpp::Element* nodeElement,xmlpp::Element* root,String parent_style,Matrix* mtx);
+
+ /* === DEFS PARSERS =============================== */
void parser_defs(const xmlpp::Node* node);
void parser_linearGradient(const xmlpp::Node* node);
void parser_radialGradient(const xmlpp::Node* node);
ColorStop* newColorStop(String color,float opacity,float pos);
- LinearGradient* newLinearGradient(String name,float x1,float y1, float x2,float y2,std::list<ColorStop*> *stops);
- RadialGradient* newRadialGradient(String name,float cx,float cy,float r,std::list<ColorStop*> *stops);
- //builds urls
- void AdjustPointUrl();
+ LinearGradient* newLinearGradient(String name,float x1,float y1, float x2,float y2,std::list<ColorStop*> *stops, Matrix* transform);
+ RadialGradient* newRadialGradient(String name,float cx,float cy,float r,std::list<ColorStop*> *stops, Matrix* transform);
+ BLine* newBLine(std::list<Vertex*> *points,bool loop);
+
+ /* === BUILDS ===================================== */
+ void build_transform(xmlpp::Element* root,Matrix* mtx);
std::list<ColorStop*>* find_colorStop(String name);
- void build_url(xmlpp::Element* root, String name,Matrix *mtx);
+ void build_fill(xmlpp::Element* root, String name,Matrix *mtx);
void build_linearGradient(xmlpp::Element* root,LinearGradient* data,Matrix* mtx);
void build_radialGradient(xmlpp::Element* root,RadialGradient* data,Matrix* mtx);
void build_stop_color(xmlpp::Element* root, std::list<ColorStop*> *stops);
void build_stop_color(xmlpp::Element* root, std::list<ColorStop*> *stops,String name);
Color adjustGamma(float r,float g,float b,float a);
- //builds
+
void build_gamma(xmlpp::Element* root,float gamma);
- Matrix* build_transform(const String transform);
void build_rotate(xmlpp::Element* root,float dx,float dy,float angle);
void build_translate(xmlpp::Element* root,float dx,float dy);
- void build_points(xmlpp::Element* root,std::list<Vertice*> p);
- void build_vertice(xmlpp::Element* root , Vertice *p);
- void build_bline(xmlpp::Element* root,std::list<Vertice*> p,bool loop,String blinegui);
+ void build_points(xmlpp::Element* root,std::list<Vertex*> p);
+ void build_vertex(xmlpp::Element* root , Vertex *p);
+ void build_bline(xmlpp::Element* root,std::list<Vertex*> p,bool loop,String blineguid);
void build_param (xmlpp::Element* root,String name,String type,String value);
void build_param (xmlpp::Element* root,String name,String type,float value);
void build_param (xmlpp::Element* root,String name,String type,int value);
void build_vector (xmlpp::Element* root,String name,float x,float y,String guid);
void build_color(xmlpp::Element* root,float r,float g,float b,float a);
xmlpp::Element* nodeStartBasicLayer(xmlpp::Element* root);
+ xmlpp::Element* nodeStartBasicLayer(xmlpp::Element* root, String name);
+
+ /* === COORDINATES & TRANSFORMATIONS ============== */
//points,etc
void coor2vect(float *x,float *y);
- void setTg2(Vertice* p,float p1x,float p1y,float p2x,float p2y);
- void setTg1(Vertice *p,float p1x,float p1y,float p2x,float p2y);
- void setSplit(Vertice* p,bool val);
- int isFirst(Vertice* nodo,float a, float b);
- Vertice* newVertice(float x,float y);
+ void setTg2(Vertex* p,float p1x,float p1y,float p2x,float p2y);
+ void setTg1(Vertex *p,float p1x,float p1y,float p2x,float p2y);
+ void setSplit(Vertex* p,bool val);
+ int isFirst(Vertex* nodo,float a, float b);
+ Vertex* newVertex(float x,float y);
//matrix operations
+ Matrix* parser_transform(const String transform);
Matrix* newMatrix(float a,float b,float c,float d,float e,float f);
Matrix* newMatrix(const String mvector);
Matrix* newMatrix(Matrix *a);
void composeMatrix(Matrix **mtx,Matrix *mtx1,Matrix *mtx2);
void multiplyMatrix(Matrix **mtx1,Matrix *mtx2);
float getRadian(float sexa);
+
+ /* === EXTRA METHODS ============================== */
+
//attributes
int extractSubAttribute(const String attribute, String name,String* value);
String loadAttribute(String name,const String path_style,const String master_style,const String subattribute,const String defaultVal);
String loadAttribute(String name,const String path_style,const String master_style,const String defaultVal);
std::vector<String> get_tokens_path(String path);
- std::list<std::list<Vertice*> > parser_path_d(String path_d,Matrix* mtx);
int randomLetter();
int getRed(String hex);
int getGreen(String hex);
int getBlue(String hex);
int hextodec(String hex);
+ int getColor(String name, int position);
float getDimension(const String ac);
- //funciones string
+ //string functions
void removeS(String *input);
void removeIntoS(String *input);
std::vector<String> tokenize(const String& str,const String& delimiters);