From 1b6f49af4a8feacfdaf1f914600f9ae9ab863586 Mon Sep 17 00:00:00 2001 From: sumit Date: Thu, 28 May 2020 10:07:54 +0530 Subject: change final shape of line --- src/main/python/shapes/line.py | 336 +++++++++++++++++++++++++++++++++++---- src/main/python/shapes/shapes.py | 14 +- 2 files changed, 318 insertions(+), 32 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 310b496..fa10936 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -20,6 +20,8 @@ class Grabber(QGraphicsPathItem): self.setFlag(QGraphicsItem.ItemIsMovable, True) self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True) self.setAcceptHoverEvents(True) + self.pen = QPen(Qt.white, -1, Qt.SolidLine) + self.brush = QBrush(Qt.transparent) def itemChange(self, change, value): """ move position of grabber after resize""" @@ -37,13 +39,11 @@ class Grabber(QGraphicsPathItem): def paint(self, painter, option, widget): """paints the path of grabber only if it is selected """ - if self.isSelected(): - # show line of grabber + if self.isSelected() and not self.m_annotation_item.isSelected() : + # show parent line of grabber self.m_annotation_item.setSelected(True) - painter.setBrush(QBrush(Qt.cyan)) - color = Qt.black if self.isSelected() else Qt.white - width = 2 if self.isSelected() else -1 - painter.setPen(QPen(color, width, Qt.SolidLine)) + painter.setBrush(self.brush) + painter.setPen(self.pen) painter.drawPath(self.path()) # To paint path of shape @@ -90,6 +90,14 @@ class Grabber(QGraphicsPathItem): self.setCursor(QCursor(Qt.ArrowCursor)) super(Grabber, self).hoverLeaveEvent(event) + def show(self): + self.pen = QPen(Qt.black, 2, Qt.SolidLine) + self.brush = QBrush(Qt.cyan) + + def hide(self): + self.pen = QPen(Qt.white, -1, Qt.SolidLine) + self.brush = QBrush(Qt.transparent) + class Line(QGraphicsPathItem): """ @@ -125,18 +133,284 @@ class Line(QGraphicsPathItem): offset = 30 x0, y0 = self.startPoint.x(), self.startPoint.y() x1, y1 = self.endPoint.x(), self.endPoint.y() + # create line is in process self.points = [self.startPoint, QPointF((x0 + x1) / 2, y0), QPointF((x0 + x1) / 2, y1), self.endPoint] - if self.startGripItem and self.startGripItem.m_location in ["left", "right"]: - if self.endGripItem and self.endGripItem.m_location in ["top", "bottom"]: - if self.endGripItem.m_location == "top": offset = -offset - self.points = [self.startPoint, QPointF((x0 + x1) / 2, y0), QPointF((x0 + x1) / 2, y1 + offset), - QPointF(self.endPoint.x(), y1 + offset), self.endPoint] - - if self.startGripItem and self.startGripItem.m_location in ["top", "bottom"]: - self.points = [self.startPoint, QPointF(x0, (y0 + y1) / 2), QPointF(x1, (y0 + y1) / 2), self.endPoint] - if self.endGripItem and self.endGripItem.m_location in ["left", "right"]: - self.points = [self.startPoint, QPointF(x0, (y0 + y1) / 2), QPointF(x1 - offset, (y0 + y1) / 2), - QPointF(x1 - offset, self.endPoint.y()), self.endPoint] + # final path of line + if self.startGripItem and self.endGripItem: + # determine ns (point next to start) + item = self.startGripItem + self.startPoint = item.parentItem().mapToScene(item.pos()) + if item.m_location == "top": + ns = QPointF(self.startPoint.x(), self.startPoint.y() - offset) + elif item.m_location == "left": + ns = QPointF(self.startPoint.x() - offset, self.startPoint.y()) + elif item.m_location == "bottom": + ns = QPointF(self.startPoint.x(), self.startPoint.y() + offset) + else: + ns = QPointF(self.startPoint.x() + offset, self.startPoint.y()) + # pe (point previous to end) + item = self.endGripItem + self.endPoint = item.parentItem().mapToScene(item.pos()) + if item.m_location == "top": + pe = QPointF(self.endPoint.x(), self.endPoint.y() - offset) + elif item.m_location == "left": + pe = QPointF(self.endPoint.x() - offset, self.endPoint.y()) + elif item.m_location == "bottom": + pe = QPointF(self.endPoint.x(), self.endPoint.y() + offset) + else: + pe = QPointF(self.endPoint.x() + offset, self.endPoint.y()) + + start = self.startPoint + end = self.endPoint + sheight = self.startGripItem.m_annotation_item.boundingRect().height() / 2 + swidth = self.startGripItem.m_annotation_item.boundingRect().width() / 2 + eheight = self.endGripItem.m_annotation_item.boundingRect().height() / 2 + ewidth = self.endGripItem.m_annotation_item.boundingRect().width() / 2 + + if self.startGripItem.m_location in ["right"]: + if self.endGripItem.m_location in ["top"]: + if start.x() + offset < end.x() - ewidth: + if start.y() + offset < end.y(): + self.points = [start, QPointF(end.x(), start.y()), end] + else: + self.points = [start, ns, QPointF(ns.x(), pe.y()), pe, end] + elif start.x() - 2 * swidth > end.x(): + if start.y() + sheight + offset < end.y(): + self.points = [start, ns, QPointF(ns.x(), pe.y()), pe, end] + elif start.y() - sheight - offset < end.y(): + self.points = [start, ns, QPointF(ns.x(), ns.y() - sheight - offset), + QPointF(pe.x(), ns.y() - sheight - offset), end] + else: + self.points = [start, ns, QPointF(ns.x(), pe.y()), pe, end] + else: + self.points = [start, ns, QPointF(ns.x(), pe.y()), pe, end] + if start.y() > end.y(): + x = max(end.x() + ewidth + offset, ns.x()) + self.points = [start, QPointF(x, start.y()), QPointF(x, pe.y()), pe, end] + + elif self.endGripItem.m_location in ["bottom"]: + if start.x() + offset < end.x() - ewidth: + if start.y() + offset < end.y(): + self.points = [start, ns, QPointF(ns.x(), pe.y()), pe, end] + else: + self.points = [start, QPointF(end.x(), start.y()), end] + + elif start.x() - 2 * swidth > end.x(): + if start.y() + sheight + offset < end.y(): + self.points = [start, ns, QPointF(ns.x(), pe.y()), pe, end] + elif start.y() - sheight - offset < end.y(): + y = max(pe.y(), start.y() + sheight + offset) + self.points = [start, ns, QPointF(ns.x(), y), + QPointF(pe.x(), y), end] + else: + self.points = [start, ns, QPointF(ns.x(), pe.y()), pe, end] + else: + self.points = [start, ns, QPointF(ns.x(), pe.y()), pe, end] + if start.y() < end.y(): + x = max(end.x() + ewidth + offset, ns.x()) + self.points = [start, QPointF(x, start.y()), QPointF(x, pe.y()), pe, end] + + elif self.endGripItem.m_location in ["right"]: + x = max(start.x() + offset, pe.x()) + self.points = [start, QPointF(x, start.y()), QPointF(x, end.y()), end] + if start.x() + offset < end.x() - ewidth: + if start.y() + offset > end.y() - eheight and end.y() >= start.y(): + self.points = [start, ns, QPointF(ns.x(), pe.y() - eheight), + QPointF(pe.x(), pe.y() - eheight), pe, end] + elif start.y() - offset < end.y() + eheight and end.y() <= start.y(): + self.points = [start, ns, QPointF(ns.x(), pe.y() + eheight), + QPointF(pe.x(), pe.y() + eheight), pe, end] + elif start.y() - sheight - offset < end.y() < start.y() + sheight + offset: + if end.y() < start.y(): + self.points = [start, ns, QPointF(ns.x(), ns.y() - sheight), + QPointF(pe.x(), ns.y() - sheight), pe, end] + else: + self.points = [start, ns, QPointF(ns.x(), ns.y() + sheight), + QPointF(pe.x(), ns.y() + sheight), pe, end] + + elif self.endGripItem.m_location in ["left"]: + self.points = [start, QPointF((start.x() + end.x()) / 2, start.y()), + QPointF((start.x() + end.x()) / 2, end.y()), end] + if end.x() < start.x() + offset: + if end.y() + eheight <= start.y() - sheight - offset: + self.points = [start, ns, QPointF(ns.x(), ns.y() - sheight), + QPointF(pe.x(), ns.y() - sheight), pe, end] + elif end.y() - eheight >= start.y() + sheight + offset: + self.points = [start, ns, QPointF(ns.x(), ns.y() + sheight), + QPointF(pe.x(), ns.y() + sheight), pe, end] + elif end.y() <= start.y(): + y = min(end.y() - eheight, start.y() - sheight) + self.points = [start, ns, QPointF(ns.x(), y), + QPointF(pe.x(), y), pe, end] + else: + y = max(end.y() + eheight, start.y() + sheight) + self.points = [start, ns, QPointF(ns.x(), y), + QPointF(pe.x(), y), pe, end] + + + elif self.startGripItem.m_location in ["left"]: + if self.endGripItem.m_location in ["top"]: + if start.x() + offset < end.x() - ewidth: + if end.y() > start.y() + sheight + offset: + self.points = [start, ns, QPointF(ns.x(), ns.y() + sheight), + QPointF(pe.x(), ns.y() + sheight), end] + else: + y = min(start.y() - sheight, pe.y()) + self.points = [start, ns, QPointF(ns.x(), y), + QPointF(pe.x(), y), end] + elif end.x() + ewidth >= start.x() - offset: + x = min(ns.x(), end.x() - ewidth) + self.points = [start, QPointF(x, ns.y()), + QPointF(x, pe.y()), pe, end] + else: + if end.y() >= start.y() + offset: + self.points = [start, QPointF(end.x(), start.y()), end] + else: + x = (start.x() + end.x()) / 2 + self.points = [start, QPointF(x, start.y()), + QPointF(x, pe.y()), pe, end] + + elif self.endGripItem.m_location in ["bottom"]: + if start.x() + offset < end.x() - ewidth: + if end.y() < start.y() - sheight - offset: + self.points = [start, ns, QPointF(ns.x(), ns.y() - sheight), + QPointF(pe.x(), ns.y() - sheight), end] + else: + y = max(start.y() + sheight, pe.y()) + self.points = [start, ns, QPointF(ns.x(), y), + QPointF(pe.x(), y), end] + elif end.x() + ewidth >= start.x() - offset: + x = min(ns.x(), end.x() - ewidth) + self.points = [start, QPointF(x, ns.y()), + QPointF(x, pe.y()), pe, end] + else: + if end.y() <= start.y() - offset: + self.points = [start, QPointF(end.x(), start.y()), end] + else: + x = (start.x() + end.x()) / 2 + self.points = [start, QPointF(x, start.y()), + QPointF(x, pe.y()), pe, end] + + elif self.endGripItem.m_location in ["right"]: + self.points = [start, QPointF((start.x() + end.x()) / 2, start.y()), + QPointF((start.x() + end.x()) / 2, end.y()), end] + if end.x() > start.x() + offset: + if end.y() + eheight <= start.y() - sheight - offset: + self.points = [start, ns, QPointF(ns.x(), ns.y() - sheight), + QPointF(pe.x(), ns.y() - sheight), pe, end] + elif end.y() - eheight >= start.y() + sheight + offset: + self.points = [start, ns, QPointF(ns.x(), ns.y() + sheight), + QPointF(pe.x(), ns.y() + sheight), pe, end] + elif end.y() <= start.y(): + y = min(end.y() - eheight, start.y() - sheight) + self.points = [start, ns, QPointF(ns.x(), y), + QPointF(pe.x(), y), pe, end] + else: + y = max(end.y() + eheight, start.y() + sheight) + self.points = [start, ns, QPointF(ns.x(), y), + QPointF(pe.x(), y), pe, end] + + elif self.endGripItem.m_location in ["left"]: + self.points = [start, QPointF(pe.x(), start.y()), pe, end] + if start.x() + offset < end.x(): + self.points = [start, ns, QPointF(ns.x(), end.y()), end] + if start.y() + sheight + offset > end.y() > start.y() - sheight - offset: + self.points = [start, ns, QPointF(ns.x(), ns.y() - sheight), + QPointF(pe.x(), ns.y() - sheight), pe, end] + elif end.y() - eheight - offset < start.y() < end.y() + eheight + offset: + if end.y() > start.y(): + self.points = [start, ns, QPointF(ns.x(), pe.y() - eheight), + QPointF(pe.x(), pe.y() - eheight), pe, end] + else: + self.points = [start, ns, QPointF(ns.x(), pe.y() + eheight), + QPointF(pe.x(), pe.y() + eheight), pe, end] + + + elif self.startGripItem.m_location in ["top"]: + if self.endGripItem.m_location in ["top"]: + self.points = [self.startPoint, QPointF(start.x(), pe.y()), + pe, self.endPoint] + if start.y() < end.y(): + self.points = [self.startPoint, ns, QPointF(pe.x(), ns.y()), self.endPoint] + if start.x() + swidth > end.x() > start.x() - swidth or end.x() + ewidth > start.x() > end.x() - ewidth: + x = max(start.x() + swidth, end.x() + ewidth) + x += offset + if start.x() > end.x(): + x = min(start.x() - swidth, end.x() - ewidth) + x -= offset + self.points = [start, ns, QPointF(x, ns.y()), + QPointF(x, pe.y()), pe, end] + + elif self.endGripItem.m_location in ["bottom"]: + self.points = [self.startPoint, ns, QPointF((x0 + x1) / 2, ns.y()), QPointF((x0 + x1) / 2, pe.y()), + pe, self.endPoint] + if start.y() - offset > end.y(): + self.points = [start, QPointF(start.x(), (y0 + y1) / 2), QPointF(end.x(), (y0 + y1) / 2), + self.endPoint] + elif start.x() + swidth > end.x() > start.x() - swidth or end.x() + ewidth > start.x() > end.x() - ewidth: + x = max(start.x() + swidth, end.x() + ewidth) + x += offset + if start.x() > end.x(): + x = min(start.x() - swidth, end.x() - ewidth) + x -= offset + self.points = [start, ns, QPointF(x, ns.y()), + QPointF(x, pe.y()), pe, end] + + elif self.endGripItem.m_location in ["right"]: + y = min(ns.y(), end.y() + eheight + offset) + self.points = [start, QPointF(ns.x(), y), QPointF(pe.x(), y), pe, end] + if start.x() - swidth - offset < end.x() < start.x() + swidth + offset and end.y() > start.y() + offset: + self.points = [start, ns, QPointF(ns.x() + swidth + offset, ns.y()), + QPointF(ns.x() + swidth + offset, pe.y()), end] + elif end.y() - eheight < start.y() - offset < end.y() + eheight: + self.points = [start, ns, QPointF(start.x(), end.y() - eheight), + QPointF(pe.x(), end.y() - eheight), pe, end] + + elif self.endGripItem.m_location in ["left"]: + y = min(ns.y(), end.y() + eheight + offset) + self.points = [start, QPointF(ns.x(), y), QPointF(pe.x(), y), pe, end] + if start.x() - swidth - offset < end.x() < start.x() + swidth + offset and end.y() > start.y() + offset: + self.points = [start, ns, QPointF(ns.x() - swidth - offset, ns.y()), + QPointF(ns.x() - swidth - offset, pe.y()), end] + elif end.y() - eheight < start.y() - offset < end.y() + eheight: + self.points = [start, ns, QPointF(start.x(), end.y() - eheight), + QPointF(pe.x(), end.y() - eheight), pe, end] + + elif self.startGripItem.m_location in ["bottom"]: + if self.endGripItem.m_location in ["top"]: + self.points = [self.startPoint, ns, QPointF((x0 + x1) / 2, ns.y()), QPointF((x0 + x1) / 2, pe.y()), + pe, self.endPoint] + if start.y() < end.y(): + self.points = [self.startPoint, ns, QPointF(pe.x(), ns.y()), self.endPoint] + if start.x() + swidth > end.x() > start.x() - swidth or end.x() + ewidth > start.x() > end.x() - ewidth: + x = max(start.x() + swidth, end.x() + ewidth) + x += offset + self.points = [start, ns, QPointF(x, ns.y()), + QPointF(x, pe.y()), pe, end] + + elif self.endGripItem.m_location in ["bottom"]: + self.points = [self.startPoint, ns, QPointF((x0 + x1) / 2, ns.y()), QPointF((x0 + x1) / 2, pe.y()), + pe, self.endPoint] + if start.x() + swidth > end.x() > start.x() - swidth or end.x() + ewidth > start.x() > end.x() - ewidth: + x = max(start.x() + swidth, end.x() + ewidth) + x += offset + self.points = [start, ns, QPointF(x, ns.y()), + QPointF(x, pe.y()), pe, end] + + elif self.endGripItem.m_location in ["right"]: + y = max(ns.y(), end.y() + eheight + offset) + self.points = [start, QPointF(ns.x(), y), QPointF(pe.x(), y), pe, end] + if start.x() - swidth - offset < end.x() < start.x() + swidth + offset: + self.points = [start, ns, QPointF(ns.x() + swidth + offset, ns.y()), + QPointF(ns.x() + swidth + offset, pe.y()), end] + + elif self.endGripItem.m_location in ["left"]: + y = max(ns.y(), end.y() + eheight + offset) + self.points = [start, QPointF(ns.x(), y), QPointF(pe.x(), y), pe, end] + if start.x() - swidth - offset < end.x() < start.x() + swidth + offset: + self.points = [start, ns, QPointF(ns.x() - swidth - offset, ns.y()), + QPointF(ns.x() - swidth - offset, pe.y()), end] + # draw line path = QPainterPath(self.startPoint) for i in range(1, len(self.points)): @@ -197,12 +471,12 @@ class Line(QGraphicsPathItem): # To paint path of shape # painter.setPen(QPen(Qt.blue, 1, Qt.SolidLine)) # painter.drawPath(self.shape()) - if self.isSelected(): - self.showGripItem() - self._selected = True - elif self._selected: - self.hideGripItem() - self._selected = False + # if self.isSelected(): + # self.showGripItem() + # self._selected = True + # elif self._selected: + # self.hideGripItem() + # self._selected = False def movePoints(self, index, movement): """move points of line @@ -222,7 +496,7 @@ class Line(QGraphicsPathItem): else: direction = [Qt.Vertical, Qt.Horizontal] for i in range(1, len(self.points) - 2): - item = Grabber(self, i, direction[i - 1]) + item = Grabber(self, i, direction[(i - 1)%2]) item.setParentItem(self) item.setPos(self.pos()) self.scene().addItem(item) @@ -243,6 +517,12 @@ class Line(QGraphicsPathItem): grabber.setEnabled(True) def itemChange(self, change, value): + if change == QGraphicsItem.ItemSelectedHasChanged: + if value == 1: + self.showGripItem() + else: + self.hideGripItem() + return if change == QGraphicsItem.ItemSceneHasChanged and self.scene(): # self.addGrabber() # self.updateGrabber() @@ -280,18 +560,20 @@ class Line(QGraphicsPathItem): self.scene().removeItem(self) def showGripItem(self): - """hides grip items which contains line + """shows grip items which contains line """ if self.startGripItem: self.startGripItem.show() if self.endGripItem: self.endGripItem.show() - # for grabber in self.m_grabber: - # grabber.setSelected(True) + for grabber in self.m_grabbers: + grabber.show() def hideGripItem(self): """hides grip items which contains line """ if self.startGripItem: self.startGripItem.hide() if self.endGripItem: self.endGripItem.hide() + for grabber in self.m_grabbers: + grabber.hide() def setStartGripItem(self, item): self.startGripItem = item diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index e79ddb7..5c39125 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -53,7 +53,7 @@ class SizeGripItem(GripItem): self.width = annotation_item.boundingRect().width() path = QPainterPath() - path.addRect(QRectF(-self.width/2, -self.height/2, self.width, self.height)) + path.addRect(QRectF(-self.width / 2, -self.height / 2, self.width, self.height)) super(SizeGripItem, self).__init__(annotation_item, path=path, parent=parent) self.setFlag(QGraphicsItem.ItemIsSelectable, True) self.setFlag(QGraphicsItem.ItemIsMovable, True) @@ -84,7 +84,7 @@ class SizeGripItem(GripItem): else: self.width = self.parentItem().boundingRect().width() path = QPainterPath() - path.addRect(QRectF(-self.width/2, -self.height/2, self.width, self.height)) + path.addRect(QRectF(-self.width / 2, -self.height / 2, self.width, self.height)) self.setPath(path) def updatePosition(self): @@ -212,8 +212,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) + self.scene().addItem(self.tempLine) super().mousePressEvent(mouseEvent) def mouseMoveEvent(self, mouseEvent): @@ -245,6 +244,7 @@ class LineGripItem(GripItem): self.transform()) if type(item) == LineGripItem and item != self: + self.tempLine.setStartGripItem(self) self.tempLine.setEndGripItem(item) endPoint = item.parentItem().mapToScene(item.pos()) self.tempLine.updateLine(endPoint=endPoint) @@ -281,6 +281,7 @@ class NodeItem(QGraphicsSvgItem): """ Extends PyQt5's QGraphicsSvgItem to create the basic structure of shapes with given unit operation type """ + renderer = QSvgRenderer("For sample svg_2.svg") def __init__(self, unitOperationType, parent=None): QGraphicsSvgItem.__init__(self, parent) @@ -319,7 +320,10 @@ class NodeItem(QGraphicsSvgItem): """ if not self.m_renderer: QGraphicsSvgItem.paint(self, painter, option, widget) - self.m_renderer.render(painter, self.boundingRect()) + elif self.id: + self.m_renderer.render(painter,self.id, self.boundingRect()) + else: + self.m_renderer.render(painter, self.boundingRect()) if self.isSelected(): self.showGripItem() -- cgit From 34b798e22ef468878176ee45c146290839f1afbc Mon Sep 17 00:00:00 2001 From: sumit Date: Thu, 28 May 2020 19:11:52 +0530 Subject: open svg from resources --- src/main/python/shapes/shapes.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index 5c39125..4615ab1 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -9,9 +9,9 @@ from PyQt5.QtWidgets import (QGraphicsColorizeEffect, QGraphicsEllipseItem, QGraphicsProxyWidget, QGraphicsSceneHoverEvent, QLineEdit) -from utils.app import fileImporter - from .line import Line +from utils.app import fileImporter + class GripItem(QGraphicsPathItem): @@ -281,15 +281,15 @@ class NodeItem(QGraphicsSvgItem): """ Extends PyQt5's QGraphicsSvgItem to create the basic structure of shapes with given unit operation type """ - renderer = QSvgRenderer("For sample svg_2.svg") + # set a common renderer for all svg + renderer = QSvgRenderer(fileImporter(f'svg/ellipse.svg')) def __init__(self, unitOperationType, parent=None): QGraphicsSvgItem.__init__(self, parent) - self.m_type = unitOperationType - # 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.id = None + self.m_renderer = NodeItem.renderer + # if each svg is seperate file + # self.m_renderer = QSvgRenderer(fileImporter(f'svg/ellipse.svg')) self.setSharedRenderer(self.m_renderer) # set initial size of item self.width = 100 -- cgit From 8f9295322a545e4b9ab070c2534ddc2d31a952c7 Mon Sep 17 00:00:00 2001 From: sumit Date: Sat, 30 May 2020 16:58:46 +0530 Subject: remove extra point of line --- src/main/python/shapes/line.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index fa10936..8bba5be 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -2,6 +2,7 @@ from PyQt5.QtGui import QPen, QPainterPath, QBrush, QPainterPathStroker, QPainte from PyQt5.QtWidgets import QGraphicsItem, QGraphicsPathItem from PyQt5.QtCore import Qt, QPointF, QRectF + class Grabber(QGraphicsPathItem): """ Extends QGraphicsPathItem to create grabber for line for moving a particular segment @@ -373,7 +374,7 @@ class Line(QGraphicsPathItem): self.points = [start, ns, QPointF(ns.x() - swidth - offset, ns.y()), QPointF(ns.x() - swidth - offset, pe.y()), end] elif end.y() - eheight < start.y() - offset < end.y() + eheight: - self.points = [start, ns, QPointF(start.x(), end.y() - eheight), + self.points = [start, QPointF(start.x(), end.y() - eheight), QPointF(pe.x(), end.y() - eheight), pe, end] elif self.startGripItem.m_location in ["bottom"]: -- cgit From 634fde62599f92bd41dbce0adfedd1ae6af52ca4 Mon Sep 17 00:00:00 2001 From: sumit Date: Sat, 30 May 2020 17:08:18 +0530 Subject: change add line for undo --- src/main/python/shapes/shapes.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index 4615ab1..a0aca48 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -212,7 +212,7 @@ class LineGripItem(GripItem): # initialize a line and add on scene startPoint = endPoint = self.parentItem().mapToScene(self.pos()) self.tempLine = Line(startPoint, endPoint) - self.scene().addItem(self.tempLine) + self.scene().addItemPlus(self.tempLine) super().mousePressEvent(mouseEvent) def mouseMoveEvent(self, mouseEvent): @@ -286,6 +286,7 @@ 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 @@ -605,9 +606,9 @@ class InducedDraftCooling(NodeItem): super(InducedDraftCooling, self).__init__("InducedDraftCooling", parent=None) -class jacketedMixingVessel(NodeItem): +class JacketedMixingVessel(NodeItem): def __init__(self): - super(jacketedMixingVessel, self).__init__("jacketedMixingVessel", parent=None) + super(JacketedMixingVessel, self).__init__("JacketedMixingVessel", parent=None) class LiquidRingCompressor(NodeItem): -- cgit From 76a8d691c267a5e65074ee99468800c1d3e3d930 Mon Sep 17 00:00:00 2001 From: sumit Date: Sun, 31 May 2020 21:31:43 +0530 Subject: common path of lines --- src/main/python/shapes/line.py | 58 ++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 16 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 8bba5be..2c5a527 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -126,6 +126,46 @@ class Line(QGraphicsPathItem): # initiates path self.createPath() + def advance(self, phase): + # items = self.collidingItems(Qt.IntersectsItemShape) + items = self.scene().items(self.shape(),Qt.IntersectsItemShape,Qt.DescendingOrder) + self.commonPaths = [] + for item in items: + if type(item) in [type(self)]: + if item == self: + break + # origin = self.mapFromItem(item, 0, 0) + shape = item.shape() + shape = self.mapFromItem(item, item.shape()) + commonPath = self.shape().intersected(shape) + self.commonPaths.append(commonPath) + + def paint(self, painter, option, widget): + color = Qt.red if self.isSelected() else Qt.black + painter.setPen(QPen(color, 2, self.penStyle)) + path = self.path() + painter.drawPath(path) + for p in self.commonPaths: + print("length = ",p.length(),"element = ",p.elementCount()) + for i in range(p.elementCount()): + print(p.elementAt(i).x,p.elementAt(i).y) + # if p.elementAt(0).x == p.elementAt(1).x: + # pass + painter.save() + painter.setPen(Qt.darkYellow) + painter.setBrush(Qt.darkYellow) + painter.drawPath(p) + painter.restore() + # painter.setPen(QPen(QBrush(Qt.black),-1)) + # painter.setBrush(QBrush(Qt.red)) + # print(painter.pen().width()) + # painter.drawPath(path) + + # To paint path of shape + # painter.setPen(QPen(Qt.blue, 1, Qt.SolidLine)) + # painter.drawPath(self.shape()) + + def createPath(self): """ creates initial path and stores it's points @@ -412,7 +452,7 @@ class Line(QGraphicsPathItem): self.points = [start, ns, QPointF(ns.x() - swidth - offset, ns.y()), QPointF(ns.x() - swidth - offset, pe.y()), end] - # draw line + # path of line path = QPainterPath(self.startPoint) for i in range(1, len(self.points)): path.lineTo(self.points[i]) @@ -464,21 +504,6 @@ class Line(QGraphicsPathItem): path = qp.createStroke(self.path()) return path - def paint(self, painter, option, widget): - color = Qt.red if self.isSelected() else Qt.black - painter.setPen(QPen(color, 2, self.penStyle)) - painter.drawPath(self.path()) - - # To paint path of shape - # painter.setPen(QPen(Qt.blue, 1, Qt.SolidLine)) - # painter.drawPath(self.shape()) - # if self.isSelected(): - # self.showGripItem() - # self._selected = True - # elif self._selected: - # self.hideGripItem() - # self._selected = False - def movePoints(self, index, movement): """move points of line """ @@ -543,6 +568,7 @@ class Line(QGraphicsPathItem): self.endPoint = endPoint self.createPath() self.updateGrabber() + self.scene().update() return if self.startGripItem and self.endGripItem: -- cgit From f98bb44ef77d7f6d42e6f112ad8978fc5ef2c9eb Mon Sep 17 00:00:00 2001 From: sumit Date: Sun, 31 May 2020 21:41:45 +0530 Subject: add variable commonPaths --- src/main/python/shapes/line.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 2c5a527..9f3bfaf 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -125,6 +125,7 @@ class Line(QGraphicsPathItem): self.setAcceptHoverEvents(True) # initiates path self.createPath() + self.commonPaths=[] def advance(self, phase): # items = self.collidingItems(Qt.IntersectsItemShape) -- cgit From 41a1fd32e6dc812c6ef4e8c369686f5096663890 Mon Sep 17 00:00:00 2001 From: sumit Date: Tue, 2 Jun 2020 11:50:35 +0530 Subject: add text label to line --- src/main/python/shapes/line.py | 87 +++++++++++++++++++++++++++++++----------- 1 file changed, 64 insertions(+), 23 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 9f3bfaf..e6b1dd9 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -1,5 +1,6 @@ +import math from PyQt5.QtGui import QPen, QPainterPath, QBrush, QPainterPathStroker, QPainter, QCursor -from PyQt5.QtWidgets import QGraphicsItem, QGraphicsPathItem +from PyQt5.QtWidgets import QGraphicsItem, QGraphicsPathItem, QGraphicsTextItem from PyQt5.QtCore import Qt, QPointF, QRectF @@ -99,6 +100,50 @@ class Grabber(QGraphicsPathItem): self.pen = QPen(Qt.white, -1, Qt.SolidLine) self.brush = QBrush(Qt.transparent) +class LineLabel(QGraphicsTextItem): + def __init__(self, parent=None): + super(LineLabel, self).__init__(parent=parent) + self.setTextInteractionFlags(Qt.TextEditorInteraction) + self.setFlags(QGraphicsItem.ItemIsMovable | + QGraphicsItem.ItemIsSelectable | + QGraphicsItem.ItemIsFocusable) + self.setFlag(QGraphicsItem.ItemSendsGeometryChanges, True) + self.setPlainText("abc") + + def paint(self, painter, option, widget): + super(LineLabel, self).paint(painter,option,widget) + painter.drawEllipse(self.boundingRect()) + + def updateLabel(self): + points = self.parentItem().points + # min_A = QPointF() + # min_B =QPointF() + # min_dis =math.inf + # for i in range(1, len(points)): + # A = points[i - 1] + # B = points[i] + # C = self.pos() + # BAx = B.x() - A.x() + # BAy = B.y() - A.y() + # CAx = C.x() - A.x() + # CAy = C.y() - A.y() + # length = math.sqrt(BAx * BAx + BAy * BAy) + # if length >0: + # dis = (BAx*CAy - CAx*BAy)/length + # if abs(dis) < abs(min_dis): + # min_dis=dis + # min_A=A + # min_B=B + # + # self.setPos(self.parentItem().mapFromScene(QPointF(min_A))) + # print(self.pos()) + + def itemChange(self, change, value): + print("label change",change,value) + # if change == QGraphicsItem.ItemPositionChange: + # print("label change", change, value) + return super(LineLabel, self).itemChange(change,value) + class Line(QGraphicsPathItem): """ @@ -126,45 +171,41 @@ class Line(QGraphicsPathItem): # initiates path self.createPath() self.commonPaths=[] + self.label = LineLabel(self) def advance(self, phase): # items = self.collidingItems(Qt.IntersectsItemShape) - items = self.scene().items(self.shape(),Qt.IntersectsItemShape,Qt.DescendingOrder) + items = self.scene().items(self.shape(),Qt.IntersectsItemShape,Qt.AscendingOrder) self.commonPaths = [] for item in items: if type(item) in [type(self)]: if item == self: break - # origin = self.mapFromItem(item, 0, 0) shape = item.shape() shape = self.mapFromItem(item, item.shape()) commonPath = self.shape().intersected(shape) - self.commonPaths.append(commonPath) + polygons = commonPath.toSubpathPolygons() + for polygon in polygons: + center = polygon.boundingRect().center() + self.commonPaths.append(center) + # self.commonPaths[commonPath] = item + self.update() def paint(self, painter, option, widget): color = Qt.red if self.isSelected() else Qt.black painter.setPen(QPen(color, 2, self.penStyle)) - path = self.path() - painter.drawPath(path) - for p in self.commonPaths: - print("length = ",p.length(),"element = ",p.elementCount()) - for i in range(p.elementCount()): - print(p.elementAt(i).x,p.elementAt(i).y) - # if p.elementAt(0).x == p.elementAt(1).x: - # pass - painter.save() - painter.setPen(Qt.darkYellow) - painter.setBrush(Qt.darkYellow) - painter.drawPath(p) - painter.restore() - # painter.setPen(QPen(QBrush(Qt.black),-1)) - # painter.setBrush(QBrush(Qt.red)) - # print(painter.pen().width()) + # path = self.path() # painter.drawPath(path) + path = QPainterPath(self.startPoint) + # iterating over all points of line + for i in range(1, len(self.points)): + for point in self.commonPaths: + # point is center of common path + pass + path.lineTo(self.points[i]) + painter.drawPath(path) + - # To paint path of shape - # painter.setPen(QPen(Qt.blue, 1, Qt.SolidLine)) - # painter.drawPath(self.shape()) def createPath(self): -- cgit From c0e2880ec1a91adbaa449b0b97d852616336e2a6 Mon Sep 17 00:00:00 2001 From: Sumit-Sahu Date: Tue, 2 Jun 2020 12:12:11 +0530 Subject: remove shapes.py from pull request --- src/main/python/shapes/shapes.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index a0aca48..9fb7428 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -10,9 +10,7 @@ from PyQt5.QtWidgets import (QGraphicsColorizeEffect, QGraphicsEllipseItem, QLineEdit) from .line import Line -from utils.app import fileImporter - - +from utils.app import fileImporter class GripItem(QGraphicsPathItem): """ -- cgit From 166376901be1006dee9ce96fd12f6b910b2e860c Mon Sep 17 00:00:00 2001 From: sumit Date: Tue, 2 Jun 2020 12:33:41 +0530 Subject: undo delete shapes.py --- src/main/python/shapes/shapes.py | 1 + 1 file changed, 1 insertion(+) (limited to 'src/main') diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index 9fb7428..5abb6a4 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -10,6 +10,7 @@ from PyQt5.QtWidgets import (QGraphicsColorizeEffect, QGraphicsEllipseItem, QLineEdit) from .line import Line + from utils.app import fileImporter class GripItem(QGraphicsPathItem): -- cgit From 172e96a0068d257986962f32ab67273bfa0200cd Mon Sep 17 00:00:00 2001 From: sumit Date: Tue, 2 Jun 2020 13:12:03 +0530 Subject: update end point of line --- src/main/python/shapes/line.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index e6b1dd9..8c5149f 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -518,6 +518,10 @@ class Line(QGraphicsPathItem): updates points of line when grabber is moved :return: """ + if self.startGripItem: + self.points[0]= self.startPoint + if self.endGripItem: + self.points[len(self.points) - 1] = self.endPoint if self.startGripItem.m_location in ["left", "right"]: point = self.points[1] self.points[1] = QPointF(point.x(), self.startPoint.y()) @@ -527,7 +531,6 @@ class Line(QGraphicsPathItem): else: point = self.points[len(self.points) - 2] self.points[len(self.points) - 2] = QPointF(self.endPoint.x(), point.y()) - else: point = self.points[1] self.points[1] = QPointF(self.startPoint.x(), point.y()) @@ -538,6 +541,7 @@ class Line(QGraphicsPathItem): point = self.points[len(self.points) - 2] self.points[len(self.points) - 2] = QPointF(self.endPoint.x(), point.y()) + def shape(self): """generates outline for path """ -- cgit From 5bf8f7e70f49e0af4939e5bf6ef71053726cc970 Mon Sep 17 00:00:00 2001 From: Blaine Date: Tue, 2 Jun 2020 14:53:37 +0530 Subject: line working --- src/main/python/shapes/line.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 8c5149f..d1e3124 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -71,7 +71,6 @@ class Grabber(QGraphicsPathItem): return self.shape().boundingRect() def mousePressEvent(self, event): - print('grabber clicked', self) super(Grabber, self).mousePressEvent(event) def hoverEnterEvent(self, event): @@ -139,7 +138,6 @@ class LineLabel(QGraphicsTextItem): # print(self.pos()) def itemChange(self, change, value): - print("label change",change,value) # if change == QGraphicsItem.ItemPositionChange: # print("label change", change, value) return super(LineLabel, self).itemChange(change,value) @@ -188,7 +186,9 @@ class Line(QGraphicsPathItem): for polygon in polygons: center = polygon.boundingRect().center() self.commonPaths.append(center) + # self.commonPaths[commonPath] = item + print(self.commonPaths) self.update() def paint(self, painter, option, widget): @@ -198,11 +198,29 @@ class Line(QGraphicsPathItem): # painter.drawPath(path) path = QPainterPath(self.startPoint) # iterating over all points of line - for i in range(1, len(self.points)): + 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: - # point is center of common path - pass - path.lineTo(self.points[i]) + x1, y1 = self.points[i].x(), self.points[i].y() + x2, y2 = self.points[i+1].x(), self.points[i+1].y() + x, y = point.x(), point.y() + # if not x1 * (y - y2) + x * (y2 - y1) + x2 * (y1 - y) : + if x == x1 == x2: + #vertical + if min(y1, y2) <= y < max(y1, y2): + path.lineTo(point - QPointF(0, 8)) + path.arcTo(QRectF(x-8, y-8, 16, 16), 90, -180) + path.moveTo(point + QPointF(0, 8)) + elif y == y1 == y2: + #horizontal + if min(x1, x2) <= x < max(x1, x2): + path.lineTo(point - QPointF(8, 0)) + path.arcTo(QRectF(x-8, y-8, 16, 16), 180, 180) + path.moveTo(point + QPointF(8, 0)) + path.lineTo(self.points[i+1]) + painter.drawPath(path) -- cgit From bfda61462a7c993efc8ed5bf3583f68601c6c074 Mon Sep 17 00:00:00 2001 From: Blaine Date: Tue, 2 Jun 2020 18:02:03 +0530 Subject: reverse dir fix --- src/main/python/shapes/line.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index d1e3124..e0e3fae 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -210,15 +210,29 @@ class Line(QGraphicsPathItem): if x == x1 == x2: #vertical if min(y1, y2) <= y < max(y1, y2): - path.lineTo(point - QPointF(0, 8)) + bool = y2>y1 + if bool: + path.lineTo(point - QPointF(0, 8)) + else: + path.lineTo(point + QPointF(0, 8)) path.arcTo(QRectF(x-8, y-8, 16, 16), 90, -180) - path.moveTo(point + QPointF(0, 8)) + if bool: + path.moveTo(point + QPointF(0, 8)) + else: + path.moveTo(point - QPointF(0, 8)) elif y == y1 == y2: #horizontal if min(x1, x2) <= x < max(x1, x2): - path.lineTo(point - QPointF(8, 0)) + bool = x2>x1 + if bool: + path.lineTo(point - QPointF(8, 0)) + else: + path.lineTo(point - QPointF(8, 0)) path.arcTo(QRectF(x-8, y-8, 16, 16), 180, 180) - path.moveTo(point + QPointF(8, 0)) + if bool: + path.moveTo(point + QPointF(8, 0)) + else: + path.lineTo(point - QPointF(8, 0)) path.lineTo(self.points[i+1]) painter.drawPath(path) -- cgit From 0d93a4bacf0693af87a9b4bc67156e6ce8ef414d Mon Sep 17 00:00:00 2001 From: Blaine Date: Tue, 2 Jun 2020 21:28:30 +0530 Subject: loop 2nd fix --- src/main/python/shapes/line.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index e0e3fae..1c30cd9 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -213,12 +213,11 @@ class Line(QGraphicsPathItem): bool = y2>y1 if bool: path.lineTo(point - QPointF(0, 8)) - else: - path.lineTo(point + QPointF(0, 8)) - path.arcTo(QRectF(x-8, y-8, 16, 16), 90, -180) - if bool: + path.arcTo(QRectF(x-8, y-8, 16, 16), 90, -180) path.moveTo(point + QPointF(0, 8)) else: + path.lineTo(point + QPointF(0, 8)) + path.arcTo(QRectF(x-8, y-8, 16, 16), -90, 180) path.moveTo(point - QPointF(0, 8)) elif y == y1 == y2: #horizontal @@ -226,13 +225,12 @@ class Line(QGraphicsPathItem): bool = x2>x1 if bool: path.lineTo(point - QPointF(8, 0)) - else: - path.lineTo(point - QPointF(8, 0)) - path.arcTo(QRectF(x-8, y-8, 16, 16), 180, 180) - if bool: + path.arcTo(QRectF(x-8, y-8, 16, 16), 180, 180) path.moveTo(point + QPointF(8, 0)) else: path.lineTo(point - QPointF(8, 0)) + path.arcTo(QRectF(x-8, y-8, 16, 16), 0, -180) + path.lineTo(point - QPointF(8, 0)) path.lineTo(self.points[i+1]) painter.drawPath(path) -- cgit From 4bfb3b09971d5e4c1d03469d82fb3b6e884c1aaf Mon Sep 17 00:00:00 2001 From: Blaine Date: Tue, 2 Jun 2020 23:24:34 +0530 Subject: minor typo --- src/main/python/shapes/line.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 1c30cd9..5ad61a7 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -210,8 +210,7 @@ class Line(QGraphicsPathItem): if x == x1 == x2: #vertical if min(y1, y2) <= y < max(y1, y2): - bool = y2>y1 - if bool: + if y2>y1: path.lineTo(point - QPointF(0, 8)) path.arcTo(QRectF(x-8, y-8, 16, 16), 90, -180) path.moveTo(point + QPointF(0, 8)) @@ -222,14 +221,13 @@ class Line(QGraphicsPathItem): elif y == y1 == y2: #horizontal if min(x1, x2) <= x < max(x1, x2): - bool = x2>x1 - if bool: + if x2>x1: path.lineTo(point - QPointF(8, 0)) path.arcTo(QRectF(x-8, y-8, 16, 16), 180, 180) path.moveTo(point + QPointF(8, 0)) else: path.lineTo(point - QPointF(8, 0)) - path.arcTo(QRectF(x-8, y-8, 16, 16), 0, -180) + path.arcTo(QRectF(x-8, y-8, 16, 16), 0, 180) path.lineTo(point - QPointF(8, 0)) path.lineTo(self.points[i+1]) -- cgit From fa77d7e77334d1df269564ee0919a7b917d00676 Mon Sep 17 00:00:00 2001 From: Blaine Date: Tue, 2 Jun 2020 23:27:48 +0530 Subject: checkkk --- src/main/python/shapes/line.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index 5ad61a7..c5d5b57 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -228,7 +228,7 @@ class Line(QGraphicsPathItem): else: path.lineTo(point - QPointF(8, 0)) path.arcTo(QRectF(x-8, y-8, 16, 16), 0, 180) - path.lineTo(point - QPointF(8, 0)) + path.lineTo(point + QPointF(8, 0)) path.lineTo(self.points[i+1]) painter.drawPath(path) -- cgit From d8955687ae3a35a4cb40ee5deca43bc6f605d133 Mon Sep 17 00:00:00 2001 From: sumit Date: Wed, 3 Jun 2020 05:32:55 +0530 Subject: curve fix for line from right to left --- src/main/python/shapes/line.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/line.py b/src/main/python/shapes/line.py index c5d5b57..1a54284 100644 --- a/src/main/python/shapes/line.py +++ b/src/main/python/shapes/line.py @@ -226,9 +226,9 @@ class Line(QGraphicsPathItem): path.arcTo(QRectF(x-8, y-8, 16, 16), 180, 180) path.moveTo(point + QPointF(8, 0)) else: - path.lineTo(point - QPointF(8, 0)) - path.arcTo(QRectF(x-8, y-8, 16, 16), 0, 180) path.lineTo(point + QPointF(8, 0)) + path.arcTo(QRectF(x-8, y-8, 16, 16), 0, -180) + path.lineTo(point - QPointF(8, 0)) path.lineTo(self.points[i+1]) painter.drawPath(path) -- cgit From e1cde189d5eeec7c13c7d3b65b54a9579730d34a Mon Sep 17 00:00:00 2001 From: Blaine Date: Wed, 3 Jun 2020 14:20:43 +0530 Subject: sort col points --- src/main/python/shapes/line.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'src/main') 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>>>>>> changes self.setSharedRenderer(self.m_renderer) # set initial size of item self.width = 100 -- cgit From 01e0a1e191a550ad1cbed717d768a9257d10f462 Mon Sep 17 00:00:00 2001 From: Blaine Date: Wed, 3 Jun 2020 15:29:59 +0530 Subject: upstream --- src/main/python/shapes/shapes.py | 6 ------ 1 file changed, 6 deletions(-) (limited to 'src/main') diff --git a/src/main/python/shapes/shapes.py b/src/main/python/shapes/shapes.py index 5bd68e2..4f2294d 100644 --- a/src/main/python/shapes/shapes.py +++ b/src/main/python/shapes/shapes.py @@ -287,16 +287,10 @@ class NodeItem(QGraphicsSvgItem): QGraphicsSvgItem.__init__(self, parent) self.m_type = unitOperationType self.id = None -<<<<<<< HEAD - 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')) ->>>>>>> changes self.setSharedRenderer(self.m_renderer) # set initial size of item self.width = 100 -- cgit