summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrenda-br2023-02-14 22:49:19 +0530
committerbrenda-br2023-02-14 22:49:19 +0530
commit2e4bef6ce1f52286467369e3b2ef642c5d9bd01d (patch)
tree9308417d0af9e22182db96276dfb7081170bf6b1
parent1cd054c8a19bbb4d47c8515d844f2a7bd58da5e9 (diff)
downloadChemical-Simulator-GUI-2e4bef6ce1f52286467369e3b2ef642c5d9bd01d.tar.gz
Chemical-Simulator-GUI-2e4bef6ce1f52286467369e3b2ef642c5d9bd01d.tar.bz2
Chemical-Simulator-GUI-2e4bef6ce1f52286467369e3b2ef642c5d9bd01d.zip
Fix #57 Unit Operations can be moved only inside the view
-rw-r--r--.gitignore1
-rw-r--r--Graphics.py11
-rw-r--r--Undo.datbin869 -> 2508 bytes
3 files changed, 12 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index aa892f0..10f3ec9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,3 +13,4 @@ DockWidgets/__pycache__/*
Undo.dat
test.py
Undo.dat
+Undo.dat
diff --git a/Graphics.py b/Graphics.py
index 9c55350..594db08 100644
--- a/Graphics.py
+++ b/Graphics.py
@@ -549,6 +549,7 @@ class NodeItem(QtWidgets.QGraphicsItem):
self.setFlag(QtWidgets.QGraphicsPixmapItem.ItemIsMovable)
self.setFlag(QtWidgets.QGraphicsPixmapItem.ItemIsSelectable)
+ self.setFlag(QGraphicsItem.ItemSendsGeometryChanges)
# Brush
self.brush = QtGui.QBrush()
@@ -677,6 +678,16 @@ class NodeItem(QtWidgets.QGraphicsItem):
for op in i.output:
op.hide()
+ def itemChange(self, change, value):
+ newPos = value
+ if change == self.ItemPositionChange and self.scene():
+ rect = self.container.graphicsView.sceneRect()
+ if not rect.__contains__(newPos):
+ newPos.setX(min(rect.right()-100, max(newPos.x(), rect.left())))
+ newPos.setY(min(rect.bottom()-35, max(newPos.y(), rect.top())))
+ self.obj.set_pos(newPos)
+ return super(NodeItem,self).itemChange(change, newPos)
+
def findMainWindow(self):
'''
Global function to find the (open) QMainWindow in application
diff --git a/Undo.dat b/Undo.dat
index d30c913..6870dcc 100644
--- a/Undo.dat
+++ b/Undo.dat
Binary files differ