9 Commits

Author SHA1 Message Date
admin afc4dc6dd7 v1.3.12: 桌面名称彻底修复(新身份 cc.sincos.yide + 名称定为 EDC易得); 全局去竖线统一命名 2026-10-11 23:14:22 +08:00
admin e19dddf134 v1.3.11: 全局更名为 EDC|易得; 更新下载屏幕常亮+防误触退出; 连线法向箭头+多线避让+平板拖动优化(线段拖动/磁吸虚线/抓取光标/实时预览) 2026-10-11 22:40:57 +08:00
admin f42caa3657 v1.3.10: 应用身份切换 cc.sincos.edc(彻底解决桌面名称); 移除尺寸标注与图元库自定义; 修复帮助中心空白与 Windows 更新包校验 2026-10-11 21:38:18 +08:00
admin d26991593a 1.3.9:首页更新按钮改为真实入口(检查中/已最新/升级对话框均有反馈);更新说明补充安卓名称排查指引 2026-10-11 13:45:55 +08:00
admin 0ecaac0930 1.3.8:帮助中心改垂直导航(修复关于页控制器长度);连线端点捕捉按画线侧取点不再乱飘 2026-10-11 13:03:16 +08:00
admin 3210ac50d8 发布脚本加固:Release 创建与附件上传的 JSON 解析容错(解析失败时按 tag 复核) 2026-10-11 12:17:37 +08:00
admin 32d4181dec 1.3.7:安卓体验修复(logo 按钮等高同形、识别只识别当前墨迹、移除示例入口、尺寸区置顶)+ 修复编辑对话框控制器释放时序 2026-10-11 12:13:05 +08:00
admin 80b9bae93e 1.3.6:修复增强版(橡皮 / 手动确认识别 / 连线正交+角点 / 尺寸标注增强 / 帮助文件大规模更新) 2026-10-11 11:33:28 +08:00
admin c8147e294d 架构图增强:橡皮、手动确认识别(平板推荐)、连线一律正交+角点拖拽、手绘/连线职责分离、尺寸标注一键操作;帮助文件大规模更新;修复品牌按钮与 pubspec 描述 2026-10-11 11:22:01 +08:00
62 changed files with 2078 additions and 1942 deletions
+10 -2
View File
@@ -26,8 +26,16 @@ android {
} }
defaultConfig { defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). // 应用身份(applicationId):
applicationId = "cc.sincos.sequence_diagram" // v1.3.10:sequence_diagram → cc.sincos.edc(首轮换身份);
// v1.3.12:cc.sincos.edc → cc.sincos.yide(名称定为「EDC易得」后
// 再次换新身份,彻底刷新桌面名称)。
// 原因:部分安卓桌面会长期保留旧包身份的图标名(不随应用内更新刷新),
// 换新身份安装 = 系统当作全新应用处理,桌面必然按新包内的名称生成图标。
// 本次之后名称固定,不再变动。
// 注意:namespace 与 Kotlin 包名保持不变(仅 applicationId 变化),因此
// AndroidManifest 中组件类名需写全限定名(见 android:name)。
applicationId = "cc.sincos.yide"
// You can update the following values to match your application needs. // You can update the following values to match your application needs.
// For more information, see: https://flutter.dev/to/review-gradle-config. // For more information, see: https://flutter.dev/to/review-gradle-config.
minSdk = flutter.minSdkVersion minSdk = flutter.minSdkVersion
+2 -2
View File
@@ -9,11 +9,11 @@
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" /> <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<application <application
android:networkSecurityConfig="@xml/network_security_config" android:networkSecurityConfig="@xml/network_security_config"
android:label="EDC|易得设计" android:label="EDC易得"
android:name="${applicationName}" android:name="${applicationName}"
android:icon="@mipmap/ic_launcher"> android:icon="@mipmap/ic_launcher">
<activity <activity
android:name=".MainActivity" android:name="cc.sincos.sequence_diagram.MainActivity"
android:exported="true" android:exported="true"
android:launchMode="singleTop" android:launchMode="singleTop"
android:taskAffinity="" android:taskAffinity=""
@@ -6,6 +6,7 @@ import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Environment import android.os.Environment
import android.provider.MediaStore import android.provider.MediaStore
import android.view.WindowManager
import androidx.core.content.FileProvider import androidx.core.content.FileProvider
import io.flutter.embedding.android.FlutterActivity import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine import io.flutter.embedding.engine.FlutterEngine
@@ -98,6 +99,17 @@ class MainActivity : FlutterActivity() {
} }
} }
} }
"keepScreenOn" -> {
val on = call.argument<Boolean>("on") ?: true
runOnUiThread {
if (on) {
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
} else {
window.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
}
}
result.success(true)
}
else -> result.notImplemented() else -> result.notImplemented()
} }
} }
Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 149 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 148 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 KiB

After

Width:  |  Height:  |  Size: 153 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 115 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 125 KiB

After

Width:  |  Height:  |  Size: 124 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 151 KiB

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 144 KiB

After

Width:  |  Height:  |  Size: 144 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 121 KiB

After

Width:  |  Height:  |  Size: 120 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 118 KiB

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 86 KiB

After

Width:  |  Height:  |  Size: 85 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 122 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 175 KiB

After

Width:  |  Height:  |  Size: 174 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 170 KiB

After

Width:  |  Height:  |  Size: 170 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 180 KiB

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 KiB

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 133 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

After

Width:  |  Height:  |  Size: 95 KiB

