-
Notifications
You must be signed in to change notification settings - Fork 0
/
hivewidget.h
70 lines (56 loc) · 1.44 KB
/
hivewidget.h
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#ifndef HIVEWIDGET_H
#define HIVEWIDGET_H
#include <QOpenGLWidget>
#include <QMultiMap>
#include <QTextDocument>
#include <QPainterPath>
#include <memory>
struct Node {
QString displayName;
QString group;
QString subgroup;
std::shared_ptr<QTextDocument> sourcecode;
QColor color;
int x, y;
};
struct Edge {
bool isView = false;
QString source;
QString target;
QPainterPath path;
QPolygon arrowhead;
QBrush brush;
QBrush highlightBrush;
bool operator==(const Edge &other) {
return (source == other.source && target == other.target);
}
};
class HiveWidget : public QOpenGLWidget
{
Q_OBJECT
public:
HiveWidget(QWidget *parent = 0);
~HiveWidget();
void setNodes(const QMap<QString, Node> &nodes);
void setEdges(const QList<Edge> &edges);
protected:
virtual void paintEvent(QPaintEvent *) override;
virtual void mouseMoveEvent(QMouseEvent *) override;
virtual void mousePressEvent(QMouseEvent*) override;
virtual void resizeEvent(QResizeEvent*) override;
private:
void calculate();
QString getClosest(int x, int y);
QMap<QString, Node> m_nodes;
QList<Edge> m_edges;
QMap<QString, QColor> m_groupColors;
QMap<QString, int> m_groupYPositions;
int m_groupsXOffset;
QString m_closest;
QString m_clicked;
bool m_scaleEdgeMax;
bool m_scaleAxis;
int m_renderTime;
QStringList m_disabledGroups;
};
#endif // HIVEWIDGET_H