#include <string>
#include "graphviz_edge.h"
+#include "graphviz_node.h"
#include "svg_element.h"
GraphvizEdge::GraphvizEdge(SVG::SVGElement &svg_g_element)
void GraphvizEdge::add_outline_bbox() { m_svg_g_element.add_outline_bbox(); }
+void GraphvizEdge::add_outline_overlap_bbox(const GraphvizNode &node,
+ const double tolerance) {
+ m_svg_g_element.add_outline_overlap_bbox(node.svg_g_element(), tolerance);
+}
+
std::string_view GraphvizEdge::edgeop() const { return m_edgeop; }
std::string GraphvizEdge::fillcolor() const {
#include <string>
#include <string_view>
+#include "graphviz_node.h"
#include "svg_element.h"
/**
/// `rect` represents the outline bounding box of the edge. The outline
/// bounding box is the bounding box with penwidth taken into account.
void add_outline_bbox();
+ /// Add an SVG `rect` element representing the overlap between the outline
+ /// bounding box of the edge and the specified node, to the corresponding `g`
+ /// element. The outline bounding box is the bounding box with penwidth taken
+ /// into account.
+ void add_outline_overlap_bbox(const GraphvizNode &node, double tolerance = 0);
/// Return the bounding box of the edge
SVG::SVGRect bbox() const;
/// Return the center of the edge's bounding box
}
}
+void GraphvizGraph::add_node_edge_outline_bbox_overlaps(
+ const double tolerance) {
+ for (auto &node : m_nodes) {
+ for (auto &edge : m_edges) {
+ edge.add_outline_overlap_bbox(node, tolerance);
+ }
+ }
+}
+
void GraphvizGraph::add_outline_bboxes() {
for (auto &node : m_nodes) {
node.add_outline_bbox();
void add_edge(SVG::SVGElement &svg_g_element);
/// Add a Graphviz node to the graph
void add_node(SVG::SVGElement &svg_g_element);
+ /// Add SVG `rect` elements representing the overlap between the outline
+ /// bounding box of nodes and edges. The outline bounding box is the bounding
+ /// box with penwidth taken into account.
+ void add_node_edge_outline_bbox_overlaps(double tolerance = 0);
/// Add SVG `rect` elements representing the outline bounding boxes of nodes
/// and edges to the corresponding `g` elements. The outline bounding box is
/// the bounding box with penwidth taken into account.
}
}
+void SVGAnalyzer::add_node_edge_outline_bbox_overlaps(double tolerance) {
+ for (auto &graph : m_graphs) {
+ graph.add_node_edge_outline_bbox_overlaps(tolerance);
+ }
+}
+
void SVGAnalyzer::add_outline_bboxes() {
for (auto &graph : m_graphs) {
graph.add_outline_bboxes();
/// Add SVG `rect` elements representing the bounding boxes of nodes and edges
/// to the corresponding `g` elements
void add_bboxes();
+ /// Add SVG rects showing the overlap between the outline bounding boxes of
+ /// each node and edge (with penwidth taken into account)
+ void add_node_edge_outline_bbox_overlaps(double tolerance = 0);
/// Add SVG `rect` elements representing the outline bounding boxes of nodes
/// and edges to the corresponding `g` elements. The outline bounding box is
/// the bounding box with penwidth taken into account.
add_rect(bbox, "blue");
}
+void SVG::SVGElement::add_outline_overlap_bbox(SVG::SVGElement other,
+ const double tolerance) {
+ const auto bbox = outline_bbox();
+ const auto other_bbox = other.outline_bbox();
+ const auto overlap_bbox = bbox.intersection(other_bbox);
+ if (overlap_bbox.width <= 0 || overlap_bbox.height <= 0) {
+ return;
+ }
+ const auto within_tolerance =
+ overlap_bbox.width <= tolerance && overlap_bbox.height <= tolerance;
+ const auto color = within_tolerance ? "yellow" : "red";
+ add_rect(overlap_bbox, color);
+}
+
SVG::SVGRect SVG::SVGElement::bbox(bool throw_if_bbox_not_defined) {
if (!m_bbox.has_value()) {
// negative width and height bbox that will be immediately replaced by the
/// edge to the element. The outline bounding box is the bounding box with
/// stroke width taken into account.
void add_outline_bbox();
+ /// Add an SVG `rect` element representing the overlap between the outline
+ /// bounding box of the element and another element. The outline bounding box
+ /// is the bounding box with penwidth taken into account.
+ void add_outline_overlap_bbox(SVG::SVGElement other, double tolerance = 0);
/// Add an SVG `rect` element as a child to the element
void add_rect(SVG::SVGRect rect, std::string color);
/// \brief Return the value of an attribute retrieved from the element and its