v1.3.11: 全局更名为 EDC|易得; 更新下载屏幕常亮+防误触退出; 连线法向箭头+多线避让+平板拖动优化(线段拖动/磁吸虚线/抓取光标/实时预览)
This commit is contained in:
@@ -40,7 +40,7 @@ Future<Uint8List> renderArchPng({
|
||||
// 标题与副标题(固定左上角)。
|
||||
_text(canvas, '架构图设计', const Offset(48, 36),
|
||||
color: et.text, size: 34, weight: FontWeight.w700);
|
||||
_text(canvas, 'EDC|易得设计 · Easy Design Collection · 手绘识别架构图', const Offset(48, 88),
|
||||
_text(canvas, 'EDC|易得 · Easy Design Collection · 手绘识别架构图', const Offset(48, 88),
|
||||
color: et.sub, size: 16, weight: FontWeight.w400);
|
||||
|
||||
// 内容适配(白底令牌 + 关闭网格点阵)。
|
||||
@@ -56,7 +56,7 @@ Future<Uint8List> renderArchPng({
|
||||
|
||||
_text(
|
||||
canvas,
|
||||
'EDC|易得设计 · 架构图设计 · $projectName · 元件 ${doc.shapes.length} · 连线 '
|
||||
'EDC|易得 · 架构图设计 · $projectName · 元件 ${doc.shapes.length} · 连线 '
|
||||
'${doc.connectors.length} · 墨迹 ${doc.strokes.length}',
|
||||
Offset(48, h - 38),
|
||||
color: et.sub,
|
||||
|
||||
+192
-51
@@ -483,9 +483,12 @@ Offset archNearestBorderPoint(ArchShape s, Offset p) {
|
||||
|
||||
/// 计算连线几何:**一律正交走线**(横平竖直,无斜线)。
|
||||
///
|
||||
/// - 有折点([ArchConnector.mids],手绘轨迹 / 拖拽过的角点)时:按折点走正交台阶;
|
||||
/// - 无折点时:按两图形中心主方向自动生成单拐角正交折线(带圆角);
|
||||
/// - 端点吸附图形时从相应方向边框射出。
|
||||
/// - 端点吸附图形时:贴边点取「保存的画线侧」边框点(多条连线贴在同一条边
|
||||
/// 时自动分配槽位错开);出入两端沿该边**法向**短桩——箭头始终垂直射入
|
||||
/// 图元边,不会贴着边乱指;
|
||||
/// - 有折点([ArchConnector.mids],手绘轨迹 / 拖拽过的角点)时:按折点走
|
||||
/// 正交台阶,两端同样保证法向出入;
|
||||
/// - 无折点时:自动生成带法向短桩的正交走线(转弯走台阶)。
|
||||
ArchConnGeometry archConnectorGeometry(
|
||||
ArchDoc doc,
|
||||
ArchConnector c, {
|
||||
@@ -501,34 +504,48 @@ ArchConnGeometry archConnectorGeometry(
|
||||
final ArchShape? st = resolve(c.toId);
|
||||
final Offset cFrom = sf?.rect.center ?? c.from;
|
||||
final Offset cTo = st?.rect.center ?? c.to;
|
||||
final (Offset a, Offset b) =
|
||||
_orthoEnds(sf, st, cFrom, cTo, c.from, c.to);
|
||||
final (Offset a, Offset b) = _orthoEnds(doc, c, sf, st, cFrom, cTo);
|
||||
|
||||
// 有折点:以折点顺序走正交台阶(角点即折点,可直接拖拽编辑)。
|
||||
// 端点法向(自由端点无方向约束)。
|
||||
final Offset na =
|
||||
sf == null ? Offset.zero : _connNormal(_connSideOfPoint(sf, a));
|
||||
final Offset nb =
|
||||
st == null ? Offset.zero : _connNormal(_connSideOfPoint(st, b));
|
||||
|
||||
/// 法向短桩长度(世界单位):保证箭头垂直入边、出口垂直离边。
|
||||
const double stub = 14;
|
||||
final List<Offset> raw = <Offset>[a];
|
||||
if (c.mids.isNotEmpty) {
|
||||
final List<Offset> raw = orthoPolyline(<Offset>[a, ...c.mids, b]);
|
||||
final List<Offset> clean = <Offset>[];
|
||||
for (final Offset p in raw) {
|
||||
if (clean.isEmpty || (p - clean.last).distance > 0.5) clean.add(p);
|
||||
}
|
||||
if (clean.length >= 2) {
|
||||
return ArchConnGeometry(
|
||||
clean,
|
||||
_roundedOrthoPath(clean, 8),
|
||||
_labelPoint(clean),
|
||||
);
|
||||
if (sf != null) raw.add(a + na * stub);
|
||||
raw.addAll(c.mids);
|
||||
if (st != null) raw.add(b + nb * stub);
|
||||
raw.add(b);
|
||||
} else {
|
||||
final Offset? sA = sf == null ? null : a + na * stub;
|
||||
final Offset? sB = st == null ? null : b + nb * stub;
|
||||
if (sA != null) raw.add(sA);
|
||||
final Offset p = sA ?? a;
|
||||
final Offset q = sB ?? b;
|
||||
if (sf != null || st != null) {
|
||||
// 中段:先沿吸附端的主轴走,再拐到另一端(台阶转弯)。
|
||||
final Offset main = sf != null ? na : nb;
|
||||
if (main.dx != 0) {
|
||||
if ((p.dy - q.dy).abs() > 0.5) raw.add(Offset(q.dx, p.dy));
|
||||
} else if ((p.dx - q.dx).abs() > 0.5) {
|
||||
raw.add(Offset(p.dx, q.dy));
|
||||
}
|
||||
} else if ((p.dx - q.dx).abs() >= (p.dy - q.dy).abs()) {
|
||||
// 双自由端点:单拐角(先横后竖 / 先竖后横按主方向)。
|
||||
raw.add(Offset(q.dx, p.dy));
|
||||
} else {
|
||||
raw.add(Offset(p.dx, q.dy));
|
||||
}
|
||||
if (sB != null) raw.add(sB);
|
||||
raw.add(b);
|
||||
}
|
||||
|
||||
// 无折点:自动单拐角(先横后竖 / 先竖后横按两端射出点的主方向决定,
|
||||
// 端点位置稳定,不随中心方向抖动)。
|
||||
final bool horizontalFirst =
|
||||
(b.dx - a.dx).abs() >= (b.dy - a.dy).abs();
|
||||
final List<Offset> pts = horizontalFirst
|
||||
? <Offset>[a, Offset(b.dx, a.dy), b]
|
||||
: <Offset>[a, Offset(a.dx, b.dy), b];
|
||||
final List<Offset> clean = <Offset>[];
|
||||
for (final Offset p in pts) {
|
||||
for (final Offset p in orthoPolyline(raw)) {
|
||||
if (clean.isEmpty || (p - clean.last).distance > 0.5) clean.add(p);
|
||||
}
|
||||
return ArchConnGeometry(
|
||||
@@ -538,46 +555,170 @@ ArchConnGeometry archConnectorGeometry(
|
||||
);
|
||||
}
|
||||
|
||||
/// 正交走线的两端射出点。
|
||||
/// 连线端点在图元边框上的贴边(正交走线的出入方向)。
|
||||
enum _ConnSide {
|
||||
/// 上边(法向朝上)。
|
||||
top,
|
||||
|
||||
/// 下边(法向朝下)。
|
||||
bottom,
|
||||
|
||||
/// 左边(法向朝左)。
|
||||
left,
|
||||
|
||||
/// 右边(法向朝右)。
|
||||
right,
|
||||
}
|
||||
|
||||
/// 边框点 [p] 所在边(矩形类按最近边判定;椭圆 / 圆按径向主方向判定)。
|
||||
_ConnSide _connSideOfPoint(ArchShape s, Offset p) {
|
||||
final Rect r = s.rect;
|
||||
if (s.type == ArchShapeType.ellipse || s.type == ArchShapeType.circle) {
|
||||
final Offset d = p - r.center;
|
||||
if (d.dx.abs() >= d.dy.abs()) {
|
||||
return d.dx >= 0 ? _ConnSide.right : _ConnSide.left;
|
||||
}
|
||||
return d.dy >= 0 ? _ConnSide.bottom : _ConnSide.top;
|
||||
}
|
||||
final double dl = (p.dx - r.left).abs();
|
||||
final double dr = (r.right - p.dx).abs();
|
||||
final double dt = (p.dy - r.top).abs();
|
||||
final double db = (r.bottom - p.dy).abs();
|
||||
final double m = math.min(math.min(dl, dr), math.min(dt, db));
|
||||
if (m == dl) return _ConnSide.left;
|
||||
if (m == dr) return _ConnSide.right;
|
||||
if (m == dt) return _ConnSide.top;
|
||||
return _ConnSide.bottom;
|
||||
}
|
||||
|
||||
/// 边的外侧法向(单位向量,正交轴对齐)。
|
||||
Offset _connNormal(_ConnSide s) {
|
||||
switch (s) {
|
||||
case _ConnSide.top:
|
||||
return const Offset(0, -1);
|
||||
case _ConnSide.bottom:
|
||||
return const Offset(0, 1);
|
||||
case _ConnSide.left:
|
||||
return const Offset(-1, 0);
|
||||
case _ConnSide.right:
|
||||
return const Offset(1, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// 用户保存的贴边点:优先取「离保存点最近的边框点」(画线 / 拖拽的一侧,
|
||||
/// 稳定不随中心方向乱跳);保存点接近中心(程序化创建)时按朝向对方中心的
|
||||
/// 主轴方向自动取向。
|
||||
Offset _naturalAttach(ArchShape s, Offset free, Offset otherCenter) {
|
||||
if ((free - s.rect.center).distance < 4) {
|
||||
final Offset d = otherCenter - s.rect.center;
|
||||
final Offset dir = d.dx.abs() >= d.dy.abs()
|
||||
? Offset(d.dx >= 0 ? 1 : -1, 0)
|
||||
: Offset(0, d.dy >= 0 ? 1 : -1);
|
||||
return archBorderPoint(s, s.rect.center + dir * 1e5);
|
||||
}
|
||||
return archNearestBorderPoint(s, free);
|
||||
}
|
||||
|
||||
/// 贴边点(含**同边多条连线的自动槽位避让**)。
|
||||
///
|
||||
/// 同一条边上的多条连线按自然到达顺序均匀错开,避免起点 / 箭头重叠;
|
||||
/// 椭圆 / 圆收敛到 4 个正交点(保证法向进出)。
|
||||
Offset _attachWithSlots(
|
||||
ArchDoc doc,
|
||||
ArchConnector c,
|
||||
ArchShape s,
|
||||
Offset natural, {
|
||||
required bool isFrom,
|
||||
}) {
|
||||
final _ConnSide side = _connSideOfPoint(s, natural);
|
||||
final Rect r = s.rect;
|
||||
if (s.type == ArchShapeType.ellipse || s.type == ArchShapeType.circle) {
|
||||
switch (side) {
|
||||
case _ConnSide.top:
|
||||
return Offset(r.center.dx, r.top);
|
||||
case _ConnSide.bottom:
|
||||
return Offset(r.center.dx, r.bottom);
|
||||
case _ConnSide.left:
|
||||
return Offset(r.left, r.center.dy);
|
||||
case _ConnSide.right:
|
||||
return Offset(r.right, r.center.dy);
|
||||
}
|
||||
}
|
||||
final bool onHorizontalEdge =
|
||||
side == _ConnSide.top || side == _ConnSide.bottom;
|
||||
// 收集该图元该边上的全部连线端点(含本连线的两端),按自然位置排序。
|
||||
final List<({double key, String order})> mates =
|
||||
<({double key, String order})>[];
|
||||
void considerEndpoint(String? shapeId, Offset free, String? otherId,
|
||||
Offset otherFree, String order) {
|
||||
if (shapeId != s.id) return;
|
||||
final Offset other = doc.shapeById(otherId ?? '')?.rect.center ?? otherFree;
|
||||
final Offset nat = _naturalAttach(s, free, other);
|
||||
if (_connSideOfPoint(s, nat) != side) return;
|
||||
mates.add((
|
||||
key: onHorizontalEdge ? other.dx : other.dy,
|
||||
order: order,
|
||||
));
|
||||
}
|
||||
|
||||
for (final ArchConnector o in doc.connectors) {
|
||||
considerEndpoint(o.fromId, o.from, o.toId, o.to, '${o.id}#f');
|
||||
considerEndpoint(o.toId, o.to, o.fromId, o.from, '${o.id}#t');
|
||||
}
|
||||
if (mates.length <= 1) return natural;
|
||||
mates.sort((a, b) {
|
||||
final int k = a.key.compareTo(b.key);
|
||||
return k != 0 ? k : a.order.compareTo(b.order);
|
||||
});
|
||||
final String selfOrder = '${c.id}#${isFrom ? 'f' : 't'}';
|
||||
final int index = mates.indexWhere((m) => m.order == selfOrder);
|
||||
if (index < 0) return natural;
|
||||
final double lo = onHorizontalEdge ? r.left : r.top;
|
||||
final double hi = onHorizontalEdge ? r.right : r.bottom;
|
||||
final double len = hi - lo;
|
||||
double pad = math.min(24, len * 0.18);
|
||||
if (len - 2 * pad < 24) pad = math.max(0, len * 0.1);
|
||||
final double usable = math.max(1, len - 2 * pad);
|
||||
final double pos = lo + pad + (index + 0.5) * usable / mates.length;
|
||||
if (onHorizontalEdge) {
|
||||
return Offset(pos, side == _ConnSide.top ? r.top : r.bottom);
|
||||
}
|
||||
return Offset(side == _ConnSide.left ? r.left : r.right, pos);
|
||||
}
|
||||
|
||||
/// 正交走线的两端贴边点。
|
||||
///
|
||||
/// 稳定优先:端点**朝「保存的端点位置」(用户画线 / 拖拽的一侧)**在边框取点——
|
||||
/// 不会随两图形中心方向的微小变化而左右乱跳;仅当保存端点接近中心
|
||||
/// (程序化创建等)时,退回「朝向对方中心象限」的自动取向。
|
||||
/// (程序化创建等)时,退回「朝向对方中心」的自动取向。
|
||||
/// 多连线贴在同一条边时自动分配槽位(智能避让);椭圆 / 圆取正交点。
|
||||
(Offset, Offset) _orthoEnds(
|
||||
ArchDoc doc,
|
||||
ArchConnector c,
|
||||
ArchShape? sf,
|
||||
ArchShape? st,
|
||||
Offset cFrom,
|
||||
Offset cTo,
|
||||
Offset freeFrom,
|
||||
Offset freeTo,
|
||||
) {
|
||||
Offset a;
|
||||
if (sf == null) {
|
||||
a = freeFrom;
|
||||
} else if ((freeFrom - sf.rect.center).distance < 4) {
|
||||
a = archBorderPoint(
|
||||
Offset a = c.from;
|
||||
if (sf != null) {
|
||||
a = _attachWithSlots(
|
||||
doc,
|
||||
c,
|
||||
sf,
|
||||
Offset(
|
||||
cTo.dx >= cFrom.dx ? sf.rect.right + 1e5 : sf.rect.left - 1e5,
|
||||
cTo.dy >= cFrom.dy ? sf.rect.bottom + 1e5 : sf.rect.top - 1e5,
|
||||
),
|
||||
_naturalAttach(sf, c.from, cTo),
|
||||
isFrom: true,
|
||||
);
|
||||
} else {
|
||||
a = archNearestBorderPoint(sf, freeFrom);
|
||||
}
|
||||
Offset b;
|
||||
if (st == null) {
|
||||
b = freeTo;
|
||||
} else if ((freeTo - st.rect.center).distance < 4) {
|
||||
b = archBorderPoint(
|
||||
Offset b = c.to;
|
||||
if (st != null) {
|
||||
b = _attachWithSlots(
|
||||
doc,
|
||||
c,
|
||||
st,
|
||||
Offset(
|
||||
cFrom.dx >= cTo.dx ? st.rect.right + 1e5 : st.rect.left - 1e5,
|
||||
cFrom.dy >= cTo.dy ? st.rect.bottom + 1e5 : st.rect.top - 1e5,
|
||||
),
|
||||
_naturalAttach(st, c.to, cFrom),
|
||||
isFrom: false,
|
||||
);
|
||||
} else {
|
||||
b = archNearestBorderPoint(st, freeTo);
|
||||
}
|
||||
return (a, b);
|
||||
}
|
||||
|
||||
@@ -430,9 +430,11 @@ class ArchPainter extends CustomPainter {
|
||||
..color = t.line2,
|
||||
);
|
||||
// 连线在底层(图形遮住线头,视觉更干净;隐藏图层不绘制)。
|
||||
// 拖拽编辑中的连线用预览对象绘制(实时反馈)。
|
||||
for (final ArchConnector c in doc.connectors) {
|
||||
if (!doc.isLayerVisible(c.layerId)) continue;
|
||||
_connector(canvas, c);
|
||||
final ArchConnector? pc = previewConnector;
|
||||
_connector(canvas, pc != null && pc.id == c.id ? pc : c);
|
||||
}
|
||||
for (final ArchShape s in doc.shapes) {
|
||||
if (!doc.isLayerVisible(s.layerId)) continue;
|
||||
@@ -1204,7 +1206,11 @@ class ArchPainter extends CustomPainter {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
final ArchConnector? c = doc.connectorById(id);
|
||||
final ArchConnector? base = doc.connectorById(id);
|
||||
final ArchConnector? pc = previewConnector;
|
||||
final ArchConnector? c = (base != null && pc != null && pc.id == base.id)
|
||||
? pc
|
||||
: base;
|
||||
if (c != null) {
|
||||
if (!doc.isLayerVisible(c.layerId)) continue;
|
||||
final ArchConnGeometry g =
|
||||
|
||||
+2
-2
@@ -94,7 +94,7 @@ class _SequenceDiagramAppState extends State<SequenceDiagramApp> {
|
||||
// 标题走模块注册表(首页显示品牌名,不带文件名)。
|
||||
if (_controller.appMode == AppMode.home) {
|
||||
_windowChannel
|
||||
.invokeMethod<void>('setTitle', 'EDC|易得设计')
|
||||
.invokeMethod<void>('setTitle', 'EDC|易得')
|
||||
.catchError((Object _) {});
|
||||
return;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ class _SequenceDiagramAppState extends State<SequenceDiagramApp> {
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
final Tokens tokens = Tokens.of(_controller.brightness);
|
||||
return MaterialApp(
|
||||
title: 'EDC|易得设计 · Easy Design Collection',
|
||||
title: 'EDC|易得 · Easy Design Collection',
|
||||
debugShowCheckedModeBanner: false,
|
||||
theme: buildTheme(tokens),
|
||||
// 固定文本缩放;系统栏图标随主题亮度自动切换(透明系统栏,
|
||||
|
||||
@@ -145,5 +145,5 @@ EdcModule? moduleOf(AppMode m) {
|
||||
/// AppMode → 窗口标题用模块名(首页用品牌名)。
|
||||
String appModeLabel(AppMode m) {
|
||||
final EdcModule? mod = moduleOf(m);
|
||||
return mod == null ? 'EDC|易得设计' : 'EDC|易得设计 · ${mod.name}设计';
|
||||
return mod == null ? 'EDC|易得' : 'EDC|易得 · ${mod.name}设计';
|
||||
}
|
||||
|
||||
@@ -929,6 +929,8 @@ class _AppShellState extends State<AppShell> {
|
||||
if (!mounted) return;
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
// 点对话框外灰色区域不关闭(下载中防误触退出)。
|
||||
barrierDismissible: false,
|
||||
builder: (_) => UpdateDialog(controller: c, info: info!),
|
||||
);
|
||||
}
|
||||
|
||||
+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: (_) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// 左上角品牌按钮 +「EDC|易得设计」设计合集菜单。
|
||||
/// 左上角品牌按钮 +「EDC|易得」设计合集菜单。
|
||||
///
|
||||
/// 点开左上角 logo:菜单从 logo **下方**下拉展开(不遮挡 logo)。
|
||||
/// 菜单由模块注册表驱动:首页入口 + 已开放模块(可进入/新建)+
|
||||
@@ -56,7 +56,7 @@ class BrandMenuButton extends StatelessWidget {
|
||||
final Tokens t = context.tok;
|
||||
final BorderRadius radius = BorderRadius.circular(10);
|
||||
return Tooltip(
|
||||
message: 'EDC|易得设计:设计合集',
|
||||
message: 'EDC|易得:设计合集',
|
||||
child: Material(
|
||||
color: t.panel,
|
||||
borderRadius: radius,
|
||||
@@ -238,7 +238,7 @@ class BrandMenuButton extends StatelessWidget {
|
||||
padding: const EdgeInsets.fromLTRB(12, 6, 12, 8),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text('EDC|易得设计',
|
||||
Text('EDC|易得',
|
||||
style: TextStyle(
|
||||
color: t.text,
|
||||
fontSize: 12.5,
|
||||
|
||||
+5
-3
@@ -2049,7 +2049,7 @@ class _StationRowState extends State<_StationRow> {
|
||||
/// 双视图说明以及单位与导出等信息。
|
||||
/// 软件设置:集中设置入口(外观 / 文档默认 / 架构图网格 / 更新)。
|
||||
///
|
||||
/// 从左上角「EDC|易得设计」菜单底部的「软件设置」打开;文档级的完整设置
|
||||
/// 从左上角「EDC|易得」菜单底部的「软件设置」打开;文档级的完整设置
|
||||
/// (单位 / 循环 / 相位等)仍在「文档设置」(F2 / 左侧栏)里。
|
||||
class SoftwareSettingsDialog extends StatefulWidget {
|
||||
/// 构造软件设置对话框。
|
||||
@@ -2081,6 +2081,8 @@ class _SoftwareSettingsDialogState extends State<SoftwareSettingsDialog> {
|
||||
}
|
||||
await showDialog<void>(
|
||||
context: context,
|
||||
// 点对话框外灰色区域不关闭(下载中防误触退出)。
|
||||
barrierDismissible: false,
|
||||
builder: (_) => UpdateDialog(controller: c, info: info),
|
||||
);
|
||||
} catch (e) {
|
||||
@@ -2650,7 +2652,7 @@ class _HelpDialogState extends State<HelpDialog> {
|
||||
]),
|
||||
// 目标:架构图编辑操作与导出。
|
||||
_section(t, <List<String>>[
|
||||
<String>['连线规则', '连线一律正交(横平竖直),不会出现斜线;端点自动吸附图形边框,选中后拖拽路径上的角点可调整走线位置;端点也可拖到别的图形重新吸附或脱离。'],
|
||||
<String>['连线规则', '连线一律正交(横平竖直):两端垂直出入图元边框(箭头不会乱指),同一图元多条连线自动错开;选中后可拖端点换吸附、拖折点或线段平移走线(平板已加大命中范围),拖动时有磁力对齐与虚线导引;鼠标悬停连线显示抓取光标。'],
|
||||
<String>['对齐 / 均布', '框选或 Ctrl 多选后,右栏出现 8 个对齐按钮:左 / 横向居中 / 右、顶 / 纵向居中 / 底、横向均布、纵向均布(以选中范围为参照,均布需 ≥3 个)。'],
|
||||
<String>['层级 / 复制 / 删除', '选中后右栏可「上移一层 / 下移一层」;拖拽移动、白色手柄缩放;Delete 删除选中;Ctrl+A 全选。'],
|
||||
<String>['我要导出 DXF', '顶部「导出」→「导出 DXF」:AutoCAD R12 格式(图层 / 图形 / 连线 / 文字),可直接在 AutoCAD / DraftSight / ZWCAD 打开继续编辑。'],
|
||||
@@ -2741,7 +2743,7 @@ class _HelpDialogState extends State<HelpDialog> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text('EDC|易得设计 · Easy Design Collection',
|
||||
Text('EDC|易得 · Easy Design Collection',
|
||||
style: TextStyle(color: t.text, fontSize: 15, fontWeight: FontWeight.w700)),
|
||||
const SizedBox(height: 4),
|
||||
Text('V$kAppVersion(${android ? '安卓版' : 'Windows 版'})',
|
||||
|
||||
@@ -195,7 +195,7 @@ class _HomeViewState extends State<HomeView> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text(
|
||||
'EDC|易得设计',
|
||||
'EDC|易得',
|
||||
style: TextStyle(
|
||||
color: t.text,
|
||||
fontSize: 24,
|
||||
|
||||
@@ -14,6 +14,7 @@ import 'package:flutter/services.dart';
|
||||
|
||||
import '../state/app_controller.dart';
|
||||
import '../theme/tokens.dart';
|
||||
import '../update/keep_awake.dart';
|
||||
import '../update/update_service.dart';
|
||||
import '../version.dart';
|
||||
import 'dialogs.dart';
|
||||
@@ -57,6 +58,8 @@ class _UpdateDialogState extends State<UpdateDialog> {
|
||||
_received = 0;
|
||||
_status = '正在下载更新包…';
|
||||
});
|
||||
// 下载期间保持屏幕常亮:避免锁屏中断下载(Android / Windows)。
|
||||
await KeepAwake.enable();
|
||||
try {
|
||||
if (Platform.isAndroid) {
|
||||
await _updateAndroid();
|
||||
@@ -73,6 +76,8 @@ class _UpdateDialogState extends State<UpdateDialog> {
|
||||
});
|
||||
}
|
||||
return;
|
||||
} finally {
|
||||
await KeepAwake.disable();
|
||||
}
|
||||
if (mounted) setState(() => _busy = false);
|
||||
}
|
||||
@@ -159,6 +164,7 @@ class _UpdateDialogState extends State<UpdateDialog> {
|
||||
});
|
||||
}
|
||||
await Future<void>.delayed(const Duration(milliseconds: 900));
|
||||
await KeepAwake.forceOff();
|
||||
exit(0);
|
||||
}
|
||||
|
||||
@@ -176,6 +182,13 @@ class _UpdateDialogState extends State<UpdateDialog> {
|
||||
_cancelled = true;
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
// 兜底:对话框销毁后不再强制常亮。
|
||||
KeepAwake.forceOff();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Tokens t = context.tok;
|
||||
@@ -183,10 +196,14 @@ class _UpdateDialogState extends State<UpdateDialog> {
|
||||
final String sizeText = info.assetSize > 0
|
||||
? '${(info.assetSize / 1048576).toStringAsFixed(1)} MB'
|
||||
: '';
|
||||
return Dialog(
|
||||
backgroundColor: t.dialog,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
||||
child: scaledDialogBox(
|
||||
return PopScope(
|
||||
// 下载中禁止返回键退出;未下载时可返回键关闭。
|
||||
// 点击对话框外的灰色区域始终无响应(barrierDismissible: false)。
|
||||
canPop: !_busy,
|
||||
child: Dialog(
|
||||
backgroundColor: t.dialog,
|
||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
||||
child: scaledDialogBox(
|
||||
context,
|
||||
620,
|
||||
560,
|
||||
@@ -300,7 +317,8 @@ class _UpdateDialogState extends State<UpdateDialog> {
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'下载更新过程中,请确保屏幕保持长亮、网络持续连接,避免更新包下载中断。',
|
||||
'更新过程中软件会自动保持屏幕常亮;请保持界面打开、网络连接稳定,'
|
||||
'不要退出软件,避免更新包下载中断。',
|
||||
style: TextStyle(color: t.warn, fontSize: 11.5, height: 1.5),
|
||||
),
|
||||
),
|
||||
@@ -343,6 +361,7 @@ class _UpdateDialogState extends State<UpdateDialog> {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/// 应用内更新下载期间的「屏幕常亮」开关。
|
||||
///
|
||||
/// - Android:走原生通道 `seqstudio/docs` 的 `keepScreenOn`(窗口 flag);
|
||||
/// - Windows:`SetThreadExecutionState`(FFI,禁止系统休眠与关屏);
|
||||
/// - 其它平台:空操作。任何失败都不影响更新流程(静默)。
|
||||
library;
|
||||
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// 屏幕常亮(引用计数:enable / disable 配对;嵌套安全)。
|
||||
class KeepAwake {
|
||||
KeepAwake._();
|
||||
|
||||
static const MethodChannel _channel = MethodChannel('seqstudio/docs');
|
||||
static int _count = 0;
|
||||
|
||||
/// 开启(重复开启只生效一次)。
|
||||
static Future<void> enable() async {
|
||||
_count++;
|
||||
if (_count != 1) return;
|
||||
await _apply(true);
|
||||
}
|
||||
|
||||
/// 关闭(配对 [enable])。
|
||||
static Future<void> disable() async {
|
||||
if (_count > 0) _count--;
|
||||
if (_count != 0) return;
|
||||
await _apply(false);
|
||||
}
|
||||
|
||||
/// 强制关闭(对话框销毁等兜底场景)。
|
||||
static Future<void> forceOff() async {
|
||||
_count = 0;
|
||||
await _apply(false);
|
||||
}
|
||||
|
||||
static Future<void> _apply(bool on) async {
|
||||
try {
|
||||
if (Platform.isAndroid) {
|
||||
await _channel.invokeMethod<bool>(
|
||||
'keepScreenOn',
|
||||
<String, dynamic>{'on': on},
|
||||
);
|
||||
} else if (Platform.isWindows) {
|
||||
_applyWindows(on);
|
||||
}
|
||||
} catch (_) {
|
||||
// 保持常亮失败不应中断更新。
|
||||
}
|
||||
}
|
||||
|
||||
static void _applyWindows(bool on) {
|
||||
final DynamicLibrary lib = DynamicLibrary.open('kernel32.dll');
|
||||
final int Function(int) setState =
|
||||
lib.lookupFunction<Uint32 Function(Uint32), int Function(int)>(
|
||||
'SetThreadExecutionState',
|
||||
);
|
||||
// ES_CONTINUOUS |(ES_SYSTEM_REQUIRED | ES_DISPLAY_REQUIRED)
|
||||
setState(on ? 0x80000003 : 0x80000000);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
///
|
||||
/// 应用内更新检查用它判断服务器发布的版本是否更新;
|
||||
/// **每次发版必须与 pubspec 同步更新**(见 BUILD-NOTES 的发布流程)。
|
||||
const String kAppVersion = '1.3.10';
|
||||
const String kAppVersion = '1.3.11';
|
||||
|
||||
/// 是否要求授权(License)才能导出。
|
||||
///
|
||||
|
||||
Reference in New Issue
Block a user