summaryrefslogtreecommitdiff
path: root/src/main/python
diff options
context:
space:
mode:
authorBlaine2020-06-03 14:17:38 +0530
committerBlaine2020-06-03 14:17:38 +0530
commitb11700f84b71c679d9d5fc31d44eb6173fab8871 (patch)
treec7db7ab7b03bcafc9e9d35b7a2b6ad6b3705637b /src/main/python
parent56d830cb025a1b7dd99ac2c0292c0eed27aebb9b (diff)
parent809cd1f50d320482600e7ab190dc5e13bff3bf02 (diff)
downloadChemical-PFD-b11700f84b71c679d9d5fc31d44eb6173fab8871.tar.gz
Chemical-PFD-b11700f84b71c679d9d5fc31d44eb6173fab8871.tar.bz2
Chemical-PFD-b11700f84b71c679d9d5fc31d44eb6173fab8871.zip
merge conflicts
Diffstat (limited to 'src/main/python')
-rw-r--r--src/main/python/shapes/shapes.py45
-rw-r--r--src/main/python/utils/graphics.py7
-rw-r--r--src/main/python/utils/undo.py1
3 files changed, 20 insertions, 33 deletions
diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py
index 19c0298..c2d79e4 100644
--- a/src/main/python/shapes/shapes.py
+++ b/src/main/python/shapes/shapes.py
@@ -1,14 +1,23 @@
from PyQt5 import QtCore, QtWidgets
+from PyQt5.QtCore import (QEvent, QFile, QIODevice, QMimeData, QPointF, QRect,
+ QRectF, QSizeF, Qt)
+from PyQt5.QtGui import (QBrush, QColor, QCursor, QDrag, QFont, QImage,
+ QPainter, QPainterPath, QPen, QTransform)
from PyQt5.QtSvg import QGraphicsSvgItem, QSvgRenderer
-from PyQt5.QtWidgets import QLineEdit, QGraphicsItem, QGraphicsEllipseItem, QGraphicsProxyWidget, QGraphicsPathItem, \
- QGraphicsSceneHoverEvent, QGraphicsColorizeEffect
-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
+from PyQt5.QtWidgets import (QGraphicsColorizeEffect, QGraphicsEllipseItem,
+ QGraphicsItem, QGraphicsPathItem,
+ QGraphicsProxyWidget, QGraphicsSceneHoverEvent,
+ QLineEdit)
+
+from utils.app import fileImporter
from .line import Line
from utils.app import fileImporter
+<<<<<<< HEAD
+=======
+>>>>>>> upstream/master
class GripItem(QGraphicsPathItem):
"""
@@ -27,21 +36,6 @@ class GripItem(QGraphicsPathItem):
self.setAcceptHoverEvents(True)
self.setCursor(QCursor(Qt.PointingHandCursor))
- # def hoverEnterEvent(self, event):
- # """
- # defines shape highlighting on Mouse Over
- # """
- # self.setPen(QPen(QColor("black"), 2))
- # self.setBrush(QColor("red"))
- # super(GripItem, self).hoverEnterEvent(event)
- #
- # def hoverLeaveEvent(self, event):
- # """
- # defines shape highlighting on Mouse Leave
- # """
- # self.setPen(QPen(Qt.transparent))
- # self.setBrush(Qt.transparent)
- # super(GripItem, self).hoverLeaveEvent(event)
def mouseReleaseEvent(self, event):
"""
@@ -223,6 +217,7 @@ class LineGripItem(GripItem):
# initialize a line and add on scene
startPoint = endPoint = self.parentItem().mapToScene(self.pos())
self.tempLine = Line(startPoint, endPoint)
+ self.tempLine.setStartGripItem(self)
self.scene().addItemPlus(self.tempLine)
super().mousePressEvent(mouseEvent)
@@ -298,14 +293,14 @@ class NodeItem(QGraphicsSvgItem):
def __init__(self, unitOperationType, parent=None):
QGraphicsSvgItem.__init__(self, parent)
self.m_type = unitOperationType
- self.id = None
- self.m_renderer = NodeItem.renderer
- # if each svg is seperate file
- # self.m_renderer = QSvgRenderer(fileImporter(f'svg/ellipse.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'))
+ # self.m_renderer = QSvgRenderer(resourceManager.get_resource(f'toolbar/{unitOperationType}.svg'))
self.setSharedRenderer(self.m_renderer)
# set initial size of item
self.width = 100
- self.height = 150
+ self.height = 100
self.rect = QRectF(-self.width / 2, -self.height / 2, self.width, self.height)
# set graphical settings for this item
self.setFlags(QGraphicsSvgItem.ItemIsMovable |
@@ -316,7 +311,7 @@ class NodeItem(QGraphicsSvgItem):
# grip items connected to this item
self.lineGripItems = []
self.sizeGripItems = []
-
+
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 27e02c4..a997a30 100644
--- a/src/main/python/utils/graphics.py
+++ b/src/main/python/utils/graphics.py
@@ -86,15 +86,9 @@ 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)
@@ -120,7 +114,6 @@ 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 4a9f3dd..cf539e7 100644
--- a/src/main/python/utils/undo.py
+++ b/src/main/python/utils/undo.py
@@ -36,7 +36,6 @@ 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):