feat(flow): 泳道拓宽计划(空泳道策略 + 多槽位泳道,三视图同步);发布 v1.3.4

- 空泳道策略(F2 文档设置 →「泳道」):动作全部移走的泳道可保留(默认,序号不变)
  或自动移除;条形空行 / 圆周空环 / 流程空列与左侧栏占位行同步
- 泳道加宽(1–5 槽):双击条形视图左侧泳道编号 / 右键空白泳道 / 左侧栏「N 槽」徽标;
  条形分子行(浅色虚线分隔)、圆周同色加宽环带 + 槽位虚线、流程图分子列且泳道带
  随内容智能加宽;拖拽动作同时换道 + 换槽位;旧数据零迁移(row 语义改为槽位并自动钳制)
- 流程图智能排开:同源同层扇出连线在空隙内均匀铺开;同层节点水平重叠自动推开
- 显示修复:画布左栏标题按真实行高排版(灰色副标题不再被换行标题压住,
  持续换行到泳道高度不足);多槽位采用「槽位紧凑 + 泳道间拉开」的间隔
- 「时序创建和编辑」更名为「文档设置」(含对话框标题/帮助/文档);新增自动保存
  (默认 10 分钟,可选 1/5/10/30 或关闭;写入文件并同步 .bak)
- 授权临时冻结(kLicenseRequired=false):桌面版导出无需 .lic;关于页授权状态
  「开放授权版本」、EDC 版权、开发者与交流群(邮箱 liuyu65@126.com、微信 online-goose)
- 更新体验:直接升级到最新版本提示、下载过程保持屏幕常亮提示、
  下载/上传统一限速 320KB/s(客户端限速 + 发布脚本 --limit-rate 320k)
