diff options
author | sumit | 2020-06-10 08:50:29 +0530 |
---|---|---|
committer | sumit | 2020-06-10 08:50:29 +0530 |
commit | 6772ab7c10214b816b74d36b37d8ddf68230da5a (patch) | |
tree | 29f10fa33293d6b65d6893d6779752d7637223ac /src/main | |
parent | 640e2e92688fa79a23aa229d12cb4e4437a377f7 (diff) | |
download | Chemical-PFD-6772ab7c10214b816b74d36b37d8ddf68230da5a.tar.gz Chemical-PFD-6772ab7c10214b816b74d36b37d8ddf68230da5a.tar.bz2 Chemical-PFD-6772ab7c10214b816b74d36b37d8ddf68230da5a.zip |
fix remove of line with item
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/python/shapes/line.py | 5 | ||||
-rw-r--r-- | src/main/python/shapes/shapes.py | 21 |
2 files changed, 15 insertions, 11 deletions
diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 0af0585..268b750 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -805,6 +805,11 @@ class Line(QGraphicsPathItem): else: self.hideGripItem() return + if change == QGraphicsItem.ItemSceneHasChanged and not self.scene(): + for line in self.midLines: + if line.scene(): + line.scene().removeItem(line) + return super(Line, self).itemChange(change, value) diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index a795f6a..fe92938 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -203,6 +203,15 @@ class LineGripItem(GripItem): self.setFlag(QGraphicsItem.ItemIsSelectable, True) self.setPen(QPen(QColor("black"), -1)) + def itemChange(self, change, value): + """ + Moves position of grip item on resize + """ + if change == QGraphicsItem.ItemSceneHasChanged and not self.scene(): + if self.line and self.line.scene(): + self.line.scene().removeItem(self.line) + return super(LineGripItem, self).itemChange(change, value) + def point(self, index): """ yields a list of positions of grip items in a node item @@ -439,23 +448,13 @@ class NodeItem(QGraphicsSvgItem): self.updateLineGripItem() self.updateSizeGripItem() return - if change == QGraphicsItem.ItemSceneHasChanged: + if change == QGraphicsItem.ItemSceneHasChanged and self.scene(): self.addGripItem() self.updateLineGripItem() self.updateSizeGripItem() return return super(NodeItem, self).itemChange(change, value) - def removeFromCanvas(self): - """This function is used to remove item from canvas - :return: - """ - for item in self.lineGripItems: - item.removeConnectedLines() - for item in self.sizeGripItems: - item.removeFromCanvas() - self.scene().removeItem(self) - def hoverEnterEvent(self, event): """defines shape highlighting on Mouse Over """ |