network: Reduce size of edge and fill the polygon.

mesh
Pierre-Antoine Rouby 2023-03-29 10:28:57 +02:00
parent e7f9b4a717
commit 6a320c904a
1 changed files with 10 additions and 2 deletions

View File

@ -141,7 +141,7 @@ class EdgeItem(QGraphicsItem):
elif not self.graph.graph.is_enable_edge(self.edge): elif not self.graph.graph.is_enable_edge(self.edge):
color = Qt.darkGray color = Qt.darkGray
painter.setPen(QPen(color, 3, Qt.SolidLine, Qt.RoundCap, painter.setPen(QPen(color, 2, Qt.SolidLine, Qt.RoundCap,
Qt.RoundJoin)) Qt.RoundJoin))
# Draw the line # Draw the line
painter.drawLine(line) painter.drawLine(line)
@ -152,6 +152,10 @@ class EdgeItem(QGraphicsItem):
) )
# Draw the arrows # Draw the arrows
brush = QBrush()
brush.setColor(color)
brush.setStyle(Qt.SolidPattern)
angle = math.acos(line.dx() / line.length()) angle = math.acos(line.dx() / line.length())
if line.dy() >= 0: if line.dy() >= 0:
angle = (math.pi * 2.0) - angle angle = (math.pi * 2.0) - angle
@ -165,8 +169,12 @@ class EdgeItem(QGraphicsItem):
math.sin(angle - math.pi + math.pi / 3) * size, math.sin(angle - math.pi + math.pi / 3) * size,
math.cos(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): class NodeText(QGraphicsTextItem):
def __init__(self, node_item): def __init__(self, node_item):