feat: 原创「环序」标志;双视图与侧栏优化;工位管理;帮助完善
- 原创应用标志「环序/Cycle-Step」:tools/gen-icon.py 重写 + 工具栏 Logo 同源,小尺寸简化版 - 条形时序视图:标题/副标题精简、双刻度值置于分区与刻度线之间、时间默认内嵌、依赖线箭头收窄、同泳道箭头接色块外侧、图注自动避让 - 圆周时序视图:去掉色块描边、环宽与间隙优化、度数外侧标时间、方向箭头外移;固定顺时针(移除逆时针) - 左侧栏:编辑工位/编辑相位分区入口;双击画布色块或动作行进入编辑;至少保留一个动作/泳道 - 右侧栏:移除重复的编辑操作、导出与单位卡片;文件浏览器新增「桌面」快捷入口 - AI 对话框:字号优化并新增「编辑示例」;节拍统计移除无依据的预估产能 - 文档:README 与 docs/HELP.md 全面更新;dist 同步重建
This commit is contained in:
+83
-63
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user