-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphwidget.h
More file actions
80 lines (59 loc) · 1.47 KB
/
graphwidget.h
File metadata and controls
80 lines (59 loc) · 1.47 KB
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
#ifndef GRAPHWIDGET_H
#define GRAPHWIDGET_H
#include <QWidget>
#include <QGraphicsView>
#include <QGraphicsScene>
#include<gnode.h>
#include<gedge.h>
#include"graphs.h"
#define MAX_GNODES 50
#define MAX_EDGES 1180
#define GITEM_NODE 0
#define GITEM_EDGE 1
namespace graphs
{
namespace ui
{
class GraphWidget: public QGraphicsView
{
Q_OBJECT
enum ERROR{
OK = 0,
MAX_NODES_REACHED = 1
};
QGraphicsScene* scene;
int _NodeIndex;
GNode* _Nodes[MAX_GNODES];
int _EdgeIndex;
GEdge* _Edges[MAX_EDGES];
bool bShift;
bool _bDirected;
bool _bArrowLabel;
int nSelected[2];
int _countSel;
void resetNodes();
void connectNodes();
Graph G;
protected:
void mouseDoubleClickEvent(QMouseEvent * event);
void keyPressEvent(QKeyEvent * event);
void keyReleaseEvent(QKeyEvent * event);
signals:
void errorRaised(int code);
void nodeCreated(GNode* node);
//void nodesConnected(GNode* nodeIni, GNode* nodeFin, GEdge* edge);
//void nodeChanged(GNode* node);
public slots:
void nodePressed(GNode* node);
//void nodeMoved(GNode* node);
void edgeLengthChanged(int id, long newL);
public:
GraphWidget(bool directed, QWidget *parent = 0);
void resetGraphAppearance(bool hided);
void setItemOpacity(int id, int itemType, bool show);
void showArrowLabel();
const Graph& Graph();
};
} //namespace ui
} //namespace graphs
#endif // GRAPHWIDGET_H