summaryrefslogtreecommitdiffstats
path: root/line.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'line.cpp')
-rw-r--r--line.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/line.cpp b/line.cpp
index d569c0c..5f7e171 100644
--- a/line.cpp
+++ b/line.cpp
@@ -44,3 +44,25 @@ void Line::draw(QPainter *painter)
painter->drawLine(p1(), p2());
}
+
+void Line::move(const QPoint &oldPoint, const QPoint &newPoint)
+{
+ if(m_selected)
+ {
+ QPoint offset = newPoint - oldPoint;
+ QVector3D vecOld(oldPoint);
+ if(vecOld.distanceToPoint(QVector3D(p1())) < 5)
+ {
+ setP1(p1() + offset);
+ }
+ else if(vecOld.distanceToPoint(QVector3D(p2())) < 5)
+ {
+ setP2(p2() + offset);
+ }
+ else
+ {
+ setP1(p1() + offset);
+ setP2(p2() + offset);
+ }
+ }
+}