feat: 原创「环序」标志;双视图与侧栏优化;工位管理;帮助完善
- 原创应用标志「环序/Cycle-Step」:tools/gen-icon.py 重写 + 工具栏 Logo 同源,小尺寸简化版 - 条形时序视图:标题/副标题精简、双刻度值置于分区与刻度线之间、时间默认内嵌、依赖线箭头收窄、同泳道箭头接色块外侧、图注自动避让 - 圆周时序视图:去掉色块描边、环宽与间隙优化、度数外侧标时间、方向箭头外移;固定顺时针(移除逆时针) - 左侧栏:编辑工位/编辑相位分区入口;双击画布色块或动作行进入编辑;至少保留一个动作/泳道 - 右侧栏:移除重复的编辑操作、导出与单位卡片;文件浏览器新增「桌面」快捷入口 - AI 对话框:字号优化并新增「编辑示例」;节拍统计移除无依据的预估产能 - 文档:README 与 docs/HELP.md 全面更新;dist 同步重建
This commit is contained in:
@@ -28,8 +28,11 @@ scripts\build.bat # 发布版(构建并复制到浅目录 dist
|
|||||||
- 条形节拍(甘特 / 流程图)+ 圆周节拍(同心圆)双视图,**共享同一份数据**,顶部一键切换
|
- 条形节拍(甘特 / 流程图)+ 圆周节拍(同心圆)双视图,**共享同一份数据**,顶部一键切换
|
||||||
- FS 严格顺序(绿色实线)/ SS 并行重叠(琥珀虚线)依赖箭头 + ★ 关键路径高亮
|
- FS 严格顺序(绿色实线)/ SS 并行重叠(琥珀虚线)依赖箭头 + ★ 关键路径高亮
|
||||||
- 拖拽编辑相位、拖端点改持续角、`Shift`+拖拽改层、双击空白新建动作(默认最外层)
|
- 拖拽编辑相位、拖端点改持续角、`Shift`+拖拽改层、双击空白新建动作(默认最外层)
|
||||||
- 右侧属性面板:角度滑杆、依赖增删、复制 / 对齐 / 改层 / 删除
|
- **双击画布色块(条形 / 圆弧)或左侧动作行**直接进入动作编辑;编辑工具条浮于画布,功能不重复
|
||||||
|
- **工位管理**:任意增删工位、改名称与颜色、调整顺序;删除工位后其动作自动改挂到第一个工位
|
||||||
|
- 右侧属性面板:动作属性、角度滑杆、依赖增删;工艺单位与精度
|
||||||
- 工艺参数面板(`F2`):`ms/s/min`、`°/%`、显示精度、换算表、吸附与网格
|
- 工艺参数面板(`F2`):`ms/s/min`、`°/%`、显示精度、换算表、吸附与网格
|
||||||
|
- 节拍统计(循环周期 / 动作数 / 关键路径 / 最大并行度 / 相位覆盖率 / 瓶颈工位),只展示可由项目数据推导的指标
|
||||||
- 深 / 浅双主题(`F3`);`Ctrl+滚轮` 缩放、`Ctrl+Z/Y` 撤销重做
|
- 深 / 浅双主题(`F3`);`Ctrl+滚轮` 缩放、`Ctrl+Z/Y` 撤销重做
|
||||||
- **左右侧栏可隐藏 / 显示,并可钉住**:钉住时固定占位,取消钉住后悬浮、鼠标移开自动收起
|
- **左右侧栏可隐藏 / 显示,并可钉住**:钉住时固定占位,取消钉住后悬浮、鼠标移开自动收起
|
||||||
- 画布浮层:标题、图例、选中动作卡、节拍统计、编辑工具、实时预览(按窗口宽度自适应取舍)
|
- 画布浮层:标题、图例、选中动作卡、节拍统计、编辑工具、实时预览(按窗口宽度自适应取舍)
|
||||||
@@ -37,7 +40,7 @@ scripts\build.bat # 发布版(构建并复制到浅目录 dist
|
|||||||
- **导出 PNG**:按 2 倍像素比导出当前画布
|
- **导出 PNG**:按 2 倍像素比导出当前画布
|
||||||
- **自动定时快照 + 启动崩溃恢复 + `.bak` 备份**(异常退出后可恢复)
|
- **自动定时快照 + 启动崩溃恢复 + `.bak` 备份**(异常退出后可恢复)
|
||||||
- 应用内帮助中心(`F1`)与 [`docs/HELP.md`](docs/HELP.md)
|
- 应用内帮助中心(`F1`)与 [`docs/HELP.md`](docs/HELP.md)
|
||||||
- 时钟 / 周期盘图标(`tools/gen-icon.py` 生成)
|
- 原创「环序 / Cycle-Step」应用标志(`tools/gen-icon.py` 生成,与工具栏 Logo 同源)
|
||||||
|
|
||||||
> 若本机装有绿盾等透明加密软件,构建前请阅读 [`BUILD-NOTES.md`](BUILD-NOTES.md)(含规避方案)。
|
> 若本机装有绿盾等透明加密软件,构建前请阅读 [`BUILD-NOTES.md`](BUILD-NOTES.md)(含规避方案)。
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 15 KiB |
+196
-83
@@ -1,40 +1,98 @@
|
|||||||
# 时序图设计器 · 使用帮助(按任务组织)
|
# 时序图设计器 · 使用帮助
|
||||||
|
|
||||||
> 面向 PLC 流程节拍 / 相位角设计的桌面软件(Flutter Desktop)。
|
> 面向 **PLC 流程节拍 / 相位角设计** 的桌面软件(Flutter Desktop)。
|
||||||
> 应用内按 **F1** 可随时打开同一份帮助。
|
> 应用内按 **F1**(或点顶部工具栏最右侧的 **?**)可随时打开同一份帮助。
|
||||||
>
|
>
|
||||||
> 本文按「**我要完成什么**」来组织:先找到你的目标,再照着步骤做。
|
> 本文按「**我要完成什么**」组织:先找到你的目标,再照着步骤做。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 目录
|
## 目录
|
||||||
|
|
||||||
|
- [0. 界面总览](#0-界面总览)
|
||||||
- [A. 开始一个方案](#a-开始一个方案)
|
- [A. 开始一个方案](#a-开始一个方案)
|
||||||
- [B. 动作:增、删、改、复制、对齐](#b-动作增删改复制对齐)
|
- [B. 动作:增、删、改、复制、对齐](#b-动作增删改复制对齐)
|
||||||
- [C. 时间与相位:循环长度、起止角、时长](#c-时间与相位循环长度起止角时长)
|
- [C. 时间与相位:循环长度、起止角、时长](#c-时间与相位循环长度起止角时长)
|
||||||
|
- [C2. 泳道 / 轨道:一个执行器可放多个动作](#c2-泳道--轨道一个执行器可放多个动作)
|
||||||
- [D. 依赖关系:先后顺序与并行(多输入 / 多输出)](#d-依赖关系先后顺序与并行多输入--多输出)
|
- [D. 依赖关系:先后顺序与并行(多输入 / 多输出)](#d-依赖关系先后顺序与并行多输入--多输出)
|
||||||
- [E. 相位分区:编辑名称、起止角、数量](#e-相位分区编辑名称起止角数量)
|
- [E. 工位:增删改与排序](#e-工位增删改与排序)
|
||||||
- [F. 视图:条形 / 圆周、缩放、适应视图、显示选项](#f-视图条形--圆周缩放适应视图显示选项)
|
- [F. 相位分区:编辑名称、起止角、数量](#f-相位分区编辑名称起止角数量)
|
||||||
- [G. 界面:隐藏 / 钉住侧栏,看统计](#g-界面隐藏--钉住侧栏看统计)
|
- [G. 视图:条形 / 圆周、缩放、适应视图、显示选项](#g-视图条形--圆周缩放适应视图显示选项)
|
||||||
- [H. AI 生成:用自然语言直接生成时序图](#h-ai-生成用自然语言直接生成时序图)
|
- [H. 界面:侧栏、统计、帮助入口](#h-界面侧栏统计帮助入口)
|
||||||
- [I. 导出:SVG / PNG](#i-导出svg--png)
|
- [I. AI 生成:用自然语言直接生成时序图](#i-ai-生成用自然语言直接生成时序图)
|
||||||
- [J. 保存、打开、崩溃恢复](#j-保存打开崩溃恢复)
|
- [J. 导出:SVG / PNG](#j-导出svg--png)
|
||||||
- [K. 单位与精度](#k-单位与精度)
|
- [K. 保存、打开、崩溃恢复](#k-保存打开崩溃恢复)
|
||||||
- [附录:快捷键与文件格式](#附录快捷键与文件格式)
|
- [L. 单位与精度](#l-单位与精度)
|
||||||
|
- [M. 多选与批量对齐](#m-多选与批量对齐)
|
||||||
|
- [N. 动作编辑对话框:角度 ↔ 时间](#n-动作编辑对话框角度--时间)
|
||||||
|
- [附录:快捷键、文件格式、构建](#附录快捷键文件格式构建)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 0. 界面总览
|
||||||
|
|
||||||
|
窗口从上到下分为 **顶部工具栏 / 中部画布 / 底部状态栏**,画布两侧是可隐藏、可钉住的**左、右侧栏**。
|
||||||
|
|
||||||
|
### 顶部工具栏(左 → 右)
|
||||||
|
|
||||||
|
| 位置 | 元素 | 说明 |
|
||||||
|
| --- | --- | --- |
|
||||||
|
| 左 | 应用标志 + 「时序图设计器」 | 原创「环序」标志 |
|
||||||
|
| 左 | 新建 / 打开 / 保存 | **纯图标**(`Ctrl+N / O / S`) |
|
||||||
|
| 左 | 撤销 / 重做 | **纯图标**,不可用时自动置灰(`Ctrl+Z / Y`) |
|
||||||
|
| 左 | **AI 生成** | 打开自然语言生成对话框 |
|
||||||
|
| 左 | 条形节拍 / 圆周节拍 | 视图切换(两种视图共享同一份数据) |
|
||||||
|
| 右 | 导出 SVG / 导出 PNG | 唯一的导出入口 |
|
||||||
|
| 右 | 缩放控件 | `− 100% +` |
|
||||||
|
| 右 | 适应视图 | **纯图标**(自动缩放并居中到完整可见) |
|
||||||
|
| 右 | 单位下拉 | `ms / s / min` 快速切换 |
|
||||||
|
| 右 | 左右侧栏开关 | 显示 / 隐藏两侧栏 |
|
||||||
|
| 右 | **?** | 帮助中心(等价 `F1`) |
|
||||||
|
| 右 | ☀ / ☾ | 深 / 浅主题切换(`F3`) |
|
||||||
|
|
||||||
|
> 窗口较窄时工具栏自动进入**紧凑布局**;极窄时横向滚动,保证所有按钮都能点到。
|
||||||
|
|
||||||
|
### 左侧栏(自上而下)
|
||||||
|
|
||||||
|
1. **时序创建和编辑** —— 单行入口「编辑时序与节拍参数」,打开工艺参数对话框(项目名、循环时长、单位精度、相位分区等)。
|
||||||
|
2. **动作和执行编辑** —— 「新建 / 删除」按钮 + 动作 / 泳道列表;列表下方是「**编辑工位**」与「**编辑相位分区**」两个管理入口。
|
||||||
|
3. **视图模式** —— 条形节拍 / 圆周节拍。
|
||||||
|
4. **显示选项** —— 双刻度、依赖箭头、跨循环标记、分区标注、圆环背景、层标注等开关。
|
||||||
|
5. **工位负载 / 相位占用** —— 每个工位的累计角度与占比进度条。
|
||||||
|
6. **操作提示** —— 常用拖拽与快捷键速查。
|
||||||
|
|
||||||
|
### 右侧栏(自上而下)
|
||||||
|
|
||||||
|
1. **属性 · 选中动作** —— 编号、名称、工位 / 驱动、层号、跨圈标记。
|
||||||
|
2. **属性字段** —— 开始时刻、结束时刻、持续时间、循环归属、顺序约束、相位归属(按当前单位显示)。
|
||||||
|
3. **角度编辑**(圆周视图)—— 起始角 / 持续角滑杆。
|
||||||
|
4. **工艺单位与精度** —— 时间 / 相位单位、换算表。
|
||||||
|
5. **前置依赖 · 输入** 与 **输出依赖 · 结果** —— 多输入 / 多输出,逐条可删。
|
||||||
|
6. **帮助 · 快捷键** —— 速查卡片。
|
||||||
|
|
||||||
|
> 编辑动作、复制、删除、对齐等操作**只在画布上的「编辑工具」与圆周视图浮动工具条**提供,右侧栏不再重复放置,避免功能冗余。
|
||||||
|
> 导出也只在顶部工具栏提供。
|
||||||
|
|
||||||
|
### 画布浮层
|
||||||
|
|
||||||
|
- **顶部标题**:条形视图显示「条形时序视图」,圆周视图显示「圆周时序视图」,下方一行说明箭头含义。
|
||||||
|
- **左下角**:条形视图显示「节拍统计」按钮与「编辑工具」条。
|
||||||
|
- **右下角**:实时预览卡(条形 ↔ 圆周联动缩略)。
|
||||||
|
- **圆周视图右侧**:纵向浮动工具条(添加 / 编辑 / 复制 / 删除 / 层± / 对齐)。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## A. 开始一个方案
|
## A. 开始一个方案
|
||||||
|
|
||||||
**我要新建一个空白方案**
|
**我要新建一个空白方案**
|
||||||
1. 顶部「**新建**」(或 `Ctrl+N`)→ 生成含 2 个动作(动作 1 / 动作 2)的空白节拍。
|
1. 顶部「**新建**」图标(或 `Ctrl+N`)→ 生成含 2 个工位、2 个动作(动作 1 / 动作 2)的空白节拍。
|
||||||
2. 左侧「项目」卡片里点名称即可在 `F2` 工艺参数中重命名。
|
2. 左侧「时序创建和编辑」→「编辑时序与节拍参数」里可修改**项目名**与**循环时长**。
|
||||||
|
|
||||||
**我要打开已有方案**
|
**我要打开已有方案**
|
||||||
1. 顶部「**打开**」(或 `Ctrl+O`)→ 应用内文件浏览器选择 `.seq.json`。
|
1. 顶部「**打开**」图标(或 `Ctrl+O`)→ 应用内文件浏览器选择 `.seq.json`。
|
||||||
|
|
||||||
**我要一个示例先看看**
|
**我要先看看示例**
|
||||||
- 首次启动会载入 2 个动作的示例节拍,可直接在此基础上修改。
|
- 首次启动会载入示例节拍,可直接在此基础上修改。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -42,39 +100,41 @@
|
|||||||
|
|
||||||
**我要新增动作**
|
**我要新增动作**
|
||||||
- **双击画布空白处**:在点击的相位角处新增,默认放在**最外层**;或
|
- **双击画布空白处**:在点击的相位角处新增,默认放在**最外层**;或
|
||||||
- 左侧「动作 / 工位泳道」右上角「**新建**」:在 0° 处新增。
|
- 左侧「动作和执行编辑」右上角「**新建**」:在 0° 处新增。
|
||||||
|
|
||||||
|
**我要修改动作(名称 / 工位 / 驱动 / 颜色 / 角度)**
|
||||||
|
- **双击画布上的色块**(条形块或圆周圆弧)→ 打开动作编辑对话框;或
|
||||||
|
- **双击左侧动作行** → 打开同一个对话框;或
|
||||||
|
- 点左侧该行右侧的**铅笔图标**;或
|
||||||
|
- 选中动作 → 右侧栏「属性 · 选中动作」中可直接改字段。
|
||||||
|
|
||||||
**我要删除动作**
|
**我要删除动作**
|
||||||
- 选中动作后,左侧列表标题右侧的「**删除**」(未选中时按钮为灰);或
|
- 选中后:左侧标题栏「**删除**」/ 左侧行内选中时出现的删除图标 / `Delete` 键 / 右键菜单 → 删除动作。
|
||||||
- 选中后点左侧该行动态出现的删除图标;或
|
- **保护规则**:当项目只剩 **1 个动作 / 泳道** 时,删除入口会禁用并提示,避免把方案删空。
|
||||||
- 右侧「编辑操作」里的「删除」;或
|
|
||||||
- 选中后按 `Delete`;或
|
|
||||||
- 右键动作 → 删除动作。
|
|
||||||
|
|
||||||
**我要修改动作属性(名称 / 工位 / 驱动 / 颜色)**
|
|
||||||
- 选中动作 → 右侧「编辑」;或点左侧该行右侧的编辑图标;或顶部「编辑」。
|
|
||||||
|
|
||||||
**我要复制 / 对齐**
|
**我要复制 / 对齐**
|
||||||
- 右侧「编辑操作」→「复制」/「对齐相位」;圆周视图还有「新增外层 / 重排合并层」。
|
- 画布左下角「**编辑工具**」→「复制」/「对齐」;圆周视图右侧浮动工具条有同款按钮。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## C. 时间与相位:循环长度、起止角、时长
|
## C. 时间与相位:循环长度、起止角、时长
|
||||||
|
|
||||||
**我要修改循环长度(时间轴长度)**
|
**我要修改循环长度(时间轴长度)**
|
||||||
- 方式一:左侧「项目」卡片里点击「**循环 2.400 s = 360° = 100%**」→ 打开工艺参数 →「循环与相位」→ 修改「循环时长」→「应用」。
|
- 左侧「时序创建和编辑」→「**编辑时序与节拍参数**」→「循环与相位」→ 循环时长 → 应用;或
|
||||||
- 方式二:按 `F2` →「循环与相位」→ 修改「循环时长」。
|
- 按 `F2` 打开同一对话框。
|
||||||
|
|
||||||
> 时间只存于 `cycle.durationMs`(毫秒);角度 = `ms / cycleMs × 360`,改循环时长不会丢失角度精度。
|
> 时间只存于 `cycle.durationMs`(毫秒);角度 = `ms / cycleMs × 360`。改循环时长不会丢失角度精度。
|
||||||
|
|
||||||
**我要调整某个动作的相位 / 时长**
|
**我要调整某个动作的相位 / 时长**
|
||||||
- 拖动动作块 → 平移相位(自动吸附);
|
- 拖动动作块 → 平移相位(自动吸附);
|
||||||
- 拖动条形块**右端** → 改持续角(左端固定);
|
- 拖动条形块**右端** → 改持续角(左端固定);拖**左端** → 改起始角(右端固定);
|
||||||
- 圆周视图 **Shift + 拖拽** → 径向改层;
|
- 圆周视图拖**弧的两端** → 改起止角;拖弧身 → 整体旋转;
|
||||||
- 右侧属性面板的「起始角 / 持续角」滑杆可精确调。
|
- 右侧属性面板的「起始角 / 持续角」滑杆可精确调。
|
||||||
|
|
||||||
**我要让动作跨循环**
|
**我要让动作跨循环**
|
||||||
- 使 `起始角 + 持续角 > 360°` 即可;条形/圆周会自动拆分,尾段以半透明虚线渲染。
|
- 使 `起始角 + 持续角 > 360°` 即可;条形 / 圆周会自动拆分,尾段以半透明渲染。
|
||||||
|
|
||||||
|
> 圆周视图固定为**顺时针**(12 点钟为 0°),不提供逆时针切换。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -83,9 +143,9 @@
|
|||||||
**泳道(条形)与轨道(圆周)对应同一个物理执行器**,一条泳道 / 轨道可以容纳**多个互不重叠**的动作(类似音频轨道):
|
**泳道(条形)与轨道(圆周)对应同一个物理执行器**,一条泳道 / 轨道可以容纳**多个互不重叠**的动作(类似音频轨道):
|
||||||
|
|
||||||
- 拖拽动作**上下移动**(条形视图)或 **Shift + 径向拖拽**(圆周视图)即可换道;
|
- 拖拽动作**上下移动**(条形视图)或 **Shift + 径向拖拽**(圆周视图)即可换道;
|
||||||
- 只要该时间段目标泳道里没有别的动作,就能放上去;若时间重叠会被拒绝并提示;
|
- 只要该时间段目标泳道里没有别的动作就能放上去;若时间重叠会被拒绝并提示;
|
||||||
- 泳道标题会把该道内的多个动作**合并显示**(如 `A1 上料 / A2 定位夹紧`),最多两行,用 `/` 分隔;
|
- 泳道标题会把该道内的多个动作**合并显示**(如 `A1 上料 / A2 定位夹紧`),最多两行,用 `/` 分隔;
|
||||||
- 左侧列表也按泳道分组,单动作泳道显示为普通行,多动作泳道显示合并标题。
|
- 左侧列表也按泳道分组:单动作泳道显示为普通行,多动作泳道显示合并标题。
|
||||||
|
|
||||||
> 含义:一条泳道 = 一个气缸 / 伺服轴等执行器;一个色块 = 该执行器上的一个动作。
|
> 含义:一条泳道 = 一个气缸 / 伺服轴等执行器;一个色块 = 该执行器上的一个动作。
|
||||||
|
|
||||||
@@ -94,35 +154,61 @@
|
|||||||
## D. 依赖关系:先后顺序与并行(多输入 / 多输出)
|
## D. 依赖关系:先后顺序与并行(多输入 / 多输出)
|
||||||
|
|
||||||
**依赖类型**
|
**依赖类型**
|
||||||
|
|
||||||
| 类型 | 含义 | 画法 |
|
| 类型 | 含义 | 画法 |
|
||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| **FS** 完成-启动 | 前动作完成后才启动 | 绿色实线箭头 |
|
| **FS** 完成-启动 | 前动作完成后才启动 | 绿色实线箭头 |
|
||||||
| **SS** 起始-起始 | 可提前启动(并行重叠) | 琥珀虚线箭头,标签带 `+n°` |
|
| **SS** 起始-起始 | 可提前启动(并行重叠) | 琥珀虚线箭头,标签带 `+n°` |
|
||||||
| FF / SF | 完成-完成 / 起始-完成 | 预留类型 |
|
| FF / SF | 完成-完成 / 起始-完成 | 模型与算法已支持,界面入口预留 |
|
||||||
|
|
||||||
**我要给动作添加前置依赖(输入)**
|
**我要给动作添加前置依赖(输入)**
|
||||||
- 选中动作 → 右侧「**前置依赖 · 输入**」→「添加前置依赖」→ 选择前置动作与类型;或
|
- 选中动作 → 右侧「**前置依赖 · 输入**」→「添加前置依赖」→ 选择前置动作与类型;或
|
||||||
- 右键动作 →「添加依赖…」。
|
- 右键动作 →「添加依赖…」。
|
||||||
|
|
||||||
**一个动作可以有多个前置(多输入)**
|
**一个动作可以有多个前置(多输入)**
|
||||||
- 重复添加即可;右侧会逐条列出,每条可单独删除。
|
- 重复添加即可;右侧逐条列出,每条可单独删除。
|
||||||
|
|
||||||
**一个动作可以输出多个结果(多输出)**
|
**一个动作可以输出多个结果(多输出)**
|
||||||
- 在「**输出依赖 · 结果**」区域可以看到本动作指向了哪些后续动作,并可逐条删除。
|
- 在「**输出依赖 · 结果**」区域查看本动作指向了哪些后续动作,并可逐条删除。
|
||||||
|
|
||||||
**我要删除依赖**
|
**我要删除依赖**
|
||||||
- 在「前置依赖」或「输出依赖」列表中点击该条右侧的 `×`。
|
- 在「前置依赖」或「输出依赖」列表中点击该条右侧的 `×`。
|
||||||
|
|
||||||
|
**依赖在画布上怎么画**
|
||||||
|
- 条形视图:**同泳道**的依赖用水平箭头连接两个色块的**外侧边缘**(不伸入色块);相邻泳道在两泳道之间的空隙走线;跨多泳道时在最外侧绕行。
|
||||||
|
- 依赖图注(`FS 顺序` / `SS +n°`)默认贴在依赖线旁;当两动作间距太短放不下时,会**自动移到箭头右侧**。
|
||||||
|
- 圆周视图:依赖沿圆弧绕行,箭头与线宽已收窄,与动作环的间隙匹配。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## E. 相位分区:编辑名称、起止角、数量
|
## E. 工位:增删改与排序
|
||||||
|
|
||||||
|
**工位是什么**
|
||||||
|
- 动作的**归属单元**,决定条形视图中的分组与排序,也用于「工位负载」统计。
|
||||||
|
- 一个流程可以有任意多个工位。
|
||||||
|
|
||||||
|
**我要编辑工位**
|
||||||
|
1. 左侧「动作和执行编辑」→「**编辑工位**」。
|
||||||
|
2. 在「工位管理」对话框中:
|
||||||
|
- 「**添加工位**」新增(自动分配 `STn` 编号);
|
||||||
|
- 修改**名称**、点色块换**颜色**;
|
||||||
|
- 用上 / 下箭头**调整顺序**(保存时按列表顺序写入排序);
|
||||||
|
- 「删除」移除工位(**至少保留一个**,只剩一个时禁用)。
|
||||||
|
3. 点「确定」应用。
|
||||||
|
|
||||||
|
> 删除某个工位后,原本挂在该工位下的动作会**自动改挂到列表中的第一个工位**,不会产生悬空引用。
|
||||||
|
> 单个动作归属哪个工位,在动作编辑对话框的「工位」下拉中选择。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## F. 相位分区:编辑名称、起止角、数量
|
||||||
|
|
||||||
**相位分区是什么**
|
**相位分区是什么**
|
||||||
- 把一个循环按角度划分成的若干**命名工艺阶段**(默认:上料 / 夹紧 / 加工 / 检测 / 下料),
|
- 把一个循环按角度划分成的若干**命名工艺阶段**(默认:上料 / 夹紧 / 加工 / 检测 / 下料);
|
||||||
条形图顶部那条标注带就是它;右侧属性里的「相位归属」也按它判断。
|
- 条形图顶部的标注带、右侧属性里的「相位归属」都按它判断。
|
||||||
|
|
||||||
**我要编辑相位分区**
|
**我要编辑相位分区**
|
||||||
1. 按 `F2` →「工艺参数」→ 找到「**相位分区**」→「编辑…」。
|
1. 左侧「动作和执行编辑」→「**编辑相位分区**」;或 `F2` →「相位分区」→「编辑…」。
|
||||||
2. 在弹出的编辑器里:
|
2. 在弹出的编辑器里:
|
||||||
- **添加分区** / **删除分区**(数量不限);
|
- **添加分区** / **删除分区**(数量不限);
|
||||||
- 修改**名称**、**起始角**、**结束角**;
|
- 修改**名称**、**起始角**、**结束角**;
|
||||||
@@ -135,44 +221,62 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## F. 视图:条形 / 圆周、缩放、适应视图、显示选项
|
## G. 视图:条形 / 圆周、缩放、适应视图、显示选项
|
||||||
|
|
||||||
**我要切换视图**
|
### G1. 条形时序视图
|
||||||
- 顶部「条形节拍 / 圆周节拍」分段开关;两种视图共享同一份数据。
|
|
||||||
|
- **标题**:条形时序视图。
|
||||||
|
- **横轴双刻度**:相位分区带与刻度线之间有两排字 —— **上排为相位值**(`0° / 60° / …`),**下排为等价时间**(按当前时间单位);轴单位图例「相位 / °」「时间 / s」与各自刻度同排。
|
||||||
|
- **动作块**:默认把「**名称 + 时长**」一起写在色块内、紧跟名称之后;只有当色块太短、放不下时才移到色块外侧。色块为单行高度,视觉更苗条。
|
||||||
|
- **0° / 360° 边界**:仅用绿色 / 琥珀色虚线标出,不再额外写字(坐标轴已能说明)。
|
||||||
|
- **泳道**:行距按「刚好容纳依赖箭头与图注」设置,分隔线颜色略深;同泳道可放多个不重叠动作。
|
||||||
|
|
||||||
|
### G2. 圆周时序视图
|
||||||
|
|
||||||
|
- **标题**:圆周时序视图。
|
||||||
|
- **同心环**:一层 = 一个执行器轨道;环带只求容纳文字,环与环之间留出**足够放置依赖箭头与图注的间隙**。
|
||||||
|
- **0° 起点**:12 点钟方向,顶部有起点标记;外围每 5° 一个刻度,**每 30° 标注度数,并在度数外侧标注等价时间**。
|
||||||
|
- **循环方向**:固定顺时针,外圈有一段短弧 + 切向箭头,标注「顺时针 CW」。
|
||||||
|
- **依赖**:沿圆弧绕行,线宽与箭头已收窄;标签沿弧切向排布。
|
||||||
|
|
||||||
|
### G3. 通用操作
|
||||||
|
|
||||||
**我要缩放 / 平移**
|
**我要缩放 / 平移**
|
||||||
- `Ctrl + 滚轮`:**以光标为锚点**缩放(25% – 400%);
|
- `Ctrl + 滚轮`:**以光标为锚点**缩放(25% – 400%);
|
||||||
- 普通滚轮 / 拖拽空白:平移画布。
|
- 普通滚轮 / 拖拽空白:平移画布。
|
||||||
|
|
||||||
**我要让内容完整显示(适应视图)**
|
**我要让内容完整显示(适应视图)**
|
||||||
- 顶部「**适应视图**」:按当前内容(含刻度、箭头、跨圈等标注)自动计算缩放与居中,
|
- 顶部「适应视图」图标:按当前内容(含刻度、箭头、跨圈等标注)自动计算缩放与居中。
|
||||||
编辑过圆周节拍、层数很多时也会自动缩小到完整可见。
|
|
||||||
|
|
||||||
**我要开关图元标注**
|
**我要开关图元标注**
|
||||||
- 左侧「显示选项」:
|
- 左侧「显示选项」:
|
||||||
- 条形视图:时间轴/相位双刻度、依赖箭头 FS/SS、跨循环片段标记、相位分区标注;
|
- 条形视图:时间轴 / 相位双刻度、依赖箭头 FS / SS、跨循环片段标记、相位分区标注;
|
||||||
- 圆周视图:同心圆环背景、顺序箭头、层半径标注、跨循环高亮。
|
- 圆周视图:同心圆环背景、顺序箭头、层半径标注、跨循环高亮。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## G. 界面:隐藏 / 钉住侧栏,看统计
|
## H. 界面:侧栏、统计、帮助入口
|
||||||
|
|
||||||
**我要隐藏 / 显示侧栏**
|
**我要隐藏 / 显示侧栏**
|
||||||
- 工具栏右侧有两个侧栏按钮,分别控制左、右侧栏。
|
- 工具栏右侧的两个侧栏按钮,分别控制左、右侧栏。
|
||||||
|
|
||||||
**我要钉住侧栏**
|
**我要钉住侧栏**
|
||||||
- 侧栏标题右侧的**图钉**按钮:
|
- 侧栏标题右侧的**图钉**按钮:
|
||||||
- **已钉住**:固定占位,画布让出空间;
|
- **已钉住**:固定占位,画布让出空间;
|
||||||
- **取消钉住**:变为悬浮层,鼠标移开自动收起;
|
- **取消钉住**:变为悬浮层,鼠标移开自动收起。
|
||||||
- 侧栏收起后,画布边缘有细把手:悬停临时展开、点击固定显示。
|
- 侧栏收起后,画布边缘有细把手:悬停临时展开、点击固定显示。
|
||||||
|
|
||||||
**我要查看节拍统计**
|
**我要查看节拍统计**
|
||||||
- 画布左下角「**节拍统计**」按钮 → 弹出窗口显示循环周期、动作数量、关键路径、
|
- 画布左下角「**节拍统计**」按钮 → 弹窗显示:
|
||||||
最大并行度、相位覆盖率、瓶颈工位、预估产能。
|
- 循环周期、动作数量、关键路径、最大并行度、相位覆盖率、瓶颈工位。
|
||||||
|
- 仅展示**可从当前项目数据推导**的指标;不提供缺少输入依据的推算值(如产能)。
|
||||||
|
|
||||||
|
**帮助入口**
|
||||||
|
- 顶部工具栏最右侧的 **?** 或 `F1`。画布上的编辑工具条**不再重复放置**帮助按钮。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## H. AI 生成:用自然语言直接生成时序图
|
## I. AI 生成:用自然语言直接生成时序图
|
||||||
|
|
||||||
**我要用一句话生成一张时序图**
|
**我要用一句话生成一张时序图**
|
||||||
1. 顶部「**AI 生成**」按钮。
|
1. 顶部「**AI 生成**」按钮。
|
||||||
@@ -180,33 +284,35 @@
|
|||||||
- 填写 **DeepSeek API Key**(仅保存在本机内存,不写入工程文件);
|
- 填写 **DeepSeek API Key**(仅保存在本机内存,不写入工程文件);
|
||||||
- 选择模型:**Flash · 快速**(`deepseek-chat`)或 **Pro · 深度推理**(`deepseek-reasoner`);
|
- 选择模型:**Flash · 快速**(`deepseek-chat`)或 **Pro · 深度推理**(`deepseek-reasoner`);
|
||||||
- 选择推理强度:**高 / 最高**;
|
- 选择推理强度:**高 / 最高**;
|
||||||
- 在较大的输入框里用**自然语言**描述工艺流程(工位、动作、时间、先后与并行关系)。
|
- 用**自然语言**描述工艺流程(工位、动作、时间、先后与并行关系)。
|
||||||
3. 点「生成」→ 模型返回结构化时序图并自动载入工作台;可在其上继续编辑。
|
3. 点「生成」→ 模型返回结构化时序图并自动载入工作台,可继续编辑。
|
||||||
|
|
||||||
**生成效果不理想怎么办**
|
**生成效果不理想怎么办**
|
||||||
- 描述里写清:循环时长、工位数量、每个动作大致时长、哪些是顺序(完成后启动)、哪些是并行。
|
- 描述里写清:循环时长、工位数量、每个动作大致时长、哪些是顺序(完成后启动)、哪些是并行。
|
||||||
- 生成后仍可手动微调角度、依赖与相位分区。
|
- 生成后仍可手动微调角度、依赖、工位与相位分区。
|
||||||
|
|
||||||
> 需要有效的 DeepSeek API Key 与可访问 `api.deepseek.com` 的网络。
|
> 需要有效的 DeepSeek API Key 与可访问 `api.deepseek.com` 的网络。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## I. 导出:SVG / PNG
|
## J. 导出:SVG / PNG
|
||||||
|
|
||||||
**我要导出矢量图(进工艺卡 / MES)**
|
**我要导出矢量图(进工艺卡 / MES)**
|
||||||
- 顶部「导出 SVG」→ 选择保存位置。SVG 分层、带语义 `id` 与 `data-*`:
|
- 顶部「**导出 SVG**」→ 选择保存位置。SVG 分层、带语义 `id` 与 `data-*`:
|
||||||
`background / ruler / layers / actions / dependencies / legend`,
|
`background / ruler / layers / actions / dependencies / legend`,
|
||||||
每个动作 `<g id="A3" data-action data-start data-duration data-layer data-station>`。
|
每个动作 `<g id="A3" data-action data-start data-duration data-layer data-station>`。
|
||||||
|
|
||||||
**我要导出位图**
|
**我要导出位图**
|
||||||
- 顶部「导出 PNG」→ 按 2 倍像素比导出当前画布为 `.png`。
|
- 顶部「**导出 PNG**」→ 按 2 倍像素比导出当前画布为 `.png`。
|
||||||
|
|
||||||
|
> 导出入口只在顶部工具栏提供,右侧属性栏不再重复。
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## J. 保存、打开、崩溃恢复
|
## K. 保存、打开、崩溃恢复
|
||||||
|
|
||||||
**我要保存**
|
**我要保存**
|
||||||
- 「保存 / 另存为」写入 `.seq.json`,并在同目录生成 `<文件名>.bak` 备份。
|
- 顶部「保存」图标(`Ctrl+S`)写入 `.seq.json`,并在同目录生成 `<文件名>.bak` 备份。
|
||||||
|
|
||||||
**异常退出后恢复**
|
**异常退出后恢复**
|
||||||
- 软件每 **5 秒**写入本地快照;若上次未正常退出,下次启动会弹出恢复向导,
|
- 软件每 **5 秒**写入本地快照;若上次未正常退出,下次启动会弹出恢复向导,
|
||||||
@@ -215,66 +321,66 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## K. 单位与精度
|
## L. 单位与精度
|
||||||
|
|
||||||
**我要改单位 / 精度**
|
**我要改单位 / 精度**
|
||||||
- 顶部单位下拉(ms / s / min)快速切换;或 `F2` →「单位与精度」改时间/相位单位与显示精度。
|
- 顶部单位下拉(`ms / s / min`)快速切换时间单位;或 `F2` →「单位与精度」改时间 / 相位单位与显示精度。
|
||||||
|
|
||||||
**换算关系**
|
**换算关系**
|
||||||
|
|
||||||
```
|
```
|
||||||
angle(deg) = ms / cycleMs × 360
|
angle(deg) = ms / cycleMs × 360
|
||||||
ms = angle / 360 × cycleMs
|
ms = angle / 360 × cycleMs
|
||||||
|
1 圈 = cycleMs = 360° = 100%
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## L. 多选与批量对齐
|
## M. 多选与批量对齐
|
||||||
|
|
||||||
**我要同时对齐多个动作**
|
**我要同时对齐多个动作**
|
||||||
1. 按住 **Ctrl**(或 Shift)在画布 / 左侧列表逐个点击动作,可**多选**;
|
1. 按住 **Ctrl**(或 Shift)在画布 / 左侧列表逐个点击动作,可**多选**;
|
||||||
2. 点右侧「编辑操作」→「对齐相位」,所有选中动作的起始角会**对齐到主选中项**的起始角。
|
2. 点「编辑工具」→「对齐」,所有选中动作的起始角会**对齐到主选中项**的起始角。
|
||||||
|
|
||||||
> 不按 Ctrl 点击则替换为单选;再次 Ctrl 点击已选项可取消该动作的选中。
|
> 不按 Ctrl 点击则替换为单选;再次 Ctrl 点击已选项可取消该动作的选中。
|
||||||
|
|
||||||
## M. 编辑动作:角度 ↔ 时间
|
---
|
||||||
|
|
||||||
|
## N. 动作编辑对话框:角度 ↔ 时间
|
||||||
|
|
||||||
**我要按时间(而不是角度)修改动作**
|
**我要按时间(而不是角度)修改动作**
|
||||||
- 选中动作 → 右侧「编辑」(或双击行内编辑图标)→ 编辑框内同时提供:
|
- 双击画布色块 / 左侧动作行,或点行内铅笔图标 → 编辑框内同时提供:
|
||||||
- **起始相位 / 持续相位(°)**
|
- **起始相位 / 持续相位(°)**
|
||||||
- **起始时刻 / 持续时长**(当前时间单位,如 `s`)
|
- **起始时刻 / 持续时长**(当前时间单位,如 `s`)
|
||||||
- 两组输入**实时双向换算**:改角度自动更新时间,改时间自动更新角度。
|
- 两组输入**实时双向换算**:改角度自动更新时间,改时间自动更新角度。
|
||||||
- 换算关系:`时间 = 角度 / 360 × 循环时长`。
|
- 换算关系:`时间 = 角度 / 360 × 循环时长`。
|
||||||
|
- 对话框内还可改**名称、驱动、工位、颜色**。
|
||||||
|
|
||||||
**拖拽时的辅助**
|
**拖拽时的辅助**
|
||||||
- 把鼠标移到**色块左/右端**或**分区边界**附近,指针会变成**左右拖拽箭头**;
|
- 鼠标移到**色块左 / 右端**或**分区边界**附近,指针会变成**左右拖拽箭头**;
|
||||||
- 拖动时会显示**竖直虚线坐标参考**,并带**弱吸附**(自动贴合整 5°、其它动作端点、分区边界)。
|
- 拖动时显示**竖直虚线坐标参考**,并带**弱吸附**(自动贴合整 5°、其它动作端点、分区边界)。
|
||||||
|
|
||||||
## N. 关于
|
|
||||||
|
|
||||||
- **软件**:时序图设计器 · Sequence Diagram Studio
|
|
||||||
- **设计人**:呆头鹅
|
|
||||||
- **版本**:V1.0.1
|
|
||||||
- **版权**:Copyright © 2026 呆头鹅。保留所有权利。
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 附录:快捷键与文件格式
|
## 附录:快捷键、文件格式、构建
|
||||||
|
|
||||||
### 快捷键
|
### 快捷键
|
||||||
|
|
||||||
| 操作 | 行为 |
|
| 操作 | 行为 |
|
||||||
| --- | --- |
|
| --- | --- |
|
||||||
| 左键拖拽动作块 | 平移相位(自动吸附) |
|
| 左键拖拽动作块 | 平移相位(自动吸附) |
|
||||||
| 拖拽条形块右端 | 改持续角 |
|
| 拖拽条形块右端 / 左端 | 改持续角 / 改起始角 |
|
||||||
| `Shift` + 拖拽 | 圆周视图改层;条形视图上下拖动改层 |
|
| 圆周视图拖弧两端 | 改起止角 |
|
||||||
|
| `Shift` + 拖拽 | 圆周视图径向改层;条形视图上下拖动改层 |
|
||||||
|
| 双击画布色块 / 左侧动作行 | 打开动作编辑对话框 |
|
||||||
| 双击空白 | 在点击角度处新建动作 |
|
| 双击空白 | 在点击角度处新建动作 |
|
||||||
| `Ctrl` + 滚轮 | 以光标为锚点缩放 |
|
| `Ctrl` + 滚轮 | 以光标为锚点缩放 |
|
||||||
| 普通滚轮 | 平移画布 |
|
| 普通滚轮 | 平移画布 |
|
||||||
| 右键动作 | 菜单:添加依赖 / 改层 / 复制 / 删除 |
|
| 右键动作 | 菜单:添加依赖 / 改层 / 复制 / 删除 |
|
||||||
| `Ctrl+Z` / `Ctrl+Y` | 撤销 / 重做 |
|
| `Ctrl+Z` / `Ctrl+Y` | 撤销 / 重做 |
|
||||||
| `Ctrl+S` / `Ctrl+O` / `Ctrl+N` | 保存 / 打开 / 新建 |
|
| `Ctrl+S` / `Ctrl+O` / `Ctrl+N` | 保存 / 打开 / 新建 |
|
||||||
| `Delete` | 删除选中动作 |
|
| `Delete` | 删除选中动作(至少保留一个) |
|
||||||
| `F1` / `F2` / `F3` | 帮助 / 工艺参数 / 深浅主题 |
|
| `F1` / `F2` / `F3` | 帮助 / 编辑时序与节拍参数 / 深浅主题 |
|
||||||
|
|
||||||
### 工程文件格式(`.seq.json`)
|
### 工程文件格式(`.seq.json`)
|
||||||
|
|
||||||
@@ -284,7 +390,7 @@ ms = angle / 360 × cycleMs
|
|||||||
"project": {
|
"project": {
|
||||||
"name": "示例节拍",
|
"name": "示例节拍",
|
||||||
"units": { "timeUnit": "s", "phaseUnit": "deg", "precision": -1 },
|
"units": { "timeUnit": "s", "phaseUnit": "deg", "precision": -1 },
|
||||||
"cycle": { "durationMs": 2400, "startAngle": 0, "direction": "cw", "origin": "twelve" },
|
"cycle": { "durationMs": 3600, "startAngle": 0, "direction": "cw", "origin": "twelve", "snapDeg": 1 },
|
||||||
"stations": [ { "id": "ST1", "name": "工位 1", "order": 0, "color": "#4cc9f0" } ],
|
"stations": [ { "id": "ST1", "name": "工位 1", "order": 0, "color": "#4cc9f0" } ],
|
||||||
"actions": [
|
"actions": [
|
||||||
{ "id": "A1", "name": "动作 1", "stationId": "ST1", "driver": "气缸 Y1",
|
{ "id": "A1", "name": "动作 1", "stationId": "ST1", "driver": "气缸 Y1",
|
||||||
@@ -300,6 +406,13 @@ ms = angle / 360 × cycleMs
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 应用标志
|
||||||
|
|
||||||
|
- 原创标记「**环序 / Cycle-Step**」:缺口圆环(一圈 = 一个循环,缺口指示 0° 起点)
|
||||||
|
\+ 阶梯折线(动作按时间顺序推进)+ 原点 / 链尾节点。
|
||||||
|
- 由 `tools/gen-icon.py` 生成 `windows/runner/resources/app_icon.ico` 与 `demo/app-icon.png`;
|
||||||
|
工具栏 Logo 为同一几何构成(`lib/ui/app_logo.dart`),二者同源。
|
||||||
|
|
||||||
### 从源码构建
|
### 从源码构建
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
|||||||
+11
-10
@@ -105,10 +105,11 @@ class BarLayout {
|
|||||||
/// 参数 [project]:项目数据;[size]:可用画布尺寸。
|
/// 参数 [project]:项目数据;[size]:可用画布尺寸。
|
||||||
/// 副作用:初始化 [pitch]。
|
/// 副作用:初始化 [pitch]。
|
||||||
BarLayout(this.project, this.size) {
|
BarLayout(this.project, this.size) {
|
||||||
// 可用高度 = 总高 - 顶部留白 - 底部预留;按**泳道数**均分并夹取到 [46, 66]。
|
// 可用高度 = 总高 - 顶部留白 - 底部预留;按**泳道数**均分并夹取到 [44, 52],
|
||||||
|
// 让相邻泳道之间的空隙刚好容纳依赖箭头与其图注。
|
||||||
final int n = lanes.length;
|
final int n = lanes.length;
|
||||||
final double usable = size.height - topPad - bottomReserve;
|
final double usable = size.height - topPad - bottomReserve;
|
||||||
pitch = n == 0 ? 66 : (usable / n).clamp(46, 66);
|
pitch = n == 0 ? 52 : (usable / n).clamp(44, 52);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 布局所依据的项目数据。
|
/// 布局所依据的项目数据。
|
||||||
@@ -123,11 +124,11 @@ class BarLayout {
|
|||||||
/// 顶部留白(为标题/刻度等预留)。
|
/// 顶部留白(为标题/刻度等预留)。
|
||||||
static const double topPad = 210;
|
static const double topPad = 210;
|
||||||
|
|
||||||
/// 单个动作条的高度(像素):与 11–13px 文字匹配,避免过厚。
|
/// 单个动作条的高度(像素):单行文字即可,条块更苗条。
|
||||||
static const double barH = 26;
|
static const double barH = 22;
|
||||||
|
|
||||||
/// 行的视觉参考高度(像素)。
|
/// 行的视觉参考高度(像素)。
|
||||||
static const double rowVisual = 40;
|
static const double rowVisual = 36;
|
||||||
|
|
||||||
/// 底部预留空间(像素)。
|
/// 底部预留空间(像素)。
|
||||||
static const double bottomReserve = 350;
|
static const double bottomReserve = 350;
|
||||||
@@ -218,11 +219,11 @@ class CircularLayout {
|
|||||||
final int layers = lanes.length;
|
final int layers = lanes.length;
|
||||||
// 最大半径受较短边约束,减去 74px 留给刻度与边距。
|
// 最大半径受较短边约束,减去 74px 留给刻度与边距。
|
||||||
final double maxR = math.min(size.width, size.height) / 2 - 74;
|
final double maxR = math.min(size.width, size.height) / 2 - 74;
|
||||||
// 在 r0 与 maxR 之间均分各轨道,环间距夹取到 [24, 46]。
|
// 在 r0 与 maxR 之间均分各轨道,环间距夹取到 [32, 52]:
|
||||||
pitch = layers <= 1 ? 40 : ((maxR - r0) / (layers - 1)).clamp(24, 46);
|
// 让相邻环之间留出足够空隙放置依赖箭头与图注。
|
||||||
// 动作环带宽度:相对行距收窄(约 0.56),并夹取到 [12, 26],
|
pitch = layers <= 1 ? 44 : ((maxR - r0) / (layers - 1)).clamp(32, 52);
|
||||||
// 让环与环之间留出呼吸空间、文字仍能容纳。
|
// 动作环带宽度:只求容纳文字(约 15–18px),环更窄、环间空隙更宽。
|
||||||
ringWidth = (pitch * 0.56).clamp(12, 26);
|
ringWidth = (pitch * 0.45).clamp(15, 18);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 布局所依据的项目数据。
|
/// 布局所依据的项目数据。
|
||||||
|
|||||||
+83
-63
@@ -71,9 +71,13 @@ class BarPainter extends CustomPainter {
|
|||||||
final bool dropValid;
|
final bool dropValid;
|
||||||
|
|
||||||
/// 标尺横线所在的 y 坐标(画布坐标)。
|
/// 标尺横线所在的 y 坐标(画布坐标)。
|
||||||
static const double axisTop = 138;
|
static const double axisTop = 164;
|
||||||
/// 相位色带的顶部 y 坐标。
|
/// 相位色带的顶部 y 坐标。
|
||||||
static const double phaseBandTop = 92;
|
static const double phaseBandTop = 92;
|
||||||
|
/// 相位刻度值所在行的 y(分区带与刻度线之间,上排)。
|
||||||
|
static const double phaseValY = 136;
|
||||||
|
/// 时间刻度值所在行的 y(分区带与刻度线之间,下排)。
|
||||||
|
static const double timeValY = 150;
|
||||||
|
|
||||||
/// 绘制整张条形视图。
|
/// 绘制整张条形视图。
|
||||||
///
|
///
|
||||||
@@ -200,22 +204,24 @@ class BarPainter extends CustomPainter {
|
|||||||
..strokeWidth = 1,
|
..strokeWidth = 1,
|
||||||
);
|
);
|
||||||
if (d % 60 == 0) {
|
if (d % 60 == 0) {
|
||||||
_text(canvas, pfmt(d.toDouble(), u, dec: 0), Offset(x, axisTop + 44),
|
// 上排:相位刻度值;下排:时间刻度值(均位于分区带与刻度线之间)。
|
||||||
|
_text(canvas, pfmt(d.toDouble(), u, dec: 0), Offset(x, phaseValY),
|
||||||
color: tokens.accent, size: 10, align: TextAlign.center);
|
color: tokens.accent, size: 10, align: TextAlign.center);
|
||||||
_text(canvas, tvalStr(d / 360 * cycle, u, dec: u.timeUnit == TimeUnit.ms ? 0 : 1),
|
_text(canvas, tvalStr(d / 360 * cycle, u, dec: u.timeUnit == TimeUnit.ms ? 0 : 1),
|
||||||
Offset(x, axisTop + 22), color: tokens.dim, size: 10, align: TextAlign.center);
|
Offset(x, timeValY), color: tokens.sub, size: 10, align: TextAlign.center);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_text(canvas, '时间 / ${timeUnitLabel(u.timeUnit)}', Offset(layout.plotLeft - 14, axisTop + 22),
|
// 轴单位图例:与对应刻度值同排,置于最左侧。
|
||||||
color: tokens.dim, size: 10, align: TextAlign.right);
|
_text(canvas, '相位 / ${phaseUnitLabel(u.phaseUnit)}', Offset(layout.plotLeft - 12, phaseValY),
|
||||||
_text(canvas, '相位 / ${phaseUnitLabel(u.phaseUnit)}', Offset(layout.plotLeft - 14, axisTop + 44),
|
|
||||||
color: tokens.accent, size: 10, align: TextAlign.right);
|
color: tokens.accent, size: 10, align: TextAlign.right);
|
||||||
|
_text(canvas, '时间 / ${timeUnitLabel(u.timeUnit)}', Offset(layout.plotLeft - 12, timeValY),
|
||||||
|
color: tokens.sub, size: 10, align: TextAlign.right);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 绘制循环起止边界线(0° 与 360°)。
|
/// 绘制循环起止边界线(0° 与 360°)。
|
||||||
///
|
///
|
||||||
/// 0° 使用 [Tokens.ok]、360° 使用 [Tokens.warn] 的虚线竖线表示,
|
/// 0° 使用 [Tokens.ok]、360° 使用 [Tokens.warn] 的虚线竖线表示;
|
||||||
/// 并在下方标注“循环开始 / 循环结束”。虚线由 [_dashedLine] 手工分段绘制。
|
/// 不再额外标注文字(坐标轴已能说明起止)。虚线由 [_dashedLine] 手工分段绘制。
|
||||||
void _boundaries(Canvas canvas, BarLayout layout) {
|
void _boundaries(Canvas canvas, BarLayout layout) {
|
||||||
for (final double d in <double>[0, 360]) {
|
for (final double d in <double>[0, 360]) {
|
||||||
final double x = layout.xFor(d);
|
final double x = layout.xFor(d);
|
||||||
@@ -224,14 +230,6 @@ class BarPainter extends CustomPainter {
|
|||||||
..color = col.withValues(alpha: 0.7)
|
..color = col.withValues(alpha: 0.7)
|
||||||
..strokeWidth = 1.4;
|
..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.yFor(layout.ordered.length) - 4), p);
|
||||||
_text(
|
|
||||||
canvas,
|
|
||||||
d == 0 ? '循环开始 0°' : '循环结束 360°',
|
|
||||||
Offset(d == 0 ? x + 8 : x - 8, axisTop + 62),
|
|
||||||
color: col,
|
|
||||||
size: 10,
|
|
||||||
align: d == 0 ? TextAlign.left : TextAlign.right,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +284,7 @@ class BarPainter extends CustomPainter {
|
|||||||
Offset(layout.plotLeft, y + BarLayout.rowVisual - 4),
|
Offset(layout.plotLeft, y + BarLayout.rowVisual - 4),
|
||||||
Offset(layout.plotRight, y + BarLayout.rowVisual - 4),
|
Offset(layout.plotRight, y + BarLayout.rowVisual - 4),
|
||||||
Paint()
|
Paint()
|
||||||
..color = tokens.line.withValues(alpha: 0.5)
|
..color = tokens.line2.withValues(alpha: 0.6)
|
||||||
..strokeWidth = 1,
|
..strokeWidth = 1,
|
||||||
);
|
);
|
||||||
// 该泳道内的所有动作条(互不重叠)。
|
// 该泳道内的所有动作条(互不重叠)。
|
||||||
@@ -373,16 +371,18 @@ class BarPainter extends CustomPainter {
|
|||||||
Offset(layout.plotLeft + wx + 18, r.center.dy), color: tokens.warn, size: 10);
|
Offset(layout.plotLeft + wx + 18, r.center.dy), color: tokens.warn, size: 10);
|
||||||
}
|
}
|
||||||
final double durMs = a.durationAngle / 360 * cycle;
|
final double durMs = a.durationAngle / 360 * cycle;
|
||||||
if (r.width > 150) {
|
final String full = '${a.name} ${tfmt(durMs, u)}';
|
||||||
_text(canvas, a.name, Offset(r.left + 10, r.center.dy - 5),
|
// 默认「名称 + 时长」一起写在条块内、紧跟名称之后(单行,条块更苗条);
|
||||||
|
// 仅当条块太短、放不下时才移到条块外侧。
|
||||||
|
final double fullW = _tp(full, 11, tokens.arcText, FontWeight.w700).width;
|
||||||
|
if (r.width >= fullW + 20) {
|
||||||
|
_text(canvas, full, Offset(r.left + 10, r.center.dy),
|
||||||
color: tokens.arcText, size: 11, weight: FontWeight.w700);
|
color: tokens.arcText, size: 11, weight: FontWeight.w700);
|
||||||
_text(canvas, tfmt(durMs, u), Offset(r.left + 10, r.center.dy + 7),
|
} else if (r.right + 190 > layout.plotRight) {
|
||||||
color: tokens.arcText.withValues(alpha: 0.8), size: 10);
|
_text(canvas, full, Offset(r.left - 10, r.center.dy),
|
||||||
} else if (r.right + 170 > layout.plotRight) {
|
|
||||||
_text(canvas, '${a.name} ${tfmt(durMs, u)}', Offset(r.left - 10, r.center.dy),
|
|
||||||
color: c, size: 11, weight: FontWeight.w600, align: TextAlign.right);
|
color: c, size: 11, weight: FontWeight.w600, align: TextAlign.right);
|
||||||
} else {
|
} else {
|
||||||
_text(canvas, '${a.name} ${tfmt(durMs, u)}', Offset(r.right + 10, r.center.dy),
|
_text(canvas, full, Offset(r.right + 10, r.center.dy),
|
||||||
color: c, size: 11, weight: FontWeight.w600);
|
color: c, size: 11, weight: FontWeight.w600);
|
||||||
}
|
}
|
||||||
_text(canvas, 'Δ${a.durationAngle.toStringAsFixed(0)}°', Offset(layout.plotRight - 4, r.center.dy),
|
_text(canvas, 'Δ${a.durationAngle.toStringAsFixed(0)}°', Offset(layout.plotRight - 4, r.center.dy),
|
||||||
@@ -416,36 +416,57 @@ class BarPainter extends CustomPainter {
|
|||||||
final int ib = index[to.id] ?? 0;
|
final int ib = index[to.id] ?? 0;
|
||||||
final Color col = d.type == DepType.fs ? tokens.fs : tokens.ss;
|
final Color col = d.type == DepType.fs ? tokens.fs : tokens.ss;
|
||||||
final bool crit = criticalDeps.contains('${d.fromId}->${d.toId}');
|
final bool crit = criticalDeps.contains('${d.fromId}->${d.toId}');
|
||||||
|
final String label = d.type == DepType.fs ? 'FS 顺序' : 'SS +${d.offsetAngle.toStringAsFixed(0)}°';
|
||||||
|
final double chipW = _tp(label, 9.5, col, FontWeight.w600).width + 14 + (crit ? 15 : 0);
|
||||||
final Rect ra = layout.rectFor(from);
|
final Rect ra = layout.rectFor(from);
|
||||||
final Rect rb = layout.rectFor(to);
|
final Rect rb = layout.rectFor(to);
|
||||||
|
const double barHalf = BarLayout.barH / 2;
|
||||||
final double sy = ra.center.dy;
|
final double sy = ra.center.dy;
|
||||||
final double ty = rb.center.dy;
|
final double ty = rb.center.dy;
|
||||||
final double sx = d.type == DepType.fs ? ra.right : ra.left;
|
|
||||||
final double ex = d.type == DepType.fs ? sx - 9 : sx + 9;
|
|
||||||
final double tx = rb.left + 14;
|
|
||||||
final double dir = ty > sy ? 1 : -1;
|
final double dir = ty > sy ? 1 : -1;
|
||||||
final double gapY = ty - dir * 23;
|
// 箭头落点:目标条块靠源一侧外缘再留 3px。
|
||||||
final double tipY = ty - dir * 15;
|
final double tipY = ty - dir * (barHalf + 3);
|
||||||
|
|
||||||
final Path p = Path();
|
final Path p = Path();
|
||||||
double chipX;
|
double chipX;
|
||||||
double chipY;
|
double chipY;
|
||||||
// 同一泳道内的依赖(源/目标同 y):水平直线连接,标签置于线上方。
|
Offset arrowTip;
|
||||||
|
Offset arrowDir;
|
||||||
|
// 同一泳道内的依赖(源/目标同 y):箭头连接两色块的外侧边缘。
|
||||||
final bool sameLane = (ty - sy).abs() < 1;
|
final bool sameLane = (ty - sy).abs() < 1;
|
||||||
if (sameLane) {
|
if (sameLane) {
|
||||||
p.moveTo(ex, sy);
|
final bool fs = d.type == DepType.fs;
|
||||||
p.lineTo(tx, sy);
|
final double startX = fs ? ra.right + 2 : ra.left - 2;
|
||||||
chipX = (ex + tx) / 2;
|
double endX = rb.left - 2;
|
||||||
chipY = sy - 14;
|
if (endX < startX) endX = rb.right + 2;
|
||||||
|
p.moveTo(startX, sy);
|
||||||
|
p.lineTo(endX, sy);
|
||||||
|
arrowTip = Offset(endX, sy);
|
||||||
|
arrowDir = Offset(endX >= startX ? 1 : -1, 0);
|
||||||
|
chipX = (startX + endX) / 2;
|
||||||
|
chipY = sy - (barHalf + 9);
|
||||||
|
// 两动作间距太短、图注放不下时,自动移到箭头右侧。
|
||||||
|
if ((endX - startX).abs() < chipW + 8) chipX = endX + chipW / 2 + 6;
|
||||||
} else if ((ib - ia).abs() <= 1) {
|
} else if ((ib - ia).abs() <= 1) {
|
||||||
chipY = gapY;
|
// 相邻泳道:在两泳道之间的空隙中线走水平线,箭头指向目标条块。
|
||||||
p.moveTo(ex, sy + dir * 13);
|
final double mid = (sy + ty) / 2;
|
||||||
p.lineTo(ex, gapY);
|
final double sx = d.type == DepType.fs ? ra.right : ra.left;
|
||||||
p.lineTo(tx, gapY);
|
final double ex = d.type == DepType.fs ? sx - 9 : sx + 9;
|
||||||
p.lineTo(tx, tipY - dir * 12);
|
final double tx = rb.left + 14;
|
||||||
|
p.moveTo(ex, sy + dir * (barHalf + 2));
|
||||||
|
p.lineTo(ex, mid);
|
||||||
|
p.lineTo(tx, mid);
|
||||||
|
p.lineTo(tx, tipY);
|
||||||
|
arrowTip = Offset(tx, tipY);
|
||||||
|
arrowDir = Offset(0, dir);
|
||||||
chipX = (ex + tx) / 2;
|
chipX = (ex + tx) / 2;
|
||||||
|
chipY = mid;
|
||||||
|
if ((tx - ex).abs() < chipW + 10) chipX = tx + chipW / 2 + 6;
|
||||||
} else {
|
} else {
|
||||||
// 跨多行:扫描区间内所有条块边界,据此在外侧选一条竖直泳道。
|
// 跨多行:扫描区间内所有条块边界,据此在外侧选一条竖直泳道。
|
||||||
|
final double sx = d.type == DepType.fs ? ra.right : ra.left;
|
||||||
|
final double ex = d.type == DepType.fs ? sx - 9 : sx + 9;
|
||||||
|
final double tx = rb.left + 14;
|
||||||
double maxRight = 0;
|
double maxRight = 0;
|
||||||
double minLeft = double.infinity;
|
double minLeft = double.infinity;
|
||||||
final List<int> lanes = layout.lanes;
|
final List<int> lanes = layout.lanes;
|
||||||
@@ -461,15 +482,18 @@ class BarPainter extends CustomPainter {
|
|||||||
if (lane > layout.plotRight - 16) {
|
if (lane > layout.plotRight - 16) {
|
||||||
lane = math.min(math.min(sx, tx), minLeft) - 28 - (k % 3) * 16;
|
lane = math.min(math.min(sx, tx), minLeft) - 28 - (k % 3) * 16;
|
||||||
}
|
}
|
||||||
final double srcGapY = sy + dir * 27;
|
final double srcGapY = sy + dir * (barHalf + 14);
|
||||||
p.moveTo(ex, sy + dir * 13);
|
final double gapY = ty - dir * (barHalf + 6);
|
||||||
|
p.moveTo(ex, sy + dir * (barHalf + 2));
|
||||||
p.lineTo(ex, srcGapY);
|
p.lineTo(ex, srcGapY);
|
||||||
p.lineTo(lane, srcGapY);
|
p.lineTo(lane, srcGapY);
|
||||||
p.lineTo(lane, gapY);
|
p.lineTo(lane, gapY);
|
||||||
p.lineTo(tx, gapY);
|
p.lineTo(tx, gapY);
|
||||||
p.lineTo(tx, tipY - dir * 12);
|
p.lineTo(tx, tipY);
|
||||||
|
arrowTip = Offset(tx, tipY);
|
||||||
|
arrowDir = Offset(0, dir);
|
||||||
chipX = (lane + tx) / 2;
|
chipX = (lane + tx) / 2;
|
||||||
chipY = gapY;
|
chipY = gapY - (barHalf + 1);
|
||||||
}
|
}
|
||||||
// 关键路径依赖:先铺一层加粗低透明度光晕,再画主线。
|
// 关键路径依赖:先铺一层加粗低透明度光晕,再画主线。
|
||||||
if (crit) {
|
if (crit) {
|
||||||
@@ -477,7 +501,7 @@ class BarPainter extends CustomPainter {
|
|||||||
p,
|
p,
|
||||||
Paint()
|
Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 9
|
..strokeWidth = 5
|
||||||
..strokeCap = StrokeCap.round
|
..strokeCap = StrokeCap.round
|
||||||
..color = col.withValues(alpha: 0.18),
|
..color = col.withValues(alpha: 0.18),
|
||||||
);
|
);
|
||||||
@@ -486,18 +510,13 @@ class BarPainter extends CustomPainter {
|
|||||||
p,
|
p,
|
||||||
Paint()
|
Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = crit ? 2.2 : 1.7
|
..strokeWidth = crit ? 1.1 : 0.85
|
||||||
..strokeCap = StrokeCap.round
|
..strokeCap = StrokeCap.round
|
||||||
..color = col.withValues(alpha: 0.95),
|
..color = col.withValues(alpha: 0.95),
|
||||||
);
|
);
|
||||||
if (sameLane) {
|
_arrow(canvas, arrowTip, arrowDir, col);
|
||||||
_arrow(canvas, Offset(tx, sy), const Offset(1, 0), col);
|
// 标签置于依赖线旁,避免压住箭头。
|
||||||
} else {
|
_chip(canvas, Offset(chipX, chipY), label, col, crit);
|
||||||
_arrow(canvas, Offset(tx, tipY), Offset(0, dir), col);
|
|
||||||
}
|
|
||||||
final String label = d.type == DepType.fs ? 'FS 顺序' : 'SS +${d.offsetAngle.toStringAsFixed(0)}°';
|
|
||||||
// 标签上移,避免压住箭头(箭头在更靠近目标条块的一侧)。
|
|
||||||
_chip(canvas, Offset(chipX, chipY - 11), label, col, crit);
|
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -507,7 +526,7 @@ class BarPainter extends CustomPainter {
|
|||||||
///
|
///
|
||||||
/// 参数 [col] 为填充色;[dir] 只需提供方向(本函数不归一化,直接按分量使用)。
|
/// 参数 [col] 为填充色;[dir] 只需提供方向(本函数不归一化,直接按分量使用)。
|
||||||
void _arrow(Canvas canvas, Offset tip, Offset dir, Color col) {
|
void _arrow(Canvas canvas, Offset tip, Offset dir, Color col) {
|
||||||
const double s = 13;
|
const double s = 6.5;
|
||||||
final Offset b = tip - dir * s;
|
final Offset b = tip - dir * s;
|
||||||
final Offset n = Offset(-dir.dy, dir.dx) * s * 0.5;
|
final Offset n = Offset(-dir.dy, dir.dx) * s * 0.5;
|
||||||
final Path p = Path()
|
final Path p = Path()
|
||||||
@@ -523,27 +542,28 @@ class BarPainter extends CustomPainter {
|
|||||||
/// 参数 [center]:胶囊中心;[label]:文字;[col]:边框与文字色;
|
/// 参数 [center]:胶囊中心;[label]:文字;[col]:边框与文字色;
|
||||||
/// [crit]:为真时在左侧追加星形关键标记,并把胶囊加宽。
|
/// [crit]:为真时在左侧追加星形关键标记,并把胶囊加宽。
|
||||||
void _chip(Canvas canvas, Offset center, String label, Color col, bool crit) {
|
void _chip(Canvas canvas, Offset center, String label, Color col, bool crit) {
|
||||||
final TextPainter tp = _tp(label, 10.5, col, FontWeight.w600);
|
// 图注字号与刻度文字接近,整体更紧凑。
|
||||||
final double w = tp.width + 18 + (crit ? 18 : 0);
|
final TextPainter tp = _tp(label, 9.5, col, FontWeight.w600);
|
||||||
const double h = 18;
|
final double w = tp.width + 14 + (crit ? 15 : 0);
|
||||||
|
const double h = 15;
|
||||||
final Rect r = Rect.fromCenter(center: center, width: w, height: h);
|
final Rect r = Rect.fromCenter(center: center, width: w, height: h);
|
||||||
canvas.drawRRect(
|
canvas.drawRRect(
|
||||||
RRect.fromRectAndRadius(r, const Radius.circular(6)),
|
RRect.fromRectAndRadius(r, const Radius.circular(5)),
|
||||||
Paint()..color = tokens.chip,
|
Paint()..color = tokens.chip,
|
||||||
);
|
);
|
||||||
canvas.drawRRect(
|
canvas.drawRRect(
|
||||||
RRect.fromRectAndRadius(r, const Radius.circular(6)),
|
RRect.fromRectAndRadius(r, const Radius.circular(5)),
|
||||||
Paint()
|
Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 1
|
..strokeWidth = 1
|
||||||
..color = col,
|
..color = col,
|
||||||
);
|
);
|
||||||
if (crit) {
|
if (crit) {
|
||||||
canvas.drawCircle(Offset(r.left + 9, center.dy), 7, Paint()..color = tokens.crit);
|
canvas.drawCircle(Offset(r.left + 8, center.dy), 6, Paint()..color = tokens.crit);
|
||||||
_text(canvas, '★', Offset(r.left + 9, center.dy), color: tokens.onAccent, size: 10, align: TextAlign.center);
|
_text(canvas, '★', Offset(r.left + 8, center.dy), color: tokens.onAccent, size: 9, align: TextAlign.center);
|
||||||
tp.paint(canvas, Offset(r.left + 20, center.dy - tp.height / 2));
|
tp.paint(canvas, Offset(r.left + 16, center.dy - tp.height / 2));
|
||||||
} else {
|
} else {
|
||||||
tp.paint(canvas, Offset(r.left + 9, center.dy - tp.height / 2));
|
tp.paint(canvas, Offset(r.left + 7, center.dy - tp.height / 2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import 'package:flutter/material.dart' hide Action;
|
|||||||
|
|
||||||
import '../layout/layout.dart';
|
import '../layout/layout.dart';
|
||||||
import '../model/models.dart';
|
import '../model/models.dart';
|
||||||
|
import '../model/units.dart';
|
||||||
import '../theme/tokens.dart';
|
import '../theme/tokens.dart';
|
||||||
|
|
||||||
/// 圆形视图的 [CustomPainter] 实现。
|
/// 圆形视图的 [CustomPainter] 实现。
|
||||||
@@ -118,9 +119,6 @@ class CircularPainter extends CustomPainter {
|
|||||||
// 相位分区环:在最外动作环与刻度环之间画一圈分区色带并标注名称。
|
// 相位分区环:在最外动作环与刻度环之间画一圈分区色带并标注名称。
|
||||||
if (project.viewState.showPhaseBands) _phaseRing(canvas, layout);
|
if (project.viewState.showPhaseBands) _phaseRing(canvas, layout);
|
||||||
|
|
||||||
// 象限辅助线(0°/90°/180°/270°)。
|
|
||||||
_quadrants(canvas, c, layout);
|
|
||||||
|
|
||||||
// 轨道标签:为每条轨道挑选一个空位角度,避免压住该轨道的动作弧。
|
// 轨道标签:为每条轨道挑选一个空位角度,避免压住该轨道的动作弧。
|
||||||
if (project.viewState.showLayerLabels) {
|
if (project.viewState.showLayerLabels) {
|
||||||
for (int i = 0; i < layers; i++) {
|
for (int i = 0; i < layers; i++) {
|
||||||
@@ -148,9 +146,9 @@ class CircularPainter extends CustomPainter {
|
|||||||
// 拖拽端点时的径向虚线参考。
|
// 拖拽端点时的径向虚线参考。
|
||||||
if (guideAngle != null) _guide(canvas, layout);
|
if (guideAngle != null) _guide(canvas, layout);
|
||||||
|
|
||||||
// 起点标记、顺时针方向提示与外围刻度。
|
// 起点标记、循环方向提示与外围刻度。
|
||||||
_startMarker(canvas, layout);
|
_startMarker(canvas, layout);
|
||||||
_cwArrow(canvas, layout);
|
_directionArrow(canvas, layout);
|
||||||
if (project.viewState.showRuler) _ticks(canvas, layout);
|
if (project.viewState.showRuler) _ticks(canvas, layout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -285,21 +283,6 @@ class CircularPainter extends CustomPainter {
|
|||||||
return n >= a.startAngle - 0.5 || n <= (a.endAngle - 360) + 0.5;
|
return n >= a.startAngle - 0.5 || n <= (a.endAngle - 360) + 0.5;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 绘制 0°/90°/180°/270° 四条象限辅助线(从内圈延伸到刻度环)。
|
|
||||||
void _quadrants(Canvas canvas, Offset c, CircularLayout layout) {
|
|
||||||
for (final double d in <double>[0, 90, 180, 270]) {
|
|
||||||
final Offset p1 = polar(c, 30, d);
|
|
||||||
final Offset p2 = polar(c, layout.tickR + 4, d);
|
|
||||||
canvas.drawLine(
|
|
||||||
p1,
|
|
||||||
p2,
|
|
||||||
Paint()
|
|
||||||
..color = tokens.line2.withValues(alpha: 0.7)
|
|
||||||
..strokeWidth = 1,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 绘制单个动作弧。
|
/// 绘制单个动作弧。
|
||||||
///
|
///
|
||||||
/// 算法:
|
/// 算法:
|
||||||
@@ -325,14 +308,7 @@ class CircularPainter extends CustomPainter {
|
|||||||
// 第二段且为跨循环时视为“尾巴”,需淡化处理。
|
// 第二段且为跨循环时视为“尾巴”,需淡化处理。
|
||||||
final bool tail = a.wrap && k == 1;
|
final bool tail = a.wrap && k == 1;
|
||||||
final Path p = arcPath(c, r, segs[k][0], segs[k][1]);
|
final Path p = arcPath(c, r, segs[k][0], segs[k][1]);
|
||||||
canvas.drawPath(
|
// 圆周色块不加描边 / 阴影,保持干净。
|
||||||
p,
|
|
||||||
Paint()
|
|
||||||
..style = PaintingStyle.stroke
|
|
||||||
..strokeWidth = th + 7
|
|
||||||
..strokeCap = a.wrap ? StrokeCap.butt : StrokeCap.round
|
|
||||||
..color = tokens.shadow.withValues(alpha: tokens.shadowOp),
|
|
||||||
);
|
|
||||||
canvas.drawPath(
|
canvas.drawPath(
|
||||||
p,
|
p,
|
||||||
Paint()
|
Paint()
|
||||||
@@ -446,7 +422,7 @@ class CircularPainter extends CustomPainter {
|
|||||||
p,
|
p,
|
||||||
Paint()
|
Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 9
|
..strokeWidth = 5
|
||||||
..strokeCap = StrokeCap.round
|
..strokeCap = StrokeCap.round
|
||||||
..color = col.withValues(alpha: 0.2),
|
..color = col.withValues(alpha: 0.2),
|
||||||
);
|
);
|
||||||
@@ -455,7 +431,7 @@ class CircularPainter extends CustomPainter {
|
|||||||
p,
|
p,
|
||||||
Paint()
|
Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = crit ? 3 : (d.type == DepType.fs ? 2.4 : 2)
|
..strokeWidth = crit ? 1.2 : (d.type == DepType.fs ? 1.0 : 0.9)
|
||||||
..strokeCap = StrokeCap.round
|
..strokeCap = StrokeCap.round
|
||||||
..color = col,
|
..color = col,
|
||||||
);
|
);
|
||||||
@@ -482,7 +458,7 @@ class CircularPainter extends CustomPainter {
|
|||||||
final double len = dir.distance;
|
final double len = dir.distance;
|
||||||
if (len < 0.001) return;
|
if (len < 0.001) return;
|
||||||
final Offset u = dir / len;
|
final Offset u = dir / len;
|
||||||
const double s = 12;
|
const double s = 6;
|
||||||
final Offset b = tip - u * s;
|
final Offset b = tip - u * s;
|
||||||
final Offset n = Offset(-u.dy, u.dx) * s * 0.5;
|
final Offset n = Offset(-u.dy, u.dx) * s * 0.5;
|
||||||
final Path p = Path()
|
final Path p = Path()
|
||||||
@@ -535,40 +511,46 @@ class CircularPainter extends CustomPainter {
|
|||||||
color: tokens.accent, size: 11, align: TextAlign.center, weight: FontWeight.w600);
|
color: tokens.accent, size: 11, align: TextAlign.center, weight: FontWeight.w600);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 绘制顺时针方向指示:一段外圈圆弧、箭头与“顺时针 CW”文字。
|
/// 绘制循环方向指示:外圈一段短弧 + 沿切线的箭头,标注顺时针。
|
||||||
void _cwArrow(Canvas canvas, CircularLayout layout) {
|
void _directionArrow(Canvas canvas, CircularLayout layout) {
|
||||||
final Offset c = layout.center;
|
final Offset c = layout.center;
|
||||||
// 放在刻度数字之外更远处,避免“冲进”视图内部。
|
// 放在度数 / 时间两排标签之外,避免箭头与文字相撞。
|
||||||
final double r = layout.tickR + 56;
|
final double r = layout.tickR + 72;
|
||||||
final Path p = arcPath(c, r, 20, 70);
|
|
||||||
canvas.drawPath(
|
canvas.drawPath(
|
||||||
p,
|
arcPath(c, r, 25, 60),
|
||||||
Paint()
|
Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 2.4
|
..strokeWidth = 1.8
|
||||||
..strokeCap = StrokeCap.round
|
..strokeCap = StrokeCap.round
|
||||||
..color = tokens.accent2,
|
..color = tokens.accent2,
|
||||||
);
|
);
|
||||||
final Offset t1 = polar(c, r, 74);
|
// 箭头指向弧的终点,方向与切线一致(顺时针)。
|
||||||
final Offset t2 = polar(c, r + 14, 68);
|
const double te = 60;
|
||||||
final Offset t3 = polar(c, r - 14, 66);
|
final double trad = te * math.pi / 180;
|
||||||
final Path a = Path()
|
final Offset tip = polar(c, r, te);
|
||||||
..moveTo(t1.dx, t1.dy)
|
final Offset tan = Offset(math.cos(trad), math.sin(trad));
|
||||||
..lineTo(t2.dx, t2.dy)
|
const double s = 7;
|
||||||
..lineTo(t3.dx, t3.dy)
|
final Offset b = tip - tan * s;
|
||||||
|
final Offset n = Offset(-tan.dy, tan.dx) * s * 0.5;
|
||||||
|
final Path head = Path()
|
||||||
|
..moveTo(tip.dx, tip.dy)
|
||||||
|
..lineTo(b.dx + n.dx, b.dy + n.dy)
|
||||||
|
..lineTo(b.dx - n.dx, b.dy - n.dy)
|
||||||
..close();
|
..close();
|
||||||
canvas.drawPath(a, Paint()..color = tokens.accent2);
|
canvas.drawPath(head, Paint()..color = tokens.accent2);
|
||||||
final Offset label = polar(c, r + 30, 45);
|
_text(canvas, '顺时针 CW', polar(c, r + 20, 42),
|
||||||
_text(canvas, '顺时针 CW', label, color: tokens.accent2, size: 11, align: TextAlign.center, weight: FontWeight.w600);
|
color: tokens.accent2, size: 10, align: TextAlign.center, weight: FontWeight.w600);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 绘制外围角度刻度。
|
/// 绘制外围角度刻度。
|
||||||
///
|
///
|
||||||
/// 每 5° 一个刻度,10° 为中刻度,30° 为主刻度并标注度数;
|
/// 每 5° 一个刻度,10° 为中刻度,30° 为主刻度并标注度数;
|
||||||
/// 90° 的整数倍使用强调色加粗,便于快速定位象限。
|
/// 90° 的整数倍使用强调色加粗。度数外侧再标注等价的绝对时间。
|
||||||
void _ticks(Canvas canvas, CircularLayout layout) {
|
void _ticks(Canvas canvas, CircularLayout layout) {
|
||||||
final Offset c = layout.center;
|
final Offset c = layout.center;
|
||||||
final double r = layout.tickR;
|
final double r = layout.tickR;
|
||||||
|
final UnitSettings u = project.units;
|
||||||
|
final double cycle = project.cycle.durationMs;
|
||||||
for (int d = 0; d < 360; d += 5) {
|
for (int d = 0; d < 360; d += 5) {
|
||||||
final bool major = d % 30 == 0;
|
final bool major = d % 30 == 0;
|
||||||
final bool mid = d % 10 == 0;
|
final bool mid = d % 10 == 0;
|
||||||
@@ -582,12 +564,16 @@ class CircularPainter extends CustomPainter {
|
|||||||
..color = major ? tokens.line2 : tokens.line,
|
..color = major ? tokens.line2 : tokens.line,
|
||||||
);
|
);
|
||||||
if (major) {
|
if (major) {
|
||||||
final Offset lp = polar(c, r + 38, d.toDouble());
|
final Offset lp = polar(c, r + 34, d.toDouble());
|
||||||
_text(canvas, '$d°', lp,
|
_text(canvas, '$d°', lp,
|
||||||
color: d % 90 == 0 ? tokens.accent : tokens.sub,
|
color: d % 90 == 0 ? tokens.accent : tokens.sub,
|
||||||
size: 10,
|
size: 10,
|
||||||
align: TextAlign.center,
|
align: TextAlign.center,
|
||||||
weight: d % 90 == 0 ? FontWeight.w700 : FontWeight.normal);
|
weight: d % 90 == 0 ? FontWeight.w700 : FontWeight.normal);
|
||||||
|
// 度数外侧增加一个时间数值(字号与度数保持一致)。
|
||||||
|
final Offset tp = polar(c, r + 48, d.toDouble());
|
||||||
|
_text(canvas, tvalStr(d / 360 * cycle, u, dec: u.timeUnit == TimeUnit.ms ? 0 : 1), tp,
|
||||||
|
color: tokens.sub, size: 10, align: TextAlign.center);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -427,6 +427,26 @@ class AppController extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 替换工位列表(名称 / 颜色 / 顺序 / 数量均可改)。
|
||||||
|
///
|
||||||
|
/// 若某个动作引用的工位被移除,则自动改挂到列表中的第一个工位,
|
||||||
|
/// 保证「动作 → 工位」引用始终有效。空列表会被忽略(至少保留一个工位)。
|
||||||
|
void setStations(List<Station> stations, {String? status}) {
|
||||||
|
if (stations.isEmpty) {
|
||||||
|
setStatus('至少保留一个工位,无法删除');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Set<String> ids = stations.map((Station s) => s.id).toSet();
|
||||||
|
final String fallback = stations.first.id;
|
||||||
|
final List<Action> actions = _project.actions
|
||||||
|
.map((Action a) => ids.contains(a.stationId) ? a : a.copyWith(stationId: fallback))
|
||||||
|
.toList();
|
||||||
|
_mutate(
|
||||||
|
_project.copyWith(stations: stations, actions: actions),
|
||||||
|
status: status ?? '工位已更新',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// 替换相位分区列表(名称 / 起止角 / 数量均可改,允许区间重叠)。
|
/// 替换相位分区列表(名称 / 起止角 / 数量均可改,允许区间重叠)。
|
||||||
void setPhaseZones(List<PhaseZone> zones, {String? status}) {
|
void setPhaseZones(List<PhaseZone> zones, {String? status}) {
|
||||||
_project = _project.copyWith(phaseZones: zones);
|
_project = _project.copyWith(phaseZones: zones);
|
||||||
@@ -518,6 +538,11 @@ class AppController extends ChangeNotifier {
|
|||||||
/// 若 [id] 不存在则直接返回(不产生历史记录)。副作用:若被删动作处于选中
|
/// 若 [id] 不存在则直接返回(不产生历史记录)。副作用:若被删动作处于选中
|
||||||
/// 状态则清除选中,记录历史并重算关键路径。
|
/// 状态则清除选中,记录历史并重算关键路径。
|
||||||
void deleteAction(String id) {
|
void deleteAction(String id) {
|
||||||
|
// 至少保留一个动作 / 泳道:最后一个动作不可删除。
|
||||||
|
if (_project.actions.length <= 1) {
|
||||||
|
setStatus('至少保留一个动作 / 泳道,无法删除');
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 过滤掉目标动作,并从其余动作的依赖中移除与目标相关的边。
|
// 过滤掉目标动作,并从其余动作的依赖中移除与目标相关的边。
|
||||||
final List<Action> actions = _project.actions
|
final List<Action> actions = _project.actions
|
||||||
.where((Action a) => a.id != id)
|
.where((Action a) => a.id != id)
|
||||||
|
|||||||
+40
-18
@@ -30,6 +30,12 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
|||||||
/// 会话内复用的 API Key(不持久化)。
|
/// 会话内复用的 API Key(不持久化)。
|
||||||
static String _sessionKey = '';
|
static String _sessionKey = '';
|
||||||
|
|
||||||
|
/// 示例描述:与输入框灰色占位一致,可一键填入后直接编辑。
|
||||||
|
static const String _examplePrompt =
|
||||||
|
'一条装配线,循环 2.4 秒。上料后定位夹紧,夹紧完成再伺服下压 0.6 秒;'
|
||||||
|
'下压完成后并行进行超声波焊接与视觉检测;检测完成分选下料,最后清洁吹气。'
|
||||||
|
'共 3 个工位,请给出动作、相位与依赖关系。';
|
||||||
|
|
||||||
late final TextEditingController _key;
|
late final TextEditingController _key;
|
||||||
late final TextEditingController _prompt;
|
late final TextEditingController _prompt;
|
||||||
|
|
||||||
@@ -92,26 +98,26 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
|||||||
// 标题
|
// 标题
|
||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Icon(Icons.auto_awesome, size: 20, color: t.accent2),
|
Icon(Icons.auto_awesome, size: 21, color: t.accent2),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
Text('AI 生成时序图', style: TextStyle(color: t.text, fontSize: 16, fontWeight: FontWeight.w700)),
|
Text('AI 生成时序图', style: TextStyle(color: t.text, fontSize: 17, fontWeight: FontWeight.w700)),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
Text('自然语言 → 时序图', style: TextStyle(color: t.dim, fontSize: 10)),
|
Text('自然语言 → 时序图', style: TextStyle(color: t.dim, fontSize: 11.5)),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const Divider(height: 22),
|
const Divider(height: 22),
|
||||||
|
|
||||||
// API Key
|
// API Key
|
||||||
Text('DeepSeek API Key', style: TextStyle(color: t.sub, fontSize: 11)),
|
Text('DeepSeek API Key', style: TextStyle(color: t.sub, fontSize: 12.5)),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
TextField(
|
TextField(
|
||||||
controller: _key,
|
controller: _key,
|
||||||
obscureText: _obscure,
|
obscureText: _obscure,
|
||||||
style: TextStyle(color: t.text, fontSize: 11),
|
style: TextStyle(color: t.text, fontSize: 12.5),
|
||||||
decoration: InputDecoration(
|
decoration: InputDecoration(
|
||||||
isDense: true,
|
isDense: true,
|
||||||
hintText: 'sk-...',
|
hintText: 'sk-...',
|
||||||
hintStyle: TextStyle(color: t.dim, fontSize: 11),
|
hintStyle: TextStyle(color: t.dim, fontSize: 12.5),
|
||||||
filled: true,
|
filled: true,
|
||||||
fillColor: t.panel2,
|
fillColor: t.panel2,
|
||||||
prefixIcon: Icon(Icons.key, size: 16, color: t.dim),
|
prefixIcon: Icon(Icons.key, size: 16, color: t.dim),
|
||||||
@@ -133,7 +139,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text('模型', style: TextStyle(color: t.sub, fontSize: 11)),
|
Text('模型', style: TextStyle(color: t.sub, fontSize: 12.5)),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
Container(
|
Container(
|
||||||
height: 38,
|
height: 38,
|
||||||
@@ -148,7 +154,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
|||||||
isExpanded: true,
|
isExpanded: true,
|
||||||
underline: const SizedBox.shrink(),
|
underline: const SizedBox.shrink(),
|
||||||
dropdownColor: t.dialog,
|
dropdownColor: t.dialog,
|
||||||
style: TextStyle(color: t.text, fontSize: 11),
|
style: TextStyle(color: t.text, fontSize: 12.5),
|
||||||
icon: Icon(Icons.keyboard_arrow_down, size: 18, color: t.sub),
|
icon: Icon(Icons.keyboard_arrow_down, size: 18, color: t.sub),
|
||||||
items: kAiModels
|
items: kAiModels
|
||||||
.map((AiModelOption m) =>
|
.map((AiModelOption m) =>
|
||||||
@@ -167,7 +173,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Text('推理强度', style: TextStyle(color: t.sub, fontSize: 11)),
|
Text('推理强度', style: TextStyle(color: t.sub, fontSize: 12.5)),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -184,7 +190,25 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
|||||||
const SizedBox(height: 14),
|
const SizedBox(height: 14),
|
||||||
|
|
||||||
// 自然语言输入(大输入框)
|
// 自然语言输入(大输入框)
|
||||||
Text('用自然语言描述工艺流程', style: TextStyle(color: t.sub, fontSize: 11)),
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Text('用自然语言描述工艺流程', style: TextStyle(color: t.sub, fontSize: 12.5)),
|
||||||
|
const Spacer(),
|
||||||
|
// 一键把灰色示例填入输入框,便于直接修改后生成。
|
||||||
|
TextButton.icon(
|
||||||
|
onPressed: _busy
|
||||||
|
? null
|
||||||
|
: () => setState(() => _prompt.text = _examplePrompt),
|
||||||
|
icon: const Icon(Icons.edit_note, size: 17),
|
||||||
|
label: const Text('编辑示例', style: TextStyle(fontSize: 12)),
|
||||||
|
style: TextButton.styleFrom(
|
||||||
|
foregroundColor: t.accent,
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 8),
|
||||||
|
minimumSize: const Size(0, 28),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
Expanded(
|
Expanded(
|
||||||
child: Container(
|
child: Container(
|
||||||
@@ -199,12 +223,10 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
|||||||
maxLines: null,
|
maxLines: null,
|
||||||
expands: true,
|
expands: true,
|
||||||
textAlignVertical: TextAlignVertical.top,
|
textAlignVertical: TextAlignVertical.top,
|
||||||
style: TextStyle(color: t.text, fontSize: 11, height: 1.5),
|
style: TextStyle(color: t.text, fontSize: 12.5, height: 1.6),
|
||||||
decoration: InputDecoration.collapsed(
|
decoration: InputDecoration.collapsed(
|
||||||
hintText: '例如:一条装配线,循环 2.4 秒。上料后定位夹紧,夹紧完成再伺服下压 0.6 秒;'
|
hintText: '例如:$_examplePrompt',
|
||||||
'下压完成后并行进行超声波焊接与视觉检测;检测完成分选下料,最后清洁吹气。'
|
hintStyle: TextStyle(color: t.dim, fontSize: 12.5, height: 1.6),
|
||||||
'共 3 个工位,请给出动作、相位与依赖关系。',
|
|
||||||
hintStyle: TextStyle(color: t.dim, fontSize: 11, height: 1.5),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -219,7 +241,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
|||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(color: t.danger.withValues(alpha: 0.5)),
|
border: Border.all(color: t.danger.withValues(alpha: 0.5)),
|
||||||
),
|
),
|
||||||
child: Text(_error!, style: TextStyle(color: t.danger, fontSize: 11, height: 1.4)),
|
child: Text(_error!, style: TextStyle(color: t.danger, fontSize: 12, height: 1.5)),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
const SizedBox(height: 14),
|
const SizedBox(height: 14),
|
||||||
@@ -230,7 +252,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
|||||||
Expanded(
|
Expanded(
|
||||||
child: Text(
|
child: Text(
|
||||||
'API Key 仅保存在本机内存,不写入工程文件。',
|
'API Key 仅保存在本机内存,不写入工程文件。',
|
||||||
style: TextStyle(color: t.dim, fontSize: 10),
|
style: TextStyle(color: t.dim, fontSize: 11),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
TextButton(onPressed: _busy ? null : () => Navigator.pop(context), child: const Text('取消')),
|
TextButton(onPressed: _busy ? null : () => Navigator.pop(context), child: const Text('取消')),
|
||||||
@@ -275,7 +297,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
|||||||
borderRadius: BorderRadius.circular(8),
|
borderRadius: BorderRadius.circular(8),
|
||||||
border: Border.all(color: active ? t.accent : t.line2),
|
border: Border.all(color: active ? t.accent : t.line2),
|
||||||
),
|
),
|
||||||
child: Text(label, style: TextStyle(color: active ? t.accent : t.sub, fontSize: 11)),
|
child: Text(label, style: TextStyle(color: active ? t.accent : t.sub, fontSize: 12.5)),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
+84
-47
@@ -1,88 +1,125 @@
|
|||||||
// 应用图标组件:绘制一个与应用程序图标一致的紧凑“时钟 / 周期表盘”标记。
|
// 应用标志组件:绘制与应用程序图标(tools/gen-icon.py)一致的原创标记。
|
||||||
//
|
//
|
||||||
// 架构位置:属于纯 UI 装饰组件,仅依赖主题令牌(Tokens)取色,
|
// 设计构成「环序 / Cycle-Step」——全部由基础几何元素组合而成,
|
||||||
// 不持有任何业务状态;在工具栏与启动画面等处复用。
|
// 不参考、不复刻任何既有品牌图形:
|
||||||
|
// 1. 深蓝渐变圆角方形底板:在浅色 / 深色背景下都保持清晰;
|
||||||
|
// 2. 顶部带缺口的圆环:一圈 = 一个循环 = 360°,缺口指示 0° 起点;
|
||||||
|
// 3. 阶梯折线:动作按时间顺序推进的“步进”语义(即时序图本身);
|
||||||
|
// 4. 缺口内的白色原点(0° / 12 点钟)与折线末端的绿色节点(链尾)。
|
||||||
|
//
|
||||||
|
// 架构位置:纯 UI 装饰组件,不持有业务状态;颜色为品牌固定值,
|
||||||
|
// 因此不随主题变化(shouldRepaint 恒为 false)。
|
||||||
import 'dart:math' as math;
|
import 'dart:math' as math;
|
||||||
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import '../theme/tokens.dart';
|
/// 应用标志:原创「环序」标记,可在工具栏与启动画面复用。
|
||||||
|
|
||||||
/// 应用图标:一个简洁的时钟 / 周期表盘标记,呼应产品“节拍”主题。
|
|
||||||
class AppLogo extends StatelessWidget {
|
class AppLogo extends StatelessWidget {
|
||||||
/// 创建应用图标;[size] 为正方形边长,默认 30。
|
/// 创建应用标志;[size] 为正方形边长,默认 30。
|
||||||
const AppLogo({super.key, this.size = 30});
|
const AppLogo({super.key, this.size = 30});
|
||||||
|
|
||||||
/// 图标边长(逻辑像素)。
|
/// 标志边长(逻辑像素)。
|
||||||
final double size;
|
final double size;
|
||||||
|
|
||||||
/// 使用 [_LogoPainter] 在方形画布上绘制图标。
|
/// 使用 [_LogoPainter] 在方形画布上绘制标志。
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final Tokens t = context.tok;
|
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
size: Size.square(size),
|
size: Size.square(size),
|
||||||
painter: _LogoPainter(t),
|
painter: _LogoPainter(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 图标绘制器:按主题令牌绘制圆角底板、双色圆弧表盘与指针。
|
/// 标志绘制器:底板 → 缺口圆环 → 原点 → 阶梯折线 → 末端节点。
|
||||||
class _LogoPainter extends CustomPainter {
|
class _LogoPainter extends CustomPainter {
|
||||||
/// 创建绘制器,[t] 为当前主题令牌。
|
/// 底板渐变起始色(深蓝)。
|
||||||
_LogoPainter(this.t);
|
static const Color _tileTop = Color(0xFF18213D);
|
||||||
|
/// 底板渐变结束色(更深的蓝)。
|
||||||
|
static const Color _tileBot = Color(0xFF0C1226);
|
||||||
|
/// 圆环颜色(与主题强调色一致)。
|
||||||
|
static const Color _ring = Color(0xFF4CC9F0);
|
||||||
|
/// 阶梯折线颜色(与主题警告色一致,表示顺序推进)。
|
||||||
|
static const Color _step = Color(0xFFFFD166);
|
||||||
|
/// 0° 原点颜色。
|
||||||
|
static const Color _origin = Color(0xFFFFFFFF);
|
||||||
|
/// 折线末端节点颜色(与主题成功色一致,表示链尾)。
|
||||||
|
static const Color _end = Color(0xFF34D399);
|
||||||
|
|
||||||
/// 当前主题令牌,提供配色。
|
/// 缺口圆环的角度半宽(度):缺口总宽 68°。
|
||||||
final Tokens t;
|
static const double _gapHalfDeg = 34;
|
||||||
|
|
||||||
/// 依次绘制:圆角底板 → 双色圆环弧 → 时针分针 → 中心圆点。
|
/// 按上述构成绘制标志。
|
||||||
@override
|
@override
|
||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
// 以最短边为基准计算尺寸,保证图标始终为正方形。
|
|
||||||
final double s = size.shortestSide;
|
final double s = size.shortestSide;
|
||||||
final Offset c = Offset(size.width / 2, size.height / 2);
|
final Offset c = Offset(size.width / 2, size.height / 2);
|
||||||
// 圆角方形底板:半透明填充 + 主题色描边。
|
|
||||||
|
// 1) 圆角方形底板 + 顶部到底部的深蓝渐变。
|
||||||
final RRect badge = RRect.fromRectAndRadius(
|
final RRect badge = RRect.fromRectAndRadius(
|
||||||
Rect.fromLTWH(0, 0, s, s),
|
Rect.fromLTWH(0, 0, s, s),
|
||||||
Radius.circular(s * 0.28),
|
Radius.circular(s * 0.27),
|
||||||
|
);
|
||||||
|
canvas.drawRRect(
|
||||||
|
badge,
|
||||||
|
Paint()
|
||||||
|
..shader = const LinearGradient(
|
||||||
|
begin: Alignment.topCenter,
|
||||||
|
end: Alignment.bottomCenter,
|
||||||
|
colors: <Color>[_tileTop, _tileBot],
|
||||||
|
).createShader(Rect.fromLTWH(0, 0, s, s)),
|
||||||
);
|
);
|
||||||
canvas.drawRRect(badge, Paint()..color = t.accent.withValues(alpha: 0.16));
|
|
||||||
canvas.drawRRect(
|
canvas.drawRRect(
|
||||||
badge,
|
badge,
|
||||||
Paint()
|
Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = 1.2
|
..strokeWidth = s * 0.018
|
||||||
..color = t.accent,
|
..color = Colors.white.withValues(alpha: 0.14),
|
||||||
);
|
);
|
||||||
|
|
||||||
// 表盘圆环:用两段不同颜色的圆弧表示进度/周期。
|
// 2) 顶部带缺口的圆环:从 +34° 顺时针扫过 292°。
|
||||||
final double r = s * 0.30;
|
final double ringR = s * 0.293;
|
||||||
final Paint ring = Paint()
|
final double ringW = s * 0.062;
|
||||||
|
const double gapHalf = _gapHalfDeg * math.pi / 180;
|
||||||
|
canvas.drawArc(
|
||||||
|
Rect.fromCircle(center: c, radius: ringR),
|
||||||
|
-math.pi / 2 + gapHalf,
|
||||||
|
2 * math.pi - 2 * gapHalf,
|
||||||
|
false,
|
||||||
|
Paint()
|
||||||
..style = PaintingStyle.stroke
|
..style = PaintingStyle.stroke
|
||||||
..strokeWidth = s * 0.075
|
..strokeWidth = ringW
|
||||||
..strokeCap = StrokeCap.round;
|
|
||||||
ring.color = t.accent;
|
|
||||||
canvas.drawArc(Rect.fromCircle(center: c, radius: r), -math.pi / 2,
|
|
||||||
math.pi * 0.55, false, ring);
|
|
||||||
ring.color = t.accent2;
|
|
||||||
canvas.drawArc(Rect.fromCircle(center: c, radius: r), -math.pi / 2 + math.pi * 0.62,
|
|
||||||
math.pi * 0.5, false, ring);
|
|
||||||
|
|
||||||
// 指针:一根主色长针 + 一根强调色短针,从中心向外绘制。
|
|
||||||
final Paint hand = Paint()
|
|
||||||
..strokeCap = StrokeCap.round
|
..strokeCap = StrokeCap.round
|
||||||
..strokeWidth = s * 0.085;
|
..color = _ring,
|
||||||
hand.color = t.text;
|
);
|
||||||
canvas.drawLine(c, c.translate(0, -r * 0.62), hand);
|
|
||||||
hand.color = t.accent;
|
|
||||||
canvas.drawLine(c, c.translate(r * 0.5, r * 0.16), hand);
|
|
||||||
|
|
||||||
// 中心轴点:外圈文字色、内圈背景色,形成中空圆点。
|
// 3) 0° 原点:位于 12 点钟方向、落在圆环缺口内。
|
||||||
canvas.drawCircle(c, s * 0.055, Paint()..color = t.text);
|
canvas.drawCircle(Offset(c.dx, c.dy - ringR), s * 0.042, Paint()..color = _origin);
|
||||||
canvas.drawCircle(c, s * 0.022, Paint()..color = t.bg);
|
|
||||||
|
// 4) 阶梯折线:横向 → 纵向 → 横向,表示动作顺序推进。
|
||||||
|
final Offset p1 = c + Offset(-s * 0.146, s * 0.088);
|
||||||
|
final Offset p2 = c + Offset(-s * 0.010, s * 0.088);
|
||||||
|
final Offset p3 = c + Offset(-s * 0.010, -s * 0.059);
|
||||||
|
final Offset p4 = c + Offset(s * 0.166, -s * 0.059);
|
||||||
|
canvas.drawPath(
|
||||||
|
Path()
|
||||||
|
..moveTo(p1.dx, p1.dy)
|
||||||
|
..lineTo(p2.dx, p2.dy)
|
||||||
|
..lineTo(p3.dx, p3.dy)
|
||||||
|
..lineTo(p4.dx, p4.dy),
|
||||||
|
Paint()
|
||||||
|
..style = PaintingStyle.stroke
|
||||||
|
..strokeWidth = s * 0.057
|
||||||
|
..strokeCap = StrokeCap.round
|
||||||
|
..strokeJoin = StrokeJoin.round
|
||||||
|
..color = _step,
|
||||||
|
);
|
||||||
|
|
||||||
|
// 5) 折线末端节点:链尾动作。
|
||||||
|
canvas.drawCircle(p4, s * 0.037, Paint()..color = _end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 仅当主题令牌变化时重绘。
|
/// 标志为固定品牌配色,与主题无关,因此无需重绘。
|
||||||
@override
|
@override
|
||||||
bool shouldRepaint(covariant _LogoPainter old) => old.t != t;
|
bool shouldRepaint(covariant _LogoPainter old) => false;
|
||||||
}
|
}
|
||||||
|
|||||||
+100
-405
@@ -282,29 +282,6 @@ class _AppShellState extends State<AppShell> {
|
|||||||
/// 构建顶部工具栏:左侧为品牌与文件/编辑操作,右侧为导出、缩放、
|
/// 构建顶部工具栏:左侧为品牌与文件/编辑操作,右侧为导出、缩放、
|
||||||
/// 单位、侧栏开关与主题切换。根据可用宽度在完整布局与紧凑布局间切换。
|
/// 单位、侧栏开关与主题切换。根据可用宽度在完整布局与紧凑布局间切换。
|
||||||
Widget _toolbar(Tokens t) {
|
Widget _toolbar(Tokens t) {
|
||||||
final bool dirty = c.dirty;
|
|
||||||
final String fileLabel = c.filePath == null
|
|
||||||
? '文件:未保存(内存中)'
|
|
||||||
: '文件:${c.filePath!.split(RegExp(r'[\\/]')).last}';
|
|
||||||
final Widget fileChip = Container(
|
|
||||||
height: 34,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: t.panel,
|
|
||||||
borderRadius: BorderRadius.circular(9),
|
|
||||||
border: Border.all(color: t.line2),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Text(fileLabel, style: TextStyle(color: t.sub, fontSize: 11)),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Container(width: 7, height: 7, decoration: BoxDecoration(color: dirty ? t.warn : t.ok, shape: BoxShape.circle)),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
Text(dirty ? '未保存' : '已保存', style: TextStyle(color: dirty ? t.warn : t.ok, fontSize: 11)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
return Container(
|
return Container(
|
||||||
height: 54,
|
height: 54,
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||||
@@ -344,7 +321,7 @@ class _AppShellState extends State<AppShell> {
|
|||||||
final List<Widget> left;
|
final List<Widget> left;
|
||||||
final List<Widget> right;
|
final List<Widget> right;
|
||||||
if (!compact) {
|
if (!compact) {
|
||||||
// 完整布局:文字按钮 + 文件状态胶囊。
|
// 完整布局:文件 / 编辑操作图标化 + 分段视图切换。
|
||||||
left = <Widget>[
|
left = <Widget>[
|
||||||
const AppLogo(size: 32),
|
const AppLogo(size: 32),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
@@ -358,20 +335,13 @@ class _AppShellState extends State<AppShell> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(width: 18),
|
const SizedBox(width: 18),
|
||||||
_ghost(t, '新建', _newProject),
|
_iconBtn(t, Icons.note_add_outlined, _newProject, tooltip: '新建 Ctrl+N'),
|
||||||
_ghost(t, '打开', _open),
|
_iconBtn(t, Icons.folder_open_outlined, _open, tooltip: '打开 Ctrl+O'),
|
||||||
_ghost(t, '保存', _save),
|
_iconBtn(t, Icons.save_outlined, _save, tooltip: '保存 Ctrl+S'),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
_ghost(t, '撤销', c.canUndo ? c.undo : null, icon: Icons.undo),
|
_iconBtn(t, Icons.undo, c.canUndo ? c.undo : null, tooltip: '撤销 Ctrl+Z'),
|
||||||
_ghost(t, '重做', c.canRedo ? c.redo : null, icon: Icons.redo),
|
_iconBtn(t, Icons.redo, c.canRedo ? c.redo : null, tooltip: '重做 Ctrl+Y'),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
_addBtn(t, '添加动作', () => c.addAction(startAngle: 0)),
|
|
||||||
_toggleBtn(t, '编辑', Icons.edit, () {
|
|
||||||
final Action? a = c.selected;
|
|
||||||
if (a != null) {
|
|
||||||
showDialog<void>(context: context, builder: (_) => ActionEditorDialog(controller: c, action: a));
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
_aiBtn(t),
|
_aiBtn(t),
|
||||||
const SizedBox(width: 12),
|
const SizedBox(width: 12),
|
||||||
_segmented(t),
|
_segmented(t),
|
||||||
@@ -383,12 +353,10 @@ class _AppShellState extends State<AppShell> {
|
|||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
_zoomBox(t),
|
_zoomBox(t),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
_ghost(t, '适应视图', c.fitView),
|
_iconBtn(t, Icons.crop_free, c.fitView, tooltip: '适应视图'),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
_unitDropdown(t),
|
_unitDropdown(t),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
fileChip,
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
sideToggleLeft,
|
sideToggleLeft,
|
||||||
sideToggleRight,
|
sideToggleRight,
|
||||||
_iconBtn(t, Icons.help_outline, () =>
|
_iconBtn(t, Icons.help_outline, () =>
|
||||||
@@ -410,13 +378,6 @@ class _AppShellState extends State<AppShell> {
|
|||||||
_iconBtn(t, Icons.undo, c.canUndo ? c.undo : null, tooltip: '撤销 Ctrl+Z'),
|
_iconBtn(t, Icons.undo, c.canUndo ? c.undo : null, tooltip: '撤销 Ctrl+Z'),
|
||||||
_iconBtn(t, Icons.redo, c.canRedo ? c.redo : null, tooltip: '重做 Ctrl+Y'),
|
_iconBtn(t, Icons.redo, c.canRedo ? c.redo : null, tooltip: '重做 Ctrl+Y'),
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
_iconBtn(t, Icons.add_circle_outline, () => c.addAction(startAngle: 0), tooltip: '添加动作', color: t.ok),
|
|
||||||
_iconBtn(t, Icons.edit, () {
|
|
||||||
final Action? a = c.selected;
|
|
||||||
if (a != null) {
|
|
||||||
showDialog<void>(context: context, builder: (_) => ActionEditorDialog(controller: c, action: a));
|
|
||||||
}
|
|
||||||
}, tooltip: '编辑', color: t.accent),
|
|
||||||
// AI 是核心卖点,紧凑布局下也保留「AI 生成」文字,避免认不出。
|
// AI 是核心卖点,紧凑布局下也保留「AI 生成」文字,避免认不出。
|
||||||
_aiBtn(t),
|
_aiBtn(t),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
@@ -625,44 +586,6 @@ class _AppShellState extends State<AppShell> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 主强调“添加”按钮(绿色填充)。
|
|
||||||
Widget _addBtn(Tokens t, String label, VoidCallback onTap) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
|
||||||
child: FilledButton.icon(
|
|
||||||
onPressed: onTap,
|
|
||||||
icon: const Icon(Icons.add, size: 17),
|
|
||||||
label: Text(label, style: const TextStyle(fontSize: 11, fontWeight: FontWeight.w600)),
|
|
||||||
style: FilledButton.styleFrom(
|
|
||||||
backgroundColor: t.ok,
|
|
||||||
foregroundColor: t.onAccent,
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(9)),
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
|
||||||
minimumSize: const Size(0, 34),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 强调色“编辑”按钮。
|
|
||||||
Widget _toggleBtn(Tokens t, String label, IconData icon, VoidCallback onTap) {
|
|
||||||
return Padding(
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 3),
|
|
||||||
child: FilledButton.icon(
|
|
||||||
onPressed: onTap,
|
|
||||||
icon: Icon(icon, size: 16),
|
|
||||||
label: Text(label, style: const TextStyle(fontSize: 11, fontWeight: FontWeight.w600)),
|
|
||||||
style: FilledButton.styleFrom(
|
|
||||||
backgroundColor: t.accent,
|
|
||||||
foregroundColor: t.onAccent,
|
|
||||||
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(9)),
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
|
|
||||||
minimumSize: const Size(0, 34),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 主色填充按钮(用于导出等主要动作)。
|
/// 主色填充按钮(用于导出等主要动作)。
|
||||||
Widget _primaryBtn(Tokens t, String label, VoidCallback onTap) {
|
Widget _primaryBtn(Tokens t, String label, VoidCallback onTap) {
|
||||||
return FilledButton(
|
return FilledButton(
|
||||||
@@ -839,7 +762,6 @@ class _AppShellState extends State<AppShell> {
|
|||||||
/// 构建左侧栏:项目概览、动作/工位列表、视图模式、显示选项、
|
/// 构建左侧栏:项目概览、动作/工位列表、视图模式、显示选项、
|
||||||
/// 工位负载与操作提示。[floating] 为 true 时以悬浮卡片样式呈现。
|
/// 工位负载与操作提示。[floating] 为 true 时以悬浮卡片样式呈现。
|
||||||
Widget _leftPanel(Tokens t, {bool floating = false}) {
|
Widget _leftPanel(Tokens t, {bool floating = false}) {
|
||||||
final List<Action> actions = c.project.actions;
|
|
||||||
final bool bar = c.project.viewState.mode == ViewMode.bar;
|
final bool bar = c.project.viewState.mode == ViewMode.bar;
|
||||||
return Container(
|
return Container(
|
||||||
width: 300,
|
width: 300,
|
||||||
@@ -857,116 +779,72 @@ class _AppShellState extends State<AppShell> {
|
|||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
_sectionLabel(t, '节拍周期设置'),
|
_sectionLabel(t, '时序创建和编辑'),
|
||||||
const Spacer(),
|
const Spacer(),
|
||||||
_panelControls(t, true),
|
_panelControls(t, true),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Container(
|
_editEntry(
|
||||||
padding: const EdgeInsets.all(10),
|
t,
|
||||||
decoration: BoxDecoration(
|
icon: Icons.edit_note,
|
||||||
color: t.panel2,
|
label: '编辑时序与节拍参数',
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
border: Border.all(color: t.line),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Container(
|
|
||||||
width: 34,
|
|
||||||
height: 34,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: t.accent2.withValues(alpha: 0.2),
|
|
||||||
borderRadius: BorderRadius.circular(9),
|
|
||||||
),
|
|
||||||
alignment: Alignment.center,
|
|
||||||
child: Text('周', style: TextStyle(color: t.accent2, fontSize: 13, fontWeight: FontWeight.w700)),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 10),
|
|
||||||
Expanded(
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Text('节拍周期设置',
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(color: t.text, fontSize: 13, fontWeight: FontWeight.w600)),
|
|
||||||
Text(
|
|
||||||
'项目:${c.project.name} · ${c.filePath == null ? '未保存' : c.filePath!.split(RegExp(r'[\\/]')).last}',
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(color: t.dim, fontSize: 10),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const Divider(height: 16),
|
|
||||||
// 循环时长(= 时间轴长度)即一个循环的 360°/100%,点击即可编辑。
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Text('循环', style: TextStyle(color: t.dim, fontSize: 10.5)),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
Expanded(
|
|
||||||
child: Tooltip(
|
|
||||||
message: '点击编辑循环时长 / 时间轴长度',
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () => showDialog<void>(
|
onTap: () => showDialog<void>(
|
||||||
context: context,
|
context: context,
|
||||||
builder: (_) => SettingsDialog(controller: c),
|
builder: (_) => SettingsDialog(controller: c),
|
||||||
),
|
),
|
||||||
borderRadius: BorderRadius.circular(6),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Flexible(
|
|
||||||
child: Text(
|
|
||||||
'${tfmt(c.project.cycle.durationMs, c.project.units)} = 360° = 100%',
|
|
||||||
maxLines: 1,
|
|
||||||
overflow: TextOverflow.ellipsis,
|
|
||||||
style: TextStyle(color: t.accent, fontSize: 11),
|
|
||||||
),
|
),
|
||||||
),
|
// 较浅的分隔横线,区分上方「时序创建和编辑」与下方「动作和执行编辑」。
|
||||||
const SizedBox(width: 4),
|
const SizedBox(height: 14),
|
||||||
Icon(Icons.edit, size: 12, color: t.accent),
|
Divider(height: 1, thickness: 1, color: t.line),
|
||||||
],
|
const SizedBox(height: 14),
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Text('动作 ${actions.length} · 依赖 ${_depCount()}',
|
|
||||||
style: TextStyle(color: t.dim, fontSize: 10.5)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Row(
|
Row(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
Flexible(
|
// 用 Expanded 占满剩余空间,标题不会被无谓地省略成「…」。
|
||||||
child: _sectionLabel(t, bar ? '动作 / 执行器泳道' : '动作列表(按轨道 L1→L${c.project.laneCount})'),
|
Expanded(child: _sectionLabel(t, '动作和执行编辑')),
|
||||||
),
|
|
||||||
const Spacer(),
|
|
||||||
_headerAction(t, Icons.add, '新建', t.ok, t.onAccent, () => c.addAction(startAngle: 0)),
|
_headerAction(t, Icons.add, '新建', t.ok, t.onAccent, () => c.addAction(startAngle: 0)),
|
||||||
const SizedBox(width: 6),
|
const SizedBox(width: 6),
|
||||||
|
// 至少保留一个动作 / 泳道:只剩一个时禁用删除。
|
||||||
_headerAction(
|
_headerAction(
|
||||||
t,
|
t,
|
||||||
Icons.delete_outline,
|
Icons.delete_outline,
|
||||||
'删除',
|
'删除',
|
||||||
t.danger,
|
t.danger,
|
||||||
Colors.white,
|
Colors.white,
|
||||||
c.selectedId == null ? null : () => c.deleteAction(c.selectedId!),
|
(c.selectedId == null || c.project.actions.length <= 1)
|
||||||
|
? null
|
||||||
|
: () => c.deleteAction(c.selectedId!),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
// 按泳道 / 轨道分组:同一泳道内的多个动作合并显示(最多两行,/ 分隔)。
|
// 按泳道 / 轨道分组:同一泳道内的多个动作合并显示(最多两行,/ 分隔)。
|
||||||
..._laneRows(t, bar),
|
..._laneRows(t, bar),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
// 工位 / 相位分区管理入口,同属「动作和执行编辑」区域。
|
||||||
|
// 工位:一个流程可包含多个工位,可增删改与排序。
|
||||||
|
_editEntry(
|
||||||
|
t,
|
||||||
|
icon: Icons.precision_manufacturing_outlined,
|
||||||
|
label: '编辑工位',
|
||||||
|
badge: c.project.stations.length,
|
||||||
|
onTap: () => showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => StationDialog(controller: c),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(height: 8),
|
||||||
|
// 相位分区:可任意增删、改名、改起止角。
|
||||||
|
_editEntry(
|
||||||
|
t,
|
||||||
|
icon: Icons.tune,
|
||||||
|
label: '编辑相位分区',
|
||||||
|
badge: c.project.phaseZones.length,
|
||||||
|
onTap: () => showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => PhaseZoneDialog(controller: c),
|
||||||
|
),
|
||||||
|
),
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
_sectionLabel(t, '视图模式'),
|
_sectionLabel(t, '视图模式'),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
@@ -981,25 +859,6 @@ class _AppShellState extends State<AppShell> {
|
|||||||
_sectionLabel(t, '显示选项'),
|
_sectionLabel(t, '显示选项'),
|
||||||
const SizedBox(height: 6),
|
const SizedBox(height: 6),
|
||||||
..._displayOptions(t, bar),
|
..._displayOptions(t, bar),
|
||||||
const SizedBox(height: 4),
|
|
||||||
// 相位分区编辑入口:可任意增删、改名、改起止角。
|
|
||||||
Align(
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
child: TextButton.icon(
|
|
||||||
onPressed: () => showDialog<void>(
|
|
||||||
context: context,
|
|
||||||
builder: (_) => PhaseZoneDialog(controller: c),
|
|
||||||
),
|
|
||||||
icon: const Icon(Icons.tune, size: 14),
|
|
||||||
label: Text('编辑相位分区(${c.project.phaseZones.length})',
|
|
||||||
style: const TextStyle(fontSize: 11.5)),
|
|
||||||
style: TextButton.styleFrom(
|
|
||||||
foregroundColor: t.accent,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 2),
|
|
||||||
minimumSize: const Size(0, 26),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
_sectionLabel(t, '工位负载 / 相位占用'),
|
_sectionLabel(t, '工位负载 / 相位占用'),
|
||||||
const SizedBox(height: 10),
|
const SizedBox(height: 10),
|
||||||
@@ -1034,9 +893,53 @@ class _AppShellState extends State<AppShell> {
|
|||||||
s,
|
s,
|
||||||
maxLines: 1,
|
maxLines: 1,
|
||||||
overflow: TextOverflow.ellipsis,
|
overflow: TextOverflow.ellipsis,
|
||||||
style: TextStyle(color: t.dim, fontSize: 11, letterSpacing: 1.4, fontWeight: FontWeight.w500),
|
style: TextStyle(color: t.text2, fontSize: 11.5, letterSpacing: 1.2, fontWeight: FontWeight.w600),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/// 侧栏中的“单行编辑入口”卡片:图标 + 文案 + 可选计数徽标 + 右箭头。
|
||||||
|
///
|
||||||
|
/// 用于把复杂的设置模块收敛为一个点击即可进入的入口。
|
||||||
|
Widget _editEntry(
|
||||||
|
Tokens t, {
|
||||||
|
required IconData icon,
|
||||||
|
required String label,
|
||||||
|
required VoidCallback onTap,
|
||||||
|
int? badge,
|
||||||
|
}) {
|
||||||
|
return InkWell(
|
||||||
|
onTap: onTap,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
child: Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 12, vertical: 11),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: t.panel2,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
border: Border.all(color: t.line),
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(icon, size: 16, color: t.accent),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(child: Text(label, style: TextStyle(color: t.text2, fontSize: 12))),
|
||||||
|
if (badge != null) ...<Widget>[
|
||||||
|
Container(
|
||||||
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 1),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: t.accent.withValues(alpha: 0.14),
|
||||||
|
borderRadius: BorderRadius.circular(6),
|
||||||
|
),
|
||||||
|
child: Text('$badge',
|
||||||
|
style: TextStyle(color: t.accent, fontSize: 10.5, fontWeight: FontWeight.w700)),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 4),
|
||||||
|
],
|
||||||
|
Icon(Icons.chevron_right, size: 16, color: t.dim),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/// 动作列表小节标题右侧的紧凑按钮(新建 / 删除)。
|
/// 动作列表小节标题右侧的紧凑按钮(新建 / 删除)。
|
||||||
///
|
///
|
||||||
/// [onTap] 为 null 时按钮呈禁用态(降低不透明度),用于「未选中动作时禁用删除」。
|
/// [onTap] 为 null 时按钮呈禁用态(降低不透明度),用于「未选中动作时禁用删除」。
|
||||||
@@ -1100,6 +1003,9 @@ class _AppShellState extends State<AppShell> {
|
|||||||
toggle: HardwareKeyboard.instance.isControlPressed ||
|
toggle: HardwareKeyboard.instance.isControlPressed ||
|
||||||
HardwareKeyboard.instance.isShiftPressed,
|
HardwareKeyboard.instance.isShiftPressed,
|
||||||
),
|
),
|
||||||
|
// 双击泳道行直接编辑该泳道的主动作。
|
||||||
|
onDoubleTap: () => showDialog<void>(
|
||||||
|
context: context, builder: (_) => ActionEditorDialog(controller: c, action: primary)),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
||||||
@@ -1193,6 +1099,9 @@ class _AppShellState extends State<AppShell> {
|
|||||||
toggle: HardwareKeyboard.instance.isControlPressed ||
|
toggle: HardwareKeyboard.instance.isControlPressed ||
|
||||||
HardwareKeyboard.instance.isShiftPressed,
|
HardwareKeyboard.instance.isShiftPressed,
|
||||||
),
|
),
|
||||||
|
// 双击动作行直接进入编辑。
|
||||||
|
onDoubleTap: () => showDialog<void>(
|
||||||
|
context: context, builder: (_) => ActionEditorDialog(controller: c, action: a)),
|
||||||
borderRadius: BorderRadius.circular(10),
|
borderRadius: BorderRadius.circular(10),
|
||||||
child: Container(
|
child: Container(
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
||||||
@@ -1256,8 +1165,8 @@ class _AppShellState extends State<AppShell> {
|
|||||||
child: Icon(Icons.edit, size: 13, color: sel ? t.accent : t.dim),
|
child: Icon(Icons.edit, size: 13, color: sel ? t.accent : t.dim),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// 选中该动作时才出现删除入口,避免误触。
|
// 选中该动作时才出现删除入口;至少保留一个动作 / 泳道。
|
||||||
if (sel) ...<Widget>[
|
if (sel && c.project.actions.length > 1) ...<Widget>[
|
||||||
const SizedBox(width: 4),
|
const SizedBox(width: 4),
|
||||||
InkWell(
|
InkWell(
|
||||||
onTap: () => c.deleteAction(a.id),
|
onTap: () => c.deleteAction(a.id),
|
||||||
@@ -1446,61 +1355,6 @@ class _AppShellState extends State<AppShell> {
|
|||||||
(double v) => c.setActionDuration(a.id, v * 180)),
|
(double v) => c.setActionDuration(a.id, v * 180)),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
],
|
],
|
||||||
_unitCard(t),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
_sectionLabel(t, bar ? '编辑操作' : '层 / 编辑操作'),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
if (bar)
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(child: _editTool(t, Icons.add, '添加动作', t.ok, t.onAccent, () => c.addAction(startAngle: 0))),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(child: _editTool(t, Icons.edit, '编辑', t.accent, t.onAccent, () {
|
|
||||||
showDialog<void>(context: context, builder: (_) => ActionEditorDialog(controller: c, action: a));
|
|
||||||
})),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(child: _editTool(t, Icons.copy, '复制', t.panel2, t.sub, c.duplicateSelected, border: t.line2)),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(child: _editTool(t, Icons.delete_outline, '删除', t.panel2, t.sub, () => c.deleteAction(a.id), border: t.line2)),
|
|
||||||
],
|
|
||||||
)
|
|
||||||
else ...<Widget>[
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Expanded(child: _wideBtn(t, Icons.add, '新增轨道 L${c.project.laneCount + 1}', t.accent2, Colors.white,
|
|
||||||
() => c.changeLayer(a.id, 1))),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
Expanded(child: _wideBtn(t, Icons.keyboard_arrow_up, '重排 / 合并层', t.panel2, t.sub,
|
|
||||||
() => c.changeLayer(a.id, -1), border: t.line2)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
_editTool(t, Icons.copy, '复制动作', t.panel2, t.sub, c.duplicateSelected, border: t.line2),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
_editTool(t, Icons.delete_outline, '删除动作', t.panel2, t.sub, () => c.deleteAction(a.id), border: t.line2),
|
|
||||||
const SizedBox(width: 8),
|
|
||||||
_editTool(t, Icons.align_horizontal_left, '对齐相位', t.panel2, t.sub, c.alignPhase, border: t.line2),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
Container(
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: t.info,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
border: Border.all(color: t.line),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Text('新增动作放在最外层;箭头方向即执行顺序', style: TextStyle(color: t.sub, fontSize: 10, height: 1.6)),
|
|
||||||
Text('绿实线 FS 严格顺序 · 琥珀虚线 SS 并行重叠', style: TextStyle(color: t.sub, fontSize: 10, height: 1.6)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
// 输入依赖:允许多条(多前置)。
|
// 输入依赖:允许多条(多前置)。
|
||||||
_sectionLabel(t, '前置依赖 · 输入(${a.deps.length})'),
|
_sectionLabel(t, '前置依赖 · 输入(${a.deps.length})'),
|
||||||
@@ -1532,14 +1386,6 @@ class _AppShellState extends State<AppShell> {
|
|||||||
else
|
else
|
||||||
for (final (Action target, Dependency d) in _outgoingDeps(a))
|
for (final (Action target, Dependency d) in _outgoingDeps(a))
|
||||||
_outDepRow(t, a, target, d),
|
_outDepRow(t, a, target, d),
|
||||||
if (bar) ...<Widget>[
|
|
||||||
const SizedBox(height: 12),
|
|
||||||
_sectionLabel(t, '导出'),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
_exportRow(t, 'SVG(矢量 · 可编辑 · 打印级)', _exportSvg),
|
|
||||||
const SizedBox(height: 6),
|
|
||||||
_exportRow(t, 'PNG / PDF / 工艺卡', _exportPng),
|
|
||||||
],
|
|
||||||
const SizedBox(height: 12),
|
const SizedBox(height: 12),
|
||||||
_helpCard(t),
|
_helpCard(t),
|
||||||
],
|
],
|
||||||
@@ -1731,138 +1577,6 @@ class _AppShellState extends State<AppShell> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 工艺单位与精度卡片:切换时间/相位单位并显示换算关系。
|
|
||||||
Widget _unitCard(Tokens t) {
|
|
||||||
final UnitSettings u = c.project.units;
|
|
||||||
return Container(
|
|
||||||
padding: const EdgeInsets.all(10),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: t.panel2,
|
|
||||||
borderRadius: BorderRadius.circular(12),
|
|
||||||
border: Border.all(color: t.line),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
|
||||||
children: <Widget>[
|
|
||||||
Row(
|
|
||||||
children: <Widget>[
|
|
||||||
_sectionLabel(t, '工艺单位与精度'),
|
|
||||||
const Spacer(),
|
|
||||||
InkWell(
|
|
||||||
onTap: () => showDialog<void>(
|
|
||||||
context: context, builder: (_) => SettingsDialog(controller: c)),
|
|
||||||
child: Row(
|
|
||||||
children: <Widget>[
|
|
||||||
Icon(Icons.tune, size: 14, color: t.accent),
|
|
||||||
const SizedBox(width: 4),
|
|
||||||
Text('参数', style: TextStyle(color: t.accent, fontSize: 11)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
_unitRow(t, '时间单位', TimeUnit.values.map((TimeUnit x) => (timeUnitLabel(x), x == u.timeUnit)).toList(), (int i) {
|
|
||||||
c.setUnits(c.project.units.copyWith(timeUnit: TimeUnit.values[i]));
|
|
||||||
}),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
_unitRow(t, '相位单位', <(String, bool)>[('°', u.phaseUnit == PhaseUnit.deg), ('%', u.phaseUnit == PhaseUnit.percent)], (int i) {
|
|
||||||
c.setUnits(c.project.units.copyWith(phaseUnit: i == 0 ? PhaseUnit.deg : PhaseUnit.percent));
|
|
||||||
}),
|
|
||||||
const SizedBox(height: 10),
|
|
||||||
Divider(height: 1, color: t.line),
|
|
||||||
const SizedBox(height: 8),
|
|
||||||
Text(
|
|
||||||
'1° = ${tfmtAuto(c.project.cycle.durationMs / 360)} 1% = ${tfmtAuto(c.project.cycle.durationMs / 100)} 1 圈 = ${tfmt(c.project.cycle.durationMs, u)}',
|
|
||||||
style: TextStyle(color: t.dim, fontSize: 10),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 单位选择行:一组互斥的选项按钮。
|
|
||||||
Widget _unitRow(Tokens t, String label, List<(String, bool)> options, ValueChanged<int> onPick) {
|
|
||||||
return Row(
|
|
||||||
children: <Widget>[
|
|
||||||
SizedBox(width: 64, child: Text(label, style: TextStyle(color: t.sub, fontSize: 11))),
|
|
||||||
for (int i = 0; i < options.length; i++)
|
|
||||||
Padding(
|
|
||||||
padding: const EdgeInsets.only(right: 6),
|
|
||||||
child: InkWell(
|
|
||||||
onTap: () => onPick(i),
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
child: Container(
|
|
||||||
width: 54,
|
|
||||||
height: 32,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: options[i].$2 ? t.accent.withValues(alpha: 0.18) : t.panel,
|
|
||||||
borderRadius: BorderRadius.circular(8),
|
|
||||||
border: Border.all(color: options[i].$2 ? t.accent : t.line2),
|
|
||||||
),
|
|
||||||
child: Text(options[i].$1,
|
|
||||||
style: TextStyle(color: options[i].$2 ? t.accent : t.sub, fontSize: 11)),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 右侧栏中的方形编辑工具按钮。
|
|
||||||
Widget _editTool(Tokens t, IconData icon, String label, Color bg, Color fg, VoidCallback onTap, {Color? border}) {
|
|
||||||
return InkWell(
|
|
||||||
onTap: onTap,
|
|
||||||
borderRadius: BorderRadius.circular(9),
|
|
||||||
child: Container(
|
|
||||||
width: 74,
|
|
||||||
height: 58,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: bg,
|
|
||||||
borderRadius: BorderRadius.circular(9),
|
|
||||||
border: Border.all(color: border ?? bg),
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Icon(icon, size: 18, color: fg),
|
|
||||||
const SizedBox(height: 4),
|
|
||||||
Text(label, style: TextStyle(color: fg, fontSize: 10, fontWeight: FontWeight.w600)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 横向加宽的按钮(图标 + 文字)。
|
|
||||||
Widget _wideBtn(Tokens t, IconData icon, String label, Color bg, Color fg, VoidCallback onTap, {Color? border}) {
|
|
||||||
return InkWell(
|
|
||||||
onTap: onTap,
|
|
||||||
borderRadius: BorderRadius.circular(9),
|
|
||||||
child: Container(
|
|
||||||
height: 40,
|
|
||||||
alignment: Alignment.center,
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: bg,
|
|
||||||
borderRadius: BorderRadius.circular(9),
|
|
||||||
border: Border.all(color: border ?? bg),
|
|
||||||
),
|
|
||||||
child: Row(
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
Icon(icon, size: 15, color: fg),
|
|
||||||
const SizedBox(width: 6),
|
|
||||||
Flexible(
|
|
||||||
child: Text(label,
|
|
||||||
maxLines: 1, overflow: TextOverflow.ellipsis, style: TextStyle(color: fg, fontSize: 11)),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 单条依赖展示行:显示前后动作、类型与偏移角,并可删除。
|
/// 单条依赖展示行:显示前后动作、类型与偏移角,并可删除。
|
||||||
Widget _depRow(Tokens t, Action a, Dependency d) {
|
Widget _depRow(Tokens t, Action a, Dependency d) {
|
||||||
final Color col = d.type == DepType.fs ? t.fs : t.ss;
|
final Color col = d.type == DepType.fs ? t.fs : t.ss;
|
||||||
@@ -1923,25 +1637,6 @@ class _AppShellState extends State<AppShell> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 导出入口行(点击触发对应导出流程)。
|
|
||||||
Widget _exportRow(Tokens t, String label, VoidCallback onTap) {
|
|
||||||
return InkWell(
|
|
||||||
onTap: onTap,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
child: Container(
|
|
||||||
height: 42,
|
|
||||||
alignment: Alignment.centerLeft,
|
|
||||||
padding: const EdgeInsets.symmetric(horizontal: 12),
|
|
||||||
decoration: BoxDecoration(
|
|
||||||
color: t.panel2,
|
|
||||||
borderRadius: BorderRadius.circular(10),
|
|
||||||
border: Border.all(color: t.line2),
|
|
||||||
),
|
|
||||||
child: Text(label, style: TextStyle(color: t.sub, fontSize: 11)),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// 右侧栏底部的帮助与快捷键提示卡片。
|
/// 右侧栏底部的帮助与快捷键提示卡片。
|
||||||
Widget _helpCard(Tokens t) {
|
Widget _helpCard(Tokens t) {
|
||||||
return Container(
|
return Container(
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class CanvasOverlays extends StatelessWidget {
|
|||||||
: _CircularPreviewCard(t: t, project: c.project),
|
: _CircularPreviewCard(t: t, project: c.project),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
// 圆周视图右侧浮动工具栏(添加/编辑/复制/删除/改层/对齐/帮助)。
|
// 圆周视图右侧浮动工具栏(添加/编辑/复制/删除/改层/对齐)。
|
||||||
if (circular)
|
if (circular)
|
||||||
Positioned(
|
Positioned(
|
||||||
right: right - 2,
|
right: right - 2,
|
||||||
@@ -177,11 +177,11 @@ class _Title extends StatelessWidget {
|
|||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final String title = circular
|
final String title = circular
|
||||||
? '圆周节拍视图(同心圆 · 12 点钟起始 · 顺时针)'
|
? '圆周时序视图'
|
||||||
: '条形节拍视图(甘特 / 流程图 · 依赖箭头)';
|
: '条形时序视图';
|
||||||
final String sub = circular
|
final String sub = circular
|
||||||
? '同心圆环 = 动作层;箭头 = 执行顺序(绿色实线 FS 严格顺序,琥珀虚线 SS 并行重叠);1 圈 = 1 循环 = ${tfmt(project.cycle.durationMs, project.units)} = 360° = 100%'
|
? '同心圆环 = 动作层;箭头 = 执行顺序(绿色实线 FS 严格顺序,琥珀虚线 SS 并行重叠);1 圈 = 1 循环 = ${tfmt(project.cycle.durationMs, project.units)} = 360° = 100%'
|
||||||
: '时间轴与相位角双刻度联动;箭头表示动作间关联(绿色实线 FS 严格顺序 / 琥珀虚线 SS 并行重叠);跨循环动作自动拆分并标注';
|
: '箭头表示动作之间关联(绿色实线 FS 严格顺序 / 琥珀虚线 SS 并行重叠)';
|
||||||
return Column(
|
return Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -468,7 +468,7 @@ class _StatsButton extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 节拍统计弹窗:汇总循环周期、动作数、关键路径、并行度、
|
/// 节拍统计弹窗:汇总循环周期、动作数、关键路径、并行度、
|
||||||
/// 相位覆盖率、瓶颈工位与预估产能。
|
/// 相位覆盖率与瓶颈工位(仅展示可从当前项目数据推导的指标)。
|
||||||
class _CycleStatsDialog extends StatelessWidget {
|
class _CycleStatsDialog extends StatelessWidget {
|
||||||
const _CycleStatsDialog({required this.t, required this.c});
|
const _CycleStatsDialog({required this.t, required this.c});
|
||||||
|
|
||||||
@@ -483,7 +483,6 @@ class _CycleStatsDialog extends StatelessWidget {
|
|||||||
final UnitSettings u = p.units;
|
final UnitSettings u = p.units;
|
||||||
final List<Action> acts = p.actions;
|
final List<Action> acts = p.actions;
|
||||||
final int stations = p.stations.length;
|
final int stations = p.stations.length;
|
||||||
final double perHour = p.cycle.durationMs > 0 ? 3600 / (p.cycle.durationMs / 1000) : 0;
|
|
||||||
final List<List<String>> stats = <List<String>>[
|
final List<List<String>> stats = <List<String>>[
|
||||||
<String>['循环周期', '${tfmt(p.cycle.durationMs, u)} / 360° / 100%'],
|
<String>['循环周期', '${tfmt(p.cycle.durationMs, u)} / 360° / 100%'],
|
||||||
<String>['动作数量', '${acts.length}($stations 工位)'],
|
<String>['动作数量', '${acts.length}($stations 工位)'],
|
||||||
@@ -491,7 +490,6 @@ class _CycleStatsDialog extends StatelessWidget {
|
|||||||
<String>['最大并行度', _maxParallel(acts)],
|
<String>['最大并行度', _maxParallel(acts)],
|
||||||
<String>['相位覆盖率', _coverage(acts)],
|
<String>['相位覆盖率', _coverage(acts)],
|
||||||
<String>['瓶颈工位', _bottleneck(p)],
|
<String>['瓶颈工位', _bottleneck(p)],
|
||||||
<String>['预估产能', '${perHour.toStringAsFixed(0)} 件/小时(节拍 ${tfmt(p.cycle.durationMs, u)})'],
|
|
||||||
];
|
];
|
||||||
return Dialog(
|
return Dialog(
|
||||||
backgroundColor: t.dialog,
|
backgroundColor: t.dialog,
|
||||||
@@ -601,7 +599,7 @@ class _CycleStatsDialog extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 条形视图编辑工具条:添加 / 编辑 / 复制 / 删除 / 对齐 / 帮助。
|
/// 条形视图编辑工具条:添加 / 编辑 / 复制 / 删除 / 对齐。
|
||||||
class _EditTools extends StatelessWidget {
|
class _EditTools extends StatelessWidget {
|
||||||
const _EditTools({required this.t, required this.c});
|
const _EditTools({required this.t, required this.c});
|
||||||
|
|
||||||
@@ -615,7 +613,7 @@ class _EditTools extends StatelessWidget {
|
|||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return _Card(
|
return _Card(
|
||||||
t: t,
|
t: t,
|
||||||
width: 470,
|
width: 390,
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
@@ -637,10 +635,6 @@ class _EditTools extends StatelessWidget {
|
|||||||
border: t.line2),
|
border: t.line2),
|
||||||
const SizedBox(width: 8),
|
const SizedBox(width: 8),
|
||||||
_tool(t, Icons.align_horizontal_left, '对齐', t.panel, t.sub, c.alignPhase, border: t.line2),
|
_tool(t, Icons.align_horizontal_left, '对齐', t.panel, t.sub, c.alignPhase, border: t.line2),
|
||||||
const SizedBox(width: 8),
|
|
||||||
_tool(t, Icons.help_outline, '帮助', t.panel, t.sub,
|
|
||||||
() => showDialog<void>(context: context, builder: (_) => const HelpDialog()),
|
|
||||||
border: t.line2),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
@@ -674,7 +668,7 @@ class _EditTools extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 圆周视图右侧浮动工具栏:纵向排列的编辑与帮助按钮。
|
/// 圆周视图右侧浮动工具栏:纵向排列的编辑按钮。
|
||||||
class _FloatingToolbar extends StatelessWidget {
|
class _FloatingToolbar extends StatelessWidget {
|
||||||
const _FloatingToolbar({required this.t, required this.c});
|
const _FloatingToolbar({required this.t, required this.c});
|
||||||
|
|
||||||
@@ -737,8 +731,6 @@ class _FloatingToolbar extends StatelessWidget {
|
|||||||
item(Icons.keyboard_arrow_down, '层−', t.panel2, t.sub,
|
item(Icons.keyboard_arrow_down, '层−', t.panel2, t.sub,
|
||||||
() => c.selectedId != null ? c.changeLayer(c.selectedId!, -1) : null, border: t.line),
|
() => c.selectedId != null ? c.changeLayer(c.selectedId!, -1) : null, border: t.line),
|
||||||
item(Icons.align_horizontal_left, '对齐', t.panel2, t.sub, c.alignPhase, border: t.line),
|
item(Icons.align_horizontal_left, '对齐', t.panel2, t.sub, c.alignPhase, border: t.line),
|
||||||
item(Icons.help_outline, '帮助', t.panel2, t.sub,
|
|
||||||
() => showDialog<void>(context: context, builder: (_) => const HelpDialog()), border: t.line),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -270,7 +270,14 @@ class _CanvasViewState extends State<CanvasView> {
|
|||||||
final Action? hit = c.project.viewState.mode == ViewMode.bar
|
final Action? hit = c.project.viewState.mode == ViewMode.bar
|
||||||
? BarLayout(c.project, size).hitTest(p)
|
? BarLayout(c.project, size).hitTest(p)
|
||||||
: CircularLayout(c.project, size).hitTest(p);
|
: CircularLayout(c.project, size).hitTest(p);
|
||||||
if (hit != null) return;
|
// 双击动作色块 / 圆弧:进入该动作的编辑对话框。
|
||||||
|
if (hit != null) {
|
||||||
|
showDialog<void>(
|
||||||
|
context: context,
|
||||||
|
builder: (_) => ActionEditorDialog(controller: c, action: hit),
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
double angle = 0;
|
double angle = 0;
|
||||||
if (c.project.viewState.mode == ViewMode.bar) {
|
if (c.project.viewState.mode == ViewMode.bar) {
|
||||||
angle = BarLayout(c.project, size).angleAt(p.dx);
|
angle = BarLayout(c.project, size).angleAt(p.dx);
|
||||||
|
|||||||
+330
-12
@@ -127,6 +127,26 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
|||||||
setState(() {});
|
setState(() {});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 解析桌面目录:优先 OneDrive 桌面,其次 `%USERPROFILE%\Desktop`。
|
||||||
|
///
|
||||||
|
/// 返回存在的目录;都不存在时返回 null(按钮不产生跳转)。
|
||||||
|
Directory? _desktop() {
|
||||||
|
final String? home = Platform.environment['USERPROFILE'];
|
||||||
|
final String? oneDrive = Platform.environment['OneDrive'];
|
||||||
|
final String sep = Platform.pathSeparator;
|
||||||
|
final List<String> candidates = <String>[
|
||||||
|
if (oneDrive != null && oneDrive.isNotEmpty) '$oneDrive${sep}Desktop',
|
||||||
|
if (home != null && home.isNotEmpty) '$home${sep}Desktop',
|
||||||
|
if (home != null && home.isNotEmpty) '$home${sep}OneDrive${sep}Desktop',
|
||||||
|
];
|
||||||
|
for (final String p in candidates) {
|
||||||
|
try {
|
||||||
|
if (Directory(p).existsSync()) return Directory(p);
|
||||||
|
} catch (_) {}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/// 枚举 Windows 盘符(A–Z)中当前存在的根目录。
|
/// 枚举 Windows 盘符(A–Z)中当前存在的根目录。
|
||||||
List<String> _drives() {
|
List<String> _drives() {
|
||||||
final List<String> out = <String>[];
|
final List<String> out = <String>[];
|
||||||
@@ -189,7 +209,23 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
|||||||
SingleChildScrollView(
|
SingleChildScrollView(
|
||||||
scrollDirection: Axis.horizontal,
|
scrollDirection: Axis.horizontal,
|
||||||
child: Row(
|
child: Row(
|
||||||
children: drives.map((String d) {
|
children: <Widget>[
|
||||||
|
// 桌面快捷入口:导出 / 打开 / 保存时一键跳到桌面。
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.only(right: 6),
|
||||||
|
child: ActionChip(
|
||||||
|
avatar: Icon(Icons.desktop_windows_outlined, size: 15, color: t.accent),
|
||||||
|
label: const Text('桌面'),
|
||||||
|
onPressed: () {
|
||||||
|
final Directory? d = _desktop();
|
||||||
|
if (d != null) {
|
||||||
|
_dir = d;
|
||||||
|
_refresh();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
...drives.map((String d) {
|
||||||
return Padding(
|
return Padding(
|
||||||
padding: const EdgeInsets.only(right: 6),
|
padding: const EdgeInsets.only(right: 6),
|
||||||
child: ActionChip(
|
child: ActionChip(
|
||||||
@@ -200,7 +236,8 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}).toList(),
|
}),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const Divider(),
|
const Divider(),
|
||||||
@@ -778,7 +815,7 @@ class _SettingsDialogState extends State<SettingsDialog> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
const SizedBox(height: 18),
|
const SizedBox(height: 18),
|
||||||
// 循环与相位:循环时长可编辑,起点与方向为固定展示。
|
// 循环与相位:循环时长可编辑,起点与方向为固定展示(顺时针)。
|
||||||
Text('循环与相位', style: TextStyle(color: t.sub, fontSize: 11)),
|
Text('循环与相位', style: TextStyle(color: t.sub, fontSize: 11)),
|
||||||
const SizedBox(height: 8),
|
const SizedBox(height: 8),
|
||||||
Row(
|
Row(
|
||||||
@@ -807,6 +844,7 @@ class _SettingsDialogState extends State<SettingsDialog> {
|
|||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(width: 10),
|
const SizedBox(width: 10),
|
||||||
|
// 旋转方向:固定为顺时针(圆周视图约定)。
|
||||||
Expanded(
|
Expanded(
|
||||||
child: TextField(
|
child: TextField(
|
||||||
controller: TextEditingController(text: '顺时针 CW'),
|
controller: TextEditingController(text: '顺时针 CW'),
|
||||||
@@ -1233,6 +1271,281 @@ class _ZoneRowState extends State<_ZoneRow> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===================== 工位管理对话框 =====================
|
||||||
|
|
||||||
|
/// 工位管理对话框:增删工位、改名称与颜色、调整顺序。
|
||||||
|
///
|
||||||
|
/// 一个流程可能包含多个工位;删除工位后,其原动作会自动改挂到第一个工位。
|
||||||
|
class StationDialog extends StatefulWidget {
|
||||||
|
const StationDialog({super.key, required this.controller});
|
||||||
|
|
||||||
|
/// 全局应用控制器。
|
||||||
|
final AppController controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<StationDialog> createState() => _StationDialogState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _StationDialogState extends State<StationDialog> {
|
||||||
|
late List<Station> _stations;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_stations = List<Station>.of(widget.controller.project.stations);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 生成不冲突的新工位 id(ST{n})。
|
||||||
|
String _nextId() {
|
||||||
|
final Set<String> used = _stations.map((Station s) => s.id).toSet();
|
||||||
|
int n = _stations.length + 1;
|
||||||
|
while (used.contains('ST$n')) {
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
return 'ST$n';
|
||||||
|
}
|
||||||
|
|
||||||
|
void _add() {
|
||||||
|
setState(() {
|
||||||
|
_stations.add(Station(
|
||||||
|
id: _nextId(),
|
||||||
|
name: '工位 ${_stations.length + 1}',
|
||||||
|
order: _stations.length,
|
||||||
|
color: kActionPalette[_stations.length % kActionPalette.length],
|
||||||
|
));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _remove(int i) {
|
||||||
|
if (_stations.length <= 1) return;
|
||||||
|
setState(() => _stations.removeAt(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
void _move(int i, int delta) {
|
||||||
|
final int j = i + delta;
|
||||||
|
if (j < 0 || j >= _stations.length) return;
|
||||||
|
setState(() {
|
||||||
|
final Station s = _stations.removeAt(i);
|
||||||
|
_stations.insert(j, s);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void _save() {
|
||||||
|
// 归一化 order 为列表顺序,保证条形视图按此排序。
|
||||||
|
final List<Station> out = <Station>[
|
||||||
|
for (int i = 0; i < _stations.length; i++) _stations[i].copyWith(order: i),
|
||||||
|
];
|
||||||
|
widget.controller.setStations(out, status: '工位已更新(${out.length} 个)');
|
||||||
|
Navigator.pop(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final Tokens t = context.tok;
|
||||||
|
return Dialog(
|
||||||
|
backgroundColor: t.dialog,
|
||||||
|
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(14)),
|
||||||
|
child: scaledDialogBox(
|
||||||
|
context,
|
||||||
|
640,
|
||||||
|
560,
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(16),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: <Widget>[
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Icon(Icons.precision_manufacturing_outlined, size: 18, color: t.accent),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text('工位管理', style: TextStyle(fontSize: 15, fontWeight: FontWeight.w700, color: t.text)),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Expanded(
|
||||||
|
child: Text('可增删工位、改名称与颜色、调整顺序;删除工位后其动作自动改挂到第一个工位',
|
||||||
|
style: TextStyle(fontSize: 10, color: t.dim)),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
const Divider(height: 20),
|
||||||
|
Expanded(
|
||||||
|
child: ListView.builder(
|
||||||
|
itemCount: _stations.length,
|
||||||
|
itemBuilder: (BuildContext ctx, int i) {
|
||||||
|
return _StationRow(
|
||||||
|
key: ValueKey<String>(_stations[i].id),
|
||||||
|
t: t,
|
||||||
|
station: _stations[i],
|
||||||
|
first: i == 0,
|
||||||
|
last: i == _stations.length - 1,
|
||||||
|
canDelete: _stations.length > 1,
|
||||||
|
onChanged: (Station s) => setState(() => _stations[i] = s),
|
||||||
|
onMoveUp: () => _move(i, -1),
|
||||||
|
onMoveDown: () => _move(i, 1),
|
||||||
|
onDelete: () => _remove(i),
|
||||||
|
);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const Divider(height: 20),
|
||||||
|
Row(
|
||||||
|
children: <Widget>[
|
||||||
|
OutlinedButton.icon(
|
||||||
|
onPressed: _add,
|
||||||
|
icon: const Icon(Icons.add, size: 16),
|
||||||
|
label: const Text('添加工位'),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 10),
|
||||||
|
Text('共 ${_stations.length} 个工位', style: TextStyle(color: t.dim, fontSize: 11)),
|
||||||
|
const Spacer(),
|
||||||
|
TextButton(onPressed: () => Navigator.pop(context), child: const Text('取消')),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
FilledButton(onPressed: _save, child: const Text('确定')),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 工位管理中的单行:颜色、id、名称、排序与删除。
|
||||||
|
class _StationRow extends StatefulWidget {
|
||||||
|
const _StationRow({
|
||||||
|
super.key,
|
||||||
|
required this.t,
|
||||||
|
required this.station,
|
||||||
|
required this.first,
|
||||||
|
required this.last,
|
||||||
|
required this.canDelete,
|
||||||
|
required this.onChanged,
|
||||||
|
required this.onMoveUp,
|
||||||
|
required this.onMoveDown,
|
||||||
|
required this.onDelete,
|
||||||
|
});
|
||||||
|
|
||||||
|
final Tokens t;
|
||||||
|
final Station station;
|
||||||
|
final bool first;
|
||||||
|
final bool last;
|
||||||
|
final bool canDelete;
|
||||||
|
final ValueChanged<Station> onChanged;
|
||||||
|
final VoidCallback onMoveUp;
|
||||||
|
final VoidCallback onMoveDown;
|
||||||
|
final VoidCallback onDelete;
|
||||||
|
|
||||||
|
@override
|
||||||
|
State<_StationRow> createState() => _StationRowState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _StationRowState extends State<_StationRow> {
|
||||||
|
late final TextEditingController _name;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
super.initState();
|
||||||
|
_name = TextEditingController(text: widget.station.name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
_name.dispose();
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
final Tokens t = widget.t;
|
||||||
|
return Padding(
|
||||||
|
padding: const EdgeInsets.only(bottom: 8),
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
// 颜色:点击弹出调色板。
|
||||||
|
PopupMenuButton<int>(
|
||||||
|
tooltip: '选择颜色',
|
||||||
|
onSelected: (int c) => widget.onChanged(widget.station.copyWith(color: c)),
|
||||||
|
itemBuilder: (BuildContext ctx) => kActionPalette
|
||||||
|
.map((int c) => PopupMenuItem<int>(
|
||||||
|
value: c,
|
||||||
|
height: 36,
|
||||||
|
child: Row(
|
||||||
|
children: <Widget>[
|
||||||
|
Container(
|
||||||
|
width: 18,
|
||||||
|
height: 18,
|
||||||
|
decoration: BoxDecoration(color: Color(c), borderRadius: BorderRadius.circular(5)),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Text('#${c.toRadixString(16).padLeft(8, '0').substring(2).toUpperCase()}',
|
||||||
|
style: TextStyle(color: t.text, fontSize: 11)),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
))
|
||||||
|
.toList(),
|
||||||
|
child: Container(
|
||||||
|
width: 30,
|
||||||
|
height: 30,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Color(widget.station.color),
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: t.line2),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Container(
|
||||||
|
width: 44,
|
||||||
|
height: 30,
|
||||||
|
alignment: Alignment.center,
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: t.panel2,
|
||||||
|
borderRadius: BorderRadius.circular(8),
|
||||||
|
border: Border.all(color: t.line),
|
||||||
|
),
|
||||||
|
child: Text(widget.station.id, style: TextStyle(color: t.sub, fontSize: 11, fontWeight: FontWeight.w600)),
|
||||||
|
),
|
||||||
|
const SizedBox(width: 8),
|
||||||
|
Expanded(
|
||||||
|
child: TextField(
|
||||||
|
controller: _name,
|
||||||
|
onChanged: (String v) => widget.onChanged(
|
||||||
|
widget.station.copyWith(name: v.trim().isEmpty ? widget.station.name : v.trim())),
|
||||||
|
style: TextStyle(color: t.text, fontSize: 11.5),
|
||||||
|
decoration: InputDecoration(
|
||||||
|
isDense: true,
|
||||||
|
hintText: '工位名称',
|
||||||
|
hintStyle: TextStyle(color: t.dim, fontSize: 11),
|
||||||
|
filled: true,
|
||||||
|
fillColor: t.panel2,
|
||||||
|
border: OutlineInputBorder(borderRadius: BorderRadius.circular(8)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: widget.first ? null : widget.onMoveUp,
|
||||||
|
icon: const Icon(Icons.keyboard_arrow_up, size: 18),
|
||||||
|
splashRadius: 15,
|
||||||
|
tooltip: '上移',
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: widget.last ? null : widget.onMoveDown,
|
||||||
|
icon: const Icon(Icons.keyboard_arrow_down, size: 18),
|
||||||
|
splashRadius: 15,
|
||||||
|
tooltip: '下移',
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
onPressed: widget.canDelete ? widget.onDelete : null,
|
||||||
|
icon: Icon(Icons.delete_outline, size: 17, color: widget.canDelete ? t.danger : t.dim),
|
||||||
|
splashRadius: 16,
|
||||||
|
tooltip: widget.canDelete ? '删除工位' : '至少保留一个工位',
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ===================== 帮助中心对话框 =====================
|
// ===================== 帮助中心对话框 =====================
|
||||||
|
|
||||||
/// 帮助中心对话框:以四个标签页展示快速开始、快捷键、
|
/// 帮助中心对话框:以四个标签页展示快速开始、快捷键、
|
||||||
@@ -1288,15 +1601,16 @@ class HelpDialog extends StatelessWidget {
|
|||||||
<String>['我要新建方案', '顶部「新建」创建空白节拍;「打开」载入 .seq.json。'],
|
<String>['我要新建方案', '顶部「新建」创建空白节拍;「打开」载入 .seq.json。'],
|
||||||
<String>['我要先看看示例', '首次启动载入 2 个动作的示例节拍,可直接修改。'],
|
<String>['我要先看看示例', '首次启动载入 2 个动作的示例节拍,可直接修改。'],
|
||||||
<String>['我要新增动作', '双击画布空白处在点击相位新增;或左侧「新建」在 0° 新增(默认最外层)。'],
|
<String>['我要新增动作', '双击画布空白处在点击相位新增;或左侧「新建」在 0° 新增(默认最外层)。'],
|
||||||
<String>['我要删除动作', '选中后:左侧「删除」/ 行内删除图标 / 右侧删除 / Delete 键 / 右键菜单。'],
|
<String>['我要删除动作', '选中后:左侧「删除」/ 行内删除图标 / Delete 键 / 右键菜单;至少保留一个动作 / 泳道。'],
|
||||||
<String>['我要改动作属性', '选中动作 → 右侧「编辑」,可改名称、工位、驱动与颜色。'],
|
<String>['我要改动作属性', '双击画布色块(条形块 / 圆弧)或左侧动作行 → 打开动作编辑对话框;也可选中后点左侧行内编辑图标。'],
|
||||||
<String>['我要复制 / 对齐', '右侧「编辑操作」→「复制」/「对齐相位」;圆周视图还可改层。'],
|
<String>['我要复制 / 对齐', '画布左下角「编辑工具」→「复制」/「对齐」;圆周视图右侧浮动工具条同款。'],
|
||||||
|
<String>['我要编辑工位', '左侧「动作和执行编辑」→「编辑工位」:可增删工位、改名称与颜色、上下调整顺序;删除工位后其动作自动改挂到第一个工位。'],
|
||||||
<String>['一条泳道放多个动作', '泳道/轨道=一个执行器:上下拖拽(条形)或 Shift+径向拖拽(圆周)换道;不重叠即可共存,标题合并显示(/ 分隔,≤2 行)。'],
|
<String>['一条泳道放多个动作', '泳道/轨道=一个执行器:上下拖拽(条形)或 Shift+径向拖拽(圆周)换道;不重叠即可共存,标题合并显示(/ 分隔,≤2 行)。'],
|
||||||
]),
|
]),
|
||||||
// 目标:调整时间轴与动作间的先后 / 并行关系。
|
// 目标:调整时间轴与动作间的先后 / 并行关系。
|
||||||
_section(t, <List<String>>[
|
_section(t, <List<String>>[
|
||||||
<String>['我要改时间轴长度', '点左侧项目卡的「循环 …」,或按 F2 →「循环与相位」→ 循环时长 → 应用。'],
|
<String>['我要改时间轴长度', '左侧「时序创建和编辑」→「编辑时序与节拍参数」,或按 F2 →「循环与相位」→ 循环时长 → 应用。'],
|
||||||
<String>['我要调相位 / 时长', '拖动动作块平移相位;拖条形右端改持续角;右侧滑杆可精调。'],
|
<String>['我要调相位 / 时长', '拖动动作块平移相位;拖条形右端改持续角;圆周视图拖弧两端改起止角;右侧滑杆可精调。'],
|
||||||
<String>['我要让动作跨循环', '使「起始角 + 持续角 > 360°」,会自动拆分并以半透明虚线渲染尾段。'],
|
<String>['我要让动作跨循环', '使「起始角 + 持续角 > 360°」,会自动拆分并以半透明虚线渲染尾段。'],
|
||||||
<String>['我要加前置依赖(输入)', '右侧「前置依赖 · 输入」→「添加前置依赖」;或右键动作 →「添加依赖」。'],
|
<String>['我要加前置依赖(输入)', '右侧「前置依赖 · 输入」→「添加前置依赖」;或右键动作 →「添加依赖」。'],
|
||||||
<String>['一个动作多输入', '可重复添加多条前置依赖,逐条列出、逐条可删。'],
|
<String>['一个动作多输入', '可重复添加多条前置依赖,逐条列出、逐条可删。'],
|
||||||
@@ -1306,9 +1620,10 @@ class HelpDialog extends StatelessWidget {
|
|||||||
// 目标:编辑相位分区并控制画布显示。
|
// 目标:编辑相位分区并控制画布显示。
|
||||||
_section(t, <List<String>>[
|
_section(t, <List<String>>[
|
||||||
<String>['相位分区是什么', '把一个循环按角度分成的命名工艺阶段(默认上料/夹紧/加工/检测/下料),条形图顶部标注带即它。'],
|
<String>['相位分区是什么', '把一个循环按角度分成的命名工艺阶段(默认上料/夹紧/加工/检测/下料),条形图顶部标注带即它。'],
|
||||||
<String>['我要编辑相位分区', 'F2 →「相位分区」→「编辑…」:增删分区、改名称与起止角;可重叠、可留空、>360° 表示跨圈。'],
|
<String>['我要编辑相位分区', '左侧「动作和执行编辑」→「编辑相位分区」;或 F2 →「相位分区」→「编辑…」。增删分区、改名称与起止角;可重叠、可留空、>360° 表示跨圈。'],
|
||||||
<String>['我要隐藏相位分区', '左侧「显示选项」取消勾选「相位分区标注」。'],
|
<String>['我要隐藏相位分区', '左侧「显示选项」取消勾选「相位分区标注」。'],
|
||||||
<String>['我要切换视图', '顶部「条形节拍 / 圆周节拍」分段开关,两种视图共享同一份数据。'],
|
<String>['刻度怎么读', '条形视图:分区带与刻度线之间上排为相位、下排为等价时间;圆周视图:每 30° 的度数外侧标注等价时间。'],
|
||||||
|
<String>['我要切换视图', '顶部「条形节拍 / 圆周节拍」分段开关,两种视图共享同一份数据;标题分别为「条形时序视图」「圆周时序视图」。'],
|
||||||
<String>['我要缩放 / 平移', 'Ctrl+滚轮 以光标为锚点缩放;普通滚轮或拖拽空白平移。'],
|
<String>['我要缩放 / 平移', 'Ctrl+滚轮 以光标为锚点缩放;普通滚轮或拖拽空白平移。'],
|
||||||
<String>['我要完整显示', '顶部「适应视图」:自动按内容(含刻度、箭头、跨圈标注)计算缩放与居中,编辑后也不会被裁切。'],
|
<String>['我要完整显示', '顶部「适应视图」:自动按内容(含刻度、箭头、跨圈标注)计算缩放与居中,编辑后也不会被裁切。'],
|
||||||
<String>['我要开关标注', '左侧「显示选项」逐项开关双刻度、依赖箭头、圆环背景、层标注、跨循环高亮等。'],
|
<String>['我要开关标注', '左侧「显示选项」逐项开关双刻度、依赖箭头、圆环背景、层标注、跨循环高亮等。'],
|
||||||
@@ -1317,7 +1632,7 @@ class HelpDialog extends StatelessWidget {
|
|||||||
_section(t, <List<String>>[
|
_section(t, <List<String>>[
|
||||||
<String>['我要 AI 生成', '顶部「AI 生成」→ 填 DeepSeek API Key → 选模型(Flash / Pro)→ 选强度(高 / 最高)→ 用自然语言描述 → 生成。'],
|
<String>['我要 AI 生成', '顶部「AI 生成」→ 填 DeepSeek API Key → 选模型(Flash / Pro)→ 选强度(高 / 最高)→ 用自然语言描述 → 生成。'],
|
||||||
<String>['生成效果不好', '描述里写清:循环时长、工位数、各动作时长、哪些顺序(完成后启动)、哪些并行。'],
|
<String>['生成效果不好', '描述里写清:循环时长、工位数、各动作时长、哪些顺序(完成后启动)、哪些并行。'],
|
||||||
<String>['我要看节拍统计', '画布左下角「节拍统计」按钮 → 弹窗查看关键路径、并行度、瓶颈工位、产能等。'],
|
<String>['我要看节拍统计', '画布左下角「节拍统计」按钮 → 弹窗查看循环周期、动作数、关键路径、最大并行度、相位覆盖率与瓶颈工位(仅展示可从项目数据推导的指标)。'],
|
||||||
<String>['我要导出 SVG', '顶部「导出 SVG」:矢量、分层、带语义 id 与 data-*,可直接进工艺卡 / MES。'],
|
<String>['我要导出 SVG', '顶部「导出 SVG」:矢量、分层、带语义 id 与 data-*,可直接进工艺卡 / MES。'],
|
||||||
<String>['我要导出 PNG', '顶部「导出 PNG」:按 2 倍像素比导出当前画布为位图。'],
|
<String>['我要导出 PNG', '顶部「导出 PNG」:按 2 倍像素比导出当前画布为位图。'],
|
||||||
<String>['我要保存 / 恢复', '「保存」写入 .seq.json 并生成 .bak;每 5 秒自动快照,异常退出后启动可恢复。'],
|
<String>['我要保存 / 恢复', '「保存」写入 .seq.json 并生成 .bak;每 5 秒自动快照,异常退出后启动可恢复。'],
|
||||||
@@ -1328,9 +1643,12 @@ class HelpDialog extends StatelessWidget {
|
|||||||
<String>['我要钉住侧栏', '侧栏标题右侧图钉:钉住=固定占位;取消钉住=悬浮,鼠标移开自动收起。'],
|
<String>['我要钉住侧栏', '侧栏标题右侧图钉:钉住=固定占位;取消钉住=悬浮,鼠标移开自动收起。'],
|
||||||
<String>['边缘把手', '侧栏收起后画布边缘有细把手:悬停临时展开,点击固定显示。'],
|
<String>['边缘把手', '侧栏收起后画布边缘有细把手:悬停临时展开,点击固定显示。'],
|
||||||
<String>['拖拽 / 缩放', '左键拖拽平移相位;拖端点改时长;Shift+拖拽改层;Ctrl+滚轮缩放。'],
|
<String>['拖拽 / 缩放', '左键拖拽平移相位;拖端点改时长;Shift+拖拽改层;Ctrl+滚轮缩放。'],
|
||||||
|
<String>['双击编辑', '双击画布色块(条形块 / 圆弧)或左侧动作行 → 打开动作编辑对话框。'],
|
||||||
<String>['右键动作', '菜单:添加依赖 / 改层 / 复制 / 删除。'],
|
<String>['右键动作', '菜单:添加依赖 / 改层 / 复制 / 删除。'],
|
||||||
<String>['撤销 / 保存', 'Ctrl+Z / Ctrl+Y 撤销重做;Ctrl+S 保存;Ctrl+O / Ctrl+N 打开 / 新建。'],
|
<String>['撤销 / 保存', 'Ctrl+Z / Ctrl+Y 撤销重做;Ctrl+S 保存;Ctrl+O / Ctrl+N 打开 / 新建。'],
|
||||||
<String>['其它', 'F1 帮助;F2 工艺参数(含相位分区);F3 切换深/浅主题;Delete 删除选中动作。'],
|
<String>['帮助入口', '顶部工具栏右侧「?」或 F1 打开帮助中心;画布编辑工具条不重复放置帮助按钮。'],
|
||||||
|
<String>['导出入口', '导出 SVG / PNG 统一放在顶部工具栏右侧,避免多处重复。'],
|
||||||
|
<String>['其它', 'F2 编辑时序与节拍参数(含单位与相位分区);F3 切换深/浅主题;Delete 删除选中动作。'],
|
||||||
]),
|
]),
|
||||||
// 关于:设计人、版本与版权声明。
|
// 关于:设计人、版本与版权声明。
|
||||||
_section(t, <List<String>>[
|
_section(t, <List<String>>[
|
||||||
|
|||||||
+11
-7
@@ -5,14 +5,18 @@ setlocal
|
|||||||
|
|
||||||
set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
|
set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
|
||||||
set PUB_HOSTED_URL=https://pub.flutter-io.cn
|
set PUB_HOSTED_URL=https://pub.flutter-io.cn
|
||||||
set PATH=E:\flutter\bin;%PATH%
|
|
||||||
|
|
||||||
if exist E:\cmake-lv\bin\cmk2.exe (
|
rem NOTE: avoid `if (...)` blocks here -- %PATH% contains parentheses
|
||||||
set FLUTTER_CMAKE_PATH=E:\cmake-lv\bin\cmk2.exe
|
rem (e.g. "Program Files (x86)") which break cmd block parsing.
|
||||||
) else (
|
set FLUTTER_BIN=D:\flutter\bin
|
||||||
echo [warn] renamed CMake not found: E:\cmake-lv\bin\cmk2.exe
|
if not exist D:\flutter\bin\flutter.bat set FLUTTER_BIN=E:\flutter\bin
|
||||||
echo [warn] if a transparent-encryption DLP is installed, run scripts\setup-cmake.bat first.
|
set PATH=%FLUTTER_BIN%;%PATH%
|
||||||
)
|
|
||||||
|
set FLUTTER_CMAKE_PATH=
|
||||||
|
if exist D:\cmake-lv\bin\cmk2.exe set FLUTTER_CMAKE_PATH=D:\cmake-lv\bin\cmk2.exe
|
||||||
|
if exist E:\cmake-lv\bin\cmk2.exe set FLUTTER_CMAKE_PATH=E:\cmake-lv\bin\cmk2.exe
|
||||||
|
if "%FLUTTER_CMAKE_PATH%"=="" echo [warn] renamed CMake not found: D:\cmake-lv\bin\cmk2.exe
|
||||||
|
if "%FLUTTER_CMAKE_PATH%"=="" echo [warn] if a transparent-encryption DLP is installed, run scripts\setup-cmake.bat first.
|
||||||
|
|
||||||
cd /d "%~dp0.."
|
cd /d "%~dp0.."
|
||||||
rem --no-tree-shake-icons: bundle the full Material icon font so newly used
|
rem --no-tree-shake-icons: bundle the full Material icon font so newly used
|
||||||
|
|||||||
+8
-1
@@ -4,8 +4,15 @@ setlocal
|
|||||||
|
|
||||||
set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
|
set FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
|
||||||
set PUB_HOSTED_URL=https://pub.flutter-io.cn
|
set PUB_HOSTED_URL=https://pub.flutter-io.cn
|
||||||
set PATH=E:\flutter\bin;%PATH%
|
|
||||||
|
|
||||||
|
rem NOTE: avoid `if (...)` blocks here -- %PATH% contains parentheses
|
||||||
|
rem (e.g. "Program Files (x86)") which break cmd block parsing.
|
||||||
|
set FLUTTER_BIN=D:\flutter\bin
|
||||||
|
if not exist D:\flutter\bin\flutter.bat set FLUTTER_BIN=E:\flutter\bin
|
||||||
|
set PATH=%FLUTTER_BIN%;%PATH%
|
||||||
|
|
||||||
|
set FLUTTER_CMAKE_PATH=
|
||||||
|
if exist D:\cmake-lv\bin\cmk2.exe set FLUTTER_CMAKE_PATH=D:\cmake-lv\bin\cmk2.exe
|
||||||
if exist E:\cmake-lv\bin\cmk2.exe set FLUTTER_CMAKE_PATH=E:\cmake-lv\bin\cmk2.exe
|
if exist E:\cmake-lv\bin\cmk2.exe set FLUTTER_CMAKE_PATH=E:\cmake-lv\bin\cmk2.exe
|
||||||
|
|
||||||
cd /d "%~dp0.."
|
cd /d "%~dp0.."
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
|
import 'package:sequence_diagram/model/models.dart';
|
||||||
|
import 'package:sequence_diagram/state/app_controller.dart';
|
||||||
|
|
||||||
|
void main() {
|
||||||
|
group('station management', () {
|
||||||
|
test('setStations reassigns actions of a removed station', () {
|
||||||
|
final AppController c = AppController(project: Project.demo());
|
||||||
|
expect(c.project.stations.length, 2);
|
||||||
|
final String removed = c.project.stations[1].id;
|
||||||
|
expect(c.project.actions.any((Action a) => a.stationId == removed), isTrue);
|
||||||
|
|
||||||
|
c.setStations(<Station>[c.project.stations.first]);
|
||||||
|
|
||||||
|
expect(c.project.stations.length, 1);
|
||||||
|
expect(c.project.actions.every((Action a) => a.stationId == c.project.stations.first.id), isTrue);
|
||||||
|
expect(c.canUndo, isTrue);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('setStations ignores an empty list (keep at least one station)', () {
|
||||||
|
final AppController c = AppController(project: Project.demo());
|
||||||
|
final int before = c.project.stations.length;
|
||||||
|
c.setStations(<Station>[]);
|
||||||
|
expect(c.project.stations.length, before);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('setStations can add and rename stations', () {
|
||||||
|
final AppController c = AppController(project: Project.demo());
|
||||||
|
final List<Station> next = <Station>[
|
||||||
|
...c.project.stations,
|
||||||
|
const Station(id: 'ST3', name: '工位 3', order: 2, color: 0xFF4ADE80),
|
||||||
|
];
|
||||||
|
c.setStations(next);
|
||||||
|
expect(c.project.stations.length, 3);
|
||||||
|
expect(c.project.stationById('ST3')?.name, '工位 3');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
+87
-55
@@ -1,11 +1,18 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""Generate the Sequence Diagram Studio application icon.
|
"""Generate the Sequence Diagram Studio application icon.
|
||||||
|
|
||||||
A clock / cycle dial that reflects the product spirit: one turn = one cycle,
|
Original mark, designed for this product ("Cycle-Step" / 环序):
|
||||||
12 o'clock origin, clockwise phase progression.
|
|
||||||
|
|
||||||
Design note: the badge uses a **bright cyan→violet gradient** with a **white
|
1. A rounded square tile with a deep navy gradient — a neutral stage that
|
||||||
clock** so the icon stays legible on both light and dark taskbars.
|
stays legible on both light and dark Windows taskbars.
|
||||||
|
2. A **gapped ring**: one turn = one cycle = 360 deg; the gap at the top
|
||||||
|
marks the 0 deg origin (12 o'clock).
|
||||||
|
3. A **step-function polyline**: the sequence of actions advancing in time
|
||||||
|
(a timing/step chart, which is exactly what this tool draws).
|
||||||
|
4. An **origin dot** sitting in the ring gap, plus a terminal node dot.
|
||||||
|
|
||||||
|
Everything is composed from primitive geometry (ring, polyline, circles) and
|
||||||
|
does not reproduce, trace, or approximate any existing brand mark.
|
||||||
|
|
||||||
Outputs:
|
Outputs:
|
||||||
windows/runner/resources/app_icon.ico (multi-size, for the Windows build)
|
windows/runner/resources/app_icon.ico (multi-size, for the Windows build)
|
||||||
@@ -21,18 +28,29 @@ OUT_ICO = os.path.join(ROOT, "windows", "runner", "resources", "app_icon.ico")
|
|||||||
OUT_PNG = os.path.join(ROOT, "demo", "app-icon.png")
|
OUT_PNG = os.path.join(ROOT, "demo", "app-icon.png")
|
||||||
|
|
||||||
S = 1024
|
S = 1024
|
||||||
BG_TOP = (76, 201, 240, 255) # #4CC9F0 cyan
|
INSET = 56 # transparent margin around the tile
|
||||||
BG_BOT = (124, 92, 255, 255) # #7C5CFF violet
|
TILE = S - 2 * INSET
|
||||||
WHITE = (255, 255, 255, 255)
|
|
||||||
WHITE_SOFT = (255, 255, 255, 170)
|
TILE_TOP = (24, 33, 61, 255) # #18213D
|
||||||
NAVY = (11, 16, 24, 255) # #0B1018
|
TILE_BOT = (12, 18, 38, 255) # #0C1226
|
||||||
EDGE = (255, 255, 255, 90)
|
EDGE = (255, 255, 255, 38)
|
||||||
|
RING = (76, 201, 240, 255) # #4CC9F0 accent cyan
|
||||||
|
STEP = (255, 209, 102, 255) # #FFD166 amber
|
||||||
|
ORIGIN = (255, 255, 255, 255)
|
||||||
|
END = (52, 211, 153, 255) # #34D399
|
||||||
|
|
||||||
|
CX = CY = S // 2
|
||||||
|
|
||||||
|
|
||||||
def lerp(a, b, t):
|
def lerp(a, b, t):
|
||||||
return tuple(round(a[i] + (b[i] - a[i]) * t) for i in range(4))
|
return tuple(round(a[i] + (b[i] - a[i]) * t) for i in range(4))
|
||||||
|
|
||||||
|
|
||||||
|
def polar(cx, cy, r, deg):
|
||||||
|
t = math.radians(deg - 90)
|
||||||
|
return (cx + r * math.cos(t), cy + r * math.sin(t))
|
||||||
|
|
||||||
|
|
||||||
def rounded_mask(size, radius, inset=0):
|
def rounded_mask(size, radius, inset=0):
|
||||||
m = Image.new("L", (size, size), 0)
|
m = Image.new("L", (size, size), 0)
|
||||||
d = ImageDraw.Draw(m)
|
d = ImageDraw.Draw(m)
|
||||||
@@ -44,76 +62,90 @@ def rounded_mask(size, radius, inset=0):
|
|||||||
return m
|
return m
|
||||||
|
|
||||||
|
|
||||||
def polar(cx, cy, r, deg):
|
def draw_ring(img, r_ring, ring_w, gap_deg, color):
|
||||||
t = math.radians(deg - 90)
|
"""Draw a circular arc with a gap centred at 12 o'clock and round caps."""
|
||||||
return (cx + r * math.cos(t), cy + r * math.sin(t))
|
outer = r_ring + ring_w / 2
|
||||||
|
inner = r_ring - ring_w / 2
|
||||||
|
mask = Image.new("L", (S, S), 0)
|
||||||
|
md = ImageDraw.Draw(mask)
|
||||||
|
md.ellipse([CX - outer, CY - outer, CX + outer, CY + outer], fill=255)
|
||||||
|
md.ellipse([CX - inner, CY - inner, CX + inner, CY + inner], fill=0)
|
||||||
|
# Cut the gap wedge (centred on the top, i.e. -90 deg).
|
||||||
|
a0 = polar(CX, CY, outer + 8, -90 - gap_deg / 2)
|
||||||
|
a1 = polar(CX, CY, outer + 8, -90 + gap_deg / 2)
|
||||||
|
md.polygon([(CX, CY), a0, a1], fill=0)
|
||||||
|
# Round caps at both arc ends.
|
||||||
|
for deg in (-90 + gap_deg / 2, -90 - gap_deg / 2):
|
||||||
|
p = polar(CX, CY, r_ring, deg)
|
||||||
|
md.ellipse([p[0] - ring_w / 2, p[1] - ring_w / 2,
|
||||||
|
p[0] + ring_w / 2, p[1] + ring_w / 2], fill=255)
|
||||||
|
img.paste(color, (0, 0), mask)
|
||||||
|
|
||||||
|
|
||||||
def build_master():
|
def draw_steps(img, pts, width, color):
|
||||||
|
"""Draw a step polyline with rounded joins and caps."""
|
||||||
|
d = ImageDraw.Draw(img)
|
||||||
|
d.line(pts, fill=color, width=width, joint="curve")
|
||||||
|
for p in pts:
|
||||||
|
d.ellipse([p[0] - width / 2, p[1] - width / 2,
|
||||||
|
p[0] + width / 2, p[1] + width / 2], fill=color)
|
||||||
|
|
||||||
|
|
||||||
|
def build_master(simplified=False):
|
||||||
img = Image.new("RGBA", (S, S), (0, 0, 0, 0))
|
img = Image.new("RGBA", (S, S), (0, 0, 0, 0))
|
||||||
|
|
||||||
# Bright gradient body.
|
# --- tile with a vertical navy gradient ---
|
||||||
body = Image.new("RGBA", (S, S), (0, 0, 0, 0))
|
body = Image.new("RGBA", (S, S), (0, 0, 0, 0))
|
||||||
bd = ImageDraw.Draw(body)
|
bd = ImageDraw.Draw(body)
|
||||||
for y in range(S):
|
for y in range(S):
|
||||||
bd.line([(0, y), (S, y)], fill=lerp(BG_TOP, BG_BOT, y / (S - 1)))
|
bd.line([(0, y), (S, y)], fill=lerp(TILE_TOP, TILE_BOT, y / (S - 1)))
|
||||||
mask = rounded_mask(S, 210, inset=48)
|
img.paste(body, (0, 0), rounded_mask(S, int(0.27 * TILE), inset=INSET))
|
||||||
img.paste(body, (0, 0), mask)
|
ImageDraw.Draw(img).rounded_rectangle(
|
||||||
|
[INSET, INSET, S - 1 - INSET, S - 1 - INSET],
|
||||||
draw = ImageDraw.Draw(img)
|
radius=int(0.27 * TILE),
|
||||||
# Subtle inner edge to separate from the taskbar.
|
|
||||||
draw.rounded_rectangle(
|
|
||||||
[48, 48, S - 1 - 48, S - 1 - 48],
|
|
||||||
radius=210,
|
|
||||||
outline=EDGE,
|
outline=EDGE,
|
||||||
width=5,
|
width=5,
|
||||||
)
|
)
|
||||||
|
|
||||||
cx = cy = S // 2
|
# --- mark ---
|
||||||
r_ring = 300
|
r_ring = 0.293 * TILE
|
||||||
ring_w = 40
|
ring_w = (0.085 if simplified else 0.062) * TILE
|
||||||
|
draw_ring(img, r_ring, ring_w, 68, RING)
|
||||||
|
|
||||||
# White outer ring (the cycle).
|
# origin dot in the ring gap (0 deg / 12 o'clock)
|
||||||
draw.ellipse(
|
d = ImageDraw.Draw(img)
|
||||||
[cx - r_ring - ring_w // 2, cy - r_ring - ring_w // 2,
|
od = (0.050 if simplified else 0.042) * TILE
|
||||||
cx + r_ring + ring_w // 2, cy + r_ring + ring_w // 2],
|
op = (CX, CY - r_ring)
|
||||||
outline=WHITE,
|
d.ellipse([op[0] - od, op[1] - od, op[0] + od, op[1] + od], fill=ORIGIN)
|
||||||
width=ring_w,
|
|
||||||
)
|
|
||||||
|
|
||||||
# 12 tick marks; 12/3/6/9 are longer and thicker.
|
# step-function polyline (sequence of actions)
|
||||||
for d in range(0, 360, 30):
|
sw = (0.085 if simplified else 0.057) * TILE
|
||||||
major = d % 90 == 0
|
p1 = (CX - 0.146 * TILE, CY + 0.088 * TILE)
|
||||||
r1 = r_ring - 96
|
p2 = (CX - 0.010 * TILE, CY + 0.088 * TILE)
|
||||||
r2 = r_ring - (52 if major else 74)
|
p3 = (CX - 0.010 * TILE, CY - 0.059 * TILE)
|
||||||
draw.line(
|
p4 = (CX + 0.166 * TILE, CY - 0.059 * TILE)
|
||||||
[polar(cx, cy, r1, d), polar(cx, cy, r2, d)],
|
draw_steps(img, [p1, p2, p3, p4], int(sw), STEP)
|
||||||
fill=WHITE if major else WHITE_SOFT,
|
|
||||||
width=16 if major else 9,
|
|
||||||
)
|
|
||||||
|
|
||||||
# Clock hands: classic 10:10 pose, navy for contrast on white.
|
# terminal node dot
|
||||||
for r, deg, col, w in ((170, 305, NAVY, 34), (240, 55, NAVY, 26)):
|
ed = (0.050 if simplified else 0.037) * TILE
|
||||||
hx, hy = polar(cx, cy, r, deg)
|
d.ellipse([p4[0] - ed, p4[1] - ed, p4[0] + ed, p4[1] + ed], fill=END)
|
||||||
draw.line([(cx, cy), (hx, hy)], fill=col, width=w)
|
|
||||||
draw.ellipse([hx - w / 2, hy - w / 2, hx + w / 2, hy + w / 2], fill=col)
|
|
||||||
|
|
||||||
# Hub.
|
|
||||||
draw.ellipse([cx - 30, cy - 30, cx + 30, cy + 30], fill=NAVY)
|
|
||||||
draw.ellipse([cx - 12, cy - 12, cx + 12, cy + 12], fill=WHITE)
|
|
||||||
|
|
||||||
return img
|
return img
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
master = build_master()
|
master = build_master(False)
|
||||||
|
small = build_master(True)
|
||||||
os.makedirs(os.path.dirname(OUT_ICO), exist_ok=True)
|
os.makedirs(os.path.dirname(OUT_ICO), exist_ok=True)
|
||||||
os.makedirs(os.path.dirname(OUT_PNG), exist_ok=True)
|
os.makedirs(os.path.dirname(OUT_PNG), exist_ok=True)
|
||||||
|
|
||||||
master.save(OUT_PNG)
|
master.save(OUT_PNG)
|
||||||
|
|
||||||
sizes = [256, 128, 64, 48, 32, 24, 16]
|
sizes = [256, 128, 64, 48, 32, 24, 16]
|
||||||
frames = [master.resize((s, s), Image.LANCZOS) for s in sizes]
|
frames = []
|
||||||
|
for s in sizes:
|
||||||
|
src = small if s <= 32 else master
|
||||||
|
frames.append(src.resize((s, s), Image.LANCZOS))
|
||||||
frames[0].save(
|
frames[0].save(
|
||||||
OUT_ICO,
|
OUT_ICO,
|
||||||
format="ICO",
|
format="ICO",
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 46 KiB After Width: | Height: | Size: 39 KiB |
Reference in New Issue
Block a user