QTfrontend/drawmapscene.h
author nemo
Sun, 11 Sep 2011 21:32:49 -0400
changeset 5872 454f246fe4c5
parent 5858 1f4a8cf9efcb
child 6616 f77bb02b669f
permissions -rw-r--r--
uh, that was just so I could look at the flame more closely, wasn't supposed to be checked in
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4976
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
     1
/*
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
     2
 * Hedgewars, a free turn based strategy game
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
     3
 * Copyright (c) 2011 Andrey Korotaev <unC0Rr@gmail.com>
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
     4
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
     8
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
    12
 * GNU General Public License for more details.
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
    13
 *
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
    14
 * You should have received a copy of the GNU General Public License
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
    15
 * along with this program; if not, write to the Free Software
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
    16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
    17
 */
088d40d8aba2 Happy 2011 :)
koda
parents: 4560
diff changeset
    18
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    19
#ifndef DRAWMAPSCENE_H
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    20
#define DRAWMAPSCENE_H
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    21
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    22
#include <QGraphicsScene>
4442
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
    23
#include <QPainterPath>
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    24
4426
969e411c72aa Improve map editor a bit
unc0rr
parents: 4424
diff changeset
    25
class QGraphicsPathItem;
969e411c72aa Improve map editor a bit
unc0rr
parents: 4424
diff changeset
    26
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    27
typedef QList<QList<QPoint> > Paths;
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    28
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    29
class DrawMapScene : public QGraphicsScene
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    30
{
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    31
Q_OBJECT
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    32
public:
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    33
    explicit DrawMapScene(QObject *parent = 0);
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    34
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    35
    QByteArray encode();
4442
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
    36
    void decode(QByteArray data);
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    37
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    38
signals:
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    39
    void pathChanged();
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    40
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    41
public slots:
4426
969e411c72aa Improve map editor a bit
unc0rr
parents: 4424
diff changeset
    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
27a896207aae Some more improvements
unC0Rr
parents: 4434
diff changeset
    44
    void simplifyLast();
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    45
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    46
private:
4424
3225ea34e415 Some basic functionality
unc0rr
parents: 4423
diff changeset
    47
    QPen m_pen;
3225ea34e415 Some basic functionality
unc0rr
parents: 4423
diff changeset
    48
    QBrush m_brush;
4426
969e411c72aa Improve map editor a bit
unc0rr
parents: 4424
diff changeset
    49
    QGraphicsPathItem  * m_currPath;
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    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
3225ea34e415 Some basic functionality
unc0rr
parents: 4423
diff changeset
    53
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    54
    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent);
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    55
    virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent);
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    56
    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent);
4442
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
    57
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
    58
    QPainterPath pointsToPath(const QList<QPoint> points);
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    59
};
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    60
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    61
#endif // DRAWMAPSCENE_H