equal
deleted
inserted
replaced
22 #include <QGraphicsScene> |
22 #include <QGraphicsScene> |
23 #include <QPainterPath> |
23 #include <QPainterPath> |
24 |
24 |
25 class QGraphicsPathItem; |
25 class QGraphicsPathItem; |
26 |
26 |
27 typedef QList<QPair<quint8, QList<QPoint> > > Paths; |
27 struct PathParams |
|
28 { |
|
29 quint8 width; |
|
30 bool erasing; |
|
31 QList<QPoint> points; |
|
32 }; |
|
33 |
|
34 typedef QList<PathParams> Paths; |
28 |
35 |
29 class DrawMapScene : public QGraphicsScene |
36 class DrawMapScene : public QGraphicsScene |
30 { |
37 { |
31 Q_OBJECT |
38 Q_OBJECT |
32 public: |
39 public: |
40 |
47 |
41 public slots: |
48 public slots: |
42 void undo(); |
49 void undo(); |
43 void clearMap(); |
50 void clearMap(); |
44 void simplifyLast(); |
51 void simplifyLast(); |
|
52 void setErasing(bool erasing); |
45 |
53 |
46 private: |
54 private: |
47 QPen m_pen; |
55 QPen m_pen; |
|
56 QBrush m_eraser; |
48 QBrush m_brush; |
57 QBrush m_brush; |
49 QGraphicsPathItem * m_currPath; |
58 QGraphicsPathItem * m_currPath; |
50 Paths paths; |
59 Paths paths; |
51 Paths oldPaths; |
60 Paths oldPaths; |
|
61 bool m_isErasing; |
52 QList<QGraphicsItem *> oldItems; |
62 QList<QGraphicsItem *> oldItems; |
53 |
63 |
54 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); |
64 virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); |
55 virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent); |
65 virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent); |
56 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent); |
66 virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent); |