QTfrontend/drawmapscene.h
author unc0rr
Mon, 13 Dec 2010 22:12:30 +0300
changeset 4520 e7882bd1a894
parent 4442 tools/drawMapTest/drawmapscene.h@f8424e1bc936
child 4560 5d6c7f88db73
permissions -rw-r--r--
Allow to draw maps in frontend and play them (only locally, some bugs to fix)

#ifndef DRAWMAPSCENE_H
#define DRAWMAPSCENE_H

#include <QGraphicsScene>
#include <QPainterPath>

class QGraphicsPathItem;

typedef QList<QList<QPoint> > Paths;

class DrawMapScene : public QGraphicsScene
{
Q_OBJECT
public:
    explicit DrawMapScene(QObject *parent = 0);

    QByteArray encode();
    void decode(QByteArray data);

signals:
    void pathChanged();

public slots:
    void undo();
    void simplifyLast();

private:
    QPen m_pen;
    QBrush m_brush;
    QGraphicsPathItem  * m_currPath;
    Paths paths;

    virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent);
    virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent);
    virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent);

    QPainterPath pointsToPath(const QList<QPoint> points);
};

#endif // DRAWMAPSCENE_H