13 minx_ = maxx_ = miny_ = maxy_ = 0;
19 out_ <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << endl;
20 out_ <<
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD Svg 1.1//EN\"" << endl;
21 out_ <<
"\"http://www.w3.org/Graphics/Svg/1.1/DTD/svg11.dtd\">" << endl;
22 out_ <<
"<svg width=\"" << (maxx_ - minx_) <<
"\" height=\"" << (maxy_ - miny_) <<
"\" version=\"1.1\"" << endl;
23 out_ <<
" xmlns=\"http://www.w3.org/2000/svg\"" << endl;
25 out_ <<
" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"";
28 out_ <<
"<g transform=\"translate(" << (-minx_) <<
"," << (-miny_) <<
")\">" << endl;
30 for (map<
int, vector<string>>::iterator it = layers_.begin(); it != layers_.end(); it++)
32 out_ <<
"<g id=\"layer" << it->first <<
"\"";
35 out_ <<
" inkscape:groupmode=\"layer\"";
38 vector<string>* v = &it->second;
39 for (
unsigned int i = 0; i < v->size(); i++)
41 out_ << (*v)[i] << endl;
43 out_ <<
"</g>" << endl;
45 out_ <<
"</g>" << endl;
47 out_ <<
"</svg>" << endl;
56 string style =
"stroke:" + colorToText(getCurrentForegroundColor()) +
";stroke-width:" +
TextTools::toString(getCurrentPointSize());
57 if (getCurrentLineType() == LINE_DASHED)
58 style +=
";stroke-dasharray:4,4";
59 else if (getCurrentLineType() == LINE_DOTTED)
60 style +=
";stroke-dasharray:1,2";
62 oss <<
"<line x1=\"" << x1 <<
"\" y1=\"" << y1 <<
"\" x2=\"" << x2 <<
"\" y2=\"" << y2 <<
"\" style=\"" << style <<
"\" />";
63 layers_[getCurrentLayer()].push_back(oss.str());
88 string style =
"stroke:" + colorToText(getCurrentForegroundColor()) +
";stroke-width:" +
TextTools::toString(getCurrentPointSize());
89 if (fill == FILL_FILLED)
91 style +=
";fill:" + colorToText(getCurrentBackgroundColor());
94 oss <<
"<rect x=\"" << x <<
"\" y=\"" << y <<
"\" width=\"" << width <<
"\" height=\"" << height <<
"\" style=\"" << style <<
"\" />";
95 layers_[getCurrentLayer()].push_back(oss.str());
100 if (x + width > maxx_)
102 if (y + height > maxy_)
111 string style =
"stroke:" + colorToText(getCurrentForegroundColor()) +
";stroke-width:" +
TextTools::toString(getCurrentPointSize());
112 if (fill == FILL_FILLED)
114 style +=
";fill:" + colorToText(getCurrentBackgroundColor());
117 oss <<
"<rect cx=\"" << x <<
"\" cy=\"" << y <<
"\" cr=\"" << radius <<
"\" style=\"" << style <<
"\" />";
118 layers_[getCurrentLayer()].push_back(oss.str());
125 string style =
"font-family:" + getCurrentFont().getFamily() +
";font-style:" + fontStyles_[getCurrentFont().getStyle()] +
";font-weight:" + fontWeights_[getCurrentFont().getWeight()] +
";font-size:" +
TextTools::toString(getCurrentFont().getSize()) +
"px";
126 style +=
";dominant-baseline:";
127 if (vpos == TEXT_VERTICAL_BOTTOM)
128 style +=
"before-edge";
129 else if (vpos == TEXT_VERTICAL_TOP)
130 style +=
"after-edge";
131 else if (vpos == TEXT_VERTICAL_CENTER)
135 style +=
";text-anchor:";
136 if (hpos == TEXT_HORIZONTAL_LEFT)
138 else if (hpos == TEXT_HORIZONTAL_RIGHT)
140 else if (hpos == TEXT_HORIZONTAL_CENTER)
144 style +=
";fill:" + colorToText(getCurrentForegroundColor());
147 oss <<
"<text x=\"" << x <<
"\" y=\"" << y <<
"\" rotate=\"" << angle <<
"\" style=\"" << style <<
"\" >" << text <<
"</text>";
148 layers_[getCurrentLayer()].push_back(oss.str());
void drawCircle(double x, double y, double radius, short fill=FILL_EMPTY)
Draw a circle.
void begin()
Start the painting.
void drawRect(double x, double y, double width, double height, short fill=FILL_EMPTY)
Draw a rectangle.
void drawLine(double x1, double y1, double x2, double y2)
Draw a line between two points.
void end()
End the painting.
std::string toString(T t)
General template method to convert to a string.
void drawText(double x, double y, const std::string &text, short hpos=TEXT_HORIZONTAL_LEFT, short vpos=TEXT_VERTICAL_BOTTOM, double angle=0)
Draw some characters.