feat: 原创「环序」标志;双视图与侧栏优化;工位管理;帮助完善

- 原创应用标志「环序/Cycle-Step」:tools/gen-icon.py 重写 + 工具栏 Logo 同源,小尺寸简化版

- 条形时序视图:标题/副标题精简、双刻度值置于分区与刻度线之间、时间默认内嵌、依赖线箭头收窄、同泳道箭头接色块外侧、图注自动避让

- 圆周时序视图:去掉色块描边、环宽与间隙优化、度数外侧标时间、方向箭头外移;固定顺时针(移除逆时针)

- 左侧栏:编辑工位/编辑相位分区入口;双击画布色块或动作行进入编辑;至少保留一个动作/泳道

- 右侧栏:移除重复的编辑操作、导出与单位卡片;文件浏览器新增「桌面」快捷入口

- AI 对话框:字号优化并新增「编辑示例」;节拍统计移除无依据的预估产能

- 文档:README 与 docs/HELP.md 全面更新;dist 同步重建
This commit is contained in:
admin
2026-09-18 23:32:36 +08:00
parent 71e84e05aa
commit 43c99fc4b6
18 changed files with 1079 additions and 779 deletions
+83 -63
View File
@@ -71,9 +71,13 @@ class BarPainter extends CustomPainter {
final bool dropValid;
/// 标尺横线所在的 y 坐标(画布坐标)。
static const double axisTop = 138;
static const double axisTop = 164;
/// 相位色带的顶部 y 坐标。
static const double phaseBandTop = 92;
/// 相位刻度值所在行的 y(分区带与刻度线之间,上排)。
static const double phaseValY = 136;
/// 时间刻度值所在行的 y(分区带与刻度线之间,下排)。
static const double timeValY = 150;
/// 绘制整张条形视图。
///
@@ -200,22 +204,24 @@ class BarPainter extends CustomPainter {
..strokeWidth = 1,
);
if (d % 60 == 0) {
_text(canvas, pfmt(d.toDouble(), u, dec: 0), Offset(x, axisTop + 44),
// 上排:相位刻度值;下排:时间刻度值(均位于分区带与刻度线之间)。
_text(canvas, pfmt(d.toDouble(), u, dec: 0), Offset(x, phaseValY),
color: tokens.accent, size: 10, align: TextAlign.center);
_text(canvas, tvalStr(d / 360 * cycle, u, dec: u.timeUnit == TimeUnit.ms ? 0 : 1),
Offset(x, axisTop + 22), color: tokens.dim, size: 10, align: TextAlign.center);
Offset(x, timeValY), color: tokens.sub, size: 10, align: TextAlign.center);
}
}
_text(canvas, '时间 / ${timeUnitLabel(u.timeUnit)}', Offset(layout.plotLeft - 14, axisTop + 22),
color: tokens.dim, size: 10, align: TextAlign.right);
_text(canvas, '相位 / ${phaseUnitLabel(u.phaseUnit)}', Offset(layout.plotLeft - 14, axisTop + 44),
// 轴单位图例:与对应刻度值同排,置于最左侧。
_text(canvas, '相位 / ${phaseUnitLabel(u.phaseUnit)}', Offset(layout.plotLeft - 12, phaseValY),
color: tokens.accent, size: 10, align: TextAlign.right);
_text(canvas, '时间 / ${timeUnitLabel(u.timeUnit)}', Offset(layout.plotLeft - 12, timeValY),
color: tokens.sub, size: 10, align: TextAlign.right);
}
/// 绘制循环起止边界线(0° 与 360°)。
///
/// 0° 使用 [Tokens.ok]、360° 使用 [Tokens.warn] 的虚线竖线表示,
/// 并在下方标注“循环开始 / 循环结束”。虚线由 [_dashedLine] 手工分段绘制。
/// 0° 使用 [Tokens.ok]、360° 使用 [Tokens.warn] 的虚线竖线表示;
/// 不再额外标注文字(坐标轴已能说明起止)。虚线由 [_dashedLine] 手工分段绘制。
void _boundaries(Canvas canvas, BarLayout layout) {
for (final double d in <double>[0, 360]) {
final double x = layout.xFor(d);
@@ -224,14 +230,6 @@ class BarPainter extends CustomPainter {
..color = col.withValues(alpha: 0.7)
..strokeWidth = 1.4;
_dashedLine(canvas, Offset(x, axisTop + 28), Offset(x, layout.yFor(layout.ordered.length) - 4), p);
_text(
canvas,
d == 0 ? '循环开始 0°' : '循环结束 360°',
Offset(d == 0 ? x + 8 : x - 8, axisTop + 62),
color: col,
size: 10,
align: d == 0 ? TextAlign.left : TextAlign.right,
);
}
}
@@ -286,7 +284,7 @@ class BarPainter extends CustomPainter {
Offset(layout.plotLeft, y + BarLayout.rowVisual - 4),
Offset(layout.plotRight, y + BarLayout.rowVisual - 4),
Paint()
..color = tokens.line.withValues(alpha: 0.5)
..color = tokens.line2.withValues(alpha: 0.6)
..strokeWidth = 1,
);
// 该泳道内的所有动作条(互不重叠)。
@@ -373,16 +371,18 @@ class BarPainter extends CustomPainter {
Offset(layout.plotLeft + wx + 18, r.center.dy), color: tokens.warn, size: 10);
}
final double durMs = a.durationAngle / 360 * cycle;
if (r.width > 150) {
_text(canvas, a.name, Offset(r.left + 10, r.center.dy - 5),
final String full = '${a.name} ${tfmt(durMs, u)}';
// 默认「名称 + 时长」一起写在条块内、紧跟名称之后(单行,条块更苗条);
// 仅当条块太短、放不下时才移到条块外侧。
final double fullW = _tp(full, 11, tokens.arcText, FontWeight.w700).width;
if (r.width >= fullW + 20) {
_text(canvas, full, Offset(r.left + 10, r.center.dy),
color: tokens.arcText, size: 11, weight: FontWeight.w700);
_text(canvas, tfmt(durMs, u), Offset(r.left + 10, r.center.dy + 7),
color: tokens.arcText.withValues(alpha: 0.8), size: 10);
} else if (r.right + 170 > layout.plotRight) {
_text(canvas, '${a.name} ${tfmt(durMs, u)}', Offset(r.left - 10, r.center.dy),
} else if (r.right + 190 > layout.plotRight) {
_text(canvas, full, Offset(r.left - 10, r.center.dy),
color: c, size: 11, weight: FontWeight.w600, align: TextAlign.right);
} else {
_text(canvas, '${a.name} ${tfmt(durMs, u)}', Offset(r.right + 10, r.center.dy),
_text(canvas, full, Offset(r.right + 10, r.center.dy),
color: c, size: 11, weight: FontWeight.w600);
}
_text(canvas, 'Δ${a.durationAngle.toStringAsFixed(0)}°', Offset(layout.plotRight - 4, r.center.dy),
@@ -416,36 +416,57 @@ class BarPainter extends CustomPainter {
final int ib = index[to.id] ?? 0;
final Color col = d.type == DepType.fs ? tokens.fs : tokens.ss;
final bool crit = criticalDeps.contains('${d.fromId}->${d.toId}');
final String label = d.type == DepType.fs ? 'FS 顺序' : 'SS +${d.offsetAngle.toStringAsFixed(0)}°';
final double chipW = _tp(label, 9.5, col, FontWeight.w600).width + 14 + (crit ? 15 : 0);
final Rect ra = layout.rectFor(from);
final Rect rb = layout.rectFor(to);
const double barHalf = BarLayout.barH / 2;
final double sy = ra.center.dy;
final double ty = rb.center.dy;
final double sx = d.type == DepType.fs ? ra.right : ra.left;
final double ex = d.type == DepType.fs ? sx - 9 : sx + 9;
final double tx = rb.left + 14;
final double dir = ty > sy ? 1 : -1;
final double gapY = ty - dir * 23;
final double tipY = ty - dir * 15;
// 箭头落点:目标条块靠源一侧外缘再留 3px。
final double tipY = ty - dir * (barHalf + 3);
final Path p = Path();
double chipX;
double chipY;
// 同一泳道内的依赖(源/目标同 y):水平直线连接,标签置于线上方。
Offset arrowTip;
Offset arrowDir;
// 同一泳道内的依赖(源/目标同 y):箭头连接两色块的外侧边缘。
final bool sameLane = (ty - sy).abs() < 1;
if (sameLane) {
p.moveTo(ex, sy);
p.lineTo(tx, sy);
chipX = (ex + tx) / 2;
chipY = sy - 14;
final bool fs = d.type == DepType.fs;
final double startX = fs ? ra.right + 2 : ra.left - 2;
double endX = rb.left - 2;
if (endX < startX) endX = rb.right + 2;
p.moveTo(startX, sy);
p.lineTo(endX, sy);
arrowTip = Offset(endX, sy);
arrowDir = Offset(endX >= startX ? 1 : -1, 0);
chipX = (startX + endX) / 2;
chipY = sy - (barHalf + 9);
// 两动作间距太短、图注放不下时,自动移到箭头右侧。
if ((endX - startX).abs() < chipW + 8) chipX = endX + chipW / 2 + 6;
} else if ((ib - ia).abs() <= 1) {
chipY = gapY;
p.moveTo(ex, sy + dir * 13);
p.lineTo(ex, gapY);
p.lineTo(tx, gapY);
p.lineTo(tx, tipY - dir * 12);
// 相邻泳道:在两泳道之间的空隙中线走水平线,箭头指向目标条块。
final double mid = (sy + ty) / 2;
final double sx = d.type == DepType.fs ? ra.right : ra.left;
final double ex = d.type == DepType.fs ? sx - 9 : sx + 9;
final double tx = rb.left + 14;
p.moveTo(ex, sy + dir * (barHalf + 2));
p.lineTo(ex, mid);
p.lineTo(tx, mid);
p.lineTo(tx, tipY);
arrowTip = Offset(tx, tipY);
arrowDir = Offset(0, dir);
chipX = (ex + tx) / 2;
chipY = mid;
if ((tx - ex).abs() < chipW + 10) chipX = tx + chipW / 2 + 6;
} else {
// 跨多行:扫描区间内所有条块边界,据此在外侧选一条竖直泳道。
final double sx = d.type == DepType.fs ? ra.right : ra.left;
final double ex = d.type == DepType.fs ? sx - 9 : sx + 9;
final double tx = rb.left + 14;
double maxRight = 0;
double minLeft = double.infinity;
final List<int> lanes = layout.lanes;
@@ -461,15 +482,18 @@ class BarPainter extends CustomPainter {
if (lane > layout.plotRight - 16) {
lane = math.min(math.min(sx, tx), minLeft) - 28 - (k % 3) * 16;
}
final double srcGapY = sy + dir * 27;
p.moveTo(ex, sy + dir * 13);
final double srcGapY = sy + dir * (barHalf + 14);
final double gapY = ty - dir * (barHalf + 6);
p.moveTo(ex, sy + dir * (barHalf + 2));
p.lineTo(ex, srcGapY);
p.lineTo(lane, srcGapY);
p.lineTo(lane, gapY);
p.lineTo(tx, gapY);
p.lineTo(tx, tipY - dir * 12);
p.lineTo(tx, tipY);
arrowTip = Offset(tx, tipY);
arrowDir = Offset(0, dir);
chipX = (lane + tx) / 2;
chipY = gapY;
chipY = gapY - (barHalf + 1);
}
// 关键路径依赖:先铺一层加粗低透明度光晕,再画主线。
if (crit) {
@@ -477,7 +501,7 @@ class BarPainter extends CustomPainter {
p,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 9
..strokeWidth = 5
..strokeCap = StrokeCap.round
..color = col.withValues(alpha: 0.18),
);
@@ -486,18 +510,13 @@ class BarPainter extends CustomPainter {
p,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = crit ? 2.2 : 1.7
..strokeWidth = crit ? 1.1 : 0.85
..strokeCap = StrokeCap.round
..color = col.withValues(alpha: 0.95),
);
if (sameLane) {
_arrow(canvas, Offset(tx, sy), const Offset(1, 0), col);
} else {
_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 - 11), label, col, crit);
_arrow(canvas, arrowTip, arrowDir, col);
// 标签置于依赖线旁,避免压住箭头。
_chip(canvas, Offset(chipX, chipY), label, col, crit);
k++;
}
}
@@ -507,7 +526,7 @@ class BarPainter extends CustomPainter {
///
/// 参数 [col] 为填充色;[dir] 只需提供方向(本函数不归一化,直接按分量使用)。
void _arrow(Canvas canvas, Offset tip, Offset dir, Color col) {
const double s = 13;
const double s = 6.5;
final Offset b = tip - dir * s;
final Offset n = Offset(-dir.dy, dir.dx) * s * 0.5;
final Path p = Path()
@@ -523,27 +542,28 @@ class BarPainter extends CustomPainter {
/// 参数 [center]:胶囊中心;[label]:文字;[col]:边框与文字色;
/// [crit]:为真时在左侧追加星形关键标记,并把胶囊加宽。
void _chip(Canvas canvas, Offset center, String label, Color col, bool crit) {
final TextPainter tp = _tp(label, 10.5, col, FontWeight.w600);
final double w = tp.width + 18 + (crit ? 18 : 0);
const double h = 18;
// 图注字号与刻度文字接近,整体更紧凑。
final TextPainter tp = _tp(label, 9.5, col, FontWeight.w600);
final double w = tp.width + 14 + (crit ? 15 : 0);
const double h = 15;
final Rect r = Rect.fromCenter(center: center, width: w, height: h);
canvas.drawRRect(
RRect.fromRectAndRadius(r, const Radius.circular(6)),
RRect.fromRectAndRadius(r, const Radius.circular(5)),
Paint()..color = tokens.chip,
);
canvas.drawRRect(
RRect.fromRectAndRadius(r, const Radius.circular(6)),
RRect.fromRectAndRadius(r, const Radius.circular(5)),
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = col,
);
if (crit) {
canvas.drawCircle(Offset(r.left + 9, center.dy), 7, Paint()..color = tokens.crit);
_text(canvas, '★', Offset(r.left + 9, center.dy), color: tokens.onAccent, size: 10, align: TextAlign.center);
tp.paint(canvas, Offset(r.left + 20, center.dy - tp.height / 2));
canvas.drawCircle(Offset(r.left + 8, center.dy), 6, Paint()..color = tokens.crit);
_text(canvas, '★', Offset(r.left + 8, center.dy), color: tokens.onAccent, size: 9, align: TextAlign.center);
tp.paint(canvas, Offset(r.left + 16, center.dy - tp.height / 2));
} else {
tp.paint(canvas, Offset(r.left + 9, center.dy - tp.height / 2));
tp.paint(canvas, Offset(r.left + 7, center.dy - tp.height / 2));
}
}
+36 -50
View File
@@ -17,6 +17,7 @@ import 'package:flutter/material.dart' hide Action;
import '../layout/layout.dart';
import '../model/models.dart';
import '../model/units.dart';
import '../theme/tokens.dart';
/// 圆形视图的 [CustomPainter] 实现。
@@ -118,9 +119,6 @@ class CircularPainter extends CustomPainter {
// 相位分区环:在最外动作环与刻度环之间画一圈分区色带并标注名称。
if (project.viewState.showPhaseBands) _phaseRing(canvas, layout);
// 象限辅助线(0°/90°/180°/270°)。
_quadrants(canvas, c, layout);
// 轨道标签:为每条轨道挑选一个空位角度,避免压住该轨道的动作弧。
if (project.viewState.showLayerLabels) {
for (int i = 0; i < layers; i++) {
@@ -148,9 +146,9 @@ class CircularPainter extends CustomPainter {
// 拖拽端点时的径向虚线参考。
if (guideAngle != null) _guide(canvas, layout);
// 起点标记、顺时针方向提示与外围刻度。
// 起点标记、循环方向提示与外围刻度。
_startMarker(canvas, layout);
_cwArrow(canvas, layout);
_directionArrow(canvas, layout);
if (project.viewState.showRuler) _ticks(canvas, layout);
}
@@ -285,21 +283,6 @@ class CircularPainter extends CustomPainter {
return n >= a.startAngle - 0.5 || n <= (a.endAngle - 360) + 0.5;
}
/// 绘制 0°/90°/180°/270° 四条象限辅助线(从内圈延伸到刻度环)。
void _quadrants(Canvas canvas, Offset c, CircularLayout layout) {
for (final double d in <double>[0, 90, 180, 270]) {
final Offset p1 = polar(c, 30, d);
final Offset p2 = polar(c, layout.tickR + 4, d);
canvas.drawLine(
p1,
p2,
Paint()
..color = tokens.line2.withValues(alpha: 0.7)
..strokeWidth = 1,
);
}
}
/// 绘制单个动作弧。
///
/// 算法:
@@ -325,14 +308,7 @@ class CircularPainter extends CustomPainter {
// 第二段且为跨循环时视为“尾巴”,需淡化处理。
final bool tail = a.wrap && k == 1;
final Path p = arcPath(c, r, segs[k][0], segs[k][1]);
canvas.drawPath(
p,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = th + 7
..strokeCap = a.wrap ? StrokeCap.butt : StrokeCap.round
..color = tokens.shadow.withValues(alpha: tokens.shadowOp),
);
// 圆周色块不加描边 / 阴影,保持干净。
canvas.drawPath(
p,
Paint()
@@ -446,7 +422,7 @@ class CircularPainter extends CustomPainter {
p,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 9
..strokeWidth = 5
..strokeCap = StrokeCap.round
..color = col.withValues(alpha: 0.2),
);
@@ -455,7 +431,7 @@ class CircularPainter extends CustomPainter {
p,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = crit ? 3 : (d.type == DepType.fs ? 2.4 : 2)
..strokeWidth = crit ? 1.2 : (d.type == DepType.fs ? 1.0 : 0.9)
..strokeCap = StrokeCap.round
..color = col,
);
@@ -482,7 +458,7 @@ class CircularPainter extends CustomPainter {
final double len = dir.distance;
if (len < 0.001) return;
final Offset u = dir / len;
const double s = 12;
const double s = 6;
final Offset b = tip - u * s;
final Offset n = Offset(-u.dy, u.dx) * s * 0.5;
final Path p = Path()
@@ -535,40 +511,46 @@ class CircularPainter extends CustomPainter {
color: tokens.accent, size: 11, align: TextAlign.center, weight: FontWeight.w600);
}
/// 绘制顺时针方向指示:一段外圈圆弧、箭头与“顺时针 CW”文字。
void _cwArrow(Canvas canvas, CircularLayout layout) {
/// 绘制循环方向指示:外圈一段短弧 + 沿切线的箭头,标注顺时针。
void _directionArrow(Canvas canvas, CircularLayout layout) {
final Offset c = layout.center;
// 放在刻度数字之外更远处,避免“冲进”视图内部。
final double r = layout.tickR + 56;
final Path p = arcPath(c, r, 20, 70);
// 放在度数 / 时间两排标签之外,避免箭头与文字相撞。
final double r = layout.tickR + 72;
canvas.drawPath(
p,
arcPath(c, r, 25, 60),
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 2.4
..strokeWidth = 1.8
..strokeCap = StrokeCap.round
..color = tokens.accent2,
);
final Offset t1 = polar(c, r, 74);
final Offset t2 = polar(c, r + 14, 68);
final Offset t3 = polar(c, r - 14, 66);
final Path a = Path()
..moveTo(t1.dx, t1.dy)
..lineTo(t2.dx, t2.dy)
..lineTo(t3.dx, t3.dy)
// 箭头指向弧的终点,方向与切线一致(顺时针)。
const double te = 60;
final double trad = te * math.pi / 180;
final Offset tip = polar(c, r, te);
final Offset tan = Offset(math.cos(trad), math.sin(trad));
const double s = 7;
final Offset b = tip - tan * s;
final Offset n = Offset(-tan.dy, tan.dx) * s * 0.5;
final Path head = Path()
..moveTo(tip.dx, tip.dy)
..lineTo(b.dx + n.dx, b.dy + n.dy)
..lineTo(b.dx - n.dx, b.dy - n.dy)
..close();
canvas.drawPath(a, Paint()..color = tokens.accent2);
final Offset label = polar(c, r + 30, 45);
_text(canvas, '顺时针 CW', label, color: tokens.accent2, size: 11, align: TextAlign.center, weight: FontWeight.w600);
canvas.drawPath(head, Paint()..color = tokens.accent2);
_text(canvas, '顺时针 CW', polar(c, r + 20, 42),
color: tokens.accent2, size: 10, align: TextAlign.center, weight: FontWeight.w600);
}
/// 绘制外围角度刻度。
///
/// 每 5° 一个刻度,10° 为中刻度,30° 为主刻度并标注度数;
/// 90° 的整数倍使用强调色加粗,便于快速定位象限。
/// 90° 的整数倍使用强调色加粗。度数外侧再标注等价的绝对时间。
void _ticks(Canvas canvas, CircularLayout layout) {
final Offset c = layout.center;
final double r = layout.tickR;
final UnitSettings u = project.units;
final double cycle = project.cycle.durationMs;
for (int d = 0; d < 360; d += 5) {
final bool major = d % 30 == 0;
final bool mid = d % 10 == 0;
@@ -582,12 +564,16 @@ class CircularPainter extends CustomPainter {
..color = major ? tokens.line2 : tokens.line,
);
if (major) {
final Offset lp = polar(c, r + 38, d.toDouble());
final Offset lp = polar(c, r + 34, d.toDouble());
_text(canvas, '$d°', lp,
color: d % 90 == 0 ? tokens.accent : tokens.sub,
size: 10,
align: TextAlign.center,
weight: d % 90 == 0 ? FontWeight.w700 : FontWeight.normal);
// 度数外侧增加一个时间数值(字号与度数保持一致)。
final Offset tp = polar(c, r + 48, d.toDouble());
_text(canvas, tvalStr(d / 360 * cycle, u, dec: u.timeUnit == TimeUnit.ms ? 0 : 1), tp,
color: tokens.sub, size: 10, align: TextAlign.center);
}
}
}