@@ -16,10 +16,8 @@ class ConnectionPainter
1616
1717public:
1818
19- QPainterPath painterPath () const
19+ QPainterPath cubicPath () const
2020 {
21- QPainterPath path;
22-
2321 QPointF const & source = _connectionGeometry.source ();
2422 QPointF const & sink = _connectionGeometry.sink ();
2523
@@ -30,7 +28,7 @@ class ConnectionPainter
3028
3129 double const defaultOffset = 200 ;
3230
33- double const lineWidth = _connectionGeometry.lineWidth ();
31+ double const lineWidth = _connectionGeometry.lineWidth ();
3432
3533 double const ratio1 = 0.5 ;
3634
@@ -44,19 +42,29 @@ class ConnectionPainter
4442 QPointF c1 (source.x () + defaultOffset * ratio1, source.y () + 2 * verticalOffset);
4543 QPointF c2 (sink.x () - defaultOffset * ratio1, sink.y () + verticalOffset);
4644
47- QPen p;
48-
49- p.setWidth (2 * lineWidth);
50-
5145 // cubic spline
5246 QPainterPath cubic (source);
5347 cubic.cubicTo (c1, c2, sink);
5448
55- path.addPath (cubic);
49+ QPainterPath result (source);
50+
51+ unsigned segments = 20 ;
52+
53+ for (auto i = 0ul ; i < segments; ++i)
54+ {
55+ result.lineTo (cubic.pointAtPercent ( double (i + 1 ) / segments ));
56+ }
5657
57- return path;
58+ QPainterPathStroker stroker; stroker.setWidth (10.0 );
59+
60+ return stroker.createStroke (result);
5861 }
5962
63+ // QPainterPath painterPath() const
64+ // {
65+ // return cubicPath();
66+ // }
67+
6068 inline
6169 void paint (QPainter* painter) const
6270 {
@@ -101,6 +109,10 @@ class ConnectionPainter
101109 painter->drawLine (QLineF (c2, sink));
102110 painter->drawEllipse (c1, 4 , 4 );
103111 painter->drawEllipse (c2, 4 , 4 );
112+
113+ painter->setBrush (Qt::NoBrush);
114+
115+ painter->drawPath (cubicPath ());
104116 }
105117#endif
106118
0 commit comments