summaryrefslogtreecommitdiff
path: root/src/main/python/shapes/shapes.py
diff options
context:
space:
mode:
authorpravindalve2020-06-10 11:28:50 +0530
committerGitHub2020-06-10 11:28:50 +0530
commit0d33ceda3262494437fe022466e4368db62c8849 (patch)
treec935128e1212c4a264689f44d841c97eaf8257b6 /src/main/python/shapes/shapes.py
parent181f050b352560fa5dbbbcf4888db2ccd7a37061 (diff)
parent0d09cb1bf30e2370b0a160375dad0e7c926b9515 (diff)
downloadChemical-PFD-0d33ceda3262494437fe022466e4368db62c8849.tar.gz
Chemical-PFD-0d33ceda3262494437fe022466e4368db62c8849.tar.bz2
Chemical-PFD-0d33ceda3262494437fe022466e4368db62c8849.zip
Merge pull request #11 from Sumit-Sahu/master
make shape of line grabber independent of line path,fix in initial path of line,fix removing of items
Diffstat (limited to 'src/main/python/shapes/shapes.py')
-rw-r--r--src/main/python/shapes/shapes.py26
1 files changed, 10 insertions, 16 deletions
diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py
index a795f6a..0358898 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
@@ -231,9 +240,6 @@ class LineGripItem(GripItem):
if mouseEvent.button() != Qt.LeftButton:
return
# initialize a line and add on scene
- if self.line and not self.line.scene():
- self.line = None
-
if not self.line:
startPoint = endPoint = self.parentItem().mapToScene(self.pos())
self.tempLine = Line(startPoint, endPoint)
@@ -268,8 +274,6 @@ class LineGripItem(GripItem):
items = self.scene().items(QPointF(mouseEvent.scenePos().x(), mouseEvent.scenePos().y()))
for item in items:
if type(item) == LineGripItem and item != self:
- if item.line and not item.line.scene():
- item.line = None
if item.line:
break
self.tempLine.setStartGripItem(self)
@@ -439,23 +443,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
"""