-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhivewidget.h
47 lines (36 loc) · 975 Bytes
/
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
#ifndef HIVEWIDGET_H
#define HIVEWIDGET_H
#include <QOpenGLWidget>
#include <QMultiMap>
struct Edge {
QString source;
QString target;
QPainterPath path;
QBrush brush;
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 QMultiMap<QString, QString> &nodes);
void setEdges(const QList<Edge> &edges);
protected:
virtual void paintEvent(QPaintEvent *);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void resizeEvent(QResizeEvent*);
private:
void calculate();
QMultiMap<QString, QString> m_nodes;
QList<Edge> m_edges;
QMap<QString, QColor> m_nodeColors;
QMap<QString, QColor> m_colors;
QMap<QString, QPoint> m_positions;
QString m_closest;
bool m_scaleEdgeMax;
};
#endif // HIVEWIDGET_H