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:
+143
-10
@@ -180,6 +180,40 @@ class FlowLayout {
|
||||
/// 内容范围(所有节点矩形并集再外扩,供适应视图使用)。
|
||||
Rect bounds = Rect.zero;
|
||||
|
||||
/// 泳道内两个槽位之间的横向间距(留出依赖连线的走线空间)。
|
||||
static const double slotGap = 26;
|
||||
|
||||
/// 各泳道左边缘 x(放置完成后按内容自适应填充)。
|
||||
final List<double> laneStarts = <double>[];
|
||||
|
||||
/// 各泳道宽度(基础 = 槽位数,放置后按内容自动加宽)。
|
||||
final List<double> laneWidths = <double>[];
|
||||
|
||||
/// 第 [li] 条泳道的宽度(优先取内容自适应结果;未计算时按槽位数)。
|
||||
double laneWidth(int li) {
|
||||
if (li >= 0 && li < laneWidths.length) return laneWidths[li];
|
||||
if (li < 0 || li >= lanes.length) return nodeW;
|
||||
final int s = project.slotsOf(lanes[li]);
|
||||
return s * nodeW + (s - 1) * slotGap;
|
||||
}
|
||||
|
||||
/// 第 [li] 条泳道左边缘 x(优先取内容自适应结果,其次按槽位宽度累加)。
|
||||
double laneStartX(int li) {
|
||||
if (li >= 0 && li < laneStarts.length) return laneStarts[li];
|
||||
double x = marginX;
|
||||
for (int i = 0; i < li && i < lanes.length; i++) {
|
||||
x += laneWidth(i) + laneGap;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
/// 第 [li] 条泳道第 [slot] 列的节点中心 x(槽位钳制到有效范围)。
|
||||
double slotCenterX(int li, int slot) {
|
||||
final int s = (li >= 0 && li < lanes.length) ? project.slotsOf(lanes[li]) : 1;
|
||||
final int k = slot < 0 ? 0 : (slot >= s ? s - 1 : slot);
|
||||
return laneStartX(li) + k * (nodeW + slotGap) + nodeW / 2;
|
||||
}
|
||||
|
||||
/// 按 id 查找节点。
|
||||
FlowNode? nodeById(String id) {
|
||||
for (final FlowNode n in nodes) {
|
||||
@@ -198,7 +232,7 @@ class FlowLayout {
|
||||
|
||||
/// 构建节点、连线并完成布局。
|
||||
void _build() {
|
||||
lanes = (<int>{for (final Action a in project.actions) a.layer}.toList())..sort();
|
||||
lanes = project.renderLanes;
|
||||
final Map<String, FlowNode> byId = <String, FlowNode>{};
|
||||
|
||||
// 1) 动作节点(序号与条形视图一致:项目动作列表顺序 + 1)。
|
||||
@@ -290,7 +324,18 @@ class FlowLayout {
|
||||
cellTotal[key] = (cellTotal[key] ?? 0) + 1;
|
||||
}
|
||||
final Map<String, int> cellSeen = <String, int>{};
|
||||
final double lanePitch = nodeW + laneGap;
|
||||
// 泳道基础几何:宽度按槽位数,左边缘按前一泳道宽度累加。
|
||||
laneStarts.clear();
|
||||
laneWidths.clear();
|
||||
{
|
||||
double x = marginX;
|
||||
for (int i = 0; i < lanes.length; i++) {
|
||||
final int s = project.slotsOf(lanes[i]);
|
||||
laneStarts.add(x);
|
||||
laneWidths.add(s * nodeW + (s - 1) * slotGap);
|
||||
x += laneWidths.last + laneGap;
|
||||
}
|
||||
}
|
||||
for (final FlowNode n in nodes) {
|
||||
final int li = laneIndex[n.lane] ?? 0;
|
||||
final String key = '${n.lane}:${n.rank}';
|
||||
@@ -299,15 +344,91 @@ class FlowLayout {
|
||||
cellSeen[key] = idx + 1;
|
||||
final double w = (n.isStart || n.isEnd) ? capW : nodeW;
|
||||
final double h = (n.isStart || n.isEnd) ? capH : nodeH;
|
||||
final double centerX = marginX + li * lanePitch + nodeW / 2 +
|
||||
(idx - (total - 1) / 2) * (nodeW * 0.62);
|
||||
// 开始 / 结束节点居中于泳道带;动作节点按(泳道, 槽位)分列,
|
||||
// 同格多节点再沿横向错开。
|
||||
final double centerX;
|
||||
if (n.isStart || n.isEnd) {
|
||||
centerX = laneStartX(li) + laneWidth(li) / 2;
|
||||
} else {
|
||||
final int slot = effectiveSlot(project, n.action!);
|
||||
centerX = slotCenterX(li, slot) + (idx - (total - 1) / 2) * (nodeW * 0.62);
|
||||
}
|
||||
final double top = marginY + n.rank * (nodeH + rankGap) + (nodeH - h) / 2;
|
||||
n.rect = Rect.fromLTWH(centerX - w / 2, top, w, h);
|
||||
}
|
||||
|
||||
// 同层智能排开:同一 rank 行内若有水平重叠(同格多节点 / 跨列挤出),
|
||||
// 从左到右依次推开,保证节点之间至少留 10px,避免“堆叠到一起看不清”。
|
||||
final Map<int, List<FlowNode>> byRank = <int, List<FlowNode>>{};
|
||||
for (final FlowNode n in nodes) {
|
||||
byRank.putIfAbsent(n.rank, () => <FlowNode>[]).add(n);
|
||||
}
|
||||
for (final List<FlowNode> row in byRank.values) {
|
||||
row.sort((FlowNode a, FlowNode b) => a.rect.left.compareTo(b.rect.left));
|
||||
for (int i = 1; i < row.length; i++) {
|
||||
final FlowNode prev = row[i - 1];
|
||||
final FlowNode cur = row[i];
|
||||
final double minLeft = prev.rect.right + 10;
|
||||
if (cur.rect.left < minLeft) {
|
||||
cur.rect = cur.rect.shift(Offset(minLeft - cur.rect.left, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 泳道带按内容**智能加宽**:若某泳道的节点被推到基础宽度之外,
|
||||
// 先按内容算出需要的加宽量,再把该泳道及其后所有泳道整体右移,
|
||||
// 保证底部泳道带完整覆盖自己的动作节点(与条形 / 圆周视图的观感一致)。
|
||||
final List<double> extra = List<double>.filled(lanes.length, 0);
|
||||
for (int i = 0; i < lanes.length; i++) {
|
||||
double contentRight = double.negativeInfinity;
|
||||
for (final FlowNode n in nodes) {
|
||||
if ((laneIndex[n.lane] ?? 0) == i) {
|
||||
contentRight = math.max(contentRight, n.rect.right);
|
||||
}
|
||||
}
|
||||
if (contentRight.isFinite) {
|
||||
final double need = contentRight + 26 - (laneStarts[i] + laneWidths[i]);
|
||||
if (need > 0) extra[i] = need;
|
||||
}
|
||||
}
|
||||
if (extra.any((double e) => e > 0)) {
|
||||
double delta = 0;
|
||||
for (int i = 0; i < lanes.length; i++) {
|
||||
if (delta != 0) {
|
||||
for (final FlowNode n in nodes) {
|
||||
if ((laneIndex[n.lane] ?? 0) == i) {
|
||||
n.rect = n.rect.shift(Offset(delta, 0));
|
||||
}
|
||||
}
|
||||
laneStarts[i] += delta;
|
||||
}
|
||||
laneWidths[i] += extra[i];
|
||||
// 泳道加宽后,开始 / 结束胶囊重新居中于泳道带。
|
||||
if (extra[i] > 0) {
|
||||
for (final FlowNode n in nodes) {
|
||||
if ((n.isStart || n.isEnd) && (laneIndex[n.lane] ?? 0) == i) {
|
||||
final double cx = laneStarts[i] + laneWidths[i] / 2;
|
||||
n.rect = Rect.fromLTWH(
|
||||
cx - n.rect.width / 2, n.rect.top, n.rect.width, n.rect.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
delta += extra[i];
|
||||
}
|
||||
}
|
||||
|
||||
// 6) 连线走线:画布绘制 / SVG / drawio 导出共用(同源同层分支扇形错位)。
|
||||
// 依赖上保存的手动走线偏移(routeOffset)在此叠加:
|
||||
// 向下流为竖直偏移(拖动横线),同层绕行为水平偏移(拖动纵向走廊)。
|
||||
// 同源同层的多条分支预先分组,横线在可用空隙内**均匀铺开**,
|
||||
// 分支多时不再全部挤在同一条线上(流程图“智能排开”)。
|
||||
final Map<String, List<FlowEdge>> fanGroups = <String, List<FlowEdge>>{};
|
||||
for (final FlowEdge e in edges) {
|
||||
final FlowNode? a = byId[e.fromId];
|
||||
final FlowNode? b = byId[e.toId];
|
||||
if (a == null || b == null || b.rank <= a.rank) continue;
|
||||
fanGroups.putIfAbsent('${e.fromId}:${b.rank}', () => <FlowEdge>[]).add(e);
|
||||
}
|
||||
final Map<String, int> fanIndex = <String, int>{};
|
||||
for (final FlowEdge e in edges) {
|
||||
final FlowNode? a = byId[e.fromId];
|
||||
@@ -325,14 +446,26 @@ class FlowLayout {
|
||||
}
|
||||
if (b.rank > a.rank) {
|
||||
final String key = '${e.fromId}:${b.rank}';
|
||||
final List<FlowEdge> group = fanGroups[key] ?? <FlowEdge>[e];
|
||||
final int idx = fanIndex[key] ?? 0;
|
||||
fanIndex[key] = idx + 1;
|
||||
// 横线高度:扇形错开 + 手动偏移,限制在源/目标两行之间的空隙内。
|
||||
double lane = math.min(
|
||||
(a.rect.bottom + b.rect.top) / 2 + idx * 14 + routeOffset,
|
||||
b.rect.top - 8,
|
||||
);
|
||||
if (lane < a.rect.bottom + 10) lane = a.rect.bottom + 10;
|
||||
// 横线高度:单条分支沿用“空隙中线”;多条分支在
|
||||
// [源底 + 10, 目标顶 - 8] 内均匀铺开(第 idx+1 / n+1 份),再叠加手动偏移。
|
||||
final double gapLow = a.rect.bottom + 10;
|
||||
double gapHigh = double.infinity;
|
||||
for (final FlowEdge ge in group) {
|
||||
final FlowNode? gb = byId[ge.toId];
|
||||
if (gb != null && gb.rect.top - 8 < gapHigh) gapHigh = gb.rect.top - 8;
|
||||
}
|
||||
double lane;
|
||||
if (group.length <= 1) {
|
||||
lane = math.min((a.rect.bottom + b.rect.top) / 2 + routeOffset, b.rect.top - 8);
|
||||
} else {
|
||||
final double span = math.max(gapHigh - gapLow, 8);
|
||||
lane = gapLow + span * (idx + 1) / (group.length + 1) + routeOffset;
|
||||
}
|
||||
if (lane < gapLow) lane = gapLow;
|
||||
if (lane > gapHigh) lane = gapHigh;
|
||||
final double x0 = a.rect.center.dx;
|
||||
final double x1 = b.rect.center.dx;
|
||||
routes.add(FlowEdgeRoute(
|
||||
|
||||
Reference in New Issue
Block a user