v1.3.11: 全局更名为 EDC|易得; 更新下载屏幕常亮+防误触退出; 连线法向箭头+多线避让+平板拖动优化(线段拖动/磁吸虚线/抓取光标/实时预览)
This commit is contained in:
+340
-95
@@ -26,6 +26,9 @@ import '../state/app_controller.dart';
|
||||
import '../theme/tokens.dart';
|
||||
import 'dialogs.dart';
|
||||
|
||||
/// 连线拖拽吸附结果:吸附后的坐标 + 对齐导引(null = 该轴无对齐)。
|
||||
typedef ConnSnap = ({double x, double y, double? gx, double? gy});
|
||||
|
||||
/// 架构图画布组件。
|
||||
class ArchView extends StatefulWidget {
|
||||
/// 构造画布;[controller] 为全局应用控制器。
|
||||
@@ -56,15 +59,29 @@ class _ArchViewState extends State<ArchView>
|
||||
// ---- 连线草稿(按住左键画路径) ----
|
||||
String? _connFromId;
|
||||
|
||||
// ---- 连线折点拖动 ----
|
||||
// ---- 连线拖拽编辑(端点 / 折点 / 线段三种模式) ----
|
||||
ArchConnector? _connVertexOrigin;
|
||||
int _connVertexIndex = 0;
|
||||
List<Offset> _connVertexPts = <Offset>[];
|
||||
ArchConnector? _connVertexUpdated;
|
||||
|
||||
/// 端点拖拽中的候选吸附目标(松手时生效;null = 脱离为自由端点)。
|
||||
/// 拖动模式:endpoint(端点)/ corner(折点)/ segment(线段)。
|
||||
String? _connDragMode;
|
||||
|
||||
/// 端点模式:几何端点序号(0 = 起点,末位 = 终点)。
|
||||
int _connVertexIndex = 0;
|
||||
|
||||
/// 折点模式:折点序号([ArchConnector.mids] 下标)。
|
||||
int _connMidIndex = 0;
|
||||
|
||||
/// 线段模式:拖动轴('x' / 'y')与初始坐标(同坐标折点一起移动)。
|
||||
String? _connSegAxis;
|
||||
double? _connSegSeed;
|
||||
|
||||
/// 端点拖拽中的候选吸附目标(实时预览;null = 脱离为自由端点)。
|
||||
String? _connDragTargetId;
|
||||
|
||||
/// 鼠标悬停在连线上(显示抓取光标)。
|
||||
bool _hoverConn = false;
|
||||
|
||||
// ---- 平移 ----
|
||||
bool _panning = false;
|
||||
Offset _panStartScreen = Offset.zero;
|
||||
@@ -356,8 +373,9 @@ class _ArchViewState extends State<ArchView>
|
||||
);
|
||||
|
||||
/// 命中测试:返回 (id, 图形?)。优先图形 → 连线 → 墨迹(后者在上层);
|
||||
/// 隐藏图层与锁定图层的对象不可选中。
|
||||
(String?, ArchShape?) _hitTest(Offset world) {
|
||||
/// 隐藏图层与锁定图层的对象不可选中。[connTol] > 0 时覆盖连线的命中宽容
|
||||
/// (平板 / 手指选中连线时放大)。
|
||||
(String?, ArchShape?) _hitTest(Offset world, {double connTol = 0}) {
|
||||
final ArchDoc doc = c.arch;
|
||||
for (int i = doc.shapes.length - 1; i >= 0; i--) {
|
||||
final ArchShape s = doc.shapes[i];
|
||||
@@ -366,19 +384,11 @@ class _ArchViewState extends State<ArchView>
|
||||
}
|
||||
if (s.hitTest(world)) return (s.id, s);
|
||||
}
|
||||
final double tol = 8 / c.arch.zoom + 4;
|
||||
for (int i = doc.connectors.length - 1; i >= 0; i--) {
|
||||
final ArchConnector cn = doc.connectors[i];
|
||||
if (!doc.isLayerVisible(cn.layerId) || doc.isLayerLocked(cn.layerId)) {
|
||||
continue;
|
||||
}
|
||||
final ArchConnGeometry g = archConnectorGeometry(doc, cn);
|
||||
for (int k = 0; k < g.pts.length - 1; k++) {
|
||||
if (archDistToSegment(world, g.pts[k], g.pts[k + 1]) <= tol) {
|
||||
return (cn.id, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
final ArchConnector? cn = _connAt(
|
||||
world,
|
||||
connTol > 0 ? connTol : (8 / c.arch.zoom + 4),
|
||||
);
|
||||
if (cn != null) return (cn.id, null);
|
||||
for (int i = doc.strokes.length - 1; i >= 0; i--) {
|
||||
final ArchStroke s = doc.strokes[i];
|
||||
if (!doc.isLayerVisible(s.layerId) || doc.isLayerLocked(s.layerId)) {
|
||||
@@ -389,17 +399,199 @@ class _ArchViewState extends State<ArchView>
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
/// 命中的图形(宽容 6px,用于手绘箭头端点与连线自动吸附;
|
||||
/// 命中连线(最上层优先;隐藏 / 锁定图层跳过)。
|
||||
ArchConnector? _connAt(Offset world, double tol) {
|
||||
final ArchDoc doc = c.arch;
|
||||
for (int i = doc.connectors.length - 1; i >= 0; i--) {
|
||||
final ArchConnector cn = doc.connectors[i];
|
||||
if (!doc.isLayerVisible(cn.layerId) || doc.isLayerLocked(cn.layerId)) {
|
||||
continue;
|
||||
}
|
||||
final ArchConnGeometry g = archConnectorGeometry(doc, cn);
|
||||
for (int k = 0; k < g.pts.length - 1; k++) {
|
||||
if (archDistToSegment(world, g.pts[k], g.pts[k + 1]) <= tol) {
|
||||
return cn;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// 命中的图形(宽容 [pad],用于手绘箭头端点与连线自动吸附;
|
||||
/// 锁定图层仍可作为吸附参照,隐藏图层不可)。
|
||||
ArchShape? _shapeAt(Offset world) {
|
||||
ArchShape? _shapeAt(Offset world, {double pad = 6}) {
|
||||
final ArchDoc doc = c.arch;
|
||||
for (int i = doc.shapes.length - 1; i >= 0; i--) {
|
||||
if (!doc.isLayerVisible(doc.shapes[i].layerId)) continue;
|
||||
if (doc.shapes[i].hitTest(world, pad: 6)) return doc.shapes[i];
|
||||
if (doc.shapes[i].hitTest(world, pad: pad)) return doc.shapes[i];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---- 连线拖拽辅助(端点 / 折点 / 线段 + 吸附导引) ----
|
||||
|
||||
/// 开始连线拖拽(端点 / 折点模式)。
|
||||
void _beginConnDrag(ArchConnector conn, String mode) {
|
||||
_connVertexOrigin = conn;
|
||||
_connVertexUpdated = null;
|
||||
_connDragMode = mode;
|
||||
_connDragTargetId = null;
|
||||
_connSegAxis = null;
|
||||
_connSegSeed = null;
|
||||
_guideXs = const <double>[];
|
||||
_guideYs = const <double>[];
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
/// 开始连线线段拖动:把路径中间台阶物化为折点,整体平移该段。
|
||||
void _beginConnSegmentDrag(
|
||||
ArchConnector conn,
|
||||
ArchConnGeometry g,
|
||||
Offset world,
|
||||
int k,
|
||||
bool hasA,
|
||||
bool hasB,
|
||||
) {
|
||||
final List<Offset> pts = g.pts;
|
||||
final int last = pts.length - 1;
|
||||
final Offset d = pts[k + 1] - pts[k];
|
||||
final bool segH = d.dx.abs() >= d.dy.abs();
|
||||
List<Offset> mids;
|
||||
String axis;
|
||||
double seed;
|
||||
if (conn.mids.isNotEmpty) {
|
||||
mids = List<Offset>.of(conn.mids);
|
||||
axis = segH ? 'y' : 'x';
|
||||
seed = segH ? pts[k].dy : pts[k].dx;
|
||||
} else {
|
||||
// 无折点:优先取路径中间的可移动台阶(其两端均为折点)。
|
||||
final int lo = hasA ? 2 : 1;
|
||||
final int hi = hasB ? last - 2 : last - 1;
|
||||
final List<Offset>? found = lo < hi ? <Offset>[pts[lo], pts[lo + 1]] : null;
|
||||
if (found != null) {
|
||||
mids = found;
|
||||
final Offset fd = found[1] - found[0];
|
||||
final bool fh = fd.dx.abs() >= fd.dy.abs();
|
||||
axis = fh ? 'y' : 'x';
|
||||
seed = fh ? found[0].dy : found[0].dx;
|
||||
} else if (segH) {
|
||||
// 直线:在抓取处生成竖台阶(之后随手指左右平移)。
|
||||
axis = 'x';
|
||||
seed = world.dx;
|
||||
mids = <Offset>[
|
||||
Offset(seed, pts.first.dy),
|
||||
Offset(seed, pts.last.dy),
|
||||
];
|
||||
} else {
|
||||
// 直线:在抓取处生成横台阶(之后随手指上下平移)。
|
||||
axis = 'y';
|
||||
seed = world.dy;
|
||||
mids = <Offset>[
|
||||
Offset(pts.first.dx, seed),
|
||||
Offset(pts.last.dx, seed),
|
||||
];
|
||||
}
|
||||
}
|
||||
_connVertexOrigin = conn.copyWith(mids: mids);
|
||||
_connVertexUpdated = _connVertexOrigin;
|
||||
_connDragMode = 'segment';
|
||||
_connDragTargetId = null;
|
||||
_connSegAxis = axis;
|
||||
_connSegSeed = seed;
|
||||
_guideXs = const <double>[];
|
||||
_guideYs = const <double>[];
|
||||
setState(() {});
|
||||
}
|
||||
|
||||
/// 连线拖拽吸附:磁力对齐(图元边 / 中心、其它连线折点、自身折点、
|
||||
/// 图纸中心)+ 网格回退;返回导引虚线坐标(虚线由画笔统一绘制)。
|
||||
ConnSnap _snapConnCoord(
|
||||
Offset p,
|
||||
ArchConnector? self, {
|
||||
bool onlyX = false,
|
||||
bool onlyY = false,
|
||||
}) {
|
||||
final double tol = 6 / c.arch.zoom;
|
||||
double bx = p.dx;
|
||||
double by = p.dy;
|
||||
double? gx;
|
||||
double? gy;
|
||||
if (!onlyY) {
|
||||
double best = tol + 0.0001;
|
||||
double? val;
|
||||
for (final double cx in _alignCandidates(self, x: true)) {
|
||||
final double d = (cx - p.dx).abs();
|
||||
if (d < best) {
|
||||
best = d;
|
||||
val = cx;
|
||||
}
|
||||
}
|
||||
if (val != null) {
|
||||
bx = val;
|
||||
gx = val;
|
||||
}
|
||||
}
|
||||
if (!onlyX) {
|
||||
double best = tol + 0.0001;
|
||||
double? val;
|
||||
for (final double cy in _alignCandidates(self, x: false)) {
|
||||
final double d = (cy - p.dy).abs();
|
||||
if (d < best) {
|
||||
best = d;
|
||||
val = cy;
|
||||
}
|
||||
}
|
||||
if (val != null) {
|
||||
by = val;
|
||||
gy = val;
|
||||
}
|
||||
}
|
||||
if (c.arch.gridSnap) {
|
||||
final Offset s = archSnapPoint(c.arch, Offset(bx, by));
|
||||
if (gx == null && !onlyY) bx = s.dx;
|
||||
if (gy == null && !onlyX) by = s.dy;
|
||||
}
|
||||
return (x: bx, y: by, gx: gx, gy: gy);
|
||||
}
|
||||
|
||||
/// 对齐候补坐标:图元左 / 中 / 右(或上 / 中 / 下)、其它连线折点、
|
||||
/// 自身折点、图纸中心。
|
||||
Iterable<double> _alignCandidates(
|
||||
ArchConnector? self, {
|
||||
required bool x,
|
||||
}) sync* {
|
||||
for (final ArchShape s in c.arch.shapes) {
|
||||
if (!c.arch.isLayerVisible(s.layerId)) continue;
|
||||
final Rect r = s.rect;
|
||||
yield x ? r.left : r.top;
|
||||
yield x ? r.center.dx : r.center.dy;
|
||||
yield x ? r.right : r.bottom;
|
||||
}
|
||||
for (final ArchConnector o in c.arch.connectors) {
|
||||
if (self != null && o.id == self.id) continue;
|
||||
final ArchConnGeometry g = archConnectorGeometry(c.arch, o);
|
||||
for (final Offset q in g.pts) {
|
||||
yield x ? q.dx : q.dy;
|
||||
}
|
||||
}
|
||||
if (self != null) {
|
||||
for (final Offset m in self.mids) {
|
||||
yield x ? m.dx : m.dy;
|
||||
}
|
||||
}
|
||||
yield x ? kArchPageSize.width / 2 : kArchPageSize.height / 2;
|
||||
}
|
||||
|
||||
/// 鼠标样式:拖拽连线时抓取,手绘精确,悬停连线显示可抓取。
|
||||
MouseCursor _mouseCursor() {
|
||||
if (_connVertexOrigin != null) return SystemMouseCursors.grabbing;
|
||||
if (c.archTool == ArchTool.pen) return SystemMouseCursors.precise;
|
||||
if (c.archTool == ArchTool.select && _hoverConn) {
|
||||
return SystemMouseCursors.grab;
|
||||
}
|
||||
return SystemMouseCursors.basic;
|
||||
}
|
||||
|
||||
// ===================== 参数化草图:交互 =====================
|
||||
|
||||
/// 草图按下:选择 / 拖拽(约束求解)/ 绘制 / 修剪。
|
||||
@@ -948,7 +1140,7 @@ class _ArchViewState extends State<ArchView>
|
||||
if (soleSel != null && !soleSel.isLinear) {
|
||||
final List<Rect> hs = archHandleRects(soleSel.rect, c.arch.zoom);
|
||||
for (int i = 0; i < hs.length; i++) {
|
||||
if (hs[i].inflate(4 / c.arch.zoom).contains(world)) {
|
||||
if (hs[i].inflate((touch ? 12 : 4) / c.arch.zoom).contains(world)) {
|
||||
_resizeHandle = i;
|
||||
_resizeOrigin = soleSel;
|
||||
_resizeRect = soleSel.rect;
|
||||
@@ -964,7 +1156,7 @@ class _ArchViewState extends State<ArchView>
|
||||
soleSel.b != null
|
||||
? <Offset>[soleSel.a!, soleSel.b!]
|
||||
: soleSel.pts;
|
||||
final double tol = 10 / c.arch.zoom;
|
||||
final double tol = (touch ? 20 : 10) / c.arch.zoom;
|
||||
for (int i = 0; i < vs.length; i++) {
|
||||
if ((vs[i] - world).distance <= tol) {
|
||||
_vertexIndex = i;
|
||||
@@ -975,30 +1167,56 @@ class _ArchViewState extends State<ArchView>
|
||||
}
|
||||
}
|
||||
}
|
||||
// 连线折点拖动:所有折点可拖;端点拖到别的图形会重新吸附(松手生效)。
|
||||
// 连线拖拽编辑(选中单条连线时):端点 / 折点 / 线段三种拖动。
|
||||
// 针对平板 / 手指:命中半径加大;路径任意一段可整体平移。
|
||||
final ArchConnector? soleConn = c.archSelIds.length == 1
|
||||
? c.arch.connectorById(c.archSelId)
|
||||
: null;
|
||||
if (soleConn != null) {
|
||||
final ArchConnGeometry g = archConnectorGeometry(c.arch, soleConn);
|
||||
final double tol = 10 / c.arch.zoom;
|
||||
if (soleConn != null &&
|
||||
c.arch.isLayerVisible(soleConn.layerId) &&
|
||||
!c.arch.isLayerLocked(soleConn.layerId)) {
|
||||
final ArchDoc adoc = c.arch;
|
||||
final bool hasA = adoc.shapeById(soleConn.fromId ?? '') != null;
|
||||
final bool hasB = adoc.shapeById(soleConn.toId ?? '') != null;
|
||||
final ArchConnGeometry g = archConnectorGeometry(adoc, soleConn);
|
||||
final int last = g.pts.length - 1;
|
||||
final double vTol = (touch ? 22 : 10) / c.arch.zoom;
|
||||
for (int i = 0; i < g.pts.length; i++) {
|
||||
if ((g.pts[i] - world).distance <= tol) {
|
||||
// 角点编辑:把当前正交路径的全部拐点物化为折点(拖拽自由,
|
||||
// 路径仍按折点走横平竖直的正交台阶)。
|
||||
final List<Offset> cornerList = g.pts.length > 2
|
||||
? g.pts.sublist(1, g.pts.length - 1)
|
||||
: const <Offset>[];
|
||||
_connVertexOrigin = soleConn.copyWith(mids: cornerList);
|
||||
if ((g.pts[i] - world).distance > vTol) continue;
|
||||
if (i == 0 || i == last) {
|
||||
// 端点:拖拽换吸附目标 / 脱离为自由端点(实时预览)。
|
||||
_beginConnDrag(soleConn, 'endpoint');
|
||||
_connVertexIndex = i;
|
||||
_connVertexPts = List<Offset>.of(g.pts);
|
||||
_connDragTargetId = null;
|
||||
setState(() {});
|
||||
return;
|
||||
}
|
||||
// 吸附端的固定短桩不单独拖动,交给线段拖动。
|
||||
if ((hasA && i == 1) || (hasB && i == last - 1)) break;
|
||||
// 折点:把路径拐点物化为折点后自由拖动(跳过两端固定短桩)。
|
||||
final List<Offset> mids = <Offset>[];
|
||||
int midIndex = 0;
|
||||
for (int j = 1; j < last; j++) {
|
||||
if (hasA && j == 1) continue;
|
||||
if (hasB && j == last - 1) continue;
|
||||
if (j < i) midIndex++;
|
||||
mids.add(g.pts[j]);
|
||||
}
|
||||
_beginConnDrag(soleConn.copyWith(mids: mids), 'corner');
|
||||
_connMidIndex = midIndex;
|
||||
return;
|
||||
}
|
||||
// 线段拖动:命中路径任意一段 → 整体平移该段(磁力吸附 + 导引虚线)。
|
||||
final double sTol = (touch ? 20 : 9) / c.arch.zoom;
|
||||
for (int k = 0; k < last; k++) {
|
||||
if (archDistToSegment(world, g.pts[k], g.pts[k + 1]) <= sTol) {
|
||||
_beginConnSegmentDrag(soleConn, g, world, k, hasA, hasB);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final (String?, ArchShape?) hit = _hitTest(world);
|
||||
final (String?, ArchShape?) hit = _hitTest(
|
||||
world,
|
||||
connTol: touch ? 20 / c.arch.zoom : 0,
|
||||
);
|
||||
final String? id = hit.$1;
|
||||
final ArchShape? shape = hit.$2;
|
||||
if (id != null) {
|
||||
@@ -1124,26 +1342,69 @@ class _ArchViewState extends State<ArchView>
|
||||
return;
|
||||
}
|
||||
if (_connVertexOrigin != null) {
|
||||
final int last = _connVertexPts.length - 1;
|
||||
final bool isEndpoint =
|
||||
_connVertexIndex == 0 || _connVertexIndex == last;
|
||||
Offset p = world;
|
||||
if (isEndpoint) {
|
||||
// 端点:优先吸附到鼠标下的图形边框(可换目标重新吸附),无则脱离。
|
||||
final ArchShape? target = _shapeAt(world);
|
||||
final ArchConnector origin = _connVertexOrigin!;
|
||||
final String mode = _connDragMode ?? 'corner';
|
||||
if (mode == 'segment') {
|
||||
// 线段拖动:沿垂直方向整体平移(磁力吸附 + 导引虚线)。
|
||||
final bool axisX = _connSegAxis == 'x';
|
||||
final ConnSnap snap = _snapConnCoord(
|
||||
world,
|
||||
origin,
|
||||
onlyX: axisX,
|
||||
onlyY: !axisX,
|
||||
);
|
||||
_guideXs = snap.gx == null ? const <double>[] : <double>[snap.gx!];
|
||||
_guideYs = snap.gy == null ? const <double>[] : <double>[snap.gy!];
|
||||
final double v = axisX ? snap.x : snap.y;
|
||||
final double seed = _connSegSeed ?? v;
|
||||
final List<Offset> mids = <Offset>[
|
||||
for (final Offset m in origin.mids)
|
||||
((axisX ? m.dx : m.dy) - seed).abs() < 0.75
|
||||
? (axisX ? Offset(v, m.dy) : Offset(m.dx, v))
|
||||
: m,
|
||||
];
|
||||
_connVertexUpdated = origin.copyWith(mids: mids);
|
||||
setState(() {});
|
||||
return;
|
||||
}
|
||||
if (mode == 'endpoint') {
|
||||
// 端点:实时预览吸附(可换目标 / 脱离);空白处磁力吸附 + 网格回退。
|
||||
final ArchShape? target = _shapeAt(
|
||||
world,
|
||||
pad: math.max(6, 10 / c.arch.zoom),
|
||||
);
|
||||
final bool isFrom = _connVertexIndex == 0;
|
||||
Offset p;
|
||||
String? targetId;
|
||||
ConnSnap? snap;
|
||||
if (target != null) {
|
||||
p = archNearestBorderPoint(target, world);
|
||||
_connDragTargetId = target.id;
|
||||
targetId = target.id;
|
||||
} else {
|
||||
_connDragTargetId = null;
|
||||
if (c.arch.gridSnap) p = archSnapPoint(c.arch, world);
|
||||
snap = _snapConnCoord(world, origin);
|
||||
p = Offset(snap.x, snap.y);
|
||||
targetId = null;
|
||||
}
|
||||
} else if (c.arch.gridSnap) {
|
||||
p = archSnapPoint(c.arch, world);
|
||||
_connDragTargetId = targetId;
|
||||
_guideXs =
|
||||
snap?.gx == null ? const <double>[] : <double>[snap!.gx!];
|
||||
_guideYs =
|
||||
snap?.gy == null ? const <double>[] : <double>[snap!.gy!];
|
||||
_connVertexUpdated = isFrom
|
||||
? origin.copyWith(fromId: targetId, from: p)
|
||||
: origin.copyWith(toId: targetId, to: p);
|
||||
setState(() {});
|
||||
return;
|
||||
}
|
||||
_connVertexPts[_connVertexIndex] = p;
|
||||
_connVertexUpdated =
|
||||
_applyConnVertices(_connVertexOrigin!, _connVertexIndex, _connVertexPts);
|
||||
// 折点:磁力吸附(对齐虚线)+ 网格回退。
|
||||
final ConnSnap snap = _snapConnCoord(world, origin);
|
||||
_guideXs = snap.gx == null ? const <double>[] : <double>[snap.gx!];
|
||||
_guideYs = snap.gy == null ? const <double>[] : <double>[snap.gy!];
|
||||
final List<Offset> mids = List<Offset>.of(origin.mids);
|
||||
if (_connMidIndex >= 0 && _connMidIndex < mids.length) {
|
||||
mids[_connMidIndex] = Offset(snap.x, snap.y);
|
||||
}
|
||||
_connVertexUpdated = origin.copyWith(mids: mids);
|
||||
setState(() {});
|
||||
return;
|
||||
}
|
||||
@@ -1276,25 +1537,21 @@ class _ArchViewState extends State<ArchView>
|
||||
return;
|
||||
}
|
||||
if (_connVertexOrigin != null) {
|
||||
final int index = _connVertexIndex;
|
||||
final int last = _connVertexPts.length - 1;
|
||||
final bool isEndpoint = index == 0 || index == last;
|
||||
ArchConnector? done = _connVertexUpdated;
|
||||
final ArchConnector? done = _connVertexUpdated;
|
||||
final String mode = _connDragMode ?? 'corner';
|
||||
final String? targetId = _connDragTargetId;
|
||||
_connVertexOrigin = null;
|
||||
_connVertexPts = <Offset>[];
|
||||
_connVertexUpdated = null;
|
||||
_connDragMode = null;
|
||||
_connDragTargetId = null;
|
||||
if (done != null && isEndpoint) {
|
||||
// 端点松手:吸附到新图形(更新归属);空白处则脱离为自由端点。
|
||||
done = index == 0
|
||||
? done.copyWith(fromId: targetId)
|
||||
: done.copyWith(toId: targetId);
|
||||
}
|
||||
_connSegAxis = null;
|
||||
_connSegSeed = null;
|
||||
_guideXs = const <double>[];
|
||||
_guideYs = const <double>[];
|
||||
if (done != null) {
|
||||
final String st = !isEndpoint
|
||||
? '编辑连线折点'
|
||||
: (targetId == null ? '连线端点:已脱离(自由端点)' : '连线端点:已吸附到图形');
|
||||
final String st = mode == 'endpoint'
|
||||
? (targetId == null ? '连线端点:已脱离(自由端点)' : '连线端点:已吸附到图形')
|
||||
: (mode == 'segment' ? '拖动连线路径' : '编辑连线折点');
|
||||
c.updateArchConnector(done, status: st);
|
||||
}
|
||||
setState(() {});
|
||||
@@ -1419,8 +1676,11 @@ class _ArchViewState extends State<ArchView>
|
||||
_draft = null;
|
||||
_connFromId = null;
|
||||
_connVertexOrigin = null;
|
||||
_connVertexPts = <Offset>[];
|
||||
_connVertexUpdated = null;
|
||||
_connDragMode = null;
|
||||
_connDragTargetId = null;
|
||||
_connSegAxis = null;
|
||||
_connSegSeed = null;
|
||||
_moveIds = <String>[];
|
||||
_moveDeltas = null;
|
||||
_guideXs = const <double>[];
|
||||
@@ -1521,27 +1781,6 @@ class _ArchViewState extends State<ArchView>
|
||||
));
|
||||
}
|
||||
|
||||
/// 把折点拖拽结果写回连线(中间折点 / 自由端点)。
|
||||
ArchConnector _applyConnVertices(
|
||||
ArchConnector origin,
|
||||
int index,
|
||||
List<Offset> pts,
|
||||
) {
|
||||
final int last = pts.length - 1;
|
||||
final List<Offset> mids = List<Offset>.of(origin.mids);
|
||||
Offset from = origin.from;
|
||||
Offset to = origin.to;
|
||||
if (index == 0) {
|
||||
from = pts.first;
|
||||
} else if (index == last) {
|
||||
to = pts.last;
|
||||
} else {
|
||||
final int mi = index - 1;
|
||||
if (mi >= 0 && mi < mids.length) mids[mi] = pts[index];
|
||||
}
|
||||
return origin.copyWith(from: from, to: to, mids: mids);
|
||||
}
|
||||
|
||||
/// 按目标外接框生成图元图形(保持图元自然纵横比)。
|
||||
ArchShape _symbolShapeFor(LibSymbol sym, Rect b) {
|
||||
final Rect nat = symbolNaturalBounds(sym);
|
||||
@@ -1867,14 +2106,20 @@ class _ArchViewState extends State<ArchView>
|
||||
autofocus: true,
|
||||
onKeyEvent: _onKey,
|
||||
child: MouseRegion(
|
||||
cursor: c.archTool == ArchTool.pen
|
||||
? SystemMouseCursors.precise
|
||||
: SystemMouseCursors.basic,
|
||||
cursor: _mouseCursor(),
|
||||
onHover: (PointerHoverEvent e) {
|
||||
final Offset w = _toWorld(e.localPosition);
|
||||
final bool hover = c.archTool == ArchTool.select &&
|
||||
_connVertexOrigin == null &&
|
||||
_connAt(w, 10 / c.arch.zoom) != null;
|
||||
final Offset? cur = _cursorWorld;
|
||||
if (cur == null || (cur - w).distance > 0.4) {
|
||||
setState(() => _cursorWorld = w);
|
||||
if (hover != _hoverConn ||
|
||||
cur == null ||
|
||||
(cur - w).distance > 0.4) {
|
||||
setState(() {
|
||||
_cursorWorld = w;
|
||||
_hoverConn = hover;
|
||||
});
|
||||
}
|
||||
},
|
||||
onExit: (_) {
|
||||
|
||||
Reference in New Issue
Block a user