Debian Codegraph @

tests/graphviz_node.h

raw
1 #pragma once
2
3 #include <string>
4 #include <string_view>
5
6 #include "svg_element.h"
7
8 /**
9 * @brief The GraphvizNode class represents a Graphviz node according to the DOT
10 * language
11 */
12
13 class GraphvizNode {
14 public:
15 GraphvizNode() = delete;
16 explicit GraphvizNode(SVG::SVGElement &svg_element);
17
18 /// Add an SVG `rect` element representing the bounding box of the node to the
19 /// corresponding `g` element
20 void add_bbox();
21 /// Add an SVG `rect` element representing the outline bounding box of the
22 /// node to the corresponding `g` element. The outline bounding box is the
23 /// bounding box with penwidth taken into account.
24 void add_outline_bbox();
25 /// Return the node's bounding box
26 SVG::SVGRect bbox() const;
27 /// Return the center of the node's bounding box
28 SVG::SVGPoint center() const;
29 /// Return the node's `color` attribute in RGB hex format if the opacity is
30 /// 100 % or in RGBA hex format otherwise.
31 std::string color() const;
32 /// Return the node's `fillcolor` attribute in RGB hex format if the opacity
33 /// is 100 % or in RGBA hex format otherwise.
34 std::string fillcolor() const;
35 /// Return the node's `node_id` as defined by the DOT language
36 std::string_view node_id() const;
37 /// Return the outline bounding box of the node. The outline bounding box is
38 /// the bounding box with penwidth taken into account.
39 SVG::SVGRect outline_bbox() const;
40 /// Return the node's `penwidth` attribute
41 double penwidth() const;
42 /// Return a non-mutable reference to the SVG `g` element corresponding to the
43 /// node
44 const SVG::SVGElement &svg_g_element() const;
45
46 private:
47 /// The `node_id` according to the DOT language specification. Note that this
48 /// is not the same as the `id` attribute of a node
49 std::string m_node_id;
50 /// The SVG `g` element corresponding to the node
51 SVG::SVGElement &m_svg_g_element;
52 };