38#ifndef DRAIN_TREE_ELEM_UTILS_SVG
39#define DRAIN_TREE_ELEM_UTILS_SVG
51#include <drain/util/XML.h>
52#include <drain/util/TreeXML.h>
58#define DRAIN_SVG_ELEM_CLS(E) drain::NodeXML<drain::image::svg::tag_t>::Elem<drain::image::svg::tag_t::E>
59#define DRAIN_SVG_ELEM(E) typedef drain::NodeXML<drain::image::svg::tag_t>::Elem<drain::image::svg::tag_t::E> svg##E;
68template <>
template <>
69class DRAIN_SVG_ELEM_CLS(RECT){
74 Elem(image::NodeSVG & node) : node(node = image::svg::tag_t::RECT), x(node[
"x"]), y(node[
"y"]), width(node[
"width"]), height(node[
"height"]){
77 NodeXML<image::svg::tag_t> & node;
90class DRAIN_SVG_ELEM_CLS(CIRCLE){
94 NodeXML<image::svg::tag_t> & node;
97 Elem(image::NodeSVG & node) : node(node = image::svg::tag_t::CIRCLE), cx(node[
"cx"]), cy(node[
"cy"]), r(node[
"r"] = 0.0){
111DRAIN_SVG_ELEM(CIRCLE)
117class DRAIN_SVG_ELEM_CLS(POLYGON){
122 Elem(image::NodeSVG & node) : node(node = image::svg::tag_t::POLYGON), points(node[
"points"]), writablePoints(node[
"points"]){
125 NodeXML<image::svg::tag_t> & node;
136 writablePoints.clear();
139 template <
typename T>
141 void append(
const T &x,
const T &y){
142 writablePoints << x <<
',' << y <<
' ';
145 template <
typename T>
148 writablePoints << p.x <<
',' << p.y <<
' ';
152DRAIN_SVG_ELEM(POLYGON)
158class DRAIN_SVG_ELEM_CLS(PATH){
163 Elem(image::NodeSVG & node) : node(node = image::svg::tag_t::PATH), d(node[
"d"]) {
173 NodeXML<image::svg::tag_t> & node;
197 template <Command C,
typename ...T>
198 void relative(
const T... args){
199 appendCmd<C,RELATIVE>();
200 appendArgs<C>(args...);
203 template <Command C,
typename ...T>
204 void absolute(
const T... args){
205 appendCmd<C,ABSOLUTE>();
206 appendArgs<C>(args...);
210 node[
"d"] = sstr.str();
222 std::stringstream sstr;
224 template <Command C, Coord R=RELATIVE>
227 sstr << char(
int(C) +
int(R)) <<
' ';
234 void appendArgs(
double x,
double y);
237 void appendArgs(
double x,
double y,
double x2,
double y2);
240 void appendArgs(
double x,
double y,
double x2,
double y2,
double x3,
double y3);
243 template <Command C,
typename T>
246 appendArgs<C>(p.x, p.y);
249 template <Command C,
typename T>
252 appendArgs<C>(p.x, p.y, p2.x, p2.y);
255 template <Command C,
typename T>
258 appendArgs<C>(p.x, p.y, p2.x, p2.y, p3.x, p3.y);
264 void appendPoint(
double x){
268 template <
typename T>
271 sstr << p.x <<
' ' << p.y <<
' ';
276 template <
typename ...TT>
278 void appendPoints(
double x,
double y,
const TT... args){
280 sstr << x <<
' ' << y;
281 appendMorePoints(args...);
285 template <
typename T,
typename ...TT>
288 sstr << p.x <<
' ' << p.y;
290 appendMorePoints(args...);
293 template <
typename ...TT>
295 void appendMorePoints(
const TT... args){
297 appendPoints(args...);
302 void appendMorePoints(){
315void svgPATH::appendArgs<svgPATH::CLOSE>(){
321void svgPATH::appendArgs<svgPATH::MOVE>(
double x,
double y){
327void svgPATH::appendArgs<svgPATH::LINE>(
double x,
double y){
333void svgPATH::appendArgs<svgPATH::CURVE_C>(
double x1,
double y1,
double x2,
double y2,
double x3,
double y3){
334 appendPoints(x1,y1, x2,y2, x3,y3);
339void svgPATH::appendArgs<svgPATH::CURVE_C_SHORT>(
double x2,
double y2,
double x,
double y){
340 appendPoints(x2,y2, x,y);
Definition DataSelector.cpp:1277
VariableT< VariableInitializer< ReferenceT< VariableBase > > > FlexibleVariable
Value container supporting dynamic type with own memory and optional linking (referencing) of externa...
Definition FlexibleVariable.h:67