void GraphvizEdge::add_bbox() { m_svg_g_element.add_bbox(); }
+void GraphvizEdge::add_outline_bbox() { m_svg_g_element.add_outline_bbox(); }
+
std::string_view GraphvizEdge::edgeop() const { return m_edgeop; }
std::string GraphvizEdge::fillcolor() const {
/// Add an SVG `rect` element to the edge's corresponding `g` element. The
/// `rect` is represes the bounding box of the edge.
void add_bbox();
+ /// Add an SVG `rect` element to the edge's corresponding `g` element. The
+ /// `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();
/// Return the bounding box of the edge
SVG::SVGRect bbox() const;
/// Return the center of the edge's bounding box
edge.add_bbox();
}
}
+
+void GraphvizGraph::add_outline_bboxes() {
+ for (auto &node : m_nodes) {
+ node.add_outline_bbox();
+ }
+ for (auto &edge : m_edges) {
+ edge.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 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 add_outline_bboxes();
const GraphvizEdge &edge(std::string_view edgeop) const;
/// Return a non-mutable reference to the list of Graphviz edges
const std::vector<GraphvizEdge> &edges() const;
void GraphvizNode::add_bbox() { m_svg_g_element.add_bbox(); }
+void GraphvizNode::add_outline_bbox() { m_svg_g_element.add_outline_bbox(); }
+
SVG::SVGPoint GraphvizNode::center() const { return bbox().center(); }
std::string GraphvizNode::color() const {
/// Add an SVG `rect` element representing the bounding box of the node to the
/// corresponding `g` element
void add_bbox();
+ /// Add an SVG `rect` element representing the outline bounding box of the
+ /// node to the corresponding `g` element. The outline bounding box is the
+ /// bounding box with penwidth taken into account.
+ void add_outline_bbox();
/// Return the node's bounding box
SVG::SVGRect bbox() const;
/// Return the center of the node's bounding box
}
}
+void SVGAnalyzer::add_outline_bboxes() {
+ for (auto &graph : m_graphs) {
+ graph.add_outline_bboxes();
+ }
+}
+
SVGAnalyzer SVGAnalyzer::make_from_dot(const std::string &dot_source,
const std::string &engine) {
auto g = CGraph::AGraph{dot_source};
/// Add SVG `rect` elements representing the bounding boxes of nodes and edges
/// to the corresponding `g` elements
void add_bboxes();
+ /// 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 add_outline_bboxes();
/// Create an SVGAnalyzer from DOT source using the `engine` layout engine.
///
/// \param dot_source The DOT source
children.push_back(element);
}
+void SVG::SVGElement::add_outline_bbox() {
+ const auto bbox = SVGElement::outline_bbox();
+ add_rect(bbox, "blue");
+}
+
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
/// Add an SVG `rect` element representing the bounding box of the edge to the
/// element
void add_bbox();
+ /// Add an SVG `rect` element representing the outline bounding box of 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 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