From: Magnus Jacobsson Date: Wed, 5 Oct 2022 20:28:14 +0000 (+0200) Subject: tests: GraphvizEdge: handle primitive arrow shape 'dot' in arrowhead_outline_bbox X-Git-Tag: 7.0.0~6^2~4 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e2bfae11f53e664ead1f41cc54869ec9c8bf15d6;p=graphviz tests: GraphvizEdge: handle primitive arrow shape 'dot' in arrowhead_outline_bbox --- diff --git a/tests/graphviz_edge.cpp b/tests/graphviz_edge.cpp index 35c75015f..72754195e 100644 --- a/tests/graphviz_edge.cpp +++ b/tests/graphviz_edge.cpp @@ -21,10 +21,35 @@ void GraphvizEdge::add_outline_overlap_bbox(const GraphvizNode &node, static const std::unordered_set supported_primitive_arrow_shapes = { "box", // + "dot", // "inv", // "normal", // }; +static const std::unordered_set + polygon_based_primitive_arrow_shapes = { + "box", // + "inv", // + "normal", // +}; + +static const std::unordered_set + ellipse_based_primitive_arrow_shapes = { + "dot", // +}; + +static SVG::SVGElementType +edge_arrowhead_main_svg_element_type(std::string_view primitive_arrow_shape) { + if (polygon_based_primitive_arrow_shapes.contains(primitive_arrow_shape)) { + return SVG::SVGElementType::Polygon; + } else if (ellipse_based_primitive_arrow_shapes.contains( + primitive_arrow_shape)) { + return SVG::SVGElementType::Ellipse; + } else { + assert(false && "unsupported primitive arrow shape"); + } +} + SVG::SVGRect GraphvizEdge::arrowhead_outline_bbox( std::string_view dir, std::string_view primitive_arrow_shape) const { assert((dir == "forward" || dir == "both") && @@ -36,8 +61,11 @@ SVG::SVGRect GraphvizEdge::arrowhead_outline_bbox( primitive_arrow_shape)}; } const auto index = dir == "forward" ? 0 : 1; + + const auto main_svg_element_type = + edge_arrowhead_main_svg_element_type(primitive_arrow_shape); auto edge_arrowhead = - m_svg_g_element.find_child(SVG::SVGElementType::Polygon, index); + m_svg_g_element.find_child(main_svg_element_type, index); auto edge_arrowhead_bbox = edge_arrowhead.outline_bbox(); if (primitive_arrow_shape == "box") { auto edge_arrowhead_stem =