From 7e09e122f75145085ba93a25d19759a8711771c7 Mon Sep 17 00:00:00 2001 From: Blaine Date: Wed, 17 Jun 2020 14:43:10 +0530 Subject: preserve comments --- src/main/python/shapes/line.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/main/python/shapes') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 1438fbc..c893fe6 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -284,10 +284,8 @@ class LineLabel(QGraphicsTextItem): def focusOutEvent(self, event): super(LineLabel, self).focusOutEvent(event) - self.setTextInteractionFlags(Qt.NoTextInteraction) - self.nameChanged.emit() - self.setTextInteractionFlags(Qt.NoTextInteraction) # set text non interactive + self.nameChanged.emit() def __getstate__(self): return { -- cgit From fe42ad1a31426b58809d22d29131c6861723b1a3 Mon Sep 17 00:00:00 2001 From: Blaine Date: Wed, 17 Jun 2020 15:21:26 +0530 Subject: line and grip items work properly --- src/main/python/shapes/shapes.py | 41 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'src/main/python/shapes') diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index 117ffb8..05ac233 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -12,6 +12,17 @@ from PyQt5.QtWidgets import (QGraphicsColorizeEffect, QGraphicsEllipseItem, from .line import Line, findIndex from utils.app import fileImporter +directionsEnum = [ + "top", + "right", + "left", + "bottom" +] + +orientationEnum = [ + Qt.Horizontal, + Qt.Vertical +] class ItemLabel(QGraphicsTextItem): """Extends PyQt5's QGraphicsPathItem to create text label for svg item @@ -91,7 +102,7 @@ class SizeGripItem(QGraphicsPathItem): self.setPen(QPen(QColor("black"), 0)) self.setZValue(2) # property direction - self._direction = direction + self._direction = orientationEnum.index(direction) self.m_index = index @property @@ -99,7 +110,10 @@ class SizeGripItem(QGraphicsPathItem): """ property that returns the current intended resize direction of the grip item object """ - return self._direction + if self.parentItem().rotation % 2: + return orientationEnum[(self._direction + 1)%2] + else: + return orientationEnum[self._direction] def updatePath(self): """updates path of size grip item @@ -209,7 +223,7 @@ class LineGripItem(QGraphicsPathItem): # store position of self self.position = QPointF(grip[0], grip[1]) # set location - self._m_location = grip[2] + self._m_location = directionsEnum.index(grip[2]) # set size in case of rectangle grip self.size = grip[3] if len(grip) == 4 else None # stores current line which is in process @@ -226,7 +240,11 @@ class LineGripItem(QGraphicsPathItem): @property def m_location(self): - return self._m_location + return directionsEnum[(self._m_location + self.parentItem().rotation)%4] + + @m_location.setter + def m_location(self, location): + self._m_location = directionsEnum.index(location) def shape(self): # return interactive path @@ -428,7 +446,22 @@ class NodeItem(QGraphicsSvgItem): self.lineGripItems = [] self.sizeGripItems = [] self.label = None + self._rotation = 0 + @property + def rotation(self): + return self._rotation + + @rotation.setter + def rotation(self, rotation): + self._rotation = rotation % 4 + transform = QTransform() + transform.rotate(90*rotation) + self.setTransform(transform) + for i in self.lineGripItems: + for j in i.lines: + j.createPath() + def boundingRect(self): """Overrides QGraphicsSvgItem's boundingRect() virtual public function and returns a valid bounding -- cgit From 776c773f17632d12247a13640cc294f5dbb2fa7d Mon Sep 17 00:00:00 2001 From: Blaine Date: Wed, 17 Jun 2020 19:25:56 +0530 Subject: minor fixes --- src/main/python/shapes/shapes.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/main/python/shapes') diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index 05ac233..dbf3e9e 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -102,9 +102,13 @@ class SizeGripItem(QGraphicsPathItem): self.setPen(QPen(QColor("black"), 0)) self.setZValue(2) # property direction - self._direction = orientationEnum.index(direction) - self.m_index = index + self._direction = (orientationEnum.index(direction) + self.parentItem().rotation) % 4 + self._m_index = index + @property + def m_index(self): + return (self._m_index + self.parentItem().rotation) % 4 + @property def direction(self): """ -- cgit From 4e52d02b6e7ccc36176eb90f35bd1013ecc74a10 Mon Sep 17 00:00:00 2001 From: Blaine Date: Thu, 18 Jun 2020 13:57:11 +0530 Subject: minor fix --- src/main/python/shapes/shapes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main/python/shapes') diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index dbf3e9e..71e9be7 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -15,8 +15,8 @@ from utils.app import fileImporter directionsEnum = [ "top", "right", - "left", - "bottom" + "bottom", + "left" ] orientationEnum = [ -- cgit From 79b0690d4ae7d9f8853aa90ba0cdbe58af7c1c4d Mon Sep 17 00:00:00 2001 From: Blaine Date: Thu, 18 Jun 2020 14:00:01 +0530 Subject: fix line grip item transform --- src/main/python/shapes/shapes.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/main/python/shapes') diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index 71e9be7..7205ba7 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -463,6 +463,8 @@ class NodeItem(QGraphicsSvgItem): transform.rotate(90*rotation) self.setTransform(transform) for i in self.lineGripItems: + i.setTransform(transform) + i.updatePosition() for j in i.lines: j.createPath() -- cgit