author | koda |
Fri, 26 Oct 2012 14:19:43 +0100 | |
branch | 0.9.16 |
changeset 6007 | b3b9e995ae90 |
parent 5858 | 1f4a8cf9efcb |
child 6616 | f77bb02b669f |
permissions | -rw-r--r-- |
4976 | 1 |
/* |
2 |
* Hedgewars, a free turn based strategy game |
|
3 |
* Copyright (c) 2011 Andrey Korotaev <unC0Rr@gmail.com> |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
4423 | 19 |
#ifndef DRAWMAPSCENE_H |
20 |
#define DRAWMAPSCENE_H |
|
21 |
||
22 |
#include <QGraphicsScene> |
|
4442 | 23 |
#include <QPainterPath> |
4423 | 24 |
|
4426 | 25 |
class QGraphicsPathItem; |
26 |
||
4427 | 27 |
typedef QList<QList<QPoint> > Paths; |
28 |
||
4423 | 29 |
class DrawMapScene : public QGraphicsScene |
30 |
{ |
|
31 |
Q_OBJECT |
|
32 |
public: |
|
33 |
explicit DrawMapScene(QObject *parent = 0); |
|
34 |
||
4427 | 35 |
QByteArray encode(); |
4442 | 36 |
void decode(QByteArray data); |
4427 | 37 |
|
4423 | 38 |
signals: |
4427 | 39 |
void pathChanged(); |
4423 | 40 |
|
41 |
public slots: |
|
4426 | 42 |
void undo(); |
4560
5d6c7f88db73
- Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents:
4520
diff
changeset
|
43 |
void clearMap(); |
4439 | 44 |
void simplifyLast(); |
4423 | 45 |
|
46 |
private: |
|
4424 | 47 |
QPen m_pen; |
48 |
QBrush m_brush; |
|
4426 | 49 |
QGraphicsPathItem * m_currPath; |
4427 | 50 |
Paths paths; |
5858
1f4a8cf9efcb
hand drawn map editor: allow "undo" after "clear"
sheepluva
parents:
4976
diff
changeset
|
51 |
Paths oldPaths; |
1f4a8cf9efcb
hand drawn map editor: allow "undo" after "clear"
sheepluva
parents:
4976
diff
changeset
|
52 |
QList<QGraphicsItem *> oldItems; |
4424 | 53 |
|
4423 | 54 |
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); |
55 |
virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent); |
|
56 |
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent); |
|
4442 | 57 |
|
58 |
QPainterPath pointsToPath(const QList<QPoint> points); |
|
4423 | 59 |
}; |
60 |
||
61 |
#endif // DRAWMAPSCENE_H |