current_element().attributes.width = width;
}
+void SVGAnalyzer::set_x(double x) { current_element().attributes.x = x; }
+
+void SVGAnalyzer::set_y(double y) { current_element().attributes.y = y; }
+
void SVGAnalyzer::set_transform(double a, double b, double c, double d,
double e, double f) {
current_element().attributes.transform = {a, b, c, d, e, f};
double f) override;
void set_viewBox(double x, double y, double width, double height) override;
void set_width(double width) override;
+ void set_x(double x) override;
+ void set_y(double y) override;
std::size_t num_svgs() const { return m_num_svgs; };
std::size_t num_groups() const { return m_num_groups; };
std::size_t num_circles() const { return m_num_circles; };
double f) = 0;
virtual void set_viewBox(double x, double y, double width, double height) = 0;
virtual void set_width(double width) = 0;
+ virtual void set_x(double x) = 0;
+ virtual void set_y(double y) = 0;
};
break;
case SVG::SVGElementType::Text:
attributes_str +=
- fmt::format(R"(text-anchor="{}")", attributes.text_anchor);
+ fmt::format(R"(text-anchor="{}" x="{}" y="{}")", attributes.text_anchor,
+ attributes.x, attributes.y);
break;
case SVG::SVGElementType::Title:
// Graphviz doesn't generate attributes on 'title' elements
std::optional<SVGMatrix> transform;
SVGRect viewBox;
double width;
+ double x;
+ double y;
};
/**
(void)v;
}
-void SvgppContext::set(svgpp::tag::attribute::x a, const double v) {
- (void)a;
- (void)v;
+void SvgppContext::set(svgpp::tag::attribute::x, const double v) {
+ m_svgAnalyzer->set_x(v);
}
-void SvgppContext::set(svgpp::tag::attribute::y a, const double v) {
- (void)a;
- (void)v;
+void SvgppContext::set(svgpp::tag::attribute::x, const NumbersRange &range) {
+ if (boost::size(range) != 1) {
+ throw std::runtime_error{
+ "Multiple value list for the 'x' attribute is not yet implemented"};
+ }
+ m_svgAnalyzer->set_x(*range.begin());
+}
+
+void SvgppContext::set(svgpp::tag::attribute::y, const double v) {
+ m_svgAnalyzer->set_y(v);
+}
+
+void SvgppContext::set(svgpp::tag::attribute::y, const NumbersRange &range) {
+ if (boost::size(range) != 1) {
+ throw std::runtime_error{
+ "Multiple value list for the 'y' attribute is not yet implemented"};
+ }
+ m_svgAnalyzer->set_y(*range.begin());
}
void SvgppContext::set(svgpp::tag::attribute::width, const double v) {
const std::pair<double, double> &, std::ptrdiff_t>
PointsRange;
void set(svgpp::tag::attribute::points points, const PointsRange &range);
- void set(svgpp::tag::attribute::x a, double v);
- void set(svgpp::tag::attribute::y y, double v);
+ void set(svgpp::tag::attribute::x, double v);
+ typedef boost::any_range<double, boost::single_pass_traversal_tag, double,
+ std::ptrdiff_t>
+ NumbersRange;
+ void set(svgpp::tag::attribute::x, const NumbersRange &range);
+ void set(svgpp::tag::attribute::y, double v);
+ void set(svgpp::tag::attribute::y, const NumbersRange &range);
void set(svgpp::tag::attribute::width width, double v);
void set(svgpp::tag::attribute::height height, double v);
void set(svgpp::tag::attribute::id a, boost::iterator_range<const char *> v);
svgpp::tag::attribute::text_anchor, //
svgpp::tag::attribute::transform, //
svgpp::tag::attribute::viewBox, //
- svgpp::tag::attribute::width //
+ svgpp::tag::attribute::width, //
+ svgpp::tag::attribute::x, //
+ svgpp::tag::attribute::y //
>::type;
svgpp::document_traversal<
// yet handle all attributes on the 'path' element
break;
}
- if (recreated_svg_lines[i] == "<text text-anchor=\"middle\">a</text>") {
+ if (recreated_svg_lines[i].starts_with(
+ "<text text-anchor=\"middle\" x=\"")) {
// stop comparison here since we do not yet handle all attributes on the
// 'text' element
break;
CHECK(recreated_svg.find("<title>a</title>") != std::string::npos);
CHECK(recreated_svg.find("<title>b</title>") != std::string::npos);
if (shape != "point") {
- CHECK(recreated_svg.find("<text text-anchor=\"middle\">a</text>") !=
- std::string::npos);
- CHECK(recreated_svg.find("<text text-anchor=\"middle\">b</text>") !=
+ CHECK(recreated_svg.find("<text text-anchor=\"middle\" x=\"") !=
std::string::npos);
+ CHECK(recreated_svg.find("\" y=\"") != std::string::npos);
+ CHECK(recreated_svg.find("a</text>") != std::string::npos);
+ CHECK(recreated_svg.find("b</text>") != std::string::npos);
}
CHECK(recreated_svg.find("<path fill=\"none\" stroke=\"black\"/>") !=
std::string::npos);