From 6a320c904a75f300857f2165a5c67dfbdef52a13 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Rouby <pierre-antoine.rouby@inrae.fr> Date: Wed, 29 Mar 2023 10:28:57 +0200 Subject: [PATCH] network: Reduce size of edge and fill the polygon. --- src/view/network/GraphWidget.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/view/network/GraphWidget.py b/src/view/network/GraphWidget.py index 8878bed4..ff3d8009 100644 --- a/src/view/network/GraphWidget.py +++ b/src/view/network/GraphWidget.py @@ -141,7 +141,7 @@ class EdgeItem(QGraphicsItem): elif not self.graph.graph.is_enable_edge(self.edge): color = Qt.darkGray - painter.setPen(QPen(color, 3, Qt.SolidLine, Qt.RoundCap, + painter.setPen(QPen(color, 2, Qt.SolidLine, Qt.RoundCap, Qt.RoundJoin)) # Draw the line painter.drawLine(line) @@ -152,6 +152,10 @@ class EdgeItem(QGraphicsItem): ) # Draw the arrows + brush = QBrush() + brush.setColor(color) + brush.setStyle(Qt.SolidPattern) + angle = math.acos(line.dx() / line.length()) if line.dy() >= 0: angle = (math.pi * 2.0) - angle @@ -165,8 +169,12 @@ class EdgeItem(QGraphicsItem): math.sin(angle - math.pi + math.pi / 3) * size, math.cos(angle - math.pi + math.pi / 3) * size ) + poly = QPolygonF([line_center, arrow_p1, arrow_p2]) + path = QPainterPath() + path.addPolygon(poly) - painter.drawPolygon(QPolygonF([line_center, arrow_p1, arrow_p2])) + painter.drawPolygon(poly) + painter.fillPath(path, brush) class NodeText(QGraphicsTextItem): def __init__(self, node_item): -- GitLab