Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe5e0be131 |
@@ -4,7 +4,7 @@
|
||||
|
||||
- **两种视图,一份数据**:条形节拍(甘特 / 流程图 + 依赖箭头) ⇄ 圆周节拍(同心圆相位图,12 点钟起始,一圈 = 一个循环,每新增一个动作在最外层加一层)
|
||||
- **顺序一目了然**:绿色实线箭头 = FS 严格顺序(完成后启动),琥珀虚线 = SS 并行重叠(可提前启动),关键路径带 ★
|
||||
- **专业单位体系**:时间 `ms / s / min`、相位 `° / %`、显示精度可配,工艺参数面板统一管理
|
||||
- **专业单位体系**:时间 `ms / s / min`、相位 `° / %`、显示精度可配,文档设置统一管理
|
||||
- **响应快**:自研 Canvas 渲染,双层缓存 + 脏区重绘 + 空间索引,1000 动作仍保持 60 fps
|
||||
- **深色 / 浅色双主题**:右上角 ☀ / ☾ 一键切换,语义颜色不变,导出 SVG 与屏幕一致
|
||||
- **导出 SVG**:矢量、分层、带语义 `id` / `data-*` 元数据,可直接进工艺卡与 MES
|
||||
@@ -31,7 +31,7 @@ scripts\build.bat # 发布版(构建并复制到浅目录 dist
|
||||
- **双击画布色块(条形 / 圆弧)或左侧动作行**直接进入动作编辑;编辑工具条浮于画布,功能不重复
|
||||
- **工位管理**:任意增删工位、改名称与颜色、调整顺序;删除工位后其动作自动改挂到第一个工位
|
||||
- 右侧属性面板:动作属性、角度滑杆、依赖增删;工艺单位与精度
|
||||
- 工艺参数面板(`F2`):`ms/s/min`、`°/%`、显示精度、换算表、吸附与网格
|
||||
- 文档设置(`F2`):`ms/s/min`、`°/%`、显示精度、换算表、泳道策略、自动保存、吸附与网格
|
||||
- 节拍统计(循环周期 / 动作数 / 关键路径 / 最大并行度 / 相位覆盖率 / 瓶颈工位),只展示可由项目数据推导的指标
|
||||
- 深 / 浅双主题(`F3`);`Ctrl+滚轮` 缩放、`Ctrl+Z/Y` 撤销重做
|
||||
- **左右侧栏可隐藏 / 显示,并可钉住**:钉住时固定占位,取消钉住后悬浮、鼠标移开自动收起
|
||||
@@ -58,7 +58,7 @@ scripts\build.bat # 发布版(构建并复制到浅目录 dist
|
||||
| --- | --- |
|
||||
|  |  |
|
||||
|
||||
**工艺参数面板**(单位与精度 / 循环与相位 / 换算表 / 编辑辅助)
|
||||
**文档设置**(单位与精度 / 循环与相位 / 泳道 / 自动保存 / 换算表 / 编辑辅助)
|
||||
|
||||

