v1.3.10: 应用身份切换 cc.sincos.edc(彻底解决桌面名称); 移除尺寸标注与图元库自定义; 修复帮助中心空白与 Windows 更新包校验
This commit is contained in:
@@ -132,196 +132,6 @@ enum ArchShapeType {
|
||||
symbol,
|
||||
}
|
||||
|
||||
/// 可编辑尺寸类型(识别后图形的直接尺寸;不走约束求解器)。
|
||||
enum ArchDimKind {
|
||||
/// 宽度(水平尺寸)。
|
||||
width,
|
||||
|
||||
/// 高度(垂直尺寸)。
|
||||
height,
|
||||
|
||||
/// 长度(线类图形的路径长度)。
|
||||
length,
|
||||
|
||||
/// 直径(圆)。
|
||||
diameter,
|
||||
}
|
||||
|
||||
/// 尺寸类型 JSON 名称。
|
||||
String archDimKindName(ArchDimKind k) => switch (k) {
|
||||
ArchDimKind.width => 'width',
|
||||
ArchDimKind.height => 'height',
|
||||
ArchDimKind.length => 'length',
|
||||
ArchDimKind.diameter => 'diameter',
|
||||
};
|
||||
|
||||
/// JSON 名称 → 尺寸类型。
|
||||
ArchDimKind archDimKindFrom(String s) => switch (s) {
|
||||
'height' => ArchDimKind.height,
|
||||
'length' => ArchDimKind.length,
|
||||
'diameter' => ArchDimKind.diameter,
|
||||
_ => ArchDimKind.width,
|
||||
};
|
||||
|
||||
/// 尺寸类型中文名。
|
||||
String archDimKindLabel(ArchDimKind k) => switch (k) {
|
||||
ArchDimKind.width => '宽度',
|
||||
ArchDimKind.height => '高度',
|
||||
ArchDimKind.length => '长度',
|
||||
ArchDimKind.diameter => '直径',
|
||||
};
|
||||
|
||||
/// 图形适用的尺寸类型(右栏编辑 / 画布标注用)。
|
||||
List<ArchDimKind> archShapeDimKinds(ArchShape s) {
|
||||
if (s.isLinear) {
|
||||
return const <ArchDimKind>[
|
||||
ArchDimKind.length,
|
||||
ArchDimKind.width,
|
||||
ArchDimKind.height,
|
||||
];
|
||||
}
|
||||
if (s.type == ArchShapeType.circle) {
|
||||
return const <ArchDimKind>[ArchDimKind.diameter];
|
||||
}
|
||||
return const <ArchDimKind>[ArchDimKind.width, ArchDimKind.height];
|
||||
}
|
||||
|
||||
/// 线类图形的外接矩形(pts / a-b)。
|
||||
Rect archLinearBounds(ArchShape s) {
|
||||
if (s.type == ArchShapeType.line && s.a != null && s.b != null) {
|
||||
return Rect.fromPoints(s.a!, s.b!);
|
||||
}
|
||||
if (s.pts.isEmpty) return s.rect;
|
||||
double l = s.pts.first.dx, r = l, t = s.pts.first.dy, b = t;
|
||||
for (final Offset p in s.pts) {
|
||||
if (p.dx < l) l = p.dx;
|
||||
if (p.dx > r) r = p.dx;
|
||||
if (p.dy < t) t = p.dy;
|
||||
if (p.dy > b) b = p.dy;
|
||||
}
|
||||
return Rect.fromLTRB(l, t, r, b);
|
||||
}
|
||||
|
||||
/// 线类图形的路径长度(直线 / 折线 / 曲线按顶点折线近似)。
|
||||
double archShapeLength(ArchShape s) {
|
||||
if (s.type == ArchShapeType.line && s.a != null && s.b != null) {
|
||||
return (s.b! - s.a!).distance;
|
||||
}
|
||||
double len = 0;
|
||||
for (int i = 1; i < s.pts.length; i++) {
|
||||
len += (s.pts[i] - s.pts[i - 1]).distance;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
/// 测量图形当前尺寸值。
|
||||
double archShapeDimValue(ArchShape s, ArchDimKind k) {
|
||||
switch (k) {
|
||||
case ArchDimKind.length:
|
||||
return archShapeLength(s);
|
||||
case ArchDimKind.diameter:
|
||||
return s.rect.width;
|
||||
case ArchDimKind.width:
|
||||
return s.isLinear ? archLinearBounds(s).width : s.rect.width;
|
||||
case ArchDimKind.height:
|
||||
return s.isLinear ? archLinearBounds(s).height : s.rect.height;
|
||||
}
|
||||
}
|
||||
|
||||
/// 线类图形按比例缩放(绕外接框中心;[fx]/[fy] 为横纵缩放系数)。
|
||||
ArchShape _scaleLinear(ArchShape s, double fx, double fy) {
|
||||
final Rect b = archLinearBounds(s);
|
||||
final Offset c0 = b.center;
|
||||
Offset map(Offset p) =>
|
||||
Offset(c0.dx + (p.dx - c0.dx) * fx, c0.dy + (p.dy - c0.dy) * fy);
|
||||
if (s.type == ArchShapeType.line && s.a != null && s.b != null) {
|
||||
final Offset a2 = map(s.a!);
|
||||
final Offset b2 = map(s.b!);
|
||||
return s.copyWith(a: a2, b: b2, rect: Rect.fromPoints(a2, b2));
|
||||
}
|
||||
final List<Offset> pts = <Offset>[for (final Offset p in s.pts) map(p)];
|
||||
if (pts.isEmpty) return s;
|
||||
double l = pts.first.dx, r = l, t = pts.first.dy, bo = t;
|
||||
for (final Offset p in pts) {
|
||||
if (p.dx < l) l = p.dx;
|
||||
if (p.dx > r) r = p.dx;
|
||||
if (p.dy < t) t = p.dy;
|
||||
if (p.dy > bo) bo = p.dy;
|
||||
}
|
||||
return s.copyWith(pts: pts, rect: Rect.fromLTRB(l, t, r, bo));
|
||||
}
|
||||
|
||||
/// 应用尺寸(直接缩放几何,中心保持;值 <= 0.1 时按 0.1 处理)。
|
||||
ArchShape archShapeApplyDim(ArchShape s, ArchDimKind k, double value) {
|
||||
final double v = value <= 0.1 ? 0.1 : value;
|
||||
switch (k) {
|
||||
case ArchDimKind.width:
|
||||
if (s.isLinear) {
|
||||
final double w = archLinearBounds(s).width;
|
||||
return _scaleLinear(s, w <= 1e-6 ? 1 : v / w, 1);
|
||||
}
|
||||
return s.copyWith(
|
||||
rect: Rect.fromCenter(
|
||||
center: s.rect.center, width: v, height: s.rect.height));
|
||||
case ArchDimKind.height:
|
||||
if (s.isLinear) {
|
||||
final double h = archLinearBounds(s).height;
|
||||
return _scaleLinear(s, 1, h <= 1e-6 ? 1 : v / h);
|
||||
}
|
||||
return s.copyWith(
|
||||
rect: Rect.fromCenter(
|
||||
center: s.rect.center, width: s.rect.width, height: v));
|
||||
case ArchDimKind.diameter:
|
||||
return s.copyWith(
|
||||
rect: Rect.fromCenter(center: s.rect.center, width: v, height: v));
|
||||
case ArchDimKind.length:
|
||||
final double len = archShapeLength(s);
|
||||
if (len <= 1e-6) return s;
|
||||
final double f = v / len;
|
||||
return _scaleLinear(s, f, f);
|
||||
}
|
||||
}
|
||||
|
||||
/// 尺寸标签锚点(世界坐标;屏幕恒定间距由 [zoom] 折算)。
|
||||
Offset archShapeDimLabelPos(
|
||||
ArchShape s,
|
||||
ArchDimKind k,
|
||||
int index,
|
||||
double zoom,
|
||||
) {
|
||||
final double z = zoom <= 0.05 ? 1 : zoom;
|
||||
final double gap = 17 / z;
|
||||
final Rect b = s.isLinear ? archLinearBounds(s) : s.rect;
|
||||
final bool wide =
|
||||
s.type == ArchShapeType.line || s.type == ArchShapeType.curve;
|
||||
return Offset(
|
||||
b.center.dx + (wide ? gap * 0.9 : 0),
|
||||
b.bottom + gap * (index + 0.8),
|
||||
);
|
||||
}
|
||||
|
||||
/// 命中的尺寸标签(双击编辑用);未命中返回 null。
|
||||
(ArchShape, ArchDimKind)? archShapeDimHitAt(
|
||||
ArchDoc doc,
|
||||
Offset p,
|
||||
double zoom,
|
||||
) {
|
||||
final double z = zoom <= 0.05 ? 1 : zoom;
|
||||
final double tol = 14 / z + 6;
|
||||
for (final ArchShape s in doc.shapes) {
|
||||
if (!doc.isLayerVisible(s.layerId)) continue;
|
||||
final List<ArchDimKind> kinds = <ArchDimKind>[
|
||||
for (final ArchDimKind k in archShapeDimKinds(s))
|
||||
if (s.dims.contains(k)) k,
|
||||
];
|
||||
for (int i = 0; i < kinds.length; i++) {
|
||||
final Offset a = archShapeDimLabelPos(s, kinds[i], i, z);
|
||||
if ((p - a).distance <= tol) return (s, kinds[i]);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// 把折线正交化:保留顶点位置,但所有段强制「横平竖直」。
|
||||
///
|
||||
/// 用于手绘连线的轨迹:笔迹认出的折点仍被尊重,但不会出现斜线
|
||||
@@ -925,7 +735,6 @@ class ArchShape {
|
||||
this.pts = const <Offset>[],
|
||||
this.layerId = kArchDefaultLayerId,
|
||||
this.symbolId = '',
|
||||
this.dims = const <ArchDimKind>{},
|
||||
});
|
||||
|
||||
/// 唯一标识(如 `S1`)。
|
||||
@@ -973,9 +782,6 @@ class ArchShape {
|
||||
/// 图元库符号 id(仅 [ArchShapeType.symbol] 使用;空串 = 未指定)。
|
||||
final String symbolId;
|
||||
|
||||
/// 画布上标注的尺寸类型(识别后图形可直接改值缩放,见 [archShapeApplyDim])。
|
||||
final Set<ArchDimKind> dims;
|
||||
|
||||
/// 是否为「线类」图形(直线 / 箭头 / 折线 / 曲线)。
|
||||
bool get isLinear =>
|
||||
type == ArchShapeType.line ||
|
||||
@@ -1048,7 +854,6 @@ class ArchShape {
|
||||
List<Offset>? pts,
|
||||
String? layerId,
|
||||
String? symbolId,
|
||||
Set<ArchDimKind>? dims,
|
||||
}) {
|
||||
return ArchShape(
|
||||
id: id ?? this.id,
|
||||
@@ -1066,7 +871,6 @@ class ArchShape {
|
||||
pts: pts ?? this.pts,
|
||||
layerId: layerId ?? this.layerId,
|
||||
symbolId: symbolId ?? this.symbolId,
|
||||
dims: dims ?? this.dims,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1107,10 +911,6 @@ class ArchShape {
|
||||
'pts': <double>[for (final Offset p in pts) ...<double>[p.dx, p.dy]],
|
||||
if (layerId.isNotEmpty) 'ly': layerId,
|
||||
if (symbolId.isNotEmpty) 'sy': symbolId,
|
||||
if (dims.isNotEmpty)
|
||||
'dim': <String>[
|
||||
for (final ArchDimKind k in dims) archDimKindName(k),
|
||||
],
|
||||
};
|
||||
|
||||
/// 从 JSON 反序列化(字段缺失时使用安全默认值)。
|
||||
@@ -1151,10 +951,6 @@ class ArchShape {
|
||||
pts: pts,
|
||||
layerId: j['ly'] as String? ?? kArchDefaultLayerId,
|
||||
symbolId: j['sy'] as String? ?? '',
|
||||
dims: <ArchDimKind>{
|
||||
for (final dynamic e in (j['dim'] as List<dynamic>?) ?? <dynamic>[])
|
||||
archDimKindFrom(e.toString()),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user