QTfrontend/drawmapscene.h
author unc0rr
Wed, 28 Mar 2012 23:53:45 +0400
changeset 6834 2af81d3b176d
parent 6781 23f627ba8ee9
child 6873 30840365af0a
permissions -rw-r--r--
Resolve deferred type on dereference
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
6700
e04da46ee43c the most important commit of the year
koda
parents: 6616
diff changeset
     3
 * Copyright (c) 2012 Andrey Korotaev <unC0Rr@gmail.com>
4976
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
6781
23f627ba8ee9 Variable pen width
unc0rr
parents: 6700
diff changeset
    27
typedef QList<QPair<quint8, QList<QPoint> > > Paths;
4427
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
{
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    31
        Q_OBJECT
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    32
    public:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    33
        explicit DrawMapScene(QObject *parent = 0);
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    34
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    35
        QByteArray encode();
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    36
        void decode(QByteArray data);
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    37
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    38
    signals:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    39
        void pathChanged();
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    40
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    41
    public slots:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    42
        void undo();
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    43
        void clearMap();
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    44
        void simplifyLast();
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    45
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    46
    private:
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    47
        QPen m_pen;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    48
        QBrush m_brush;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    49
        QGraphicsPathItem  * m_currPath;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    50
        Paths paths;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    51
        Paths oldPaths;
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    52
        QList<QGraphicsItem *> oldItems;
4424
3225ea34e415 Some basic functionality
unc0rr
parents: 4423
diff changeset
    53
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    54
        virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent);
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    55
        virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent);
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    56
        virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent);
6781
23f627ba8ee9 Variable pen width
unc0rr
parents: 6700
diff changeset
    57
        virtual void wheelEvent(QGraphicsSceneWheelEvent *);
4442
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
    58
6616
f77bb02b669f astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents: 5858
diff changeset
    59
        QPainterPath pointsToPath(const QList<QPoint> points);
6781
23f627ba8ee9 Variable pen width
unc0rr
parents: 6700
diff changeset
    60
23f627ba8ee9 Variable pen width
unc0rr
parents: 6700
diff changeset
    61
        quint8 serializePenWidth(int width);
23f627ba8ee9 Variable pen width
unc0rr
parents: 6700
diff changeset
    62
        int deserializePenWidth(quint8 width);
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    63
};
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    64
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    65
#endif // DRAWMAPSCENE_H