GraphvizLayout.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <graphviz/gvc.h>
4 
5 #include <QPointF>
6 #include <QList>
7 
8 #include <optional>
9 #include <string>
10 #include <map>
11 
12 namespace armarx
13 {
15  {
16  float posX = 0.0f;
17  float posY = 0.0f;
18  float width = 0.0f;
19  float height = 0.0f;
20  std::string label;
21  };
22 
24  {
25  QList<QPointF> controlPoints;
26  std::optional<QPointF> startPoint;
27  std::optional<QPointF> endPoint;
28 
29  std::string label; // May be empty
30  float labelPosX = 0.0f;
31  float labelPosY = 0.0f;
32  };
33 
35  {
36  std::map<int, GraphvizLayoutedNode> nodes;
37  std::map<std::pair<int, int>, GraphvizLayoutedEdge> edges;
38  };
39 
41  {
42  public:
44 
45  GraphvizLayout(GraphvizLayout const&) = delete;
46 
48 
49  void addNode(int id, std::string const& label);
50 
51  void addEdge(int sourceID, int targetID, const std::string& label);
52 
53  GraphvizLayoutedGraph finish(std::string const& savePNG = "");
54 
55 
56  private:
57  GVC_t* context = nullptr;
58  graph_t* graph = nullptr;
59 
60  std::map<int, node_t*> id2node;
61  std::map<std::pair<int, int>, edge_t*> id2edge;
62  };
63 
64 }
armarx::GraphvizLayoutedEdge::endPoint
std::optional< QPointF > endPoint
Definition: GraphvizLayout.h:27
armarx::GraphvizLayoutedNode::height
float height
Definition: GraphvizLayout.h:19
armarx::GraphvizLayout::~GraphvizLayout
~GraphvizLayout()
Definition: GraphvizLayout.cpp:67
armarx::GraphvizLayoutedEdge::startPoint
std::optional< QPointF > startPoint
Definition: GraphvizLayout.h:26
armarx::GraphvizLayoutedGraph::nodes
std::map< int, GraphvizLayoutedNode > nodes
Definition: GraphvizLayout.h:36
armarx::GraphvizLayout::GraphvizLayout
GraphvizLayout()
Definition: GraphvizLayout.cpp:35
armarx::GraphvizLayoutedEdge::labelPosY
float labelPosY
Definition: GraphvizLayout.h:31
armarx::GraphvizLayout::addNode
void addNode(int id, std::string const &label)
Definition: GraphvizLayout.cpp:80
armarx::GraphvizLayout
Definition: GraphvizLayout.h:40
armarx::GraphvizLayout::addEdge
void addEdge(int sourceID, int targetID, const std::string &label)
Definition: GraphvizLayout.cpp:87
armarx::GraphvizLayoutedNode::posX
float posX
Definition: GraphvizLayout.h:16
armarx::GraphvizLayoutedEdge
Definition: GraphvizLayout.h:23
armarx::GraphvizLayoutedNode::posY
float posY
Definition: GraphvizLayout.h:17
armarx::GraphvizLayout::finish
GraphvizLayoutedGraph finish(std::string const &savePNG="")
Definition: GraphvizLayout.cpp:99
armarx::GraphvizLayoutedEdge::controlPoints
QList< QPointF > controlPoints
Definition: GraphvizLayout.h:25
armarx::GraphvizLayoutedEdge::labelPosX
float labelPosX
Definition: GraphvizLayout.h:30
armarx::GraphvizLayoutedEdge::label
std::string label
Definition: GraphvizLayout.h:29
armarx::GraphvizLayoutedGraph
Definition: GraphvizLayout.h:34
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::GraphvizLayoutedNode::width
float width
Definition: GraphvizLayout.h:18
armarx::GraphvizLayoutedGraph::edges
std::map< std::pair< int, int >, GraphvizLayoutedEdge > edges
Definition: GraphvizLayout.h:37
armarx::GraphvizLayoutedNode
Definition: GraphvizLayout.h:14
armarx::GraphvizLayoutedNode::label
std::string label
Definition: GraphvizLayout.h:20