tools/drawMapTest/drawmapscene.h
author sheepluva
Thu, 22 Sep 2011 14:02:44 +0200
changeset 5990 578978418fe5
parent 4442 f8424e1bc936
permissions -rw-r--r--
let frontend send (copypasta) multi-line messages line by line to avoid protocol violation
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();
4439
27a896207aae Some more improvements
unC0Rr
parents: 4434
diff changeset
    25
    void simplifyLast();
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    26
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    27
private:
4424
3225ea34e415 Some basic functionality
unc0rr
parents: 4423
diff changeset
    28
    QPen m_pen;
3225ea34e415 Some basic functionality
unc0rr
parents: 4423
diff changeset
    29
    QBrush m_brush;
4426
969e411c72aa Improve map editor a bit
unc0rr
parents: 4424
diff changeset
    30
    QGraphicsPathItem  * m_currPath;
4427
c5193713055f Basic encoding of drawn map
unc0rr
parents: 4426
diff changeset
    31
    Paths paths;
4424
3225ea34e415 Some basic functionality
unc0rr
parents: 4423
diff changeset
    32
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    33
    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent);
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    34
    virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent);
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    35
    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent);
4442
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
    36
f8424e1bc936 - Implement decode() function.
unc0rr
parents: 4439
diff changeset
    37
    QPainterPath pointsToPath(const QList<QPoint> points);
4423
4391526e436e Initial commit of the Draw Map Scene
unc0rr
parents:
diff changeset
    38
};
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
#endif // DRAWMAPSCENE_H