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:
+166
-44
@@ -95,6 +95,16 @@ bool angleRangesOverlap(double s1, double e1, double s2, double e2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// 动作 [a] 在 [project] 中其泳道内的有效槽位(与泳道槽位数钳制一致)。
|
||||
///
|
||||
/// 1 槽泳道恒为 0;旧数据中的历史行序(超出范围 / -1)会被钳制到有效槽位。
|
||||
int effectiveSlot(Project project, Action a) {
|
||||
final int slots = project.slotsOf(a.layer);
|
||||
if (slots <= 1) return 0;
|
||||
final int r = a.row;
|
||||
return r < 0 ? 0 : (r >= slots ? slots - 1 : r);
|
||||
}
|
||||
|
||||
/// 条形(甘特)视图布局。
|
||||
///
|
||||
/// 横轴为相位角(0°–360°),纵轴为动作行。行顺序由 [ordered] 决定,
|
||||
@@ -105,14 +115,23 @@ class BarLayout {
|
||||
/// 参数 [project]:项目数据;[size]:可用画布尺寸。
|
||||
/// 副作用:初始化 [pitch]。
|
||||
BarLayout(this.project, this.size) {
|
||||
// 可用高度 = 总高 - 顶部留白 - 底部预留;按**泳道数**均分并夹取到 [44, 58],
|
||||
// 让相邻泳道之间的空隙能容纳依赖连线及其标签(上限定得高一些,
|
||||
// 泳道少时获得更多垂直间隙,减少标签相互压盖)。
|
||||
final int n = lanes.length;
|
||||
// 可用高度 = 总高 - 顶部留白 - 底部预留;按**总子行数**(各泳道槽位数之和)
|
||||
// 均分并夹取到 [44, 58];单槽泳道时与旧版行为完全一致。
|
||||
// 多槽位工程采用「组内紧凑 + 泳道间拉开」:子行更紧、泳道之间额外留白,
|
||||
// 一眼能看出哪些子行属于同一条泳道。
|
||||
final int n = subRowCount;
|
||||
final int laneN = lanes.length;
|
||||
final double extraTotal = _grouped && laneN > 1 ? (laneN - 1) * laneExtraGap : 0;
|
||||
final double usable = size.height - topPad - bottomReserve;
|
||||
pitch = n == 0 ? 58 : (usable / n).clamp(44, 58);
|
||||
pitch = n == 0 ? 58 : ((usable - extraTotal) / n).clamp(_grouped ? 36 : 44, 58);
|
||||
}
|
||||
|
||||
/// 是否启用「组内紧凑 + 泳道间拉开」的间隔分组(仅多槽位工程)。
|
||||
bool get _grouped => project.hasMultiSlotLanes;
|
||||
|
||||
/// 泳道之间的额外纵向留白(仅多槽位分组时生效,像素)。
|
||||
static const double laneExtraGap = 16;
|
||||
|
||||
/// 布局所依据的项目数据。
|
||||
final Project project;
|
||||
|
||||
@@ -149,12 +168,10 @@ class BarLayout {
|
||||
/// 决定行先后的动作列表;见顶层函数 [orderActions]。
|
||||
List<Action> get ordered => orderActions(project);
|
||||
|
||||
/// 泳道编号(= 物理执行器轨道):所有动作 `layer` 的去重升序列表。
|
||||
List<int> get lanes {
|
||||
final Set<int> s = <int>{for (final Action a in project.actions) a.layer};
|
||||
final List<int> l = s.toList()..sort();
|
||||
return l;
|
||||
}
|
||||
/// 泳道编号(= 物理执行器轨道):来自 [Project.renderLanes]。
|
||||
///
|
||||
/// 开启「保留空泳道」时包含动作已全部移走的空泳道(序号不变)。
|
||||
List<int> get lanes => project.renderLanes;
|
||||
|
||||
/// 泳道号在 [lanes] 中的序号。
|
||||
int laneIndexOf(int lane) => lanes.indexOf(lane);
|
||||
@@ -163,17 +180,65 @@ class BarLayout {
|
||||
List<Action> actionsInLane(int lane) =>
|
||||
ordered.where((Action a) => a.layer == lane).toList();
|
||||
|
||||
/// 泳道号转纵坐标(该泳道顶部 y)。
|
||||
double yForLane(int lane) => topPad + laneIndexOf(lane) * pitch;
|
||||
/// 泳道 [lane] 的槽位数(1–5)。
|
||||
int slotsOf(int lane) => project.slotsOf(lane);
|
||||
|
||||
/// 行索引转纵坐标(按泳道序号)。
|
||||
double yFor(int index) => topPad + index * pitch;
|
||||
/// 动作 [a] 的实际槽位(钳制到所属泳道的有效范围;1 槽泳道恒为 0)。
|
||||
int slotOf(Action a) => effectiveSlot(project, a);
|
||||
|
||||
/// 全部泳道的子行总数(Σ 槽位)。
|
||||
int get subRowCount {
|
||||
int n = 0;
|
||||
for (final int lane in lanes) {
|
||||
n += slotsOf(lane);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/// 泳道 [lane] 之前(不含)的纵向高度(子行 + 分组留白)。
|
||||
double _laneOffsetBefore(int lane) {
|
||||
double h = 0;
|
||||
for (final int l in lanes) {
|
||||
if (l == lane) break;
|
||||
h += slotsOf(l) * pitch + (_grouped ? laneExtraGap : 0);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
/// 泳道号转纵坐标(该泳道顶部 y)。
|
||||
double yForLane(int lane) => topPad + _laneOffsetBefore(lane);
|
||||
|
||||
/// 泳道内槽位转纵坐标(该槽位所在子行的顶部 y)。
|
||||
double yForSlot(int lane, int slot) => yForLane(lane) + slot * pitch;
|
||||
|
||||
/// 内容底部 y(最后一个子行之后)。
|
||||
double get plotBottom {
|
||||
double h = subRowCount * pitch;
|
||||
if (_grouped && lanes.length > 1) h += (lanes.length - 1) * laneExtraGap;
|
||||
return topPad + h;
|
||||
}
|
||||
|
||||
/// 由纵坐标反查最近的泳道号(用于拖拽换道)。
|
||||
int laneAt(double y) {
|
||||
if (lanes.isEmpty) return 0;
|
||||
final int i = ((y - topPad) / pitch).round().clamp(0, lanes.length - 1);
|
||||
return lanes[i];
|
||||
int laneAt(double y) => laneSlotAt(y).$1;
|
||||
|
||||
/// 由纵坐标反查(泳道号, 槽位)——拖拽换道 / 换槽位时使用。
|
||||
(int, int) laneSlotAt(double y) {
|
||||
if (lanes.isEmpty) return (0, 0);
|
||||
double top = topPad;
|
||||
for (int li = 0; li < lanes.length; li++) {
|
||||
final int lane = lanes[li];
|
||||
final int s = slotsOf(lane);
|
||||
final double h = s * pitch;
|
||||
// 泳道之间的额外留白按半份归属本道,保证指针落在空隙中也能命中相邻泳道。
|
||||
final double boundary =
|
||||
top + h + (_grouped && li < lanes.length - 1 ? laneExtraGap * 0.5 : 0);
|
||||
if (y < boundary || li == lanes.length - 1) {
|
||||
final int slot = ((y - top) / pitch).round().clamp(0, s - 1);
|
||||
return (lane, slot);
|
||||
}
|
||||
top += h + (_grouped ? laneExtraGap : 0);
|
||||
}
|
||||
return (lanes.last, slotsOf(lanes.last) - 1);
|
||||
}
|
||||
|
||||
/// 相位角(度)转横坐标;角度先钳制到 `[0, 360]`。
|
||||
@@ -183,7 +248,7 @@ class BarLayout {
|
||||
///
|
||||
/// 宽度至少为 3px,避免极短动作不可见;跨圈部分会被截断到 360°。
|
||||
Rect rectFor(Action a) {
|
||||
final double y = yForLane(a.layer);
|
||||
final double y = yForSlot(a.layer, slotOf(a));
|
||||
final double x0 = xFor(a.startAngle);
|
||||
final double x1 = xFor(math.min(a.endAngle, 360));
|
||||
return Rect.fromLTWH(x0, y, math.max(x1 - x0, 3), barH);
|
||||
@@ -217,18 +282,29 @@ class CircularLayout {
|
||||
CircularLayout(this.project, this.size) {
|
||||
// 圆心略微下移 18px 以平衡顶部刻度标签的视觉重心。
|
||||
center = Offset(size.width / 2, size.height / 2 + 18);
|
||||
// 轨道数 = 泳道数(layer 去重),同一轨道可放多个互不重叠的动作。
|
||||
final int layers = lanes.length;
|
||||
// 子环总数 = Σ 各轨道槽位数(泳道加宽后同一轨道可有多条并行子环);
|
||||
// 单槽时与旧版(按轨道数)完全一致。
|
||||
final int rings = subRingCount;
|
||||
final int laneN = lanes.length;
|
||||
// 多槽位工程采用「组内紧凑 + 轨道间拉开」:同一轨道的子环更紧、
|
||||
// 轨道之间额外留白,一眼能看出哪些子环属于同一轨道。
|
||||
final double extraTotal = _grouped && laneN > 1 ? (laneN - 1) * ringExtraGap : 0;
|
||||
// 最大半径受较短边约束,减去 74px 留给刻度与边距。
|
||||
final double maxR = math.min(size.width, size.height) / 2 - 74;
|
||||
// 在 r0 与 maxR 之间均分各轨道,环间距夹取到 [32, 52]:
|
||||
// 让相邻环之间留出足够空隙放置依赖箭头与图注。
|
||||
pitch = layers <= 1 ? 46 : ((maxR - r0) / (layers - 1)).clamp(32, 56);
|
||||
// 动作环带宽度:只求容纳文字(约 15–18px),环更窄、环间空隙更宽,
|
||||
// 便于在环间放置依赖标签(减少与动作名、其它标签的压盖)。
|
||||
ringWidth = (pitch * 0.42).clamp(14, 17);
|
||||
// 在 r0 与 maxR 之间均分各子环,环间距夹取(多槽位时允许更紧)。
|
||||
pitch = rings <= 1
|
||||
? 46
|
||||
: ((maxR - r0 - extraTotal) / (rings - 1)).clamp(_grouped ? 24 : 32, 56);
|
||||
// 动作环带宽度:只求容纳文字;多槽位分组时子环更窄,轨道间靠留白区分。
|
||||
ringWidth = (pitch * 0.42).clamp(_grouped ? 10 : 14, 17);
|
||||
}
|
||||
|
||||
/// 是否启用「组内紧凑 + 轨道间拉开」的间隔分组(仅多槽位工程)。
|
||||
bool get _grouped => project.hasMultiSlotLanes;
|
||||
|
||||
/// 轨道之间的额外径向留白(仅多槽位分组时生效,像素)。
|
||||
static const double ringExtraGap = 18;
|
||||
|
||||
/// 布局所依据的项目数据。
|
||||
final Project project;
|
||||
|
||||
@@ -247,31 +323,77 @@ class CircularLayout {
|
||||
/// 环的视觉宽度(像素)。
|
||||
late final double ringWidth;
|
||||
|
||||
/// 轨道编号(= 泳道):所有动作 `layer` 的去重升序列表。
|
||||
List<int> get lanes {
|
||||
final Set<int> s = <int>{for (final Action a in project.actions) a.layer};
|
||||
final List<int> l = s.toList()..sort();
|
||||
return l;
|
||||
}
|
||||
/// 轨道编号(= 泳道):来自 [Project.renderLanes](含保留的空轨道)。
|
||||
List<int> get lanes => project.renderLanes;
|
||||
|
||||
/// 轨道号在 [lanes] 中的序号。
|
||||
int laneIndexOf(int lane) => lanes.indexOf(lane);
|
||||
|
||||
/// 由半径反查最近的轨道号(用于拖拽换轨)。
|
||||
int laneAtRadius(double r) {
|
||||
if (lanes.isEmpty) return 0;
|
||||
final int i = ((r - r0) / pitch).round().clamp(0, lanes.length - 1);
|
||||
return lanes[i];
|
||||
/// 轨道 [lane] 的槽位数(1–5)。
|
||||
int slotsOf(int lane) => project.slotsOf(lane);
|
||||
|
||||
/// 动作 [a] 的实际槽位(钳制;1 槽轨道恒为 0)。
|
||||
int slotOf(Action a) => effectiveSlot(project, a);
|
||||
|
||||
/// 全部轨道的子环总数(Σ 槽位)。
|
||||
int get subRingCount {
|
||||
int n = 0;
|
||||
for (final int lane in lanes) {
|
||||
n += slotsOf(lane);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/// 第 [lane] 条轨道对应的环半径(未知轨道回退到最内圈)。
|
||||
double radiusFor(int lane) {
|
||||
/// 轨道 [lane] 之前(不含)的子环数。
|
||||
int subRingIndexOfLane(int lane) {
|
||||
int n = 0;
|
||||
for (final int l in lanes) {
|
||||
if (l == lane) break;
|
||||
n += slotsOf(l);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/// 由半径反查最近的轨道号(用于拖拽换轨)。
|
||||
int laneAtRadius(double r) => laneSlotAtRadius(r).$1;
|
||||
|
||||
/// 由半径反查(轨道号, 槽位)——拖拽换轨 / 换子环时使用。
|
||||
(int, int) laneSlotAtRadius(double r) {
|
||||
if (lanes.isEmpty) return (0, 0);
|
||||
double base = r0;
|
||||
for (int li = 0; li < lanes.length; li++) {
|
||||
final int lane = lanes[li];
|
||||
final int s = slotsOf(lane);
|
||||
final double h = s * pitch;
|
||||
// 轨道之间的额外留白按半份归属本道,落在空隙中也能命中相邻轨道。
|
||||
final double boundary =
|
||||
base + h + (_grouped && li < lanes.length - 1 ? ringExtraGap * 0.5 : 0);
|
||||
if (r < boundary || li == lanes.length - 1) {
|
||||
final int slot = ((r - base) / pitch).round().clamp(0, s - 1);
|
||||
return (lane, slot);
|
||||
}
|
||||
base += h + (_grouped ? ringExtraGap : 0);
|
||||
}
|
||||
return (lanes.last, slotsOf(lanes.last) - 1);
|
||||
}
|
||||
|
||||
/// 轨道 [lane] 第 [slot] 条子环的半径(未知轨道回退到最内圈)。
|
||||
double radiusFor(int lane, [int slot = 0]) {
|
||||
final int i = laneIndexOf(lane);
|
||||
return r0 + (i < 0 ? 0 : i) * pitch;
|
||||
if (i < 0) return r0;
|
||||
final int s = slotsOf(lane);
|
||||
final int k = slot < 0 ? 0 : (slot >= s ? s - 1 : slot);
|
||||
return r0 +
|
||||
(subRingIndexOfLane(lane) + k) * pitch +
|
||||
(_grouped ? i * ringExtraGap : 0);
|
||||
}
|
||||
|
||||
/// 最外层半径。
|
||||
double get rMax => lanes.isEmpty ? r0 : radiusFor(lanes.last);
|
||||
double get rMax {
|
||||
if (lanes.isEmpty) return r0;
|
||||
final double extra = _grouped && lanes.length > 1 ? (lanes.length - 1) * ringExtraGap : 0;
|
||||
return r0 + (subRingCount - 1) * pitch + extra;
|
||||
}
|
||||
|
||||
/// 刻度标签所在的半径(最外层再向外偏移)。
|
||||
/// 刻度环半径:在外层动作环之外留出足够间距,
|
||||
@@ -292,7 +414,7 @@ class CircularLayout {
|
||||
Action? best;
|
||||
double bestDelta = double.infinity;
|
||||
for (final Action a2 in project.actions) {
|
||||
final double r = radiusFor(a2.layer);
|
||||
final double r = radiusFor(a2.layer, slotOf(a2));
|
||||
if ((d - r).abs() > ringWidth / 2 + slop) continue;
|
||||
if (_inArc(a2, a)) {
|
||||
final double delta = (d - r).abs();
|
||||
|
||||
Reference in New Issue
Block a user