QTfrontend/drawmapscene.cpp
changeset 4937 55b9145fea94
parent 4666 34551d8639cf
child 4938 0985edac2ad7
equal deleted inserted replaced
4936:d65d438acd23 4937:55b9145fea94
     1 #include <QGraphicsSceneMouseEvent>
     1 #include <QGraphicsSceneMouseEvent>
     2 #include <QGraphicsPathItem>
     2 #include <QGraphicsPathItem>
     3 #include <QtEndian>
     3 #include <QtEndian>
       
     4 #include <QDebug>
     4 
     5 
     5 #include "drawmapscene.h"
     6 #include "drawmapscene.h"
     6 
     7 
     7 template <class T> T sqr(const T & x)
     8 template <class T> T sqr(const T & x)
     8 {
     9 {
    30 void DrawMapScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent)
    31 void DrawMapScene::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent)
    31 {
    32 {
    32     if(m_currPath && (mouseEvent->buttons() & Qt::LeftButton))
    33     if(m_currPath && (mouseEvent->buttons() & Qt::LeftButton))
    33     {
    34     {
    34         QPainterPath path = m_currPath->path();
    35         QPainterPath path = m_currPath->path();
    35         path.lineTo(mouseEvent->scenePos());
    36 
    36         paths.first().append(mouseEvent->scenePos().toPoint());
    37         if(mouseEvent->modifiers() & Qt::AltModifier)
       
    38         {
       
    39             int c = path.elementCount();
       
    40             QPointF pos = mouseEvent->scenePos();
       
    41             path.setElementPositionAt(c - 1, pos.x(), pos.y());
       
    42 
       
    43         } else
       
    44         {
       
    45             path.lineTo(mouseEvent->scenePos());
       
    46             paths.first().append(mouseEvent->scenePos().toPoint());
       
    47         }
    37         m_currPath->setPath(path);
    48         m_currPath->setPath(path);
    38 
    49 
    39         emit pathChanged();
    50         emit pathChanged();
    40     }
    51     }
    41 }
    52 }