-
Notifications
You must be signed in to change notification settings - Fork 1
/
qmapperdbscene.h
81 lines (58 loc) · 1.86 KB
/
qmapperdbscene.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
#ifndef QMAPPERDBSCENE_H
#define QMAPPERDBSCENE_H
#include <QGraphicsItem>
#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QDebug>
#include "qmapperdbmodel.h"
#include "customrect.h"
#include "qmapperscenelayer.h"
//for Z-order of objects
#define MAPPER_SCENE_TOP_LAYER 30
#define MAPPER_SCENE_MIDDLE_LAYER 20
#define MAPPER_SCENE_BOTTOM_LAYER 10
class QMapperDbScene : public QGraphicsScene
{
Q_OBJECT
public:
QMapperDbScene(QObject *parent);
~QMapperDbScene();
void updateScene();
void redrawMapPaths();
void setMapperDbModel(QMapperDbModel* model);
void setMapperDbModelActive(QMapperDbModel* model);
void updateTempPath();
void addMap(int src_idx, int dst_idx, bool ifExistsRemove = false);
int mapExists(int src_idx, int dst_idx);
void updateMapPaths();
void removeMapPaths();
//void mouseMoveEvent(QGraphicsSceneMouseEvent *e);
void setAlpha(int alpha);
public Q_SLOTS:
void mouseDropped(QPointF pos); //not used any more
void mouseDropped(QPointF src_pos, QPointF drop_pos);
void mouseDragged(QPointF pos); //not used any more
void mouseDragged(QPointF src_pos, QPointF drag_pos);
void devsigMoved();
void mouseDoubleClicked();
private:
//find index of item within square hitbox of certain length
int getIndexOfSigNear(QPointF pos, float len);
private:
QMapperDbModel *dbModel;
std::vector<CustomRect*> sigs;
//draw items for temp line
QGraphicsPathItem tempPathItem;
QPainterPath tempPath;
QPointF mapPtSrc;
QPointF mapPtDst;
//draw items for map list
std::vector<QGraphicsPathItem*> mapPathItems;
std::vector<QPointF> mapSrcs;
std::vector<QPointF> mapDsts;
//list of map src/dsts
std::vector<int> mapSrcIdxs;
std::vector<int> mapDstIdxs;
QMapperSceneLayer activeLayer;
};
#endif // QMAPPERDBSCENE_H