-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbngraphicsscene.h
64 lines (52 loc) · 1.42 KB
/
bngraphicsscene.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
/**
* \author trungvv1
*
* \date 3/25/2015
* \class MyGraphicsScene
*
* \brief write something about your class
*
*
*/
#ifndef MYGRAPHICSSCENE_H
#define MYGRAPHICSSCENE_H
#include <QGraphicsScene>
#include <QMap>
#include <QList>
class QBayesNode;
class QBayesEdge;
class BnGraphicsScene : public QGraphicsScene
{
Q_OBJECT
public:
static constexpr double RADIUS = 20;
BnGraphicsScene(QObject *parent = 0);
~BnGraphicsScene();
void setCurrentNodeLabel(QString label);
bool hasNodeSelected();
QBayesNode* getSelectedNode();
QBayesEdge* getSelectedEdge();
QBayesNode* getNodeAt(uint index) const;
QString toString() const;
void addNode(QString label, QPointF pos);
void addEdge(QBayesNode *parentNode, QBayesNode *childNode);
void loadFromText(QString *text);
void clearNetwork();
public slots:
void onNodeDeleted();
void onEdgeDeleted();
signals:
void nodeAdded();
void nodeDeleted(uint index);
void edgeAdded(uint parentIndex, uint childIndex);
void edgeDeleted(uint parentIndex, uint childIndex);
void nodePositionChanged();
protected:
void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);
void mousePressEvent(QGraphicsSceneMouseEvent *event);
private:
uint mNumNodes;
QMap<QBayesNode*, QList<QBayesEdge*>> mMapBayes; /// map each node to all edge related to it
QList<QBayesEdge*> mListEdges;
};
#endif // MYGRAPHICSSCENE_H