diff options
author | sumit | 2020-06-03 14:22:45 +0530 |
---|---|---|
committer | sumit | 2020-06-03 14:22:45 +0530 |
commit | 1c5b2f668cd526dfcc0901124daef2dc041b447e (patch) | |
tree | 2161b480699cce1822e9cbfcf7d1d484774ef340 /src/main/python/shapes | |
parent | 6d002432a2234180e447114de67a522ad58372d3 (diff) | |
parent | 7980ef69a7c4b3b02c5edd4ecb8c765c99d44d18 (diff) | |
download | Chemical-PFD-1c5b2f668cd526dfcc0901124daef2dc041b447e.tar.gz Chemical-PFD-1c5b2f668cd526dfcc0901124daef2dc041b447e.tar.bz2 Chemical-PFD-1c5b2f668cd526dfcc0901124daef2dc041b447e.zip |
Merge branch 'master' of https://github.com/Sumit-Sahu/Chemical-PFD
Diffstat (limited to 'src/main/python/shapes')
-rw-r--r-- | src/main/python/shapes/line.py | 9 | ||||
-rw-r--r-- | src/main/python/shapes/shapes.py | 75 |
2 files changed, 14 insertions, 70 deletions
diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 1a54284..2d7eba8 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -199,12 +199,9 @@ class Line(QGraphicsPathItem): path = QPainterPath(self.startPoint) # iterating over all points of line for i in range(len(self.points) - 1): - # for point in self.commonPaths: - # # point is center of common path - # pass - for point in self.commonPaths: - x1, y1 = self.points[i].x(), self.points[i].y() - x2, y2 = self.points[i+1].x(), self.points[i+1].y() + x1, y1 = self.points[i].x(), self.points[i].y() + x2, y2 = self.points[i+1].x(), self.points[i+1].y() + for point in self.commonPaths.sort(key = lambda x: x.x() + x.y(), reverse=x2<x1 or y2<y1): x, y = point.x(), point.y() # if not x1 * (y - y2) + x * (y2 - y1) + x2 * (y1 - y) : if x == x1 == x2: diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index 582215e..3237e72 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -1,28 +1,19 @@ 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 - -<<<<<<< HEAD -from .line import Line -from utils.app import fileImporter - - -======= -<<<<<<< HEAD -from line import Line +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 -from utils.app import fileImporter ->>>>>>> merge -# resourceManager = ApplicationContext() - ->>>>>>> upstream/master class GripItem(QGraphicsPathItem): """ @@ -41,21 +32,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): """ @@ -237,16 +213,8 @@ 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): @@ -321,29 +289,14 @@ 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 | @@ -354,13 +307,7 @@ class NodeItem(QGraphicsSvgItem): # grip items connected to this item 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 |