QTfrontend/drawmapscene.h
author unc0rr
Wed, 02 Feb 2011 21:53:39 +0300
branchserver_refactor
changeset 4624 538e5556262b
parent 4560 5d6c7f88db73
child 4976 088d40d8aba2
permissions -rw-r--r--
Close branch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
     1
#ifndef DRAWMAPSCENE_H
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
     2
#define DRAWMAPSCENE_H
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
     3
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
     4
#include <QGraphicsScene>
4442
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
     5
#include <QPainterPath>
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
     6
4426
969e411c72aa Improve map editor a bit
unc0rr
parents: 4424
diff changeset
     7
class QGraphicsPathItem;
969e411c72aa Improve map editor a bit
unc0rr
parents: 4424
diff changeset
     8
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
     9
typedef QList<QList<QPoint> > Paths;
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    10
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    11
class DrawMapScene : public QGraphicsScene
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    12
{
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    13
Q_OBJECT
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    14
public:
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    15
    explicit DrawMapScene(QObject *parent = 0);
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    16
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    17
    QByteArray encode();
4442
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
    18
    void decode(QByteArray data);
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    19
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    20
signals:
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    21
    void pathChanged();
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    22
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    23
public slots:
4426
969e411c72aa Improve map editor a bit
unc0rr
parents: 4424
diff changeset
    24
    void undo();
4560
5d6c7f88db73 - Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents: 4520
diff changeset
    25
    void clearMap();
4439
27a896207aae Some more improvements
unC0Rr
parents: 4434
diff changeset
    26
    void simplifyLast();
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    27
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    28
private:
4424
3225ea34e415 Some basic functionality
unc0rr
parents: 4423
diff changeset
    29
    QPen m_pen;
3225ea34e415 Some basic functionality
unc0rr
parents: 4423
diff changeset
    30
    QBrush m_brush;
4426
969e411c72aa Improve map editor a bit
unc0rr
parents: 4424
diff changeset
    31
    QGraphicsPathItem  * m_currPath;
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    32
    Paths paths;
4424
3225ea34e415 Some basic functionality
unc0rr
parents: 4423
diff changeset
    33
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    34
    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent);
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    35
    virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent);
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    36
    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent);
4442
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
    37
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
    38
    QPainterPath pointsToPath(const QList<QPoint> points);
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    39
};
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
#endif // DRAWMAPSCENE_H