+2 -2
View File
@@ -1,4 +1,4 @@
# EDC|易得设计 架构升级评估(1.3.5 大版本) # EDC易得 架构升级评估(1.3.5 大版本)
> 状态:P0 已实施(空白启动首页 + 模块注册表 + 文件路由 + 测试适配,全量 106 项通过); > 状态:P0 已实施(空白启动首页 + 模块注册表 + 文件路由 + 测试适配,全量 106 项通过);
> P1 部分完成(release/ 目录已按方案 B 重组并验证,运行时路径迁移与素材库目录待做)。 > P1 部分完成(release/ 目录已按方案 B 重组并验证,运行时路径迁移与素材库目录待做)。
@@ -31,7 +31,7 @@
- `AppMode` 增加 `home`:**启动即进入首页**(无文档、无画布、无侧栏)。 - `AppMode` 增加 `home`:**启动即进入首页**(无文档、无画布、无侧栏)。
- 首页内容(COMSOL Home 风格,单页即可): - 首页内容(COMSOL Home 风格,单页即可):
1. 顶部:品牌 EDC|易得设计 + 版本号; 1. 顶部:品牌 EDC易得 + 版本号;
2. 中央「新建文档」网格:6 个模块卡片(图标 + 名称 + 一句话); 2. 中央「新建文档」网格:6 个模块卡片(图标 + 名称 + 一句话);
未开放的模块灰显标注「未开放」(符合既定规则,无"规划中"字样); 未开放的模块灰显标注「未开放」(符合既定规则,无"规划中"字样);
3. 「打开文档…」按钮(按类型路由到对应模块的打开流程); 3. 「打开文档…」按钮(按类型路由到对应模块的打开流程);
+167 -461
View File
@@ -1,478 +1,184 @@
# 时序图设计 · 使用帮助 # EDC易得 · 帮助手册(1.3.5)
> 面向 **PLC 流程节拍 / 相位角设计** 的桌面软件(Flutter Desktop)。 > 本手册对应 1.3.5 大版本(软件已更名 EDC易得,仓库 EasyDesignCollection)。
> 应用内按 **F1**(或点顶部工具栏最右侧的 **?**)可随时打开同一份帮助。 > 本次更新变化较大,**新功能可能仍存在较多 bug 与问题**,欢迎反馈:
> > 开发者邮箱 liuyu65@126.com · 微信 online-goose。
> 本文按「**我要完成什么**」组织:先找到你的目标,再照着步骤做。
--- ---
## 目录 ## 1. 启动与首页(空白启动)
- [0. 界面总览](#0-界面总览) 打开软件进入**首页**(不再直接进时序图):
- [A. 开始一个方案](#a-开始一个方案)
- [B. 动作:增、删、改、复制、对齐](#b-动作增删改复制对齐)
- [C. 时间与相位:循环长度、起止角、时长](#c-时间与相位循环长度起止角时长)
- [C2. 泳道 / 轨道:一个执行器可放多个动作](#c2-泳道--轨道一个执行器可放多个动作)
- [D. 依赖关系:先后顺序与并行(多输入 / 多输出)](#d-依赖关系先后顺序与并行多输入--多输出)
- [E. 工位:增删改与排序](#e-工位增删改与排序)
- [F. 相位分区:编辑名称、起止角、数量](#f-相位分区编辑名称起止角数量)
- [G. 视图:条形 / 圆周、缩放、适应视图、显示选项](#g-视图条形--圆周缩放适应视图显示选项)
- [H. 界面:侧栏、统计、帮助入口](#h-界面侧栏统计帮助入口)
- [I. AI 生成:用自然语言直接生成时序图](#i-ai-生成用自然语言直接生成时序图)
- [J. 导出:SVG / PNG](#j-导出svg--png)
- [K. 保存、打开、崩溃恢复](#k-保存打开崩溃恢复)
- [L. 单位与精度](#l-单位与精度)
- [M. 多选与批量对齐](#m-多选与批量对齐)
- [N. 动作编辑对话框:角度 ↔ 时间](#n-动作编辑对话框角度--时间)
- [附录:快捷键、文件格式、构建](#附录快捷键文件格式构建)
--- - **新建文档**:六个模块一次列全——**架构图、时序图**已开放;电器原理图、
IO 表、拓扑图、PID 图灰显「未开放」。点卡片即新建对应文档进入模块。
- **打开文档…**:先选文档类型,再选文件。
- **最近打开**:记录最近文件(图标 / 名称 / 路径 / 时间),可单条删除或清空。
- 左上角 **logo 按钮(品牌菜单)**:首页 / 架构图设计 / 时序图设计 / 软件设置。
切换模块前如有未保存修改会先弹确认。
- 右下角同工具栏:软件设置、帮助中心、检查更新。
## 0. 界面总览 ### 文档与数据位置
窗口从上到下分为 **顶部工具栏 / 中部画布 / 底部状态栏**,画布两侧是可隐藏、可钉住的**左、右侧栏**。 | 内容 | 位置 |
### 顶部工具栏(左 → 右)
| 位置 | 元素 | 说明 |
| --- | --- | --- |
| 左 | 应用标志 + 「时序图」 | 原创「环序」标志 |
| 左 | 新建 / 打开 / 保存 | **纯图标**(`Ctrl+N / O / S`) |
| 左 | 撤销 / 重做 | **纯图标**,不可用时自动置灰(`Ctrl+Z / Y`) |
| 左 | **AI 生成** | 打开自然语言生成对话框 |
| 左 | 条形节拍 / 圆周节拍 / 流程图 | 视图切换(三种视图共享同一份数据;流程图由时序图自动生成、只读) |
| 右 | 导出(下拉菜单) | 唯一的导出入口:SVG / PNG 三种视图通用;流程图另有 drawio |
| 右 | 缩放控件 | `− 100% +` |
| 右 | 适应视图 | **纯图标**(自动缩放并居中到完整可见) |
| 右 | 单位下拉 | `ms / s / min` 快速切换 |
| 右 | 左右侧栏开关 | 显示 / 隐藏两侧栏 |
| 右 | **?** | 帮助中心(等价 `F1`) |
| 右 | ☀ / ☾ | 深 / 浅主题切换(`F3`) |
> 窗口较窄时工具栏自动进入**紧凑布局**;极窄时横向滚动,保证所有按钮都能点到。
### 左侧栏(自上而下)
1. **文档设置** —— 单行入口「文档设置」(同 `F2`):项目名、循环时长、单位精度、**泳道策略**(空泳道保留 / 移除)、**自动保存**(默认 10 分钟)、相位分区等。
2. **动作和执行编辑** —— 「新建 / 删除」按钮 + 动作 / 泳道列表;列表下方是「**编辑工位**」与「**编辑相位分区**」两个管理入口。
3. **视图模式** —— 条形节拍 / 圆周节拍(流程图入口在顶部工具栏的三段切换中)。
4. **显示选项** —— 双刻度、依赖箭头、跨循环标记、分区标注、圆环背景、层标注等开关。
5. **工位负载 / 相位占用** —— 每个工位的累计角度与占比进度条。
6. **操作提示** —— 常用拖拽与快捷键速查。
### 右侧栏(自上而下)
1. **属性 · 选中动作** —— 编号、名称、工位 / 驱动、层号、跨圈标记。
2. **属性字段** —— 开始时刻、结束时刻、持续时间、循环归属、顺序约束、相位归属(按当前单位显示)。
3. **角度编辑**(圆周视图)—— 起始角 / 持续角滑杆。
4. **工艺单位与精度** —— 时间 / 相位单位、换算表。
5. **前置依赖 · 输入** 与 **输出依赖 · 结果** —— 多输入 / 多输出,逐条可删。
6. **帮助 · 快捷键** —— 速查卡片。
> 编辑动作、复制、删除、对齐等操作**只在画布上的「编辑工具」与圆周视图浮动工具条**提供,右侧栏不再重复放置,避免功能冗余。
> 导出也只在顶部工具栏提供。
### 画布浮层
- **顶部标题**:条形 / 圆周显示「视图名 +(线型说明)」单行;流程图仅标题(说明在帮助中)。
- **左下角**:条形视图显示「节拍统计」按钮与「编辑工具」条。
- **右下角**:实时预览卡(条形 ↔ 圆周联动缩略)。
- **圆周视图右侧**:纵向浮动工具条(添加 / 编辑 / 复制 / 删除 / 层± / 对齐)。
---
## A. 开始一个方案
**我要新建一个空白方案**
1. 顶部「**新建**」图标(或 `Ctrl+N`)→ 生成含 2 个工位、2 个动作(动作 1 / 动作 2)的空白节拍。
2. 左侧「文档设置」里可修改**项目名**与**循环时长**。
**我要打开已有方案**
1. 顶部「**打开**」图标(或 `Ctrl+O`)→ 应用内文件浏览器选择 `.seq.json`。
**我要先看看示例**
- 首次启动会载入示例节拍,可直接在此基础上修改。
---
## B. 动作:增、删、改、复制、对齐
**我要新增动作**
- **双击画布空白处**:在点击的相位角处新增,默认放在**最外层**;或
- 左侧「动作和执行编辑」右上角「**新建**」:在 0° 处新增。
**我要修改动作(名称 / 工位 / 驱动 / 颜色 / 角度)**
- **双击画布上的色块**(条形块或圆周圆弧)→ 打开动作编辑对话框;或
- **双击左侧动作行** → 打开同一个对话框;或
- 点左侧该行右侧的**铅笔图标**;或
- 选中动作 → 右侧栏「属性 · 选中动作」中可直接改字段。
**我要删除动作**
- 选中后:左侧标题栏「**删除**」/ 左侧行内选中时出现的删除图标 / `Delete` 键 / 右键菜单 → 删除动作。
- **保护规则**:当项目只剩 **1 个动作 / 泳道** 时,删除入口会禁用并提示,避免把方案删空。
**我要复制 / 对齐**
- 画布左下角「**编辑工具**」→「复制」/「对齐」;圆周视图右侧浮动工具条有同款按钮。
---
## C. 时间与相位:循环长度、起止角、时长
**我要修改循环长度(时间轴长度)**
- 左侧「文档设置」→「循环与相位」→ 循环时长 → 应用;或
- 按 `F2` 打开同一对话框。
> 时间只存于 `cycle.durationMs`(毫秒);角度 = `ms / cycleMs × 360`。改循环时长不会丢失角度精度。
**我要调整某个动作的相位 / 时长**
- 拖动动作块 → 平移相位(自动吸附);
- 拖动条形块**右端** → 改持续角(左端固定);拖**左端** → 改起始角(右端固定);
- 圆周视图拖**弧的两端** → 改起止角;拖弧身 → 整体旋转;
- 右侧属性面板的「起始角 / 持续角」滑杆可精确调。
**我要让动作跨循环**
- 使 `起始角 + 持续角 > 360°` 即可;条形 / 圆周会自动拆分,尾段以半透明渲染。
> 圆周视图固定为**顺时针**(12 点钟为 0°),不提供逆时针切换。
---
## C2. 泳道 / 轨道:一个执行器可放多个动作
**泳道(条形)与轨道(圆周)对应同一个物理执行器**,一条泳道 / 轨道可以容纳**多个互不重叠**的动作(类似音频轨道):
- 拖拽动作**上下移动**(条形视图)或 **Shift + 径向拖拽**(圆周视图)即可换道;
- 只要该时间段目标泳道里没有别的动作就能放上去;若时间重叠会有提示;
- 泳道标题会把该道内的多个动作**合并显示**(如 `A1 上料 / A2 定位夹紧`),`/` 分隔、
按固定宽度**自动换行**(多槽位泳道会一直换行到泳道高度不足为止);
- 左侧列表也按泳道分组:单动作泳道显示为普通行,多动作泳道显示合并标题。
**泳道加宽(多槽位,1–5)**
- 默认每条泳道 **1 槽**;同一时间并行的动作**优先用不同工位 / 泳道区分**;
- 需要同一泳道并行时:**双击条形视图左侧泳道编号**(或右键空白泳道 /
点左侧栏「N 槽」徽标)→ 选 **1–5 槽**(5 为上限);
- 效果:条形视图同一泳道分**多条子行**、圆周视图分**多条同心子环**、
流程图分**多条子列**(泳道带自动加宽);
- 槽位之间自动留出间距,保证依赖箭头与标签放得下;拖拽动作可同时**换道 + 换槽位**;
- 加宽不会打散已有动作(全部留在槽 1,由你拖拽分配)。
**空泳道策略(可设置)**
- `F2 文档设置` →「泳道」→ **保留空泳道**(默认开):动作全部移走的泳道保留、序号不变;
- 关闭后空泳道自动移除、序号顺延;条形空行 / 圆周空环 / 流程图空列与左侧栏同步。
> 含义:一条泳道 = 一个气缸 / 伺服轴等执行器;一个色块 = 该执行器上的一个动作;
> 加宽后的槽位 = 该执行器可并行的动作数。
---
## D. 依赖关系:先后顺序与并行(多输入 / 多输出)
**依赖类型**
| 类型 | 含义 | 画法 |
| --- | --- | --- |
| **FS** 完成-启动 | 前动作完成后才启动 | 绿色实线箭头 |
| **SS** 起始-起始 | 可提前启动(并行重叠) | 琥珀虚线箭头,标签带 `+n°` |
| FF / SF | 完成-完成 / 起始-完成 | 模型与算法已支持,界面入口预留 |
**我要给动作添加前置依赖(输入)**
- 选中动作 → 右侧「**前置依赖 · 输入**」→「添加前置依赖」→ 选择前置动作与类型;或
- 右键动作 →「添加依赖…」。
**一个动作可以有多个前置(多输入)**
- 重复添加即可;右侧逐条列出,每条可单独删除。
**一个动作可以输出多个结果(多输出)**
- 在「**输出依赖 · 结果**」区域查看本动作指向了哪些后续动作,并可逐条删除。
**我要删除依赖**
- 在「前置依赖」或「输出依赖」列表中点击该条右侧的 `×`。
**依赖在画布上怎么画**
- 条形视图:**同泳道**的依赖用水平箭头连接两个色块的**外侧边缘**(不伸入色块);相邻泳道在两泳道之间的空隙走线;跨多泳道时在最外侧绕行。
- 依赖图注(`FS 顺序` / `SS +n°`)默认贴在依赖线旁;当两动作间距太短放不下时,会**自动移到箭头右侧**。
- 圆周视图:依赖沿圆弧绕行,箭头与线宽已收窄,与动作环的间隙匹配。
---
## E. 工位:增删改与排序
**工位是什么**
- 动作的**归属单元**(谁在做:上料 / 加工 / 检测…),决定条形视图中的分组与排序,
也用于「工位负载」统计;一个流程可以有任意多个工位。
- **与泳道的关系**:工位 = 物理归属(谁在做);泳道 / 轨道 = 执行器轨道(并行关系)。
并行动作**优先用不同工位 / 泳道区分**;同一工位需要并行时再用「泳道加宽」。
**我要编辑工位**
1. 左侧「动作和执行编辑」→「**编辑工位**」。
2. 在「工位管理」对话框中:
- 「**添加工位**」新增(自动分配 `STn` 编号);
- 修改**名称**、点色块换**颜色**;
- 用上 / 下箭头**调整顺序**(保存时按列表顺序写入排序);
- 「删除」移除工位(**至少保留一个**,只剩一个时禁用)。
3. 点「确定」应用。
> 删除某个工位后,原本挂在该工位下的动作会**自动改挂到列表中的第一个工位**,不会产生悬空引用。
> 单个动作归属哪个工位,在动作编辑对话框的「工位」下拉中选择。
---
## F. 相位分区:编辑名称、起止角、数量
**相位分区是什么**
- 把一个循环按角度划分成的若干**命名工艺阶段**(默认:上料 / 加工 / 检测);
- **三种视图同步呈现**:条形图为顶部标注色带、圆周视图为最外圈相位环与径向边界、
流程图为左侧竖排阶段栏;右侧属性的「相位归属」也按它判断;
- 分区允许**重叠**、允许**留空**;结束角 `> 360°` 表示跨圈。
**我要编辑相位分区**
1. 左侧「动作和执行编辑」→「**编辑相位分区**」;或 `F2` →「相位分区」→「编辑…」。
2. 在弹出的编辑器里:
- **添加分区** / **删除分区**(数量不限);
- 修改**名称**、**起始角**、**结束角**;
- 允许区间**重叠**,也允许**留空**;结束角 `> 360°` 表示跨圈;
- 「恢复默认」回到五个标准阶段。
3. 点「确定」应用。
**我要隐藏相位分区标注**
- 左侧「显示选项」→ 取消勾选「相位分区标注」。
---
## G. 视图:条形 / 圆周、缩放、适应视图、显示选项
### G1. 条形时序视图
- **标题**:条形时序视图。
- **横轴双刻度**:相位分区带与刻度线之间有两排字 —— **上排为相位值**(`0° / 60° / …`),**下排为等价时间**(按当前时间单位);轴单位图例「相位 / °」「时间 / s」与各自刻度同排。
- **动作块**:默认把「**名称 + 时长**」一起写在色块内、紧跟名称之后;只有当色块太短、放不下时才移到色块外侧。色块为单行高度,视觉更苗条。
- **0° / 360° 边界**:仅用绿色 / 琥珀色虚线标出,不再额外写字(坐标轴已能说明)。
- **泳道**:行距按「刚好容纳依赖箭头与图注」设置,分隔线颜色略深;同泳道可放多个不重叠动作。
### G2. 圆周时序视图
- **标题**:圆周时序视图。
- **同心环**:一层 = 一个执行器轨道;环带只求容纳文字,环与环之间留出**足够放置依赖箭头与图注的间隙**。
- **0° 起点**:12 点钟方向,顶部有起点标记;外围每 5° 一个刻度,**每 30° 标注度数,并在度数外侧标注等价时间**。
- **循环方向**:固定顺时针,外圈有一段短弧 + 切向箭头,标注「顺时针 CW」。
- **依赖**:沿圆弧绕行,线宽与箭头已收窄;标签沿弧切向排布。
### G3. 通用操作
**我要缩放 / 平移**
- `Ctrl + 滚轮`:**以光标为锚点**缩放(25% – 400%);
- 普通滚轮 / 拖拽空白:平移画布。
**我要让内容完整显示(适应视图)**
- 顶部「适应视图」图标:按当前内容(含刻度、箭头、跨圈等标注)自动计算缩放与居中。
**我要开关图元标注**
- 左侧「显示选项」:
- 条形视图:时间轴 / 相位双刻度、依赖箭头 FS / SS、跨循环片段标记、相位分区标注;
- 圆周视图:同心圆环背景、顺序箭头、层半径标注、跨循环高亮。
---
## H. 界面:侧栏、统计、帮助入口
**我要隐藏 / 显示侧栏**
- 工具栏右侧的两个侧栏按钮,分别控制左、右侧栏。
**我要钉住侧栏**
- 侧栏标题右侧的**图钉**按钮:
- **已钉住**:固定占位,画布让出空间;
- **取消钉住**:变为悬浮层,鼠标移开自动收起。
- 侧栏收起后,画布边缘有细把手:悬停临时展开、点击固定显示。
**我要查看节拍统计**
- 画布左下角「**节拍统计**」按钮 → 弹窗显示:
- 循环周期、动作数量、关键路径、最大并行度、相位覆盖率、瓶颈工位。
- 仅展示**可从当前项目数据推导**的指标;不提供缺少输入依据的推算值(如产能)。
**帮助入口**
- 顶部工具栏最右侧的 **?** 或 `F1`。画布上的编辑工具条**不再重复放置**帮助按钮。
---
## I. AI 生成:用自然语言直接生成时序图
**我要用一句话生成一张时序图**
1. 顶部「**AI 生成**」按钮。
2. 在对话框中:
- 填写 **DeepSeek API Key**(仅保存在本机内存,不写入工程文件);
- 选择模型:**Flash · 快速**(`deepseek-chat`)或 **Pro · 深度推理**(`deepseek-reasoner`);
- 选择推理强度:**高 / 最高**;
- 用**自然语言**描述工艺流程(工位、动作、时间、先后与并行关系)。
3. 点「生成」→ 模型返回结构化时序图并自动载入工作台,可继续编辑。
**生成效果不理想怎么办**
- 描述里写清:循环时长、工位数量、每个动作大致时长、哪些是顺序(完成后启动)、哪些是并行。
- 生成后仍可手动微调角度、依赖、工位与相位分区。
> 需要有效的 DeepSeek API Key 与可访问 `api.deepseek.com` 的网络。
---
## J. 导出:SVG / PNG / drawio
**导出入口**
- 顶部「**导出**」下拉菜单(唯一入口):
- 「导出 SVG」「导出 PNG」:三种视图(条形 / 圆周 / 流程图)通用;
- 「导出 drawio」:**仅流程图视图提供** —— 输出 diagrams.net(draw.io)
可继续编辑的工程文件(泳道、相位分区、依赖关系均保留)。
**我要导出矢量图(进工艺卡 / MES)**
- 「导出 SVG」→ 选择保存位置。SVG 分层、带语义 `id` 与 `data-*`:
`background / ruler / layers / actions / dependencies / legend`,
每个动作 `<g id="A3" data-action data-start data-duration data-layer data-station>`。
**我要导出位图**
- 「导出 PNG」→ 按 2 倍像素比导出当前画布为 `.png`。
> 导出入口只在顶部工具栏提供,右侧属性栏不再重复。
---
## K. 保存、打开、崩溃恢复
**我要保存**
- 顶部「保存」图标(`Ctrl+S`)写入 `.seq.json`,并在同目录生成 `<文件名>.bak` 备份。
**自动保存(可配置)**
- `F2 文档设置` →「自动保存」:默认**每 10 分钟**自动保存一次
(可选 1 / 5 / 10 / 30 分钟,或关闭);
- 需先手动保存过一次(有文件路径)才生效;自动保存与手动保存一样会更新 `.bak`。
**异常退出后恢复**
- 软件每 **5 秒**写入本地快照;若上次未正常退出,下次启动会弹出恢复向导,
可选择「恢复自动快照 / 从 .bak 恢复 / 忽略并删除快照」。
- 快照目录:`%APPDATA%\SequenceDiagramStudio\autosave\`。
---
## L. 单位与精度
**我要改单位 / 精度**
- 顶部单位下拉(`ms / s / min`)快速切换时间单位;或 `F2` →「单位与精度」改时间 / 相位单位与显示精度。
**换算关系**
```
angle(deg) = ms / cycleMs × 360
ms = angle / 360 × cycleMs
1 圈 = cycleMs = 360° = 100%
```
---
## M. 多选与批量对齐
**我要同时对齐多个动作**
1. 按住 **Ctrl**(或 Shift)在画布 / 左侧列表逐个点击动作,可**多选**;
2. 点「编辑工具」→「对齐」,所有选中动作的起始角会**对齐到主选中项**的起始角。
> 不按 Ctrl 点击则替换为单选;再次 Ctrl 点击已选项可取消该动作的选中。
---
## N. 动作编辑对话框:角度 ↔ 时间
**我要按时间(而不是角度)修改动作**
- 双击画布色块 / 左侧动作行,或点行内铅笔图标 → 编辑框内同时提供:
- **起始相位 / 持续相位(°)**
- **起始时刻 / 持续时长**(当前时间单位,如 `s`)
- 两组输入**实时双向换算**:改角度自动更新时间,改时间自动更新角度。
- 换算关系:`时间 = 角度 / 360 × 循环时长`。
- 对话框内还可改**名称、驱动、工位、颜色**。
**拖拽时的辅助**
- 鼠标移到**色块左 / 右端**或**分区边界**附近,指针会变成**左右拖拽箭头**;
- 拖动时显示**竖直虚线坐标参考**,并带**弱吸附**(自动贴合整 5°、其它动作端点、分区边界)。
---
## O. 授权(License)
> **当前为「开放授权版本」**:1.3.4 起临时冻结授权校验,**无需 `.lic` 即可导出**
> SVG / PNG / drawio;后续功能丰富后会恢复授权校验,并提前在官网与帮助中公告。
**联系方式**
- 开发者邮箱:`liuyu65@126.com`;
- **设计交流群**:添加开发者微信 **online-goose**,加入「设计与制造业设计交流群」;
- 官网:`sincos.cc`。
**(以下为恢复授权后的流程,仅作预留)**
1. 打开「帮助 → 关于」,查看**本机 MAC** 与**授权申请邮箱**;
2. 把本机 MAC 发送到该邮箱申请授权,收到 `.lic` 文件(一行文本);
3. 把 `.lic` 放入软件目录下的 **`license`** 文件夹,重启软件即可导出。
授权串算法(管理员用 `tools/keygen/keygen.exe` 图形界面生成):
`MAC → 去横线 → A=01…Z=26(数字 0–9 记 00–09)→ 末尾加 26 → 整串倒序`。
例:`AA-BB-CC-DD-EE-FF` → `62606050504040303020201010`。
---
## 附录:快捷键、文件格式、构建
### 快捷键
| 操作 | 行为 |
| --- | --- | | --- | --- |
| 左键拖拽动作块 | 平移相位(自动吸附) | | 时序图文档 | `*.seq.json`(只含时序内容) |
| 拖拽条形块右端 / 左端 | 改持续角 / 改起始角 | | 架构图文档 | `*.arch.json`(只含架构内容) |
| 圆周视图拖弧两端 | 改起止角 | | 旧版文档 | `.edc.json` 可继续打开(自动兼容) |
| `Shift` + 拖拽 | 圆周视图径向改层;条形视图上下拖动改层 | | 桌面数据目录 | `%APPDATA%/EDC`(autosave 快照 / recent 最近列表 / library 素材库;旧目录首次启动自动复制迁移,不改写原目录) |
| 双击画布色块 / 左侧动作行 | 打开动作编辑对话框 | | 安卓公共目录 | `Documents/EDC`(兼容读取旧目录 `Documents/SequenceDiagram`) |
| 双击空白 | 在点击角度处新建动作 | | 用户图元 | `library/symbols/*.symbol.json`(可拷贝分享) |
| `Ctrl` + 滚轮 | 以光标为锚点缩放 | | 备份 | 保存时自动生成 `<文档>.bak` |
| 普通滚轮 | 平移画布 |
| 右键动作 | 菜单:添加依赖 / 改层 / 复制 / 删除 |
| `Ctrl+Z` / `Ctrl+Y` | 撤销 / 重做 |
| `Ctrl+S` / `Ctrl+O` / `Ctrl+N` | 保存 / 打开 / 新建 |
| `Delete` | 删除选中动作(至少保留一个) |
| `F1` / `F2` / `F3` | 帮助 / 文档设置 / 深浅主题 |
### 工程文件格式(`.seq.json`) ---
```json ## 2. 架构图模块
{
"schema": "seqdiagram/1.2",
"project": {
"name": "示例节拍",
"units": { "timeUnit": "s", "phaseUnit": "deg", "precision": -1 },
"cycle": { "durationMs": 3600, "startAngle": 0, "direction": "cw", "origin": "twelve", "snapDeg": 1 },
"stations": [ { "id": "ST1", "name": "工位 1", "order": 0, "color": "#4cc9f0" } ],
"actions": [
{ "id": "A1", "name": "动作 1", "stationId": "ST1", "driver": "气缸 Y1",
"startAngle": 0, "durationAngle": 70, "layer": 0, "color": "#4cc9f0",
"deps": [] },
{ "id": "A2", "name": "动作 2", "stationId": "ST2", "driver": "气缸 Y2",
"startAngle": 80, "durationAngle": 60, "layer": 1, "color": "#7bd88f",
"deps": [ { "fromId": "A1", "toId": "A2", "type": "FS", "offsetAngle": 0 } ] }
],
"viewState": { "mode": "bar", "zoom": 1, "pan": [0, 0], "showDeps": true },
"phaseZones": [ { "name": "上料相位", "startAngle": 0, "endAngle": 70 } ]
}
}
```
### 应用标志 ### 2.1 工具栏
- 原创标记「**环序 / Cycle-Step**」:缺口圆环(一圈 = 一个循环,缺口指示 0° 起点) **选择 / 手绘 / 连线 / 橡皮** + 「**识别(N)**」确认按钮(N = 待识别墨迹笔数)。
\+ 阶梯折线(动作按时间顺序推进)+ 原点 / 链尾节点。
- 由 `tools/gen-icon.py` 生成 `windows/runner/resources/app_icon.ico` 与 `demo/app-icon.png`;
工具栏 Logo 为同一几何构成(`lib/ui/app_logo.dart`),二者同源。
### 从源码构建 ### 2.2 手绘识别
```bash - 「手绘」工具下按住拖动,松手自动把笔迹扶正为标准图形:
flutter pub get 矩形 / 圆角矩形 / 椭圆 / 圆 / 三角形 / 菱形 / 六边形 / 圆柱 / 云 /
flutter run -d windows # 开发调试 箭头 / 直线 / 折线 / 曲线。
scripts\build.bat # 发布版:构建并复制到 dist\ - **多笔组合**:两笔画的矩形、圆柱(顶盖 + 柱体)自动拼接;
``` 与上一笔刚生成的图形也能在 2.5 秒内合并。
- 识别不了的笔迹保留为**墨迹**(可擦除或之后点「识别」重试)。
- **手动确认识别(平板推荐)**:左栏「手绘识别」关闭「松手自动识别」
(安卓默认关闭)→ 笔迹先保留为墨迹,画完点顶部「识别(N)」按钮统一确认。
产物:`dist\sequence_diagram.exe` ### 2.3 图形库
> 若本机装有绿盾等透明加密软件,请先阅读仓库根目录 `BUILD-NOTES.md`。 - 左栏「图形库」内置标准图形(矩形 / 圆角矩形 / 椭圆 / 圆 / 三角 / 菱形 /
> 架构与性能优化点见 `docs/ARCHITECTURE.md`。 六边形 / 圆柱 / 云…)与 IT 图元(服务器 / 客户端 / 移动端 / 防火墙 /
交换机 / 消息队列),点一下即插入画布。
### 2.4 橡皮
「橡皮」工具:拖过**图形 / 墨迹 / 连线**即擦除;
一次连续擦除算**一步撤销**(Ctrl+Z 整段回退)。
### 2.5 连线
- 画路径即出连线,**一律正交(横平竖直),不会出现斜线**。
- 两端**垂直出入图元边框**(沿法向):箭头始终垂直指向图元,不会贴着边乱指;
同一图元同一条边上的多条连线**自动错开**(避让,不再重叠)。
- 选中连线后(平板 / 手指已加大命中范围):
- 拖**端点**可换吸附目标、拖到别的图形重新吸附或脱离为自由端点(实时预览);
- 拖**折点**自由调整走线(自动物化台阶);
- 拖**线段**整体平移该段(直线会就地生成台阶);
- 拖动时有**磁力吸附**(对齐图元边 / 中心、其它连线、图纸中心)并显示
**虚线导引**;鼠标悬停连线会显示抓取光标。
### 2.6 文字
- 双击图形 → 编辑图形文字;双击连线 → 编辑连线标签;
- 双击空白 → 新建文本(输入法直接打字,支持多行)。
### 2.7 图层
左栏「图层」:新建 / **可见**(眼睛)/ **锁定**(锁)/ 颜色 / 双击改名。
- 隐藏图层:不绘制、不可选、不可吸附;
- 锁定图层:可见但不可选(仍可作吸附参照);
- 删除图层:该层对象移入第一层。
### 2.8 标尺与绘图辅助
- **四边标尺单位为 mm**(左上角单位徽标;垂直轴数值显示在**右侧**);
- 鼠标位置在标尺上显示**实线**游标;
- **F8 正交移动**(走水平 / 垂直);**F10 极轴追踪**(角度倍数在左栏设置);
- 网格吸附(粒度可调 10/20/40/80)与**磁力对齐线**(移动时自动吸附相邻图元)。
### 2.9 默认图纸
新建架构图为 **A0 图纸**(1189 × 841 mm;**1 世界单位 = 1 mm**),
自动适配视口居中;画布上绘制浅色 A0 边界。
### 2.10 对齐 / 均布与编辑
- 多选(框选 / Ctrl 点选)后右栏 8 个按钮:左 / 横向居中 / 右、
顶 / 纵向居中 / 底、横向均布、纵向均布(以选中范围为参照,均布需 ≥3 个)。
- 上移 / 下移一层、删除(Del)、Ctrl+A 全选。
### 2.11 导出
| 格式 | 说明 |
| --- | --- |
| SVG | 矢量(图元逐基元还原),可直接进文档二次编辑 |
| PNG | 位图(3840×2160) |
| DXF | AutoCAD R12(图层 / 图形 / 连线 / 文字;每段独立折线),可在 AutoCAD / DraftSight / ZWCAD 继续编辑 |
导出使用纯白背景,与屏幕主题无关。
---
## 3. 时序图模块
(与 1.3.4 基本一致,摘要如下;详细问答见软件内帮助中心)
- **动作**:双击空白新增;双击色块编辑;拖动改相位;拖端点改时长;
右键菜单复制 / 删除 / 加依赖。
- **工位与泳道**:工位 = 谁在做(可增删改排序);泳道 = 执行器轨道;
泳道可加宽 1–5 槽(双击泳道编号),支持换道 + 换槽位拖拽。
- **依赖**:FS 绿色实线(完成后启动)/ SS 琥珀虚线(可提前启动,+n°);
重叠连线可拖拽错开,双击复位。
- **相位分区**:命名工艺阶段(上料 / 加工 / 检测…),条形 / 圆周 / 流程图同步展示。
- **三视图**:条形节拍 / 圆周节拍 / 流程图(流程图自动生成、只读);
切换自动适应窗口;Ctrl+滚轮缩放。
- **AI 生成**:顶部「AI 生成」→ DeepSeek API Key → 模型 / 强度 → 自然语言描述。
- **节拍统计**:循环周期、关键路径、最大并行度、相位覆盖率、瓶颈工位。
- **导出**:SVG / PNG 三视图通用;流程图另有 drawio。
- **保存**:`*.seq.json` + `.bak`;每 5 秒自动快照;可开启「自动保存」(默认 10 分钟)。
---
## 4. 更新与版本
- 首页 / 帮助 / 设置中的「检查更新」:检测到新版本**直接升级到最新版**,
无需逐版本安装;下载 / 上传统一限速 **320KB/s**,下载中请保持屏幕常亮与网络稳定。
- 更新通道(Gitea):仓库 `admin/EasyDesignCollection`;
旧仓库名保留 301 重定向,**老版本客户端(1.3.4 及更早)不受改名影响**。
---
## 5. 快捷键总览
| 快捷键 | 功能 |
| --- | --- |
| Ctrl+N / Ctrl+O / Ctrl+S | 新建 / 打开 / 保存 |
| Ctrl+Z / Ctrl+Y | 撤销 / 重做 |
| Ctrl+A | 全选(当前模块) |
| Delete | 删除选中 |
| F1 | 帮助中心 |
| F2 | 文档设置(时序图:单位 / 循环 / 泳道 / 相位分区) |
| F3 | 切换深 / 浅主题 |
| F8 / F10 | 正交移动 / 极轴追踪(架构图) |
| Ctrl+滚轮 | 缩放(以光标为锚点) |
---
## 6. 常见问题(FAQ)
**Q:老版本 1.3.4 能自动更新到 1.3.5 吗?**
能。旧地址在服务器保留 301 重定向,1.3.4 的「检查更新」会照常看到 1.3.5 并升级。
**Q:升级后我的旧文档还能打开吗?**
能。时序图 `*.seq.json` / 架构图 `*.arch.json` 与旧版 `.edc.json` 都兼容。
**Q:平板手写识别不准怎么办?**
关闭「松手自动识别」,画完点「识别(N)」统一确认;或用「橡皮」重写。
**Q:为什么连线不能画斜线?**
按产品约定连线**一律正交**(横平竖直);需要斜段请用「手绘」画直线图形。
**Q:升级后桌面出现两个图标 / 名称还是旧的?**
1.3.12 起应用换了新身份(`cc.sincos.yide`),系统会当作**全新应用**安装:
桌面新图标即 `EDC易得`;旧图标(时序图设计 / EDC|易得设计)长按全部卸载即可。
项目文件保存在公共文档目录(`Documents/SequenceDiagram`),不受影响。
**Q:1.3.12 之后怎么更新?**
仍从首页 / 工具栏「检查更新」下载安装,此后都在新身份上**原地覆盖更新**
(名称已固定为 EDC易得,不会再需要换身份重装)。
+2 -2
View File
@@ -39,9 +39,9 @@
## 三、v1.3.5 更名与架构图(开发中) ## 三、v1.3.5 更名与架构图(开发中)
- **软件更名**:`Easy Design Collection`(缩写 **EDC**),中文名 **EDC|易得设计** - **软件更名**:`Easy Design Collection`(缩写 **EDC**),中文名 **EDC易得**
(窗口标题、Logo 菜单、关于页已替换;安装包命名与 README 随发布更新)。 (窗口标题、Logo 菜单、关于页已替换;安装包命名与 README 随发布更新)。
- **合集菜单**:左上角「EDC|易得设计」下拉**一次列全所有模块**(时序图 / 架构图已可用, - **合集菜单**:左上角「EDC易得」下拉**一次列全所有模块**(时序图 / 架构图已可用,
其余以「规划中」列出、按序点亮);后续模块只需在菜单中逐个开放,不再调整导航结构。 其余以「规划中」列出、按序点亮);后续模块只需在菜单中逐个开放,不再调整导航结构。
菜单在 logo 下方展开、不遮挡 logo,内容超高时内部滚动。 菜单在 logo 下方展开、不遮挡 logo,内容超高时内部滚动。
- **架构图设计(本轮已交付)**: - **架构图设计(本轮已交付)**:
+2 -2
View File
@@ -40,7 +40,7 @@ Future<Uint8List> renderArchPng({
// 标题与副标题(固定左上角)。 // 标题与副标题(固定左上角)。
_text(canvas, '架构图设计', const Offset(48, 36), _text(canvas, '架构图设计', const Offset(48, 36),
color: et.text, size: 34, weight: FontWeight.w700); 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); color: et.sub, size: 16, weight: FontWeight.w400);
// 内容适配(白底令牌 + 关闭网格点阵)。 // 内容适配(白底令牌 + 关闭网格点阵)。
@@ -56,7 +56,7 @@ Future<Uint8List> renderArchPng({
_text( _text(
canvas, canvas,
'EDC|易得设计 · 架构图设计 · $projectName · 元件 ${doc.shapes.length} · 连线 ' 'EDC易得 · 架构图设计 · $projectName · 元件 ${doc.shapes.length} · 连线 '
'${doc.connectors.length} · 墨迹 ${doc.strokes.length}', '${doc.connectors.length} · 墨迹 ${doc.strokes.length}',
Offset(48, h - 38), Offset(48, h - 38),
color: et.sub, color: et.sub,
+248 -280
View File
@@ -28,6 +28,9 @@ enum ArchTool {
/// 连线(从一个图形拖到另一个图形,自动吸附并跟随移动)。 /// 连线(从一个图形拖到另一个图形,自动吸附并跟随移动)。
connect, connect,
/// 橡皮(拖过图形 / 墨迹 / 连线即擦除;一次连续擦除 = 一步撤销)。
eraser,
} }
/// 连线走线方式。 /// 连线走线方式。
@@ -129,194 +132,40 @@ enum ArchShapeType {
symbol, symbol,
} }
/// 可编辑尺寸类型(识别后图形的直接尺寸;不走约束求解器)。 /// 把折线正交化:保留顶点位置,但所有段强制「横平竖直」。
enum ArchDimKind { ///
/// 宽度(水平尺寸)。 /// 用于手绘连线的轨迹:笔迹认出的折点仍被尊重,但不会出现斜线
width, ///(斜段自动拆成 横 + 竖 或 竖 + 横 两段台阶)。
List<Offset> orthoPolyline(List<Offset> pts) {
/// 高度(垂直尺寸)。 if (pts.length < 2) return List<Offset>.of(pts);
height, final List<Offset> out = <Offset>[pts.first];
for (int i = 1; i < pts.length; i++) {
/// 长度(线类图形的路径长度)。 final Offset p = pts[i];
length, final Offset last = out.last;
final Offset d = p - last;
/// 直径(圆)。 if (d.distance < 1e-3) continue;
diameter, if (d.dx.abs() >= d.dy.abs()) {
} out.add(Offset(p.dx, last.dy));
if (d.dy.abs() > 6) out.add(p);
/// 尺寸类型 JSON 名称。 } else {
String archDimKindName(ArchDimKind k) => switch (k) { out.add(Offset(last.dx, p.dy));
ArchDimKind.width => 'width', if (d.dx.abs() > 6) out.add(p);
ArchDimKind.height => 'height',
ArchDimKind.length => 'length',
ArchDimKind.diameter => 'diameter',
};
/// JSON 名称 → 尺寸类型。
ArchDimKind archDimKindFrom(String s) => switch (s) {
'height' => ArchDimKind.height,
'length' => ArchDimKind.length,
'diameter' => ArchDimKind.diameter,
_ => ArchDimKind.width,
};
/// 尺寸类型中文名。
String archDimKindLabel(ArchDimKind k) => switch (k) {
ArchDimKind.width => '宽度',
ArchDimKind.height => '高度',
ArchDimKind.length => '长度',
ArchDimKind.diameter => '直径',
};
/// 图形适用的尺寸类型(右栏编辑 / 画布标注用)。
List<ArchDimKind> archShapeDimKinds(ArchShape s) {
if (s.isLinear) {
return const <ArchDimKind>[
ArchDimKind.length,
ArchDimKind.width,
ArchDimKind.height,
];
}
if (s.type == ArchShapeType.circle) {
return const <ArchDimKind>[ArchDimKind.diameter];
}
return const <ArchDimKind>[ArchDimKind.width, ArchDimKind.height];
}
/// 线类图形的外接矩形(pts / a-b)。
Rect archLinearBounds(ArchShape s) {
if (s.type == ArchShapeType.line && s.a != null && s.b != null) {
return Rect.fromPoints(s.a!, s.b!);
}
if (s.pts.isEmpty) return s.rect;
double l = s.pts.first.dx, r = l, t = s.pts.first.dy, b = t;
for (final Offset p in s.pts) {
if (p.dx < l) l = p.dx;
if (p.dx > r) r = p.dx;
if (p.dy < t) t = p.dy;
if (p.dy > b) b = p.dy;
}
return Rect.fromLTRB(l, t, r, b);
}
/// 线类图形的路径长度(直线 / 折线 / 曲线按顶点折线近似)。
double archShapeLength(ArchShape s) {
if (s.type == ArchShapeType.line && s.a != null && s.b != null) {
return (s.b! - s.a!).distance;
}
double len = 0;
for (int i = 1; i < s.pts.length; i++) {
len += (s.pts[i] - s.pts[i - 1]).distance;
}
return len;
}
/// 测量图形当前尺寸值。
double archShapeDimValue(ArchShape s, ArchDimKind k) {
switch (k) {
case ArchDimKind.length:
return archShapeLength(s);
case ArchDimKind.diameter:
return s.rect.width;
case ArchDimKind.width:
return s.isLinear ? archLinearBounds(s).width : s.rect.width;
case ArchDimKind.height:
return s.isLinear ? archLinearBounds(s).height : s.rect.height;
}
}
/// 线类图形按比例缩放(绕外接框中心;[fx]/[fy] 为横纵缩放系数)。
ArchShape _scaleLinear(ArchShape s, double fx, double fy) {
final Rect b = archLinearBounds(s);
final Offset c0 = b.center;
Offset map(Offset p) =>
Offset(c0.dx + (p.dx - c0.dx) * fx, c0.dy + (p.dy - c0.dy) * fy);
if (s.type == ArchShapeType.line && s.a != null && s.b != null) {
final Offset a2 = map(s.a!);
final Offset b2 = map(s.b!);
return s.copyWith(a: a2, b: b2, rect: Rect.fromPoints(a2, b2));
}
final List<Offset> pts = <Offset>[for (final Offset p in s.pts) map(p)];
if (pts.isEmpty) return s;
double l = pts.first.dx, r = l, t = pts.first.dy, bo = t;
for (final Offset p in pts) {
if (p.dx < l) l = p.dx;
if (p.dx > r) r = p.dx;
if (p.dy < t) t = p.dy;
if (p.dy > bo) bo = p.dy;
}
return s.copyWith(pts: pts, rect: Rect.fromLTRB(l, t, r, bo));
}
/// 应用尺寸(直接缩放几何,中心保持;值 <= 0.1 时按 0.1 处理)。
ArchShape archShapeApplyDim(ArchShape s, ArchDimKind k, double value) {
final double v = value <= 0.1 ? 0.1 : value;
switch (k) {
case ArchDimKind.width:
if (s.isLinear) {
final double w = archLinearBounds(s).width;
return _scaleLinear(s, w <= 1e-6 ? 1 : v / w, 1);
}
return s.copyWith(
rect: Rect.fromCenter(
center: s.rect.center, width: v, height: s.rect.height));
case ArchDimKind.height:
if (s.isLinear) {
final double h = archLinearBounds(s).height;
return _scaleLinear(s, 1, h <= 1e-6 ? 1 : v / h);
}
return s.copyWith(
rect: Rect.fromCenter(
center: s.rect.center, width: s.rect.width, height: v));
case ArchDimKind.diameter:
return s.copyWith(
rect: Rect.fromCenter(center: s.rect.center, width: v, height: v));
case ArchDimKind.length:
final double len = archShapeLength(s);
if (len <= 1e-6) return s;
final double f = v / len;
return _scaleLinear(s, f, f);
}
}
/// 尺寸标签锚点(世界坐标;屏幕恒定间距由 [zoom] 折算)。
Offset archShapeDimLabelPos(
ArchShape s,
ArchDimKind k,
int index,
double zoom,
) {
final double z = zoom <= 0.05 ? 1 : zoom;
final double gap = 17 / z;
final Rect b = s.isLinear ? archLinearBounds(s) : s.rect;
final bool wide =
s.type == ArchShapeType.line || s.type == ArchShapeType.curve;
return Offset(
b.center.dx + (wide ? gap * 0.9 : 0),
b.bottom + gap * (index + 0.8),
);
}
/// 命中的尺寸标签(双击编辑用);未命中返回 null。
(ArchShape, ArchDimKind)? archShapeDimHitAt(
ArchDoc doc,
Offset p,
double zoom,
) {
final double z = zoom <= 0.05 ? 1 : zoom;
final double tol = 14 / z + 6;
for (final ArchShape s in doc.shapes) {
if (!doc.isLayerVisible(s.layerId)) continue;
final List<ArchDimKind> kinds = <ArchDimKind>[
for (final ArchDimKind k in archShapeDimKinds(s))
if (s.dims.contains(k)) k,
];
for (int i = 0; i < kinds.length; i++) {
final Offset a = archShapeDimLabelPos(s, kinds[i], i, z);
if ((p - a).distance <= tol) return (s, kinds[i]);
} }
} }
return null; // 去掉相邻重复点。
final List<Offset> clean = <Offset>[out.first];
for (int i = 1; i < out.length; i++) {
if ((out[i] - clean.last).distance < 2) continue;
clean.add(out[i]);
}
// 去掉共线冗余点(中间点与前后同横或同竖)。
for (int i = clean.length - 2; i >= 1; i--) {
final Offset a = clean[i - 1], b = clean[i], cc = clean[i + 1];
final bool h = (a.dy - b.dy).abs() < 1 && (b.dy - cc.dy).abs() < 1;
final bool v = (a.dx - b.dx).abs() < 1 && (b.dx - cc.dx).abs() < 1;
if (h || v) clean.removeAt(i);
}
return clean;
} }
/// 默认画布(图纸)尺寸:A0 横放(1189 × 841 mm;1 世界单位 = 1 mm)。 /// 默认画布(图纸)尺寸:A0 横放(1189 × 841 mm;1 世界单位 = 1 mm)。
@@ -632,8 +481,14 @@ Offset archNearestBorderPoint(ArchShape s, Offset p) {
return Offset(p.dx.clamp(r.left, r.right), p.dy.clamp(r.top, r.bottom)); return Offset(p.dx.clamp(r.left, r.right), p.dy.clamp(r.top, r.bottom));
} }
/// 计算连线几何:直线端点为「创建时吸附的最近边缘点」在当前图形上的投影; /// 计算连线几何:**一律正交走线**(横平竖直,无斜线)。
/// [ArchRoute.ortho] 时自动生成横平竖直的正交折线(带圆角)。 ///
/// - 端点吸附图形时:贴边点取「保存的画线侧」边框点(多条连线贴在同一条边
/// 时自动分配槽位错开);出入两端沿该边**法向**短桩——箭头始终垂直射入
/// 图元边,不会贴着边乱指;
/// - 有折点([ArchConnector.mids],手绘轨迹 / 拖拽过的角点)时:按折点走
/// 正交台阶,两端同样保证法向出入;
/// - 无折点时:自动生成带法向短桩的正交走线(转弯走台阶)。
ArchConnGeometry archConnectorGeometry( ArchConnGeometry archConnectorGeometry(
ArchDoc doc, ArchDoc doc,
ArchConnector c, { ArchConnector c, {
@@ -649,89 +504,48 @@ ArchConnGeometry archConnectorGeometry(
final ArchShape? st = resolve(c.toId); final ArchShape? st = resolve(c.toId);
final Offset cFrom = sf?.rect.center ?? c.from; final Offset cFrom = sf?.rect.center ?? c.from;
final Offset cTo = st?.rect.center ?? c.to; final Offset cTo = st?.rect.center ?? c.to;
final (Offset a, Offset b) = _orthoEnds(doc, c, sf, st, cFrom, cTo);
if (c.route == ArchRoute.ortho) { // 端点法向(自由端点无方向约束)。
return _orthoGeometry(sf, st, cFrom, cTo, c.from, c.to); final Offset na =
} sf == null ? Offset.zero : _connNormal(_connSideOfPoint(sf, a));
final Offset nb =
st == null ? Offset.zero : _connNormal(_connSideOfPoint(st, b));
final Offset a = sf == null ? c.from : archNearestBorderPoint(sf, c.from); /// 法向短桩长度(世界单位):保证箭头垂直入边、出口垂直离边。
final Offset b = st == null ? c.to : archNearestBorderPoint(st, c.to); const double stub = 14;
// 手画折线:经过识别出的中间折点。 final List<Offset> raw = <Offset>[a];
final List<Offset> raw = <Offset>[a, ...c.mids, b]; if (c.mids.isNotEmpty) {
final List<Offset> clean = <Offset>[]; if (sf != null) raw.add(a + na * stub);
for (final Offset p in raw) { raw.addAll(c.mids);
if (clean.isEmpty || (p - clean.last).distance > 0.5) clean.add(p); if (st != null) raw.add(b + nb * stub);
} raw.add(b);
if (clean.length < 2) {
clean
..clear()
..addAll(<Offset>[a, b]);
}
final Path path = Path()..moveTo(clean.first.dx, clean.first.dy);
for (int i = 1; i < clean.length; i++) {
path.lineTo(clean[i].dx, clean[i].dy);
}
return ArchConnGeometry(clean, path, _labelPoint(clean));
}
/// 正交走线:按两图形中心的主方向决定「先横后竖 / 先竖后横」,
/// 端点从相应方向的边框射出,中间折一次。
ArchConnGeometry _orthoGeometry(
ArchShape? sf,
ArchShape? st,
Offset cFrom,
Offset cTo,
Offset freeFrom,
Offset freeTo,
) {
final bool horizontalFirst =
(cTo.dx - cFrom.dx).abs() >= (cTo.dy - cFrom.dy).abs();
Offset a;
Offset b;
if (horizontalFirst) {
a = sf == null
? freeFrom
: archBorderPoint(
sf,
Offset(
cTo.dx >= cFrom.dx ? sf.rect.right + 1e5 : sf.rect.left - 1e5,
cFrom.dy,
),
);
b = st == null
? freeTo
: archBorderPoint(
st,
Offset(
cTo.dx >= cFrom.dx ? st.rect.left - 1e5 : st.rect.right + 1e5,
cTo.dy,
),
);
} else { } else {
a = sf == null final Offset? sA = sf == null ? null : a + na * stub;
? freeFrom final Offset? sB = st == null ? null : b + nb * stub;
: archBorderPoint( if (sA != null) raw.add(sA);
sf, final Offset p = sA ?? a;
Offset( final Offset q = sB ?? b;
cFrom.dx, if (sf != null || st != null) {
cTo.dy >= cFrom.dy ? sf.rect.bottom + 1e5 : sf.rect.top - 1e5, // 中段:先沿吸附端的主轴走,再拐到另一端(台阶转弯)。
), final Offset main = sf != null ? na : nb;
); if (main.dx != 0) {
b = st == null if ((p.dy - q.dy).abs() > 0.5) raw.add(Offset(q.dx, p.dy));
? freeTo } else if ((p.dx - q.dx).abs() > 0.5) {
: archBorderPoint( raw.add(Offset(p.dx, q.dy));
st,
Offset(
cTo.dx,
cTo.dy >= cFrom.dy ? st.rect.top - 1e5 : st.rect.bottom + 1e5,
),
);
} }
final List<Offset> pts = horizontalFirst } else if ((p.dx - q.dx).abs() >= (p.dy - q.dy).abs()) {
? <Offset>[a, Offset(b.dx, a.dy), b] // 双自由端点:单拐角(先横后竖 / 先竖后横按主方向)。
: <Offset>[a, Offset(a.dx, b.dy), b]; 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 List<Offset> clean = <Offset>[]; 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); if (clean.isEmpty || (p - clean.last).distance > 0.5) clean.add(p);
} }
return ArchConnGeometry( return ArchConnGeometry(
@@ -741,6 +555,174 @@ ArchConnGeometry _orthoGeometry(
); );
} }
/// 连线端点在图元边框上的贴边(正交走线的出入方向)。
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 a = c.from;
if (sf != null) {
a = _attachWithSlots(
doc,
c,
sf,
_naturalAttach(sf, c.from, cTo),
isFrom: true,
);
}
Offset b = c.to;
if (st != null) {
b = _attachWithSlots(
doc,
c,
st,
_naturalAttach(st, c.to, cFrom),
isFrom: false,
);
}
return (a, b);
}
/// 标签锚点:最长段的中点。 /// 标签锚点:最长段的中点。
Offset _labelPoint(List<Offset> pts) { Offset _labelPoint(List<Offset> pts) {
double best = -1; double best = -1;
@@ -894,7 +876,6 @@ class ArchShape {
this.pts = const <Offset>[], this.pts = const <Offset>[],
this.layerId = kArchDefaultLayerId, this.layerId = kArchDefaultLayerId,
this.symbolId = '', this.symbolId = '',
this.dims = const <ArchDimKind>{},
}); });
/// 唯一标识(如 `S1`)。 /// 唯一标识(如 `S1`)。
@@ -942,9 +923,6 @@ class ArchShape {
/// 图元库符号 id(仅 [ArchShapeType.symbol] 使用;空串 = 未指定)。 /// 图元库符号 id(仅 [ArchShapeType.symbol] 使用;空串 = 未指定)。
final String symbolId; final String symbolId;
/// 画布上标注的尺寸类型(识别后图形可直接改值缩放,见 [archShapeApplyDim])。
final Set<ArchDimKind> dims;
/// 是否为「线类」图形(直线 / 箭头 / 折线 / 曲线)。 /// 是否为「线类」图形(直线 / 箭头 / 折线 / 曲线)。
bool get isLinear => bool get isLinear =>
type == ArchShapeType.line || type == ArchShapeType.line ||
@@ -1017,7 +995,6 @@ class ArchShape {
List<Offset>? pts, List<Offset>? pts,
String? layerId, String? layerId,
String? symbolId, String? symbolId,
Set<ArchDimKind>? dims,
}) { }) {
return ArchShape( return ArchShape(
id: id ?? this.id, id: id ?? this.id,
@@ -1035,7 +1012,6 @@ class ArchShape {
pts: pts ?? this.pts, pts: pts ?? this.pts,
layerId: layerId ?? this.layerId, layerId: layerId ?? this.layerId,
symbolId: symbolId ?? this.symbolId, symbolId: symbolId ?? this.symbolId,
dims: dims ?? this.dims,
); );
} }
@@ -1076,10 +1052,6 @@ class ArchShape {
'pts': <double>[for (final Offset p in pts) ...<double>[p.dx, p.dy]], 'pts': <double>[for (final Offset p in pts) ...<double>[p.dx, p.dy]],
if (layerId.isNotEmpty) 'ly': layerId, if (layerId.isNotEmpty) 'ly': layerId,
if (symbolId.isNotEmpty) 'sy': symbolId, if (symbolId.isNotEmpty) 'sy': symbolId,
if (dims.isNotEmpty)
'dim': <String>[
for (final ArchDimKind k in dims) archDimKindName(k),
],
}; };
/// 从 JSON 反序列化(字段缺失时使用安全默认值)。 /// 从 JSON 反序列化(字段缺失时使用安全默认值)。
@@ -1120,10 +1092,6 @@ class ArchShape {
pts: pts, pts: pts,
layerId: j['ly'] as String? ?? kArchDefaultLayerId, layerId: j['ly'] as String? ?? kArchDefaultLayerId,
symbolId: j['sy'] as String? ?? '', symbolId: j['sy'] as String? ?? '',
dims: <ArchDimKind>{
for (final dynamic e in (j['dim'] as List<dynamic>?) ?? <dynamic>[])
archDimKindFrom(e.toString()),
},
); );
} }
} }
+8 -65
View File
@@ -430,9 +430,11 @@ class ArchPainter extends CustomPainter {
..color = t.line2, ..color = t.line2,
); );
// 连线在底层(图形遮住线头,视觉更干净;隐藏图层不绘制)。 // 连线在底层(图形遮住线头,视觉更干净;隐藏图层不绘制)。
// 拖拽编辑中的连线用预览对象绘制(实时反馈)。
for (final ArchConnector c in doc.connectors) { for (final ArchConnector c in doc.connectors) {
if (!doc.isLayerVisible(c.layerId)) continue; 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) { for (final ArchShape s in doc.shapes) {
if (!doc.isLayerVisible(s.layerId)) continue; if (!doc.isLayerVisible(s.layerId)) continue;
@@ -1030,70 +1032,7 @@ class ArchPainter extends CustomPainter {
: 12.5, : 12.5,
); );
} }
// 尺寸标注(识别后图形 / 曲线 / 图元可直接改值缩放;标签屏幕字号恒定)。
if (s.dims.isNotEmpty) {
final double z = doc.zoom < 0.05 ? 1 : doc.zoom;
final List<ArchDimKind> kinds = <ArchDimKind>[
for (final ArchDimKind k in archShapeDimKinds(s))
if (s.dims.contains(k)) k,
];
for (int i = 0; i < kinds.length; i++) {
final ArchDimKind k = kinds[i];
_dimBadge(canvas, s, k, archShapeDimLabelPos(s, k, i, z), z);
} }
}
}
/// 尺寸标签(小圆角底片 + 数值;屏幕尺寸恒定,双击可改值)。
void _dimBadge(
Canvas canvas,
ArchShape s,
ArchDimKind k,
Offset center,
double z,
) {
final double inv = 1 / z;
final double v = archShapeDimValue(s, k);
final String txt = switch (k) {
ArchDimKind.width => 'W ${_fmtDim(v)}',
ArchDimKind.height => 'H ${_fmtDim(v)}',
ArchDimKind.length => 'L ${_fmtDim(v)}',
ArchDimKind.diameter => '⌀ ${_fmtDim(v)}',
};
final TextPainter tp = TextPainter(
text: TextSpan(
text: txt,
style: TextStyle(
color: const Color(0xFF0F766E),
fontSize: 10 * inv,
fontWeight: FontWeight.w600,
fontFamily: 'Microsoft YaHei UI',
fontFamilyFallback: const <String>['Microsoft YaHei', 'Segoe UI'],
),
),
textDirection: TextDirection.ltr,
)..layout();
final Rect r = Rect.fromCenter(
center: center,
width: tp.width + 8 * inv,
height: tp.height + 3 * inv,
);
final RRect rr = RRect.fromRectAndRadius(r, Radius.circular(4 * inv));
canvas.drawRRect(rr, Paint()..color = t.panel.withValues(alpha: 0.94));
canvas.drawRRect(
rr,
Paint()
..style = PaintingStyle.stroke
..strokeWidth = 1 * inv
..color = const Color(0xFF0F766E).withValues(alpha: 0.5),
);
tp.paint(canvas, r.center - Offset(tp.width / 2, tp.height / 2));
}
static String _fmtDim(double v) => (v - v.roundToDouble()).abs() < 0.05
? v.round().toString()
: v.toStringAsFixed(1);
/// 绘制连线(吸附端实时求边框交点;直线 / 正交折线;箭头 + 标签)。 /// 绘制连线(吸附端实时求边框交点;直线 / 正交折线;箭头 + 标签)。
void _connector(Canvas canvas, ArchConnector c) { void _connector(Canvas canvas, ArchConnector c) {
@@ -1267,7 +1206,11 @@ class ArchPainter extends CustomPainter {
} }
continue; 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 (c != null) {
if (!doc.isLayerVisible(c.layerId)) continue; if (!doc.isLayerVisible(c.layerId)) continue;
final ArchConnGeometry g = final ArchConnGeometry g =
+19 -102
View File
@@ -1,22 +1,15 @@
/// 图元库(电气符号 / 通用图元)数据层。 /// 图元库(内置图形图元)数据层。
/// ///
/// - 内置符号:[SymbolLibrary.builtin],随安装包发布(只读,代码内定义); /// - 内置符号:[SymbolLibrary.builtin],随安装包发布(只读,代码内定义);
/// - 用户符号:`library/symbols/*.symbol.json`(见 `app_paths.dart`),
/// 可新增 / 覆盖 / 删除,跨工程复用;
/// - 坐标约定:符号在 **100×100 归一化画布** 内绘制((0,0) 左上、(100,100) /// - 坐标约定:符号在 **100×100 归一化画布** 内绘制((0,0) 左上、(100,100)
/// 右下),引脚 [SymPin] 位于边界附近;实际绘制时按目标矩形等比换算; /// 右下),引脚 [SymPin] 位于边界附近;实际绘制时按目标矩形等比换算;
/// - 单位:与画布一致(1 世界单位 = 1 mm)。 /// - 单位:与画布一致(1 世界单位 = 1 mm)。
///
/// 供「电器原理图」等模块使用(P2:图元库先行;画布 / 布线后续接入)。
library; library;
import 'dart:convert'; import 'dart:convert';
import 'dart:io';
import 'dart:math' as math; import 'dart:math' as math;
import 'dart:ui' show Offset, Path, Rect; import 'dart:ui' show Offset, Path, Rect;
import '../persistence/app_paths.dart';
// ===================== 模型 ===================== // ===================== 模型 =====================
/// 符号基元类型。 /// 符号基元类型。
@@ -332,46 +325,10 @@ Rect symbolNaturalBounds(LibSymbol s) {
return Rect.fromLTWH(l!, t!, w, h).inflate(2); return Rect.fromLTWH(l!, t!, w, h).inflate(2);
} }
/// 运行时图元缓存(内置 + 用户;启动与导入 / 保存 / 删除后刷新)。 /// 图元库:内置符号(随安装包发布,只读)。
///
/// 绘制与手绘识别需要同步访问图元列表,故在内存中保持一份。
class SymbolCache {
SymbolCache._();
static List<LibSymbol> _all = List<LibSymbol>.of(SymbolLibrary.builtin);
static Map<String, LibSymbol> _byId = <String, LibSymbol>{
for (final LibSymbol s in SymbolLibrary.builtin) s.id: s,
};
/// 全部图元(内置 + 用户)。
static List<LibSymbol> get all => _all;
/// 按 id 查找图元。
static LibSymbol? byId(String id) => _byId[id];
/// 重新加载(应用启动 / 导入 / 保存 / 删除后调用)。
static Future<void> refresh() async {
final List<LibSymbol> list = await SymbolLibrary.all();
_all = list;
_byId = <String, LibSymbol>{
for (final LibSymbol s in list) s.id: s,
};
}
}
// ===================== 库(内置 + 用户) =====================
/// 图元库:内置符号 + 用户目录加载 / 保存 / 删除。
class SymbolLibrary { class SymbolLibrary {
SymbolLibrary._(); SymbolLibrary._();
/// 用户符号文件名后缀。
static const String fileSuffix = '.symbol.json';
/// 是否为内置符号 id(内置图元不可删除)。
static bool isBuiltinId(String id) =>
builtin.any((LibSymbol s) => s.id == id);
// 垂直元件的通用引脚(上 / 下)。 // 垂直元件的通用引脚(上 / 下)。
static const List<SymPin> _vpins = <SymPin>[ static const List<SymPin> _vpins = <SymPin>[
SymPin(id: '1', x: 50, y: 0, dir: 't'), SymPin(id: '1', x: 50, y: 0, dir: 't'),
@@ -580,61 +537,21 @@ class SymbolLibrary {
], ],
), ),
]; ];
}
/// 文件名安全化。
static String _safeId(String id) => /// 运行时图元缓存(内置;绘制与手写识别共用)。
id.replaceAll(RegExp(r'[^A-Za-z0-9_-]'), '_'); class SymbolCache {
SymbolCache._();
/// 用户符号目录(可注入用于测试)。
static Future<Directory> _dir(Directory? custom) async => static final List<LibSymbol> _all =
custom ?? await AppPaths.symbolsDir(); List<LibSymbol>.unmodifiable(SymbolLibrary.builtin);
static final Map<String, LibSymbol> _byId = <String, LibSymbol>{
/// 读取用户符号(目录缺失 / 文件损坏时跳过,不抛异常)。 for (final LibSymbol s in SymbolLibrary.builtin) s.id: s,
static Future<List<LibSymbol>> loadUser({Directory? dir}) async { };
try {
final Directory d = await _dir(dir); /// 全部图元(内置)。
if (!await d.exists()) return <LibSymbol>[]; static List<LibSymbol> get all => _all;
final List<LibSymbol> out = <LibSymbol>[];
await for (final FileSystemEntity e in d.list()) { /// 按 id 查找图元。
if (e is! File || !e.path.endsWith(fileSuffix)) continue; static LibSymbol? byId(String id) => _byId[id];
try {
out.add(LibSymbol.fromJson(
jsonDecode(await e.readAsString()) as Map<String, dynamic>));
} catch (_) {}
}
return out;
} catch (_) {
return <LibSymbol>[];
}
}
/// 全部符号:内置 + 用户(同 id 时用户覆盖内置)。
static Future<List<LibSymbol>> all({Directory? dir}) async {
final List<LibSymbol> user = await loadUser(dir: dir);
final Set<String> userIds = <String>{
for (final LibSymbol s in user) s.id,
};
return <LibSymbol>[
for (final LibSymbol s in builtin)
if (!userIds.contains(s.id)) s,
...user,
];
}
/// 保存用户符号(已存在同 id 时覆盖)。
static Future<void> saveUser(LibSymbol s, {Directory? dir}) async {
final Directory d = await _dir(dir);
await d.create(recursive: true);
final File f =
File('${d.path}${Platform.pathSeparator}${_safeId(s.id)}$fileSuffix');
await f.writeAsString(s.encode(), flush: true);
}
/// 删除用户符号;不存在时静默。
static Future<void> deleteUser(String id, {Directory? dir}) async {
final Directory d = await _dir(dir);
final File f =
File('${d.path}${Platform.pathSeparator}${_safeId(id)}$fileSuffix');
if (await f.exists()) await f.delete();
}
} }
+2 -5
View File
@@ -13,7 +13,6 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart'; import 'package:flutter/services.dart';
import 'license/license_service.dart'; import 'license/license_service.dart';
import 'library/symbol_library.dart';
import 'model/models.dart'; import 'model/models.dart';
import 'modules/module_registry.dart'; import 'modules/module_registry.dart';
import 'persistence/app_paths.dart'; import 'persistence/app_paths.dart';
@@ -65,8 +64,6 @@ class _SequenceDiagramAppState extends State<SequenceDiagramApp> {
_controller.goHome(); _controller.goHome();
// 素材库目录(library/symbols|images|templates):确保存在(失败静默)。 // 素材库目录(library/symbols|images|templates):确保存在(失败静默)。
AppPaths.ensureLibrary(); AppPaths.ensureLibrary();
// 图元库缓存(内置 + library/symbols/*.symbol.json):绘制与识别共用。
SymbolCache.refresh();
_controller.addListener(_updateWindowTitle); _controller.addListener(_updateWindowTitle);
// 启动即校验授权(读取可执行文件同级 license/*.lic)。 // 启动即校验授权(读取可执行文件同级 license/*.lic)。
LicenseService.instance.init().then((LicenseInfo info) { LicenseService.instance.init().then((LicenseInfo info) {
@@ -97,7 +94,7 @@ class _SequenceDiagramAppState extends State<SequenceDiagramApp> {
// 标题走模块注册表(首页显示品牌名,不带文件名)。 // 标题走模块注册表(首页显示品牌名,不带文件名)。
if (_controller.appMode == AppMode.home) { if (_controller.appMode == AppMode.home) {
_windowChannel _windowChannel
.invokeMethod<void>('setTitle', 'EDC|易得设计') .invokeMethod<void>('setTitle', 'EDC易得')
.catchError((Object _) {}); .catchError((Object _) {});
return; return;
} }
@@ -180,7 +177,7 @@ class _SequenceDiagramAppState extends State<SequenceDiagramApp> {
builder: (BuildContext context, Widget? child) { builder: (BuildContext context, Widget? child) {
final Tokens tokens = Tokens.of(_controller.brightness); final Tokens tokens = Tokens.of(_controller.brightness);
return MaterialApp( return MaterialApp(
title: 'EDC|易得设计 · Easy Design Collection', title: 'EDC易得 · Easy Design Collection',
debugShowCheckedModeBanner: false, debugShowCheckedModeBanner: false,
theme: buildTheme(tokens), theme: buildTheme(tokens),
// 固定文本缩放;系统栏图标随主题亮度自动切换(透明系统栏, // 固定文本缩放;系统栏图标随主题亮度自动切换(透明系统栏,
+2 -2
View File
@@ -63,7 +63,7 @@ const List<EdcModule> kModules = <EdcModule>[
suffix: '.arch.json', suffix: '.arch.json',
available: true, available: true,
defaultName: '未命名-架构图', defaultName: '未命名-架构图',
blurb: '手绘识别 · 图元库', blurb: '手绘识别 · 图形库',
), ),
EdcModule( EdcModule(
id: 'sequence', id: 'sequence',
@@ -145,5 +145,5 @@ EdcModule? moduleOf(AppMode m) {
/// AppMode → 窗口标题用模块名(首页用品牌名)。 /// AppMode → 窗口标题用模块名(首页用品牌名)。
String appModeLabel(AppMode m) { String appModeLabel(AppMode m) {
final EdcModule? mod = moduleOf(m); final EdcModule? mod = moduleOf(m);
return mod == null ? 'EDC|易得设计' : 'EDC|易得设计 · ${mod.name}设计'; return mod == null ? 'EDC易得' : 'EDC易得 · ${mod.name}设计';
} }
+61 -29
View File
@@ -10,7 +10,7 @@ library;
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:io' show File; import 'dart:io' show File, Platform;
import 'dart:math' as math; import 'dart:math' as math;
import 'dart:typed_data'; import 'dart:typed_data';
@@ -435,10 +435,55 @@ class AppController extends ChangeNotifier {
ArchTool.select => '工具:选择', ArchTool.select => '工具:选择',
ArchTool.pen => '工具:手绘(松手自动识别)', ArchTool.pen => '工具:手绘(松手自动识别)',
ArchTool.connect => '工具:连线(拖到图形自动吸附)', ArchTool.connect => '工具:连线(拖到图形自动吸附)',
ArchTool.eraser => '工具:橡皮(拖过图形 / 墨迹 / 连线即擦除)',
}; };
notifyListeners(); notifyListeners();
} }
/// 手绘是否「松手自动识别」。
///
/// 关闭时:笔迹先保留为墨迹,点「识别」按钮统一确认识别——平板手写
/// 识别误判较多时的推荐模式(安卓默认关闭,桌面默认开启)。
bool _archAutoRecognize = !Platform.isAndroid;
/// 手绘是否松手自动识别。
bool get archAutoRecognize => _archAutoRecognize;
/// 切换手绘识别模式(自动 / 手动确认)。
void setArchAutoRecognize(bool on) {
if (_archAutoRecognize == on) return;
_archAutoRecognize = on;
_status = on
? '手绘:松手自动识别'
: '手绘:手动确认识别(画完点顶部「识别」按钮)';
notifyListeners();
}
/// 橡皮擦开始:压一次撤销快照(一次连续擦除 = 一步撤销)。
void beginArchErase() {
_undo.add(_project);
if (_undo.length > 200) _undo.removeAt(0);
_redo.clear();
}
/// 擦除对象(图形 / 墨迹 / 连线;不入撤销栈,由 [beginArchErase] 快照统一回退)。
///
/// 返回实际擦除数量;删除图形时吸附其上的连线一并移除。
int eraseArchIds(Set<String> ids) {
final Set<String> hit = <String>{
for (final String id in ids)
if (arch.shapeById(id) != null ||
arch.strokeById(id) != null ||
arch.connectorById(id) != null)
id,
};
if (hit.isEmpty) return 0;
_project = _project.copyWith(arch: arch.removeIds(hit));
_dirty = true;
notifyListeners();
return hit.length;
}
// ===================== 参数化草图 ===================== // ===================== 参数化草图 =====================
/// 是否处于参数化草图模式。 /// 是否处于参数化草图模式。
@@ -850,34 +895,6 @@ class AppController extends ChangeNotifier {
]); ]);
} }
// ---- 识别后图形的尺寸编辑(不走约束求解器:直接缩放几何) ----
/// 修改图形尺寸(识别后图形 / 曲线 / 图元直接改值缩放)。
void setArchShapeDim(String id, ArchDimKind kind, double value) {
final ArchShape? s = arch.shapeById(id);
if (s == null || value <= 0) return;
updateArchShape(
archShapeApplyDim(s, kind, value),
status: '${s.text.isNotEmpty ? s.text : archShapeTypeLabel(s.type)}'
':${archDimKindLabel(kind)} → ${value.toStringAsFixed(1)} mm',
);
}
/// 切换画布尺寸标注(显示 / 隐藏;双击标签可改值)。
void toggleArchShapeDim(String id, ArchDimKind kind) {
final ArchShape? s = arch.shapeById(id);
if (s == null) return;
final Set<ArchDimKind> next = Set<ArchDimKind>.of(s.dims);
final bool removed = next.remove(kind);
if (!removed) next.add(kind);
updateArchShape(
s.copyWith(dims: next),
status: removed
? '已取消${archDimKindLabel(kind)}标注'
: '已标注${archDimKindLabel(kind)}(双击标签可改值)',
);
}
/// 删除选中的草图对象。 /// 删除选中的草图对象。
void deleteSketchSelection() { void deleteSketchSelection() {
if (_sketchSelIds.isEmpty) return; if (_sketchSelIds.isEmpty) return;
@@ -1441,6 +1458,21 @@ class AppController extends ChangeNotifier {
archFit(); archFit();
} }
/// 识别当前墨迹(不载入示例):把画布上待识别的笔迹逐笔转化。
///
/// 顶部「识别(N)」按钮与手动确认识别模式使用;没有墨迹时只给提示。
void archRecognizeInk() {
if (arch.strokes.isEmpty) {
_status = '没有待识别的墨迹(先用「手绘」画几笔)';
notifyListeners();
return;
}
_archSelIds = const <String>[];
_archPlayToken++;
_status = '识别中:逐笔转化(${arch.strokes.length} 笔)…';
notifyListeners();
}
/// 清空架构图。 /// 清空架构图。
void archClear() { void archClear() {
_archSelIds = const <String>[]; _archSelIds = const <String>[];
+47 -3
View File
@@ -727,6 +727,7 @@ class _AppShellState extends State<AppShell> {
onOpenSettings: () => _handleBrandCommand('_settings'), onOpenSettings: () => _handleBrandCommand('_settings'),
onOpenHelp: () => onOpenHelp: () =>
showDialog<void>(context: context, builder: (_) => const HelpDialog()), showDialog<void>(context: context, builder: (_) => const HelpDialog()),
onCheckUpdate: _openUpdate,
), ),
); );
} }
@@ -928,6 +929,8 @@ class _AppShellState extends State<AppShell> {
if (!mounted) return; if (!mounted) return;
await showDialog<void>( await showDialog<void>(
context: context, context: context,
// 点对话框外灰色区域不关闭(下载中防误触退出)。
barrierDismissible: false,
builder: (_) => UpdateDialog(controller: c, info: info!), builder: (_) => UpdateDialog(controller: c, info: info!),
); );
} }
@@ -1206,11 +1209,51 @@ class _AppShellState extends State<AppShell> {
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
seg('选择', Icons.near_me_outlined, ArchTool.select, '选择 / 移动 / 缩放'), seg('选择', Icons.near_me_outlined, ArchTool.select, '选择 / 移动 / 缩放'),
seg('手绘', Icons.gesture, ArchTool.pen, '按住拖动绘制,松手自动识别为标准图形'), seg('手绘', Icons.gesture, ArchTool.pen,
seg('连线', Icons.arrow_right_alt, ArchTool.connect, '从图形拖到另一个图形'), c.archAutoRecognize ? '按住拖动绘制,松手自动识别' : '按住拖动绘制;画完点「识别」确认识别'),
seg('连线', Icons.arrow_right_alt, ArchTool.connect,
'从图形拖到另一个图形(横平竖直正交走线,角点可拖拽)'),
seg('橡皮', Icons.cleaning_services_outlined, ArchTool.eraser,
'擦除图形 / 墨迹 / 连线(拖动连擦,一次撤销可整体回退)'),
], ],
), ),
), ),
SizedBox(width: 6 * _toolScale),
// 「识别」确认按钮:手动模式下把待识别墨迹统一识别(自动模式下也可用)。
Container(
padding: EdgeInsets.all(3 * _toolScale),
decoration: BoxDecoration(
color: t.panel,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: t.line2),
),
child: InkWell(
onTap: c.arch.strokes.isEmpty ? null : c.archRecognizeInk,
borderRadius: BorderRadius.circular(9),
child: Container(
height: 34 * _toolScale,
padding: EdgeInsets.symmetric(horizontal: 12 * _toolScale),
alignment: Alignment.center,
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Icon(Icons.auto_fix_high,
size: 15 * _toolScale,
color: c.arch.strokes.isEmpty ? t.dim : t.accent),
SizedBox(width: 5 * _toolScale),
Text(
'识别(${c.arch.strokes.length})',
style: TextStyle(
color: c.arch.strokes.isEmpty ? t.dim : t.accent,
fontSize: _toolFont(11),
fontWeight: FontWeight.w600,
),
),
],
),
),
),
),
], ],
); );
} }
@@ -2837,8 +2880,9 @@ class _AppShellState extends State<AppShell> {
? '草图·${sketchToolLabel(c.sketchTool)}' ? '草图·${sketchToolLabel(c.sketchTool)}'
: switch (c.archTool) { : switch (c.archTool) {
ArchTool.select => '选择', ArchTool.select => '选择',
ArchTool.pen => '手绘识别', ArchTool.pen => c.archAutoRecognize ? '手绘识别' : '手绘(待确认)',
ArchTool.connect => '连线', ArchTool.connect => '连线',
ArchTool.eraser => '橡皮',
}; };
final List<String> items = <String>[ final List<String> items = <String>[
c.sketchMode ? '参数化草图' : '架构图模式', c.sketchMode ? '参数化草图' : '架构图模式',
+33 -560
View File
@@ -6,83 +6,15 @@
/// 外层容器(宽度 / 边框 / 标题栏)由 `app_shell.dart` 负责,本文件只提供主体。 /// 外层容器(宽度 / 边框 / 标题栏)由 `app_shell.dart` 负责,本文件只提供主体。
library; library;
import 'dart:convert';
import 'dart:io' show File;
import 'dart:math' as math;
import 'dart:typed_data';
import 'dart:ui' show PathMetric, Tangent;
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import '../arch/arch_models.dart'; import '../arch/arch_models.dart';
import '../arch/arch_painter.dart';
import '../arch/arch_samples.dart';
import '../library/symbol_library.dart';
import '../persistence/android_docs.dart';
import '../sketch/sketch_models.dart'; import '../sketch/sketch_models.dart';
import '../sketch/sketch_solver.dart'; import '../sketch/sketch_solver.dart';
import '../state/app_controller.dart'; import '../state/app_controller.dart';
import '../theme/tokens.dart'; import '../theme/tokens.dart';
import 'dialogs.dart'; import 'dialogs.dart';
/// 尺寸改值对话框(识别后图形 / 曲线 / 图元;右栏与画布标签共用逻辑)。
Future<void> _editShapeDim(
BuildContext context,
AppController c,
ArchShape s,
ArchDimKind k,
) async {
final double cur = archShapeDimValue(s, k);
final String? input = await showTextEditDialog(
context,
title: '编辑${archDimKindLabel(k)}(当前 ${cur.toStringAsFixed(1)} mm)',
initial: cur.toStringAsFixed(1),
);
if (input == null) return;
final double? v = double.tryParse(input.trim());
if (v == null || v <= 0) {
c.setStatus('数值无效:请输入正数');
return;
}
c.setArchShapeDim(s.id, k, v);
}
/// 图元预览画笔(100×100 归一化盒 → 控件尺寸;跳过文字保证小尺寸清晰)。
class _SymPreviewPainter extends CustomPainter {
/// 构造。
_SymPreviewPainter(this.symbol, this.color);
final LibSymbol symbol;
final Color color;
/// 绘制。
@override
void paint(Canvas canvas, Size size) {
if (size.width <= 0 || size.height <= 0) return;
canvas.save();
canvas.scale(size.width / 100, size.height / 100);
const Rect box = Rect.fromLTWH(0, 0, 100, 100);
final Paint stroke = Paint()
..style = PaintingStyle.stroke
..strokeWidth = 100 / size.width * 0.9
..strokeCap = StrokeCap.round
..strokeJoin = StrokeJoin.round
..color = color;
for (final SymPrim p in symbol.prims) {
if (p.kind == SymPrimKind.text) continue;
final Path? path = symPrimPath(p, box);
if (path == null) continue;
canvas.drawPath(path, stroke);
}
canvas.restore();
}
/// 是否需要重绘。
@override
bool shouldRepaint(covariant _SymPreviewPainter old) =>
old.symbol.id != symbol.id || old.color != color;
}
/// 小节标题。 /// 小节标题。
Widget _sec(Tokens t, String s) => Text( Widget _sec(Tokens t, String s) => Text(
s, s,
@@ -116,9 +48,28 @@ class ArchLeftBody extends StatelessWidget {
_sec(t, '手绘识别'), _sec(t, '手绘识别'),
const SizedBox(height: 8), const SizedBox(height: 8),
Text( Text(
'松手自动把笔迹扶正为标准图形(矩形 / 圆 / 箭头 / 折线 / 曲线):' '笔迹一律扶正为标准图形(矩形 / 圆 / 箭头 / 折线 / 曲线):支持两笔组合、'
'支持两笔组合(如两笔试画一个矩形)与圆柱(顶盖 + 柱体);' '圆柱拼接;识别不了的保留为墨迹,可用「橡皮」擦除。文字请双击图形 / 空白处直接输入。',
'识别不了的笔迹会保留为墨迹。文字请双击图形 / 空白处直接输入。', style: TextStyle(color: t.dim, fontSize: 10, height: 1.5),
),
const SizedBox(height: 6),
Row(
children: <Widget>[
Expanded(
child: Text('松手自动识别',
style: TextStyle(color: t.sub, fontSize: 11)),
),
Switch(
value: c.archAutoRecognize,
onChanged: c.setArchAutoRecognize,
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
),
],
),
if (!c.archAutoRecognize)
Text(
'已关闭:笔迹先保留为墨迹(${c.arch.strokes.length} 笔待识别),'
'点顶部「识别」按钮统一确认(平板手写推荐)。',
style: TextStyle(color: t.dim, fontSize: 10, height: 1.5), style: TextStyle(color: t.dim, fontSize: 10, height: 1.5),
), ),
const SizedBox(height: 14), const SizedBox(height: 14),
@@ -273,8 +224,8 @@ class ArchLeftBody extends StatelessWidget {
const SizedBox(height: 14), const SizedBox(height: 14),
_sec(t, '连线'), _sec(t, '连线'),
const SizedBox(height: 6), const SizedBox(height: 6),
Text('按住左键画出路径 → 松手自动识别为直线 / 折线(近轴段扶正);' Text('画路径即出连线,一律横平竖直(正交);端点自动吸附图元边框,'
'端点自动吸附图元边框;选中后可拖动折点继续编辑。', '选中后拖拽路径上的角点可调整走线位置。',
style: TextStyle(color: t.dim, fontSize: 10, height: 1.5)), style: TextStyle(color: t.dim, fontSize: 10, height: 1.5)),
const SizedBox(height: 14), const SizedBox(height: 14),
_sec(t, '图形库'), _sec(t, '图形库'),
@@ -313,8 +264,6 @@ class ArchLeftBody extends StatelessWidget {
ArchShapeType.queue), ArchShapeType.queue),
], ],
), ),
const SizedBox(height: 10),
_SymbolLibPanel(controller: c),
const SizedBox(height: 14), const SizedBox(height: 14),
_sec(t, '颜色'), _sec(t, '颜色'),
const SizedBox(height: 8), const SizedBox(height: 8),
@@ -328,52 +277,12 @@ class ArchLeftBody extends StatelessWidget {
Text('影响新绘制的图形;选中图形后点色块可直接换色(支持多选)。', Text('影响新绘制的图形;选中图形后点色块可直接换色(支持多选)。',
style: TextStyle(color: t.dim, fontSize: 10, height: 1.5)), style: TextStyle(color: t.dim, fontSize: 10, height: 1.5)),
const SizedBox(height: 14), const SizedBox(height: 14),
_sec(t, '示例场景'), SizedBox(
const SizedBox(height: 8), width: double.infinity,
Row( child: TextButton.icon(
children: <Widget>[
Expanded(
child: OutlinedButton(
onPressed: () => c.archLoadDemo(ArchDemoKind.ink),
style: _btnStyle(),
child: const Text('手绘稿'),
),
),
const SizedBox(width: 8),
Expanded(
child: FilledButton(
onPressed: c.archPlayDemo,
style: FilledButton.styleFrom(
visualDensity: VisualDensity.compact,
textStyle: const TextStyle(
fontSize: 11.5,
fontFamily: 'Microsoft YaHei UI',
fontFamilyFallback: <String>[
'Microsoft YaHei',
'Segoe UI',
'sans-serif',
],
),
),
child: const Text('识别演示 ▶'),
),
),
],
),
const SizedBox(height: 8),
Row(
children: <Widget>[
Expanded(
child: OutlinedButton(
onPressed: () => c.archLoadDemo(ArchDemoKind.done),
style: _btnStyle(),
child: const Text('完成图'),
),
),
const SizedBox(width: 8),
Expanded(
child: TextButton(
onPressed: c.archClear, onPressed: c.archClear,
icon: const Icon(Icons.delete_sweep_outlined, size: 15),
label: const Text('清空画布'),
style: TextButton.styleFrom( style: TextButton.styleFrom(
foregroundColor: t.danger, foregroundColor: t.danger,
visualDensity: VisualDensity.compact, visualDensity: VisualDensity.compact,
@@ -387,11 +296,8 @@ class ArchLeftBody extends StatelessWidget {
], ],
), ),
), ),
child: const Text('清空画布'),
), ),
), ),
],
),
const SizedBox(height: 14), const SizedBox(height: 14),
Container( Container(
padding: const EdgeInsets.all(10), padding: const EdgeInsets.all(10),
@@ -523,20 +429,6 @@ class ArchLeftBody extends StatelessWidget {
), ),
); );
} }
/// 小尺寸描边按钮样式。
ButtonStyle _btnStyle() => OutlinedButton.styleFrom(
visualDensity: VisualDensity.compact,
textStyle: const TextStyle(
fontSize: 11.5,
fontFamily: 'Microsoft YaHei UI',
fontFamilyFallback: <String>[
'Microsoft YaHei',
'Segoe UI',
'sans-serif',
],
),
);
} }
/// 架构图右侧栏主体:选中对象属性(支持多选)。 /// 架构图右侧栏主体:选中对象属性(支持多选)。
@@ -666,59 +558,6 @@ class ArchRightBody extends StatelessWidget {
_mini(t, '删除(Del)', c.removeArchSelection, danger: true), _mini(t, '删除(Del)', c.removeArchSelection, danger: true),
], ],
), ),
const SizedBox(height: 10),
Text('尺寸(点数值修改 · 右键图标在画布上标注)',
style: TextStyle(color: t.dim, fontSize: 10)),
const SizedBox(height: 4),
for (final ArchDimKind k in archShapeDimKinds(s))
Padding(
padding: const EdgeInsets.only(bottom: 3),
child: Row(
children: <Widget>[
SizedBox(
width: 34,
child: Text(archDimKindLabel(k),
style: TextStyle(color: t.dim, fontSize: 11)),
),
InkWell(
onTap: () => _editShapeDim(context, c, s, k),
borderRadius: BorderRadius.circular(5),
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 6, vertical: 2),
decoration: BoxDecoration(
color: t.panel2,
borderRadius: BorderRadius.circular(5),
border: Border.all(color: t.line),
),
child: Text(
'${archShapeDimValue(s, k).toStringAsFixed(1)} mm',
style: TextStyle(
color: t.accent2,
fontSize: 11,
fontWeight: FontWeight.w600,
),
),
),
),
const Spacer(),
InkWell(
onTap: () => c.toggleArchShapeDim(s.id, k),
borderRadius: BorderRadius.circular(6),
child: Padding(
padding: const EdgeInsets.all(3),
child: Icon(
s.dims.contains(k)
? Icons.label
: Icons.label_outline,
size: 14,
color: s.dims.contains(k) ? t.accent : t.dim,
),
),
),
],
),
),
]) ])
else if (cn != null) else if (cn != null)
_card(t, <Widget>[ _card(t, <Widget>[
@@ -734,25 +573,10 @@ class ArchRightBody extends StatelessWidget {
cn.label.isEmpty ? '(无标签)' : '标签:${cn.label}', cn.label.isEmpty ? '(无标签)' : '标签:${cn.label}',
style: TextStyle(color: t.sub, fontSize: 11), style: TextStyle(color: t.sub, fontSize: 11),
), ),
const SizedBox(height: 8), const SizedBox(height: 4),
Row( Text(
children: <Widget>[ '走线:一律正交(横平竖直);拖拽路径上的角点可调整走线位置。',
_mini( style: TextStyle(color: t.dim, fontSize: 10.5, height: 1.5),
t,
'直线',
() => c.updateArchConnector(
cn.copyWith(route: ArchRoute.straight), status: '走线:直线'),
active: cn.route == ArchRoute.straight,
),
const SizedBox(width: 6),
_mini(
t,
'正交折线',
() => c.updateArchConnector(
cn.copyWith(route: ArchRoute.ortho), status: '走线:正交折线'),
active: cn.route == ArchRoute.ortho,
),
],
), ),
const SizedBox(height: 6), const SizedBox(height: 6),
Row( Row(
@@ -1233,354 +1057,3 @@ class ArchRightBody extends StatelessWidget {
} }
} }
} }
// ===================== 图元库面板(可折叠 · Visio 式) =====================
/// 图元库面板:按分类折叠展示(默认全部收起,只展开选中的库),
/// 点图元即插入画布;用户图元可删除;支持导入与「从选中图形存为图元」。
class _SymbolLibPanel extends StatefulWidget {
/// 构造。
const _SymbolLibPanel({required this.controller});
/// 全局应用控制器。
final AppController controller;
/// 创建状态。
@override
State<_SymbolLibPanel> createState() => _SymbolLibPanelState();
}
/// 面板状态:记录当前展开的分类(同时只允许一个)。
class _SymbolLibPanelState extends State<_SymbolLibPanel> {
String? _openCategory;
/// 构建。
@override
Widget build(BuildContext context) {
final Tokens t = context.tok;
final AppController c = widget.controller;
final Map<String, List<LibSymbol>> groups = <String, List<LibSymbol>>{};
for (final LibSymbol s in SymbolCache.all) {
groups.putIfAbsent(s.category, () => <LibSymbol>[]).add(s);
}
final List<String> cats = groups.keys.toList();
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Row(
children: <Widget>[
Text('图元库(可扩展)',
style: TextStyle(color: t.dim, fontSize: 10)),
const Spacer(),
InkWell(
onTap: () => _symImport(context, c),
borderRadius: BorderRadius.circular(6),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
child: Text('导入图元…',
style: TextStyle(
color: t.accent,
fontSize: 10.5,
fontWeight: FontWeight.w600)),
),
),
],
),
const SizedBox(height: 4),
for (final String cat in cats) ...<Widget>[
InkWell(
onTap: () => setState(() =>
_openCategory = _openCategory == cat ? null : cat),
borderRadius: BorderRadius.circular(7),
child: Container(
padding:
const EdgeInsets.symmetric(horizontal: 8, vertical: 5),
margin: const EdgeInsets.only(bottom: 3),
decoration: BoxDecoration(
color: _openCategory == cat
? t.accent.withValues(alpha: 0.10)
: t.panel2,
borderRadius: BorderRadius.circular(7),
border: Border.all(
color: _openCategory == cat
? t.accent.withValues(alpha: 0.5)
: t.line,
),
),
child: Row(
children: <Widget>[
Icon(
_openCategory == cat
? Icons.expand_less
: Icons.expand_more,
size: 15,
color: _openCategory == cat ? t.accent : t.sub,
),
const SizedBox(width: 6),
Expanded(
child: Text(
'$cat(${groups[cat]!.length})',
style: TextStyle(
color: _openCategory == cat ? t.accent : t.sub,
fontSize: 11,
fontWeight: _openCategory == cat
? FontWeight.w700
: FontWeight.w500,
),
),
),
],
),
),
),
if (_openCategory == cat)
Padding(
padding: const EdgeInsets.only(left: 6, right: 2, bottom: 4),
child: Wrap(
spacing: 6,
runSpacing: 6,
children: <Widget>[
for (final LibSymbol sym in groups[cat]!) _symCard(t, c, sym),
],
),
),
],
const SizedBox(height: 4),
SizedBox(
width: double.infinity,
child: OutlinedButton.icon(
onPressed:
c.archSelIds.isEmpty ? null : () => _symFromSelection(context, c),
icon: const Icon(Icons.add_box_outlined, size: 15),
label: const Text('从选中图形存为图元'),
style: OutlinedButton.styleFrom(
visualDensity: VisualDensity.compact,
textStyle: const TextStyle(
fontSize: 11.5,
fontFamily: 'Microsoft YaHei UI',
fontFamilyFallback: <String>[
'Microsoft YaHei',
'Segoe UI',
'sans-serif',
],
),
),
),
),
],
);
}
}
/// 图元卡片(预览 + 名称;用户图元带删除角标)。
Widget _symCard(Tokens t, AppController c, LibSymbol sym) {
final bool user = !SymbolLibrary.isBuiltinId(sym.id);
return InkWell(
onTap: () => _insertSymbolShape(c, sym),
borderRadius: BorderRadius.circular(9),
child: Container(
width: 82,
height: 64,
decoration: BoxDecoration(
color: t.panel2,
borderRadius: BorderRadius.circular(9),
border: Border.all(color: t.line),
),
child: Stack(
children: <Widget>[
Positioned.fill(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 34,
height: 30,
child: CustomPaint(
painter: _SymPreviewPainter(sym, t.sub),
),
),
const SizedBox(height: 2),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 3),
child: Text(
sym.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: t.sub, fontSize: 9.5),
),
),
],
),
),
if (user)
Positioned(
right: 0,
top: 0,
child: InkWell(
onTap: () => _symDelete(c, sym),
borderRadius: BorderRadius.circular(8),
child: Padding(
padding: const EdgeInsets.all(3),
child: Icon(Icons.close, size: 12, color: t.dim),
),
),
),
],
),
),
);
}
/// 插入图元库符号(保持图元纵横比,位置在视口中心、可吸附网格)。
void _insertSymbolShape(AppController c, LibSymbol sym) {
final ArchDoc doc = c.arch;
final Size vp = c.archViewport;
final Offset center = vp.width < 10 || vp.height < 10
? const Offset(400, 300)
: Offset(
(vp.width / 2 - doc.panX) / doc.zoom,
(vp.height / 2 - doc.panY) / doc.zoom,
);
final Rect nat = symbolNaturalBounds(sym);
final double scale = 140 / math.max(nat.width, nat.height);
Rect r = Rect.fromCenter(
center: center,
width: nat.width * scale,
height: nat.height * scale,
);
if (doc.gridSnap && doc.gridSize > 1) {
final Offset tl = archSnapPoint(doc, r.topLeft);
r = Rect.fromLTWH(tl.dx, tl.dy, r.width, r.height);
}
final int color = c.archColor;
final ArchShape s = ArchShape(
id: archNewId('S', doc.allIds),
type: ArchShapeType.symbol,
symbolId: sym.id,
rect: r,
fill: archFillOf(color),
stroke: color,
sw: 1.8,
);
c.addArchShape(s);
c.selectArch(s.id);
}
/// 删除用户图元(内置图元不可删)。
Future<void> _symDelete(AppController c, LibSymbol sym) async {
await SymbolLibrary.deleteUser(sym.id);
await SymbolCache.refresh();
c.setStatus('已删除图元「${sym.name}」');
}
/// 导入图元文件(`*.symbol.json`;桌面文件浏览器 / 安卓公共目录)。
Future<void> _symImport(BuildContext context, AppController c) async {
try {
String content;
if (AndroidDocs.isAvailable) {
final String? name = await showDialog<String>(
context: context,
builder: (_) => const AndroidFileDialog(
saveMode: false,
defaultName: '',
suffix: '.symbol.json',
),
);
if (name == null) return;
final Uint8List? bytes = await AndroidDocs.readFile(name);
if (bytes == null) {
c.setStatus('导入失败:未找到文件 $name');
return;
}
content = utf8.decode(bytes);
} else {
final String? path = await pickFile(
context,
save: false,
suffix: '.symbol.json',
);
if (path == null) return;
content = await File(path).readAsString();
}
final LibSymbol sym =
LibSymbol.fromJson(jsonDecode(content) as Map<String, dynamic>);
if (sym.id.isEmpty || sym.prims.isEmpty) {
c.setStatus('导入失败:不是有效的图元文件');
return;
}
await SymbolLibrary.saveUser(sym);
await SymbolCache.refresh();
c.setStatus('已导入图元「${sym.name}」(${sym.category})');
} catch (e) {
c.setStatus('导入失败:$e');
}
}
/// 把当前选中的图形保存为图元(可多选;几何按选中范围归一化到 100×100)。
Future<void> _symFromSelection(BuildContext context, AppController c) async {
final List<ArchShape> sel = <ArchShape>[
for (final String id in c.archSelIds)
if (c.arch.shapeById(id) != null) c.arch.shapeById(id)!,
];
if (sel.isEmpty) {
c.setStatus('先选中要保存为图元的图形(可多选)');
return;
}
final String? name = await showTextEditDialog(
context,
title: '保存为图元(名称)',
initial: '自定义图元',
);
if (name == null || name.trim().isEmpty) return;
final LibSymbol sym = _symbolFromShapes(sel, name.trim());
await SymbolLibrary.saveUser(sym);
await SymbolCache.refresh();
c.setStatus('已保存图元「${sym.name}」到图元库(可点击插入 / 手绘识别)');
}
/// 由图形集合生成图元(采样轮廓为折线 + 文本)。
LibSymbol _symbolFromShapes(List<ArchShape> shapes, String name) {
Rect union = shapes.first.bounds;
for (final ArchShape s in shapes) {
union = union.expandToInclude(s.bounds);
}
final double scale = 100 / math.max(union.width, union.height);
final Offset c0 = union.center;
Offset norm(Offset p) =>
Offset((p.dx - c0.dx) * scale + 50, (p.dy - c0.dy) * scale + 50);
final List<SymPrim> prims = <SymPrim>[];
for (final ArchShape s in shapes) {
final Path path = archShapePath(s);
for (final PathMetric m in path.computeMetrics()) {
final int count =
math.max(6, (m.length * scale / 5).ceil()).clamp(6, 160);
final List<double> flat = <double>[];
for (int i = 0; i <= count; i++) {
final Tangent? t = m.getTangentForOffset(m.length * i / count);
if (t == null) continue;
final Offset n2 = norm(t.position);
flat.add(n2.dx);
flat.add(n2.dy);
}
if (flat.length >= 4) {
prims.add(SymPrim(kind: SymPrimKind.polyline, pts: flat));
}
}
if (s.text.isNotEmpty) {
final Offset n2 = norm(s.rect.center);
prims.add(SymPrim(
kind: SymPrimKind.text,
pts: <double>[n2.dx - s.text.length * 2.5, n2.dy - 5],
label: s.text,
));
}
}
return LibSymbol(
id: 'user-${DateTime.now().millisecondsSinceEpoch}',
name: name,
category: '自定义',
prims: prims,
pins: const <SymPin>[],
);
}
+521 -152
View File
@@ -26,6 +26,9 @@ import '../state/app_controller.dart';
import '../theme/tokens.dart'; import '../theme/tokens.dart';
import 'dialogs.dart'; import 'dialogs.dart';
/// 连线拖拽吸附结果:吸附后的坐标 + 对齐导引(null = 该轴无对齐)。
typedef ConnSnap = ({double x, double y, double? gx, double? gy});
/// 架构图画布组件。 /// 架构图画布组件。
class ArchView extends StatefulWidget { class ArchView extends StatefulWidget {
/// 构造画布;[controller] 为全局应用控制器。 /// 构造画布;[controller] 为全局应用控制器。
@@ -56,15 +59,29 @@ class _ArchViewState extends State<ArchView>
// ---- 连线草稿(按住左键画路径) ---- // ---- 连线草稿(按住左键画路径) ----
String? _connFromId; String? _connFromId;
// ---- 连线折点拖动 ---- // ---- 连线拖拽编辑(端点 / 折点 / 线段三种模式) ----
ArchConnector? _connVertexOrigin; ArchConnector? _connVertexOrigin;
int _connVertexIndex = 0;
List<Offset> _connVertexPts = <Offset>[];
ArchConnector? _connVertexUpdated; 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; String? _connDragTargetId;
/// 鼠标悬停在连线上(显示抓取光标)。
bool _hoverConn = false;
// ---- 平移 ---- // ---- 平移 ----
bool _panning = false; bool _panning = false;
Offset _panStartScreen = Offset.zero; Offset _panStartScreen = Offset.zero;
@@ -128,6 +145,10 @@ class _ArchViewState extends State<ArchView>
List<Offset> _lastConvPts = const <Offset>[]; List<Offset> _lastConvPts = const <Offset>[];
DateTime? _lastConvAt; DateTime? _lastConvAt;
// ---- 橡皮擦 ----
bool _erasing = false;
int _eraseCount = 0;
// ---- 组合识别缓存(两笔绘图 / 圆柱拼接) ---- // ---- 组合识别缓存(两笔绘图 / 圆柱拼接) ----
String? _lastInkId; String? _lastInkId;
DateTime? _lastInkAt; DateTime? _lastInkAt;
@@ -225,7 +246,8 @@ class _ArchViewState extends State<ArchView>
setState(() {}); setState(() {});
} }
/// 播放「识别演示」:把当前墨迹逐条识别,串行播放转化动画。 /// 播放「识别」:把当前墨迹逐条识别(图元库单笔 → 内置 → 与前一条组合),
/// 串行播放转化动画。手动确认识别模式与「识别 N」按钮共用。
Future<void> _startPlay() async { Future<void> _startPlay() async {
if (_playing) return; if (_playing) return;
_playing = true; _playing = true;
@@ -233,29 +255,112 @@ class _ArchViewState extends State<ArchView>
final List<String> ids = <String>[ final List<String> ids = <String>[
for (final ArchStroke s in c.arch.strokes) s.id, for (final ArchStroke s in c.arch.strokes) s.id,
]; ];
for (final String id in ids) {
if (!mounted || !_playing || _seenPlayToken != token) break; void convert(ArchShape shape, List<Offset> pts, Set<String> removeIds) {
final ArchStroke? st = c.arch.strokeById(id);
if (st == null) continue;
final ArchRecognition? r = recognizeArchStroke(st.pts);
if (r != null) {
final ArchShape shape = archShapeFromRecognition(
r,
id: archNewId('S', c.arch.allIds),
color: c.archColor,
);
_conversions.add(ArchConversion( _conversions.add(ArchConversion(
pts: st.pts, pts: pts,
shape: shape, shape: shape,
startMs: DateTime.now().millisecondsSinceEpoch.toDouble(), startMs: DateTime.now().millisecondsSinceEpoch.toDouble(),
undo: false, undo: false,
removeIds: <String>{id}, removeIds: removeIds,
)); ));
if (!_ticker.isActive) _ticker.start(); if (!_ticker.isActive) _ticker.start();
setState(() {}); setState(() {});
} }
await Future<void>.delayed(const Duration(milliseconds: 230));
Future<void> waitTick() =>
Future<void>.delayed(const Duration(milliseconds: 230));
ArchStroke? prev;
ArchRecognition? prevBuiltin;
Future<void> flushPrev() async {
final ArchStroke? p = prev;
final ArchRecognition? r0 = prevBuiltin;
prev = null;
prevBuiltin = null;
if (p == null || r0 == null) return;
convert(
_snapShapeToGrid(archShapeFromRecognition(r0,
id: archNewId('S', c.arch.allIds), color: c.archColor)),
p.pts,
<String>{p.id},
);
await waitTick();
} }
for (final String id in ids) {
if (!mounted || !_playing || _seenPlayToken != token) break;
final ArchStroke? st = c.arch.strokeById(id);
if (st == null) continue;
// 1) 图元库单笔。
final ArchSymbolMatch? m1 =
recognizeArchSymbol(<List<Offset>>[st.pts], SymbolCache.all);
if (m1 != null) {
await flushPrev();
convert(
_symbolShapeFor(m1.symbol, _ptsBounds(st.pts)),
st.pts,
<String>{id},
);
await waitTick();
continue;
}
final ArchRecognition? r = recognizeArchStroke(st.pts);
final bool weak = r == null ||
r.type == ArchShapeType.curve ||
r.type == ArchShapeType.polyline;
// 2) 内置强结果:直接转化。
if (!weak) {
await flushPrev();
convert(
_snapShapeToGrid(archShapeFromRecognition(r,
id: archNewId('S', c.arch.allIds), color: c.archColor)),
st.pts,
<String>{id},
);
await waitTick();
continue;
}
// 3) 弱结果 / 未识别:先与上一条尝试组合(图元库 → 内置两笔)。
if (prev != null) {
final ArchStroke p = prev!;
final ArchSymbolMatch? m2 = recognizeArchSymbol(
<List<Offset>>[p.pts, st.pts], SymbolCache.all);
if (m2 != null) {
prev = null;
prevBuiltin = null;
convert(
_symbolShapeFor(
m2.symbol,
_ptsBounds(p.pts).expandToInclude(_ptsBounds(st.pts)),
),
st.pts,
<String>{p.id, id},
);
await waitTick();
continue;
}
final ArchRecognition? r2 =
recognizeArchStrokes(<List<Offset>>[p.pts, st.pts]);
if (r2 != null && r2.type != ArchShapeType.line) {
prev = null;
prevBuiltin = null;
convert(
_snapShapeToGrid(archShapeFromRecognition(r2,
id: archNewId('S', c.arch.allIds), color: c.archColor)),
st.pts,
<String>{p.id, id},
);
await waitTick();
continue;
}
await flushPrev();
}
prev = st;
prevBuiltin = r;
}
await flushPrev();
_playing = false; _playing = false;
} }
@@ -268,8 +373,9 @@ class _ArchViewState extends State<ArchView>
); );
/// 命中测试:返回 (id, 图形?)。优先图形 → 连线 → 墨迹(后者在上层); /// 命中测试:返回 (id, 图形?)。优先图形 → 连线 → 墨迹(后者在上层);
/// 隐藏图层与锁定图层的对象不可选中。 /// 隐藏图层与锁定图层的对象不可选中。[connTol] > 0 时覆盖连线的命中宽容
(String?, ArchShape?) _hitTest(Offset world) { /// (平板 / 手指选中连线时放大)。
(String?, ArchShape?) _hitTest(Offset world, {double connTol = 0}) {
final ArchDoc doc = c.arch; final ArchDoc doc = c.arch;
for (int i = doc.shapes.length - 1; i >= 0; i--) { for (int i = doc.shapes.length - 1; i >= 0; i--) {
final ArchShape s = doc.shapes[i]; final ArchShape s = doc.shapes[i];
@@ -278,19 +384,11 @@ class _ArchViewState extends State<ArchView>
} }
if (s.hitTest(world)) return (s.id, s); if (s.hitTest(world)) return (s.id, s);
} }
final double tol = 8 / c.arch.zoom + 4; final ArchConnector? cn = _connAt(
for (int i = doc.connectors.length - 1; i >= 0; i--) { world,
final ArchConnector cn = doc.connectors[i]; connTol > 0 ? connTol : (8 / c.arch.zoom + 4),
if (!doc.isLayerVisible(cn.layerId) || doc.isLayerLocked(cn.layerId)) { );
continue; if (cn != null) return (cn.id, null);
}
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);
}
}
}
for (int i = doc.strokes.length - 1; i >= 0; i--) { for (int i = doc.strokes.length - 1; i >= 0; i--) {
final ArchStroke s = doc.strokes[i]; final ArchStroke s = doc.strokes[i];
if (!doc.isLayerVisible(s.layerId) || doc.isLayerLocked(s.layerId)) { if (!doc.isLayerVisible(s.layerId) || doc.isLayerLocked(s.layerId)) {
@@ -301,17 +399,199 @@ class _ArchViewState extends State<ArchView>
return (null, null); 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; final ArchDoc doc = c.arch;
for (int i = doc.shapes.length - 1; i >= 0; i--) { for (int i = doc.shapes.length - 1; i >= 0; i--) {
if (!doc.isLayerVisible(doc.shapes[i].layerId)) continue; 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; 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;
}
// ===================== 参数化草图:交互 ===================== // ===================== 参数化草图:交互 =====================
/// 草图按下:选择 / 拖拽(约束求解)/ 绘制 / 修剪。 /// 草图按下:选择 / 拖拽(约束求解)/ 绘制 / 修剪。
@@ -758,6 +1038,41 @@ class _ArchViewState extends State<ArchView>
c.setSketchDimValue(d.id, v); c.setSketchDimValue(d.id, v);
} }
/// 橡皮擦:擦除 [world] 附近的图形 / 墨迹 / 连线(不删除锁定图层的对象)。
void _eraseAt(Offset world) {
final ArchDoc doc = c.arch;
final double z = c.arch.zoom <= 0 ? 1 : c.arch.zoom;
final Set<String> ids = <String>{};
for (final ArchStroke s in doc.strokes) {
if (!doc.isLayerVisible(s.layerId) || doc.isLayerLocked(s.layerId)) {
continue;
}
if (s.hitTest(world, pad: 10 / z)) ids.add(s.id);
}
for (final ArchShape s in doc.shapes) {
if (!doc.isLayerVisible(s.layerId) || doc.isLayerLocked(s.layerId)) {
continue;
}
if (s.hitTest(world, pad: 6 / z)) ids.add(s.id);
}
for (final ArchConnector cn in doc.connectors) {
if (!doc.isLayerVisible(cn.layerId) || doc.isLayerLocked(cn.layerId)) {
continue;
}
final ArchConnGeometry g = archConnectorGeometry(doc, cn);
final double tol = 10 / z + 4;
for (int k = 0; k < g.pts.length - 1; k++) {
if (archDistToSegment(world, g.pts[k], g.pts[k + 1]) <= tol) {
ids.add(cn.id);
break;
}
}
}
if (ids.isEmpty) return;
_eraseCount += c.eraseArchIds(ids);
setState(() {});
}
// ===================== 指针事件 ===================== // ===================== 指针事件 =====================
/// 按下:进入捏合 / 平移 / 框选 / 手绘 / 连线 / 选择移动。 /// 按下:进入捏合 / 平移 / 框选 / 手绘 / 连线 / 选择移动。
@@ -802,6 +1117,14 @@ class _ArchViewState extends State<ArchView>
setState(() {}); setState(() {});
return; return;
} }
if (tool == ArchTool.eraser) {
// 橡皮:按下即开始擦除;连续拖动 = 一次撤销快照。
_erasing = true;
_eraseCount = 0;
c.beginArchErase();
_eraseAt(world);
return;
}
if (tool == ArchTool.connect) { if (tool == ArchTool.connect) {
// 按住左键画路径:松手后识别为直线 / 折线并吸附到图形边框。 // 按住左键画路径:松手后识别为直线 / 折线并吸附到图形边框。
_connFromId = _shapeAt(world)?.id; _connFromId = _shapeAt(world)?.id;
@@ -817,7 +1140,7 @@ class _ArchViewState extends State<ArchView>
if (soleSel != null && !soleSel.isLinear) { if (soleSel != null && !soleSel.isLinear) {
final List<Rect> hs = archHandleRects(soleSel.rect, c.arch.zoom); final List<Rect> hs = archHandleRects(soleSel.rect, c.arch.zoom);
for (int i = 0; i < hs.length; i++) { 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; _resizeHandle = i;
_resizeOrigin = soleSel; _resizeOrigin = soleSel;
_resizeRect = soleSel.rect; _resizeRect = soleSel.rect;
@@ -833,7 +1156,7 @@ class _ArchViewState extends State<ArchView>
soleSel.b != null soleSel.b != null
? <Offset>[soleSel.a!, soleSel.b!] ? <Offset>[soleSel.a!, soleSel.b!]
: soleSel.pts; : 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++) { for (int i = 0; i < vs.length; i++) {
if ((vs[i] - world).distance <= tol) { if ((vs[i] - world).distance <= tol) {
_vertexIndex = i; _vertexIndex = i;
@@ -844,38 +1167,56 @@ class _ArchViewState extends State<ArchView>
} }
} }
} }
// 连线折点拖动:所有折点可拖;端点拖到别的图形会重新吸附(松手生效)。 // 连线拖拽编辑(选中单条连线时):端点 / 折点 / 线段三种拖动。
// 针对平板 / 手指:命中半径加大;路径任意一段可整体平移。
final ArchConnector? soleConn = c.archSelIds.length == 1 final ArchConnector? soleConn = c.archSelIds.length == 1
? c.arch.connectorById(c.archSelId) ? c.arch.connectorById(c.archSelId)
: null; : null;
if (soleConn != null) { if (soleConn != null &&
final ArchConnGeometry g = archConnectorGeometry(c.arch, soleConn); c.arch.isLayerVisible(soleConn.layerId) &&
final double tol = 10 / c.arch.zoom; !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++) { for (int i = 0; i < g.pts.length; i++) {
if ((g.pts[i] - world).distance <= tol) { if ((g.pts[i] - world).distance > vTol) continue;
_connVertexOrigin = soleConn; if (i == 0 || i == last) {
// 端点:拖拽换吸附目标 / 脱离为自由端点(实时预览)。
_beginConnDrag(soleConn, 'endpoint');
_connVertexIndex = i; _connVertexIndex = i;
_connVertexPts = List<Offset>.of(g.pts); return;
_connDragTargetId = null; }
setState(() {}); // 吸附端的固定短桩不单独拖动,交给线段拖动。
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; return;
} }
} }
} }
// 尺寸标签:双击进入改值(识别后图形 / 曲线 / 图元可直接编辑尺寸)。 final (String?, ArchShape?) hit = _hitTest(
final (ArchShape, ArchDimKind)? dimHit = world,
archShapeDimHitAt(c.arch, world, c.arch.zoom); connTol: touch ? 20 / c.arch.zoom : 0,
if (dimHit != null) { );
final int now = DateTime.now().millisecondsSinceEpoch;
final bool dbl = now - _lastClickMs < 400 &&
(e.localPosition - _lastClickPos).distance < 28;
if (dbl) {
_lastClickMs = 0;
_editDimLabel(dimHit.$1, dimHit.$2);
return;
}
}
final (String?, ArchShape?) hit = _hitTest(world);
final String? id = hit.$1; final String? id = hit.$1;
final ArchShape? shape = hit.$2; final ArchShape? shape = hit.$2;
if (id != null) { if (id != null) {
@@ -974,6 +1315,10 @@ class _ArchViewState extends State<ArchView>
_sketchMove(world); _sketchMove(world);
return; return;
} }
if (_erasing) {
_eraseAt(world);
return;
}
// 触屏长按(原地停顿)转为框选。 // 触屏长按(原地停顿)转为框选。
if (_panning && _touchEmpty && !_marquee) { if (_panning && _touchEmpty && !_marquee) {
@@ -997,26 +1342,69 @@ class _ArchViewState extends State<ArchView>
return; return;
} }
if (_connVertexOrigin != null) { if (_connVertexOrigin != null) {
final int last = _connVertexPts.length - 1; final ArchConnector origin = _connVertexOrigin!;
final bool isEndpoint = final String mode = _connDragMode ?? 'corner';
_connVertexIndex == 0 || _connVertexIndex == last; if (mode == 'segment') {
Offset p = world; // 线段拖动:沿垂直方向整体平移(磁力吸附 + 导引虚线)。
if (isEndpoint) { final bool axisX = _connSegAxis == 'x';
// 端点:优先吸附到鼠标下的图形边框(可换目标重新吸附),无则脱离。 final ConnSnap snap = _snapConnCoord(
final ArchShape? target = _shapeAt(world); 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) { if (target != null) {
p = archNearestBorderPoint(target, world); p = archNearestBorderPoint(target, world);
_connDragTargetId = target.id; targetId = target.id;
} else { } else {
_connDragTargetId = null; snap = _snapConnCoord(world, origin);
if (c.arch.gridSnap) p = archSnapPoint(c.arch, world); p = Offset(snap.x, snap.y);
targetId = null;
} }
} else if (c.arch.gridSnap) { _connDragTargetId = targetId;
p = archSnapPoint(c.arch, world); _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 = final ConnSnap snap = _snapConnCoord(world, origin);
_applyConnVertices(_connVertexOrigin!, _connVertexIndex, _connVertexPts); _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(() {}); setState(() {});
return; return;
} }
@@ -1128,6 +1516,14 @@ class _ArchViewState extends State<ArchView>
_sketchUp(world, moved); _sketchUp(world, moved);
return; return;
} }
if (_erasing) {
_erasing = false;
if (_eraseCount > 0) {
c.setStatus('橡皮:已擦除 $_eraseCount 项(可一次撤销回退)');
}
setState(() {});
return;
}
if (_draft != null) { if (_draft != null) {
final List<Offset> pts = _draft!; final List<Offset> pts = _draft!;
@@ -1141,25 +1537,21 @@ class _ArchViewState extends State<ArchView>
return; return;
} }
if (_connVertexOrigin != null) { if (_connVertexOrigin != null) {
final int index = _connVertexIndex; final ArchConnector? done = _connVertexUpdated;
final int last = _connVertexPts.length - 1; final String mode = _connDragMode ?? 'corner';
final bool isEndpoint = index == 0 || index == last;
ArchConnector? done = _connVertexUpdated;
final String? targetId = _connDragTargetId; final String? targetId = _connDragTargetId;
_connVertexOrigin = null; _connVertexOrigin = null;
_connVertexPts = <Offset>[];
_connVertexUpdated = null; _connVertexUpdated = null;
_connDragMode = null;
_connDragTargetId = null; _connDragTargetId = null;
if (done != null && isEndpoint) { _connSegAxis = null;
// 端点松手:吸附到新图形(更新归属);空白处则脱离为自由端点。 _connSegSeed = null;
done = index == 0 _guideXs = const <double>[];
? done.copyWith(fromId: targetId) _guideYs = const <double>[];
: done.copyWith(toId: targetId);
}
if (done != null) { if (done != null) {
final String st = !isEndpoint final String st = mode == 'endpoint'
? '编辑连线折点' ? (targetId == null ? '连线端点:已脱离(自由端点)' : '连线端点:已吸附到图形')
: (targetId == null ? '连线端点:已脱离(自由端点)' : '连线端点:已吸附到图形'); : (mode == 'segment' ? '拖动连线路径' : '编辑连线折点');
c.updateArchConnector(done, status: st); c.updateArchConnector(done, status: st);
} }
setState(() {}); setState(() {});
@@ -1284,8 +1676,11 @@ class _ArchViewState extends State<ArchView>
_draft = null; _draft = null;
_connFromId = null; _connFromId = null;
_connVertexOrigin = null; _connVertexOrigin = null;
_connVertexPts = <Offset>[];
_connVertexUpdated = null; _connVertexUpdated = null;
_connDragMode = null;
_connDragTargetId = null;
_connSegAxis = null;
_connSegSeed = null;
_moveIds = <String>[]; _moveIds = <String>[];
_moveDeltas = null; _moveDeltas = null;
_guideXs = const <double>[]; _guideXs = const <double>[];
@@ -1354,8 +1749,6 @@ class _ArchViewState extends State<ArchView>
if (v.length < 2) return; if (v.length < 2) return;
final Offset p0 = v.first; final Offset p0 = v.first;
final Offset p1 = v.last; final Offset p1 = v.last;
final List<Offset> mids =
v.length > 2 ? v.sublist(1, v.length - 1) : const <Offset>[];
// 端点吸附:起点优先用按下时命中的图形;终点按松手位置命中。 // 端点吸附:起点优先用按下时命中的图形;终点按松手位置命中。
final ArchShape? sf = c.arch.shapeById(_connFromId) ?? _shapeAt(p0); final ArchShape? sf = c.arch.shapeById(_connFromId) ?? _shapeAt(p0);
final ArchShape? st = _shapeAt(p1); final ArchShape? st = _shapeAt(p1);
@@ -1368,6 +1761,15 @@ class _ArchViewState extends State<ArchView>
: (snap ? archSnapPoint(c.arch, p1) : p1); : (snap ? archSnapPoint(c.arch, p1) : p1);
_connFromId = null; _connFromId = null;
if ((to - from).distance < 12) return; if ((to - from).distance < 12) return;
// 连线一律正交:把手绘轨迹正交化(保留折点位置,所有段横平竖直)。
final List<Offset> ortho = orthoPolyline(<Offset>[
from,
...v.sublist(1, v.length - 1),
to,
]);
final List<Offset> mids = ortho.length > 2
? ortho.sublist(1, ortho.length - 1)
: const <Offset>[];
c.addArchConnector(ArchConnector( c.addArchConnector(ArchConnector(
id: archNewId('C', c.arch.allIds), id: archNewId('C', c.arch.allIds),
fromId: sf?.id, fromId: sf?.id,
@@ -1375,30 +1777,10 @@ class _ArchViewState extends State<ArchView>
toId: st?.id, toId: st?.id,
to: to, to: to,
mids: mids, mids: mids,
route: ArchRoute.ortho,
)); ));
} }
/// 把折点拖拽结果写回连线(中间折点 / 自由端点)。
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) { ArchShape _symbolShapeFor(LibSymbol sym, Rect b) {
final Rect nat = symbolNaturalBounds(sym); final Rect nat = symbolNaturalBounds(sym);
@@ -1429,23 +1811,6 @@ class _ArchViewState extends State<ArchView>
_startConversion(pts, _symbolShapeFor(sym, b), removeIds: removeIds); _startConversion(pts, _symbolShapeFor(sym, b), removeIds: removeIds);
} }
/// 双击尺寸标签:输入数值直接缩放图形(识别后图形 / 曲线 / 图元)。
Future<void> _editDimLabel(ArchShape s, ArchDimKind k) async {
final double cur = archShapeDimValue(s, k);
final String? input = await showTextEditDialog(
context,
title: '编辑${archDimKindLabel(k)}(当前 ${cur.toStringAsFixed(1)} mm)',
initial: cur.toStringAsFixed(1),
);
if (input == null || !mounted) return;
final double? v = double.tryParse(input.trim());
if (v == null || v <= 0) {
c.setStatus('数值无效:请输入正数');
return;
}
c.setArchShapeDim(s.id, k, v);
}
/// 提交手绘:统一按图形识别处理(识别失败保留墨迹),并尝试两笔组合识别。 /// 提交手绘:统一按图形识别处理(识别失败保留墨迹),并尝试两笔组合识别。
void _commitInk(List<Offset> pts) { void _commitInk(List<Offset> pts) {
if (pts.length < 5) return; if (pts.length < 5) return;
@@ -1455,6 +1820,18 @@ class _ArchViewState extends State<ArchView>
} }
if (len < 24) return; if (len < 24) return;
// 手动确认识别(平板推荐):只保留墨迹,点顶部「识别 N」按钮统一处理。
if (!c.archAutoRecognize) {
final ArchStroke st = ArchStroke(
id: archNewId('K', c.arch.allIds),
pts: pts,
color: c.archColor,
);
c.addArchStroke(st);
c.setStatus('墨迹已保留(${c.arch.strokes.length} 笔待识别)· 点顶部「识别」确认');
return;
}
// 图元库组合(回溯):2.5 秒内新笔迹先尝试与「上一步刚生成的图形」 // 图元库组合(回溯):2.5 秒内新笔迹先尝试与「上一步刚生成的图形」
// 合成图元(如 圆 + 叉 = 指示灯)——即使第一笔已被即时识别成标准图形。 // 合成图元(如 圆 + 叉 = 指示灯)——即使第一笔已被即时识别成标准图形。
final String? convId = _lastConvId; final String? convId = _lastConvId;
@@ -1542,21 +1919,7 @@ class _ArchViewState extends State<ArchView>
_lastInkId = null; _lastInkId = null;
_lastInkAt = null; _lastInkAt = null;
// 手绘箭头两端都落在图形上 → 直接生成吸附连线。 // 规则:手绘模式只出图形——连线请用「连线」工具(不再从箭头自动生成连线)。
if (r.type == ArchShapeType.line && r.a != null && r.b != null) {
final ArchShape? sf = _shapeAt(r.a!);
final ArchShape? st = _shapeAt(r.b!);
if (sf != null && st != null && sf.id != st.id) {
c.addArchConnector(ArchConnector(
id: archNewId('C', c.arch.allIds),
fromId: sf.id,
from: archNearestBorderPoint(sf, r.a!),
toId: st.id,
to: archNearestBorderPoint(st, r.b!),
));
return;
}
}
final ArchShape shape = final ArchShape shape =
_snapShapeToGrid(archShapeFromRecognition( _snapShapeToGrid(archShapeFromRecognition(
@@ -1743,14 +2106,20 @@ class _ArchViewState extends State<ArchView>
autofocus: true, autofocus: true,
onKeyEvent: _onKey, onKeyEvent: _onKey,
child: MouseRegion( child: MouseRegion(
cursor: c.archTool == ArchTool.pen cursor: _mouseCursor(),
? SystemMouseCursors.precise
: SystemMouseCursors.basic,
onHover: (PointerHoverEvent e) { onHover: (PointerHoverEvent e) {
final Offset w = _toWorld(e.localPosition); 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; final Offset? cur = _cursorWorld;
if (cur == null || (cur - w).distance > 0.4) { if (hover != _hoverConn ||
setState(() => _cursorWorld = w); cur == null ||
(cur - w).distance > 0.4) {
setState(() {
_cursorWorld = w;
_hoverConn = hover;
});
} }
}, },
onExit: (_) { onExit: (_) {
+10 -6
View File
@@ -1,4 +1,4 @@
/// 左上角品牌按钮 +「EDC|易得设计」设计合集菜单。 /// 左上角品牌按钮 +「EDC易得」设计合集菜单。
/// ///
/// 点开左上角 logo:菜单从 logo **下方**下拉展开(不遮挡 logo)。 /// 点开左上角 logo:菜单从 logo **下方**下拉展开(不遮挡 logo)。
/// 菜单由模块注册表驱动:首页入口 + 已开放模块(可进入/新建)+ /// 菜单由模块注册表驱动:首页入口 + 已开放模块(可进入/新建)+
@@ -48,12 +48,15 @@ class BrandMenuButton extends StatelessWidget {
} }
/// 构建按钮。 /// 构建按钮。
///
/// 与工具栏「手绘 / 选择」等分段按钮**等高同形**(圆角矩形):
/// 固定高度 34×scale、圆角 10、内容垂直居中。
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Tokens t = context.tok; final Tokens t = context.tok;
final BorderRadius radius = BorderRadius.circular(10); final BorderRadius radius = BorderRadius.circular(10);
return Tooltip( return Tooltip(
message: 'EDC|易得设计:设计合集', message: 'EDC易得:设计合集',
child: Material( child: Material(
color: t.panel, color: t.panel,
borderRadius: radius, borderRadius: radius,
@@ -62,8 +65,9 @@ class BrandMenuButton extends StatelessWidget {
borderRadius: radius, borderRadius: radius,
hoverColor: t.accent.withValues(alpha: 0.08), hoverColor: t.accent.withValues(alpha: 0.08),
child: Container( child: Container(
// 高度只由内容决定:去掉上下留白(按钮高度 = 内容高度)。 height: 34 * scale,
padding: EdgeInsets.only(left: 9 * scale, right: 9 * scale), padding: EdgeInsets.symmetric(horizontal: 9 * scale),
alignment: Alignment.center,
decoration: BoxDecoration( decoration: BoxDecoration(
borderRadius: radius, borderRadius: radius,
border: Border.all(color: t.line2), border: Border.all(color: t.line2),
@@ -71,7 +75,7 @@ class BrandMenuButton extends StatelessWidget {
child: Row( child: Row(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: <Widget>[ children: <Widget>[
AppLogo(size: (compact ? 22 : 24) * scale), AppLogo(size: 20 * scale),
SizedBox(width: 7 * scale), SizedBox(width: 7 * scale),
Column( Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
@@ -234,7 +238,7 @@ class BrandMenuButton extends StatelessWidget {
padding: const EdgeInsets.fromLTRB(12, 6, 12, 8), padding: const EdgeInsets.fromLTRB(12, 6, 12, 8),
child: Row( child: Row(
children: <Widget>[ children: <Widget>[
Text('EDC|易得设计', Text('EDC易得',
style: TextStyle( style: TextStyle(
color: t.text, color: t.text,
fontSize: 12.5, fontSize: 12.5,
+139 -65
View File
@@ -2049,7 +2049,7 @@ class _StationRowState extends State<_StationRow> {
/// 双视图说明以及单位与导出等信息。 /// 双视图说明以及单位与导出等信息。
/// 软件设置:集中设置入口(外观 / 文档默认 / 架构图网格 / 更新)。 /// 软件设置:集中设置入口(外观 / 文档默认 / 架构图网格 / 更新)。
/// ///
/// 从左上角「EDC|易得设计」菜单底部的「软件设置」打开;文档级的完整设置 /// 从左上角「EDC易得」菜单底部的「软件设置」打开;文档级的完整设置
/// (单位 / 循环 / 相位等)仍在「文档设置」(F2 / 左侧栏)里。 /// (单位 / 循环 / 相位等)仍在「文档设置」(F2 / 左侧栏)里。
class SoftwareSettingsDialog extends StatefulWidget { class SoftwareSettingsDialog extends StatefulWidget {
/// 构造软件设置对话框。 /// 构造软件设置对话框。
@@ -2081,6 +2081,8 @@ class _SoftwareSettingsDialogState extends State<SoftwareSettingsDialog> {
} }
await showDialog<void>( await showDialog<void>(
context: context, context: context,
// 点对话框外灰色区域不关闭(下载中防误触退出)。
barrierDismissible: false,
builder: (_) => UpdateDialog(controller: c, info: info), builder: (_) => UpdateDialog(controller: c, info: info),
); );
} catch (e) { } catch (e) {
@@ -2479,14 +2481,78 @@ Future<String?> showTextEditDialog(
); );
}, },
); );
ctrl.dispose(); // 等对话框退场动画结束后再释放输入控制器(动画期间组件仍会引用它)。
Future<void>.delayed(const Duration(milliseconds: 400), ctrl.dispose);
return result; return result;
} }
class HelpDialog extends StatelessWidget { class HelpDialog extends StatefulWidget {
/// 构造帮助中心(左侧垂直导航 + 右侧内容,不再水平滑动)。
const HelpDialog({super.key}); const HelpDialog({super.key});
/// 渲染帮助中心:标签栏 + 各标签页的内容列表。 /// 创建状态。
@override
State<HelpDialog> createState() => _HelpDialogState();
}
/// 帮助中心状态:记录当前分页(左侧垂直导航索引)。
class _HelpDialogState extends State<HelpDialog> {
int _tab = 0;
/// 分页标题(与内容顺序一致)。
static const List<String> _tabs = <String>[
'首页与模块',
'时序图 · 动作',
'时序图 · 视图导出',
'架构图 · 绘制识别',
'架构图 · 编辑导出',
'界面与快捷键',
'关于',
];
/// 左侧垂直导航条目。
Widget _navItem(Tokens t, int index, String label) {
final bool active = _tab == index;
return InkWell(
onTap: () => setState(() => _tab = index),
borderRadius: BorderRadius.circular(8),
child: Container(
margin: const EdgeInsets.only(bottom: 6),
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 9),
decoration: BoxDecoration(
color: active
? t.accent.withValues(alpha: 0.14)
: Colors.transparent,
borderRadius: BorderRadius.circular(8),
border: Border.all(
color: active ? t.accent : Colors.transparent,
),
),
child: Row(
children: <Widget>[
Icon(
active ? Icons.chevron_right : Icons.circle,
size: active ? 15 : 6,
color: active ? t.accent : t.dim,
),
const SizedBox(width: 8),
Expanded(
child: Text(
label,
style: TextStyle(
color: active ? t.accent : t.sub,
fontSize: 12,
fontWeight: active ? FontWeight.w700 : FontWeight.w500,
),
),
),
],
),
),
);
}
/// 渲染帮助中心:左侧分页导航 + 右侧内容(垂直滚动)。
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Tokens t = context.tok; final Tokens t = context.tok;
@@ -2511,89 +2577,98 @@ class HelpDialog extends StatelessWidget {
), ),
const Divider(height: 22), const Divider(height: 22),
Expanded( Expanded(
child: DefaultTabController( child: Row(
length: 6, crossAxisAlignment: CrossAxisAlignment.stretch,
child: Column(
children: <Widget>[ children: <Widget>[
const TabBar( // 左侧:垂直导航(窄栏,内容过高时纵向滚动)。
isScrollable: true, SizedBox(
tabs: <Widget>[ width: 150,
Tab(text: '开始与动作'), child: ListView(
Tab(text: '时间与依赖'), children: <Widget>[
Tab(text: '相位分区与视图'), for (int i = 0; i < _tabs.length; i++)
Tab(text: 'AI 与导出'), _navItem(t, i, _tabs[i]),
Tab(text: '界面与快捷键'),
Tab(text: '关于'),
], ],
), ),
),
const SizedBox(width: 12),
Container(width: 1, color: t.line2),
const SizedBox(width: 12),
// 右侧:当前分页内容。
// 每个分页自身就是可滚动列表(_section 返回 ListView),
// 这里不能再套 SingleChildScrollView——无界高度会把内容撑空。
Expanded( Expanded(
child: TabBarView( child: IndexedStack(
index: _tab,
children: <Widget>[ children: <Widget>[
// 目标:完成方案的搭建与动作的增删改。 // 目标:从首页进入正确模块、理解文档与数据位置。
_section(t, <List<String>>[ _section(t, <List<String>>[
<String>['我要新建方案', '顶部「新建」创建空白设计;「打开」按时序 / 架构模块分别载入 .seq.json / .arch.json(兼容旧版 .edc.json)。'], <String>['打开软件是空白首页', '软件采用「空白启动」:打开后进入首页(不再直接进时序图)。在首页选择要新建的文档类型,或打开已有文档。'],
<String>['六个设计模块', '首页与左上角品牌菜单一次列全:架构图、时序图已开放;电器原理图、IO 表、拓扑图、PID 图灰显「未开放」(暂不可进入)。'],
<String>['新建 / 打开 / 最近', '首页点模块卡片即新建对应文档;「打开文档…」先选类型再选文件;「最近打开」记录最近文件(可单条删除 / 清空)。'],
<String>['切换模块 / 回首页', '左上角 logo 按钮 → 品牌菜单:首页、架构图设计、时序图设计、软件设置。切换模块前如有未保存修改会先确认。'],
<String>['文档格式', '时序图保存为 *.seq.json(只含时序内容);架构图保存为 *.arch.json(只含架构内容);旧版 .edc.json 文件可继续打开。'],
<String>['数据保存在哪里', '桌面:%APPDATA%/EDC(autosave 快照、recent 最近列表、library 素材库;旧目录自动复制迁移)。安卓:公共目录 Documents/EDC(兼容旧目录读取)。'],
]),
// 目标:搭建时序方案、增删改动作与工位(沿用既有说明)。
_section(t, <List<String>>[
<String>['我要新建方案', '顶部「新建」创建空白时序设计;「打开」按时序 / 架构模块分别载入 .seq.json / .arch.json(兼容旧版 .edc.json)。'],
<String>['我要先看看示例', '首次启动载入 5 个动作的示例节拍(装配线节拍),可直接修改。'], <String>['我要先看看示例', '首次启动载入 5 个动作的示例节拍(装配线节拍),可直接修改。'],
<String>['我要新增动作', '双击画布空白处在点击相位新增;或左侧「新建」在 0° 新增(默认最外层)。'], <String>['我要新增动作', '双击画布空白处在点击相位新增;或左侧「新建」在 0° 新增(默认最外层)。'],
<String>['我要删除动作', '选中后:左侧「删除」/ 行内删除图标 / Delete 键 / 右键菜单;至少保留一个动作 / 泳道。'], <String>['我要删除动作', '选中后:左侧「删除」/ 行内删除图标 / Delete 键 / 右键菜单;至少保留一个动作 / 泳道。'],
<String>['我要改动作属性', '双击画布色块(条形块 / 圆弧)或左侧动作行 → 打开动作编辑对话框;也可选中后点左侧行内编辑图标。'], <String>['我要改动作属性', '双击画布色块(条形块 / 圆弧)或左侧动作行 → 打开动作编辑对话框;也可选中后点左侧行内编辑图标。'],
<String>['我要复制 / 对齐', '画布左下角「编辑工具」→「复制」/「对齐」;圆周视图右侧浮动工具条同款。'], <String>['我要编辑工位', '左侧「文档设置」→「编辑工位」:可增删工位、改名称与颜色、上下调整顺序;删除工位后其动作自动改挂到第一个工位。'],
<String>['我要编辑工位', '左侧「动作和执行编辑」→「编辑工位」:可增删工位、改名称与颜色、上下调整顺序;删除工位后其动作自动改挂到第一个工位。工位用于区分“谁在做”,是并行关系的首选维度(同工位并行时再用泳道加宽)。'],
<String>['一条泳道放多个动作', '泳道/轨道=一个执行器:上下拖拽(条形)或 Shift+径向拖拽(圆周)换道;不重叠即可共存,标题合并显示(/ 分隔,≤2 行)。'],
<String>['泳道加宽(并列动作)', '默认每条泳道 1 槽;并行动作优先用不同工位 / 泳道区分。需要同一泳道并行时:双击条形视图左侧泳道编号(或右键空白泳道 / 点左侧栏「N 槽」徽标)→ 选 1–5 槽(5 为上限);条形分子行、圆周分子环、流程图分子列,槽位间自动留出依赖箭头空间;拖拽动作可同时换道 + 换槽位。'],
<String>['空泳道的保留 / 移除', 'F2 文档设置 →「泳道」→ 保留空泳道(默认开):动作全部移走的泳道保留,序号不变;关闭则自动移除、序号顺延。条形空行 / 圆周空环 / 流程图空列与左侧栏同步显示。'],
<String>['工位与泳道的关系', '工位 = 物理工位(谁在做:上料 / 加工 / 检测…,可增删改与排序);泳道 = 执行器轨道(并行关系:同一泳道 = 同一执行器,可放多个不重叠动作,加宽后最多 5 个并列)。'],
]),
// 目标:调整时间轴与动作间的先后 / 并行关系。
_section(t, <List<String>>[
<String>['我要改时间轴长度', '左侧「文档设置」入口(或按 F2)→「循环与相位」→ 循环时长 → 应用。'], <String>['我要改时间轴长度', '左侧「文档设置」入口(或按 F2)→「循环与相位」→ 循环时长 → 应用。'],
<String>['我要调相位 / 时长', '拖动动作块平移相位;拖条形右端改持续角;圆周视图拖弧两端改起止角;右侧滑杆可精调。'], <String>['我要调相位 / 时长', '拖动动作块平移相位;拖条形右端改持续角;圆周视图拖弧两端改起止角;右侧滑杆可精调。'],
<String>['我要让动作跨循环', '使「起始角 + 持续角 > 360°」,会自动拆分并以半透明虚线渲染尾段。'], <String>['泳道加宽(并列动作)', '双击条形视图左侧泳道编号(或点左侧栏「N 槽」徽标)→ 选 1–5 槽;拖拽动作可同时换道 + 换槽位。'],
<String>['我要加前置依赖(输入)', '右侧「前置依赖 · 输入」→「添加前置依赖」;或右键动作 →「添加依赖」。'], <String>['空泳道的保留 / 移除', 'F2 文档设置 →「泳道」→ 保留空泳道(默认开):动作全部移走的泳道保留,序号不变;关闭则自动移除。'],
<String>['一个动作多输入', '可重复添加多条前置依赖,逐条列出、逐条可删。'], <String>['我要加前置依赖(输入)', '右侧「前置依赖 · 输入」→「添加前置依赖」;或右键动作 →「添加依赖」。FS 绿色实线=完成后启动;SS 琥珀虚线=可提前启动(带 +n°)。'],
<String>['一个动作多输出', '在「输出依赖 · 结果」查看本动作指向的后续动作,并可逐条删除。'], <String>['连线重叠怎么办', '点选连线后拖动可沿法线方向平移整条线(圆周沿半径方向);双击连线或右键「复位走线偏移」恢复;同一组连线会自动错开。'],
<String>['FS / SS 是什么', 'FS 绿色实线=完成后启动;SS 琥珀虚线=可提前启动(并行重叠,带 +n°)。'], <String>['我要编辑相位分区', '左侧「文档设置」→「编辑相位分区」;增删分区、改名称与起止角;可重叠、可留空、>360° 表示跨圈。'],
<String>['连线重叠怎么办', '点选连线后拖动可沿法线方向平移整条线(圆周沿半径方向;跨行走廊为左右拖动);双击连线或右键「复位走线偏移」恢复;同一组连线会自动错开。'],
]), ]),
// 目标:编辑相位分区并控制画布显示。 // 目标:视图操作、AI 生成与三视图导出(沿用既有说明)。
_section(t, <List<String>>[ _section(t, <List<String>>[
<String>['相位分区是什么', '把一个循环按角度分成的命名工艺阶段(默认上料 / 加工 / 检测):条形图顶部为标注色带、圆周视图为最外圈相位环与径向边界、流程图左侧为竖排阶段栏。可重叠、可留空、>360° 表示跨圈。'],
<String>['我要编辑相位分区', '左侧「动作和执行编辑」→「编辑相位分区」;或 F2 →「相位分区」→「编辑…」。增删分区、改名称与起止角;可重叠、可留空、>360° 表示跨圈。'],
<String>['我要隐藏相位分区', '左侧「显示选项」取消勾选「相位分区标注」。'],
<String>['刻度怎么读', '条形视图:分区带与刻度线之间上排为相位、下排为等价时间;圆周视图:每 30° 的度数外侧标注等价时间。'],
<String>['我要切换视图', '顶部「条形节拍 / 圆周节拍 / 流程图」分段开关,三种视图共享同一份数据;流程图由时序图自动生成(只读)。每次切换都会自动「适应窗口」。'], <String>['我要切换视图', '顶部「条形节拍 / 圆周节拍 / 流程图」分段开关,三种视图共享同一份数据;流程图由时序图自动生成(只读)。每次切换都会自动「适应窗口」。'],
<String>['条形视图怎么看', '箭头表示动作之间关联:绿色实线 FS 严格顺序;琥珀虚线 SS 并行重叠。'],
<String>['圆周视图怎么看', '同心圆环 = 动作层;箭头 = 执行顺序(绿色实线 FS 严格顺序,琥珀虚线 SS 并行重叠);1 圈 = 1 循环 = 360° = 100%。'],
<String>['流程图怎么看', '泳道 = 轨道;实线 = FS 顺序,虚线 = SS 并行(含偏移角);加粗光晕 = 关键路径;点击节点选中动作(修改请回时序图)。'],
<String>['我要缩放 / 平移', 'Ctrl+滚轮 以光标为锚点缩放;普通滚轮或拖拽空白平移。'], <String>['我要缩放 / 平移', 'Ctrl+滚轮 以光标为锚点缩放;普通滚轮或拖拽空白平移。'],
<String>['我要完整显示', '顶部「适应视图」:自动按内容(含刻度、箭头、跨圈标注)计算缩放与居中,编辑后也不会被裁切。'], <String>['我要完整显示', '顶部「适应视图」:自动按内容(含刻度、箭头、跨圈标注)计算缩放与居中。'],
<String>['我要开关标注', '左侧「显示选项」逐项开关双刻度、依赖箭头、圆环背景、层标注、跨循环高亮等。'], <String>['我要开关标注', '左侧「显示选项」逐项开关双刻度、依赖箭头、圆环背景、层标注、跨循环高亮等。'],
]),
// 目标:用 AI 生成,并导出成果。
_section(t, <List<String>>[
<String>['我要 AI 生成', '顶部「AI 生成」→ 填 DeepSeek API Key → 选模型(Flash / Pro)→ 选强度(高 / 最高)→ 用自然语言描述 → 生成。'], <String>['我要 AI 生成', '顶部「AI 生成」→ 填 DeepSeek API Key → 选模型(Flash / Pro)→ 选强度(高 / 最高)→ 用自然语言描述 → 生成。'],
<String>['生成效果不好', '描述里写清:循环时长、工位数、各动作时长、哪些顺序(完成后启动)、哪些并行。'], <String>['我要看节拍统计', '画布左下角「节拍统计」按钮 → 弹窗查看循环周期、动作数、关键路径、最大并行度、相位覆盖率与瓶颈工位。'],
<String>['我要看节拍统计', '画布左下角「节拍统计」按钮 → 弹窗查看循环周期、动作数、关键路径、最大并行度、相位覆盖率与瓶颈工位(仅展示可从项目数据推导的指标)。'], <String>['我要导出 SVG / PNG', '顶部「导出」下拉菜单:SVG(矢量、分层、带语义 id)/ PNG(2 倍像素位图);三种视图通用。'],
<String>['我要导出 SVG', '顶部「导出」下拉菜单 →「导出 SVG」:矢量、分层、带语义 id 与 data-*,可直接进工艺卡 / MES。'],
<String>['我要导出 PNG', '顶部「导出」下拉菜单 →「导出 PNG」:按 2 倍像素比导出当前视图为位图。'],
<String>['我要导出 drawio', '流程图视图专用:顶部「导出」→「导出 drawio」,输出 diagrams.net(draw.io)可继续编辑的工程文件。'], <String>['我要导出 drawio', '流程图视图专用:顶部「导出」→「导出 drawio」,输出 diagrams.net(draw.io)可继续编辑的工程文件。'],
<String>['我要保存 / 恢复', '「保存」按时序 / 架构模块分别写入 .seq.json / .arch.json 并生成 .bak;每 5 秒自动快照(异常退出可恢复);「软件设置」中可开启「自动保存」(默认每 10 分钟一次,需先手动保存过一次路径)。'], <String>['我要保存 / 恢复', '「保存」写入 .seq.json 并生成 .bak;每 5 秒自动快照(异常退出可恢复);「软件设置」中可开启「自动保存」(默认每 10 分钟一次,需先手动保存过一次路径)。'],
]),
// 目标:架构图的绘制、识别与图元库(本轮重点)。
_section(t, <List<String>>[
<String>['工具条怎么用', '架构图顶部工具:选择 / 手绘 / 连线 / 橡皮,旁边是「识别 N」确认按钮(N = 待识别墨迹笔数)。'],
<String>['手绘识别', '「手绘」工具下按住拖动:松手自动把笔迹扶正为标准图形(矩形 / 圆 / 箭头 / 折线 / 曲线 / 云 / 圆柱……);识别不了的保留为墨迹,可用橡皮擦掉。'],
<String>['多笔组合识别', '支持两笔组合(如两笔试画一个矩形)、圆柱拼接(顶盖 + 柱体);与上一笔刚生成的图形也能在 2.5 秒内合并。'],
<String>['平板手写总识别不准', '左栏「手绘识别」关闭「松手自动识别」(安卓默认关闭):笔迹先保留为墨迹,画完点顶部「识别(N)」按钮统一确认,识别更从容。'],
<String>['图形库', '左栏「图形库」内置标准图形(矩形 / 圆角矩形 / 椭圆 / 圆 / 三角 / 菱形 / 六边形 / 圆柱 / 云)与 IT 图元(服务器 / 客户端 / 移动端 / 防火墙 / 交换机 / 消息队列),点一下即插入画布。'],
<String>['橡皮', '「橡皮」工具:拖过图形 / 墨迹 / 连线即擦除;一次连续擦除算一步撤销(Ctrl+Z 可整段回退)。'],
<String>['文字怎么输入', '双击图形 → 编辑图形文字;双击连线 → 编辑标签;双击空白 → 新建文本(输入法直接打字)。'],
<String>['图层', '左栏「图层」:新建 / 可见(眼睛)/ 锁定(锁)/ 颜色 / 双击改名。隐藏图层不绘制不可选;锁定图层可见但不可选(仍可作吸附参照)。'],
<String>['标尺与辅助', '四边标尺单位固定为 mm(垂直轴数值在右侧);F8 正交移动 / F10 极轴追踪(角度在左栏设置);支持网格吸附与磁力对齐线。'],
<String>['默认图纸', '新建架构图的画布为 A0 图纸(1189×841 mm,1 世界单位 = 1 mm),自动适配视口;画布上绘制浅色 A0 边界。'],
]),
// 目标:架构图编辑操作与导出。
_section(t, <List<String>>[
<String>['连线规则', '连线一律正交(横平竖直):两端垂直出入图元边框(箭头不会乱指),同一图元多条连线自动错开;选中后可拖端点换吸附、拖折点或线段平移走线(平板已加大命中范围),拖动时有磁力对齐与虚线导引;鼠标悬停连线显示抓取光标。'],
<String>['对齐 / 均布', '框选或 Ctrl 多选后,右栏出现 8 个对齐按钮:左 / 横向居中 / 右、顶 / 纵向居中 / 底、横向均布、纵向均布(以选中范围为参照,均布需 ≥3 个)。'],
<String>['层级 / 复制 / 删除', '选中后右栏可「上移一层 / 下移一层」;拖拽移动、白色手柄缩放;Delete 删除选中;Ctrl+A 全选。'],
<String>['我要导出 DXF', '顶部「导出」→「导出 DXF」:AutoCAD R12 格式(图层 / 图形 / 连线 / 文字),可直接在 AutoCAD / DraftSight / ZWCAD 打开继续编辑。'],
<String>['我要导出 SVG / PNG', '顶部「导出」→ SVG(矢量)/ PNG(位图);导出使用纯白背景,与屏幕主题无关。'],
<String>['我要保存 / 恢复', '「保存」写入 .arch.json 并生成 .bak;自动快照与「自动保存」设置与时序图通用。'],
]), ]),
// 目标:调整界面与使用快捷键。 // 目标:调整界面与使用快捷键。
_section(t, <List<String>>[ _section(t, <List<String>>[
<String>['我要隐藏 / 显示侧栏', '工具栏右侧两个侧栏按钮,分别控制左、右侧栏。'], <String>['我要隐藏 / 显示侧栏', '工具栏右侧两个侧栏按钮,分别控制左、右侧栏;图钉可钉住侧栏(固定占位)或悬浮(鼠标移开自动收起)。'],
<String>['我要钉住侧栏', '侧栏标题右侧图钉:钉住=固定占位;取消钉住=悬浮,鼠标移开自动收起。'],
<String>['边缘把手', '侧栏收起后画布边缘有细把手:悬停临时展开,点击固定显示。'],
if (Platform.isAndroid) if (Platform.isAndroid)
<String>['触屏操作', '单指点选选中动作;按住动作整体拖动移动;选中后抓两端白色把手拖拽改时长;空白单指不平移;双指捏合缩放、双指拖拽平移。'] <String>['触屏操作', '单指点选;按住拖动移动 / 手绘 / 擦除;双指捏合缩放、双指拖拽平移;长按空白进入框选。']
else else
<String>['拖拽 / 缩放', '左键拖拽平移相位;拖端点改时长;Shift+拖拽改层;Ctrl+滚轮缩放。'], <String>['拖拽 / 缩放', '左键拖拽移动或绘制;Ctrl+滚轮缩放;中键 / 右键拖拽平移。'],
<String>['双击编辑', '双击画布色块(条形块 / 圆弧)或左侧动作行 → 打开动作编辑对话框。'], <String>['撤销 / 保存', 'Ctrl+Z / Ctrl+Y 撤销重做;Ctrl+S 保存;Ctrl+O / Ctrl+N 打开 / 新建;Delete 删除选中。'],
if (!Platform.isAndroid) <String>['功能键', 'F1 帮助(本窗口);F2 文档设置(时序图:单位 / 循环 / 泳道 / 相位分区);F3 切换深 / 浅主题。'],
<String>['右键动作', '菜单:添加依赖 / 改层 / 复制 / 删除。'], <String>['检查更新', '首页右上角更新图标,或帮助 / 设置中「检查更新」:检测到新版本可直接下载升级(下载限速 320KB/s)。'],
<String>['撤销 / 保存', 'Ctrl+Z / Ctrl+Y 撤销重做;Ctrl+S 保存;Ctrl+O / Ctrl+N 打开 / 新建。'],
<String>['帮助入口', '顶部工具栏右侧「?」或 F1 打开帮助中心;画布编辑工具条不重复放置帮助按钮。'],
<String>['导出入口', '导出统一放在顶部工具栏「导出」下拉菜单:SVG / PNG 三种视图通用;流程图另有 drawio。'],
<String>['其它', 'F2 文档设置(含单位、循环、泳道与相位分区);F3 切换深/浅主题;Delete 删除选中动作。'],
]), ]),
// 关于:设计人、版本、版权、授权信息与本机 MAC。 // 关于:设计人、版本、版权、授权信息与本机 MAC。
_about(context, t), _about(context, t),
@@ -2603,7 +2678,6 @@ class HelpDialog extends StatelessWidget {
], ],
), ),
), ),
),
Align( Align(
alignment: Alignment.centerRight, alignment: Alignment.centerRight,
child: FilledButton(onPressed: () => Navigator.pop(context), child: const Text('关闭')), child: FilledButton(onPressed: () => Navigator.pop(context), child: const Text('关闭')),
@@ -2669,7 +2743,7 @@ class HelpDialog extends StatelessWidget {
child: Column( child: Column(
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text('EDC|易得设计 · Easy Design Collection', Text('EDC易得 · Easy Design Collection',
style: TextStyle(color: t.text, fontSize: 15, fontWeight: FontWeight.w700)), style: TextStyle(color: t.text, fontSize: 15, fontWeight: FontWeight.w700)),
const SizedBox(height: 4), const SizedBox(height: 4),
Text('V$kAppVersion(${android ? '安卓版' : 'Windows 版'})', Text('V$kAppVersion(${android ? '安卓版' : 'Windows 版'})',
+18 -3
View File
@@ -25,6 +25,7 @@ class HomeView extends StatefulWidget {
required this.onOpenRecent, required this.onOpenRecent,
required this.onOpenSettings, required this.onOpenSettings,
required this.onOpenHelp, required this.onOpenHelp,
required this.onCheckUpdate,
}); });
/// 全局控制器(只读展示用)。 /// 全局控制器(只读展示用)。
@@ -45,6 +46,9 @@ class HomeView extends StatefulWidget {
/// 帮助中心。 /// 帮助中心。
final VoidCallback onOpenHelp; final VoidCallback onOpenHelp;
/// 检查更新(真实按钮:检查中 / 已是最新 / 发现新版本都有明确反馈)。
final VoidCallback onCheckUpdate;
/// 创建状态。 /// 创建状态。
@override @override
State<HomeView> createState() => _HomeViewState(); State<HomeView> createState() => _HomeViewState();
@@ -191,7 +195,7 @@ class _HomeViewState extends State<HomeView> {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
Text( Text(
'EDC|易得设计', 'EDC易得',
style: TextStyle( style: TextStyle(
color: t.text, color: t.text,
fontSize: 24, fontSize: 24,
@@ -210,7 +214,12 @@ class _HomeViewState extends State<HomeView> {
const SizedBox(width: 8), const SizedBox(width: 8),
_iconAction(t, Icons.help_outline, '帮助中心', widget.onOpenHelp), _iconAction(t, Icons.help_outline, '帮助中心', widget.onOpenHelp),
const SizedBox(width: 8), const SizedBox(width: 8),
UpdateIcon(size: 36, color: t.sub), _iconActionIcon(
t,
'检查更新',
widget.onCheckUpdate,
UpdateIcon(size: 22, color: t.sub),
),
], ],
); );
} }
@@ -218,6 +227,12 @@ class _HomeViewState extends State<HomeView> {
/// 圆形图标按钮(触屏 ≥ 44px 点按区)。 /// 圆形图标按钮(触屏 ≥ 44px 点按区)。
Widget _iconAction( Widget _iconAction(
Tokens t, IconData icon, String tip, VoidCallback onTap) { Tokens t, IconData icon, String tip, VoidCallback onTap) {
return _iconActionIcon(t, tip, onTap, Icon(icon, size: 20, color: t.sub));
}
/// 圆形按钮(自定义内容):与 [_iconAction] 同尺寸同风格。
Widget _iconActionIcon(
Tokens t, String tip, VoidCallback onTap, Widget child) {
return Tooltip( return Tooltip(
message: tip, message: tip,
child: InkWell( child: InkWell(
@@ -232,7 +247,7 @@ class _HomeViewState extends State<HomeView> {
borderRadius: BorderRadius.circular(12), borderRadius: BorderRadius.circular(12),
border: Border.all(color: t.line), border: Border.all(color: t.line),
), ),
child: Icon(icon, size: 20, color: t.sub), child: child,
), ),
), ),
); );
+26 -7
View File
@@ -14,6 +14,7 @@ import 'package:flutter/services.dart';
import '../state/app_controller.dart'; import '../state/app_controller.dart';
import '../theme/tokens.dart'; import '../theme/tokens.dart';
import '../update/keep_awake.dart';
import '../update/update_service.dart'; import '../update/update_service.dart';
import '../version.dart'; import '../version.dart';
import 'dialogs.dart'; import 'dialogs.dart';
@@ -57,6 +58,8 @@ class _UpdateDialogState extends State<UpdateDialog> {
_received = 0; _received = 0;
_status = '正在下载更新包…'; _status = '正在下载更新包…';
}); });
// 下载期间保持屏幕常亮:避免锁屏中断下载(Android / Windows)。
await KeepAwake.enable();
try { try {
if (Platform.isAndroid) { if (Platform.isAndroid) {
await _updateAndroid(); await _updateAndroid();
@@ -73,6 +76,8 @@ class _UpdateDialogState extends State<UpdateDialog> {
}); });
} }
return; return;
} finally {
await KeepAwake.disable();
} }
if (mounted) setState(() => _busy = false); if (mounted) setState(() => _busy = false);
} }
@@ -120,11 +125,11 @@ class _UpdateDialogState extends State<UpdateDialog> {
// 兼容两种打包方式:zip 根目录即程序文件,或多包一层 dist/。 // 兼容两种打包方式:zip 根目录即程序文件,或多包一层 dist/。
String srcDir = extractDir; String srcDir = extractDir;
if (!File('$extractDir\\sequence_diagram.exe').existsSync()) { if (!File('$extractDir\\EasyDesignCollection.exe').existsSync()) {
if (File('$extractDir\\dist\\sequence_diagram.exe').existsSync()) { if (File('$extractDir\\dist\\EasyDesignCollection.exe').existsSync()) {
srcDir = '$extractDir\\dist'; srcDir = '$extractDir\\dist';
} else { } else {
throw Exception('更新包内容不完整(未找到 sequence_diagram.exe)'); throw Exception('更新包内容不完整(未找到 EasyDesignCollection.exe)');
} }
} }
@@ -137,13 +142,13 @@ class _UpdateDialogState extends State<UpdateDialog> {
File(batPath).writeAsStringSync( File(batPath).writeAsStringSync(
'@echo off\r\n' '@echo off\r\n'
':wait\r\n' ':wait\r\n'
'tasklist /fi "IMAGENAME eq sequence_diagram.exe" | find /i "sequence_diagram.exe" >nul\r\n' 'tasklist /fi "IMAGENAME eq EasyDesignCollection.exe" | find /i "EasyDesignCollection.exe" >nul\r\n'
'if not errorlevel 1 (\r\n' 'if not errorlevel 1 (\r\n'
' ping -n 1 -w 600 127.0.0.1 >nul\r\n' ' ping -n 1 -w 600 127.0.0.1 >nul\r\n'
' goto wait\r\n' ' goto wait\r\n'
')\r\n' ')\r\n'
'xcopy /e /i /y /q "%~1\\*" "%~2\\"\r\n' 'xcopy /e /i /y /q "%~1\\*" "%~2\\"\r\n'
'start "" "%~2\\sequence_diagram.exe"\r\n' 'start "" "%~2\\EasyDesignCollection.exe"\r\n'
'del "%~f0"\r\n', 'del "%~f0"\r\n',
flush: true, flush: true,
); );
@@ -159,6 +164,7 @@ class _UpdateDialogState extends State<UpdateDialog> {
}); });
} }
await Future<void>.delayed(const Duration(milliseconds: 900)); await Future<void>.delayed(const Duration(milliseconds: 900));
await KeepAwake.forceOff();
exit(0); exit(0);
} }
@@ -176,6 +182,13 @@ class _UpdateDialogState extends State<UpdateDialog> {
_cancelled = true; _cancelled = true;
} }
@override
void dispose() {
// 兜底:对话框销毁后不再强制常亮。
KeepAwake.forceOff();
super.dispose();
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
final Tokens t = context.tok; final Tokens t = context.tok;
@@ -183,7 +196,11 @@ class _UpdateDialogState extends State<UpdateDialog> {
final String sizeText = info.assetSize > 0 final String sizeText = info.assetSize > 0
? '${(info.assetSize / 1048576).toStringAsFixed(1)} MB' ? '${(info.assetSize / 1048576).toStringAsFixed(1)} MB'
: ''; : '';
return Dialog( return PopScope(
// 下载中禁止返回键退出;未下载时可返回键关闭。
// 点击对话框外的灰色区域始终无响应(barrierDismissible: false)。
canPop: !_busy,
child: Dialog(
backgroundColor: t.dialog, backgroundColor: t.dialog,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)), shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
child: scaledDialogBox( child: scaledDialogBox(
@@ -300,7 +317,8 @@ class _UpdateDialogState extends State<UpdateDialog> {
const SizedBox(width: 8), const SizedBox(width: 8),
Expanded( Expanded(
child: Text( child: Text(
'下载更新过程中,请确保屏幕保持长亮、网络持续连接,避免更新包下载中断。', '更新过程中软件会自动保持屏幕常亮;请保持界面打开、网络连接稳定,'
'不要退出软件,避免更新包下载中断。',
style: TextStyle(color: t.warn, fontSize: 11.5, height: 1.5), style: TextStyle(color: t.warn, fontSize: 11.5, height: 1.5),
), ),
), ),
@@ -343,6 +361,7 @@ class _UpdateDialogState extends State<UpdateDialog> {
), ),
), ),
), ),
),
); );
} }
} }
+64
View File
@@ -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
View File
@@ -48,7 +48,7 @@ class UpdateInfo {
/// 更新说明(Markdown 文本)。 /// 更新说明(Markdown 文本)。
final String notes; final String notes;
/// 安装包文件名(如 `sequence_diagram_android_v1.2.1_release.apk`)。 /// 安装包文件名(如 `EasyDesignCollection_android_v1.3.10_release.apk`)。
final String assetName; final String assetName;
/// 安装包下载地址。 /// 安装包下载地址。
+1 -1
View File
@@ -2,7 +2,7 @@
/// ///
/// 应用内更新检查用它判断服务器发布的版本是否更新; /// 应用内更新检查用它判断服务器发布的版本是否更新;
/// **每次发版必须与 pubspec 同步更新**(见 BUILD-NOTES 的发布流程)。 /// **每次发版必须与 pubspec 同步更新**(见 BUILD-NOTES 的发布流程)。
const String kAppVersion = '1.3.5'; const String kAppVersion = '1.3.12';
/// 是否要求授权(License)才能导出。 /// 是否要求授权(License)才能导出。
/// ///
+2 -2
View File
@@ -1,5 +1,5 @@
name: sequence_diagram name: sequence_diagram
description: "时序图设计 · Sequence Diagram Studio —— 面向 PLC 流程节拍 / 相位角设计的桌面软件。" description: "EDC易得 · Easy Design Collection:面向 PLC 流程节拍 / 相位角、系统架构与电气设计的桌面软件。"
# The following line prevents the package from being accidentally published to # The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages. # pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev publish_to: 'none' # Remove this line if you wish to publish to pub.dev
@@ -16,7 +16,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
# In Windows, build-name is used as the major, minor, and patch parts # In Windows, build-name is used as the major, minor, and patch parts
# of the product and file versions while build-number is used as the build suffix. # of the product and file versions while build-number is used as the build suffix.
version: 1.3.5+26 version: 1.3.12+34
environment: environment:
sdk: ^3.13.3 sdk: ^3.13.3
+45
View File
@@ -0,0 +1,45 @@
# V1.3.10 更新内容
> ⚠️ 本次为**应用身份切换版**(包名由 `cc.sincos.sequence_diagram` 换为 `cc.sincos.edc`)——
> 「桌面名称不变」问题的彻底方案。装完请按下方第 1 节操作。新功能仍可能存在较多 bug
> 或问题,欢迎反馈(开发者邮箱 liuyu65@126.com / 微信 online-goose)。
## 1. 「桌面名称不变」——彻底解决(本次核心)
之前版本的安装包内应用名称已多次实测确认为 **EDC|易得设计**,但部分手机桌面
会长期保留旧包身份的图标名(时序图设计)。本次直接**更换应用身份**:
- 安装 1.3.10 时,系统会当作**全新应用**安装 → 桌面出现名为
**EDC|易得设计** 的新图标(新条目,不存在任何旧缓存可继承);
- 旧的「时序图设计」图标:确认新图标可用后**长按卸载**即可
(安装后两个图标可能短暂并存,属正常);
- 你的项目文件保存在公共目录 `Documents/SequenceDiagram`,不受影响;
仅应用内设置(如最近列表)会重置;
- 从 1.3.10 起,之后每次更新都在新身份上**原地覆盖**,不再有名称问题。
## 2. 界面精简(按反馈做减法)
- 移除「尺寸标注 · mm」:右栏尺寸区、画布尺寸标签、双击改值全部去掉;
- 图元库取消自定义(导入 / 存为图元 / 删除)与电气图元条目;
左栏只保留架构图需要的「**图形库**」(标准图形 + IT 图元)。
## 3. 修复
- **帮助中心空白**:上一版改垂直导航时内容区被套了两层滚动容器,导致整页
空白,已修复(帮助内容同步更新为本版功能集);
- **Windows 应用内更新**:更新包校验仍按旧程序名 `sequence_diagram.exe`
查找,会误报「更新包内容不完整」,已改为 `EasyDesignCollection.exe`。
## 4. 更新方式
- 应用内:首页 / 工具栏「检查更新」→ 立即更新
(下载限速 320KB/s,请保持屏幕常亮、网络稳定);
- 手动:Release 页下载 `EasyDesignCollection_android_v1.3.10_release.apk`
或 `EasyDesignCollection_windows_v1.3.10.zip`。
## 5. 复验点
1. 装好后桌面出现 **EDC|易得设计** 新图标(可与旧图标并存,之后卸载旧图标);
2. 帮助中心(F1)左侧导航 7 页均可打开,内容不再空白;
3. 架构图左栏只有「图形库 / 图层 / 连线」等,右栏属性卡无「尺寸 · mm」;
4. 应用内「检查更新」应提示:当前已是最新版本(v1.3.10)。
+50
View File
@@ -0,0 +1,50 @@
# V1.3.11 更新内容
> ⚠️ 本次为修复 / 优化版:更新体验、连线编辑与全局更名。新功能仍可能存在较多
> bug 或问题,欢迎反馈(开发者邮箱 liuyu65@126.com / 微信 online-goose)。
## 1. 名称统一为「EDC|易得」
- 桌面图标名(安卓)、窗口标题(Windows)、应用内品牌、导出图签、文件属性
全部改为 **EDC|易得**(不再带「设计」二字);
- 图标本身为纯图形(无文字),无需更换;
- 若你的设备已装 1.3.10:本次为**原地覆盖更新**,装好后桌面名称应直接刷新;
个别桌面若未刷新,重启桌面或卸载重装一次即可。
- 若从更早版本(1.3.9 及以前)直接装本次:系统会当作全新应用
(`cc.sincos.edc`)建立图标,桌面即为 EDC|易得,旧图标卸载即可。
## 2. 更新体验(下载更安心)
- 开始下载后软件**自动保持屏幕常亮**,不会锁屏中断下载(安卓 / Windows);
- 下载过程中点击对话框外的灰色区域**没有任何响应**、按返回键也**不会退出**
更新界面,防止误触中断(需取消请点「取消下载」);
- 提示文案同步更新,下载进度、限速 320KB/s 照常显示。
## 3. 连线(架构图)大优化
- **箭头不再乱指**:连线两端沿图元边**法向**垂直出入,箭头始终垂直指向
图元边框(垂直边水平射入、水平边垂直射入);
- **多连线自动避让**:同一图元同一条边上的多条连线**自动错开**分布,
起点与箭头不再重叠(拖动画布上的图形后同样自动重新分布);
- **平板 / 手指拖动优化**:
- 命中范围加大(手指 / 触控笔更容易选中端点和线段);
- 新增**线段拖动**:抓住连线任意一段可整体平移(直线会就地生成台阶);
- 端点拖拽实时预览:拖到别的图形即时吸附、拖到空白即时脱离;
- **磁力吸附 + 虚线导引**:拖动端点 / 折点 / 线段时,自动吸附对齐图元
边与中心、其它连线、图纸中心,并用**虚线**显示对齐位置;
- **鼠标光标**:悬停连线显示抓取光标,拖拽中显示抓取中光标。
## 4. 更新方式
- 应用内:首页 / 工具栏「检查更新」→ 立即更新(保持网络稳定即可,
现在下载期间屏幕会自动常亮);
- 手动:Release 页下载 `EasyDesignCollection_android_v1.3.11_release.apk`
或 `EasyDesignCollection_windows_v1.3.11.zip`。
## 5. 复验点
1. 桌面 / 窗口标题 / 应用内左上角品牌均显示 **EDC|易得**;
2. 点「检查更新」→ 立即更新:下载中不锁屏、点灰区不退出;
3. 架构图:新建两条从同一图形出发的连线 → 起点自动错开;
箭头垂直指向目标边框;拖动端点 / 折点 / 线段时出现虚线对齐提示;
4. 鼠标悬停连线时光标变为抓取样式(桌面端)。
+42
View File
@@ -0,0 +1,42 @@
# V1.3.12 更新内容
> ⚠️ 本次为**桌面名称彻底修复版**(应用身份再次切换 + 名称定为「EDC易得」)。
> 装完后桌面会多出一个全新图标,请按第 1 节操作。其余功能与 1.3.11 一致。
## 1. 桌面名称「EDC易得」——彻底修复(本次核心)
老问题(桌面名称不随更新刷新)用**已验证过的方法**一次性解决:
- 应用身份更换为全新的 **`cc.sincos.yide`**(上一个身份 `cc.sincos.edc` 作废);
- 名称统一为 **EDC易得**(桌面图标名、Windows 窗口标题 / 文件属性、应用内
品牌、导出图签,全部一致,不再带「设计」也不带竖线);
- 安装本版时,系统会把它当作**全新应用**安装 → 桌面必然生成名为
**EDC易得** 的全新图标(全新条目,任何旧名称都不会沿用到它身上);
- 装好后请**长按旧图标并卸载**(此前可能有「时序图设计」「EDC|易得设计」
等旧图标,可能不止一个,全部卸载):
- 注意不要误删新图标:新图标名字就是 **EDC易得**;
- 你的项目文件保存在公共目录 `Documents/SequenceDiagram`,**不受影响**;
仅应用内设置(如「最近打开」列表)会重置一次;
- **本次之后名称固定为 EDC易得,不再变动**——以后更新都在新身份上原地
覆盖,「桌面名称不刷新」的问题不会再出现。
## 2. 更新方式
- 应用内:打开现在的应用 → 首页 / 工具栏「检查更新」→ 立即更新
(下载期间屏幕自动保持常亮,点灰色区域不会退出);
- 手动:Release 页下载
`EasyDesignCollection_android_v1.3.12_release.apk` 或
`EasyDesignCollection_windows_v1.3.12.zip`。
## 3. 本版包含(若你此前未更新到 1.3.11)
- 更新下载时**屏幕自动常亮**;下载中点击灰区 / 返回键都不会退出更新界面;
- 架构图连线:箭头沿图元边**法向**垂直出入(不再乱指);同一图元多条连线
**自动错开**;平板 / 手指拖动优化(端点 / 折点 / 线段拖动,命中范围加大,
实时预览);拖动时**磁力吸附 + 虚线对齐导引**;鼠标悬停显示抓取光标。
## 4. 复验点
1. 装完后桌面出现全新图标 **EDC易得**(旧图标卸载后,桌面上只剩它一个);
2. 打开应用 → 关于页应显示 **v1.3.12**;
3. 应用内「检查更新」应提示:当前已是最新版本(v1.3.12)。
+12
View File
@@ -46,6 +46,18 @@
- 导出:**SVG / PNG / DXF**(AutoCAD 可直接打开继续编辑); - 导出:**SVG / PNG / DXF**(AutoCAD 可直接打开继续编辑);
- 修复:缩小时画布内容溢出到侧栏 / 工具栏(裁剪修复)。 - 修复:缩小时画布内容溢出到侧栏 / 工具栏(裁剪修复)。
## 本轮补充(热更新,已包含在附件中)
- **橡皮**:拖过图形 / 墨迹 / 连线即擦除,一次连续擦除 = 一步撤销;
- **手动确认识别**(平板推荐):可关闭「松手自动识别」(安卓默认关闭),
笔迹先保留为墨迹,画完点顶部「**识别(N)**」按钮统一识别;
- **连线一律正交**(横平竖直,无斜线):选中后拖拽路径**角点**调整走线位置;
端点可拖到别的图形重新吸附或脱离;
- **手绘只出图形、连线只出连线**:不再从手绘箭头自动生成连线(避免误识别);
- **尺寸标注增强**:右栏「尺寸 · mm」一键「标注全部 / 清除标注」,
双击画布上的尺寸标签直接改值(比例缩放、中心保持);
- **帮助文件大规模更新**:应用内帮助中心(7 个分页)与 `docs/HELP.md` 全量重写。
## 时序图模块 ## 时序图模块
- 保存格式分离:时序图保存为 **`*.seq.json`**(只含时序内容); - 保存格式分离:时序图保存为 **`*.seq.json`**(只含时序内容);
+36
View File
@@ -0,0 +1,36 @@
# V1.3.6 更新内容
> ⚠️ **说明**:本版是 1.3.5 大版本之后的**修复增强版**。1.3.5 的新功能仍可能
> 存在较多 bug 与问题,遇到问题欢迎反馈(开发者邮箱 liuyu65@126.com / 微信 online-goose)。
>
> 已经装过 1.3.5 的用户:请检查更新到本版,以下修复都包含在本版附件中。
## 架构图 · 本轮修复与增强
- **橡皮**:工具栏新增「橡皮」——拖过图形 / 墨迹 / 连线即擦除;
一次连续擦除 = 一步撤销(Ctrl+Z 整段回退);
- **手动确认识别(平板推荐)**:左栏「手绘识别」可关闭「松手自动识别」
(安卓默认关闭):笔迹先保留为墨迹,画完点顶部「**识别(N)**」按钮统一识别;
批量识别升级:图元库单笔 → 内置图形 → 两笔组合(手动模式下「圆 + 叉」也能合成指示灯);
- **手绘 / 连线职责分离**:手绘只出图形、连线只出连线
(取消了「手绘箭头落两图形上自动变连线」的误识别行为);
- **连线一律正交(无斜线)**:选中连线后**拖拽路径上的角点**即可调整走线位置
(保持横平竖直);端点可拖到别的图形重新吸附或脱离;
- **尺寸标注增强**:右栏「尺寸 · mm」一键「**标注全部 / 清除标注**」,
双击画布上的尺寸标签直接改值(比例缩放、中心保持);
- **品牌按钮**缩身:去掉上下留白(高度约为原来的 90%),副标题精简;
- 修复上一版中已知的若干细节问题(标尺游标实线、画布裁剪、菜单宽度等)。
## 帮助文件大规模更新(本次重点)
- 应用内帮助中心重排为 **7 个分页**:首页与模块 / 时序图 · 动作 /
时序图 · 视图导出 / 架构图 · 绘制识别 / 架构图 · 尺寸导出 / 界面与快捷键 / 关于;
- 新增架构图全套新功能问答(手绘识别、图元库、橡皮、手动识别、正交连线与角点、
尺寸标注、图层、mm 标尺、A0 图纸、DXF 导出);
- 仓库 `docs/HELP.md` 全量重写(含 FAQ 与快捷键总览)。
## 其它
- 安卓安装名称 / 图标:安装包名称为 **EDC|易得设计**(如显示旧名请卸载后重装);
- 更新通道:仓库 `admin/EasyDesignCollection`(旧地址 301 兼容老客户端);
- 下载 / 上传统一限速 320KB/s;安装包约 53MB(安卓)/ 12MB(Windows 整包)。
+27
View File
@@ -0,0 +1,27 @@
# V1.3.7 更新内容
> ⚠️ 本版为 1.3.5 / 1.3.6 之后的修复增强版。新功能仍可能存在较多 bug 与问题,
> 遇到问题欢迎反馈(开发者邮箱 liuyu65@126.com / 微信 online-goose)。
## 安卓体验修复(本版重点)
- **左上角 logo 按钮**:与「手绘 / 选择」等工具按钮**等高同形**
(圆角矩形、固定高度),不再出现"两头圆"的矮胶囊外观;
- **顶部「识别(N)」按钮**:现在**只识别你刚画的墨迹**——不再误载入示例场景;
- **移除「示例场景」入口**(手绘稿 / 完成图 / 识别演示):保留「清空画布」;
- **「尺寸 · mm」移到属性卡最上方**(选中图形即可看到):
宽度 / 高度 / 长度 / 直径点数值直接修改,几何按比例缩放;
「标注全部」在画布上显示尺寸标签,双击标签也可改值;
- **修复**:文本 / 数值编辑对话框在退场动画期间释放输入控制器导致的偶发异常
(安卓上编辑尺寸、文字、标签时更容易命中)。
## 说明:安卓桌面显示旧名称怎么办
安装包名称已为 **EDC|易得设计**。若桌面/应用列表仍显示旧名(如"时序图设计"),
这是**桌面启动器缓存了旧标签**,不是安装包问题:请**卸载后重新安装一次**,
或重启手机刷新桌面缓存;在应用内「关于」页可核对当前版本号是否为 1.3.7。
## 其它
- 更新通道:仓库 `admin/EasyDesignCollection`(旧地址 301 兼容老客户端);
- 下载 / 上传统一限速 320KB/s;安卓包约 53MB(≈3 分钟)/ Windows 整包约 12MB(≈40 秒)。
+28
View File
@@ -0,0 +1,28 @@
# V1.3.8 更新内容
> ⚠️ 1.3.5 大版本的后续修复增强版。新功能仍可能存在较多 bug 与问题,
> 遇到问题欢迎反馈(开发者邮箱 liuyu65@126.com / 微信 online-goose)。
## 帮助中心:改为垂直排列(不再水平滑动)
- 帮助窗口改为**左侧垂直导航 + 右侧内容**:七个分页(首页与模块 / 时序图 ·
动作 / 时序图 · 视图导出 / 架构图 · 绘制识别 / 架构图 · 尺寸导出 /
界面与快捷键 / **关于**)纵向排列,点击即切换,不需要再左右滑动;
- 修复一处分页控制器长度不一致的问题(可能导致「关于」分页在部分情况下
点不开)。
## 连线端点捕捉稳定性修复("乱飘")
- 连线端点改为**按用户实际画线 / 拖拽的一侧**在图形边框上取点——
不再随两图形中心方向的微小变化在"右边 / 下边"之间乱跳;
- 只有程序化创建(端点恰在图形中心)时才退回"朝向对方"的自动取向;
- 自动单拐角方向也随之以实际端点为准,走线更符合直觉。
## 其它(1.3.7 修复回顾,如未更新过请一并获取)
- 安卓 logo 按钮与手绘按钮等高同形;「识别(N)」只识别当前墨迹;
移除示例场景入口;「尺寸 · mm」移到属性卡最上方;
- 修复编辑对话框在退场动画期间释放输入控制器导致的偶发异常。
> 安卓桌面若仍显示旧名称(如"时序图设计"):属桌面启动器缓存,
> 卸载后重新安装一次即可;应用内「关于」页可核对版本号为 1.3.8。
+32
View File
@@ -0,0 +1,32 @@
# V1.3.9 更新内容
> ⚠️ 1.3.5 大版本的后续修复版。新功能仍可能存在较多 bug 与问题,欢迎反馈
> (开发者邮箱 liuyu65@126.com / 微信 online-goose)。
## 首页「检查更新」按钮修复
- 之前首页右上角是一个**纯图标**(不可点击)——看似"假按钮";现在它是
真正的更新按钮:
- 点击 → 显示「正在检查更新…」;
- 已是最新:弹出提示「当前已是最新版本(vX)」;
- 发现新版本:直接弹出升级对话框(下载 / 安装)。
- 工具栏的更新按钮行为不变(一致)。
## 关于「安卓桌面仍显示旧名称(时序图设计)」
经核查:安装包内应用名称已确认为 **EDC|易得设计**(APK 实测 application-label),
且包名 `cc.sincos.sequence_diagram` 从第一个安卓版本起从未变过——不存在新旧
两个应用并存的情况。如果桌面仍显示旧名,请按下面两步定位:
1. **先确认装的是哪一版**:打开应用 → 首页底部「工程总体设计合集… v1.3.x」,
或「关于」页。若显示的不是 1.3.7+,说明新安装包**实际没有被装上**
(应用内更新流程可能被"安装未知应用"权限拦截),请到 Release 页手动下载
`*.apk` 安装;
2. 若已显示 1.3.9 而桌面名称仍旧:属**桌面启动器标签缓存**——请查看
系统「设置 → 应用 → 找到该应用」确认系统层名称(系统直读安装包,不缓存),
或重启手机 / 卸载后重装一次刷新桌面。
## 其它(如未更新过请一并获取)
- 帮助中心垂直导航、连线端点捕捉稳定(1.3.8);
- 安卓 logo 按钮等高同形、「识别」只识别当前墨迹、「尺寸 · mm」置顶(1.3.7)。
+24 -4
View File
@@ -84,8 +84,16 @@ if ($rel -and $rel.id) {
[System.IO.File]::WriteAllText($tmp, $payload, (New-Object System.Text.UTF8Encoding($false))) [System.IO.File]::WriteAllText($tmp, $payload, (New-Object System.Text.UTF8Encoding($false)))
Write-Host "创建 Release v$Version ..." Write-Host "创建 Release v$Version ..."
$resp = curl.exe -s --max-time 300 -X POST -H "Content-Type: application/json" --data-binary "@$tmp" -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases" $resp = curl.exe -s --max-time 300 -X POST -H "Content-Type: application/json" --data-binary "@$tmp" -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases"
$rel = $resp | ConvertFrom-Json # 响应解析容错:偶发 JSON 解析异常时按 tag 重新查询(创建可能已成功)。
if (-not $rel.id) { throw "创建 Release 失败:$resp" } $rel = $null
try { $rel = $resp | ConvertFrom-Json } catch { $rel = $null }
if (-not $rel -or -not $rel.id) {
curl.exe -s --max-time 300 -o $tagFile "$Server/api/v1/repos/$Owner/$Repo/releases/tags/v$Version" | Out-Null
try {
$rel = [System.IO.File]::ReadAllText($tagFile, [System.Text.Encoding]::UTF8) | ConvertFrom-Json
} catch { $rel = $null }
}
if (-not $rel -or -not $rel.id) { throw "创建 Release 失败:$resp" }
} }
Write-Host "Release id = $($rel.id)" Write-Host "Release id = $($rel.id)"
@@ -106,8 +114,20 @@ function Upload-Asset([string]$path) {
} catch {} } catch {}
Write-Host "上传附件:$name (限速 $UploadLimit)..." Write-Host "上传附件:$name (限速 $UploadLimit)..."
$r = curl.exe -s --limit-rate $UploadLimit -X POST -F "attachment=@$path" -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($rel.id)/assets?name=$name" $r = curl.exe -s --limit-rate $UploadLimit -X POST -F "attachment=@$path" -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($rel.id)/assets?name=$name"
$asset = $r | ConvertFrom-Json # 解析容错:异常时按 tag 复核附件是否已存在(上传可能已成功)。
if (-not $asset.name) { throw "上传失败:$r" } $asset = $null
try { $asset = $r | ConvertFrom-Json } catch { $asset = $null }
if (-not $asset -or -not $asset.name) {
curl.exe -s --max-time 300 -o $curFile "$Server/api/v1/repos/$Owner/$Repo/releases/tags/v$Version" | Out-Null
$okName = $false
try {
$cur2 = [System.IO.File]::ReadAllText($curFile, [System.Text.Encoding]::UTF8) | ConvertFrom-Json
foreach ($a in $cur2.assets) {
if ($a.name -eq $name) { $okName = $true; $asset = $a }
}
} catch {}
if (-not $okName) { throw "上传失败:$r" }
}
Write-Host " 完成:$($asset.browser_download_url)" Write-Host " 完成:$($asset.browser_download_url)"
} }
Upload-Asset $ApkPath Upload-Asset $ApkPath
+38
View File
@@ -0,0 +1,38 @@
// 架构图属性面板回归:选中图元后显示基本信息;已移除的「尺寸标注」不再出现。
import 'package:flutter/material.dart' hide Action;
import 'package:flutter_test/flutter_test.dart';
import 'package:sequence_diagram/arch/arch_models.dart';
import 'package:sequence_diagram/model/models.dart';
import 'package:sequence_diagram/state/app_controller.dart';
import 'package:sequence_diagram/theme/tokens.dart';
import 'package:sequence_diagram/ui/arch_panel.dart';
void main() {
testWidgets('选中图元:属性卡正常显示,且不再有「尺寸 · mm」区',
(WidgetTester tester) async {
final AppController c = AppController(project: Project.demo());
c.addArchShape(const ArchShape(
id: 'S1',
type: ArchShapeType.symbol,
symbolId: 'pe-ground',
rect: Rect.fromLTWH(100, 100, 80, 150),
));
c.selectArch('S1');
await tester.pumpWidget(MaterialApp(
theme: buildTheme(Tokens.light),
home: Scaffold(
body: SingleChildScrollView(child: ArchRightBody(controller: c)),
),
));
await tester.pump();
// 属性卡正常渲染(图元类型中文名)。
expect(find.textContaining('图元'), findsWidgets);
// 已移除:尺寸标注区不存在。
expect(find.textContaining('尺寸 · mm'), findsNothing);
// 清理:先卸载组件树,再释放控制器。
await tester.pumpWidget(const SizedBox());
c.dispose();
});
}
-36
View File
@@ -1,5 +1,4 @@
// 图元库手绘识别测试:内置符号笔迹命中、乱涂拒绝、自定义图元可识别。 // 图元库手绘识别测试:内置符号笔迹命中、乱涂拒绝、自定义图元可识别。
import 'dart:io';
import 'dart:math' as math; import 'dart:math' as math;
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
@@ -108,41 +107,6 @@ void main() {
); );
}); });
test('自定义图元:保存到用户目录后能被识别', () async {
final Directory tmp = await Directory.systemTemp.createTemp('edc-symr-');
addTearDown(() async => tmp.delete(recursive: true));
// 自定义三角形图元。
await SymbolLibrary.saveUser(
const LibSymbol(
id: 'my-tri',
name: '自定义三角',
category: '自定义',
prims: <SymPrim>[
SymPrim(
kind: SymPrimKind.polyline,
pts: <double>[50, 10, 90, 80, 10, 80, 50, 10],
),
],
pins: <SymPin>[],
),
dir: tmp,
);
final List<LibSymbol> catalog = await SymbolLibrary.all(dir: tmp);
final ArchSymbolMatch? m = recognizeArchSymbol(
<List<Offset>>[
<Offset>[
const Offset(50, 10),
const Offset(90, 80),
const Offset(10, 80),
const Offset(50, 10),
],
],
catalog,
);
expect(m, isNotNull, reason: '自定义图元应能被识别(图元库可扩展)');
expect(m!.symbol.id, 'my-tri');
});
test('空 / 过短笔迹:null', () { test('空 / 过短笔迹:null', () {
expect(recognizeArchSymbol(const <List<Offset>>[], SymbolLibrary.builtin), isNull); expect(recognizeArchSymbol(const <List<Offset>>[], SymbolLibrary.builtin), isNull);
expect( expect(
+289 -67
View File
@@ -343,9 +343,17 @@ void main() {
expect(back.connectors.single.mids.length, 2); expect(back.connectors.single.mids.length, 2);
final ArchConnGeometry g = final ArchConnGeometry g =
archConnectorGeometry(back, back.connectors.single); archConnectorGeometry(back, back.connectors.single);
expect(g.pts.length, 4); // 正交走线:路径经过两个折点(顺序保持),所有段横平竖直。
expect(g.pts.length, greaterThanOrEqualTo(4));
expect(g.pts[1], const Offset(40, 0)); expect(g.pts[1], const Offset(40, 0));
expect(g.pts[2], const Offset(40, 60)); expect(g.pts[2], const Offset(40, 60));
expect(g.pts.first, const Offset(0, 0));
expect(g.pts.last, const Offset(100, 0));
for (int i = 0; i < g.pts.length - 1; i++) {
final Offset d = g.pts[i + 1] - g.pts[i];
expect(d.dx.abs() < 0.01 || d.dy.abs() < 0.01, isTrue,
reason: '第 $i 段不是横/竖:$d');
}
}); });
test('连线吸附:开始 / 结束吸附到最近边缘点', () { test('连线吸附:开始 / 结束吸附到最近边缘点', () {
@@ -650,91 +658,305 @@ void main() {
}); });
}); });
group('尺寸编辑(识别后图形)', () { group('默认画布', () {
test('矩形宽 / 圆直径:直接缩放且中心保持', () { test('默认画布 A0:空文档内容边界 1189×841', () {
const ArchShape rect = ArchShape( final Rect b = ArchDoc.empty.contentBounds();
id: 'D1', expect(b.width, 1189);
type: ArchShapeType.rect, expect(b.height, 841);
rect: Rect.fromLTWH(100, 100, 200, 120), });
);
final ArchShape w = archShapeApplyDim(rect, ArchDimKind.width, 300);
expect(w.rect.width, 300);
expect(w.rect.center, rect.rect.center);
expect(w.rect.height, 120);
final ArchShape c = archShapeApplyDim(
const ArchShape(
id: 'D2',
type: ArchShapeType.circle,
rect: Rect.fromLTWH(0, 0, 80, 80),
),
ArchDimKind.diameter,
120,
);
expect(c.rect.width, 120);
expect(c.rect.height, 120);
}); });
test('直线 / 曲线长度:按比例缩放保持形状', () { group('正交连线(一律横平竖直)', () {
const ArchShape line = ArchShape( test('orthoPolyline:斜段拆成横竖台阶且端点保持', () {
id: 'L1', final List<Offset> out = orthoPolyline(<Offset>[
type: ArchShapeType.line, const Offset(0, 0),
rect: Rect.fromLTWH(0, 0, 100, 0), const Offset(100, 50),
a: Offset(0, 0), ]);
b: Offset(100, 0), expect(out.length, greaterThanOrEqualTo(3));
); for (int i = 0; i < out.length - 1; i++) {
expect(archShapeDimValue(line, ArchDimKind.length), 100); final Offset d = out[i + 1] - out[i];
final ArchShape l2 = archShapeApplyDim(line, ArchDimKind.length, 250); expect(d.dx.abs() < 0.01 || d.dy.abs() < 0.01, isTrue,
expect(archShapeDimValue(l2, ArchDimKind.length), closeTo(250, 0.01)); reason: '第 $i 段不是横/竖:$d');
expect(l2.rect.center, line.rect.center); }
expect(out.first, const Offset(0, 0));
expect(out.last, const Offset(100, 50));
});
const ArchShape curve = ArchShape( test('连线几何:无折点自动单拐角;有折点按折点走台阶', () {
const ArchShape a = ArchShape(
id: 'A',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(0, 0, 80, 60),
);
const ArchShape b = ArchShape(
id: 'B',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(300, 200, 80, 60),
);
final ArchDoc doc =
ArchDoc.empty.copyWith(shapes: <ArchShape>[a, b]);
final ArchConnector c1 = ArchConnector(
id: 'C1', id: 'C1',
type: ArchShapeType.curve, fromId: 'A',
rect: Rect.fromLTWH(0, 0, 100, 50), from: a.rect.center,
pts: <Offset>[Offset(0, 0), Offset(100, 0), Offset(100, 50)], toId: 'B',
to: b.rect.center,
); );
expect(archShapeLength(curve), closeTo(150, 0.01)); final ArchConnGeometry g1 = archConnectorGeometry(doc, c1);
final ArchShape c2 = archShapeApplyDim(curve, ArchDimKind.length, 300); for (int i = 0; i < g1.pts.length - 1; i++) {
expect(archShapeLength(c2), closeTo(300, 0.5)); final Offset d = g1.pts[i + 1] - g1.pts[i];
final Rect b2 = archLinearBounds(c2); expect(d.dx.abs() < 0.01 || d.dy.abs() < 0.01, isTrue,
expect(b2.width / b2.height, closeTo(2.0, 0.01)); reason: '无折点第 $i 段不是横/竖');
}
final ArchConnector c2 =
c1.copyWith(mids: <Offset>[const Offset(150, 90)]);
final ArchConnGeometry g2 = archConnectorGeometry(doc, c2);
for (int i = 0; i < g2.pts.length - 1; i++) {
final Offset d = g2.pts[i + 1] - g2.pts[i];
expect(d.dx.abs() < 0.01 || d.dy.abs() < 0.01, isTrue,
reason: '有折点第 $i 段不是横/竖');
}
final double dmin = g2.pts
.map((Offset p) => (p - const Offset(150, 90)).distance)
.reduce((double x, double y) => x < y ? x : y);
expect(dmin, lessThan(2), reason: '路径应经过拖拽的角点');
}); });
test('尺寸标注 JSON 往返', () { test('端点捕捉稳定:按保存的画线侧取边框点(不随中心方向乱跳)', () {
const ArchShape s = ArchShape( const ArchShape a = ArchShape(
id: 'S1', id: 'A',
type: ArchShapeType.rect, type: ArchShapeType.rect,
rect: Rect.fromLTWH(0, 0, 100, 80), rect: Rect.fromLTWH(0, 0, 100, 100),
dims: <ArchDimKind>{ArchDimKind.width, ArchDimKind.height},
); );
final ArchShape back = ArchShape.fromJson( const ArchShape b = ArchShape(
jsonDecode(jsonEncode(s.toJson())) as Map<String, dynamic>); id: 'B',
expect(back.dims.contains(ArchDimKind.width), isTrue); type: ArchShapeType.rect,
expect(back.dims.contains(ArchDimKind.height), isTrue); rect: Rect.fromLTWH(300, 140, 100, 100),
);
final ArchDoc doc =
ArchDoc.empty.copyWith(shapes: <ArchShape>[a, b]);
final ArchConnector c1 = ArchConnector(
id: 'C1',
fromId: 'A',
from: const Offset(0, 50),
toId: 'B',
to: const Offset(350, 190),
);
// 从 A 的左侧画线:置左边中点 → 起点应留在左侧(目标在右下也不跳)。
final ArchConnGeometry g1 = archConnectorGeometry(doc, c1);
expect(g1.pts.first.dx, closeTo(0, 1));
// 从 A 的右侧画线:置右边中点 → 起点应留在右侧。
final ArchConnGeometry g2 =
archConnectorGeometry(doc, c1.copyWith(from: const Offset(100, 50)));
expect(g2.pts.first.dx, closeTo(100, 1));
// 保存端点为图形中心(程序化创建):退回朝向对方,且落在边框上。
final ArchConnGeometry g3 =
archConnectorGeometry(doc, c1.copyWith(from: a.rect.center));
final Offset p = g3.pts.first;
final bool onBorder = (p.dx - a.rect.left).abs() < 1 ||
(p.dx - a.rect.right).abs() < 1 ||
(p.dy - a.rect.top).abs() < 1 ||
(p.dy - a.rect.bottom).abs() < 1;
expect(onBorder, isTrue);
});
}); });
test('控制器:改值缩放 + 标注开关', () { group('连线法向与自动避让', () {
test('水平相邻:出口水平、箭头垂直射入目标左边', () {
const ArchShape a = ArchShape(
id: 'A',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(0, 0, 100, 80));
const ArchShape b = ArchShape(
id: 'B',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(300, 40, 100, 80));
final ArchDoc doc =
ArchDoc.empty.copyWith(shapes: <ArchShape>[a, b]);
final ArchConnector conn = ArchConnector(
id: 'C1',
fromId: 'A',
from: a.rect.center,
toId: 'B',
to: b.rect.center,
);
final ArchConnGeometry g = archConnectorGeometry(doc, conn);
expect(g.start.dx, closeTo(100, 0.5));
expect(g.end.dx, closeTo(300, 0.5));
expect((g.pts[1].dy - g.start.dy).abs(), lessThan(0.5),
reason: '出口应沿法向(水平)');
final Offset lastD = g.end - g.pts[g.pts.length - 2];
expect(lastD.dy.abs(), lessThan(0.5), reason: '箭头应水平射入');
expect(lastD.dx, greaterThan(0));
});
test('垂直相邻:出口垂直、箭头垂直射入目标上边', () {
const ArchShape a = ArchShape(
id: 'A',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(0, 0, 100, 80));
const ArchShape b = ArchShape(
id: 'B',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(60, 300, 100, 80));
final ArchDoc doc =
ArchDoc.empty.copyWith(shapes: <ArchShape>[a, b]);
final ArchConnector conn = ArchConnector(
id: 'C1',
fromId: 'A',
from: a.rect.center,
toId: 'B',
to: b.rect.center,
);
final ArchConnGeometry g = archConnectorGeometry(doc, conn);
expect(g.start.dy, closeTo(80, 0.5));
expect(g.end.dy, closeTo(300, 0.5));
expect((g.pts[1].dx - g.start.dx).abs(), lessThan(0.5),
reason: '出口应沿法向(垂直)');
final Offset lastD = g.end - g.pts[g.pts.length - 2];
expect(lastD.dx.abs(), lessThan(0.5), reason: '箭头应垂直射入');
expect(lastD.dy, greaterThan(0));
});
test('多条连线贴同一条边:自动错开(槽位避让)', () {
const ArchShape hub = ArchShape(
id: 'H',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(0, 0, 100, 240));
const ArchShape b1 = ArchShape(
id: 'B1',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(320, 0, 80, 60));
const ArchShape b2 = ArchShape(
id: 'B2',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(320, 90, 80, 60));
const ArchShape b3 = ArchShape(
id: 'B3',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(320, 180, 80, 60));
final List<ArchConnector> conns = <ArchConnector>[
ArchConnector(
id: 'C1',
fromId: 'H',
from: hub.rect.center,
toId: 'B1',
to: b1.rect.center),
ArchConnector(
id: 'C2',
fromId: 'H',
from: hub.rect.center,
toId: 'B2',
to: b2.rect.center),
ArchConnector(
id: 'C3',
fromId: 'H',
from: hub.rect.center,
toId: 'B3',
to: b3.rect.center),
];
final ArchDoc doc = ArchDoc.empty.copyWith(
shapes: <ArchShape>[hub, b1, b2, b3],
connectors: conns,
);
final List<double> ys = <double>[
for (final ArchConnector cn in conns)
archConnectorGeometry(doc, cn).start.dy,
];
// 起点互不相同、均落在 hub 右边框内,并保持自然顺序。
expect(ys[0], lessThan(ys[1]));
expect(ys[1], lessThan(ys[2]));
for (final double y in ys) {
expect(y, greaterThan(0));
expect(y, lessThan(240));
}
for (final ArchConnector cn in conns) {
final ArchConnGeometry g = archConnectorGeometry(doc, cn);
expect(g.start.dx, closeTo(100, 0.5), reason: '起点应贴 hub 右边框');
}
});
test('带折点:最后一段仍沿法向射入目标边', () {
const ArchShape a = ArchShape(
id: 'A',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(0, 0, 100, 80));
const ArchShape b = ArchShape(
id: 'B',
type: ArchShapeType.rect,
rect: Rect.fromLTWH(300, 200, 100, 80));
final ArchDoc doc =
ArchDoc.empty.copyWith(shapes: <ArchShape>[a, b]);
final ArchConnector conn = ArchConnector(
id: 'C1',
fromId: 'A',
from: a.rect.center,
toId: 'B',
to: b.rect.center,
mids: const <Offset>[Offset(150, 90)],
);
final ArchConnGeometry g = archConnectorGeometry(doc, conn);
final Offset lastD = g.end - g.pts[g.pts.length - 2];
expect(lastD.dx.abs() < 0.5 || lastD.dy.abs() < 0.5, isTrue,
reason: '最后一段应横平竖直(法向)');
const Rect br = Rect.fromLTWH(300, 200, 100, 80);
final bool onBorder = (g.end.dx - br.left).abs() < 0.5 ||
(g.end.dx - br.right).abs() < 0.5 ||
(g.end.dy - br.top).abs() < 0.5 ||
(g.end.dy - br.bottom).abs() < 0.5;
expect(onBorder, isTrue, reason: '终点应落在目标边框上');
});
});
group('橡皮擦', () {
test('连续擦除计入一次撤销', () {
final AppController c = AppController(project: Project.demo()); final AppController c = AppController(project: Project.demo());
addTearDown(c.dispose); addTearDown(c.dispose);
c.addArchShape(const ArchShape( c.addArchShape(const ArchShape(
id: 'S1', id: 'S1',
type: ArchShapeType.rect, type: ArchShapeType.rect,
rect: Rect.fromLTWH(10, 10, 100, 60), rect: Rect.fromLTWH(0, 0, 100, 60),
)); ));
c.setArchShapeDim('S1', ArchDimKind.width, 260); c.addArchShape(const ArchShape(
expect(c.arch.shapeById('S1')!.rect.width, 260); id: 'S2',
c.toggleArchShapeDim('S1', ArchDimKind.width); type: ArchShapeType.rect,
expect( rect: Rect.fromLTWH(200, 0, 100, 60),
c.arch.shapeById('S1')!.dims.contains(ArchDimKind.width), isTrue); ));
c.toggleArchShapeDim('S1', ArchDimKind.width); c.beginArchErase();
expect( expect(c.eraseArchIds(<String>{'S1'}), 1);
c.arch.shapeById('S1')!.dims.contains(ArchDimKind.width), isFalse); expect(c.eraseArchIds(<String>{'S2'}), 1);
expect(c.arch.shapes, isEmpty);
c.undo();
expect(c.arch.shapes.length, 2, reason: '一次连续擦除应整步回退');
});
}); });
test('默认画布 A0:空文档内容边界 1189×841', () { group('手绘识别模式', () {
final Rect b = ArchDoc.empty.contentBounds(); test('默认自动(桌面);可切换手动确认', () {
expect(b.width, 1189); final AppController c = AppController(project: Project.demo());
expect(b.height, 841); addTearDown(c.dispose);
expect(c.archAutoRecognize, isTrue); // Windows 测试环境
c.setArchAutoRecognize(false);
expect(c.archAutoRecognize, isFalse);
expect(c.status, contains('手动'));
});
test('识别按钮只识别当前墨迹(不载入示例)', () {
final AppController c = AppController(project: Project.demo());
addTearDown(c.dispose);
c.archClear();
final int t0 = c.archPlayToken;
c.archRecognizeInk();
expect(c.archPlayToken, t0, reason: '没有墨迹时不应触发识别');
expect(c.arch.strokes, isEmpty);
expect(c.arch.shapes, isEmpty, reason: '不得载入示例图形');
c.addArchStroke(const ArchStroke(
id: 'K1',
pts: <Offset>[Offset(0, 0), Offset(10, 0), Offset(10, 10)],
));
c.archRecognizeInk();
expect(c.archPlayToken, t0 + 1);
expect(c.arch.strokes.length, 1, reason: '识别前墨迹保持不动');
}); });
}); });
} }
+28
View File
@@ -0,0 +1,28 @@
// 帮助中心回归:垂直导航正常渲染、可切换分页,内容不为空。
import 'package:flutter/material.dart' hide Action;
import 'package:flutter_test/flutter_test.dart';
import 'package:sequence_diagram/theme/tokens.dart';
import 'package:sequence_diagram/ui/dialogs.dart';
void main() {
testWidgets('帮助中心:垂直导航 + 内容非空 + 可切到「关于」', (WidgetTester tester) async {
await tester.pumpWidget(MaterialApp(
theme: buildTheme(Tokens.light),
home: const Scaffold(body: HelpDialog()),
));
await tester.pump();
// 左侧垂直导航:分页标题可见。
expect(find.text('首页与模块'), findsOneWidget);
expect(find.text('架构图 · 绘制识别'), findsOneWidget);
expect(find.text('关于'), findsOneWidget);
// 内容区非空:首个分页的问答项存在(IndexedStack 全部子页在树中)。
expect(find.text('打开软件是空白首页'), findsOneWidget);
// 切到「关于」分页:不应抛异常,且关于页内容在树中。
await tester.tap(find.text('关于'));
await tester.pumpAndSettle();
expect(find.textContaining('EDC易得'), findsWidgets);
});
}
+1 -1
View File
@@ -26,7 +26,7 @@ void main() {
expect(moduleOf(AppMode.home), isNull); expect(moduleOf(AppMode.home), isNull);
expect(moduleOf(AppMode.sequence)!.name, '时序图'); expect(moduleOf(AppMode.sequence)!.name, '时序图');
expect(moduleOf(AppMode.architecture)!.suffix, '.arch.json'); expect(moduleOf(AppMode.architecture)!.suffix, '.arch.json');
expect(appModeLabel(AppMode.home), 'EDC|易得设计'); expect(appModeLabel(AppMode.home), 'EDC易得');
expect(appModeLabel(AppMode.sequence), contains('时序图')); expect(appModeLabel(AppMode.sequence), contains('时序图'));
}); });
}); });
-6
View File
@@ -126,12 +126,6 @@ ArchDoc makeArch() => ArchDoc(
symbolId: ArchShapeType.values[i] == ArchShapeType.symbol symbolId: ArchShapeType.values[i] == ArchShapeType.symbol
? 'pe-ground' ? 'pe-ground'
: '', : '',
dims: i == 0
? const <ArchDimKind>{
ArchDimKind.width,
ArchDimKind.height,
}
: const <ArchDimKind>{},
), ),
], ],
strokes: const <ArchStroke>[ strokes: const <ArchStroke>[
-47
View File
@@ -1,5 +1,4 @@
// 图元库测试:内置符号完整性、JSON 往返、用户目录存取与合并覆盖、坐标换算。 // 图元库测试:内置符号完整性、JSON 往返、用户目录存取与合并覆盖、坐标换算。
import 'dart:io';
import 'dart:ui' show Path, Rect; import 'dart:ui' show Path, Rect;
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
@@ -57,50 +56,4 @@ void main() {
expect(b.top, closeTo(20, 0.01)); expect(b.top, closeTo(20, 0.01));
expect(b.bottom, closeTo(220, 0.01)); expect(b.bottom, closeTo(220, 0.01));
}); });
test('用户目录存取 / 删除 / all() 合并与覆盖', () async {
final Directory tmp = await Directory.systemTemp.createTemp('edc-sym-');
addTearDown(() async => tmp.delete(recursive: true));
expect(await SymbolLibrary.loadUser(dir: tmp), isEmpty);
const LibSymbol custom = LibSymbol(
id: 'my-sym',
name: '自定义符号',
category: '自定义',
prims: <SymPrim>[
SymPrim(kind: SymPrimKind.circle, pts: <double>[50, 50], r: 30),
],
pins: <SymPin>[SymPin(id: '1', x: 50, y: 0)],
);
await SymbolLibrary.saveUser(custom, dir: tmp);
final List<LibSymbol> loaded = await SymbolLibrary.loadUser(dir: tmp);
expect(loaded.single.id, 'my-sym');
final List<LibSymbol> merged = await SymbolLibrary.all(dir: tmp);
expect(merged.length, SymbolLibrary.builtin.length + 1);
// 用户符号覆盖同名内置 id。
await SymbolLibrary.saveUser(
const LibSymbol(
id: 'motor-m',
name: '电机(自定义)',
category: '自定义',
prims: <SymPrim>[
SymPrim(kind: SymPrimKind.rect, pts: <double>[20, 20, 60, 60]),
],
pins: <SymPin>[SymPin(id: '1', x: 50, y: 0)],
),
dir: tmp,
);
final List<LibSymbol> merged2 = await SymbolLibrary.all(dir: tmp);
expect(merged2.length, SymbolLibrary.builtin.length + 1);
expect(
merged2.firstWhere((LibSymbol s) => s.id == 'motor-m').name,
'电机(自定义)',
);
await SymbolLibrary.deleteUser('my-sym', dir: tmp);
await SymbolLibrary.deleteUser('motor-m', dir: tmp);
expect(await SymbolLibrary.loadUser(dir: tmp), isEmpty);
});
} }
+2 -2
View File
@@ -1,4 +1,4 @@
// Microsoft Visual C++ generated resource script. // Microsoft Visual C++ generated resource script.
// //
#pragma code_page(65001) #pragma code_page(65001)
#include "resource.h" #include "resource.h"
@@ -90,7 +90,7 @@ BEGIN
BLOCK "040904e4" BLOCK "040904e4"
BEGIN BEGIN
VALUE "CompanyName", "呆头鹅" "\0" VALUE "CompanyName", "呆头鹅" "\0"
VALUE "FileDescription", "EDC|易得设计 Easy Design Collection" "\0" VALUE "FileDescription", "EDC易得 Easy Design Collection" "\0"
VALUE "FileVersion", VERSION_AS_STRING "\0" VALUE "FileVersion", VERSION_AS_STRING "\0"
VALUE "InternalName", "EasyDesignCollection" "\0" VALUE "InternalName", "EasyDesignCollection" "\0"
VALUE "LegalCopyright", "Copyright (C) 2026 呆头鹅. All rights reserved." "\0" VALUE "LegalCopyright", "Copyright (C) 2026 呆头鹅. All rights reserved." "\0"
+1 -1
View File
@@ -38,7 +38,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
Win32Window::Size size( Win32Window::Size size(
static_cast<unsigned int>(screen_width / scale * 0.94), static_cast<unsigned int>(screen_width / scale * 0.94),
static_cast<unsigned int>(screen_height / scale * 0.94)); static_cast<unsigned int>(screen_height / scale * 0.94));
if (!window.Create(L"\u65F6\u5E8F\u56FE\u8BBE\u8BA1\u5668", origin, size)) { if (!window.Create(L"EDC\u6613\u5F97", origin, size)) {
return EXIT_FAILURE; return EXIT_FAILURE;
} }
window.SetQuitOnClose(true); window.SetQuitOnClose(true);