-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsphereview.h
95 lines (69 loc) · 2 KB
/
sphereview.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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef SPHEREVIEW_H
#define SPHEREVIEW_H
#include <QGraphicsView>
#include <QGraphicsPixmapItem>
#include <QWheelEvent>
enum SphereHostType
{
HOST_TYPE_ARM,
HOST_TYPE_PAUS,
HOST_TYPE_MANAGER,
HOST_TYPE_SERVER,
HOST_TYPE_INVALID
};
enum NetStatus
{
NET_STATUS_ONLINE,
NET_STATUS_OFFLINE,
NET_STATUS_INVALID
};
class SphereItem;
class TopologyViewer : public QGraphicsView
{
Q_OBJECT
public:
explicit TopologyViewer(QWidget *parent = 0);
~TopologyViewer();
void setData(QString data);
private:
void resizeEvent (QResizeEvent* event);
void wheelEvent(QWheelEvent*);
void addManagerItem(const QString &name, NetStatus status, QGraphicsItemGroup *group);
void addServerItem(const QString &name, NetStatus status, QGraphicsItemGroup *group);
void addArmItem(const QString &name, NetStatus status, QGraphicsItemGroup *group);
void addPausItem(const QString &name, NetStatus status, QGraphicsItemGroup *group);
QGraphicsPathItem* drawConnection(const QPointF &from, const QPointF &to);
void createConnection(QGraphicsItemGroup *group, QGraphicsItemGroup *item);
signals:
public slots:
private:
qreal scaleFactor;
QGraphicsScene* _scene;
QGraphicsItemGroup* _groupCenter;
QGraphicsItemGroup* _groupRight;
QGraphicsItemGroup* _groupLeft;
double xLeft; // left gtoup
double yLeft;
double xCenter; // central group
double yCenter;
double xRight; // right group
double yRight;
};
class SphereItem : public QGraphicsItem
{
//Q_OBJECT
public:
explicit SphereItem(const QString &name, const QRectF &rect, const QString &img, QGraphicsItem *parent = 0);
QPointF connectPointLeft();
QPointF connectPointRight();
QPointF center();
protected:
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0);
QRectF boundingRect() const;
QPainterPath shape() const;
private:
QString _name;
QString _img;
QRectF _rec;
};
#endif // SPHEREVIEW_H