mirror of https://gitlab.com/pamhyr/pamhyr2
network: Reduce size of edge and fill the polygon.
parent
e7f9b4a717
commit
6a320c904a
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Reference in New Issue