feat(V1.0.1): 泳道/轨道支持多动作(同执行器多条不重叠);圆周弧可拖拽端点;依赖标签沿弧避让

- 泳道模型:layer 兼作泳道/轨道编号,同一泳道可放多个互不重叠动作(角区间重叠校验)
- 条形:上下拖拽换道;圆周:Shift+径向拖拽换轨;冲突时拒绝并提示
- 泳道标题合并显示(/ 分隔,≤2 行);左侧列表按泳道分组
- 圆周动作弧支持拖拽两端改起止角(弱吸附 + 径向虚线参考),整体拖拽旋转
- 圆周依赖标签沿圆弧切向排布,落入环间空隙,避免压住动作弧
- 版本 1.0.1+2;帮助/README 补充泳道说明;重新构建 dist
This commit is contained in:
呆头鹅
2026-09-18 17:54:35 +08:00
parent 279cc2318f
commit 339b96c73f
11 changed files with 483 additions and 196 deletions
+75 -33
View File
@@ -39,6 +39,7 @@ class CircularPainter extends CustomPainter {
required this.criticalActions,
required this.criticalDeps,
required this.selectedIds,
this.guideAngle,
});
/// 待绘制的工程数据源。
@@ -52,6 +53,9 @@ class CircularPainter extends CustomPainter {
/// 当前选中的动作 id 集合(支持多选)。
final Set<String> selectedIds;
/// 拖拽动作弧端点时的参考角(度);非空时绘制一条径向虚线参考。
final double? guideAngle;
/// 绘制整个圆形视图。
///
/// 参数 [canvas]/[size] 遵循 Flutter 绘制约定。
@@ -76,12 +80,13 @@ class CircularPainter extends CustomPainter {
..color = tokens.line2,
);
// 圆环背景:每层用一条粗描边构成环带,奇偶层交替着色,
// 圆环背景:每条轨道用一条粗描边构成环带,奇偶交替着色,
// 并在环带内外沿各画一条细描边作为边界。
final int layers = project.maxLayer + 1;
final List<int> lanes = layout.lanes;
final int layers = lanes.length;
if (project.viewState.showRingBg) {
for (int i = 0; i < layers; i++) {
final double r = layout.radiusFor(i);
final double r = layout.radiusFor(lanes[i]);
canvas.drawCircle(
c,
r,
@@ -116,11 +121,11 @@ class CircularPainter extends CustomPainter {
// 象限辅助线(0°/90°/180°/270°)。
_quadrants(canvas, c, layout);
// 层号标签:为每层挑选一个空位角度,避免压住该层的动作弧。
// 轨道标签:为每条轨道挑选一个空位角度,避免压住该轨道的动作弧。
if (project.viewState.showLayerLabels) {
for (int i = 0; i < layers; i++) {
final double r = layout.radiusFor(i);
final double free = _freeAngle(i);
final double r = layout.radiusFor(lanes[i]);
final double free = _freeAngle(lanes[i]);
final Offset lp = polar(c, r, free);
_text(canvas, 'L${i + 1}', lp, color: tokens.ringLabel, size: 10, align: TextAlign.center, weight: FontWeight.w700);
}
@@ -140,6 +145,9 @@ class CircularPainter extends CustomPainter {
_action(canvas, layout, a, u);
}
// 拖拽端点时的径向虚线参考。
if (guideAngle != null) _guide(canvas, layout);
// 起点标记、顺时针方向提示与外围刻度。
_startMarker(canvas, layout);
_cwArrow(canvas, layout);
@@ -409,7 +417,8 @@ class CircularPainter extends CustomPainter {
final bool degenerate = (aStart - aEnd).abs() < 0.5;
final Path p;
final Offset tipDir;
final Offset chipPos;
final double chipR;
final double chipDeg;
if (degenerate) {
final double r0 = rTip - (rTip > rB ? 28 : -28);
final Offset q0 = polar(c, r0, aStart);
@@ -417,7 +426,9 @@ class CircularPainter extends CustomPainter {
..moveTo(q0.dx, q0.dy)
..lineTo(p3.dx, p3.dy);
tipDir = p3 - q0;
chipPos = polar(c, (rA + rB) / 2, aStart + 12);
// 标签放在源环与目标环之间的径向空隙中,沿切向排布。
chipR = (rA + rB) / 2;
chipDeg = aStart;
} else {
p = Path()
..moveTo(p0.dx, p0.dy)
@@ -426,8 +437,8 @@ class CircularPainter extends CustomPainter {
..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);
chipR = skip ? rC : (span < 30 ? rB + layout.th / 2 + 10 : rC);
chipDeg = (aEnd + aStart) / 2;
}
if (crit) {
@@ -453,7 +464,37 @@ class CircularPainter extends CustomPainter {
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, chipPos, '${A.id}→${B.id} $label', col, crit);
_arcChip(canvas, c, chipR, chipDeg, '${A.id}→${B.id} $label', col, crit);
}
/// 沿圆弧切向绘制依赖标签胶囊,使其贴合环间空隙、不压住动作弧。
void _arcChip(Canvas canvas, Offset c, double r, double midDeg, String label, Color col, bool crit) {
final TextPainter tp = _tp(label, 10, col, FontWeight.w600);
final double w = tp.width + 16 + (crit ? 18 : 0);
const double h = 17;
final Offset pos = polar(c, r, midDeg);
final double rad = midDeg * math.pi / 180;
final bool flip = midDeg > 90 && midDeg < 270;
canvas.save();
canvas.translate(pos.dx, pos.dy);
canvas.rotate(flip ? rad + math.pi : rad);
final Rect rect = Rect.fromCenter(center: Offset.zero, width: w, height: h);
canvas.drawRRect(RRect.fromRectAndRadius(rect, const Radius.circular(6)), Paint()..color = tokens.chip);
canvas.drawRRect(
RRect.fromRectAndRadius(rect, const Radius.circular(6)),
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = col,
);
double tx = rect.left + 8;
if (crit) {
canvas.drawCircle(Offset(rect.left + 8, 0), 6.5, Paint()..color = tokens.crit);
_text(canvas, '★', Offset(rect.left + 8, 0), color: tokens.onAccent, size: 10, align: TextAlign.center);
tx = rect.left + 18;
}
tp.paint(canvas, Offset(tx, -tp.height / 2));
canvas.restore();
}
/// 在 [tip] 处绘制指向 [dir] 方向的实心三角箭头。
@@ -474,29 +515,30 @@ class CircularPainter extends CustomPainter {
canvas.drawPath(p, Paint()..color = col);
}
/// 绘制依赖标签胶囊。
///
/// 参数 [center]:胶囊中心;[label]:文字;[col]:边框与文字色;
/// [crit]:为真时在左侧追加星形关键标记并加宽胶囊。
void _chip(Canvas canvas, Offset center, String label, Color col, bool crit) {
final TextPainter tp = _tp(label, 10, col, FontWeight.w600);
final double w = tp.width + 16 + (crit ? 18 : 0);
final Rect r = Rect.fromCenter(center: center, width: w, height: 17);
canvas.drawRRect(RRect.fromRectAndRadius(r, const Radius.circular(6)), Paint()..color = tokens.chip);
canvas.drawRRect(
RRect.fromRectAndRadius(r, const Radius.circular(6)),
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = col,
);
double tx = r.left + 8;
if (crit) {
canvas.drawCircle(Offset(r.left + 8, center.dy), 6.5, Paint()..color = tokens.crit);
_text(canvas, '★', Offset(r.left + 8, center.dy), color: tokens.onAccent, size: 10, align: TextAlign.center);
tx = r.left + 18;
/// 绘制拖拽端点时的径向虚线参考与角度标注。
void _guide(Canvas canvas, CircularLayout layout) {
final Offset c = layout.center;
final double deg = guideAngle!;
final Offset p1 = polar(c, math.max(CircularLayout.r0 - 24, 8), deg);
final Offset p2 = polar(c, layout.tickR + 6, deg);
final Paint paint = Paint()
..color = tokens.accent
..strokeWidth = 1.4
..strokeCap = StrokeCap.round;
const double dash = 6;
const double gap = 6;
final double total = (p2 - p1).distance;
if (total > 0) {
final Offset dir = (p2 - p1) / total;
double t = 0;
while (t < total) {
final double end = math.min(t + dash, total);
canvas.drawLine(p1 + dir * t, p1 + dir * end, paint);
t = end + gap;
}
}
tp.paint(canvas, Offset(tx, center.dy - tp.height / 2));
_text(canvas, '${deg.toStringAsFixed(1)}°', polar(c, layout.tickR + 22, deg),
color: tokens.accent, size: 11, align: TextAlign.center, weight: FontWeight.w700);
}
/// 绘制 0° 起点标记:顶部朝下的三角与“0° · 12 点钟”文字。