feat(deps): 依赖连线自动错开 + 拖拽调整走线(三种视图);发布 v1.3.3

- 新增共享走线模块 lib/layout/dep_routes.dart:条形 / 圆周的走线、标签
  挂钩与外移判定、命中测试统一到同一份几何(绘制与命中不再各算一套);
- 自动错开:同一走线分组(同泳道 / 相邻泳道对 / 跨行对)内的多条依赖
  依次 ±6px 错开,解决“多条线完全重叠”;
- 手动走线偏移:Dependency.routeOffset(随工程保存)——
  · 条形 / 流程图:上下拖动平移横线,跨行走廊为左右拖动;
  · 圆周:沿半径方向(法线)拖动;
  · 直角拐点随平移保留,双击连线或右键「复位走线偏移」恢复自动位置;
  · 选中连线以强调色加粗高亮,状态栏给出操作提示;
- 画布命中判定改用「按下位置」(此前用手势验收点,细目标会抓空),
  端点把手与连线重叠时按“谁更近”判定优先级;
- 帮助中心补充「连线重叠怎么办」;版本号 1.3.3+19;
  更新说明 release/RELEASE_NOTES_v1.3.3.md。
This commit is contained in:
2026-10-09 21:27:40 +08:00
parent c352af2359
commit b902fa06c4
15 changed files with 920 additions and 233 deletions
+27 -5
View File
@@ -14,6 +14,7 @@ import 'dart:ui';
import '../model/models.dart';
import '../model/units.dart';
import 'dep_routes.dart';
import 'layout.dart';
/// 流程图节点(动作节点或开始 / 结束节点)。
@@ -85,7 +86,7 @@ class FlowEdge {
/// 连线走线结果(供画布绘制 / SVG / drawio 导出共用)。
class FlowEdgeRoute {
/// 构造。
FlowEdgeRoute(this.edge, this.points, this.tip, this.dir, this.labelAt);
FlowEdgeRoute(this.edge, this.points, this.tip, this.dir, this.labelAt, this.axis);
/// 对应的连线。
final FlowEdge edge;
@@ -97,6 +98,11 @@ class FlowEdgeRoute {
final Offset dir;
/// FS / SS 标签位置。
final Offset labelAt;
/// 拖拽调整走线的方向:向下流为竖直(上下拖动),同层绕行为水平(左右拖动)。
final RouteAxis axis;
/// 依赖键 `from->to`。
String get key => '${edge.fromId}->${edge.toId}';
/// 是否虚线(SS 依赖)。
bool get dashed => edge.type == DepType.ss;
@@ -300,19 +306,33 @@ class FlowLayout {
}
// 6) 连线走线:画布绘制 / SVG / drawio 导出共用(同源同层分支扇形错位)。
// 依赖上保存的手动走线偏移(routeOffset)在此叠加:
// 向下流为竖直偏移(拖动横线),同层绕行为水平偏移(拖动纵向走廊)。
final Map<String, int> fanIndex = <String, int>{};
for (final FlowEdge e in edges) {
final FlowNode? a = byId[e.fromId];
final FlowNode? b = byId[e.toId];
if (a == null || b == null) continue;
double routeOffset = 0;
if (e.type != null) {
final Action? to = project.actionById(e.toId);
for (final Dependency d in to?.deps ?? const <Dependency>[]) {
if (d.fromId == e.fromId) {
routeOffset = d.routeOffset;
break;
}
}
}
if (b.rank > a.rank) {
final String key = '${e.fromId}:${b.rank}';
final int idx = fanIndex[key] ?? 0;
fanIndex[key] = idx + 1;
final double lane = math.min(
(a.rect.bottom + b.rect.top) / 2 + idx * 14,
// 横线高度:扇形错开 + 手动偏移,限制在源/目标两行之间的空隙内。
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;
final double x0 = a.rect.center.dx;
final double x1 = b.rect.center.dx;
routes.add(FlowEdgeRoute(
@@ -326,10 +346,11 @@ class FlowLayout {
Offset(x1, b.rect.top),
const Offset(0, 1),
Offset((x0 + x1) / 2, lane - 11),
RouteAxis.vertical,
));
} else {
// 同层 / 回连:右侧绕行
final double x = math.max(a.rect.right, b.rect.right) + 22;
// 同层 / 回连:右侧绕行;手动偏移作用于绕行走廊的横向位置。
final double x = math.max(a.rect.right, b.rect.right) + 22 + routeOffset;
routes.add(FlowEdgeRoute(
e,
<Offset>[
@@ -341,6 +362,7 @@ class FlowLayout {
Offset(b.rect.right, b.rect.center.dy),
const Offset(-1, 0),
Offset(x + 16, (a.rect.center.dy + b.rect.center.dy) / 2),
RouteAxis.horizontal,
));
}
}