From c21e2857f6c0de9ab94c4b768fbde0de817aede4 Mon Sep 17 00:00:00 2001 From: brenda-br Date: Thu, 16 Feb 2023 18:01:26 +0530 Subject: Fix #57 Repositioning unit operations --- Graphics.py | 10 +++++++--- Undo.dat | Bin 2508 -> 61657 bytes 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Graphics.py b/Graphics.py index 594db08..1d9e7ef 100644 --- a/Graphics.py +++ b/Graphics.py @@ -682,9 +682,13 @@ class NodeItem(QtWidgets.QGraphicsItem): 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()))) + width = self.boundingRect().width() + height = self.boundingRect().height() + eWH1 = QPointF(newPos.x()+width,newPos.y()+height) + eWH2 = QPointF(newPos.x()-width,newPos.y()-height) + if not rect.__contains__(eWH1) or not rect.__contains__(eWH2) : + newPos.setX(min(rect.right()-width-40, max(newPos.x(), rect.left()))) + newPos.setY(min(rect.bottom()-height-35, max(newPos.y(), rect.top()))) self.obj.set_pos(newPos) return super(NodeItem,self).itemChange(change, newPos) diff --git a/Undo.dat b/Undo.dat index 6870dcc..7cf571d 100644 Binary files a/Undo.dat and b/Undo.dat differ -- cgit