Draw straight lines while holding Alt key
authorunc0rr
Wed, 09 Feb 2011 21:59:43 +0300
changeset 4937 55b9145fea94
parent 4936 d65d438acd23
child 4938 0985edac2ad7
Draw straight lines while holding Alt key
QTfrontend/drawmapscene.cpp
--- a/QTfrontend/drawmapscene.cpp	Tue Feb 08 22:24:30 2011 +0300
+++ b/QTfrontend/drawmapscene.cpp	Wed Feb 09 21:59:43 2011 +0300
@@ -1,6 +1,7 @@
 #include <QGraphicsSceneMouseEvent>
 #include <QGraphicsPathItem>
 #include <QtEndian>
+#include <QDebug>
 
 #include "drawmapscene.h"
 
@@ -32,8 +33,18 @@
     if(m_currPath && (mouseEvent->buttons() & Qt::LeftButton))
     {
         QPainterPath path = m_currPath->path();
-        path.lineTo(mouseEvent->scenePos());
-        paths.first().append(mouseEvent->scenePos().toPoint());
+
+        if(mouseEvent->modifiers() & Qt::AltModifier)
+        {
+            int c = path.elementCount();
+            QPointF pos = mouseEvent->scenePos();
+            path.setElementPositionAt(c - 1, pos.x(), pos.y());
+
+        } else
+        {
+            path.lineTo(mouseEvent->scenePos());
+            paths.first().append(mouseEvent->scenePos().toPoint());
+        }
         m_currPath->setPath(path);
 
         emit pathChanged();