50 minx_ = maxx_ = miny_ = maxy_ = 0;
56 out_ <<
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << endl;
57 out_ <<
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD Svg 1.1//EN\"" << endl;
58 out_ <<
"\"http://www.w3.org/Graphics/Svg/1.1/DTD/svg11.dtd\">" << endl;
59 out_ <<
"<svg width=\"" << (maxx_ - minx_) <<
"\" height=\"" << (maxy_ - miny_) <<
"\" version=\"1.1\"" << endl;
60 out_ <<
" xmlns=\"http://www.w3.org/2000/svg\"" << endl;
62 out_ <<
" xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\"";
65 out_ <<
"<g transform=\"translate(" << (-minx_) <<
"," << (-miny_) <<
")\">" << endl;
67 for (map<
int, vector<string> >::iterator it = layers_.begin(); it != layers_.end(); it++)
69 out_ <<
"<g id=\"layer" << it->first <<
"\"";
72 out_ <<
" inkscape:groupmode=\"layer\"";
75 vector<string>* v = &it->second;
76 for (
unsigned int i = 0; i < v->size(); i++)
78 out_ << (*v)[i] << endl;
80 out_ <<
"</g>" << endl;
82 out_ <<
"</g>" << endl;
84 out_ <<
"</svg>" << endl;
93 string style =
"stroke:" + colorToText(getCurrentForegroundColor()) +
";stroke-width:" +
TextTools::toString(getCurrentPointSize());
94 if (getCurrentLineType() == LINE_DASHED)
95 style +=
";stroke-dasharray:4,4";
96 else if (getCurrentLineType() == LINE_DOTTED)
97 style +=
";stroke-dasharray:1,2";
99 oss <<
"<line x1=\"" << x1 <<
"\" y1=\"" << y1 <<
"\" x2=\"" << x2 <<
"\" y2=\"" << y2 <<
"\" style=\"" << style <<
"\" />";
100 layers_[getCurrentLayer()].push_back(oss.str());
125 string style =
"stroke:" + colorToText(getCurrentForegroundColor()) +
";stroke-width:" +
TextTools::toString(getCurrentPointSize());
126 if (fill == FILL_FILLED)
128 style +=
";fill:" + colorToText(getCurrentBackgroundColor());
131 oss <<
"<rect x=\"" << x <<
"\" y=\"" << y <<
"\" width=\"" << width <<
"\" height=\"" << height <<
"\" style=\"" << style <<
"\" />";
132 layers_[getCurrentLayer()].push_back(oss.str());
137 if (x + width > maxx_)
139 if (y + height > maxy_)
148 string style =
"stroke:" + colorToText(getCurrentForegroundColor()) +
";stroke-width:" +
TextTools::toString(getCurrentPointSize());
149 if (fill == FILL_FILLED)
151 style +=
";fill:" + colorToText(getCurrentBackgroundColor());
154 oss <<
"<rect cx=\"" << x <<
"\" cy=\"" << y <<
"\" cr=\"" << radius <<
"\" style=\"" << style <<
"\" />";
155 layers_[getCurrentLayer()].push_back(oss.str());
162 string style =
"font-family:" + getCurrentFont().getFamily() +
";font-style:" + fontStyles_[getCurrentFont().getStyle()] +
";font-weight:" + fontWeights_[getCurrentFont().getWeight()] +
";font-size:" +
TextTools::toString(getCurrentFont().getSize()) +
"px";
163 style +=
";dominant-baseline:";
164 if (vpos == TEXT_VERTICAL_BOTTOM)
165 style +=
"before-edge";
166 else if (vpos == TEXT_VERTICAL_TOP)
167 style +=
"after-edge";
168 else if (vpos == TEXT_VERTICAL_CENTER)
172 style +=
";text-anchor:";
173 if (hpos == TEXT_HORIZONTAL_LEFT)
175 else if (hpos == TEXT_HORIZONTAL_RIGHT)
177 else if (hpos == TEXT_HORIZONTAL_CENTER)
181 style +=
";fill:" + colorToText(getCurrentForegroundColor());
184 oss <<
"<text x=\"" << x <<
"\" y=\"" << y <<
"\" rotate=\"" << angle <<
"\" style=\"" << style <<
"\" >" << text <<
"</text>";
185 layers_[getCurrentLayer()].push_back(oss.str());
void drawCircle(double x, double y, double radius, short fill=FILL_EMPTY)
Draw a circle.
void drawLine(double x1, double y1, double x2, double y2)
Draw a line between two points.
void drawRect(double x, double y, double width, double height, short fill=FILL_EMPTY)
Draw a rectangle.
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.
void begin()
Start the painting.
void end()
End the painting.
std::string toString(T t)
General template method to convert to a string.