-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmyqgraphicsview.h
executable file
·62 lines (51 loc) · 1.4 KB
/
myqgraphicsview.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
#ifndef MYQGRAPHICSVIEW_H
#define MYQGRAPHICSVIEW_H
#include <QWidget>
#include <QGraphicsView>
#include <QGraphicsScene>
#include <QGraphicsEllipseItem>
#include <QMouseEvent>
#include <QGraphicsLineItem>
#include <QPointF>
#include <QInputDialog>
#include "interface.h"
#include "Prim.h"
#include "gplace.h"
#include "gedge.h"
#define NO_TYPE 0
#define PLACE 1
#define EDGE 2
class MyQGraphicsView : public QGraphicsView
{
Q_OBJECT
public:
explicit MyQGraphicsView(QWidget *parent = 0);
void setDrawType(int m_draw_type);
void makeItemsSelectable(bool is_selectable);
void clearAll();
void clearView();
void redrawView();
signals:
public slots:
void mousePressEvent(QMouseEvent *e);
void mouseReleaseEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *e);
void keyPressEvent(QKeyEvent *e);
void selectionChanged(void);
private:
QGraphicsScene *scene;
QPen blackpen;
QPen redpen;
unsigned id; // unique identifier of place
gPlace *edge_start_place;
QGraphicsLineItem *line;
QLineF *new_line;
QPointF edge_start_point;
bool drawing_edge; // true while mouse is pressed and draw_type
// is EDGE
int draw_type;
bool left_button_pressed;
const qreal diameter = 30;
const qreal radius = 15;
};
#endif // MYQGRAPHICSVIEW_H