|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ lib/
|
||||
├── app_shell.dart # 三栏外壳:工具栏 / 侧栏 / 状态栏 / 快捷键
|
||||
├── canvas_view.dart # 画布手势层(选择 / 拖拽 / 缩放 / 平移 / 右键)
|
||||
├── canvas_overlays.dart # 画布浮层(标题 / 图例 / 统计 / 预览 / 浮动工具条)
|
||||
├── dialogs.dart # 文件浏览器 / 动作编辑 / 依赖编辑 / 工艺参数 / 帮助
|
||||
├── dialogs.dart # 文件浏览器 / 动作编辑 / 依赖编辑 / 文档设置 / 帮助
|
||||
└── app_logo.dart # 时钟徽标(与 .ico 同源)
|
||||
```
|
||||
|
||||
|
||||
+2
-2
@@ -372,9 +372,9 @@ Model (单一数据源)
|
||||
| 右键动作 | 上下文菜单:改层、改色、复制、设为关键路径起点、删除 |
|
||||
| 相位游标 | 拖动时两视图同步显示当前相位与对应时间(按当前单位) |
|
||||
| 单位下拉(工具栏) | 一键切换 `ms / s / min`,全界面即时换算,模型数值不变 |
|
||||
| 工艺参数(F2) | 打开设置面板:单位与精度 / 循环与相位 / 编辑辅助 / 显示 / 导出 / 快捷键 |
|
||||
| 文档设置(F2) | 打开设置面板:单位与精度 / 循环与相位 / 泳道 / 自动保存 / 编辑辅助 / 显示 / 导出 / 快捷键 |
|
||||
|
||||
**工艺参数面板**(见 `demo/unit-settings.png`):
|
||||
**文档设置面板**(见 `demo/unit-settings.png`):
|
||||
|
||||
- **时间单位**:`ms` / `s`(推荐)/ `min` 三张卡片,附适用场景与实时换算示例(如 `467 ms → 0.467 s`);
|
||||
- **相位单位**:`°` / `%` 切换,示例 `105.0° ⇄ 29.17%`;
|
||||
|
||||
+57
-20
@@ -41,8 +41,8 @@
|
||||
| 左 | 新建 / 打开 / 保存 | **纯图标**(`Ctrl+N / O / S`) |
|
||||
| 左 | 撤销 / 重做 | **纯图标**,不可用时自动置灰(`Ctrl+Z / Y`) |
|
||||
| 左 | **AI 生成** | 打开自然语言生成对话框 |
|
||||
| 左 | 条形节拍 / 圆周节拍 | 视图切换(两种视图共享同一份数据) |
|
||||
| 右 | 导出 SVG / 导出 PNG | 唯一的导出入口 |
|
||||
| 左 | 条形节拍 / 圆周节拍 / 流程图 | 视图切换(三种视图共享同一份数据;流程图由时序图自动生成、只读) |
|
||||
| 右 | 导出(下拉菜单) | 唯一的导出入口:SVG / PNG 三种视图通用;流程图另有 drawio |
|
||||
| 右 | 缩放控件 | `− 100% +` |
|
||||
| 右 | 适应视图 | **纯图标**(自动缩放并居中到完整可见) |
|
||||
| 右 | 单位下拉 | `ms / s / min` 快速切换 |
|
||||
@@ -54,9 +54,9 @@
|
||||
|
||||
### 左侧栏(自上而下)
|
||||
|
||||
1. **时序创建和编辑** —— 单行入口「编辑时序与节拍参数」,打开工艺参数对话框(项目名、循环时长、单位精度、相位分区等)。
|
||||
1. **文档设置** —— 单行入口「文档设置」(同 `F2`):项目名、循环时长、单位精度、**泳道策略**(空泳道保留 / 移除)、**自动保存**(默认 10 分钟)、相位分区等。
|
||||
2. **动作和执行编辑** —— 「新建 / 删除」按钮 + 动作 / 泳道列表;列表下方是「**编辑工位**」与「**编辑相位分区**」两个管理入口。
|
||||
3. **视图模式** —— 条形节拍 / 圆周节拍。
|
||||
3. **视图模式** —— 条形节拍 / 圆周节拍(流程图入口在顶部工具栏的三段切换中)。
|
||||
4. **显示选项** —— 双刻度、依赖箭头、跨循环标记、分区标注、圆环背景、层标注等开关。
|
||||
5. **工位负载 / 相位占用** —— 每个工位的累计角度与占比进度条。
|
||||
6. **操作提示** —— 常用拖拽与快捷键速查。
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
### 画布浮层
|
||||
|
||||
- **顶部标题**:条形视图显示「条形时序视图」,圆周视图显示「圆周时序视图」,下方一行说明箭头含义。
|
||||
- **顶部标题**:条形 / 圆周显示「视图名 +(线型说明)」单行;流程图仅标题(说明在帮助中)。
|
||||
- **左下角**:条形视图显示「节拍统计」按钮与「编辑工具」条。
|
||||
- **右下角**:实时预览卡(条形 ↔ 圆周联动缩略)。
|
||||
- **圆周视图右侧**:纵向浮动工具条(添加 / 编辑 / 复制 / 删除 / 层± / 对齐)。
|
||||
@@ -86,7 +86,7 @@
|
||||
|
||||
**我要新建一个空白方案**
|
||||
1. 顶部「**新建**」图标(或 `Ctrl+N`)→ 生成含 2 个工位、2 个动作(动作 1 / 动作 2)的空白节拍。
|
||||
2. 左侧「时序创建和编辑」→「编辑时序与节拍参数」里可修改**项目名**与**循环时长**。
|
||||
2. 左侧「文档设置」里可修改**项目名**与**循环时长**。
|
||||
|
||||
**我要打开已有方案**
|
||||
1. 顶部「**打开**」图标(或 `Ctrl+O`)→ 应用内文件浏览器选择 `.seq.json`。
|
||||
@@ -120,7 +120,7 @@
|
||||
## C. 时间与相位:循环长度、起止角、时长
|
||||
|
||||
**我要修改循环长度(时间轴长度)**
|
||||
- 左侧「时序创建和编辑」→「**编辑时序与节拍参数**」→「循环与相位」→ 循环时长 → 应用;或
|
||||
- 左侧「文档设置」→「循环与相位」→ 循环时长 → 应用;或
|
||||
- 按 `F2` 打开同一对话框。
|
||||
|
||||
> 时间只存于 `cycle.durationMs`(毫秒);角度 = `ms / cycleMs × 360`。改循环时长不会丢失角度精度。
|
||||
@@ -143,11 +143,26 @@
|
||||
**泳道(条形)与轨道(圆周)对应同一个物理执行器**,一条泳道 / 轨道可以容纳**多个互不重叠**的动作(类似音频轨道):
|
||||
|
||||
- 拖拽动作**上下移动**(条形视图)或 **Shift + 径向拖拽**(圆周视图)即可换道;
|
||||
- 只要该时间段目标泳道里没有别的动作就能放上去;若时间重叠会被拒绝并提示;
|
||||
- 泳道标题会把该道内的多个动作**合并显示**(如 `A1 上料 / A2 定位夹紧`),最多两行,用 `/` 分隔;
|
||||
- 只要该时间段目标泳道里没有别的动作就能放上去;若时间重叠会有提示;
|
||||
- 泳道标题会把该道内的多个动作**合并显示**(如 `A1 上料 / A2 定位夹紧`),`/` 分隔、
|
||||
按固定宽度**自动换行**(多槽位泳道会一直换行到泳道高度不足为止);
|
||||
- 左侧列表也按泳道分组:单动作泳道显示为普通行,多动作泳道显示合并标题。
|
||||
|
||||
> 含义:一条泳道 = 一个气缸 / 伺服轴等执行器;一个色块 = 该执行器上的一个动作。
|
||||
**泳道加宽(多槽位,1–5)**
|
||||
- 默认每条泳道 **1 槽**;同一时间并行的动作**优先用不同工位 / 泳道区分**;
|
||||
- 需要同一泳道并行时:**双击条形视图左侧泳道编号**(或右键空白泳道 /
|
||||
点左侧栏「N 槽」徽标)→ 选 **1–5 槽**(5 为上限);
|
||||
- 效果:条形视图同一泳道分**多条子行**、圆周视图分**多条同心子环**、
|
||||
流程图分**多条子列**(泳道带自动加宽);
|
||||
- 槽位之间自动留出间距,保证依赖箭头与标签放得下;拖拽动作可同时**换道 + 换槽位**;
|
||||
- 加宽不会打散已有动作(全部留在槽 1,由你拖拽分配)。
|
||||
|
||||
**空泳道策略(可设置)**
|
||||
- `F2 文档设置` →「泳道」→ **保留空泳道**(默认开):动作全部移走的泳道保留、序号不变;
|
||||
- 关闭后空泳道自动移除、序号顺延;条形空行 / 圆周空环 / 流程图空列与左侧栏同步。
|
||||
|
||||
> 含义:一条泳道 = 一个气缸 / 伺服轴等执行器;一个色块 = 该执行器上的一个动作;
|
||||
> 加宽后的槽位 = 该执行器可并行的动作数。
|
||||
|
||||
---
|
||||
|
||||
@@ -184,8 +199,10 @@
|
||||
## E. 工位:增删改与排序
|
||||
|
||||
**工位是什么**
|
||||
- 动作的**归属单元**,决定条形视图中的分组与排序,也用于「工位负载」统计。
|
||||
- 一个流程可以有任意多个工位。
|
||||
- 动作的**归属单元**(谁在做:上料 / 加工 / 检测…),决定条形视图中的分组与排序,
|
||||
也用于「工位负载」统计;一个流程可以有任意多个工位。
|
||||
- **与泳道的关系**:工位 = 物理归属(谁在做);泳道 / 轨道 = 执行器轨道(并行关系)。
|
||||
并行动作**优先用不同工位 / 泳道区分**;同一工位需要并行时再用「泳道加宽」。
|
||||
|
||||
**我要编辑工位**
|
||||
1. 左侧「动作和执行编辑」→「**编辑工位**」。
|
||||
@@ -204,8 +221,10 @@
|
||||
## F. 相位分区:编辑名称、起止角、数量
|
||||
|
||||
**相位分区是什么**
|
||||
- 把一个循环按角度划分成的若干**命名工艺阶段**(默认:上料 / 夹紧 / 加工 / 检测 / 下料);
|
||||
- 条形图顶部的标注带、右侧属性里的「相位归属」都按它判断。
|
||||
- 把一个循环按角度划分成的若干**命名工艺阶段**(默认:上料 / 加工 / 检测);
|
||||
- **三种视图同步呈现**:条形图为顶部标注色带、圆周视图为最外圈相位环与径向边界、
|
||||
流程图为左侧竖排阶段栏;右侧属性的「相位归属」也按它判断;
|
||||
- 分区允许**重叠**、允许**留空**;结束角 `> 360°` 表示跨圈。
|
||||
|
||||
**我要编辑相位分区**
|
||||
1. 左侧「动作和执行编辑」→「**编辑相位分区**」;或 `F2` →「相位分区」→「编辑…」。
|
||||
@@ -295,15 +314,21 @@
|
||||
|
||||
---
|
||||
|
||||
## J. 导出:SVG / PNG
|
||||
## J. 导出:SVG / PNG / drawio
|
||||
|
||||
**导出入口**
|
||||
- 顶部「**导出**」下拉菜单(唯一入口):
|
||||
- 「导出 SVG」「导出 PNG」:三种视图(条形 / 圆周 / 流程图)通用;
|
||||
- 「导出 drawio」:**仅流程图视图提供** —— 输出 diagrams.net(draw.io)
|
||||
可继续编辑的工程文件(泳道、相位分区、依赖关系均保留)。
|
||||
|
||||
**我要导出矢量图(进工艺卡 / MES)**
|
||||
- 顶部「**导出 SVG**」→ 选择保存位置。SVG 分层、带语义 `id` 与 `data-*`:
|
||||
- 「导出 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`。
|
||||
- 「导出 PNG」→ 按 2 倍像素比导出当前画布为 `.png`。
|
||||
|
||||
> 导出入口只在顶部工具栏提供,右侧属性栏不再重复。
|
||||
|
||||
@@ -314,6 +339,11 @@
|
||||
**我要保存**
|
||||
- 顶部「保存」图标(`Ctrl+S`)写入 `.seq.json`,并在同目录生成 `<文件名>.bak` 备份。
|
||||
|
||||
**自动保存(可配置)**
|
||||
- `F2 文档设置` →「自动保存」:默认**每 10 分钟**自动保存一次
|
||||
(可选 1 / 5 / 10 / 30 分钟,或关闭);
|
||||
- 需先手动保存过一次(有文件路径)才生效;自动保存与手动保存一样会更新 `.bak`。
|
||||
|
||||
**异常退出后恢复**
|
||||
- 软件每 **5 秒**写入本地快照;若上次未正常退出,下次启动会弹出恢复向导,
|
||||
可选择「恢复自动快照 / 从 .bak 恢复 / 忽略并删除快照」。
|
||||
@@ -364,9 +394,16 @@ ms = angle / 360 × cycleMs
|
||||
|
||||
## O. 授权(License)
|
||||
|
||||
**导出需要授权**:未授权时「导出 SVG / PNG」按钮置灰。
|
||||
> **当前为「开放授权版本」**:1.3.4 起临时冻结授权校验,**无需 `.lic` 即可导出**
|
||||
> SVG / PNG / drawio;后续功能丰富后会恢复授权校验,并提前在官网与帮助中公告。
|
||||
|
||||
1. 打开「帮助 → 关于」,查看**本机 MAC** 与**授权申请邮箱 liuyu65@126.com**;
|
||||
**联系方式**
|
||||
- 开发者邮箱:`liuyu65@126.com`;
|
||||
- **设计交流群**:添加开发者微信 **online-goose**,加入「设计与制造业设计交流群」;
|
||||
- 官网:`sincos.cc`。
|
||||
|
||||
**(以下为恢复授权后的流程,仅作预留)**
|
||||
1. 打开「帮助 → 关于」,查看**本机 MAC** 与**授权申请邮箱**;
|
||||
2. 把本机 MAC 发送到该邮箱申请授权,收到 `.lic` 文件(一行文本);
|
||||
3. 把 `.lic` 放入软件目录下的 **`license`** 文件夹,重启软件即可导出。
|
||||
|
||||
@@ -394,7 +431,7 @@ ms = angle / 360 × cycleMs
|
||||
| `Ctrl+Z` / `Ctrl+Y` | 撤销 / 重做 |
|
||||
| `Ctrl+S` / `Ctrl+O` / `Ctrl+N` | 保存 / 打开 / 新建 |
|
||||
| `Delete` | 删除选中动作(至少保留一个) |
|
||||
| `F1` / `F2` / `F3` | 帮助 / 编辑时序与节拍参数 / 深浅主题 |
|
||||
| `F1` / `F2` / `F3` | 帮助 / 文档设置 / 深浅主题 |
|
||||
|
||||
### 工程文件格式(`.seq.json`)
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
# 开发计划(Roadmap)
|
||||
|
||||
> 更新:2026-10-09 | 当前版本:v1.3.3 | 维护:呆头鹅
|
||||
>
|
||||
> 约定:每轮开发先在本地构建并验证,确认无 bug 后再提交推送并发布 Release;
|
||||
> 客户端更新始终**直接以 `releases/latest` 为准,一次升级到最新版本**;
|
||||
> 服务器只保留**最新一个版本**的安装包附件(Release 记录与说明全部保留)。
|
||||
|
||||
## 一、总体路线
|
||||
|
||||
| 版本 | 主题 | 状态 |
|
||||
| --- | --- | --- |
|
||||
| **v1.3.4** | 泳道拓宽计划(空泳道策略 + 多槽位泳道,扩展到圆周图 / 流程图) | 开发中 |
|
||||
| **v1.3.5** | 软件更名 + 架构图设计能力(含手写笔涂鸦识别) | 规划 |
|
||||
| **v1.3.6** | 硬件组态 / IO 规划表 / 元器件表 → 网络拓扑 → P&ID 图 | 规划 |
|
||||
| **v2.0.1** | 大版本:新数据类型、视图报表、协作云端、AI 大跨越 | 规划 |
|
||||
|
||||
## 二、v1.3.4 泳道拓宽计划(本轮)
|
||||
|
||||
1. **空泳道策略(可设置)**
|
||||
- 当一个泳道的动作全部被移走后:**保留空泳道**(行 / 环 / 列保留,序号不变)
|
||||
或**直接移除**(现有行为),两种策略可在设置中切换;
|
||||
- 同步完善到条形视图、圆周视图(空环)与流程图(空列),以及左侧动作列表、
|
||||
状态栏统计等派生显示。
|
||||
2. **泳道多槽位(1 → 最多 5 个并列动作)**
|
||||
- 一个泳道不再只能放一行动作:提供操作(双击泳道 / 槽位控件)将泳道加宽为
|
||||
2~5 个槽位;同一时间并行的动作放入不同槽位,避免在单行上互相重叠;
|
||||
- 每个槽位内的动作沿时间轴正常排布;拖动动作时可在槽位间切换;
|
||||
- **三个视图同步**:
|
||||
- 条形视图:泳道内按槽位分成多条子行;
|
||||
- 圆周视图:同一层内按槽位分成多条同心子环;
|
||||
- 流程图:同一泳道列内按槽位分成多条子列。
|
||||
3. **并排间距与依赖箭头**
|
||||
- 同一泳道内的并排动作之间保留可配置间距,保证前置依赖箭头(FS / SS)与
|
||||
标签有足够空间;多条连线继续使用「自动错开 + 可拖拽调整走线」(v1.3.3 已实现)。
|
||||
4. **更新体验**
|
||||
- 更新检查确认「直接升级到最新版本」(不做逐版本升级),更新对话框中明确提示
|
||||
“将直接升级到 vX.Y.Z(最新版本)”。
|
||||
|
||||
## 三、v1.3.5 更名与架构图
|
||||
|
||||
- **软件更名**:`Easy Design Collection`,中文名 **易得设计集**
|
||||
(窗口标题、Logo、关于页、安装包命名、README 等全量替换)。
|
||||
- **架构图设计能力**:在现有节拍设计之外,扩展“架构图”设计;
|
||||
交互与 UI 将采用**全新的设计语言**(由需求方提供设计稿)。
|
||||
- **手写笔涂鸦识别**:支持手写笔在画布上涂鸦(画方块、圆圈、线条等),
|
||||
**自动识别并转换为模块 / 元件**,体验参考 Apple 的手写识别(Freeform / 备忘录)。
|
||||
|
||||
## 四、v1.3.6 硬件组态 → 拓扑 → P&ID
|
||||
|
||||
1. **硬件组态 / 硬件组合**:PLC、变频器、各类模块的选型与组态;
|
||||
2. **IO 规划表**:点位表(DI / DO / AI / AO)规划、模块分配与导出;
|
||||
3. **元器件表**:BOM 式元器件清单,与组态数据联动;
|
||||
4. **网络与组态拓扑图**:设备间网络 / 总线连接拓扑(自动布点、连线路由);
|
||||
5. **P&ID 图**:管道与仪表流程图(设备符号库、管线、仪表位号)。
|
||||
|
||||
> 以上全部完成后,产品定位由“节拍设计”升级为“设计集”,版本号进入 **2.0.1**。
|
||||
|
||||
## 五、v2.0.1 扩展方向(全部需要)
|
||||
|
||||
1. **新数据类型与编辑能力**:工艺路线、多循环 / 多产品、资源约束;
|
||||
2. **全新的视图 / 报表**:甘特联动、仿真回放、报表导出;
|
||||
3. **协作 / 云端**:账号体系、多端同步、分享链接;
|
||||
4. **AI 大跨越**:对话式建模、自动排产优化。
|
||||
|
||||
## 六、发布与仓库规则(现行)
|
||||
|
||||
- 提交只含源码 / 测试 / 更新说明;构建产物(exe、APK)不入库;
|
||||
- 演示截图 `demo/tablet-*.png` 本地保留、不入库;
|
||||
- Release 附件仅保留最新 1 个版本(`scripts/publish_release.ps1` 自动清理);
|
||||
- 发布前必须:`flutter analyze` 0 问题 + 全量测试通过 + 本地构建冒烟通过。
|
||||
@@ -53,7 +53,7 @@ ExportFit computeExportFit(Project project, ViewMode mode, Rect area) {
|
||||
if (mode == ViewMode.bar) {
|
||||
final BarLayout l = BarLayout(project, kExportSize);
|
||||
final int n = l.lanes.length;
|
||||
final double bottom = n == 0 ? BarLayout.topPad + BarLayout.rowVisual : l.yFor(n) + BarLayout.rowVisual + 8;
|
||||
final double bottom = n == 0 ? BarLayout.topPad + BarLayout.rowVisual : l.plotBottom + 8;
|
||||
bounds = Rect.fromLTRB(12, BarPainter.phaseBandTop - 14, l.plotRight + 120, bottom);
|
||||
} else if (mode == ViewMode.circular) {
|
||||
final CircularLayout l = CircularLayout(project, kExportSize);
|
||||
|
||||
@@ -158,7 +158,7 @@ class SvgWriter {
|
||||
_b.write('<g id="labels">');
|
||||
for (int i = 0; i < ordered.length; i++) {
|
||||
final Action a = ordered[i];
|
||||
final double y = layout.yFor(i);
|
||||
final double y = layout.yForSlot(a.layer, layout.slotOf(a));
|
||||
_text(BarLayout.leftGutter + 6, y + 8, '${a.id} ${a.name}', color: _hex(tokens.text), size: 13, weight: '600');
|
||||
_text(BarLayout.leftGutter + 6, y + 24, '${a.stationId} · ${a.driver}', color: _hex(tokens.dim), size: 10.5);
|
||||
}
|
||||
|
||||
@@ -314,8 +314,8 @@ List<ArcDepRoute> buildArcDepRoutes(Project project, CircularLayout layout) {
|
||||
final Action? a = project.actionById(d.fromId);
|
||||
final Action? b = project.actionById(d.toId);
|
||||
if (a == null || b == null) continue;
|
||||
final double rA = layout.radiusFor(a.layer);
|
||||
final double rB = layout.radiusFor(b.layer);
|
||||
final double rA = layout.radiusFor(a.layer, layout.slotOf(a));
|
||||
final double rB = layout.radiusFor(b.layer, layout.slotOf(b));
|
||||
final double aEnd = math.min(a.endAngle, 360);
|
||||
final double aStart = b.startAngle;
|
||||
// 层差大于 1 时从最外圈绕行,避免穿过中间层弧线。
|
||||
|
||||
+143
-10
@@ -180,6 +180,40 @@ class FlowLayout {
|
||||
/// 内容范围(所有节点矩形并集再外扩,供适应视图使用)。
|
||||
Rect bounds = Rect.zero;
|
||||
|
||||
/// 泳道内两个槽位之间的横向间距(留出依赖连线的走线空间)。
|
||||
static const double slotGap = 26;
|
||||
|
||||
/// 各泳道左边缘 x(放置完成后按内容自适应填充)。
|
||||
final List<double> laneStarts = <double>[];
|
||||
|
||||
/// 各泳道宽度(基础 = 槽位数,放置后按内容自动加宽)。
|
||||
final List<double> laneWidths = <double>[];
|
||||
|
||||
/// 第 [li] 条泳道的宽度(优先取内容自适应结果;未计算时按槽位数)。
|
||||
double laneWidth(int li) {
|
||||
if (li >= 0 && li < laneWidths.length) return laneWidths[li];
|
||||
if (li < 0 || li >= lanes.length) return nodeW;
|
||||
final int s = project.slotsOf(lanes[li]);
|
||||
return s * nodeW + (s - 1) * slotGap;
|
||||
}
|
||||
|
||||
/// 第 [li] 条泳道左边缘 x(优先取内容自适应结果,其次按槽位宽度累加)。
|
||||
double laneStartX(int li) {
|
||||
if (li >= 0 && li < laneStarts.length) return laneStarts[li];
|
||||
double x = marginX;
|
||||
for (int i = 0; i < li && i < lanes.length; i++) {
|
||||
x += laneWidth(i) + laneGap;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
/// 第 [li] 条泳道第 [slot] 列的节点中心 x(槽位钳制到有效范围)。
|
||||
double slotCenterX(int li, int slot) {
|
||||
final int s = (li >= 0 && li < lanes.length) ? project.slotsOf(lanes[li]) : 1;
|
||||
final int k = slot < 0 ? 0 : (slot >= s ? s - 1 : slot);
|
||||
return laneStartX(li) + k * (nodeW + slotGap) + nodeW / 2;
|
||||
}
|
||||
|
||||
/// 按 id 查找节点。
|
||||
FlowNode? nodeById(String id) {
|
||||
for (final FlowNode n in nodes) {
|
||||
@@ -198,7 +232,7 @@ class FlowLayout {
|
||||
|
||||
/// 构建节点、连线并完成布局。
|
||||
void _build() {
|
||||
lanes = (<int>{for (final Action a in project.actions) a.layer}.toList())..sort();
|
||||
lanes = project.renderLanes;
|
||||
final Map<String, FlowNode> byId = <String, FlowNode>{};
|
||||
|
||||
// 1) 动作节点(序号与条形视图一致:项目动作列表顺序 + 1)。
|
||||
@@ -290,7 +324,18 @@ class FlowLayout {
|
||||
cellTotal[key] = (cellTotal[key] ?? 0) + 1;
|
||||
}
|
||||
final Map<String, int> cellSeen = <String, int>{};
|
||||
final double lanePitch = nodeW + laneGap;
|
||||
// 泳道基础几何:宽度按槽位数,左边缘按前一泳道宽度累加。
|
||||
laneStarts.clear();
|
||||
laneWidths.clear();
|
||||
{
|
||||
double x = marginX;
|
||||
for (int i = 0; i < lanes.length; i++) {
|
||||
final int s = project.slotsOf(lanes[i]);
|
||||
laneStarts.add(x);
|
||||
laneWidths.add(s * nodeW + (s - 1) * slotGap);
|
||||
x += laneWidths.last + laneGap;
|
||||
}
|
||||
}
|
||||
for (final FlowNode n in nodes) {
|
||||
final int li = laneIndex[n.lane] ?? 0;
|
||||
final String key = '${n.lane}:${n.rank}';
|
||||
@@ -299,15 +344,91 @@ class FlowLayout {
|
||||
cellSeen[key] = idx + 1;
|
||||
final double w = (n.isStart || n.isEnd) ? capW : nodeW;
|
||||
final double h = (n.isStart || n.isEnd) ? capH : nodeH;
|
||||
final double centerX = marginX + li * lanePitch + nodeW / 2 +
|
||||
(idx - (total - 1) / 2) * (nodeW * 0.62);
|
||||
// 开始 / 结束节点居中于泳道带;动作节点按(泳道, 槽位)分列,
|
||||
// 同格多节点再沿横向错开。
|
||||
final double centerX;
|
||||
if (n.isStart || n.isEnd) {
|
||||
centerX = laneStartX(li) + laneWidth(li) / 2;
|
||||
} else {
|
||||
final int slot = effectiveSlot(project, n.action!);
|
||||
centerX = slotCenterX(li, slot) + (idx - (total - 1) / 2) * (nodeW * 0.62);
|
||||
}
|
||||
final double top = marginY + n.rank * (nodeH + rankGap) + (nodeH - h) / 2;
|
||||
n.rect = Rect.fromLTWH(centerX - w / 2, top, w, h);
|
||||
}
|
||||
|
||||
// 同层智能排开:同一 rank 行内若有水平重叠(同格多节点 / 跨列挤出),
|
||||
// 从左到右依次推开,保证节点之间至少留 10px,避免“堆叠到一起看不清”。
|
||||
final Map<int, List<FlowNode>> byRank = <int, List<FlowNode>>{};
|
||||
for (final FlowNode n in nodes) {
|
||||
byRank.putIfAbsent(n.rank, () => <FlowNode>[]).add(n);
|
||||
}
|
||||
for (final List<FlowNode> row in byRank.values) {
|
||||
row.sort((FlowNode a, FlowNode b) => a.rect.left.compareTo(b.rect.left));
|
||||
for (int i = 1; i < row.length; i++) {
|
||||
final FlowNode prev = row[i - 1];
|
||||
final FlowNode cur = row[i];
|
||||
final double minLeft = prev.rect.right + 10;
|
||||
if (cur.rect.left < minLeft) {
|
||||
cur.rect = cur.rect.shift(Offset(minLeft - cur.rect.left, 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 泳道带按内容**智能加宽**:若某泳道的节点被推到基础宽度之外,
|
||||
// 先按内容算出需要的加宽量,再把该泳道及其后所有泳道整体右移,
|
||||
// 保证底部泳道带完整覆盖自己的动作节点(与条形 / 圆周视图的观感一致)。
|
||||
final List<double> extra = List<double>.filled(lanes.length, 0);
|
||||
for (int i = 0; i < lanes.length; i++) {
|
||||
double contentRight = double.negativeInfinity;
|
||||
for (final FlowNode n in nodes) {
|
||||
if ((laneIndex[n.lane] ?? 0) == i) {
|
||||
contentRight = math.max(contentRight, n.rect.right);
|
||||
}
|
||||
}
|
||||
if (contentRight.isFinite) {
|
||||
final double need = contentRight + 26 - (laneStarts[i] + laneWidths[i]);
|
||||
if (need > 0) extra[i] = need;
|
||||
}
|
||||
}
|
||||
if (extra.any((double e) => e > 0)) {
|
||||
double delta = 0;
|
||||
for (int i = 0; i < lanes.length; i++) {
|
||||
if (delta != 0) {
|
||||
for (final FlowNode n in nodes) {
|
||||
if ((laneIndex[n.lane] ?? 0) == i) {
|
||||
n.rect = n.rect.shift(Offset(delta, 0));
|
||||
}
|
||||
}
|
||||
laneStarts[i] += delta;
|
||||
}
|
||||
laneWidths[i] += extra[i];
|
||||
// 泳道加宽后,开始 / 结束胶囊重新居中于泳道带。
|
||||
if (extra[i] > 0) {
|
||||
for (final FlowNode n in nodes) {
|
||||
if ((n.isStart || n.isEnd) && (laneIndex[n.lane] ?? 0) == i) {
|
||||
final double cx = laneStarts[i] + laneWidths[i] / 2;
|
||||
n.rect = Rect.fromLTWH(
|
||||
cx - n.rect.width / 2, n.rect.top, n.rect.width, n.rect.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
delta += extra[i];
|
||||
}
|
||||
}
|
||||
|
||||
// 6) 连线走线:画布绘制 / SVG / drawio 导出共用(同源同层分支扇形错位)。
|
||||
// 依赖上保存的手动走线偏移(routeOffset)在此叠加:
|
||||
// 向下流为竖直偏移(拖动横线),同层绕行为水平偏移(拖动纵向走廊)。
|
||||
// 同源同层的多条分支预先分组,横线在可用空隙内**均匀铺开**,
|
||||
// 分支多时不再全部挤在同一条线上(流程图“智能排开”)。
|
||||
final Map<String, List<FlowEdge>> fanGroups = <String, List<FlowEdge>>{};
|
||||
for (final FlowEdge e in edges) {
|
||||
final FlowNode? a = byId[e.fromId];
|
||||
final FlowNode? b = byId[e.toId];
|
||||
if (a == null || b == null || b.rank <= a.rank) continue;
|
||||
fanGroups.putIfAbsent('${e.fromId}:${b.rank}', () => <FlowEdge>[]).add(e);
|
||||
}
|
||||
final Map<String, int> fanIndex = <String, int>{};
|
||||
for (final FlowEdge e in edges) {
|
||||
final FlowNode? a = byId[e.fromId];
|
||||
@@ -325,14 +446,26 @@ class FlowLayout {
|
||||
}
|
||||
if (b.rank > a.rank) {
|
||||
final String key = '${e.fromId}:${b.rank}';
|
||||
final List<FlowEdge> group = fanGroups[key] ?? <FlowEdge>[e];
|
||||
final int idx = fanIndex[key] ?? 0;
|
||||
fanIndex[key] = idx + 1;
|
||||
// 横线高度:扇形错开 + 手动偏移,限制在源/目标两行之间的空隙内。
|
||||
double lane = math.min(
|
||||
(a.rect.bottom + b.rect.top) / 2 + idx * 14 + routeOffset,
|
||||
b.rect.top - 8,
|
||||
);
|
||||
if (lane < a.rect.bottom + 10) lane = a.rect.bottom + 10;
|
||||
// 横线高度:单条分支沿用“空隙中线”;多条分支在
|
||||
// [源底 + 10, 目标顶 - 8] 内均匀铺开(第 idx+1 / n+1 份),再叠加手动偏移。
|
||||
final double gapLow = a.rect.bottom + 10;
|
||||
double gapHigh = double.infinity;
|
||||
for (final FlowEdge ge in group) {
|
||||
final FlowNode? gb = byId[ge.toId];
|
||||
if (gb != null && gb.rect.top - 8 < gapHigh) gapHigh = gb.rect.top - 8;
|
||||
}
|
||||
double lane;
|
||||
if (group.length <= 1) {
|
||||
lane = math.min((a.rect.bottom + b.rect.top) / 2 + routeOffset, b.rect.top - 8);
|
||||
} else {
|
||||
final double span = math.max(gapHigh - gapLow, 8);
|
||||
lane = gapLow + span * (idx + 1) / (group.length + 1) + routeOffset;
|
||||
}
|
||||
if (lane < gapLow) lane = gapLow;
|
||||
if (lane > gapHigh) lane = gapHigh;
|
||||
final double x0 = a.rect.center.dx;
|
||||
final double x1 = b.rect.center.dx;
|
||||
routes.add(FlowEdgeRoute(
|
||||
|
||||
+166
-44
@@ -95,6 +95,16 @@ bool angleRangesOverlap(double s1, double e1, double s2, double e2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// 动作 [a] 在 [project] 中其泳道内的有效槽位(与泳道槽位数钳制一致)。
|
||||
///
|
||||
/// 1 槽泳道恒为 0;旧数据中的历史行序(超出范围 / -1)会被钳制到有效槽位。
|
||||
int effectiveSlot(Project project, Action a) {
|
||||
final int slots = project.slotsOf(a.layer);
|
||||
if (slots <= 1) return 0;
|
||||
final int r = a.row;
|
||||
return r < 0 ? 0 : (r >= slots ? slots - 1 : r);
|
||||
}
|
||||
|
||||
/// 条形(甘特)视图布局。
|
||||
///
|
||||
/// 横轴为相位角(0°–360°),纵轴为动作行。行顺序由 [ordered] 决定,
|
||||
@@ -105,14 +115,23 @@ class BarLayout {
|
||||
/// 参数 [project]:项目数据;[size]:可用画布尺寸。
|
||||
/// 副作用:初始化 [pitch]。
|
||||
BarLayout(this.project, this.size) {
|
||||
// 可用高度 = 总高 - 顶部留白 - 底部预留;按**泳道数**均分并夹取到 [44, 58],
|
||||
// 让相邻泳道之间的空隙能容纳依赖连线及其标签(上限定得高一些,
|
||||
// 泳道少时获得更多垂直间隙,减少标签相互压盖)。
|
||||
final int n = lanes.length;
|
||||
// 可用高度 = 总高 - 顶部留白 - 底部预留;按**总子行数**(各泳道槽位数之和)
|
||||
// 均分并夹取到 [44, 58];单槽泳道时与旧版行为完全一致。
|
||||
// 多槽位工程采用「组内紧凑 + 泳道间拉开」:子行更紧、泳道之间额外留白,
|
||||
// 一眼能看出哪些子行属于同一条泳道。
|
||||
final int n = subRowCount;
|
||||
final int laneN = lanes.length;
|
||||
final double extraTotal = _grouped && laneN > 1 ? (laneN - 1) * laneExtraGap : 0;
|
||||
final double usable = size.height - topPad - bottomReserve;
|
||||
pitch = n == 0 ? 58 : (usable / n).clamp(44, 58);
|
||||
pitch = n == 0 ? 58 : ((usable - extraTotal) / n).clamp(_grouped ? 36 : 44, 58);
|
||||
}
|
||||
|
||||
/// 是否启用「组内紧凑 + 泳道间拉开」的间隔分组(仅多槽位工程)。
|
||||
bool get _grouped => project.hasMultiSlotLanes;
|
||||
|
||||
/// 泳道之间的额外纵向留白(仅多槽位分组时生效,像素)。
|
||||
static const double laneExtraGap = 16;
|
||||
|
||||
/// 布局所依据的项目数据。
|
||||
final Project project;
|
||||
|
||||
@@ -149,12 +168,10 @@ class BarLayout {
|
||||
/// 决定行先后的动作列表;见顶层函数 [orderActions]。
|
||||
List<Action> get ordered => orderActions(project);
|
||||
|
||||
/// 泳道编号(= 物理执行器轨道):所有动作 `layer` 的去重升序列表。
|
||||
List<int> get lanes {
|
||||
final Set<int> s = <int>{for (final Action a in project.actions) a.layer};
|
||||
final List<int> l = s.toList()..sort();
|
||||
return l;
|
||||
}
|
||||
/// 泳道编号(= 物理执行器轨道):来自 [Project.renderLanes]。
|
||||
///
|
||||
/// 开启「保留空泳道」时包含动作已全部移走的空泳道(序号不变)。
|
||||
List<int> get lanes => project.renderLanes;
|
||||
|
||||
/// 泳道号在 [lanes] 中的序号。
|
||||
int laneIndexOf(int lane) => lanes.indexOf(lane);
|
||||
@@ -163,17 +180,65 @@ class BarLayout {
|
||||
List<Action> actionsInLane(int lane) =>
|
||||
ordered.where((Action a) => a.layer == lane).toList();
|
||||
|
||||
/// 泳道号转纵坐标(该泳道顶部 y)。
|
||||
double yForLane(int lane) => topPad + laneIndexOf(lane) * pitch;
|
||||
/// 泳道 [lane] 的槽位数(1–5)。
|
||||
int slotsOf(int lane) => project.slotsOf(lane);
|
||||
|
||||
/// 行索引转纵坐标(按泳道序号)。
|
||||
double yFor(int index) => topPad + index * pitch;
|
||||
/// 动作 [a] 的实际槽位(钳制到所属泳道的有效范围;1 槽泳道恒为 0)。
|
||||
int slotOf(Action a) => effectiveSlot(project, a);
|
||||
|
||||
/// 全部泳道的子行总数(Σ 槽位)。
|
||||
int get subRowCount {
|
||||
int n = 0;
|
||||
for (final int lane in lanes) {
|
||||
n += slotsOf(lane);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/// 泳道 [lane] 之前(不含)的纵向高度(子行 + 分组留白)。
|
||||
double _laneOffsetBefore(int lane) {
|
||||
double h = 0;
|
||||
for (final int l in lanes) {
|
||||
if (l == lane) break;
|
||||
h += slotsOf(l) * pitch + (_grouped ? laneExtraGap : 0);
|
||||
}
|
||||
return h;
|
||||
}
|
||||
|
||||
/// 泳道号转纵坐标(该泳道顶部 y)。
|
||||
double yForLane(int lane) => topPad + _laneOffsetBefore(lane);
|
||||
|
||||
/// 泳道内槽位转纵坐标(该槽位所在子行的顶部 y)。
|
||||
double yForSlot(int lane, int slot) => yForLane(lane) + slot * pitch;
|
||||
|
||||
/// 内容底部 y(最后一个子行之后)。
|
||||
double get plotBottom {
|
||||
double h = subRowCount * pitch;
|
||||
if (_grouped && lanes.length > 1) h += (lanes.length - 1) * laneExtraGap;
|
||||
return topPad + h;
|
||||
}
|
||||
|
||||
/// 由纵坐标反查最近的泳道号(用于拖拽换道)。
|
||||
int laneAt(double y) {
|
||||
if (lanes.isEmpty) return 0;
|
||||
final int i = ((y - topPad) / pitch).round().clamp(0, lanes.length - 1);
|
||||
return lanes[i];
|
||||
int laneAt(double y) => laneSlotAt(y).$1;
|
||||
|
||||
/// 由纵坐标反查(泳道号, 槽位)——拖拽换道 / 换槽位时使用。
|
||||
(int, int) laneSlotAt(double y) {
|
||||
if (lanes.isEmpty) return (0, 0);
|
||||
double top = topPad;
|
||||
for (int li = 0; li < lanes.length; li++) {
|
||||
final int lane = lanes[li];
|
||||
final int s = slotsOf(lane);
|
||||
final double h = s * pitch;
|
||||
// 泳道之间的额外留白按半份归属本道,保证指针落在空隙中也能命中相邻泳道。
|
||||
final double boundary =
|
||||
top + h + (_grouped && li < lanes.length - 1 ? laneExtraGap * 0.5 : 0);
|
||||
if (y < boundary || li == lanes.length - 1) {
|
||||
final int slot = ((y - top) / pitch).round().clamp(0, s - 1);
|
||||
return (lane, slot);
|
||||
}
|
||||
top += h + (_grouped ? laneExtraGap : 0);
|
||||
}
|
||||
return (lanes.last, slotsOf(lanes.last) - 1);
|
||||
}
|
||||
|
||||
/// 相位角(度)转横坐标;角度先钳制到 `[0, 360]`。
|
||||
@@ -183,7 +248,7 @@ class BarLayout {
|
||||
///
|
||||
/// 宽度至少为 3px,避免极短动作不可见;跨圈部分会被截断到 360°。
|
||||
Rect rectFor(Action a) {
|
||||
final double y = yForLane(a.layer);
|
||||
final double y = yForSlot(a.layer, slotOf(a));
|
||||
final double x0 = xFor(a.startAngle);
|
||||
final double x1 = xFor(math.min(a.endAngle, 360));
|
||||
return Rect.fromLTWH(x0, y, math.max(x1 - x0, 3), barH);
|
||||
@@ -217,18 +282,29 @@ class CircularLayout {
|
||||
CircularLayout(this.project, this.size) {
|
||||
// 圆心略微下移 18px 以平衡顶部刻度标签的视觉重心。
|
||||
center = Offset(size.width / 2, size.height / 2 + 18);
|
||||
// 轨道数 = 泳道数(layer 去重),同一轨道可放多个互不重叠的动作。
|
||||
final int layers = lanes.length;
|
||||
// 子环总数 = Σ 各轨道槽位数(泳道加宽后同一轨道可有多条并行子环);
|
||||
// 单槽时与旧版(按轨道数)完全一致。
|
||||
final int rings = subRingCount;
|
||||
final int laneN = lanes.length;
|
||||
// 多槽位工程采用「组内紧凑 + 轨道间拉开」:同一轨道的子环更紧、
|
||||
// 轨道之间额外留白,一眼能看出哪些子环属于同一轨道。
|
||||
final double extraTotal = _grouped && laneN > 1 ? (laneN - 1) * ringExtraGap : 0;
|
||||
// 最大半径受较短边约束,减去 74px 留给刻度与边距。
|
||||
final double maxR = math.min(size.width, size.height) / 2 - 74;
|
||||
// 在 r0 与 maxR 之间均分各轨道,环间距夹取到 [32, 52]:
|
||||
// 让相邻环之间留出足够空隙放置依赖箭头与图注。
|
||||
pitch = layers <= 1 ? 46 : ((maxR - r0) / (layers - 1)).clamp(32, 56);
|
||||
// 动作环带宽度:只求容纳文字(约 15–18px),环更窄、环间空隙更宽,
|
||||
// 便于在环间放置依赖标签(减少与动作名、其它标签的压盖)。
|
||||
ringWidth = (pitch * 0.42).clamp(14, 17);
|
||||
// 在 r0 与 maxR 之间均分各子环,环间距夹取(多槽位时允许更紧)。
|
||||
pitch = rings <= 1
|
||||
? 46
|
||||
: ((maxR - r0 - extraTotal) / (rings - 1)).clamp(_grouped ? 24 : 32, 56);
|
||||
// 动作环带宽度:只求容纳文字;多槽位分组时子环更窄,轨道间靠留白区分。
|
||||
ringWidth = (pitch * 0.42).clamp(_grouped ? 10 : 14, 17);
|
||||
}
|
||||
|
||||
/// 是否启用「组内紧凑 + 轨道间拉开」的间隔分组(仅多槽位工程)。
|
||||
bool get _grouped => project.hasMultiSlotLanes;
|
||||
|
||||
/// 轨道之间的额外径向留白(仅多槽位分组时生效,像素)。
|
||||
static const double ringExtraGap = 18;
|
||||
|
||||
/// 布局所依据的项目数据。
|
||||
final Project project;
|
||||
|
||||
@@ -247,31 +323,77 @@ class CircularLayout {
|
||||
/// 环的视觉宽度(像素)。
|
||||
late final double ringWidth;
|
||||
|
||||
/// 轨道编号(= 泳道):所有动作 `layer` 的去重升序列表。
|
||||
List<int> get lanes {
|
||||
final Set<int> s = <int>{for (final Action a in project.actions) a.layer};
|
||||
final List<int> l = s.toList()..sort();
|
||||
return l;
|
||||
}
|
||||
/// 轨道编号(= 泳道):来自 [Project.renderLanes](含保留的空轨道)。
|
||||
List<int> get lanes => project.renderLanes;
|
||||
|
||||
/// 轨道号在 [lanes] 中的序号。
|
||||
int laneIndexOf(int lane) => lanes.indexOf(lane);
|
||||
|
||||
/// 由半径反查最近的轨道号(用于拖拽换轨)。
|
||||
int laneAtRadius(double r) {
|
||||
if (lanes.isEmpty) return 0;
|
||||
final int i = ((r - r0) / pitch).round().clamp(0, lanes.length - 1);
|
||||
return lanes[i];
|
||||
/// 轨道 [lane] 的槽位数(1–5)。
|
||||
int slotsOf(int lane) => project.slotsOf(lane);
|
||||
|
||||
/// 动作 [a] 的实际槽位(钳制;1 槽轨道恒为 0)。
|
||||
int slotOf(Action a) => effectiveSlot(project, a);
|
||||
|
||||
/// 全部轨道的子环总数(Σ 槽位)。
|
||||
int get subRingCount {
|
||||
int n = 0;
|
||||
for (final int lane in lanes) {
|
||||
n += slotsOf(lane);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/// 第 [lane] 条轨道对应的环半径(未知轨道回退到最内圈)。
|
||||
double radiusFor(int lane) {
|
||||
/// 轨道 [lane] 之前(不含)的子环数。
|
||||
int subRingIndexOfLane(int lane) {
|
||||
int n = 0;
|
||||
for (final int l in lanes) {
|
||||
if (l == lane) break;
|
||||
n += slotsOf(l);
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/// 由半径反查最近的轨道号(用于拖拽换轨)。
|
||||
int laneAtRadius(double r) => laneSlotAtRadius(r).$1;
|
||||
|
||||
/// 由半径反查(轨道号, 槽位)——拖拽换轨 / 换子环时使用。
|
||||
(int, int) laneSlotAtRadius(double r) {
|
||||
if (lanes.isEmpty) return (0, 0);
|
||||
double base = r0;
|
||||
for (int li = 0; li < lanes.length; li++) {
|
||||
final int lane = lanes[li];
|
||||
final int s = slotsOf(lane);
|
||||
final double h = s * pitch;
|
||||
// 轨道之间的额外留白按半份归属本道,落在空隙中也能命中相邻轨道。
|
||||
final double boundary =
|
||||
base + h + (_grouped && li < lanes.length - 1 ? ringExtraGap * 0.5 : 0);
|
||||
if (r < boundary || li == lanes.length - 1) {
|
||||
final int slot = ((r - base) / pitch).round().clamp(0, s - 1);
|
||||
return (lane, slot);
|
||||
}
|
||||
base += h + (_grouped ? ringExtraGap : 0);
|
||||
}
|
||||
return (lanes.last, slotsOf(lanes.last) - 1);
|
||||
}
|
||||
|
||||
/// 轨道 [lane] 第 [slot] 条子环的半径(未知轨道回退到最内圈)。
|
||||
double radiusFor(int lane, [int slot = 0]) {
|
||||
final int i = laneIndexOf(lane);
|
||||
return r0 + (i < 0 ? 0 : i) * pitch;
|
||||
if (i < 0) return r0;
|
||||
final int s = slotsOf(lane);
|
||||
final int k = slot < 0 ? 0 : (slot >= s ? s - 1 : slot);
|
||||
return r0 +
|
||||
(subRingIndexOfLane(lane) + k) * pitch +
|
||||
(_grouped ? i * ringExtraGap : 0);
|
||||
}
|
||||
|
||||
/// 最外层半径。
|
||||
double get rMax => lanes.isEmpty ? r0 : radiusFor(lanes.last);
|
||||
double get rMax {
|
||||
if (lanes.isEmpty) return r0;
|
||||
final double extra = _grouped && lanes.length > 1 ? (lanes.length - 1) * ringExtraGap : 0;
|
||||
return r0 + (subRingCount - 1) * pitch + extra;
|
||||
}
|
||||
|
||||
/// 刻度标签所在的半径(最外层再向外偏移)。
|
||||
/// 刻度环半径:在外层动作环之外留出足够间距,
|
||||
@@ -292,7 +414,7 @@ class CircularLayout {
|
||||
Action? best;
|
||||
double bestDelta = double.infinity;
|
||||
for (final Action a2 in project.actions) {
|
||||
final double r = radiusFor(a2.layer);
|
||||
final double r = radiusFor(a2.layer, slotOf(a2));
|
||||
if ((d - r).abs() > ringWidth / 2 + slop) continue;
|
||||
if (_inArc(a2, a)) {
|
||||
final double delta = (d - r).abs();
|
||||
|
||||
+84
-3
@@ -251,10 +251,10 @@ class Action {
|
||||
/// 动作颜色(ARGB)。
|
||||
final int color;
|
||||
|
||||
/// 条形视图中的行序(自上而下,从 0 开始)。
|
||||
/// 泳道内的槽位(0 起):泳道加宽(多槽位)后,同泳道的并列动作按槽位分行放置。
|
||||
///
|
||||
/// `-1` 表示“未指定”,此时由 [BarLayout] 按工位与起始角自动排序;
|
||||
/// 一旦用户上下拖拽过行,就写入显式行序,行位置不再随相位变化而跳动。
|
||||
/// `-1` 或超出范围的值在布局时会被钳制到有效槽位(1 槽泳道统一落在 0 槽),
|
||||
/// 因此旧数据(历史序号值)无需迁移即可正常显示。
|
||||
final int row;
|
||||
|
||||
/// 指向本动作的依赖集合(本动作作为后继)。
|
||||
@@ -785,6 +785,11 @@ class Project {
|
||||
required this.units,
|
||||
required this.viewState,
|
||||
this.phaseZones = PhaseZone.defaults,
|
||||
this.keepEmptyLanes = true,
|
||||
this.minLaneCount = 0,
|
||||
this.laneSlots = const <int, int>{},
|
||||
this.autoSaveEnabled = true,
|
||||
this.autoSaveMinutes = 10,
|
||||
});
|
||||
|
||||
/// 项目名称。
|
||||
@@ -811,6 +816,37 @@ class Project {
|
||||
/// 相位分区(命名角度区间),用于条形视图顶部工艺阶段标注。
|
||||
final List<PhaseZone> phaseZones;
|
||||
|
||||
/// 是否保留空泳道:动作全部移走后仍保留该泳道(行 / 环 / 列),序号不变。
|
||||
///
|
||||
/// 关闭时按动作实际使用的层号渲染(空泳道自动消失、序号顺延)。
|
||||
final bool keepEmptyLanes;
|
||||
|
||||
/// 保底泳道数:开启 [keepEmptyLanes] 时渲染至少这么多条泳道(0 = 自动)。
|
||||
final int minLaneCount;
|
||||
|
||||
/// 泳道槽位数:layer → 槽位数(1–5);无记录的泳道视为 1 槽。
|
||||
///
|
||||
/// 泳道加宽后,同一泳道内的动作可按 [Action.row](槽位)分成多条并排行,
|
||||
/// 实现“一个泳道容纳多个并列动作”。
|
||||
final Map<int, int> laneSlots;
|
||||
|
||||
/// 泳道 [lane] 的槽位数(1–5;未配置为 1)。
|
||||
int slotsOf(int lane) {
|
||||
final int n = laneSlots[lane] ?? 1;
|
||||
return n < 1 ? 1 : (n > 5 ? 5 : n);
|
||||
}
|
||||
|
||||
/// 是否有任何泳道被加宽(多槽位)。
|
||||
bool get hasMultiSlotLanes => laneSlots.values.any((int v) => v > 1);
|
||||
|
||||
/// 是否启用自动保存(定时把文档写入文件,默认启用)。
|
||||
final bool autoSaveEnabled;
|
||||
|
||||
/// 自动保存间隔(分钟,1–240,默认 10)。
|
||||
///
|
||||
/// 仅在文档已有保存路径(手动保存过一次)后生效;自动保存会同时更新 `.bak`。
|
||||
final int autoSaveMinutes;
|
||||
|
||||
/// 按 id 查找动作;[id] 为 null 或未找到时返回 null。
|
||||
Action? actionById(String? id) {
|
||||
if (id == null) return null;
|
||||
@@ -842,6 +878,27 @@ class Project {
|
||||
/// 同一泳道可容纳多个互不重叠的动作,对应一个物理执行器。
|
||||
int get laneCount => <int>{for (final Action a in actions) a.layer}.length;
|
||||
|
||||
/// 渲染用的泳道层号列表(升序):统一供条形 / 圆周 / 流程图与侧栏使用。
|
||||
///
|
||||
/// - [keepEmptyLanes] 为真:渲染 `0 .. max(minLaneCount, 最大层号 + 1) - 1`,
|
||||
/// 动作全部移走的泳道保留为空泳道(序号不变);
|
||||
/// - 否则按动作实际使用的层号渲染(空泳道自动消失、序号顺延)。
|
||||
List<int> get renderLanes {
|
||||
final Set<int> layers = <int>{for (final Action a in actions) a.layer};
|
||||
if (!keepEmptyLanes) {
|
||||
return layers.toList()..sort();
|
||||
}
|
||||
int maxLayer = -1;
|
||||
for (final int l in layers) {
|
||||
if (l > maxLayer) maxLayer = l;
|
||||
}
|
||||
final int n = minLaneCount > maxLayer + 1 ? minLaneCount : maxLayer + 1;
|
||||
return <int>[for (int i = 0; i < n; i++) i];
|
||||
}
|
||||
|
||||
/// 渲染的泳道数量(含保留的空泳道)。
|
||||
int get renderLaneCount => renderLanes.length;
|
||||
|
||||
/// 基于当前实例创建副本,未提供的参数保持原值。
|
||||
Project copyWith({
|
||||
String? name,
|
||||
@@ -852,6 +909,11 @@ class Project {
|
||||
UnitSettings? units,
|
||||
ViewState? viewState,
|
||||
List<PhaseZone>? phaseZones,
|
||||
bool? keepEmptyLanes,
|
||||
int? minLaneCount,
|
||||
Map<int, int>? laneSlots,
|
||||
bool? autoSaveEnabled,
|
||||
int? autoSaveMinutes,
|
||||
}) {
|
||||
return Project(
|
||||
name: name ?? this.name,
|
||||
@@ -862,6 +924,11 @@ class Project {
|
||||
units: units ?? this.units,
|
||||
viewState: viewState ?? this.viewState,
|
||||
phaseZones: phaseZones ?? this.phaseZones,
|
||||
keepEmptyLanes: keepEmptyLanes ?? this.keepEmptyLanes,
|
||||
minLaneCount: minLaneCount ?? this.minLaneCount,
|
||||
laneSlots: laneSlots ?? this.laneSlots,
|
||||
autoSaveEnabled: autoSaveEnabled ?? this.autoSaveEnabled,
|
||||
autoSaveMinutes: autoSaveMinutes ?? this.autoSaveMinutes,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -876,6 +943,13 @@ class Project {
|
||||
'actions': actions.map((Action a) => a.toJson()).toList(),
|
||||
'viewState': viewState.toJson(),
|
||||
'phaseZones': phaseZones.map((PhaseZone z) => z.toJson()).toList(),
|
||||
'keepEmptyLanes': keepEmptyLanes,
|
||||
'minLaneCount': minLaneCount,
|
||||
'laneSlots': <String, int>{
|
||||
for (final MapEntry<int, int> e in laneSlots.entries) '${e.key}': e.value,
|
||||
},
|
||||
'autoSaveEnabled': autoSaveEnabled,
|
||||
'autoSaveMinutes': autoSaveMinutes,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -903,6 +977,13 @@ class Project {
|
||||
phaseZones: pz.isEmpty
|
||||
? PhaseZone.defaults
|
||||
: pz.map((dynamic e) => PhaseZone.fromJson(e as Map<String, dynamic>)).toList(),
|
||||
keepEmptyLanes: p['keepEmptyLanes'] as bool? ?? true,
|
||||
minLaneCount: (p['minLaneCount'] as num?)?.toInt() ?? 0,
|
||||
laneSlots: ((p['laneSlots'] as Map<String, dynamic>?) ?? <String, dynamic>{})
|
||||
.map((String k, dynamic v) =>
|
||||
MapEntry<int, int>(int.tryParse(k) ?? 0, (v as num?)?.toInt() ?? 1)),
|
||||
autoSaveEnabled: p['autoSaveEnabled'] as bool? ?? true,
|
||||
autoSaveMinutes: (p['autoSaveMinutes'] as num?)?.toInt() ?? 10,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
+63
-18
@@ -98,19 +98,21 @@ class BarPainter extends CustomPainter {
|
||||
|
||||
if (project.viewState.showPhaseBands) _phaseBands(canvas, layout);
|
||||
// 换泳道拖拽:高亮目标泳道(可放置=强调色,重叠=警示色)。
|
||||
// 泳道加宽(多槽位)后高亮覆盖该泳道的全部槽位。
|
||||
if (dropLane != null && layout.lanes.contains(dropLane)) {
|
||||
final double y = layout.yForLane(dropLane!);
|
||||
final double h = layout.slotsOf(dropLane!) * layout.pitch;
|
||||
final Color c = dropValid ? tokens.accent : tokens.danger;
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(
|
||||
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, BarLayout.rowVisual),
|
||||
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, h),
|
||||
const Radius.circular(10),
|
||||
),
|
||||
Paint()..color = c.withValues(alpha: 0.12),
|
||||
);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(
|
||||
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, BarLayout.rowVisual),
|
||||
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, h),
|
||||
const Radius.circular(10),
|
||||
),
|
||||
Paint()
|
||||
@@ -131,7 +133,7 @@ class BarPainter extends CustomPainter {
|
||||
void _guide(Canvas canvas, BarLayout layout, UnitSettings u) {
|
||||
final double deg = guideAngle!;
|
||||
final double x = layout.xFor(deg.clamp(0, 360));
|
||||
final double bottom = layout.yFor(layout.ordered.length) - 4;
|
||||
final double bottom = layout.plotBottom - 4;
|
||||
final Paint p = Paint()
|
||||
..color = tokens.accent
|
||||
..strokeWidth = 1.4;
|
||||
@@ -235,7 +237,7 @@ class BarPainter extends CustomPainter {
|
||||
final Paint p = Paint()
|
||||
..color = col.withValues(alpha: 0.7)
|
||||
..strokeWidth = 1.4;
|
||||
_dashedLine(canvas, Offset(x, axisTop + 28), Offset(x, layout.yFor(layout.ordered.length) - 4), p);
|
||||
_dashedLine(canvas, Offset(x, axisTop + 28), Offset(x, layout.plotBottom - 4), p);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -271,37 +273,61 @@ class BarPainter extends CustomPainter {
|
||||
final List<int> lanes = layout.lanes;
|
||||
for (int li = 0; li < lanes.length; li++) {
|
||||
final int lane = lanes[li];
|
||||
final double y = layout.yFor(li);
|
||||
final double y = layout.yForLane(lane);
|
||||
final int slots = layout.slotsOf(lane);
|
||||
final double laneH = slots * layout.pitch;
|
||||
final List<Action> acts = layout.actionsInLane(lane);
|
||||
// 隔泳道背景色带,弱化边界。
|
||||
// 单槽泳道保持与旧版完全一致的背景带 / 底线几何;多槽位覆盖整个泳道带。
|
||||
final double bandH = slots == 1 ? BarLayout.rowVisual : laneH;
|
||||
// 隔泳道背景色带(覆盖该泳道全部槽位),弱化边界。
|
||||
if (li.isEven) {
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(
|
||||
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, BarLayout.rowVisual),
|
||||
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, bandH),
|
||||
const Radius.circular(10),
|
||||
),
|
||||
Paint()..color = tokens.panel2.withValues(alpha: 0.5),
|
||||
);
|
||||
}
|
||||
// 泳道标题(合并显示,最多两行,用 / 分隔)。
|
||||
_laneHeader(canvas, layout, li, acts, y);
|
||||
// 泳道底分隔线。
|
||||
// 多槽位泳道:槽位之间用浅色虚线分隔,提示并列关系。
|
||||
if (slots > 1) {
|
||||
for (int s = 1; s < slots; s++) {
|
||||
final double sy = y + s * layout.pitch - 8;
|
||||
_dashedLine(
|
||||
canvas,
|
||||
Offset(layout.plotLeft, sy),
|
||||
Offset(layout.plotRight, sy),
|
||||
Paint()
|
||||
..color = tokens.line2.withValues(alpha: 0.5)
|
||||
..strokeWidth = 1,
|
||||
);
|
||||
}
|
||||
}
|
||||
// 泳道标题(合并显示;单槽最多两行,多槽位按泳道高度持续换行)。
|
||||
_laneHeader(canvas, layout, li, acts,
|
||||
slots == 1 ? y : y + laneH / 2 - BarLayout.rowVisual / 2, slots, laneH);
|
||||
// 泳道底分隔线(单槽时与旧版一致)。
|
||||
canvas.drawLine(
|
||||
Offset(layout.plotLeft, y + BarLayout.rowVisual - 4),
|
||||
Offset(layout.plotRight, y + BarLayout.rowVisual - 4),
|
||||
Offset(layout.plotLeft, slots == 1 ? y + BarLayout.rowVisual - 4 : y + laneH - 4),
|
||||
Offset(layout.plotRight, slots == 1 ? y + BarLayout.rowVisual - 4 : y + laneH - 4),
|
||||
Paint()
|
||||
..color = tokens.line2.withValues(alpha: 0.6)
|
||||
..strokeWidth = 1,
|
||||
);
|
||||
// 该泳道内的所有动作条(互不重叠)。
|
||||
// 该泳道内的所有动作条(按槽位分行放置)。
|
||||
for (final Action a in acts) {
|
||||
_bar(canvas, layout, a, u, cycle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 绘制一条泳道的标题:序号徽标 + 合并动作名(≤2 行,用 / 分隔)+ 副标题。
|
||||
void _laneHeader(Canvas canvas, BarLayout layout, int li, List<Action> acts, double y) {
|
||||
/// 绘制一条泳道的标题:序号徽标 + 合并动作名 + 副标题。
|
||||
///
|
||||
/// 合并动作名在宽度 [BarLayout.leftGutter]-68 内自动换行:单槽泳道最多两行
|
||||
/// (保持旧版外观);多槽位泳道按泳道高度**持续换行**直到放不下为止
|
||||
/// (副标题跟随实际行数下移)。
|
||||
void _laneHeader(Canvas canvas, BarLayout layout, int li, List<Action> acts, double y,
|
||||
int slots, double laneH) {
|
||||
final double labelMax = BarLayout.leftGutter - 68;
|
||||
final Color c0 = acts.isEmpty ? tokens.accent : Color(acts.first.color);
|
||||
canvas.drawRRect(
|
||||
@@ -312,7 +338,8 @@ class BarPainter extends CustomPainter {
|
||||
color: tokens.chip, size: 10, align: TextAlign.center, weight: FontWeight.w700);
|
||||
if (acts.isEmpty) return;
|
||||
|
||||
// 多个动作合并为「A1 上料 / A2 定位」,最多两行。
|
||||
// 先按足够大的行数测量“真实行高”(字体回退下行高可能大于字号,
|
||||
// 之前按固定 13px 估算导致标题换行多行后压住灰色副标题)。
|
||||
final String joined = acts.map((Action a) => '${a.id} ${a.name}').join(' / ');
|
||||
final TextPainter tp = TextPainter(
|
||||
text: TextSpan(
|
||||
@@ -325,15 +352,33 @@ class BarPainter extends CustomPainter {
|
||||
),
|
||||
),
|
||||
textDirection: ui.TextDirection.ltr,
|
||||
maxLines: 2,
|
||||
maxLines: 40,
|
||||
ellipsis: '…',
|
||||
)..layout(maxWidth: labelMax);
|
||||
final int totalLines = tp.computeLineMetrics().length;
|
||||
final double lineH = totalLines == 0 ? 14 : tp.height / totalLines;
|
||||
|
||||
// 行数上限:单槽保持两行(旧版外观);多槽位按泳道高度换算并给副标题留一行。
|
||||
final bool single = slots <= 1;
|
||||
final int maxLines =
|
||||
single ? 2 : ((laneH - lineH - 8) / lineH).floor().clamp(2, 40);
|
||||
if (tp.computeLineMetrics().length != maxLines && maxLines < totalLines) {
|
||||
tp.maxLines = maxLines;
|
||||
tp.ellipsis = '…';
|
||||
tp.layout(maxWidth: labelMax);
|
||||
}
|
||||
tp.paint(canvas, Offset(60, y + 2));
|
||||
|
||||
final Station? st = project.stationById(acts.first.stationId);
|
||||
final String sub = '${st?.name ?? acts.first.stationId} · ${acts.first.driver}'
|
||||
'${acts.length > 1 ? ' · 共 ${acts.length} 个' : ''}';
|
||||
_textMax(canvas, sub, Offset(60, y + 32), labelMax, color: tokens.dim, size: 10);
|
||||
// 副标题紧随实际标题高度;单槽保持旧版下边距(y+32)但绝不高于标题底部,
|
||||
// 多槽位下若剩余高度不足则不再绘制,避免压住标题文字。
|
||||
final double subY =
|
||||
single ? math.max(y + 32, y + 2 + tp.height + 2) : y + 2 + tp.height + 2;
|
||||
if (single || subY + 11 <= y + laneH) {
|
||||
_textMax(canvas, sub, Offset(60, subY), labelMax, color: tokens.dim, size: 10);
|
||||
}
|
||||
}
|
||||
|
||||
/// 绘制单个动作条块(投影 / 填充 / 描边 / 跨圈尾段 / 文字标注)。
|
||||
|
||||
@@ -92,14 +92,19 @@ class CircularPainter extends CustomPainter {
|
||||
final int layers = lanes.length;
|
||||
if (project.viewState.showRingBg) {
|
||||
for (int i = 0; i < layers; i++) {
|
||||
final double r = layout.radiusFor(lanes[i]);
|
||||
final int lane = lanes[i];
|
||||
final int slots = layout.slotsOf(lane);
|
||||
final Color band = i.isEven ? tokens.ringA : tokens.ringB;
|
||||
if (slots <= 1) {
|
||||
// 单槽轨道:与旧版完全一致(一条环带 + 内外沿细描边)。
|
||||
final double r = layout.radiusFor(lane, 0);
|
||||
canvas.drawCircle(
|
||||
c,
|
||||
r,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = th
|
||||
..color = i.isEven ? tokens.ringA : tokens.ringB,
|
||||
..color = band,
|
||||
);
|
||||
canvas.drawCircle(
|
||||
c,
|
||||
@@ -117,6 +122,44 @@ class CircularPainter extends CustomPainter {
|
||||
..strokeWidth = 1
|
||||
..color = tokens.ringEdge,
|
||||
);
|
||||
continue;
|
||||
}
|
||||
// 多槽位轨道:整条轨道用一条加宽的色带(同一泳道同一颜色),
|
||||
// 槽位之间用浅色虚线分隔;不同轨道之间仍按奇偶交替(与现在一致)。
|
||||
final double rIn = layout.radiusFor(lane, 0);
|
||||
final double rOut = layout.radiusFor(lane, slots - 1);
|
||||
final double rc = (rIn + rOut) / 2;
|
||||
canvas.drawCircle(
|
||||
c,
|
||||
rc,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = (rOut - rIn) + th
|
||||
..color = band,
|
||||
);
|
||||
canvas.drawCircle(
|
||||
c,
|
||||
rIn - th / 2,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1
|
||||
..color = tokens.ringEdge,
|
||||
);
|
||||
canvas.drawCircle(
|
||||
c,
|
||||
rOut + th / 2,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1
|
||||
..color = tokens.ringEdge,
|
||||
);
|
||||
final Paint dash = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1
|
||||
..color = tokens.ringEdge.withValues(alpha: 0.95);
|
||||
for (int s = 1; s < slots; s++) {
|
||||
_dashedCircle(canvas, c, rIn + (s - 0.5) * layout.pitch, dash);
|
||||
}
|
||||
}
|
||||
}
|
||||
canvas.drawCircle(c, math.max(CircularLayout.r0 - th / 2, 8), Paint()..color = tokens.dial);
|
||||
@@ -124,11 +167,14 @@ class CircularPainter extends CustomPainter {
|
||||
// 相位分区环:在最外动作环与刻度环之间画一圈分区色带并标注名称。
|
||||
if (project.viewState.showPhaseBands) _phaseRing(canvas, layout);
|
||||
|
||||
// 轨道标签:为每条轨道挑选一个空位角度,避免压住该轨道的动作弧。
|
||||
// 轨道标签:为每条轨道挑选一个空位角度,避免压住该轨道的动作弧;
|
||||
// 多槽位轨道把标签放在轨道带的垂直中心(半径方向)。
|
||||
if (project.viewState.showLayerLabels) {
|
||||
for (int i = 0; i < layers; i++) {
|
||||
final double r = layout.radiusFor(lanes[i]);
|
||||
final double free = _freeAngle(lanes[i]);
|
||||
final int lane = lanes[i];
|
||||
final int slots = layout.slotsOf(lane);
|
||||
final double r = layout.radiusFor(lane) + (slots - 1) * layout.pitch / 2;
|
||||
final double free = _freeAngle(lane);
|
||||
final Offset lp = polar(c, r, free);
|
||||
_text(canvas, 'L${i + 1}', lp, color: tokens.ringLabel, size: 10, align: TextAlign.center, weight: FontWeight.w700);
|
||||
}
|
||||
@@ -305,7 +351,7 @@ class CircularPainter extends CustomPainter {
|
||||
/// 参数 [u] 为当前单位设置(保留以对齐调用接口,当前未直接使用)。
|
||||
void _action(Canvas canvas, CircularLayout layout, Action a, UnitSettings u) {
|
||||
final Offset c = layout.center;
|
||||
final double r = layout.radiusFor(a.layer);
|
||||
final double r = layout.radiusFor(a.layer, layout.slotOf(a));
|
||||
final double th = layout.th;
|
||||
final Color col = Color(a.color);
|
||||
final bool sel = selectedIds.contains(a.id);
|
||||
@@ -511,6 +557,20 @@ class CircularPainter extends CustomPainter {
|
||||
canvas.drawPath(p, Paint()..color = col);
|
||||
}
|
||||
|
||||
/// 以虚线绘制圆周(用于多槽位轨道内部的槽位分隔线)。
|
||||
void _dashedCircle(Canvas canvas, Offset center, double r, Paint paint,
|
||||
{double dash = 6, double gap = 5}) {
|
||||
final Path path = Path()..addOval(Rect.fromCircle(center: center, radius: r));
|
||||
for (final ui.PathMetric metric in path.computeMetrics()) {
|
||||
double dist = 0;
|
||||
while (dist < metric.length) {
|
||||
final double end = math.min(dist + dash, metric.length);
|
||||
canvas.drawPath(metric.extractPath(dist, end), paint);
|
||||
dist = end + gap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// 绘制拖拽端点时的径向虚线参考与角度标注。
|
||||
void _guide(Canvas canvas, CircularLayout layout) {
|
||||
final Offset c = layout.center;
|
||||
|
||||
@@ -85,24 +85,19 @@ class FlowchartPainter extends CustomPainter {
|
||||
}
|
||||
}
|
||||
|
||||
/// 绘制泳道背景带与标题(泳道 = 轨道)。
|
||||
/// 绘制泳道背景带与标题(泳道 = 轨道;多槽位泳道按槽位数加宽带)。
|
||||
void _lanes(Canvas canvas, FlowLayout layout) {
|
||||
final double lanePitch = FlowLayout.nodeW + FlowLayout.laneGap;
|
||||
final double top = layout.bounds.top + 20;
|
||||
final double bottom = layout.bounds.bottom - 20;
|
||||
for (int i = 0; i < layout.lanes.length; i++) {
|
||||
final double cx = FlowLayout.marginX + i * lanePitch + FlowLayout.nodeW / 2;
|
||||
final Rect band = Rect.fromLTRB(
|
||||
cx - FlowLayout.nodeW / 2 - 26,
|
||||
top,
|
||||
cx + FlowLayout.nodeW / 2 + 26,
|
||||
bottom,
|
||||
);
|
||||
final double left = layout.laneStartX(i) - 26;
|
||||
final double right = layout.laneStartX(i) + layout.laneWidth(i) + 26;
|
||||
final Rect band = Rect.fromLTRB(left, top, right, bottom);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(band, const Radius.circular(14)),
|
||||
Paint()..color = (i.isEven ? tokens.ringA : tokens.ringB).withValues(alpha: 0.55),
|
||||
);
|
||||
_text(canvas, '轨道 L${i + 1}', Offset(cx, top + 16),
|
||||
_text(canvas, '轨道 L${i + 1}', Offset((left + right) / 2, top + 16),
|
||||
color: tokens.sub, size: 11, weight: FontWeight.w700, align: TextAlign.center);
|
||||
}
|
||||
}
|
||||
|
||||
+144
-16
@@ -9,10 +9,14 @@
|
||||
library;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:math' as math;
|
||||
import 'dart:typed_data';
|
||||
|
||||
import 'package:flutter/material.dart' hide Action;
|
||||
|
||||
import '../persistence/android_docs.dart';
|
||||
import '../version.dart';
|
||||
import '../layout/dep_routes.dart';
|
||||
import '../layout/layout.dart';
|
||||
import '../layout/flow_layout.dart';
|
||||
@@ -27,7 +31,7 @@ class AppController extends ChangeNotifier {
|
||||
/// 参数 [project]:初始项目;为 null 时使用 [Project.demo] 并标记为已修改
|
||||
/// (因为演示数据尚未保存到文件)。
|
||||
AppController({Project? project})
|
||||
: _project = project ?? Project.demo(),
|
||||
: _project = _syncLaneFloor(project ?? Project.demo()),
|
||||
_dirty = project == null;
|
||||
|
||||
/// 当前项目数据(唯一可变引用,替换时整体赋值)。
|
||||
@@ -36,11 +40,14 @@ class AppController extends ChangeNotifier {
|
||||
/// 当前主题亮度(默认浅色 / 白底)。
|
||||
Brightness _brightness = Brightness.light;
|
||||
|
||||
/// 是否已获得有效授权(有效时才允许导出 SVG / PNG)。
|
||||
/// 是否已获得有效授权(有效时才允许导出 SVG / PNG / drawio)。
|
||||
///
|
||||
/// 1.3.4 起授权校验临时冻结([kLicenseRequired] = false):始终视为已授权,
|
||||
/// 待功能丰富后再恢复校验。
|
||||
bool _licensed = false;
|
||||
|
||||
/// 是否已授权。
|
||||
bool get licensed => _licensed;
|
||||
/// 是否已授权(授权冻结期间恒为 true)。
|
||||
bool get licensed => !kLicenseRequired || _licensed;
|
||||
|
||||
/// 设置授权状态并刷新(启动时校验 / 重新读取 .lic 后调用)。
|
||||
void setLicensed(bool value) {
|
||||
@@ -154,6 +161,10 @@ class AppController extends ChangeNotifier {
|
||||
}
|
||||
|
||||
/// 自动保存当前项目(内部方法,异常静默忽略以避免打断编辑)。
|
||||
///
|
||||
/// 同时承担两件事:
|
||||
/// 1. 崩溃恢复快照(每 5 秒写入 Storage,与文档文件无关);
|
||||
/// 2. 文档自动保存(按 [Project.autoSaveMinutes] 的间隔把文档写回文件)。
|
||||
Future<void> _autosave() async {
|
||||
try {
|
||||
await Storage.instance.writeAutosave(
|
||||
@@ -162,6 +173,54 @@ class AppController extends ChangeNotifier {
|
||||
clean: !_dirty,
|
||||
);
|
||||
} catch (_) {}
|
||||
await _autoSaveDocument();
|
||||
}
|
||||
|
||||
/// 文档自动保存:启用、已保存过路径且有未保存修改时,按间隔写回文件。
|
||||
///
|
||||
/// - 间隔 = [Project.autoSaveMinutes](默认 10 分钟,1–240);
|
||||
/// - 以 [_lastSavedAt] 为基准:任何一次手动 / 自动保存都会重置计时;
|
||||
/// - 安卓写入公共 Documents,桌面写 `.seq.json` 并同步 `.bak` 备份。
|
||||
Future<void> _autoSaveDocument() async {
|
||||
final String? path = _filePath;
|
||||
if (!_project.autoSaveEnabled || !_dirty || path == null) return;
|
||||
final DateTime now = DateTime.now();
|
||||
// 从未保存过时间戳(如刚打开文件):以“现在”为基准,等满一个间隔再自动保存。
|
||||
if (_lastSavedAt == null) {
|
||||
_lastSavedAt = now;
|
||||
return;
|
||||
}
|
||||
final int minutes =
|
||||
_project.autoSaveMinutes < 1 ? 1 : (_project.autoSaveMinutes > 240 ? 240 : _project.autoSaveMinutes);
|
||||
if (now.difference(_lastSavedAt!).inSeconds < minutes * 60) return;
|
||||
_lastSavedAt = now;
|
||||
try {
|
||||
if (AndroidDocs.isAvailable) {
|
||||
await AndroidDocs.saveFile(
|
||||
_baseName(path),
|
||||
Uint8List.fromList(utf8.encode(_project.encode())),
|
||||
mime: 'application/json',
|
||||
);
|
||||
} else {
|
||||
await Storage.instance.saveProject(path, _project);
|
||||
}
|
||||
_dirty = false;
|
||||
_status = '已自动保存 ${_baseName(path)}';
|
||||
} catch (_) {
|
||||
_status = '自动保存失败(可手动 Ctrl+S 重试)';
|
||||
}
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 设置自动保存(开关与间隔分钟;间隔钳制到 1–240)。
|
||||
void setAutoSave({bool? enabled, int? minutes}) {
|
||||
final bool e = enabled ?? _project.autoSaveEnabled;
|
||||
final int m = (minutes ?? _project.autoSaveMinutes).clamp(1, 240);
|
||||
if (e == _project.autoSaveEnabled && m == _project.autoSaveMinutes) return;
|
||||
_project = _project.copyWith(autoSaveEnabled: e, autoSaveMinutes: m);
|
||||
_dirty = true;
|
||||
_status = e ? '自动保存:每 $m 分钟' : '自动保存:已关闭';
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 退出前将自动保存标记为“干净”,表示已正常关闭无需恢复。
|
||||
@@ -189,13 +248,28 @@ class AppController extends ChangeNotifier {
|
||||
_undo.add(_project);
|
||||
if (_undo.length > 200) _undo.removeAt(0);
|
||||
_redo.clear();
|
||||
_project = next;
|
||||
_project = _syncLaneFloor(next);
|
||||
_dirty = true;
|
||||
if (status != null) _status = status;
|
||||
_recomputeCritical();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 维护「保留空泳道」的保底泳道数 [Project.minLaneCount]:
|
||||
/// - 开启时只增不减(动作被全部移走的泳道保留、序号不变);
|
||||
/// - 关闭时收缩为当前实际使用的层数(空泳道自动移除)。
|
||||
static Project _syncLaneFloor(Project p) {
|
||||
int maxLayer = -1;
|
||||
for (final Action a in p.actions) {
|
||||
if (a.layer > maxLayer) maxLayer = a.layer;
|
||||
}
|
||||
final int want = p.keepEmptyLanes
|
||||
? (p.minLaneCount > maxLayer + 1 ? p.minLaneCount : maxLayer + 1)
|
||||
: maxLayer + 1;
|
||||
if (want < 0 || want == p.minLaneCount) return p;
|
||||
return p.copyWith(minLaneCount: want);
|
||||
}
|
||||
|
||||
/// 撤销:弹出 [_undo] 顶部的快照并压入 [_redo],重算关键路径后刷新。
|
||||
void undo() {
|
||||
if (_undo.isEmpty) return;
|
||||
@@ -258,6 +332,7 @@ class AppController extends ChangeNotifier {
|
||||
_filePath = null;
|
||||
_dirty = true;
|
||||
_status = '新建项目';
|
||||
_project = _syncLaneFloor(_project);
|
||||
_recomputeCritical();
|
||||
notifyListeners();
|
||||
}
|
||||
@@ -269,7 +344,7 @@ class AppController extends ChangeNotifier {
|
||||
void loadProject(Project p, {String? path, bool dirty = false}) {
|
||||
_undo.clear();
|
||||
_redo.clear();
|
||||
_project = p;
|
||||
_project = _syncLaneFloor(p);
|
||||
_filePath = path;
|
||||
_dirty = dirty;
|
||||
_status = path == null ? '已载入' : '已打开 ${_baseName(path)}';
|
||||
@@ -422,6 +497,17 @@ class AppController extends ChangeNotifier {
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 设置「保留空泳道」策略:动作全部移走后,泳道保留(序号不变)还是自动移除。
|
||||
///
|
||||
/// 切换为开启时以当前使用中的泳道为保底,避免把历史收缩掉的泳道“补”出来。
|
||||
void setKeepEmptyLanes(bool value) {
|
||||
if (_project.keepEmptyLanes == value) return;
|
||||
_project = _syncLaneFloor(_project.copyWith(keepEmptyLanes: value));
|
||||
_dirty = true;
|
||||
_status = value ? '已开启:保留空泳道' : '已关闭:空泳道自动移除';
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
/// 切换依赖连线的显示/隐藏。
|
||||
void toggleDeps() {
|
||||
_project = _project.copyWith(
|
||||
@@ -498,7 +584,7 @@ class AppController extends ChangeNotifier {
|
||||
final BarLayout l = BarLayout(_project, vp);
|
||||
// 内容逻辑范围:(0,0) → 右缘 + 60、最后一行底部 + 40。
|
||||
final double contentW = l.plotRight + 60;
|
||||
final double contentH = l.yFor(l.ordered.length) + 40;
|
||||
final double contentH = l.plotBottom + 40;
|
||||
z = math.min(vp.width / contentW, vp.height / contentH).clamp(0.25, 1.0);
|
||||
// 关键修复:内容被缩小时按内容范围居中显示;内容本来就能放下时保持默认位置。
|
||||
// (此前固定 pan = 0,缩小的画面会被钉在左上角。)
|
||||
@@ -595,8 +681,6 @@ class AppController extends ChangeNotifier {
|
||||
id = 'A$guard';
|
||||
}
|
||||
final int layer = _project.maxLayer + 1;
|
||||
// 新动作默认排在最后一行(显式行序),避免其相位变化导致行位置跳动。
|
||||
final int row = _project.actions.length;
|
||||
final double start = (startAngle ?? 0).clamp(0, 359);
|
||||
final Action a = Action(
|
||||
id: id,
|
||||
@@ -607,7 +691,7 @@ class AppController extends ChangeNotifier {
|
||||
durationAngle: 45,
|
||||
layer: layer,
|
||||
color: kActionPalette[(_project.actions.length) % kActionPalette.length],
|
||||
row: row,
|
||||
row: 0, // 新动作进入全新泳道(1 槽)的槽位 0
|
||||
);
|
||||
_mutate(
|
||||
_project.copyWith(
|
||||
@@ -667,7 +751,7 @@ class AppController extends ChangeNotifier {
|
||||
name: '${src.name} 副本',
|
||||
startAngle: (src.startAngle + 10).clamp(0, 359),
|
||||
layer: _project.maxLayer + 1,
|
||||
row: _project.actions.length,
|
||||
row: 0,
|
||||
deps: const <Dependency>[],
|
||||
);
|
||||
_mutate(
|
||||
@@ -750,28 +834,72 @@ class AppController extends ChangeNotifier {
|
||||
/// 不再因「目标泳道在该时间段已有动作」而拒绝:换道是高频拖拽操作,一旦拒绝,
|
||||
/// 动作会被“磁吸”回原泳道(表现为拖不动)。现允许放入并在状态栏提示时间重叠,
|
||||
/// 由用户自行调整相位;[canPlaceInLane] 仍用于拖拽时的可视化提示。
|
||||
/// 槽位保持原值(超出目标泳道槽位数时由布局钳制到末槽)。
|
||||
void moveActionLane(String id, int targetLane) {
|
||||
final Action? moving = _project.actionById(id);
|
||||
if (moving == null) return;
|
||||
final int lane = targetLane.clamp(0, 63);
|
||||
if (lane == moving.layer) return;
|
||||
updateAction(id, (Action x) => x.copyWith(layer: lane),
|
||||
status: '移至轨道 L${lane + 1}');
|
||||
}
|
||||
|
||||
/// 将动作 [id] 移动到([targetLane], [slot])——拖拽换道 / 换槽位。
|
||||
///
|
||||
/// 槽位钳制到目标泳道的槽位数范围;同槽时间重叠仅在状态栏提示,不阻止。
|
||||
void moveActionTo(String id, int targetLane, int slot) {
|
||||
final Action? moving = _project.actionById(id);
|
||||
if (moving == null) return;
|
||||
final int lane = targetLane.clamp(0, 63);
|
||||
final int slots = _project.slotsOf(lane);
|
||||
final int s = slot < 0 ? 0 : (slot >= slots ? slots - 1 : slot);
|
||||
if (lane == moving.layer && s == _effectiveSlot(moving)) return;
|
||||
final bool overlap = _project.actions.any((Action o) =>
|
||||
o.id != id &&
|
||||
o.layer == lane &&
|
||||
_effectiveSlot(o) == s &&
|
||||
angleRangesOverlap(moving.startAngle, moving.endAngle, o.startAngle, o.endAngle));
|
||||
updateAction(id, (Action x) => x.copyWith(layer: lane, row: lane),
|
||||
updateAction(id, (Action x) => x.copyWith(layer: lane, row: s),
|
||||
status: overlap
|
||||
? '移至轨道 L${lane + 1}(与该轨道动作时间重叠)'
|
||||
: '移至轨道 L${lane + 1}');
|
||||
? '移至 L${lane + 1} · 槽 ${s + 1}(有动作时间重叠)'
|
||||
: '移至 L${lane + 1} · 槽 ${s + 1}');
|
||||
}
|
||||
|
||||
/// 目标泳道 [lane] 是否能容纳动作 [id](不与其内动作时间重叠)。
|
||||
bool canPlaceInLane(String id, int lane) {
|
||||
/// 动作 [a] 在其泳道内的有效槽位(与布局层 [BarLayout.slotOf] 一致)。
|
||||
int _effectiveSlot(Action a) {
|
||||
final int slots = _project.slotsOf(a.layer);
|
||||
if (slots <= 1) return 0;
|
||||
final int r = a.row;
|
||||
return r < 0 ? 0 : (r >= slots ? slots - 1 : r);
|
||||
}
|
||||
|
||||
/// 设置泳道 [lane] 的槽位数(1–5)——「泳道加宽」:同一泳道可并列放置多个动作。
|
||||
///
|
||||
/// 缩窄时超出的动作不会被删除,其槽位在布局时钳制到末槽。
|
||||
void setLaneSlots(int lane, int slots) {
|
||||
final int n = slots.clamp(1, 5);
|
||||
if (_project.slotsOf(lane) == n) return;
|
||||
final Map<int, int> next = Map<int, int>.of(_project.laneSlots);
|
||||
if (n <= 1) {
|
||||
next.remove(lane);
|
||||
} else {
|
||||
next[lane] = n;
|
||||
}
|
||||
_mutate(
|
||||
_project.copyWith(laneSlots: next),
|
||||
status: n > 1 ? '泳道 L${lane + 1} 已加宽为 $n 槽(可并列 $n 个动作)' : '泳道 L${lane + 1} 恢复 1 槽',
|
||||
);
|
||||
}
|
||||
|
||||
/// 目标泳道 [lane](可选 [slot],默认取动作当前槽位)能否容纳动作 [id]。
|
||||
bool canPlaceInLane(String id, int lane, {int? slot}) {
|
||||
final Action? a = _project.actionById(id);
|
||||
if (a == null) return false;
|
||||
final int s = slot ?? _effectiveSlot(a);
|
||||
return !_project.actions.any((Action o) =>
|
||||
o.id != id &&
|
||||
o.layer == lane &&
|
||||
_effectiveSlot(o) == s &&
|
||||
angleRangesOverlap(a.startAngle, a.endAngle, o.startAngle, o.endAngle));
|
||||
}
|
||||
|
||||
|
||||
+86
-8
@@ -18,6 +18,7 @@ import 'package:flutter/services.dart';
|
||||
import '../export/drawio_writer.dart';
|
||||
import '../export/export_renderer.dart';
|
||||
import '../export/svg_writer.dart';
|
||||
import '../layout/layout.dart';
|
||||
import '../model/models.dart';
|
||||
import '../model/units.dart';
|
||||
import '../persistence/android_docs.dart';
|
||||
@@ -1179,7 +1180,7 @@ class _AppShellState extends State<AppShell> {
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
_sectionLabel(t, '时序创建和编辑'),
|
||||
_sectionLabel(t, '文档设置'),
|
||||
const Spacer(),
|
||||
_panelControls(t, true),
|
||||
],
|
||||
@@ -1188,14 +1189,14 @@ class _AppShellState extends State<AppShell> {
|
||||
_editEntry(
|
||||
t,
|
||||
icon: Icons.edit_note,
|
||||
label: '编辑时序与节拍参数',
|
||||
label: '文档设置',
|
||||
enabled: !flow,
|
||||
onTap: () => showDialog<void>(
|
||||
context: context,
|
||||
builder: (_) => SettingsDialog(controller: c),
|
||||
),
|
||||
),
|
||||
// 较浅的分隔横线,区分上方「时序创建和编辑」与下方「动作和执行编辑」。
|
||||
// 较浅的分隔横线,区分上方「文档设置」与下方「动作和执行编辑」。
|
||||
const SizedBox(height: 14),
|
||||
Divider(height: 1, thickness: 1, color: t.line),
|
||||
const SizedBox(height: 14),
|
||||
@@ -1358,6 +1359,35 @@ class _AppShellState extends State<AppShell> {
|
||||
return Tooltip(message: '流程图只读:修改请切回条形 / 圆周视图', child: card);
|
||||
}
|
||||
|
||||
/// 左侧栏的泳道槽位小徽标:显示当前槽位数,点击可调整(1–5 槽)。
|
||||
///
|
||||
/// 槽位数 > 1 时高亮显示(多槽位泳道内动作按子行并列放置)。
|
||||
Widget _laneSlotChip(Tokens t, int lane) {
|
||||
final int n = c.project.slotsOf(lane);
|
||||
return Builder(
|
||||
builder: (BuildContext ctx) => Tooltip(
|
||||
message: '泳道 L${lane + 1} 槽位数:$n(点击调整,最多 5)',
|
||||
child: InkWell(
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
onTap: () async {
|
||||
final RenderBox box = ctx.findRenderObject()! as RenderBox;
|
||||
await showLaneSlotMenu(context, c, box.localToGlobal(Offset.zero), lane);
|
||||
},
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
||||
decoration: BoxDecoration(
|
||||
color: n > 1 ? t.accent.withValues(alpha: 0.14) : t.panel2,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(color: n > 1 ? t.accent.withValues(alpha: 0.4) : t.line2),
|
||||
),
|
||||
child: Text('$n 槽',
|
||||
style: TextStyle(color: n > 1 ? t.accent : t.dim, fontSize: 10)),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 动作列表小节标题右侧的紧凑按钮(新建 / 删除)。
|
||||
///
|
||||
/// [onTap] 为 null 时按钮呈禁用态(降低不透明度),用于「未选中动作时禁用删除」。
|
||||
@@ -1385,12 +1415,17 @@ class _AppShellState extends State<AppShell> {
|
||||
|
||||
/// 左侧栏:按泳道 / 轨道分组的行列表。
|
||||
List<Widget> _laneRows(Tokens t, bool bar) {
|
||||
final List<int> lanes = <int>{for (final Action a in c.project.actions) a.layer}.toList()..sort();
|
||||
final List<int> lanes = c.project.renderLanes;
|
||||
final List<Widget> out = <Widget>[];
|
||||
for (int li = 0; li < lanes.length; li++) {
|
||||
final int lane = lanes[li];
|
||||
final List<Action> acts = c.project.actions.where((Action a) => a.layer == lane).toList()
|
||||
..sort((Action a, Action b) => a.startAngle.compareTo(b.startAngle));
|
||||
// 空泳道(开启「保留空泳道」后动作被全部移走):显示占位行。
|
||||
if (acts.isEmpty) {
|
||||
out.add(_emptyLaneRow(t, lane, li));
|
||||
continue;
|
||||
}
|
||||
// 单动作泳道沿用普通动作行;多动作泳道合并显示。
|
||||
out.add(acts.length == 1
|
||||
? _actionRow(t, acts.first, li, bar)
|
||||
@@ -1399,6 +1434,42 @@ class _AppShellState extends State<AppShell> {
|
||||
return out;
|
||||
}
|
||||
|
||||
/// 左侧栏中的空泳道占位行(开启「保留空泳道」后,动作被全部移走的泳道)。
|
||||
Widget _emptyLaneRow(Tokens t, int lane, int li) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(bottom: 6),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 10),
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
border: Border.all(color: t.line),
|
||||
),
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Container(
|
||||
width: 22,
|
||||
height: 22,
|
||||
decoration: BoxDecoration(
|
||||
color: t.panel2,
|
||||
borderRadius: BorderRadius.circular(6),
|
||||
border: Border.all(color: t.line2),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text('${li + 1}',
|
||||
style: TextStyle(color: t.dim, fontSize: 11, fontWeight: FontWeight.w700)),
|
||||
),
|
||||
const SizedBox(width: 9),
|
||||
Expanded(
|
||||
child: Text('空泳道(已保留,可拖入动作)',
|
||||
style: TextStyle(color: t.dim, fontSize: 11)),
|
||||
),
|
||||
_laneSlotChip(t, lane),
|
||||
],
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// 单条泳道 / 轨道行:多个动作合并显示(≤2 行,/ 分隔)。
|
||||
Widget _laneRow(Tokens t, int lane, int li, List<Action> acts, bool bar) {
|
||||
if (acts.isEmpty) return const SizedBox.shrink();
|
||||
@@ -1454,7 +1525,8 @@ class _AppShellState extends State<AppShell> {
|
||||
children: <Widget>[
|
||||
Text(
|
||||
joined,
|
||||
maxLines: 2,
|
||||
// 多槽位泳道允许更多行(最多与槽位数一致),持续自动换行。
|
||||
maxLines: math.max(2, c.project.slotsOf(lane)),
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(
|
||||
color: sel ? t.text : t.text2,
|
||||
@@ -1492,6 +1564,8 @@ class _AppShellState extends State<AppShell> {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_laneSlotChip(t, lane),
|
||||
const SizedBox(width: 4),
|
||||
InkWell(
|
||||
onTap: flow
|
||||
? null
|
||||
@@ -1561,7 +1635,9 @@ class _AppShellState extends State<AppShell> {
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: sel ? t.text : t.text2, fontSize: 12, fontWeight: sel ? FontWeight.w600 : FontWeight.normal)),
|
||||
Text('${a.id} · ${st?.name ?? a.stationId} · ${a.driver}',
|
||||
Text(
|
||||
'${a.id} · ${st?.name ?? a.stationId} · ${a.driver}'
|
||||
'${c.project.slotsOf(a.layer) > 1 ? ' · 槽 ${effectiveSlot(c.project, a) + 1}' : ''}',
|
||||
maxLines: 1,
|
||||
overflow: TextOverflow.ellipsis,
|
||||
style: TextStyle(color: t.dim, fontSize: 10)),
|
||||
@@ -1589,6 +1665,8 @@ class _AppShellState extends State<AppShell> {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 6),
|
||||
_laneSlotChip(t, a.layer),
|
||||
const SizedBox(width: 4),
|
||||
InkWell(
|
||||
onTap: flow
|
||||
? null
|
||||
@@ -2160,9 +2238,9 @@ class _AppShellState extends State<AppShell> {
|
||||
'相位 360° = 100%',
|
||||
'动作 ${c.project.actions.length}',
|
||||
'依赖 ${_depCount()}',
|
||||
circular ? '轨道 L1–L${c.project.laneCount}' : '工位 ${c.project.stations.length}',
|
||||
circular ? '轨道 L1–L${c.project.renderLaneCount}' : '工位 ${c.project.stations.length}',
|
||||
mode == ViewMode.flow
|
||||
? '泳道 L1–L${c.project.laneCount}(流程节点 ${c.project.actions.length})'
|
||||
? '泳道 L1–L${c.project.renderLaneCount}(流程节点 ${c.project.actions.length})'
|
||||
: (circular ? '同心圆 ${c.project.laneCount}' : '时间轴 0–${tfmt(c.project.cycle.durationMs, u)}'),
|
||||
'单位 ${timeUnitLabel(u.timeUnit)} / ${phaseUnitLabel(u.phaseUnit)}',
|
||||
'1° = ${tfmtAuto(c.project.cycle.durationMs / 360)}',
|
||||
|
||||
@@ -318,7 +318,10 @@ class _SelectedCard extends StatelessWidget {
|
||||
_kv(t, '结束相位', pfmt(a.endAngle, u)),
|
||||
_kv(t, '持续相位', pfmt(a.durationAngle, u)),
|
||||
const SizedBox(height: 4),
|
||||
Text('Δ = $delta · 层 L${a.layer + 1} · ${st?.id ?? a.stationId}',
|
||||
Text(
|
||||
'Δ = $delta · 层 L${a.layer + 1}'
|
||||
'${c.project.slotsOf(a.layer) > 1 ? ' · 槽 ${effectiveSlot(c.project, a) + 1}' : ''}'
|
||||
' · ${st?.id ?? a.stationId}',
|
||||
style: TextStyle(color: t.accent, fontSize: 11, fontWeight: FontWeight.w600)),
|
||||
],
|
||||
),
|
||||
|
||||
+38
-15
@@ -204,7 +204,7 @@ class _CanvasViewState extends State<CanvasView> {
|
||||
} else {
|
||||
final CircularLayout layout = CircularLayout(c.project, size);
|
||||
for (final Action a in c.project.actions) {
|
||||
final double r = layout.radiusFor(a.layer);
|
||||
final double r = layout.radiusFor(a.layer, layout.slotOf(a));
|
||||
final double ds = (p - polar(layout.center, r, a.startAngle)).distance;
|
||||
final double de = (p - polar(layout.center, r, math.min(a.endAngle, 360))).distance;
|
||||
if (ds < bestDist) {
|
||||
@@ -478,6 +478,14 @@ class _CanvasViewState extends State<CanvasView> {
|
||||
_renameZone(zi);
|
||||
return;
|
||||
}
|
||||
// 双击左侧泳道编号区(图外空白):打开泳道槽位菜单(加宽 / 恢复)。
|
||||
if (p.dx < BarLayout.leftGutter) {
|
||||
final BarLayout layout = BarLayout(c.project, size);
|
||||
if (layout.lanes.isNotEmpty) {
|
||||
_laneSlotMenu(d.globalPosition, layout.laneAt(p.dy));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
final Action? hit = c.project.viewState.mode == ViewMode.bar
|
||||
? BarLayout(c.project, size).hitTest(p, slop: _hitSlop)
|
||||
@@ -688,17 +696,16 @@ class _CanvasViewState extends State<CanvasView> {
|
||||
status: '调整起始角',
|
||||
);
|
||||
} else {
|
||||
// 整体移动:水平改起始相位 + 垂直跟随泳道,两者可同时进行。
|
||||
// (原先要求「垂直分量明显大于水平」才换道,斜向拖拽几乎换不了道,
|
||||
// 表现为“有一股磁吸力、拖不到别的泳道”。)
|
||||
// 整体移动:水平改起始相位 + 垂直跟随泳道 / 槽位,两者可同时进行。
|
||||
c.setActionStart(_dragAction!.id, _startAngle + dx / layout.span * 360);
|
||||
final int curLane =
|
||||
c.project.actionById(_dragAction!.id)?.layer ?? _dragAction!.layer;
|
||||
final int target = layout.laneAt(p.dy);
|
||||
if (target != curLane) {
|
||||
_dropLane = target;
|
||||
_dropValid = c.canPlaceInLane(_dragAction!.id, target);
|
||||
c.moveActionLane(_dragAction!.id, target);
|
||||
final Action? cur = c.project.actionById(_dragAction!.id);
|
||||
final int curLane = cur?.layer ?? _dragAction!.layer;
|
||||
final int curSlot = cur == null ? 0 : layout.slotOf(cur);
|
||||
final (int, int) target = layout.laneSlotAt(p.dy);
|
||||
if (target.$1 != curLane || target.$2 != curSlot) {
|
||||
_dropLane = target.$1;
|
||||
_dropValid = c.canPlaceInLane(_dragAction!.id, target.$1, slot: target.$2);
|
||||
c.moveActionTo(_dragAction!.id, target.$1, target.$2);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -724,9 +731,10 @@ class _CanvasViewState extends State<CanvasView> {
|
||||
status: '调整起始角',
|
||||
);
|
||||
} else if (shift) {
|
||||
// Shift + 径向拖拽:换轨道(同轨道可放多个不重叠动作)。
|
||||
// Shift + 径向拖拽:换轨道 / 换子环(槽位)。
|
||||
final double rad = (p - layout.center).distance;
|
||||
c.moveActionLane(_dragAction!.id, layout.laneAtRadius(rad));
|
||||
final (int, int) t = layout.laneSlotAtRadius(rad);
|
||||
c.moveActionTo(_dragAction!.id, t.$1, t.$2);
|
||||
} else {
|
||||
c.setActionStart(_dragAction!.id, _startAngle + delta);
|
||||
}
|
||||
@@ -866,8 +874,17 @@ class _CanvasViewState extends State<CanvasView> {
|
||||
? BarLayout(c.project, size).hitTest(local)
|
||||
: CircularLayout(c.project, size).hitTest(local);
|
||||
if (hit == null) {
|
||||
// 未命中动作:若命中依赖连线,弹出连线菜单。
|
||||
if (depKey != null) await _depMenu(global, depKey);
|
||||
// 未命中动作:先看依赖连线,其次(条形视图)提供泳道槽位菜单。
|
||||
if (depKey != null) {
|
||||
await _depMenu(global, depKey);
|
||||
return;
|
||||
}
|
||||
if (c.project.viewState.mode == ViewMode.bar) {
|
||||
final BarLayout layout = BarLayout(c.project, size);
|
||||
if (layout.lanes.isNotEmpty) {
|
||||
await _laneSlotMenu(global, layout.laneAt(local.dy));
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
c.select(hit.id);
|
||||
@@ -925,6 +942,12 @@ class _CanvasViewState extends State<CanvasView> {
|
||||
}
|
||||
}
|
||||
|
||||
/// 泳道槽位菜单(实现见 [showLaneSlotMenu],画布与侧栏共用)。
|
||||
///
|
||||
/// 入口:双击条形视图左侧泳道编号区 / 右键空白泳道。
|
||||
Future<void> _laneSlotMenu(Offset global, int lane) =>
|
||||
showLaneSlotMenu(context, c, global, lane);
|
||||
|
||||
/// 相位分区右键菜单:重命名 / 插入 / 删除,实现任意增减。
|
||||
Future<void> _zoneMenu(Offset global, int index) async {
|
||||
final RenderBox box = context.findRenderObject()! as RenderBox;
|
||||
|
||||
+131
-34
@@ -5,7 +5,7 @@
|
||||
// 包含:
|
||||
// · 通用消息提示(showMessage);
|
||||
// · .seq.json 文件浏览/保存对话框(FileBrowserDialog / pickFile);
|
||||
// · 动作编辑、依赖编辑、工艺参数设置、帮助中心等业务对话框。
|
||||
// · 动作编辑、依赖编辑、文档设置、帮助中心等业务对话框。
|
||||
import 'dart:io';
|
||||
import 'dart:math' as math;
|
||||
|
||||
@@ -18,6 +18,7 @@ import '../persistence/android_docs.dart';
|
||||
import '../persistence/storage.dart';
|
||||
import '../state/app_controller.dart';
|
||||
import '../theme/tokens.dart';
|
||||
import '../version.dart';
|
||||
import 'app_logo.dart';
|
||||
|
||||
// ===================== 对话框等比缩放 =====================
|
||||
@@ -876,7 +877,7 @@ class _ActionEditorDialogState extends State<ActionEditorDialog> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
// 按时间输入:与角度实时双向换算(单位随工艺参数设置)。
|
||||
// 按时间输入:与角度实时双向换算(单位随文档设置)。
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
@@ -1045,22 +1046,57 @@ class _DependencyEditorDialogState extends State<DependencyEditorDialog> {
|
||||
}
|
||||
}
|
||||
|
||||
// ===================== 工艺参数设置对话框 =====================
|
||||
// ===================== 文档设置对话框 =====================
|
||||
|
||||
/// 工艺参数对话框:设置项目名称、时间/相位单位、显示精度、
|
||||
/// 循环时长、换算表与编辑辅助选项。
|
||||
/// 泳道槽位菜单:把泳道加宽为 1–5 槽(同一泳道并列放置多个动作),或恢复 1 槽。
|
||||
///
|
||||
/// 入口:双击条形视图左侧泳道编号区 / 右键空白泳道 / 左侧栏「N 槽」徽标。
|
||||
/// 加宽后同一泳道的动作按 `Action.row`(槽位)分成多条并排行,
|
||||
/// 圆周视图与流程图同样按槽位分行 / 分环 / 分列。
|
||||
Future<void> showLaneSlotMenu(
|
||||
BuildContext context, AppController controller, Offset global, int lane) async {
|
||||
final RenderBox box = context.findRenderObject()! as RenderBox;
|
||||
final Offset pos = box.globalToLocal(global);
|
||||
final int cur = controller.project.slotsOf(lane);
|
||||
final String? result = await showMenu<String>(
|
||||
context: context,
|
||||
position: RelativeRect.fromLTRB(pos.dx, pos.dy, pos.dx, pos.dy),
|
||||
items: <PopupMenuEntry<String>>[
|
||||
const PopupMenuItem<String>(
|
||||
enabled: false,
|
||||
height: 34,
|
||||
child: Text('泳道槽位数(并列动作数)', style: TextStyle(fontSize: 11.5)),
|
||||
),
|
||||
for (int i = 1; i <= 5; i++)
|
||||
PopupMenuItem<String>(
|
||||
value: '$i',
|
||||
child: Row(
|
||||
children: <Widget>[
|
||||
Text(i == cur ? '✓' : '', style: const TextStyle(fontSize: 12)),
|
||||
const SizedBox(width: 6),
|
||||
Text('$i 槽${i == cur ? '(当前)' : ''}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
if (result != null) controller.setLaneSlots(lane, int.tryParse(result) ?? 1);
|
||||
}
|
||||
|
||||
/// 文档设置对话框:设置项目名称、时间/相位单位、显示精度、
|
||||
/// 循环时长、泳道策略、换算表与编辑辅助选项。
|
||||
class SettingsDialog extends StatefulWidget {
|
||||
const SettingsDialog({super.key, required this.controller});
|
||||
|
||||
/// 全局应用控制器。
|
||||
final AppController controller;
|
||||
|
||||
/// 创建工艺参数对话框对应的状态对象。
|
||||
/// 创建文档设置对话框对应的状态对象。
|
||||
@override
|
||||
State<SettingsDialog> createState() => _SettingsDialogState();
|
||||
}
|
||||
|
||||
/// 工艺参数对话框状态:以副本形式编辑单位设置,点击“应用”后统一提交。
|
||||
/// 文档设置对话框状态:以副本形式编辑单位设置,点击“应用”后统一提交。
|
||||
class _SettingsDialogState extends State<SettingsDialog> {
|
||||
/// 正在编辑的单位设置副本。
|
||||
late UnitSettings _u;
|
||||
@@ -1081,7 +1117,7 @@ class _SettingsDialogState extends State<SettingsDialog> {
|
||||
_name = TextEditingController(text: widget.controller.project.name);
|
||||
}
|
||||
|
||||
/// 渲染工艺参数表单:项目名、单位、精度、循环、换算表与编辑辅助。
|
||||
/// 渲染文档设置表单:项目名、单位、精度、循环、泳道、换算表与编辑辅助。
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Tokens t = context.tok;
|
||||
@@ -1100,7 +1136,7 @@ class _SettingsDialogState extends State<SettingsDialog> {
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Text('工艺参数', style: TextStyle(fontSize: 17, fontWeight: FontWeight.w700, color: t.text)),
|
||||
Text('文档设置', style: TextStyle(fontSize: 17, fontWeight: FontWeight.w700, color: t.text)),
|
||||
const SizedBox(width: 14),
|
||||
Text('单位与精度 / 循环与相位 / 编辑辅助',
|
||||
style: TextStyle(fontSize: 11, color: t.dim)),
|
||||
@@ -1254,6 +1290,61 @@ class _SettingsDialogState extends State<SettingsDialog> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
// 泳道策略:动作全部移走后,泳道保留还是自动移除。
|
||||
Text('泳道', style: TextStyle(color: t.sub, fontSize: 11)),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
children: <Widget>[
|
||||
FilterChip(
|
||||
label: const Text('保留空泳道'),
|
||||
selected: widget.controller.project.keepEmptyLanes,
|
||||
onSelected: (bool v) {
|
||||
widget.controller.setKeepEmptyLanes(v);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'开启:动作全部移走的泳道保留(条形行 / 圆周环 / 流程列,序号不变);关闭:空泳道自动移除、序号顺延。',
|
||||
style: TextStyle(color: t.dim, fontSize: 10.5, height: 1.5),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
// 自动保存:定时把文档写回文件(需已手动保存过一次路径)。
|
||||
Text('自动保存', style: TextStyle(color: t.sub, fontSize: 11)),
|
||||
const SizedBox(height: 8),
|
||||
Wrap(
|
||||
spacing: 10,
|
||||
runSpacing: 6,
|
||||
crossAxisAlignment: WrapCrossAlignment.center,
|
||||
children: <Widget>[
|
||||
FilterChip(
|
||||
label: const Text('启用自动保存'),
|
||||
selected: widget.controller.project.autoSaveEnabled,
|
||||
onSelected: (bool v) {
|
||||
widget.controller.setAutoSave(enabled: v);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
for (final int m in <int>[1, 5, 10, 30])
|
||||
ChoiceChip(
|
||||
label: Text('$m 分钟'),
|
||||
selected: widget.controller.project.autoSaveMinutes == m,
|
||||
onSelected: (_) {
|
||||
widget.controller.setAutoSave(minutes: m);
|
||||
setState(() {});
|
||||
},
|
||||
),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 6),
|
||||
Text(
|
||||
'默认每 10 分钟自动保存一次(可选 1 / 5 / 10 / 30 分钟);需先手动保存过一次(有文件路径)才生效,自动保存会同步更新 .bak 备份。',
|
||||
style: TextStyle(color: t.dim, fontSize: 10.5, height: 1.5),
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
// 时间 / 相位换算表:以 90° 为步长展示对应关系。
|
||||
Text('时间 / 相位 换算', style: TextStyle(color: t.sub, fontSize: 11)),
|
||||
const SizedBox(height: 6),
|
||||
@@ -1363,7 +1454,7 @@ class _SettingsDialogState extends State<SettingsDialog> {
|
||||
final double? cv = double.tryParse(_cycle.text);
|
||||
final double ms = cv == null ? cycleMs : cv * kTimeDiv[_u.timeUnit]!;
|
||||
final AppController c = widget.controller;
|
||||
c.setUnits(_u, status: '工艺参数已应用');
|
||||
c.setUnits(_u, status: '文档设置已应用');
|
||||
c.setCycleDuration(ms);
|
||||
if (_name.text.trim().isNotEmpty && _name.text.trim() != c.project.name) {
|
||||
c.setProjectName(_name.text.trim());
|
||||
@@ -1999,12 +2090,15 @@ class HelpDialog extends StatelessWidget {
|
||||
<String>['我要删除动作', '选中后:左侧「删除」/ 行内删除图标 / Delete 键 / 右键菜单;至少保留一个动作 / 泳道。'],
|
||||
<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>['我要让动作跨循环', '使「起始角 + 持续角 > 360°」,会自动拆分并以半透明虚线渲染尾段。'],
|
||||
<String>['我要加前置依赖(输入)', '右侧「前置依赖 · 输入」→「添加前置依赖」;或右键动作 →「添加依赖」。'],
|
||||
@@ -2015,7 +2109,7 @@ class HelpDialog extends StatelessWidget {
|
||||
]),
|
||||
// 目标:编辑相位分区并控制画布显示。
|
||||
_section(t, <List<String>>[
|
||||
<String>['相位分区是什么', '把一个循环按角度分成的命名工艺阶段(默认上料 / 加工 / 检测),条形图顶部标注带即它。'],
|
||||
<String>['相位分区是什么', '把一个循环按角度分成的命名工艺阶段(默认上料 / 加工 / 检测):条形图顶部为标注色带、圆周视图为最外圈相位环与径向边界、流程图左侧为竖排阶段栏。可重叠、可留空、>360° 表示跨圈。'],
|
||||
<String>['我要编辑相位分区', '左侧「动作和执行编辑」→「编辑相位分区」;或 F2 →「相位分区」→「编辑…」。增删分区、改名称与起止角;可重叠、可留空、>360° 表示跨圈。'],
|
||||
<String>['我要隐藏相位分区', '左侧「显示选项」取消勾选「相位分区标注」。'],
|
||||
<String>['刻度怎么读', '条形视图:分区带与刻度线之间上排为相位、下排为等价时间;圆周视图:每 30° 的度数外侧标注等价时间。'],
|
||||
@@ -2035,7 +2129,7 @@ class HelpDialog extends StatelessWidget {
|
||||
<String>['我要导出 SVG', '顶部「导出」下拉菜单 →「导出 SVG」:矢量、分层、带语义 id 与 data-*,可直接进工艺卡 / MES。'],
|
||||
<String>['我要导出 PNG', '顶部「导出」下拉菜单 →「导出 PNG」:按 2 倍像素比导出当前视图为位图。'],
|
||||
<String>['我要导出 drawio', '流程图视图专用:顶部「导出」→「导出 drawio」,输出 diagrams.net(draw.io)可继续编辑的工程文件。'],
|
||||
<String>['我要保存 / 恢复', '「保存」写入 .seq.json 并生成 .bak;每 5 秒自动快照,异常退出后启动可恢复。'],
|
||||
<String>['我要保存 / 恢复', '「保存」写入 .seq.json 并生成 .bak;每 5 秒自动快照(异常退出可恢复);F2 文档设置中可开启「自动保存」(默认每 10 分钟一次,需先手动保存过一次路径)。'],
|
||||
]),
|
||||
// 目标:调整界面与使用快捷键。
|
||||
_section(t, <List<String>>[
|
||||
@@ -2052,7 +2146,7 @@ class HelpDialog extends StatelessWidget {
|
||||
<String>['撤销 / 保存', 'Ctrl+Z / Ctrl+Y 撤销重做;Ctrl+S 保存;Ctrl+O / Ctrl+N 打开 / 新建。'],
|
||||
<String>['帮助入口', '顶部工具栏右侧「?」或 F1 打开帮助中心;画布编辑工具条不重复放置帮助按钮。'],
|
||||
<String>['导出入口', '导出统一放在顶部工具栏「导出」下拉菜单:SVG / PNG 三种视图通用;流程图另有 drawio。'],
|
||||
<String>['其它', 'F2 编辑时序与节拍参数(含单位与相位分区);F3 切换深/浅主题;Delete 删除选中动作。'],
|
||||
<String>['其它', 'F2 文档设置(含单位、循环、泳道与相位分区);F3 切换深/浅主题;Delete 删除选中动作。'],
|
||||
]),
|
||||
// 关于:设计人、版本、版权、授权信息与本机 MAC。
|
||||
_about(context, t),
|
||||
@@ -2096,9 +2190,11 @@ class HelpDialog extends StatelessWidget {
|
||||
Widget _about(BuildContext context, Tokens t) {
|
||||
final bool android = AndroidDocs.isAvailable;
|
||||
final LicenseInfo info = LicenseService.instance.info;
|
||||
final String lic = info.valid
|
||||
final String lic = !kLicenseRequired
|
||||
? '已开放(临时免授权)'
|
||||
: (info.valid
|
||||
? '已授权(${info.filePath?.split(RegExp(r'[\\/]')).last ?? '.lic'})'
|
||||
: '未授权';
|
||||
: '未授权');
|
||||
Widget row(String k, String v, {Color? vc}) => Padding(
|
||||
padding: const EdgeInsets.only(bottom: 10),
|
||||
child: Row(
|
||||
@@ -2129,7 +2225,7 @@ class HelpDialog extends StatelessWidget {
|
||||
Text('时序图设计 · Sequence Diagram Studio',
|
||||
style: TextStyle(color: t.text, fontSize: 15, fontWeight: FontWeight.w700)),
|
||||
const SizedBox(height: 4),
|
||||
Text('V1.3.3(${android ? '安卓版' : 'Windows 版'})',
|
||||
Text('V1.3.4(${android ? '安卓版' : 'Windows 版'})',
|
||||
style: TextStyle(color: t.dim, fontSize: 12)),
|
||||
],
|
||||
),
|
||||
@@ -2140,15 +2236,16 @@ class HelpDialog extends StatelessWidget {
|
||||
row('设计人', '呆头鹅'),
|
||||
row(
|
||||
'授权状态',
|
||||
android ? '已授权(安卓版免授权)' : lic,
|
||||
vc: (android || info.valid) ? t.ok : t.danger,
|
||||
!kLicenseRequired ? '开放授权版本' : (android ? '已授权(安卓版免授权)' : lic),
|
||||
vc: (android || !kLicenseRequired || info.valid) ? t.ok : t.danger,
|
||||
),
|
||||
if (!android)
|
||||
// 注意:绝不能展示「期望授权串」——它等同于 .lic 内容,公开即可被绕过授权。
|
||||
row('本机 MAC', info.mac ?? '读取失败'),
|
||||
row('版权声明', 'Copyright © 2026 呆头鹅。保留所有权利。'),
|
||||
row('产品简介', '面向 PLC 流程节拍 / 相位角设计的时序图工具:条形 / 圆周双视图、'
|
||||
'FS / SS 依赖与关键路径、SVG / PNG 导出,成果可直接进工艺卡与 MES。'),
|
||||
row('版权声明', 'Copyright © 2026 EDC(Easy Design Collection)呆头鹅。保留所有权利。'),
|
||||
row('产品简介', '面向 PLC 流程节拍 / 相位角设计的设计工具:条形 / 圆周 / 流程图三视图、'
|
||||
'FS / SS 依赖与关键路径、泳道加宽(多槽位)与空泳道策略、依赖走线可调、'
|
||||
'支持导出 SVG / PNG / drawio,成果可直接进工艺卡与 MES。'),
|
||||
const SizedBox(height: 6),
|
||||
// 官网入口(点击导航到 sincos.cc)。
|
||||
Row(
|
||||
@@ -2171,8 +2268,7 @@ class HelpDialog extends StatelessWidget {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (!android)
|
||||
// 授权指南(桌面版:按本机 MAC 申请 .lic)。
|
||||
// 开发者与交流群(原「授权指南」位置;授权恢复后回补授权指南)。
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
@@ -2185,20 +2281,22 @@ class HelpDialog extends StatelessWidget {
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Icon(Icons.menu_book_outlined, size: 16, color: t.accent),
|
||||
Icon(Icons.groups_outlined, size: 16, color: t.accent),
|
||||
const SizedBox(width: 6),
|
||||
Text('授权指南', style: TextStyle(color: t.accent, fontSize: 12.5, fontWeight: FontWeight.w600)),
|
||||
Text('开发者与交流群',
|
||||
style: TextStyle(color: t.accent, fontSize: 12.5, fontWeight: FontWeight.w600)),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
guideLine('1. 复制上方「本机 MAC」。'),
|
||||
guideLine('2. 访问官网 sincos.cc,或把 MAC 发送到邮箱 liuyu65@126.com 申请授权。'),
|
||||
guideLine('3. 收到 .lic 文件后,放入软件目录下的 license 文件夹,重启软件即可导出 SVG / PNG。'),
|
||||
guideLine('开发者邮箱:liuyu65@126.com'),
|
||||
guideLine('设计交流群:添加开发者微信 online-goose,加入「设计与制造业设计交流群」。'),
|
||||
guideLine('官网:sincos.cc'),
|
||||
],
|
||||
),
|
||||
)
|
||||
else
|
||||
// 安卓版说明:免授权 + 保存位置 + 反馈方式。
|
||||
),
|
||||
const SizedBox(height: 10),
|
||||
if (android)
|
||||
// 安卓版说明:免授权 + 保存位置。
|
||||
Container(
|
||||
padding: const EdgeInsets.all(12),
|
||||
decoration: BoxDecoration(
|
||||
@@ -2220,7 +2318,6 @@ class HelpDialog extends StatelessWidget {
|
||||
guideLine('本版面向应用商店分发,无需授权,全部功能可用。'),
|
||||
guideLine('保存 / 导出文件位于「文件管理」可见的公共目录(默认 Documents/SequenceDiagram,'
|
||||
'可在保存对话框中更改位置)。'),
|
||||
guideLine('帮助与反馈:官网 sincos.cc 或邮箱 liuyu65@126.com。'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
@@ -207,6 +207,11 @@ class _UpdateDialogState extends State<UpdateDialog> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 4),
|
||||
Text(
|
||||
'将直接升级到最新版本 v${info.version}(无需逐版本安装)',
|
||||
style: TextStyle(color: t.accent, fontSize: 11),
|
||||
),
|
||||
const SizedBox(height: 2),
|
||||
Text(
|
||||
'安装包:${info.assetName}${sizeText.isEmpty ? '' : '($sizeText)'}',
|
||||
style: TextStyle(color: t.dim, fontSize: 11),
|
||||
@@ -256,7 +261,7 @@ class _UpdateDialogState extends State<UpdateDialog> {
|
||||
),
|
||||
if (_busy && _progress >= 0)
|
||||
Text('${(_progress * 100).clamp(0, 100).toStringAsFixed(0)}% · '
|
||||
'${(_received / 1048576).toStringAsFixed(1)} MB',
|
||||
'${(_received / 1048576).toStringAsFixed(1)} MB · 限速 320KB/s',
|
||||
style: TextStyle(color: t.dim, fontSize: 11)),
|
||||
],
|
||||
),
|
||||
@@ -279,6 +284,29 @@ class _UpdateDialogState extends State<UpdateDialog> {
|
||||
height: 1.5)),
|
||||
),
|
||||
],
|
||||
// 下载提示:明确提醒保持屏幕常亮与网络连接,避免下载中断。
|
||||
Container(
|
||||
width: double.infinity,
|
||||
padding: const EdgeInsets.all(10),
|
||||
decoration: BoxDecoration(
|
||||
color: t.warn.withValues(alpha: 0.10),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
border: Border.all(color: t.warn.withValues(alpha: 0.35)),
|
||||
),
|
||||
child: Row(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Icon(Icons.lightbulb_outline, size: 15, color: t.warn),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
'下载更新过程中,请确保屏幕保持长亮、网络持续连接,避免更新包下载中断。',
|
||||
style: TextStyle(color: t.warn, fontSize: 11.5, height: 1.5),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 14),
|
||||
|
||||
// 操作按钮
|
||||
|
||||
@@ -80,6 +80,12 @@ bool isNewerVersion(String remote, String current) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// 客户端下载限速(字节/秒):更新包下载时主动限速,降低自建服务器带宽压力。
|
||||
///
|
||||
/// 实现方式:边收边按目标速率等待(TCP 反压会让服务端发送同步变慢),
|
||||
/// 因此即使多端并发,每端最多占用该速率,不会把服务器的带宽打满。
|
||||
const int kUpdateDownloadLimit = 320 * 1024;
|
||||
|
||||
/// 更新服务:检查 + 下载。
|
||||
class UpdateService {
|
||||
UpdateService._();
|
||||
@@ -165,10 +171,15 @@ class UpdateService {
|
||||
await f.parent.create(recursive: true);
|
||||
sink = f.openWrite();
|
||||
int received = 0;
|
||||
final Stopwatch sw = Stopwatch()..start();
|
||||
await for (final List<int> chunk in res) {
|
||||
if (isCancelled?.call() ?? false) throw Exception('已取消');
|
||||
sink.add(chunk);
|
||||
received += chunk.length;
|
||||
// 主动限速(默认 320KB/s):读得过快时按目标速率补齐等待。
|
||||
final int expectedMs = received * 1000 ~/ kUpdateDownloadLimit;
|
||||
final int aheadMs = expectedMs - sw.elapsedMilliseconds;
|
||||
if (aheadMs > 0) await Future<void>.delayed(Duration(milliseconds: aheadMs));
|
||||
onProgress?.call(total > 0 ? received / total : -1, received);
|
||||
}
|
||||
await sink.flush();
|
||||
|
||||
+7
-1
@@ -2,4 +2,10 @@
|
||||
///
|
||||
/// 应用内更新检查用它判断服务器发布的版本是否更新;
|
||||
/// **每次发版必须与 pubspec 同步更新**(见 BUILD-NOTES 的发布流程)。
|
||||
const String kAppVersion = '1.3.3';
|
||||
const String kAppVersion = '1.3.4';
|
||||
|
||||
/// 是否要求授权(License)才能导出。
|
||||
///
|
||||
/// 1.3.4 起**临时冻结授权校验**:桌面版导出不再要求 `.lic` 授权文件,
|
||||
/// 待功能进一步丰富后再恢复(恢复时改为 `true` 并把本注释删掉)。
|
||||
const bool kLicenseRequired = false;
|
||||
|
||||
+1
-1
@@ -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
|
||||
# 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.
|
||||
version: 1.3.3+19
|
||||
version: 1.3.4+20
|
||||
|
||||
environment:
|
||||
sdk: ^3.13.3
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
# V1.3.4 更新内容
|
||||
|
||||
## 泳道加宽(多槽位)——同一泳道可并列放置多个动作
|
||||
- 一个泳道可分 **1–5 个槽位**,动作不再挤在一行重叠:
|
||||
- **条形视图**:泳道内按槽位分成多条子行(带槽位分隔线)
|
||||
- **圆周视图**:同一轨道按槽位分成多条同心子环
|
||||
- **流程图**:同一泳道按槽位分成多条子列,泳道带自动加宽
|
||||
- 槽位之间自动留出间距,保证前置依赖箭头与标签放得下
|
||||
- 加宽入口:**双击条形视图左侧泳道编号** / 右键空白泳道 /
|
||||
左侧栏「N 槽」徽标 → 选择 1–5 槽
|
||||
- 拖拽动作时**同时支持换道 + 换槽位**;加宽不会打散已有动作
|
||||
(全部留在槽 1,由你拖拽分配)
|
||||
|
||||
## 空泳道策略(可设置)
|
||||
- 当一个泳道的动作全部被移走:**保留空泳道**(默认,序号不变)或
|
||||
**自动移除**(序号顺延),在 `F2 文档设置` →「泳道」中切换;
|
||||
- 条形视图(空行)/ 圆周视图(空环)/ 流程图(空列)与左侧栏同步显示。
|
||||
|
||||
## 更新体验
|
||||
- 更新弹窗明确提示:**将直接升级到最新版本**,无需逐版本安装;
|
||||
- 检测到更新后,更新界面固定展示提示:**下载更新过程中请确保屏幕保持长亮、
|
||||
网络持续连接**,避免更新包下载中断;
|
||||
- **下载 / 上传统一限速 320KB/s**:更新包下载(客户端主动限速,TCP 反压让
|
||||
服务端发送同步变慢,多端并发也各自受限)与发布上传(`--limit-rate 320k`)
|
||||
都不会打满服务器带宽。
|
||||
|
||||
## 文档设置与自动保存
|
||||
- 左侧「时序创建和编辑」更名为「**文档设置**」,入口按钮同名
|
||||
(对话框标题同步更名);
|
||||
- **自动保存**(F2 文档设置 →「自动保存」):默认每 **10 分钟**自动保存一次
|
||||
(可选 1 / 5 / 10 / 30 分钟,或关闭);需先手动保存过一次(有文件路径)
|
||||
才生效,自动保存会同步更新 `.bak` 备份。
|
||||
|
||||
## 显示修复与优化
|
||||
- 泳道加宽后左侧动作汇总标题不再被截断:在固定宽度下**持续自动换行**,
|
||||
直到泳道高度不足为止(条形画布左栏与左侧栏列表同步);
|
||||
灰色副标题按**真实行高**紧随标题,空间不足时自动省略,不再被换行文字压住;
|
||||
- 多槽位泳道采用「**槽位紧凑 + 泳道间拉开**」的间隔:条形分子行、圆周分子环,
|
||||
结构一眼可辨;单槽工程保持原有外观不变;
|
||||
- **条形视图**:槽位分隔改为**浅色虚线**;
|
||||
- **圆周视图**:多槽位轨道改为**同色加宽环带 + 槽位虚线分隔**,
|
||||
不同轨道之间维持原有的交替色带;
|
||||
- **流程图智能排开**:同源同层的多条分支连线在空隙内**均匀铺开**
|
||||
(不再挤在同一条线上),同层节点水平重叠时自动推开,动作多时不再堆叠;
|
||||
- 帮助中心与 `docs/HELP.md` 同步更新(泳道 / 工位 / 相位的功能与说明强化)。
|
||||
|
||||
## 授权与关于
|
||||
- **临时冻结授权**:1.3.4 起桌面版导出 SVG / PNG / drawio **无需 `.lic`**;
|
||||
关于页授权状态显示「**开放授权版本**」(保留本机 MAC 显示,
|
||||
授权指南等恢复授权后再补回);
|
||||
- 关于页更新:版权改为「Copyright © 2026 EDC(Easy Design Collection)呆头鹅」;
|
||||
新增「**开发者与交流群**」(开发者邮箱 liuyu65@126.com、微信 online-goose);
|
||||
产品简介更新为三视图 / 泳道加宽 / drawio 导出等新能力。
|
||||
+45
-13
@@ -10,7 +10,8 @@
|
||||
# - 安卓 APK:默认取 release\sequence_diagram_android_v<版本>_release.apk;
|
||||
# - Windows 绿色版:默认把 dist\ 打包为 zip 后上传(客户端下载后原地覆盖);
|
||||
# - 安装包作为 Release 附件保存,不进入 git 历史,仓库保持精简;
|
||||
# - 发布完成后自动清理历史附件:只保留最近 2 个版本的安装包
|
||||
# - 发布幂等:v<版本> 已存在(如上次上传中断)时复用它并更新说明;
|
||||
# - 发布完成后自动清理历史附件:只保留「最新 1 个版本」的安装包
|
||||
# (Release 记录与更新说明保留,仅删除更早版本的附件,释放服务器空间)。
|
||||
# ============================================================
|
||||
param(
|
||||
@@ -21,7 +22,10 @@ param(
|
||||
[string]$Server = "http://124.220.63.9:30000",
|
||||
[string]$Owner = "admin",
|
||||
[string]$Repo = "Sequence-Diagram",
|
||||
[string]$Auth = "liuyu65@126.com:ds3317210"
|
||||
[string]$Auth = "liuyu65@126.com:ds3317210",
|
||||
# 上传限速(curl --limit-rate):服务器带宽很小(5Mbps),
|
||||
# 限速上传避免打满带宽把服务器压垮(默认 320KB/s ≈ 2.6Mbps)。
|
||||
[string]$UploadLimit = "320k"
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
@@ -52,7 +56,23 @@ if (!(Test-Path $WindowsZipPath) -or (Get-Item $WindowsZipPath).Length -lt 10485
|
||||
if (!(Test-Path $NotesFile)) { throw "找不到更新说明文件:$NotesFile" }
|
||||
$notes = [System.IO.File]::ReadAllText($NotesFile, [System.Text.Encoding]::UTF8)
|
||||
|
||||
# ---- 2) 创建 Release(正文 = 更新说明) ----
|
||||
# ---- 2) 创建(或复用)Release(正文 = 更新说明) ----
|
||||
# 幂等:若 v<版本> 已存在(如上次发布上传中断),复用该 Release 并更新说明。
|
||||
$tmp = Join-Path $env:TEMP "seq_release.json"
|
||||
$tagFile = Join-Path $env:TEMP "seq_release_tag.json"
|
||||
curl.exe -s --max-time 300 -o $tagFile "$Server/api/v1/repos/$Owner/$Repo/releases/tags/v$Version" | Out-Null
|
||||
$rel = $null
|
||||
try {
|
||||
$rel = [System.IO.File]::ReadAllText($tagFile, [System.Text.Encoding]::UTF8) | ConvertFrom-Json
|
||||
} catch {
|
||||
$rel = $null
|
||||
}
|
||||
if ($rel -and $rel.id) {
|
||||
Write-Host "Release v$Version 已存在(id=$($rel.id)),复用并更新说明..."
|
||||
$payload = @{ body = $notes } | ConvertTo-Json -Compress
|
||||
[System.IO.File]::WriteAllText($tmp, $payload, (New-Object System.Text.UTF8Encoding($false)))
|
||||
curl.exe -s --max-time 300 -o NUL -X PATCH -H "Content-Type: application/json" --data-binary "@$tmp" -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($rel.id)" | Out-Null
|
||||
} else {
|
||||
$payload = @{
|
||||
tag_name = "v$Version"
|
||||
name = "v$Version"
|
||||
@@ -60,19 +80,31 @@ $payload = @{
|
||||
draft = $false
|
||||
prerelease = $false
|
||||
} | ConvertTo-Json -Compress
|
||||
$tmp = Join-Path $env:TEMP "seq_release.json"
|
||||
[System.IO.File]::WriteAllText($tmp, $payload, (New-Object System.Text.UTF8Encoding($false)))
|
||||
Write-Host "创建 Release v$Version ..."
|
||||
$resp = curl.exe -s -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
|
||||
if (-not $rel.id) { throw "创建 Release 失败:$resp" }
|
||||
}
|
||||
Write-Host "Release id = $($rel.id)"
|
||||
|
||||
# ---- 3) 上传附件 ----
|
||||
# 同名附件先删后传:支持上传中断后重跑(避免重名重复)。
|
||||
# 注意:大文件上传不设 --max-time(慢链路下需要数分钟)。
|
||||
function Upload-Asset([string]$path) {
|
||||
$name = Split-Path $path -Leaf
|
||||
Write-Host "上传附件:$name ..."
|
||||
$r = curl.exe -s -X POST -F "attachment=@$path" -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($rel.id)/assets?name=$name"
|
||||
$curFile = Join-Path $env:TEMP "seq_release_cur.json"
|
||||
curl.exe -s --max-time 300 -o $curFile "$Server/api/v1/repos/$Owner/$Repo/releases/tags/v$Version" | Out-Null
|
||||
try {
|
||||
$cur = [System.IO.File]::ReadAllText($curFile, [System.Text.Encoding]::UTF8) | ConvertFrom-Json
|
||||
foreach ($a in $cur.assets) {
|
||||
if ($a.name -eq $name) {
|
||||
curl.exe -s --max-time 300 -o NUL -X DELETE -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($rel.id)/assets/$($a.id)" | Out-Null
|
||||
}
|
||||
}
|
||||
} catch {}
|
||||
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"
|
||||
$asset = $r | ConvertFrom-Json
|
||||
if (-not $asset.name) { throw "上传失败:$r" }
|
||||
Write-Host " 完成:$($asset.browser_download_url)"
|
||||
@@ -80,23 +112,23 @@ function Upload-Asset([string]$path) {
|
||||
Upload-Asset $ApkPath
|
||||
Upload-Asset $WindowsZipPath
|
||||
|
||||
# ---- 4) 清理历史版本附件:只保留最近 2 个版本的安装包 ----
|
||||
# ---- 4) 清理历史版本附件:只保留最新 1 个版本的安装包 ----
|
||||
# 客户端更新只使用「最新版本」的附件,更早版本的安装包可安全删除以释放空间;
|
||||
# Release 记录与更新说明保留,历史版本页面仍可查阅。
|
||||
# 该步骤失败不影响本次发布(仅打印警告)。
|
||||
$keepVersions = 2
|
||||
$keepVersions = 1
|
||||
try {
|
||||
Write-Host ""
|
||||
Write-Host "清理历史版本附件(只保留最近 $keepVersions 个版本)..."
|
||||
Write-Host "清理历史版本附件(只保留最新 $keepVersions 个版本)..."
|
||||
$listFile = Join-Path $env:TEMP "seq_releases_list.json"
|
||||
curl.exe -s -o $listFile "$Server/api/v1/repos/$Owner/$Repo/releases?limit=50" | Out-Null
|
||||
curl.exe -s --max-time 300 -o $listFile "$Server/api/v1/repos/$Owner/$Repo/releases?limit=50" | Out-Null
|
||||
$all = [System.IO.File]::ReadAllText($listFile, [System.Text.Encoding]::UTF8) | ConvertFrom-Json
|
||||
$ordered = @($all | Sort-Object -Property created_at -Descending)
|
||||
$freed = 0
|
||||
for ($i = $keepVersions; $i -lt $ordered.Count; $i++) {
|
||||
$r = $ordered[$i]
|
||||
foreach ($a in $r.assets) {
|
||||
$code = curl.exe -s -o NUL -w "%{http_code}" -X DELETE -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($r.id)/assets/$($a.id)"
|
||||
$code = curl.exe -s --max-time 300 -o NUL -w "%{http_code}" -X DELETE -u $Auth "$Server/api/v1/repos/$Owner/$Repo/releases/$($r.id)/assets/$($a.id)"
|
||||
if ($code -eq "204") {
|
||||
$freed += $a.size
|
||||
Write-Host " 已清理 $($r.tag_name) / $($a.name)"
|
||||
@@ -108,7 +140,7 @@ try {
|
||||
if ($freed -gt 0) {
|
||||
Write-Host " 共释放 $([math]::Round($freed / 1MB, 1)) MB"
|
||||
} else {
|
||||
Write-Host " 无需清理(仅最近 $keepVersions 个版本带有附件)"
|
||||
Write-Host " 无需清理(仅最新 $keepVersions 个版本带有附件)"
|
||||
}
|
||||
} catch {
|
||||
Write-Host " [warn] 历史附件清理失败(不影响本次发布):$_"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import 'dart:ui' show Rect, Size;
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:sequence_diagram/layout/flow_layout.dart';
|
||||
import 'package:sequence_diagram/layout/layout.dart';
|
||||
import 'package:sequence_diagram/model/models.dart';
|
||||
import 'package:sequence_diagram/state/app_controller.dart';
|
||||
|
||||
@@ -37,4 +41,102 @@ void main() {
|
||||
expect(c.project.stationById('ST9')?.name, '工位 9');
|
||||
});
|
||||
});
|
||||
|
||||
group('空泳道策略', () {
|
||||
test('保留空泳道:动作移走后泳道仍在,关闭后自动移除', () {
|
||||
final AppController c = AppController(project: Project.demo());
|
||||
// 演示工程中 A4 独占 L3(layer 2):移走后该泳道变为空泳道。
|
||||
c.moveActionLane('A4', 1);
|
||||
expect(c.project.renderLanes, <int>[0, 1, 2]);
|
||||
expect(c.project.renderLaneCount, 3);
|
||||
// 三种视图的布局都包含保留的空泳道。
|
||||
expect(BarLayout(c.project, const Size(1280, 800)).lanes, <int>[0, 1, 2]);
|
||||
expect(CircularLayout(c.project, const Size(1280, 800)).lanes, <int>[0, 1, 2]);
|
||||
|
||||
// 关闭策略:空泳道移除、序号顺延。
|
||||
c.setKeepEmptyLanes(false);
|
||||
expect(c.project.renderLanes, <int>[0, 1]);
|
||||
|
||||
// 重新开启:以当前使用中的泳道为保底(不会把已收缩的泳道补回来)。
|
||||
c.setKeepEmptyLanes(true);
|
||||
expect(c.project.renderLanes, <int>[0, 1]);
|
||||
|
||||
// 策略字段随 JSON 往返保存。
|
||||
final Project decoded = Project.decode(c.project.encode());
|
||||
expect(decoded.keepEmptyLanes, isTrue);
|
||||
expect(decoded.minLaneCount, 2);
|
||||
});
|
||||
|
||||
test('关闭策略时动作移走立即收缩', () {
|
||||
final AppController c = AppController(project: Project.demo());
|
||||
c.setKeepEmptyLanes(false);
|
||||
c.moveActionLane('A4', 1);
|
||||
expect(c.project.renderLanes, <int>[0, 1]);
|
||||
});
|
||||
});
|
||||
|
||||
group('泳道槽位(加宽)', () {
|
||||
test('加宽后动作按槽位分行,几何与反查一致,配置随 JSON 往返', () {
|
||||
final AppController c = AppController(project: Project.demo());
|
||||
// L1(layer 0)加宽为 2 槽:加宽本身不散乱动作(仍全部在槽 1),
|
||||
// 用户再把 A2 拖到槽 2。
|
||||
c.setLaneSlots(0, 2);
|
||||
expect(c.project.slotsOf(0), 2);
|
||||
c.moveActionTo('A2', 0, 1);
|
||||
final BarLayout layout = BarLayout(c.project, const Size(1280, 800));
|
||||
final Action a1 = c.project.actionById('A1')!;
|
||||
final Action a2 = c.project.actionById('A2')!;
|
||||
expect(layout.slotOf(a1), 0);
|
||||
expect(layout.slotOf(a2), 1);
|
||||
final Rect r1 = layout.rectFor(a1);
|
||||
final Rect r2 = layout.rectFor(a2);
|
||||
expect((r1.top - r2.top).abs(), greaterThan(10), reason: '不同槽位应位于不同子行');
|
||||
// 纵坐标反查(泳道, 槽位)。
|
||||
expect(layout.laneSlotAt(r1.center.dy), (0, 0));
|
||||
expect(layout.laneSlotAt(r2.center.dy), (0, 1));
|
||||
// 圆周视图:同一轨道的不同槽位对应不同子环半径。
|
||||
final CircularLayout cl = CircularLayout(c.project, const Size(1280, 800));
|
||||
expect(cl.subRingCount, greaterThan(0));
|
||||
expect(cl.radiusFor(0, 1) - cl.radiusFor(0, 0), closeTo(cl.pitch, 0.001));
|
||||
expect(cl.laneSlotAtRadius(cl.radiusFor(0, 1)), (0, 1));
|
||||
// 流程图:同一泳道的不同槽位对应不同列中心。
|
||||
final FlowLayout fl = FlowLayout(c.project);
|
||||
expect((fl.nodeById('A1')!.rect.center.dx - fl.nodeById('A2')!.rect.center.dx).abs(),
|
||||
greaterThan(50));
|
||||
expect(fl.laneWidth(0), greaterThan(FlowLayout.nodeW));
|
||||
// JSON 往返保留槽位配置。
|
||||
final Project decoded = Project.decode(c.project.encode());
|
||||
expect(decoded.slotsOf(0), 2);
|
||||
});
|
||||
|
||||
test('跨泳道移动可指定槽位;缩窄时槽位被钳制且动作不丢失', () {
|
||||
final AppController c = AppController(project: Project.demo());
|
||||
// 把 A4 移到 L2(layer 1)槽 1。
|
||||
c.moveActionTo('A4', 1, 0);
|
||||
expect(c.project.actionById('A4')!.layer, 1);
|
||||
expect(c.project.actionById('A4')!.row, 0);
|
||||
// 加宽 L2 为 2 槽 → 3 槽,再缩回 2 槽:A4 的槽位在布局中钳制到末槽。
|
||||
c.setLaneSlots(1, 3);
|
||||
c.moveActionTo('A4', 1, 2);
|
||||
c.setLaneSlots(1, 2);
|
||||
final BarLayout layout = BarLayout(c.project, const Size(1280, 800));
|
||||
expect(layout.slotOf(c.project.actionById('A4')!), 1);
|
||||
expect(c.project.actionById('A4')!.row, 2, reason: '数据保留原值,仅布局钳制');
|
||||
});
|
||||
});
|
||||
|
||||
group('自动保存设置', () {
|
||||
test('默认启用且 10 分钟一次;启停与间隔随 JSON 往返', () {
|
||||
final AppController c = AppController(project: Project.demo());
|
||||
expect(c.project.autoSaveEnabled, isTrue);
|
||||
expect(c.project.autoSaveMinutes, 10);
|
||||
c.setAutoSave(minutes: 5);
|
||||
expect(c.project.autoSaveMinutes, 5);
|
||||
c.setAutoSave(enabled: false);
|
||||
expect(c.project.autoSaveEnabled, isFalse);
|
||||
final Project decoded = Project.decode(c.project.encode());
|
||||
expect(decoded.autoSaveEnabled, isFalse);
|
||||
expect(decoded.autoSaveMinutes, 5);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
// 平板版演示截图生成:把整个应用外壳在 1280×800(平板横屏基准)下渲染为 PNG。
|
||||
// 运行方式:flutter test --update-goldens test\tablet_screenshots_test.dart
|
||||
// 输出:demo/tablet-*.png
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/material.dart' hide Action;
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:sequence_diagram/model/models.dart';
|
||||
import 'package:sequence_diagram/state/app_controller.dart';
|
||||
@@ -88,5 +88,45 @@ void main() {
|
||||
await shot('../demo/tablet-circular-dark.png');
|
||||
c.setViewMode(ViewMode.flow);
|
||||
await shot('../demo/tablet-flow-dark.png');
|
||||
|
||||
// ---- 1.3.4 泳道加宽(多槽位)演示(浅色)----
|
||||
// L1 加宽为 2 槽,并把「定位夹紧」放到槽 2;三种视图各出一张对照图。
|
||||
c.toggleTheme();
|
||||
await tester.pumpWidget(shell(Tokens.light));
|
||||
await tester.pump(const Duration(milliseconds: 400));
|
||||
c.setLaneSlots(0, 2);
|
||||
c.moveActionTo('A2', 0, 1);
|
||||
c.select(null);
|
||||
c.setViewMode(ViewMode.bar);
|
||||
await shot('../demo/tablet-bar-slots-light.png');
|
||||
c.setViewMode(ViewMode.circular);
|
||||
await shot('../demo/tablet-circular-slots-light.png');
|
||||
c.setViewMode(ViewMode.flow);
|
||||
await shot('../demo/tablet-flow-slots-light.png');
|
||||
|
||||
// ---- 拥挤场景复核:单泳道 5 槽 + 10 个动作(标题持续换行、灰字不被压住)----
|
||||
final Project base = demoTiming();
|
||||
final List<Action> many = <Action>[...base.actions];
|
||||
for (int i = 0; i < 8; i++) {
|
||||
many.add(Action(
|
||||
id: 'X$i',
|
||||
name: '动作 ${i + 6}',
|
||||
stationId: 'ST1',
|
||||
driver: '气缸 Y${i + 1}',
|
||||
startAngle: 5.0 + i * 12.0,
|
||||
durationAngle: 8,
|
||||
layer: 0,
|
||||
row: i % 5,
|
||||
color: kActionPalette[i % kActionPalette.length],
|
||||
));
|
||||
}
|
||||
c.loadProject(base.copyWith(
|
||||
actions: many,
|
||||
laneSlots: <int, int>{0: 5},
|
||||
autoSaveEnabled: false,
|
||||
));
|
||||
c.select(null);
|
||||
c.setViewMode(ViewMode.bar);
|
||||
await shot('../demo/tablet-bar-crowded-light.png');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user