diff options
author | Blaine | 2020-05-28 20:49:24 +0530 |
---|---|---|
committer | Blaine | 2020-05-28 20:49:24 +0530 |
commit | e42080caf6c315ce46cb8f3e1e0a25e06cbed02f (patch) | |
tree | a5df66fc3fcbb1bb9f9d4826ceb5db06fe5b1918 /src/main/python/utils/graphics.py | |
parent | e71280aadb91ce6345b9b8c55833c0e70c8de874 (diff) | |
download | Chemical-PFD-e42080caf6c315ce46cb8f3e1e0a25e06cbed02f.tar.gz Chemical-PFD-e42080caf6c315ce46cb8f3e1e0a25e06cbed02f.tar.bz2 Chemical-PFD-e42080caf6c315ce46cb8f3e1e0a25e06cbed02f.zip |
customScene collision boilerplate
Diffstat (limited to 'src/main/python/utils/graphics.py')
-rw-r--r-- | src/main/python/utils/graphics.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/main/python/utils/graphics.py b/src/main/python/utils/graphics.py index a997a30..27e02c4 100644 --- a/src/main/python/utils/graphics.py +++ b/src/main/python/utils/graphics.py @@ -86,9 +86,15 @@ class customScene(QGraphicsScene): def __init__(self, *args, parent=None): super(customScene, self).__init__(*args, parent=parent) + self.setItemIndexMethod(QGraphicsScene.NoIndex) + self.undoStack = QUndoStack(self) #Used to store undo-redo moves self.createActions() #creates necessary actions that need to be called for undo-redo + def update(self, *args): + self.advance() + return super(customScene, self).update(*args) + def createActions(self): # helper function to create delete, undo and redo shortcuts self.deleteAction = QAction("Delete Item", self) @@ -114,6 +120,7 @@ class customScene(QGraphicsScene): def itemMoved(self, movedItem, lastPos): #item move event, checks if item is moved self.undoStack.push(moveCommand(movedItem, lastPos)) + self.advance() def addItemPlus(self, item): # extended add item method, so that a corresponding undo action is also pushed |