- docs/HELP.md 与帮助中心同步更新;新增 docs/ROADMAP.md 开发路线图
- flutter analyze 0 问题、40 项测试全过;演示截图更新(含泳道加宽与拥挤场景验证图)
This commit is contained in:
2026-10-10 09:21:45 +08:00
parent b902fa06c4
commit fe5e0be131
27 changed files with 1390 additions and 245 deletions
+63 -18
View File
@@ -98,19 +98,21 @@ class BarPainter extends CustomPainter {
if (project.viewState.showPhaseBands) _phaseBands(canvas, layout);
// 换泳道拖拽:高亮目标泳道(可放置=强调色,重叠=警示色)。
// 泳道加宽(多槽位)后高亮覆盖该泳道的全部槽位。
if (dropLane != null && layout.lanes.contains(dropLane)) {
final double y = layout.yForLane(dropLane!);
final double h = layout.slotsOf(dropLane!) * layout.pitch;
final Color c = dropValid ? tokens.accent : tokens.danger;
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, BarLayout.rowVisual),
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, h),
const Radius.circular(10),
),
Paint()..color = c.withValues(alpha: 0.12),
);
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, BarLayout.rowVisual),
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, h),
const Radius.circular(10),
),
Paint()
@@ -131,7 +133,7 @@ class BarPainter extends CustomPainter {
void _guide(Canvas canvas, BarLayout layout, UnitSettings u) {
final double deg = guideAngle!;
final double x = layout.xFor(deg.clamp(0, 360));
final double bottom = layout.yFor(layout.ordered.length) - 4;
final double bottom = layout.plotBottom - 4;
final Paint p = Paint()
..color = tokens.accent
..strokeWidth = 1.4;
@@ -235,7 +237,7 @@ class BarPainter extends CustomPainter {
final Paint p = Paint()
..color = col.withValues(alpha: 0.7)
..strokeWidth = 1.4;
_dashedLine(canvas, Offset(x, axisTop + 28), Offset(x, layout.yFor(layout.ordered.length) - 4), p);
_dashedLine(canvas, Offset(x, axisTop + 28), Offset(x, layout.plotBottom - 4), p);
}
}
@@ -271,37 +273,61 @@ class BarPainter extends CustomPainter {
final List<int> lanes = layout.lanes;
for (int li = 0; li < lanes.length; li++) {
final int lane = lanes[li];
final double y = layout.yFor(li);
final double y = layout.yForLane(lane);
final int slots = layout.slotsOf(lane);
final double laneH = slots * layout.pitch;
final List<Action> acts = layout.actionsInLane(lane);
// 隔泳道背景色带,弱化边界。
// 单槽泳道保持与旧版完全一致的背景带 / 底线几何;多槽位覆盖整个泳道带。
final double bandH = slots == 1 ? BarLayout.rowVisual : laneH;
// 隔泳道背景色带(覆盖该泳道全部槽位),弱化边界。
if (li.isEven) {
canvas.drawRRect(
RRect.fromRectAndRadius(
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, BarLayout.rowVisual),
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, bandH),
const Radius.circular(10),
),
Paint()..color = tokens.panel2.withValues(alpha: 0.5),
);
}
// 泳道标题(合并显示,最多两行,用 / 分隔)。
_laneHeader(canvas, layout, li, acts, y);
// 泳道底分隔线。
// 多槽位泳道:槽位之间用浅色虚线分隔,提示并列关系。
if (slots > 1) {
for (int s = 1; s < slots; s++) {
final double sy = y + s * layout.pitch - 8;
_dashedLine(
canvas,
Offset(layout.plotLeft, sy),
Offset(layout.plotRight, sy),
Paint()
..color = tokens.line2.withValues(alpha: 0.5)
..strokeWidth = 1,
);
}
}
// 泳道标题(合并显示;单槽最多两行,多槽位按泳道高度持续换行)。
_laneHeader(canvas, layout, li, acts,
slots == 1 ? y : y + laneH / 2 - BarLayout.rowVisual / 2, slots, laneH);
// 泳道底分隔线(单槽时与旧版一致)。
canvas.drawLine(
Offset(layout.plotLeft, y + BarLayout.rowVisual - 4),
Offset(layout.plotRight, y + BarLayout.rowVisual - 4),
Offset(layout.plotLeft, slots == 1 ? y + BarLayout.rowVisual - 4 : y + laneH - 4),
Offset(layout.plotRight, slots == 1 ? y + BarLayout.rowVisual - 4 : y + laneH - 4),
Paint()
..color = tokens.line2.withValues(alpha: 0.6)
..strokeWidth = 1,
);
// 该泳道内的所有动作条(互不重叠)。
// 该泳道内的所有动作条(按槽位分行放置)。
for (final Action a in acts) {
_bar(canvas, layout, a, u, cycle);
}
}
}
/// 绘制一条泳道的标题:序号徽标 + 合并动作名(≤2 行,用 / 分隔)+ 副标题。
void _laneHeader(Canvas canvas, BarLayout layout, int li, List<Action> acts, double y) {
/// 绘制一条泳道的标题:序号徽标 + 合并动作名 + 副标题。
///
/// 合并动作名在宽度 [BarLayout.leftGutter]-68 内自动换行:单槽泳道最多两行
/// (保持旧版外观);多槽位泳道按泳道高度**持续换行**直到放不下为止
/// (副标题跟随实际行数下移)。
void _laneHeader(Canvas canvas, BarLayout layout, int li, List<Action> acts, double y,
int slots, double laneH) {
final double labelMax = BarLayout.leftGutter - 68;
final Color c0 = acts.isEmpty ? tokens.accent : Color(acts.first.color);
canvas.drawRRect(
@@ -312,7 +338,8 @@ class BarPainter extends CustomPainter {
color: tokens.chip, size: 10, align: TextAlign.center, weight: FontWeight.w700);
if (acts.isEmpty) return;
// 多个动作合并为「A1 上料 / A2 定位」,最多两行。
// 先按足够大的行数测量“真实行高”(字体回退下行高可能大于字号,
// 之前按固定 13px 估算导致标题换行多行后压住灰色副标题)。
final String joined = acts.map((Action a) => '${a.id} ${a.name}').join(' / ');
final TextPainter tp = TextPainter(
text: TextSpan(
@@ -325,15 +352,33 @@ class BarPainter extends CustomPainter {
),
),
textDirection: ui.TextDirection.ltr,
maxLines: 2,
maxLines: 40,
ellipsis: '…',
)..layout(maxWidth: labelMax);
final int totalLines = tp.computeLineMetrics().length;
final double lineH = totalLines == 0 ? 14 : tp.height / totalLines;
// 行数上限:单槽保持两行(旧版外观);多槽位按泳道高度换算并给副标题留一行。
final bool single = slots <= 1;
final int maxLines =
single ? 2 : ((laneH - lineH - 8) / lineH).floor().clamp(2, 40);
if (tp.computeLineMetrics().length != maxLines && maxLines < totalLines) {
tp.maxLines = maxLines;
tp.ellipsis = '…';
tp.layout(maxWidth: labelMax);
}
tp.paint(canvas, Offset(60, y + 2));
final Station? st = project.stationById(acts.first.stationId);
final String sub = '${st?.name ?? acts.first.stationId} · ${acts.first.driver}'
'${acts.length > 1 ? ' · 共 ${acts.length} 个' : ''}';
_textMax(canvas, sub, Offset(60, y + 32), labelMax, color: tokens.dim, size: 10);
// 副标题紧随实际标题高度;单槽保持旧版下边距(y+32)但绝不高于标题底部,
// 多槽位下若剩余高度不足则不再绘制,避免压住标题文字。
final double subY =
single ? math.max(y + 32, y + 2 + tp.height + 2) : y + 2 + tp.height + 2;
if (single || subY + 11 <= y + laneH) {
_textMax(canvas, sub, Offset(60, subY), labelMax, color: tokens.dim, size: 10);
}
}
/// 绘制单个动作条块(投影 / 填充 / 描边 / 跨圈尾段 / 文字标注)。
+70 -10
View File
@@ -92,18 +92,54 @@ class CircularPainter extends CustomPainter {
final int layers = lanes.length;
if (project.viewState.showRingBg) {
for (int i = 0; i < layers; i++) {
final double r = layout.radiusFor(lanes[i]);
final int lane = lanes[i];
final int slots = layout.slotsOf(lane);
final Color band = i.isEven ? tokens.ringA : tokens.ringB;
if (slots <= 1) {
// 单槽轨道:与旧版完全一致(一条环带 + 内外沿细描边)。
final double r = layout.radiusFor(lane, 0);
canvas.drawCircle(
c,
r,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = th
..color = band,
);
canvas.drawCircle(
c,
r - th / 2,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = tokens.ringEdge,
);
canvas.drawCircle(
c,
r + th / 2,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = tokens.ringEdge,
);
continue;
}
// 多槽位轨道:整条轨道用一条加宽的色带(同一泳道同一颜色),
// 槽位之间用浅色虚线分隔;不同轨道之间仍按奇偶交替(与现在一致)。
final double rIn = layout.radiusFor(lane, 0);
final double rOut = layout.radiusFor(lane, slots - 1);
final double rc = (rIn + rOut) / 2;
canvas.drawCircle(
c,
r,
rc,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = th
..color = i.isEven ? tokens.ringA : tokens.ringB,
..strokeWidth = (rOut - rIn) + th
..color = band,
);
canvas.drawCircle(
c,
r - th / 2,
rIn - th / 2,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
@@ -111,12 +147,19 @@ class CircularPainter extends CustomPainter {
);
canvas.drawCircle(
c,
r + th / 2,
rOut + th / 2,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = tokens.ringEdge,
);
final Paint dash = Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1
..color = tokens.ringEdge.withValues(alpha: 0.95);
for (int s = 1; s < slots; s++) {
_dashedCircle(canvas, c, rIn + (s - 0.5) * layout.pitch, dash);
}
}
}
canvas.drawCircle(c, math.max(CircularLayout.r0 - th / 2, 8), Paint()..color = tokens.dial);
@@ -124,11 +167,14 @@ class CircularPainter extends CustomPainter {
// 相位分区环:在最外动作环与刻度环之间画一圈分区色带并标注名称。
if (project.viewState.showPhaseBands) _phaseRing(canvas, layout);
// 轨道标签:为每条轨道挑选一个空位角度,避免压住该轨道的动作弧。
// 轨道标签:为每条轨道挑选一个空位角度,避免压住该轨道的动作弧;
// 多槽位轨道把标签放在轨道带的垂直中心(半径方向)。
if (project.viewState.showLayerLabels) {
for (int i = 0; i < layers; i++) {
final double r = layout.radiusFor(lanes[i]);
final double free = _freeAngle(lanes[i]);
final int lane = lanes[i];
final int slots = layout.slotsOf(lane);
final double r = layout.radiusFor(lane) + (slots - 1) * layout.pitch / 2;
final double free = _freeAngle(lane);
final Offset lp = polar(c, r, free);
_text(canvas, 'L${i + 1}', lp, color: tokens.ringLabel, size: 10, align: TextAlign.center, weight: FontWeight.w700);
}
@@ -305,7 +351,7 @@ class CircularPainter extends CustomPainter {
/// 参数 [u] 为当前单位设置(保留以对齐调用接口,当前未直接使用)。
void _action(Canvas canvas, CircularLayout layout, Action a, UnitSettings u) {
final Offset c = layout.center;
final double r = layout.radiusFor(a.layer);
final double r = layout.radiusFor(a.layer, layout.slotOf(a));
final double th = layout.th;
final Color col = Color(a.color);
final bool sel = selectedIds.contains(a.id);
@@ -511,6 +557,20 @@ class CircularPainter extends CustomPainter {
canvas.drawPath(p, Paint()..color = col);
}
/// 以虚线绘制圆周(用于多槽位轨道内部的槽位分隔线)。
void _dashedCircle(Canvas canvas, Offset center, double r, Paint paint,
{double dash = 6, double gap = 5}) {
final Path path = Path()..addOval(Rect.fromCircle(center: center, radius: r));
for (final ui.PathMetric metric in path.computeMetrics()) {
double dist = 0;
while (dist < metric.length) {
final double end = math.min(dist + dash, metric.length);
canvas.drawPath(metric.extractPath(dist, end), paint);
dist = end + gap;
}
}
}
/// 绘制拖拽端点时的径向虚线参考与角度标注。
void _guide(Canvas canvas, CircularLayout layout) {
final Offset c = layout.center;
+5 -10
View File
@@ -85,24 +85,19 @@ class FlowchartPainter extends CustomPainter {
}
}
/// 绘制泳道背景带与标题(泳道 = 轨道)。
/// 绘制泳道背景带与标题(泳道 = 轨道;多槽位泳道按槽位数加宽带)。
void _lanes(Canvas canvas, FlowLayout layout) {
final double lanePitch = FlowLayout.nodeW + FlowLayout.laneGap;
final double top = layout.bounds.top + 20;
final double bottom = layout.bounds.bottom - 20;
for (int i = 0; i < layout.lanes.length; i++) {
final double cx = FlowLayout.marginX + i * lanePitch + FlowLayout.nodeW / 2;
final Rect band = Rect.fromLTRB(
cx - FlowLayout.nodeW / 2 - 26,
top,
cx + FlowLayout.nodeW / 2 + 26,
bottom,
);
final double left = layout.laneStartX(i) - 26;
final double right = layout.laneStartX(i) + layout.laneWidth(i) + 26;
final Rect band = Rect.fromLTRB(left, top, right, bottom);
canvas.drawRRect(
RRect.fromRectAndRadius(band, const Radius.circular(14)),
Paint()..color = (i.isEven ? tokens.ringA : tokens.ringB).withValues(alpha: 0.55),
);
_text(canvas, '轨道 L${i + 1}', Offset(cx, top + 16),
_text(canvas, '轨道 L${i + 1}', Offset((left + right) / 2, top + 16),
color: tokens.sub, size: 11, weight: FontWeight.w700, align: TextAlign.center);
}
}