QTfrontend/drawmapscene.h
changeset 9551 61f160dfd0f1
parent 9472 265e5997580e
child 9555 485b424be769
equal deleted inserted replaced
9549:ac5c1f691ce2 9551:61f160dfd0f1
    27 
    27 
    28 struct PathParams
    28 struct PathParams
    29 {
    29 {
    30     quint8 width;
    30     quint8 width;
    31     bool erasing;
    31     bool erasing;
       
    32     QPoint initialPoint;
    32     QList<QPoint> points;
    33     QList<QPoint> points;
    33 };
    34 };
    34 
    35 
    35 typedef QList<PathParams> Paths;
    36 typedef QList<PathParams> Paths;
    36 
    37 
    37 class DrawMapScene : public QGraphicsScene
    38 class DrawMapScene : public QGraphicsScene
    38 {
    39 {
    39         Q_OBJECT
    40         Q_OBJECT
    40     public:
    41     public:
       
    42         enum PathType {
       
    43             Polyline  = 0,
       
    44             Rectangle = 1,
       
    45             Ellipse   = 2
       
    46         };
       
    47 
    41         explicit DrawMapScene(QObject *parent = 0);
    48         explicit DrawMapScene(QObject *parent = 0);
    42 
    49 
    43         QByteArray encode();
    50         QByteArray encode();
    44         void decode(QByteArray data);
    51         void decode(QByteArray data);
    45         int pointsCount();
    52         int pointsCount();
    52         void clearMap();
    59         void clearMap();
    53         void simplifyLast();
    60         void simplifyLast();
    54         void setErasing(bool erasing);
    61         void setErasing(bool erasing);
    55         void showCursor();
    62         void showCursor();
    56         void hideCursor();
    63         void hideCursor();
       
    64         void setPathType(PathType pathType);
    57 
    65 
    58     private:
    66     private:
    59         QPen m_pen;
    67         QPen m_pen;
    60         QBrush m_eraser;
    68         QBrush m_eraser;
    61         QBrush m_brush;
    69         QBrush m_brush;
    65         bool m_isErasing;
    73         bool m_isErasing;
    66         QList<QGraphicsItem *> oldItems;
    74         QList<QGraphicsItem *> oldItems;
    67         QGraphicsEllipseItem * m_cursor;
    75         QGraphicsEllipseItem * m_cursor;
    68         bool m_isCursorShown;
    76         bool m_isCursorShown;
    69         QByteArray m_specialPoints;
    77         QByteArray m_specialPoints;
       
    78         PathType m_pathType;
    70 
    79 
    71         virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent);
    80         virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent);
    72         virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent);
    81         virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent);
    73         virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent);
    82         virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent);
    74         virtual void wheelEvent(QGraphicsSceneWheelEvent *);
    83         virtual void wheelEvent(QGraphicsSceneWheelEvent *);
    75 
    84 
    76         QPainterPath pointsToPath(const QList<QPoint> points);
    85         QPainterPath pointsToPath(const QList<QPoint> points);
    77 
    86 
    78         quint8 serializePenWidth(int width);
    87         quint8 serializePenWidth(int width);
    79         int deserializePenWidth(quint8 width);
    88         int deserializePenWidth(quint8 width);
       
    89         QList<QPointF> makeEllipse(const QPointF & center, const QPointF & corner);
    80 };
    90 };
    81 
    91 
    82 #endif // DRAWMAPSCENE_H
    92 #endif // DRAWMAPSCENE_H