From cd1bf0177de8a86444998ec3418d2ecae576c68c Mon Sep 17 00:00:00 2001 From: Magnus Jacobsson Date: Tue, 4 Oct 2022 15:08:15 +0200 Subject: [PATCH] tests: graphviz_edge: remove 'arrow' method and inline instead Upcoming commits will introduce handling of primitive arrow shapes other than 'normal' or 'inv' which cannot be represented by a single SVG element. --- tests/graphviz_edge.cpp | 12 ++++++------ tests/graphviz_edge.h | 3 --- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/tests/graphviz_edge.cpp b/tests/graphviz_edge.cpp index 602b90191..8db2301b6 100644 --- a/tests/graphviz_edge.cpp +++ b/tests/graphviz_edge.cpp @@ -18,10 +18,6 @@ void GraphvizEdge::add_outline_overlap_bbox(const GraphvizNode &node, m_svg_g_element.add_outline_overlap_bbox(node.svg_g_element(), tolerance); } -SVG::SVGElement &GraphvizEdge::arrow(const std::size_t index) const { - return m_svg_g_element.find_child(SVG::SVGElementType::Polygon, index); -} - static const std::unordered_set supported_primitive_arrow_shapes = { "inv", // @@ -38,7 +34,9 @@ SVG::SVGRect GraphvizEdge::arrowhead_outline_bbox( fmt::format("primitive arrow shape {} is not yet supported", primitive_arrow_shape)}; } - auto edge_arrowhead = dir == "forward" ? arrow(0) : arrow(1); + const auto index = dir == "forward" ? 0 : 1; + auto edge_arrowhead = + m_svg_g_element.find_child(SVG::SVGElementType::Polygon, index); const auto edge_arrowhead_bbox = edge_arrowhead.outline_bbox(); return edge_arrowhead_bbox; @@ -53,7 +51,9 @@ SVG::SVGRect GraphvizEdge::arrowtail_outline_bbox( fmt::format("primitive arrow shape {} is not yet supported", primitive_arrow_shape)}; } - auto edge_arrowtail = arrow(0); + const auto index = 0; + auto edge_arrowtail = + m_svg_g_element.find_child(SVG::SVGElementType::Polygon, index); const auto edge_arrowtail_bbox = edge_arrowtail.outline_bbox(); return edge_arrowtail_bbox; diff --git a/tests/graphviz_edge.h b/tests/graphviz_edge.h index 36a0dd327..d5d13f544 100644 --- a/tests/graphviz_edge.h +++ b/tests/graphviz_edge.h @@ -32,9 +32,6 @@ public: /// both an arrowhead and an arrowtail, the arrowtail is at index 0 and the /// arrowhead is at index 1. If there's only one, it's at index 0. Throws an /// exception if there's no arrow at the specified index. - SVG::SVGElement &arrow(std::size_t index = 0) const; - /// Return the outline bounding box of the edge arrowhead. The outline - /// bounding box is the bounding box with penwidth taken into account. SVG::SVGRect arrowhead_outline_bbox(std::string_view dir, std::string_view primitive_arrow_shape) const; -- 2.40.0