feat: 原创「环序」标志;双视图与侧栏优化;工位管理;帮助完善
- 原创应用标志「环序/Cycle-Step」:tools/gen-icon.py 重写 + 工具栏 Logo 同源,小尺寸简化版 - 条形时序视图:标题/副标题精简、双刻度值置于分区与刻度线之间、时间默认内嵌、依赖线箭头收窄、同泳道箭头接色块外侧、图注自动避让 - 圆周时序视图:去掉色块描边、环宽与间隙优化、度数外侧标时间、方向箭头外移;固定顺时针(移除逆时针) - 左侧栏:编辑工位/编辑相位分区入口;双击画布色块或动作行进入编辑;至少保留一个动作/泳道 - 右侧栏:移除重复的编辑操作、导出与单位卡片;文件浏览器新增「桌面」快捷入口 - AI 对话框:字号优化并新增「编辑示例」;节拍统计移除无依据的预估产能 - 文档:README 与 docs/HELP.md 全面更新;dist 同步重建
This commit is contained in:
+11
-10
@@ -105,10 +105,11 @@ class BarLayout {
|
||||
/// 参数 [project]:项目数据;[size]:可用画布尺寸。
|
||||
/// 副作用:初始化 [pitch]。
|
||||
BarLayout(this.project, this.size) {
|
||||
// 可用高度 = 总高 - 顶部留白 - 底部预留;按**泳道数**均分并夹取到 [46, 66]。
|
||||
// 可用高度 = 总高 - 顶部留白 - 底部预留;按**泳道数**均分并夹取到 [44, 52],
|
||||
// 让相邻泳道之间的空隙刚好容纳依赖箭头与其图注。
|
||||
final int n = lanes.length;
|
||||
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;
|
||||
|
||||
/// 单个动作条的高度(像素):与 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;
|
||||
@@ -218,11 +219,11 @@ class CircularLayout {
|
||||
final int layers = lanes.length;
|
||||
// 最大半径受较短边约束,减去 74px 留给刻度与边距。
|
||||
final double maxR = math.min(size.width, size.height) / 2 - 74;
|
||||
// 在 r0 与 maxR 之间均分各轨道,环间距夹取到 [24, 46]。
|
||||
pitch = layers <= 1 ? 40 : ((maxR - r0) / (layers - 1)).clamp(24, 46);
|
||||
// 动作环带宽度:相对行距收窄(约 0.56),并夹取到 [12, 26],
|
||||
// 让环与环之间留出呼吸空间、文字仍能容纳。
|
||||
ringWidth = (pitch * 0.56).clamp(12, 26);
|
||||
// 在 r0 与 maxR 之间均分各轨道,环间距夹取到 [32, 52]:
|
||||
// 让相邻环之间留出足够空隙放置依赖箭头与图注。
|
||||
pitch = layers <= 1 ? 44 : ((maxR - r0) / (layers - 1)).clamp(32, 52);
|
||||
// 动作环带宽度:只求容纳文字(约 15–18px),环更窄、环间空隙更宽。
|
||||
ringWidth = (pitch * 0.45).clamp(15, 18);
|
||||
}
|
||||
|
||||
/// 布局所依据的项目数据。
|
||||
|
||||
+83
-63
@@ -71,9 +71,13 @@ class BarPainter extends CustomPainter {
|
||||
final bool dropValid;
|
||||
|
||||
/// 标尺横线所在的 y 坐标(画布坐标)。
|
||||
static const double axisTop = 138;
|
||||
static const double axisTop = 164;
|
||||
/// 相位色带的顶部 y 坐标。
|
||||
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,
|
||||
);
|
||||
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);
|
||||
_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 - 14, axisTop + 44),
|
||||
// 轴单位图例:与对应刻度值同排,置于最左侧。
|
||||
_text(canvas, '相位 / ${phaseUnitLabel(u.phaseUnit)}', Offset(layout.plotLeft - 12, phaseValY),
|
||||
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° 使用 [Tokens.ok]、360° 使用 [Tokens.warn] 的虚线竖线表示,
|
||||
/// 并在下方标注“循环开始 / 循环结束”。虚线由 [_dashedLine] 手工分段绘制。
|
||||
/// 0° 使用 [Tokens.ok]、360° 使用 [Tokens.warn] 的虚线竖线表示;
|
||||
/// 不再额外标注文字(坐标轴已能说明起止)。虚线由 [_dashedLine] 手工分段绘制。
|
||||
void _boundaries(Canvas canvas, BarLayout layout) {
|
||||
for (final double d in <double>[0, 360]) {
|
||||
final double x = layout.xFor(d);
|
||||
@@ -224,14 +230,6 @@ class BarPainter extends CustomPainter {
|
||||
..color = col.withValues(alpha: 0.7)
|
||||
..strokeWidth = 1.4;
|
||||
_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.plotRight, y + BarLayout.rowVisual - 4),
|
||||
Paint()
|
||||
..color = tokens.line.withValues(alpha: 0.5)
|
||||
..color = tokens.line2.withValues(alpha: 0.6)
|
||||
..strokeWidth = 1,
|
||||
);
|
||||
// 该泳道内的所有动作条(互不重叠)。
|
||||
@@ -373,16 +371,18 @@ class BarPainter extends CustomPainter {
|
||||
Offset(layout.plotLeft + wx + 18, r.center.dy), color: tokens.warn, size: 10);
|
||||
}
|
||||
final double durMs = a.durationAngle / 360 * cycle;
|
||||
if (r.width > 150) {
|
||||
_text(canvas, a.name, Offset(r.left + 10, r.center.dy - 5),
|
||||
final String full = '${a.name} ${tfmt(durMs, u)}';
|
||||
// 默认「名称 + 时长」一起写在条块内、紧跟名称之后(单行,条块更苗条);
|
||||
// 仅当条块太短、放不下时才移到条块外侧。
|
||||
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);
|
||||
_text(canvas, tfmt(durMs, u), Offset(r.left + 10, r.center.dy + 7),
|
||||
color: tokens.arcText.withValues(alpha: 0.8), size: 10);
|
||||
} else if (r.right + 170 > layout.plotRight) {
|
||||
_text(canvas, '${a.name} ${tfmt(durMs, u)}', Offset(r.left - 10, r.center.dy),
|
||||
} else if (r.right + 190 > layout.plotRight) {
|
||||
_text(canvas, full, Offset(r.left - 10, r.center.dy),
|
||||
color: c, size: 11, weight: FontWeight.w600, align: TextAlign.right);
|
||||
} 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);
|
||||
}
|
||||
_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 Color col = d.type == DepType.fs ? tokens.fs : tokens.ss;
|
||||
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 rb = layout.rectFor(to);
|
||||
const double barHalf = BarLayout.barH / 2;
|
||||
final double sy = ra.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 gapY = ty - dir * 23;
|
||||
final double tipY = ty - dir * 15;
|
||||
// 箭头落点:目标条块靠源一侧外缘再留 3px。
|
||||
final double tipY = ty - dir * (barHalf + 3);
|
||||
|
||||
final Path p = Path();
|
||||
double chipX;
|
||||
double chipY;
|
||||
// 同一泳道内的依赖(源/目标同 y):水平直线连接,标签置于线上方。
|
||||
Offset arrowTip;
|
||||
Offset arrowDir;
|
||||
// 同一泳道内的依赖(源/目标同 y):箭头连接两色块的外侧边缘。
|
||||
final bool sameLane = (ty - sy).abs() < 1;
|
||||
if (sameLane) {
|
||||
p.moveTo(ex, sy);
|
||||
p.lineTo(tx, sy);
|
||||
chipX = (ex + tx) / 2;
|
||||
chipY = sy - 14;
|
||||
final bool fs = d.type == DepType.fs;
|
||||
final double startX = fs ? ra.right + 2 : ra.left - 2;
|
||||
double endX = rb.left - 2;
|
||||
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) {
|
||||
chipY = gapY;
|
||||
p.moveTo(ex, sy + dir * 13);
|
||||
p.lineTo(ex, gapY);
|
||||
p.lineTo(tx, gapY);
|
||||
p.lineTo(tx, tipY - dir * 12);
|
||||
// 相邻泳道:在两泳道之间的空隙中线走水平线,箭头指向目标条块。
|
||||
final double mid = (sy + ty) / 2;
|
||||
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;
|
||||
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;
|
||||
chipY = mid;
|
||||
if ((tx - ex).abs() < chipW + 10) chipX = tx + chipW / 2 + 6;
|
||||
} 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 minLeft = double.infinity;
|
||||
final List<int> lanes = layout.lanes;
|
||||
@@ -461,15 +482,18 @@ class BarPainter extends CustomPainter {
|
||||
if (lane > layout.plotRight - 16) {
|
||||
lane = math.min(math.min(sx, tx), minLeft) - 28 - (k % 3) * 16;
|
||||
}
|
||||
final double srcGapY = sy + dir * 27;
|
||||
p.moveTo(ex, sy + dir * 13);
|
||||
final double srcGapY = sy + dir * (barHalf + 14);
|
||||
final double gapY = ty - dir * (barHalf + 6);
|
||||
p.moveTo(ex, sy + dir * (barHalf + 2));
|
||||
p.lineTo(ex, srcGapY);
|
||||
p.lineTo(lane, srcGapY);
|
||||
p.lineTo(lane, 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;
|
||||
chipY = gapY;
|
||||
chipY = gapY - (barHalf + 1);
|
||||
}
|
||||
// 关键路径依赖:先铺一层加粗低透明度光晕,再画主线。
|
||||
if (crit) {
|
||||
@@ -477,7 +501,7 @@ class BarPainter extends CustomPainter {
|
||||
p,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 9
|
||||
..strokeWidth = 5
|
||||
..strokeCap = StrokeCap.round
|
||||
..color = col.withValues(alpha: 0.18),
|
||||
);
|
||||
@@ -486,18 +510,13 @@ class BarPainter extends CustomPainter {
|
||||
p,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = crit ? 2.2 : 1.7
|
||||
..strokeWidth = crit ? 1.1 : 0.85
|
||||
..strokeCap = StrokeCap.round
|
||||
..color = col.withValues(alpha: 0.95),
|
||||
);
|
||||
if (sameLane) {
|
||||
_arrow(canvas, Offset(tx, sy), const Offset(1, 0), col);
|
||||
} else {
|
||||
_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);
|
||||
_arrow(canvas, arrowTip, arrowDir, col);
|
||||
// 标签置于依赖线旁,避免压住箭头。
|
||||
_chip(canvas, Offset(chipX, chipY), label, col, crit);
|
||||
k++;
|
||||
}
|
||||
}
|
||||
@@ -507,7 +526,7 @@ class BarPainter extends CustomPainter {
|
||||
///
|
||||
/// 参数 [col] 为填充色;[dir] 只需提供方向(本函数不归一化,直接按分量使用)。
|
||||
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 n = Offset(-dir.dy, dir.dx) * s * 0.5;
|
||||
final Path p = Path()
|
||||
@@ -523,27 +542,28 @@ class BarPainter extends CustomPainter {
|
||||
/// 参数 [center]:胶囊中心;[label]:文字;[col]:边框与文字色;
|
||||
/// [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);
|
||||
const double h = 18;
|
||||
// 图注字号与刻度文字接近,整体更紧凑。
|
||||
final TextPainter tp = _tp(label, 9.5, col, FontWeight.w600);
|
||||
final double w = tp.width + 14 + (crit ? 15 : 0);
|
||||
const double h = 15;
|
||||
final Rect r = Rect.fromCenter(center: center, width: w, height: h);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(r, const Radius.circular(6)),
|
||||
RRect.fromRectAndRadius(r, const Radius.circular(5)),
|
||||
Paint()..color = tokens.chip,
|
||||
);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(r, const Radius.circular(6)),
|
||||
RRect.fromRectAndRadius(r, const Radius.circular(5)),
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1
|
||||
..color = col,
|
||||
);
|
||||
if (crit) {
|
||||
canvas.drawCircle(Offset(r.left + 9, center.dy), 7, Paint()..color = tokens.crit);
|
||||
_text(canvas, '★', Offset(r.left + 9, center.dy), color: tokens.onAccent, size: 10, align: TextAlign.center);
|
||||
tp.paint(canvas, Offset(r.left + 20, center.dy - tp.height / 2));
|
||||
canvas.drawCircle(Offset(r.left + 8, center.dy), 6, Paint()..color = tokens.crit);
|
||||
_text(canvas, '★', Offset(r.left + 8, center.dy), color: tokens.onAccent, size: 9, align: TextAlign.center);
|
||||
tp.paint(canvas, Offset(r.left + 16, center.dy - tp.height / 2));
|
||||
} 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 '../model/models.dart';
|
||||
import '../model/units.dart';
|
||||
import '../theme/tokens.dart';
|
||||
|
||||
/// 圆形视图的 [CustomPainter] 实现。
|
||||
@@ -118,9 +119,6 @@ class CircularPainter extends CustomPainter {
|
||||
// 相位分区环:在最外动作环与刻度环之间画一圈分区色带并标注名称。
|
||||
if (project.viewState.showPhaseBands) _phaseRing(canvas, layout);
|
||||
|
||||
// 象限辅助线(0°/90°/180°/270°)。
|
||||
_quadrants(canvas, c, layout);
|
||||
|
||||
// 轨道标签:为每条轨道挑选一个空位角度,避免压住该轨道的动作弧。
|
||||
if (project.viewState.showLayerLabels) {
|
||||
for (int i = 0; i < layers; i++) {
|
||||
@@ -148,9 +146,9 @@ class CircularPainter extends CustomPainter {
|
||||
// 拖拽端点时的径向虚线参考。
|
||||
if (guideAngle != null) _guide(canvas, layout);
|
||||
|
||||
// 起点标记、顺时针方向提示与外围刻度。
|
||||
// 起点标记、循环方向提示与外围刻度。
|
||||
_startMarker(canvas, layout);
|
||||
_cwArrow(canvas, layout);
|
||||
_directionArrow(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;
|
||||
}
|
||||
|
||||
/// 绘制 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 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(
|
||||
p,
|
||||
Paint()
|
||||
@@ -446,7 +422,7 @@ class CircularPainter extends CustomPainter {
|
||||
p,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 9
|
||||
..strokeWidth = 5
|
||||
..strokeCap = StrokeCap.round
|
||||
..color = col.withValues(alpha: 0.2),
|
||||
);
|
||||
@@ -455,7 +431,7 @@ class CircularPainter extends CustomPainter {
|
||||
p,
|
||||
Paint()
|
||||
..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
|
||||
..color = col,
|
||||
);
|
||||
@@ -482,7 +458,7 @@ class CircularPainter extends CustomPainter {
|
||||
final double len = dir.distance;
|
||||
if (len < 0.001) return;
|
||||
final Offset u = dir / len;
|
||||
const double s = 12;
|
||||
const double s = 6;
|
||||
final Offset b = tip - u * s;
|
||||
final Offset n = Offset(-u.dy, u.dx) * s * 0.5;
|
||||
final Path p = Path()
|
||||
@@ -535,40 +511,46 @@ class CircularPainter extends CustomPainter {
|
||||
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 double r = layout.tickR + 56;
|
||||
final Path p = arcPath(c, r, 20, 70);
|
||||
// 放在度数 / 时间两排标签之外,避免箭头与文字相撞。
|
||||
final double r = layout.tickR + 72;
|
||||
canvas.drawPath(
|
||||
p,
|
||||
arcPath(c, r, 25, 60),
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 2.4
|
||||
..strokeWidth = 1.8
|
||||
..strokeCap = StrokeCap.round
|
||||
..color = tokens.accent2,
|
||||
);
|
||||
final Offset t1 = polar(c, r, 74);
|
||||
final Offset t2 = polar(c, r + 14, 68);
|
||||
final Offset t3 = polar(c, r - 14, 66);
|
||||
final Path a = Path()
|
||||
..moveTo(t1.dx, t1.dy)
|
||||
..lineTo(t2.dx, t2.dy)
|
||||
..lineTo(t3.dx, t3.dy)
|
||||
// 箭头指向弧的终点,方向与切线一致(顺时针)。
|
||||
const double te = 60;
|
||||
final double trad = te * math.pi / 180;
|
||||
final Offset tip = polar(c, r, te);
|
||||
final Offset tan = Offset(math.cos(trad), math.sin(trad));
|
||||
const double s = 7;
|
||||
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();
|
||||
canvas.drawPath(a, Paint()..color = tokens.accent2);
|
||||
final Offset label = polar(c, r + 30, 45);
|
||||
_text(canvas, '顺时针 CW', label, color: tokens.accent2, size: 11, align: TextAlign.center, weight: FontWeight.w600);
|
||||
canvas.drawPath(head, Paint()..color = tokens.accent2);
|
||||
_text(canvas, '顺时针 CW', polar(c, r + 20, 42),
|
||||
color: tokens.accent2, size: 10, align: TextAlign.center, weight: FontWeight.w600);
|
||||
}
|
||||
|
||||
/// 绘制外围角度刻度。
|
||||
///
|
||||
/// 每 5° 一个刻度,10° 为中刻度,30° 为主刻度并标注度数;
|
||||
/// 90° 的整数倍使用强调色加粗,便于快速定位象限。
|
||||
/// 90° 的整数倍使用强调色加粗。度数外侧再标注等价的绝对时间。
|
||||
void _ticks(Canvas canvas, CircularLayout layout) {
|
||||
final Offset c = layout.center;
|
||||
final double r = layout.tickR;
|
||||
final UnitSettings u = project.units;
|
||||
final double cycle = project.cycle.durationMs;
|
||||
for (int d = 0; d < 360; d += 5) {
|
||||
final bool major = d % 30 == 0;
|
||||
final bool mid = d % 10 == 0;
|
||||
@@ -582,12 +564,16 @@ class CircularPainter extends CustomPainter {
|
||||
..color = major ? tokens.line2 : tokens.line,
|
||||
);
|
||||
if (major) {
|
||||
final Offset lp = polar(c, r + 38, d.toDouble());
|
||||
final Offset lp = polar(c, r + 34, d.toDouble());
|
||||
_text(canvas, '$d°', lp,
|
||||
color: d % 90 == 0 ? tokens.accent : tokens.sub,
|
||||
size: 10,
|
||||
align: TextAlign.center,
|
||||
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();
|
||||
}
|
||||
|
||||
/// 替换工位列表(名称 / 颜色 / 顺序 / 数量均可改)。
|
||||
///
|
||||
/// 若某个动作引用的工位被移除,则自动改挂到列表中的第一个工位,
|
||||
/// 保证「动作 → 工位」引用始终有效。空列表会被忽略(至少保留一个工位)。
|
||||
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}) {
|
||||
_project = _project.copyWith(phaseZones: zones);
|
||||
@@ -518,6 +538,11 @@ class AppController extends ChangeNotifier {
|
||||
/// 若 [id] 不存在则直接返回(不产生历史记录)。副作用:若被删动作处于选中
|
||||
/// 状态则清除选中,记录历史并重算关键路径。
|
||||
void deleteAction(String id) {
|
||||
// 至少保留一个动作 / 泳道:最后一个动作不可删除。
|
||||
if (_project.actions.length <= 1) {
|
||||
setStatus('至少保留一个动作 / 泳道,无法删除');
|
||||
return;
|
||||
}
|
||||
// 过滤掉目标动作,并从其余动作的依赖中移除与目标相关的边。
|
||||
final List<Action> actions = _project.actions
|
||||
.where((Action a) => a.id != id)
|
||||
|
||||
+40
-18
@@ -30,6 +30,12 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
||||
/// 会话内复用的 API Key(不持久化)。
|
||||
static String _sessionKey = '';
|
||||
|
||||
/// 示例描述:与输入框灰色占位一致,可一键填入后直接编辑。
|
||||
static const String _examplePrompt =
|
||||
'一条装配线,循环 2.4 秒。上料后定位夹紧,夹紧完成再伺服下压 0.6 秒;'
|
||||
'下压完成后并行进行超声波焊接与视觉检测;检测完成分选下料,最后清洁吹气。'
|
||||
'共 3 个工位,请给出动作、相位与依赖关系。';
|
||||
|
||||
late final TextEditingController _key;
|
||||
late final TextEditingController _prompt;
|
||||
|
||||
@@ -92,26 +98,26 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
||||
// 标题
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Icon(Icons.auto_awesome, size: 20, color: t.accent2),
|
||||
Icon(Icons.auto_awesome, size: 21, color: t.accent2),
|
||||
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(),
|
||||
Text('自然语言 → 时序图', style: TextStyle(color: t.dim, fontSize: 10)),
|
||||
Text('自然语言 → 时序图', style: TextStyle(color: t.dim, fontSize: 11.5)),
|
||||
],
|
||||
),
|
||||
const Divider(height: 22),
|
||||
|
||||
// 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),
|
||||
TextField(
|
||||
controller: _key,
|
||||
obscureText: _obscure,
|
||||
style: TextStyle(color: t.text, fontSize: 11),
|
||||
style: TextStyle(color: t.text, fontSize: 12.5),
|
||||
decoration: InputDecoration(
|
||||
isDense: true,
|
||||
hintText: 'sk-...',
|
||||
hintStyle: TextStyle(color: t.dim, fontSize: 11),
|
||||
hintStyle: TextStyle(color: t.dim, fontSize: 12.5),
|
||||
filled: true,
|
||||
fillColor: t.panel2,
|
||||
prefixIcon: Icon(Icons.key, size: 16, color: t.dim),
|
||||
@@ -133,7 +139,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text('模型', style: TextStyle(color: t.sub, fontSize: 11)),
|
||||
Text('模型', style: TextStyle(color: t.sub, fontSize: 12.5)),
|
||||
const SizedBox(height: 6),
|
||||
Container(
|
||||
height: 38,
|
||||
@@ -148,7 +154,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
||||
isExpanded: true,
|
||||
underline: const SizedBox.shrink(),
|
||||
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),
|
||||
items: kAiModels
|
||||
.map((AiModelOption m) =>
|
||||
@@ -167,7 +173,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
Text('推理强度', style: TextStyle(color: t.sub, fontSize: 11)),
|
||||
Text('推理强度', style: TextStyle(color: t.sub, fontSize: 12.5)),
|
||||
const SizedBox(height: 6),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
@@ -184,7 +190,25 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
||||
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),
|
||||
Expanded(
|
||||
child: Container(
|
||||
@@ -199,12 +223,10 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
||||
maxLines: null,
|
||||
expands: true,
|
||||
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(
|
||||
hintText: '例如:一条装配线,循环 2.4 秒。上料后定位夹紧,夹紧完成再伺服下压 0.6 秒;'
|
||||
'下压完成后并行进行超声波焊接与视觉检测;检测完成分选下料,最后清洁吹气。'
|
||||
'共 3 个工位,请给出动作、相位与依赖关系。',
|
||||
hintStyle: TextStyle(color: t.dim, fontSize: 11, height: 1.5),
|
||||
hintText: '例如:$_examplePrompt',
|
||||
hintStyle: TextStyle(color: t.dim, fontSize: 12.5, height: 1.6),
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -219,7 +241,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
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),
|
||||
@@ -230,7 +252,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
||||
Expanded(
|
||||
child: Text(
|
||||
'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('取消')),
|
||||
@@ -275,7 +297,7 @@ class _AiGenerateDialogState extends State<AiGenerateDialog> {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
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)),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
+85
-48
@@ -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 'package:flutter/material.dart';
|
||||
|
||||
import '../theme/tokens.dart';
|
||||
|
||||
/// 应用图标:一个简洁的时钟 / 周期表盘标记,呼应产品“节拍”主题。
|
||||
/// 应用标志:原创「环序」标记,可在工具栏与启动画面复用。
|
||||
class AppLogo extends StatelessWidget {
|
||||
/// 创建应用图标;[size] 为正方形边长,默认 30。
|
||||
/// 创建应用标志;[size] 为正方形边长,默认 30。
|
||||
const AppLogo({super.key, this.size = 30});
|
||||
|
||||
/// 图标边长(逻辑像素)。
|
||||
/// 标志边长(逻辑像素)。
|
||||
final double size;
|
||||
|
||||
/// 使用 [_LogoPainter] 在方形画布上绘制图标。
|
||||
/// 使用 [_LogoPainter] 在方形画布上绘制标志。
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final Tokens t = context.tok;
|
||||
return CustomPaint(
|
||||
size: Size.square(size),
|
||||
painter: _LogoPainter(t),
|
||||
painter: _LogoPainter(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// 图标绘制器:按主题令牌绘制圆角底板、双色圆弧表盘与指针。
|
||||
/// 标志绘制器:底板 → 缺口圆环 → 原点 → 阶梯折线 → 末端节点。
|
||||
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);
|
||||
|
||||
/// 当前主题令牌,提供配色。
|
||||
final Tokens t;
|
||||
/// 缺口圆环的角度半宽(度):缺口总宽 68°。
|
||||
static const double _gapHalfDeg = 34;
|
||||
|
||||
/// 依次绘制:圆角底板 → 双色圆环弧 → 时针分针 → 中心圆点。
|
||||
/// 按上述构成绘制标志。
|
||||
@override
|
||||
void paint(Canvas canvas, Size size) {
|
||||
// 以最短边为基准计算尺寸,保证图标始终为正方形。
|
||||
final double s = size.shortestSide;
|
||||
final Offset c = Offset(size.width / 2, size.height / 2);
|
||||
// 圆角方形底板:半透明填充 + 主题色描边。
|
||||
|
||||
// 1) 圆角方形底板 + 顶部到底部的深蓝渐变。
|
||||
final RRect badge = RRect.fromRectAndRadius(
|
||||
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(
|
||||
badge,
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1.2
|
||||
..color = t.accent,
|
||||
..strokeWidth = s * 0.018
|
||||
..color = Colors.white.withValues(alpha: 0.14),
|
||||
);
|
||||
|
||||
// 表盘圆环:用两段不同颜色的圆弧表示进度/周期。
|
||||
final double r = s * 0.30;
|
||||
final Paint ring = Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = s * 0.075
|
||||
..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);
|
||||
// 2) 顶部带缺口的圆环:从 +34° 顺时针扫过 292°。
|
||||
final double ringR = s * 0.293;
|
||||
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
|
||||
..strokeWidth = ringW
|
||||
..strokeCap = StrokeCap.round
|
||||
..color = _ring,
|
||||
);
|
||||
|
||||
// 指针:一根主色长针 + 一根强调色短针,从中心向外绘制。
|
||||
final Paint hand = Paint()
|
||||
..strokeCap = StrokeCap.round
|
||||
..strokeWidth = s * 0.085;
|
||||
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(Offset(c.dx, c.dy - ringR), s * 0.042, Paint()..color = _origin);
|
||||
|
||||
// 中心轴点:外圈文字色、内圈背景色,形成中空圆点。
|
||||
canvas.drawCircle(c, s * 0.055, Paint()..color = t.text);
|
||||
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
|
||||
bool shouldRepaint(covariant _LogoPainter old) => old.t != t;
|
||||
bool shouldRepaint(covariant _LogoPainter old) => false;
|
||||
}
|
||||
|
||||
+103
-408
@@ -282,29 +282,6 @@ class _AppShellState extends State<AppShell> {
|
||||
/// 构建顶部工具栏:左侧为品牌与文件/编辑操作,右侧为导出、缩放、
|
||||
/// 单位、侧栏开关与主题切换。根据可用宽度在完整布局与紧凑布局间切换。
|
||||
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(
|
||||
height: 54,
|
||||
padding: const EdgeInsets.symmetric(horizontal: 6),
|
||||
@@ -344,7 +321,7 @@ class _AppShellState extends State<AppShell> {
|
||||
final List<Widget> left;
|
||||
final List<Widget> right;
|
||||
if (!compact) {
|
||||
// 完整布局:文字按钮 + 文件状态胶囊。
|
||||
// 完整布局:文件 / 编辑操作图标化 + 分段视图切换。
|
||||
left = <Widget>[
|
||||
const AppLogo(size: 32),
|
||||
const SizedBox(width: 10),
|
||||
@@ -358,20 +335,13 @@ class _AppShellState extends State<AppShell> {
|
||||
],
|
||||
),
|
||||
const SizedBox(width: 18),
|
||||
_ghost(t, '新建', _newProject),
|
||||
_ghost(t, '打开', _open),
|
||||
_ghost(t, '保存', _save),
|
||||
_iconBtn(t, Icons.note_add_outlined, _newProject, tooltip: '新建 Ctrl+N'),
|
||||
_iconBtn(t, Icons.folder_open_outlined, _open, tooltip: '打开 Ctrl+O'),
|
||||
_iconBtn(t, Icons.save_outlined, _save, tooltip: '保存 Ctrl+S'),
|
||||
const SizedBox(width: 6),
|
||||
_ghost(t, '撤销', c.canUndo ? c.undo : null, icon: Icons.undo),
|
||||
_ghost(t, '重做', c.canRedo ? c.redo : null, icon: Icons.redo),
|
||||
_iconBtn(t, Icons.undo, c.canUndo ? c.undo : null, tooltip: '撤销 Ctrl+Z'),
|
||||
_iconBtn(t, Icons.redo, c.canRedo ? c.redo : null, tooltip: '重做 Ctrl+Y'),
|
||||
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),
|
||||
const SizedBox(width: 12),
|
||||
_segmented(t),
|
||||
@@ -383,12 +353,10 @@ class _AppShellState extends State<AppShell> {
|
||||
const SizedBox(width: 6),
|
||||
_zoomBox(t),
|
||||
const SizedBox(width: 6),
|
||||
_ghost(t, '适应视图', c.fitView),
|
||||
_iconBtn(t, Icons.crop_free, c.fitView, tooltip: '适应视图'),
|
||||
const SizedBox(width: 8),
|
||||
_unitDropdown(t),
|
||||
const SizedBox(width: 8),
|
||||
fileChip,
|
||||
const SizedBox(width: 8),
|
||||
sideToggleLeft,
|
||||
sideToggleRight,
|
||||
_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.redo, c.canRedo ? c.redo : null, tooltip: '重做 Ctrl+Y'),
|
||||
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 生成」文字,避免认不出。
|
||||
_aiBtn(t),
|
||||
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) {
|
||||
return FilledButton(
|
||||
@@ -839,7 +762,6 @@ class _AppShellState extends State<AppShell> {
|
||||
/// 构建左侧栏:项目概览、动作/工位列表、视图模式、显示选项、
|
||||
/// 工位负载与操作提示。[floating] 为 true 时以悬浮卡片样式呈现。
|
||||
Widget _leftPanel(Tokens t, {bool floating = false}) {
|
||||
final List<Action> actions = c.project.actions;
|
||||
final bool bar = c.project.viewState.mode == ViewMode.bar;
|
||||
return Container(
|
||||
width: 300,
|
||||
@@ -857,116 +779,72 @@ class _AppShellState extends State<AppShell> {
|
||||
children: <Widget>[
|
||||
Row(
|
||||
children: <Widget>[
|
||||
_sectionLabel(t, '节拍周期设置'),
|
||||
_sectionLabel(t, '时序创建和编辑'),
|
||||
const Spacer(),
|
||||
_panelControls(t, true),
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 8),
|
||||
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>[
|
||||
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>(
|
||||
context: context,
|
||||
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),
|
||||
Icon(Icons.edit, size: 12, color: t.accent),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 8),
|
||||
Text('动作 ${actions.length} · 依赖 ${_depCount()}',
|
||||
style: TextStyle(color: t.dim, fontSize: 10.5)),
|
||||
],
|
||||
),
|
||||
],
|
||||
_editEntry(
|
||||
t,
|
||||
icon: Icons.edit_note,
|
||||
label: '编辑时序与节拍参数',
|
||||
onTap: () => showDialog<void>(
|
||||
context: context,
|
||||
builder: (_) => SettingsDialog(controller: c),
|
||||
),
|
||||
),
|
||||
const SizedBox(height: 12),
|
||||
// 较浅的分隔横线,区分上方「时序创建和编辑」与下方「动作和执行编辑」。
|
||||
const SizedBox(height: 14),
|
||||
Divider(height: 1, thickness: 1, color: t.line),
|
||||
const SizedBox(height: 14),
|
||||
Row(
|
||||
children: <Widget>[
|
||||
Flexible(
|
||||
child: _sectionLabel(t, bar ? '动作 / 执行器泳道' : '动作列表(按轨道 L1→L${c.project.laneCount})'),
|
||||
),
|
||||
const Spacer(),
|
||||
// 用 Expanded 占满剩余空间,标题不会被无谓地省略成「…」。
|
||||
Expanded(child: _sectionLabel(t, '动作和执行编辑')),
|
||||
_headerAction(t, Icons.add, '新建', t.ok, t.onAccent, () => c.addAction(startAngle: 0)),
|
||||
const SizedBox(width: 6),
|
||||
// 至少保留一个动作 / 泳道:只剩一个时禁用删除。
|
||||
_headerAction(
|
||||
t,
|
||||
Icons.delete_outline,
|
||||
'删除',
|
||||
t.danger,
|
||||
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),
|
||||
// 按泳道 / 轨道分组:同一泳道内的多个动作合并显示(最多两行,/ 分隔)。
|
||||
..._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),
|
||||
_sectionLabel(t, '视图模式'),
|
||||
const SizedBox(height: 8),
|
||||
@@ -981,25 +859,6 @@ class _AppShellState extends State<AppShell> {
|
||||
_sectionLabel(t, '显示选项'),
|
||||
const SizedBox(height: 6),
|
||||
..._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),
|
||||
_sectionLabel(t, '工位负载 / 相位占用'),
|
||||
const SizedBox(height: 10),
|
||||
@@ -1034,9 +893,53 @@ class _AppShellState extends State<AppShell> {
|
||||
s,
|
||||
maxLines: 1,
|
||||
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 时按钮呈禁用态(降低不透明度),用于「未选中动作时禁用删除」。
|
||||
@@ -1100,6 +1003,9 @@ class _AppShellState extends State<AppShell> {
|
||||
toggle: HardwareKeyboard.instance.isControlPressed ||
|
||||
HardwareKeyboard.instance.isShiftPressed,
|
||||
),
|
||||
// 双击泳道行直接编辑该泳道的主动作。
|
||||
onDoubleTap: () => showDialog<void>(
|
||||
context: context, builder: (_) => ActionEditorDialog(controller: c, action: primary)),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Container(
|
||||
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 8),
|
||||
@@ -1193,6 +1099,9 @@ class _AppShellState extends State<AppShell> {
|
||||
toggle: HardwareKeyboard.instance.isControlPressed ||
|
||||
HardwareKeyboard.instance.isShiftPressed,
|
||||
),
|
||||
// 双击动作行直接进入编辑。
|
||||
onDoubleTap: () => showDialog<void>(
|
||||
context: context, builder: (_) => ActionEditorDialog(controller: c, action: a)),
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
child: Container(
|
||||
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),
|
||||
),
|
||||
),
|
||||
// 选中该动作时才出现删除入口,避免误触。
|
||||
if (sel) ...<Widget>[
|
||||
// 选中该动作时才出现删除入口;至少保留一个动作 / 泳道。
|
||||
if (sel && c.project.actions.length > 1) ...<Widget>[
|
||||
const SizedBox(width: 4),
|
||||
InkWell(
|
||||
onTap: () => c.deleteAction(a.id),
|
||||
@@ -1446,61 +1355,6 @@ class _AppShellState extends State<AppShell> {
|
||||
(double v) => c.setActionDuration(a.id, v * 180)),
|
||||
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),
|
||||
// 输入依赖:允许多条(多前置)。
|
||||
_sectionLabel(t, '前置依赖 · 输入(${a.deps.length})'),
|
||||
@@ -1532,14 +1386,6 @@ class _AppShellState extends State<AppShell> {
|
||||
else
|
||||
for (final (Action target, Dependency d) in _outgoingDeps(a))
|
||||
_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),
|
||||
_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) {
|
||||
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) {
|
||||
return Container(
|
||||
|
||||
@@ -121,7 +121,7 @@ class CanvasOverlays extends StatelessWidget {
|
||||
: _CircularPreviewCard(t: t, project: c.project),
|
||||
),
|
||||
),
|
||||
// 圆周视图右侧浮动工具栏(添加/编辑/复制/删除/改层/对齐/帮助)。
|
||||
// 圆周视图右侧浮动工具栏(添加/编辑/复制/删除/改层/对齐)。
|
||||
if (circular)
|
||||
Positioned(
|
||||
right: right - 2,
|
||||
@@ -177,11 +177,11 @@ class _Title extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final String title = circular
|
||||
? '圆周节拍视图(同心圆 · 12 点钟起始 · 顺时针)'
|
||||
: '条形节拍视图(甘特 / 流程图 · 依赖箭头)';
|
||||
? '圆周时序视图'
|
||||
: '条形时序视图';
|
||||
final String sub = circular
|
||||
? '同心圆环 = 动作层;箭头 = 执行顺序(绿色实线 FS 严格顺序,琥珀虚线 SS 并行重叠);1 圈 = 1 循环 = ${tfmt(project.cycle.durationMs, project.units)} = 360° = 100%'
|
||||
: '时间轴与相位角双刻度联动;箭头表示动作间关联(绿色实线 FS 严格顺序 / 琥珀虚线 SS 并行重叠);跨循环动作自动拆分并标注';
|
||||
: '箭头表示动作之间关联(绿色实线 FS 严格顺序 / 琥珀虚线 SS 并行重叠)';
|
||||
return Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
@@ -468,7 +468,7 @@ class _StatsButton extends StatelessWidget {
|
||||
}
|
||||
|
||||
/// 节拍统计弹窗:汇总循环周期、动作数、关键路径、并行度、
|
||||
/// 相位覆盖率、瓶颈工位与预估产能。
|
||||
/// 相位覆盖率与瓶颈工位(仅展示可从当前项目数据推导的指标)。
|
||||
class _CycleStatsDialog extends StatelessWidget {
|
||||
const _CycleStatsDialog({required this.t, required this.c});
|
||||
|
||||
@@ -483,7 +483,6 @@ class _CycleStatsDialog extends StatelessWidget {
|
||||
final UnitSettings u = p.units;
|
||||
final List<Action> acts = p.actions;
|
||||
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>>[
|
||||
<String>['循环周期', '${tfmt(p.cycle.durationMs, u)} / 360° / 100%'],
|
||||
<String>['动作数量', '${acts.length}($stations 工位)'],
|
||||
@@ -491,7 +490,6 @@ class _CycleStatsDialog extends StatelessWidget {
|
||||
<String>['最大并行度', _maxParallel(acts)],
|
||||
<String>['相位覆盖率', _coverage(acts)],
|
||||
<String>['瓶颈工位', _bottleneck(p)],
|
||||
<String>['预估产能', '${perHour.toStringAsFixed(0)} 件/小时(节拍 ${tfmt(p.cycle.durationMs, u)})'],
|
||||
];
|
||||
return Dialog(
|
||||
backgroundColor: t.dialog,
|
||||
@@ -601,7 +599,7 @@ class _CycleStatsDialog extends StatelessWidget {
|
||||
}
|
||||
}
|
||||
|
||||
/// 条形视图编辑工具条:添加 / 编辑 / 复制 / 删除 / 对齐 / 帮助。
|
||||
/// 条形视图编辑工具条:添加 / 编辑 / 复制 / 删除 / 对齐。
|
||||
class _EditTools extends StatelessWidget {
|
||||
const _EditTools({required this.t, required this.c});
|
||||
|
||||
@@ -615,7 +613,7 @@ class _EditTools extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return _Card(
|
||||
t: t,
|
||||
width: 470,
|
||||
width: 390,
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: <Widget>[
|
||||
@@ -637,10 +635,6 @@ class _EditTools extends StatelessWidget {
|
||||
border: t.line2),
|
||||
const SizedBox(width: 8),
|
||||
_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 {
|
||||
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,
|
||||
() => 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.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
|
||||
? BarLayout(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;
|
||||
if (c.project.viewState.mode == ViewMode.bar) {
|
||||
angle = BarLayout(c.project, size).angleAt(p.dx);
|
||||
|
||||
+335
-17
@@ -127,6 +127,26 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
||||
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)中当前存在的根目录。
|
||||
List<String> _drives() {
|
||||
final List<String> out = <String>[];
|
||||
@@ -189,18 +209,35 @@ class _FileBrowserDialogState extends State<FileBrowserDialog> {
|
||||
SingleChildScrollView(
|
||||
scrollDirection: Axis.horizontal,
|
||||
child: Row(
|
||||
children: drives.map((String d) {
|
||||
return Padding(
|
||||
children: <Widget>[
|
||||
// 桌面快捷入口:导出 / 打开 / 保存时一键跳到桌面。
|
||||
Padding(
|
||||
padding: const EdgeInsets.only(right: 6),
|
||||
child: ActionChip(
|
||||
label: Text(d),
|
||||
avatar: Icon(Icons.desktop_windows_outlined, size: 15, color: t.accent),
|
||||
label: const Text('桌面'),
|
||||
onPressed: () {
|
||||
_dir = Directory(d);
|
||||
_refresh();
|
||||
final Directory? d = _desktop();
|
||||
if (d != null) {
|
||||
_dir = d;
|
||||
_refresh();
|
||||
}
|
||||
},
|
||||
),
|
||||
);
|
||||
}).toList(),
|
||||
),
|
||||
...drives.map((String d) {
|
||||
return Padding(
|
||||
padding: const EdgeInsets.only(right: 6),
|
||||
child: ActionChip(
|
||||
label: Text(d),
|
||||
onPressed: () {
|
||||
_dir = Directory(d);
|
||||
_refresh();
|
||||
},
|
||||
),
|
||||
);
|
||||
}),
|
||||
],
|
||||
),
|
||||
),
|
||||
const Divider(),
|
||||
@@ -778,7 +815,7 @@ class _SettingsDialogState extends State<SettingsDialog> {
|
||||
],
|
||||
),
|
||||
const SizedBox(height: 18),
|
||||
// 循环与相位:循环时长可编辑,起点与方向为固定展示。
|
||||
// 循环与相位:循环时长可编辑,起点与方向为固定展示(顺时针)。
|
||||
Text('循环与相位', style: TextStyle(color: t.sub, fontSize: 11)),
|
||||
const SizedBox(height: 8),
|
||||
Row(
|
||||
@@ -807,6 +844,7 @@ class _SettingsDialogState extends State<SettingsDialog> {
|
||||
),
|
||||
),
|
||||
const SizedBox(width: 10),
|
||||
// 旋转方向:固定为顺时针(圆周视图约定)。
|
||||
Expanded(
|
||||
child: TextField(
|
||||
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>['我要先看看示例', '首次启动载入 2 个动作的示例节拍,可直接修改。'],
|
||||
<String>['我要新增动作', '双击画布空白处在点击相位新增;或左侧「新建」在 0° 新增(默认最外层)。'],
|
||||
<String>['我要删除动作', '选中后:左侧「删除」/ 行内删除图标 / 右侧删除 / Delete 键 / 右键菜单。'],
|
||||
<String>['我要改动作属性', '选中动作 → 右侧「编辑」,可改名称、工位、驱动与颜色。'],
|
||||
<String>['我要复制 / 对齐', '右侧「编辑操作」→「复制」/「对齐相位」;圆周视图还可改层。'],
|
||||
<String>['我要删除动作', '选中后:左侧「删除」/ 行内删除图标 / Delete 键 / 右键菜单;至少保留一个动作 / 泳道。'],
|
||||
<String>['我要改动作属性', '双击画布色块(条形块 / 圆弧)或左侧动作行 → 打开动作编辑对话框;也可选中后点左侧行内编辑图标。'],
|
||||
<String>['我要复制 / 对齐', '画布左下角「编辑工具」→「复制」/「对齐」;圆周视图右侧浮动工具条同款。'],
|
||||
<String>['我要编辑工位', '左侧「动作和执行编辑」→「编辑工位」:可增删工位、改名称与颜色、上下调整顺序;删除工位后其动作自动改挂到第一个工位。'],
|
||||
<String>['一条泳道放多个动作', '泳道/轨道=一个执行器:上下拖拽(条形)或 Shift+径向拖拽(圆周)换道;不重叠即可共存,标题合并显示(/ 分隔,≤2 行)。'],
|
||||
]),
|
||||
// 目标:调整时间轴与动作间的先后 / 并行关系。
|
||||
_section(t, <List<String>>[
|
||||
<String>['我要改时间轴长度', '点左侧项目卡的「循环 …」,或按 F2 →「循环与相位」→ 循环时长 → 应用。'],
|
||||
<String>['我要调相位 / 时长', '拖动动作块平移相位;拖条形右端改持续角;右侧滑杆可精调。'],
|
||||
<String>['我要改时间轴长度', '左侧「时序创建和编辑」→「编辑时序与节拍参数」,或按 F2 →「循环与相位」→ 循环时长 → 应用。'],
|
||||
<String>['我要调相位 / 时长', '拖动动作块平移相位;拖条形右端改持续角;圆周视图拖弧两端改起止角;右侧滑杆可精调。'],
|
||||
<String>['我要让动作跨循环', '使「起始角 + 持续角 > 360°」,会自动拆分并以半透明虚线渲染尾段。'],
|
||||
<String>['我要加前置依赖(输入)', '右侧「前置依赖 · 输入」→「添加前置依赖」;或右键动作 →「添加依赖」。'],
|
||||
<String>['一个动作多输入', '可重复添加多条前置依赖,逐条列出、逐条可删。'],
|
||||
@@ -1306,9 +1620,10 @@ class HelpDialog extends StatelessWidget {
|
||||
// 目标:编辑相位分区并控制画布显示。
|
||||
_section(t, <List<String>>[
|
||||
<String>['相位分区是什么', '把一个循环按角度分成的命名工艺阶段(默认上料/夹紧/加工/检测/下料),条形图顶部标注带即它。'],
|
||||
<String>['我要编辑相位分区', 'F2 →「相位分区」→「编辑…」:增删分区、改名称与起止角;可重叠、可留空、>360° 表示跨圈。'],
|
||||
<String>['我要编辑相位分区', '左侧「动作和执行编辑」→「编辑相位分区」;或 F2 →「相位分区」→「编辑…」。增删分区、改名称与起止角;可重叠、可留空、>360° 表示跨圈。'],
|
||||
<String>['我要隐藏相位分区', '左侧「显示选项」取消勾选「相位分区标注」。'],
|
||||
<String>['我要切换视图', '顶部「条形节拍 / 圆周节拍」分段开关,两种视图共享同一份数据。'],
|
||||
<String>['刻度怎么读', '条形视图:分区带与刻度线之间上排为相位、下排为等价时间;圆周视图:每 30° 的度数外侧标注等价时间。'],
|
||||
<String>['我要切换视图', '顶部「条形节拍 / 圆周节拍」分段开关,两种视图共享同一份数据;标题分别为「条形时序视图」「圆周时序视图」。'],
|
||||
<String>['我要缩放 / 平移', 'Ctrl+滚轮 以光标为锚点缩放;普通滚轮或拖拽空白平移。'],
|
||||
<String>['我要完整显示', '顶部「适应视图」:自动按内容(含刻度、箭头、跨圈标注)计算缩放与居中,编辑后也不会被裁切。'],
|
||||
<String>['我要开关标注', '左侧「显示选项」逐项开关双刻度、依赖箭头、圆环背景、层标注、跨循环高亮等。'],
|
||||
@@ -1317,7 +1632,7 @@ class HelpDialog extends StatelessWidget {
|
||||
_section(t, <List<String>>[
|
||||
<String>['我要 AI 生成', '顶部「AI 生成」→ 填 DeepSeek API Key → 选模型(Flash / Pro)→ 选强度(高 / 最高)→ 用自然语言描述 → 生成。'],
|
||||
<String>['生成效果不好', '描述里写清:循环时长、工位数、各动作时长、哪些顺序(完成后启动)、哪些并行。'],
|
||||
<String>['我要看节拍统计', '画布左下角「节拍统计」按钮 → 弹窗查看关键路径、并行度、瓶颈工位、产能等。'],
|
||||
<String>['我要看节拍统计', '画布左下角「节拍统计」按钮 → 弹窗查看循环周期、动作数、关键路径、最大并行度、相位覆盖率与瓶颈工位(仅展示可从项目数据推导的指标)。'],
|
||||
<String>['我要导出 SVG', '顶部「导出 SVG」:矢量、分层、带语义 id 与 data-*,可直接进工艺卡 / MES。'],
|
||||
<String>['我要导出 PNG', '顶部「导出 PNG」:按 2 倍像素比导出当前画布为位图。'],
|
||||
<String>['我要保存 / 恢复', '「保存」写入 .seq.json 并生成 .bak;每 5 秒自动快照,异常退出后启动可恢复。'],
|
||||
@@ -1328,9 +1643,12 @@ class HelpDialog extends StatelessWidget {
|
||||
<String>['我要钉住侧栏', '侧栏标题右侧图钉:钉住=固定占位;取消钉住=悬浮,鼠标移开自动收起。'],
|
||||
<String>['边缘把手', '侧栏收起后画布边缘有细把手:悬停临时展开,点击固定显示。'],
|
||||
<String>['拖拽 / 缩放', '左键拖拽平移相位;拖端点改时长;Shift+拖拽改层;Ctrl+滚轮缩放。'],
|
||||
<String>['双击编辑', '双击画布色块(条形块 / 圆弧)或左侧动作行 → 打开动作编辑对话框。'],
|
||||
<String>['右键动作', '菜单:添加依赖 / 改层 / 复制 / 删除。'],
|
||||
<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>>[
|
||||
|
||||
Reference in New Issue
Block a user