summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/main/python/shapes/shapes.py44
-rw-r--r--src/main/python/utils/graphics.py7
-rw-r--r--src/main/python/utils/undo.py1
3 files changed, 52 insertions, 0 deletions
diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py
index 19c0298..582215e 100644
--- a/src/main/python/shapes/shapes.py
+++ b/src/main/python/shapes/shapes.py
@@ -5,10 +5,24 @@ from PyQt5.QtWidgets import QLineEdit, QGraphicsItem, QGraphicsEllipseItem, QGra
from PyQt5.QtGui import QPen, QColor, QFont, QCursor, QPainterPath, QPainter, QDrag, QBrush, QImage, QTransform
from PyQt5.QtCore import Qt, QRectF, QPointF, QSizeF, QEvent, QMimeData, QFile, QIODevice, QRect
+<<<<<<< HEAD
from .line import Line
from utils.app import fileImporter
+=======
+<<<<<<< HEAD
+from line import Line
+
+
+=======
+from .line import Line
+
+from utils.app import fileImporter
+>>>>>>> merge
+# resourceManager = ApplicationContext()
+
+>>>>>>> upstream/master
class GripItem(QGraphicsPathItem):
"""
@@ -223,7 +237,16 @@ class LineGripItem(GripItem):
# initialize a line and add on scene
startPoint = endPoint = self.parentItem().mapToScene(self.pos())
self.tempLine = Line(startPoint, endPoint)
+<<<<<<< HEAD
+ self.scene().addItemPlus(self.tempLine)
+=======
+ self.tempLine.setStartGripItem(self)
+<<<<<<< HEAD
+ self.scene().addItem(self.tempLine)
+=======
self.scene().addItemPlus(self.tempLine)
+>>>>>>> merge
+>>>>>>> upstream/master
super().mousePressEvent(mouseEvent)
def mouseMoveEvent(self, mouseEvent):
@@ -298,14 +321,29 @@ class NodeItem(QGraphicsSvgItem):
def __init__(self, unitOperationType, parent=None):
QGraphicsSvgItem.__init__(self, parent)
self.m_type = unitOperationType
+<<<<<<< HEAD
self.id = None
self.m_renderer = NodeItem.renderer
# if each svg is seperate file
# self.m_renderer = QSvgRenderer(fileImporter(f'svg/ellipse.svg'))
+=======
+<<<<<<< HEAD
+ self.m_renderer = QSvgRenderer("svg/" + unitOperationType + ".svg")
+=======
+ # self.m_renderer = QSvgRenderer("svg/" + unitOperationType + ".svg")
+ # self.m_renderer = QSvgRenderer(fileImporter(f'svg/{unitOperationType}.svg'))
+ self.m_renderer = QSvgRenderer(fileImporter(f'svg/ellipse.svg'))
+>>>>>>> merge
+ # self.m_renderer = QSvgRenderer(resourceManager.get_resource(f'toolbar/{unitOperationType}.svg'))
+>>>>>>> upstream/master
self.setSharedRenderer(self.m_renderer)
# set initial size of item
self.width = 100
+<<<<<<< HEAD
self.height = 150
+=======
+ self.height = 100
+>>>>>>> merge
self.rect = QRectF(-self.width / 2, -self.height / 2, self.width, self.height)
# set graphical settings for this item
self.setFlags(QGraphicsSvgItem.ItemIsMovable |
@@ -317,6 +355,12 @@ class NodeItem(QGraphicsSvgItem):
self.lineGripItems = []
self.sizeGripItems = []
+<<<<<<< HEAD
+=======
+ def advance(self, int):
+ print (int)
+
+>>>>>>> merge
def boundingRect(self):
"""Overrides QGraphicsSvgItem's boundingRect() virtual public function and
returns a valid bounding
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
diff --git a/src/main/python/utils/undo.py b/src/main/python/utils/undo.py
index cf539e7..4a9f3dd 100644
--- a/src/main/python/utils/undo.py
+++ b/src/main/python/utils/undo.py
@@ -36,6 +36,7 @@ class addCommand(QUndoCommand):
self.scene.addItem(self.diagramItem)
self.diagramItem.setPos(self.itemPos)
self.scene.clearSelection()
+ # print(self.diagramItem)
self.scene.update()
class deleteCommand(QUndoCommand):