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/shapes.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'src/main/python/shapes/shapes.py') 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