feat(V1.0.1): 泳道/轨道支持多动作(同执行器多条不重叠);圆周弧可拖拽端点;依赖标签沿弧避让
- 泳道模型:layer 兼作泳道/轨道编号,同一泳道可放多个互不重叠动作(角区间重叠校验) - 条形:上下拖拽换道;圆周:Shift+径向拖拽换轨;冲突时拒绝并提示 - 泳道标题合并显示(/ 分隔,≤2 行);左侧列表按泳道分组 - 圆周动作弧支持拖拽两端改起止角(弱吸附 + 径向虚线参考),整体拖拽旋转 - 圆周依赖标签沿圆弧切向排布,落入环间空隙,避免压住动作弧 - 版本 1.0.1+2;帮助/README 补充泳道说明;重新构建 dist
This commit is contained in:
+112
-87
@@ -234,12 +234,13 @@ class BarPainter extends CustomPainter {
|
||||
///
|
||||
/// 参数 [layout] 提供行列几何,[u]/[cycle] 用于时长文本换算。
|
||||
void _rows(Canvas canvas, BarLayout layout, UnitSettings u, double cycle) {
|
||||
final List<Action> ordered = layout.ordered;
|
||||
for (int i = 0; i < ordered.length; i++) {
|
||||
final Action a = ordered[i];
|
||||
final double y = layout.yFor(i);
|
||||
// 隔行背景色带,弱化行边界。
|
||||
if (i.isEven) {
|
||||
final List<int> lanes = layout.lanes;
|
||||
for (int li = 0; li < lanes.length; li++) {
|
||||
final int lane = lanes[li];
|
||||
final double y = layout.yFor(li);
|
||||
final List<Action> acts = layout.actionsInLane(lane);
|
||||
// 隔泳道背景色带,弱化边界。
|
||||
if (li.isEven) {
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(
|
||||
Rect.fromLTWH(20, y - 8, layout.plotRight - 20, BarLayout.rowVisual),
|
||||
@@ -248,24 +249,9 @@ class BarPainter extends CustomPainter {
|
||||
Paint()..color = tokens.panel2.withValues(alpha: 0.5),
|
||||
);
|
||||
}
|
||||
// 左侧序号徽标:动作自身颜色作底,叠加白色序号。
|
||||
final Station? st = project.stationById(a.stationId);
|
||||
final Color c = Color(a.color);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(Rect.fromLTWH(32, y + 8, 18, 18), const Radius.circular(5)),
|
||||
Paint()..color = c,
|
||||
);
|
||||
_text(canvas, '${i + 1}', Offset(41, y + 17),
|
||||
color: tokens.chip, size: 10, align: TextAlign.center, weight: FontWeight.w700);
|
||||
// 动作标识与工位/驱动信息(两行文本)。
|
||||
// 标题列文字按列宽截断,避免越界压到图表。
|
||||
final double labelMax = BarLayout.leftGutter - 68;
|
||||
_textMax(canvas, '${i + 1}. ${a.id} ${a.name}', Offset(60, y + 6), labelMax,
|
||||
color: tokens.text, size: 12, weight: FontWeight.w600);
|
||||
_textMax(canvas, '${st?.name ?? a.stationId} · ${a.driver}', Offset(60, y + 21), labelMax,
|
||||
color: tokens.dim, size: 10);
|
||||
|
||||
// 行底分隔线,颜色较淡。
|
||||
// 泳道标题(合并显示,最多两行,用 / 分隔)。
|
||||
_laneHeader(canvas, layout, li, acts, y);
|
||||
// 泳道底分隔线。
|
||||
canvas.drawLine(
|
||||
Offset(layout.plotLeft, y + BarLayout.rowVisual - 4),
|
||||
Offset(layout.plotRight, y + BarLayout.rowVisual - 4),
|
||||
@@ -273,69 +259,104 @@ class BarPainter extends CustomPainter {
|
||||
..color = tokens.line.withValues(alpha: 0.5)
|
||||
..strokeWidth = 1,
|
||||
);
|
||||
// 该泳道内的所有动作条(互不重叠)。
|
||||
for (final Action a in acts) {
|
||||
_bar(canvas, layout, a, u, cycle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 动作条块:先投影,再填充,最后描边。
|
||||
final Rect r = layout.rectFor(a);
|
||||
final bool sel = selectedIds.contains(a.id);
|
||||
final bool crit = criticalActions.contains(a.id);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(r.shift(const Offset(1.5, 2)), const Radius.circular(8)),
|
||||
Paint()..color = tokens.shadow.withValues(alpha: tokens.shadowOp),
|
||||
);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(r, const Radius.circular(8)),
|
||||
Paint()..color = c.withValues(alpha: 0.92),
|
||||
);
|
||||
// 选中描边:选中时更亮,未选中时仅保留很淡的轮廓。
|
||||
/// 绘制一条泳道的标题:序号徽标 + 合并动作名(≤2 行,用 / 分隔)+ 副标题。
|
||||
void _laneHeader(Canvas canvas, BarLayout layout, int li, List<Action> acts, double y) {
|
||||
final double labelMax = BarLayout.leftGutter - 68;
|
||||
final Color c0 = acts.isEmpty ? tokens.accent : Color(acts.first.color);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(Rect.fromLTWH(32, y + 8, 18, 18), const Radius.circular(5)),
|
||||
Paint()..color = c0,
|
||||
);
|
||||
_text(canvas, '${li + 1}', Offset(41, y + 17),
|
||||
color: tokens.chip, size: 10, align: TextAlign.center, weight: FontWeight.w700);
|
||||
if (acts.isEmpty) return;
|
||||
|
||||
// 多个动作合并为「A1 上料 / A2 定位」,最多两行。
|
||||
final String joined = acts.map((Action a) => '${a.id} ${a.name}').join(' / ');
|
||||
final TextPainter tp = TextPainter(
|
||||
text: TextSpan(
|
||||
text: joined,
|
||||
style: TextStyle(
|
||||
color: tokens.text,
|
||||
fontSize: 11,
|
||||
fontWeight: FontWeight.w600,
|
||||
fontFamily: 'Microsoft YaHei UI',
|
||||
),
|
||||
),
|
||||
textDirection: ui.TextDirection.ltr,
|
||||
maxLines: 2,
|
||||
ellipsis: '…',
|
||||
)..layout(maxWidth: labelMax);
|
||||
tp.paint(canvas, Offset(60, y + 2));
|
||||
|
||||
final Station? st = project.stationById(acts.first.stationId);
|
||||
final String sub = '${st?.name ?? acts.first.stationId} · ${acts.first.driver}'
|
||||
'${acts.length > 1 ? ' · 共 ${acts.length} 个' : ''}';
|
||||
_textMax(canvas, sub, Offset(60, y + 32), labelMax, color: tokens.dim, size: 10);
|
||||
}
|
||||
|
||||
/// 绘制单个动作条块(投影 / 填充 / 描边 / 跨圈尾段 / 文字标注)。
|
||||
void _bar(Canvas canvas, BarLayout layout, Action a, UnitSettings u, double cycle) {
|
||||
final Color c = Color(a.color);
|
||||
final Rect r = layout.rectFor(a);
|
||||
final bool sel = selectedIds.contains(a.id);
|
||||
final bool crit = criticalActions.contains(a.id);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(r.shift(const Offset(1.5, 2)), const Radius.circular(8)),
|
||||
Paint()..color = tokens.shadow.withValues(alpha: tokens.shadowOp),
|
||||
);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(r, const Radius.circular(8)),
|
||||
Paint()..color = c.withValues(alpha: 0.92),
|
||||
);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(r, const Radius.circular(8)),
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1
|
||||
..color = tokens.selOutline.withValues(alpha: sel ? 0.9 : 0.25),
|
||||
);
|
||||
if (crit) {
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(r, const Radius.circular(8)),
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1
|
||||
..color = tokens.selOutline.withValues(alpha: sel ? 0.9 : 0.25),
|
||||
..strokeWidth = 2
|
||||
..color = tokens.crit,
|
||||
);
|
||||
// 关键路径条块额外叠加一圈加粗高亮描边。
|
||||
if (crit) {
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(r, const Radius.circular(8)),
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 2
|
||||
..color = tokens.crit,
|
||||
);
|
||||
}
|
||||
|
||||
// 跨循环延续:把 360° 之后的部分回绕到左侧 0° 起绘制,
|
||||
// 使用 [Tokens.tailOp] 透明度淡化以区别于主体。
|
||||
if (a.wrap && u.autoSplitWrap) {
|
||||
final double wx = layout.xFor(a.endAngle - 360) - layout.plotLeft;
|
||||
final Rect tail = Rect.fromLTWH(layout.plotLeft, r.top, math.max(wx, 2), r.height);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(tail, const Radius.circular(8)),
|
||||
Paint()..color = c.withValues(alpha: tokens.tailOp),
|
||||
);
|
||||
_text(canvas, '跨循环延续 ${(a.endAngle - 360).toStringAsFixed(0)}°',
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
color: c, size: 11, weight: FontWeight.w600);
|
||||
}
|
||||
_text(canvas, 'Δ${a.durationAngle.toStringAsFixed(0)}°', Offset(layout.plotRight - 4, r.center.dy),
|
||||
color: tokens.dim, size: 10, align: TextAlign.right);
|
||||
}
|
||||
if (a.wrap && u.autoSplitWrap) {
|
||||
final double wx = layout.xFor(a.endAngle - 360) - layout.plotLeft;
|
||||
final Rect tail = Rect.fromLTWH(layout.plotLeft, r.top, math.max(wx, 2), r.height);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(tail, const Radius.circular(8)),
|
||||
Paint()..color = c.withValues(alpha: tokens.tailOp),
|
||||
);
|
||||
_text(canvas, '跨循环延续 ${(a.endAngle - 360).toStringAsFixed(0)}°',
|
||||
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),
|
||||
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),
|
||||
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),
|
||||
color: c, size: 11, weight: FontWeight.w600);
|
||||
}
|
||||
_text(canvas, 'Δ${a.durationAngle.toStringAsFixed(0)}°', Offset(layout.plotRight - 4, r.center.dy),
|
||||
color: tokens.dim, size: 10, align: TextAlign.right);
|
||||
}
|
||||
|
||||
/// 绘制动作依赖连线(正交折线)。
|
||||
@@ -352,10 +373,10 @@ class BarPainter extends CustomPainter {
|
||||
/// 参数 [layout] 提供条块矩形;[u] 当前未直接使用,保留以对齐调用接口。
|
||||
void _deps(Canvas canvas, BarLayout layout, UnitSettings u) {
|
||||
final List<Action> ordered = layout.ordered;
|
||||
final Map<String, int> index = <String, int>{};
|
||||
for (int i = 0; i < ordered.length; i++) {
|
||||
index[ordered[i].id] = i;
|
||||
}
|
||||
// 以「泳道序号」判断依赖的相邻关系(同泳道多个动作不再误判)。
|
||||
final Map<String, int> index = <String, int>{
|
||||
for (final Action a in project.actions) a.id: layout.laneIndexOf(a.layer),
|
||||
};
|
||||
int k = 0;
|
||||
for (final Action to in ordered) {
|
||||
for (final Dependency d in to.deps) {
|
||||
@@ -390,10 +411,14 @@ class BarPainter extends CustomPainter {
|
||||
// 跨多行:扫描区间内所有条块边界,据此在外侧选一条竖直泳道。
|
||||
double maxRight = 0;
|
||||
double minLeft = double.infinity;
|
||||
final List<int> lanes = layout.lanes;
|
||||
for (int r = math.min(ia, ib) + 1; r < math.max(ia, ib); r++) {
|
||||
final Rect rr = layout.rectFor(ordered[r]);
|
||||
maxRight = math.max(maxRight, rr.right);
|
||||
minLeft = math.min(minLeft, rr.left);
|
||||
if (r < 0 || r >= lanes.length) continue;
|
||||
for (final Action aa in layout.actionsInLane(lanes[r])) {
|
||||
final Rect rr = layout.rectFor(aa);
|
||||
maxRight = math.max(maxRight, rr.right);
|
||||
minLeft = math.min(minLeft, rr.left);
|
||||
}
|
||||
}
|
||||
double lane = math.max(math.max(sx, tx), maxRight) + 28 + (k % 3) * 16;
|
||||
if (lane > layout.plotRight - 16) {
|
||||
|
||||
@@ -39,6 +39,7 @@ class CircularPainter extends CustomPainter {
|
||||
required this.criticalActions,
|
||||
required this.criticalDeps,
|
||||
required this.selectedIds,
|
||||
this.guideAngle,
|
||||
});
|
||||
|
||||
/// 待绘制的工程数据源。
|
||||
@@ -52,6 +53,9 @@ class CircularPainter extends CustomPainter {
|
||||
/// 当前选中的动作 id 集合(支持多选)。
|
||||
final Set<String> selectedIds;
|
||||
|
||||
/// 拖拽动作弧端点时的参考角(度);非空时绘制一条径向虚线参考。
|
||||
final double? guideAngle;
|
||||
|
||||
/// 绘制整个圆形视图。
|
||||
///
|
||||
/// 参数 [canvas]/[size] 遵循 Flutter 绘制约定。
|
||||
@@ -76,12 +80,13 @@ class CircularPainter extends CustomPainter {
|
||||
..color = tokens.line2,
|
||||
);
|
||||
|
||||
// 圆环背景:每层用一条粗描边构成环带,奇偶层交替着色,
|
||||
// 圆环背景:每条轨道用一条粗描边构成环带,奇偶交替着色,
|
||||
// 并在环带内外沿各画一条细描边作为边界。
|
||||
final int layers = project.maxLayer + 1;
|
||||
final List<int> lanes = layout.lanes;
|
||||
final int layers = lanes.length;
|
||||
if (project.viewState.showRingBg) {
|
||||
for (int i = 0; i < layers; i++) {
|
||||
final double r = layout.radiusFor(i);
|
||||
final double r = layout.radiusFor(lanes[i]);
|
||||
canvas.drawCircle(
|
||||
c,
|
||||
r,
|
||||
@@ -116,11 +121,11 @@ class CircularPainter extends CustomPainter {
|
||||
// 象限辅助线(0°/90°/180°/270°)。
|
||||
_quadrants(canvas, c, layout);
|
||||
|
||||
// 层号标签:为每层挑选一个空位角度,避免压住该层的动作弧。
|
||||
// 轨道标签:为每条轨道挑选一个空位角度,避免压住该轨道的动作弧。
|
||||
if (project.viewState.showLayerLabels) {
|
||||
for (int i = 0; i < layers; i++) {
|
||||
final double r = layout.radiusFor(i);
|
||||
final double free = _freeAngle(i);
|
||||
final double r = layout.radiusFor(lanes[i]);
|
||||
final double free = _freeAngle(lanes[i]);
|
||||
final Offset lp = polar(c, r, free);
|
||||
_text(canvas, 'L${i + 1}', lp, color: tokens.ringLabel, size: 10, align: TextAlign.center, weight: FontWeight.w700);
|
||||
}
|
||||
@@ -140,6 +145,9 @@ class CircularPainter extends CustomPainter {
|
||||
_action(canvas, layout, a, u);
|
||||
}
|
||||
|
||||
// 拖拽端点时的径向虚线参考。
|
||||
if (guideAngle != null) _guide(canvas, layout);
|
||||
|
||||
// 起点标记、顺时针方向提示与外围刻度。
|
||||
_startMarker(canvas, layout);
|
||||
_cwArrow(canvas, layout);
|
||||
@@ -409,7 +417,8 @@ class CircularPainter extends CustomPainter {
|
||||
final bool degenerate = (aStart - aEnd).abs() < 0.5;
|
||||
final Path p;
|
||||
final Offset tipDir;
|
||||
final Offset chipPos;
|
||||
final double chipR;
|
||||
final double chipDeg;
|
||||
if (degenerate) {
|
||||
final double r0 = rTip - (rTip > rB ? 28 : -28);
|
||||
final Offset q0 = polar(c, r0, aStart);
|
||||
@@ -417,7 +426,9 @@ class CircularPainter extends CustomPainter {
|
||||
..moveTo(q0.dx, q0.dy)
|
||||
..lineTo(p3.dx, p3.dy);
|
||||
tipDir = p3 - q0;
|
||||
chipPos = polar(c, (rA + rB) / 2, aStart + 12);
|
||||
// 标签放在源环与目标环之间的径向空隙中,沿切向排布。
|
||||
chipR = (rA + rB) / 2;
|
||||
chipDeg = aStart;
|
||||
} else {
|
||||
p = Path()
|
||||
..moveTo(p0.dx, p0.dy)
|
||||
@@ -426,8 +437,8 @@ class CircularPainter extends CustomPainter {
|
||||
..lineTo(p3.dx, p3.dy);
|
||||
tipDir = p3 - p2;
|
||||
final double span = (aStart - aEnd).abs();
|
||||
final double rChip = skip ? rC : (span < 30 ? rB + layout.th / 2 + 10 : rC);
|
||||
chipPos = polar(c, rChip, (aEnd + aStart) / 2);
|
||||
chipR = skip ? rC : (span < 30 ? rB + layout.th / 2 + 10 : rC);
|
||||
chipDeg = (aEnd + aStart) / 2;
|
||||
}
|
||||
|
||||
if (crit) {
|
||||
@@ -453,7 +464,37 @@ class CircularPainter extends CustomPainter {
|
||||
String label = d.type == DepType.fs ? 'FS' : 'SS+${d.offsetAngle.toStringAsFixed(0)}°';
|
||||
if (d.type == DepType.ff) label = 'FF';
|
||||
if (d.type == DepType.sf) label = 'SF';
|
||||
_chip(canvas, chipPos, '${A.id}→${B.id} $label', col, crit);
|
||||
_arcChip(canvas, c, chipR, chipDeg, '${A.id}→${B.id} $label', col, crit);
|
||||
}
|
||||
|
||||
/// 沿圆弧切向绘制依赖标签胶囊,使其贴合环间空隙、不压住动作弧。
|
||||
void _arcChip(Canvas canvas, Offset c, double r, double midDeg, String label, Color col, bool crit) {
|
||||
final TextPainter tp = _tp(label, 10, col, FontWeight.w600);
|
||||
final double w = tp.width + 16 + (crit ? 18 : 0);
|
||||
const double h = 17;
|
||||
final Offset pos = polar(c, r, midDeg);
|
||||
final double rad = midDeg * math.pi / 180;
|
||||
final bool flip = midDeg > 90 && midDeg < 270;
|
||||
canvas.save();
|
||||
canvas.translate(pos.dx, pos.dy);
|
||||
canvas.rotate(flip ? rad + math.pi : rad);
|
||||
final Rect rect = Rect.fromCenter(center: Offset.zero, width: w, height: h);
|
||||
canvas.drawRRect(RRect.fromRectAndRadius(rect, const Radius.circular(6)), Paint()..color = tokens.chip);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(rect, const Radius.circular(6)),
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1
|
||||
..color = col,
|
||||
);
|
||||
double tx = rect.left + 8;
|
||||
if (crit) {
|
||||
canvas.drawCircle(Offset(rect.left + 8, 0), 6.5, Paint()..color = tokens.crit);
|
||||
_text(canvas, '★', Offset(rect.left + 8, 0), color: tokens.onAccent, size: 10, align: TextAlign.center);
|
||||
tx = rect.left + 18;
|
||||
}
|
||||
tp.paint(canvas, Offset(tx, -tp.height / 2));
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
/// 在 [tip] 处绘制指向 [dir] 方向的实心三角箭头。
|
||||
@@ -474,29 +515,30 @@ class CircularPainter extends CustomPainter {
|
||||
canvas.drawPath(p, Paint()..color = col);
|
||||
}
|
||||
|
||||
/// 绘制依赖标签胶囊。
|
||||
///
|
||||
/// 参数 [center]:胶囊中心;[label]:文字;[col]:边框与文字色;
|
||||
/// [crit]:为真时在左侧追加星形关键标记并加宽胶囊。
|
||||
void _chip(Canvas canvas, Offset center, String label, Color col, bool crit) {
|
||||
final TextPainter tp = _tp(label, 10, col, FontWeight.w600);
|
||||
final double w = tp.width + 16 + (crit ? 18 : 0);
|
||||
final Rect r = Rect.fromCenter(center: center, width: w, height: 17);
|
||||
canvas.drawRRect(RRect.fromRectAndRadius(r, const Radius.circular(6)), Paint()..color = tokens.chip);
|
||||
canvas.drawRRect(
|
||||
RRect.fromRectAndRadius(r, const Radius.circular(6)),
|
||||
Paint()
|
||||
..style = PaintingStyle.stroke
|
||||
..strokeWidth = 1
|
||||
..color = col,
|
||||
);
|
||||
double tx = r.left + 8;
|
||||
if (crit) {
|
||||
canvas.drawCircle(Offset(r.left + 8, center.dy), 6.5, Paint()..color = tokens.crit);
|
||||
_text(canvas, '★', Offset(r.left + 8, center.dy), color: tokens.onAccent, size: 10, align: TextAlign.center);
|
||||
tx = r.left + 18;
|
||||
/// 绘制拖拽端点时的径向虚线参考与角度标注。
|
||||
void _guide(Canvas canvas, CircularLayout layout) {
|
||||
final Offset c = layout.center;
|
||||
final double deg = guideAngle!;
|
||||
final Offset p1 = polar(c, math.max(CircularLayout.r0 - 24, 8), deg);
|
||||
final Offset p2 = polar(c, layout.tickR + 6, deg);
|
||||
final Paint paint = Paint()
|
||||
..color = tokens.accent
|
||||
..strokeWidth = 1.4
|
||||
..strokeCap = StrokeCap.round;
|
||||
const double dash = 6;
|
||||
const double gap = 6;
|
||||
final double total = (p2 - p1).distance;
|
||||
if (total > 0) {
|
||||
final Offset dir = (p2 - p1) / total;
|
||||
double t = 0;
|
||||
while (t < total) {
|
||||
final double end = math.min(t + dash, total);
|
||||
canvas.drawLine(p1 + dir * t, p1 + dir * end, paint);
|
||||
t = end + gap;
|
||||
}
|
||||
}
|
||||
tp.paint(canvas, Offset(tx, center.dy - tp.height / 2));
|
||||
_text(canvas, '${deg.toStringAsFixed(1)}°', polar(c, layout.tickR + 22, deg),
|
||||
color: tokens.accent, size: 11, align: TextAlign.center, weight: FontWeight.w700);
|
||||
}
|
||||
|
||||
/// 绘制 0° 起点标记:顶部朝下的三角与“0° · 12 点钟”文字。
|
||||
|
||||
Reference in New Issue
Block a user