diff --git a/lib/render/bar_painter.dart b/lib/render/bar_painter.dart index 29c50a2..479c789 100644 --- a/lib/render/bar_painter.dart +++ b/lib/render/bar_painter.dart @@ -429,7 +429,8 @@ class BarPainter extends CustomPainter { ); _arrow(canvas, Offset(tx, tipY), Offset(0, dir), col); final String label = d.type == DepType.fs ? 'FS 顺序' : 'SS +${d.offsetAngle.toStringAsFixed(0)}°'; - _chip(canvas, Offset(chipX, chipY), label, col, crit); + // 标签上移,避免压住箭头(箭头在更靠近目标条块的一侧)。 + _chip(canvas, Offset(chipX, chipY - 11), label, col, crit); k++; } } diff --git a/lib/render/circular_painter.dart b/lib/render/circular_painter.dart index dceb831..18da435 100644 --- a/lib/render/circular_painter.dart +++ b/lib/render/circular_painter.dart @@ -404,11 +404,31 @@ class CircularPainter extends CustomPainter { final Color col = d.type == DepType.fs ? tokens.fs : tokens.ss; final bool crit = criticalDeps.contains('${d.fromId}->${d.toId}'); - final Path p = Path() - ..moveTo(p0.dx, p0.dy) - ..lineTo(p1.dx, p1.dy) - ..arcToPoint(p2, radius: Radius.circular(rC), largeArc: large == 1, clockwise: cw) - ..lineTo(p3.dx, p3.dy); + // 起止角相同(FS 紧随其后)时路径会退化为一条从圆心附近拉出的径向直线, + // 看起来像“杂线”。此时改为贴近目标环的**短箭头**,并让标签旁移。 + final bool degenerate = (aStart - aEnd).abs() < 0.5; + final Path p; + final Offset tipDir; + final Offset chipPos; + if (degenerate) { + final double r0 = rTip - (rTip > rB ? 28 : -28); + final Offset q0 = polar(c, r0, aStart); + p = Path() + ..moveTo(q0.dx, q0.dy) + ..lineTo(p3.dx, p3.dy); + tipDir = p3 - q0; + chipPos = polar(c, (rA + rB) / 2, aStart + 12); + } else { + p = Path() + ..moveTo(p0.dx, p0.dy) + ..lineTo(p1.dx, p1.dy) + ..arcToPoint(p2, radius: Radius.circular(rC), largeArc: large == 1, clockwise: cw) + ..lineTo(p3.dx, p3.dy); + tipDir = p3 - p2; + final double span = (aStart - aEnd).abs(); + final double rChip = skip ? rC : (span < 30 ? rB + layout.th / 2 + 10 : rC); + chipPos = polar(c, rChip, (aEnd + aStart) / 2); + } if (crit) { canvas.drawPath( @@ -428,17 +448,12 @@ class CircularPainter extends CustomPainter { ..strokeCap = StrokeCap.round ..color = col, ); - _arrow(canvas, p3, p3 - p2, col); + _arrow(canvas, p3, tipDir, col); - // 标签胶囊放置在连线中段:跨层时贴最外圈,短跨度时外移避免压线。 - final double theta = (aEnd + aStart) / 2; - final double span = (aStart - aEnd).abs(); - final double rChip = skip ? rC : (span < 30 ? rB + layout.th / 2 + 10 : rC); - final Offset mid = polar(c, rChip, theta); String label = d.type == DepType.fs ? 'FS' : 'SS+${d.offsetAngle.toStringAsFixed(0)}°'; if (d.type == DepType.ff) label = 'FF'; if (d.type == DepType.sf) label = 'SF'; - _chip(canvas, mid, '${A.id}→${B.id} $label', col, crit); + _chip(canvas, chipPos, '${A.id}→${B.id} $label', col, crit); } /// 在 [tip] 处绘制指向 [dir] 方向的实心三角箭头。 @@ -487,7 +502,8 @@ class CircularPainter extends CustomPainter { /// 绘制 0° 起点标记:顶部朝下的三角与“0° · 12 点钟”文字。 void _startMarker(Canvas canvas, CircularLayout layout) { final Offset c = layout.center; - final double r = layout.tickR + 12; + // 放在刻度数字之外,避免与顶部的“0°”刻度标签重叠。 + final double r = layout.tickR + 46; final Offset tip = Offset(c.dx, c.dy - r - 22); final Path p = Path() ..moveTo(tip.dx, tip.dy) @@ -502,8 +518,8 @@ class CircularPainter extends CustomPainter { /// 绘制顺时针方向指示:一段外圈圆弧、箭头与“顺时针 CW”文字。 void _cwArrow(Canvas canvas, CircularLayout layout) { final Offset c = layout.center; - // 放在刻度环之外,避免“冲进”视图内部。 - final double r = layout.tickR + 16; + // 放在刻度数字之外更远处,避免“冲进”视图内部。 + final double r = layout.tickR + 56; final Path p = arcPath(c, r, 20, 70); canvas.drawPath( p, diff --git a/lib/state/app_controller.dart b/lib/state/app_controller.dart index 3b2d370..0cb3c31 100644 --- a/lib/state/app_controller.dart +++ b/lib/state/app_controller.dart @@ -404,7 +404,7 @@ class AppController extends ChangeNotifier { final CircularLayout l = CircularLayout(_project, vp); // 半径需覆盖:刻度文字(tickR + ~50)、顺时针箭头(rMax + ~70)、 // 12 点钟起点标记(tickR + ~70),再留 20px 余量,避免任何标注被裁掉。 - final double contentR = math.max(l.tickR + 90, l.rMax + 100); + final double contentR = math.max(l.tickR + 130, l.rMax + 120); // 顶部为标题浮层预留约 60px,底部留 60px。 final double availW = vp.width - 40; final double availH = vp.height - 120;