File: graphviz_node.h

package info (click to toggle)
graphviz 14.1.1-2
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 139,440 kB
  • sloc: ansic: 142,129; cpp: 11,960; python: 7,770; makefile: 4,043; yacc: 3,030; xml: 2,972; tcl: 2,495; sh: 1,388; objc: 1,159; java: 560; lex: 423; perl: 243; awk: 156; pascal: 139; php: 58; ruby: 49; cs: 31; sed: 1
file content (52 lines) | stat: -rw-r--r-- 1,869 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once

#include <string>
#include <string_view>

#include "svg_element.h"

/**
 * @brief The GraphvizNode class represents a Graphviz node according to the DOT
 * language
 */

class GraphvizNode {
public:
  GraphvizNode() = delete;
  explicit GraphvizNode(SVG::SVGElement &svg_element);

  /// 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
  SVG::SVGPoint center() const;
  /// Return the node's `color` attribute in RGB hex format if the opacity is
  /// 100 % or in RGBA hex format otherwise.
  std::string color() const;
  /// Return the node's `fillcolor` attribute in RGB hex format if the opacity
  /// is 100 % or in RGBA hex format otherwise.
  std::string fillcolor() const;
  /// Return the node's `node_id` as defined by the DOT language
  std::string_view node_id() const;
  /// Return the outline bounding box of the node. The outline bounding box is
  /// the bounding box with penwidth taken into account.
  SVG::SVGRect outline_bbox() const;
  /// Return the node's `penwidth` attribute
  double penwidth() const;
  /// Return a non-mutable reference to the SVG `g` element corresponding to the
  /// node
  const SVG::SVGElement &svg_g_element() const;

private:
  /// The `node_id` according to the DOT language specification. Note that this
  /// is not the same as the `id` attribute of a node
  std::string m_node_id;
  /// The SVG `g` element corresponding to the node
  SVG::SVGElement &m_svg_g_element;
};