openEmbroider  0.1
an open source embroidery software
 All Classes Functions Variables
OE_path.h
1 /*
2  * Copyright (c) 2015 Tricoire Sebastien 3dsman@free.fr
3  *
4  * This software is provided 'as-is', without any express or implied
5  * warranty. In no event will the authors be held liable for any damages
6  * arising from the use of this software.
7  *
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  *
12  * 1. The origin of this software must not be misrepresented; you must not
13  * claim that you wrote the original software. If you use this software
14  * in a product, an acknowledgment in the product documentation would be
15  * appreciated but is not required.
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  * misrepresented as being the original software.
18  * 3. This notice may not be removed or altered from any source distribution.
19  *
20  */
21 
22 #ifndef OE_PATH_H
23 #define OE_PATH_H
24 
25 #include "xml/tinyxml.h"
26 
27 #include "OE_svg_base.h"
28 #include "OE_curve.h"
29 
30 class OE_path : public OE_svg_base
31 {
32  public:
34  OE_path();
36  virtual ~OE_path();
37 
39  virtual bool draw(float dpi);
40  virtual bool Parse(TiXmlElement *input);
41 
42  bool newCurve();
43 
44  protected:
45  private:
46 
47  char id[64]; // Optional 'id' attr of the curve or its group
48  float opacity; // Opacity of the curve.
49  float strokeWidth; // Stroke width (scaled).
50  char strokeLineJoin; // Stroke join type.
51  char strokeLineCap; // Stroke cap type.
52  float bounds[4]; // Tight bounding box of the curve [minx,miny,maxx,maxy].
53  OE_curve* curves; // Linked list of curves in the path.
54 
55  static float sqr(float x);
56  static float vmag(float x, float y);
57  static float vecrat(float ux, float uy, float vx, float vy);
58  static float vecang(float ux, float uy, float vx, float vy);
59  static void xformPoint(float* dx, float* dy, float x, float y, float* t);
60  static void xformVec(float* dx, float* dy, float x, float y, float* t);
61 
62  int isspace(char c);
63  int isdigit(char c);
64  int isnum(char c);
65  const char* parseNumber(const char* s, char* it, const int size);
66  const char* getNextPathItem(const char* s, char* it);
67 
69  int getArgsPerElement(char cmd);
70  void pathMoveTo(OE_curve* curve, float* cpx, float* cpy, float* args, int rel);
71  void pathLineTo(OE_curve* curve, float* cpx, float* cpy, float* args, int rel);
72  void pathHLineTo(OE_curve* curve, float* cpx, float* cpy, float* args, int rel);
73  void pathVLineTo(OE_curve* curve, float* cpx, float* cpy, float* args, int rel);
74  void pathCubicBezTo(OE_curve* curve, float* cpx, float* cpy, float* cpx2, float* cpy2, float* args, int rel);
75  void pathCubicBezShortTo(OE_curve* curve, float* cpx, float* cpy, float* cpx2, float* cpy2, float* args, int rel);
76  void pathQuadBezTo(OE_curve* curve, float* cpx, float* cpy, float* cpx2, float* cpy2, float* args, int rel);
77  void pathQuadBezShortTo(OE_curve* curve, float* cpx, float* cpy, float* cpx2, float* cpy2, float* args, int rel);
78  void pathArcTo(OE_curve* curve, float* cpx, float* cpy, float* args, int rel);
79 
80 };
81 
82 #endif // OE_PATH_H
virtual bool Parse(TiXmlElement *input)
parse the xml file to load params
Definition: OE_path.cpp:491
virtual ~OE_path()
Definition: OE_path.cpp:42
virtual bool draw(float dpi)
Definition: OE_path.cpp:665
Definition: OE_svg_base.h:27
Definition: OE_curve.h:30
Definition: OE_path.h:30
OE_path()
Definition: OE_path.cpp:31