From 4da87bd62231592002b179f3195d11d93e08d8a3 Mon Sep 17 00:00:00 2001 From: tzutalin Date: Thu, 17 Dec 2015 13:33:13 +0800 Subject: [PATCH] Avoid to be deformed while resizing it --- libs/canvas.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/libs/canvas.py b/libs/canvas.py index 356a7083..be211e23 100644 --- a/libs/canvas.py +++ b/libs/canvas.py @@ -288,7 +288,22 @@ class Canvas(QWidget): point = shape[index] if self.outOfPixmap(pos): pos = self.intersectionPoint(point, pos) - shape.moveVertexBy(index, pos - point) + + shiftPos = pos - point + shape.moveVertexBy(index, shiftPos) + + lindex = (index + 1) % 4 + rindex = (index + 3) % 4 + lshift = None + rshift = None + if index % 2 == 0: + rshift = QPointF(shiftPos.x(), 0) + lshift = QPointF(0, shiftPos.y()) + else: + lshift = QPointF(shiftPos.x(), 0) + rshift = QPointF(0, shiftPos.y()) + shape.moveVertexBy(rindex, rshift) + shape.moveVertexBy(lindex, lshift) def boundedMoveShape(self, shape, pos): if self.outOfPixmap(pos):