架构图增强:橡皮、手动确认识别(平板推荐)、连线一律正交+角点拖拽、手绘/连线职责分离、尺寸标注一键操作;帮助文件大规模更新;修复品牌按钮与 pubspec 描述
This commit is contained in:
+100
-1
@@ -343,9 +343,17 @@ void main() {
|
||||
expect(back.connectors.single.mids.length, 2);
|
||||
final ArchConnGeometry g =
|
||||
archConnectorGeometry(back, back.connectors.single);
|
||||
expect(g.pts.length, 4);
|
||||
// 正交走线:路径经过两个折点(顺序保持),所有段横平竖直。
|
||||
expect(g.pts.length, greaterThanOrEqualTo(4));
|
||||
expect(g.pts[1], const Offset(40, 0));
|
||||
expect(g.pts[2], const Offset(40, 60));
|
||||
expect(g.pts.first, const Offset(0, 0));
|
||||
expect(g.pts.last, const Offset(100, 0));
|
||||
for (int i = 0; i < g.pts.length - 1; i++) {
|
||||
final Offset d = g.pts[i + 1] - g.pts[i];
|
||||
expect(d.dx.abs() < 0.01 || d.dy.abs() < 0.01, isTrue,
|
||||
reason: '第 $i 段不是横/竖:$d');
|
||||
}
|
||||
});
|
||||
|
||||
test('连线吸附:开始 / 结束吸附到最近边缘点', () {
|
||||
@@ -737,6 +745,97 @@ void main() {
|
||||
expect(b.height, 841);
|
||||
});
|
||||
});
|
||||
|
||||
group('正交连线(一律横平竖直)', () {
|
||||
test('orthoPolyline:斜段拆成横竖台阶且端点保持', () {
|
||||
final List<Offset> out = orthoPolyline(<Offset>[
|
||||
const Offset(0, 0),
|
||||
const Offset(100, 50),
|
||||
]);
|
||||
expect(out.length, greaterThanOrEqualTo(3));
|
||||
for (int i = 0; i < out.length - 1; i++) {
|
||||
final Offset d = out[i + 1] - out[i];
|
||||
expect(d.dx.abs() < 0.01 || d.dy.abs() < 0.01, isTrue,
|
||||
reason: '第 $i 段不是横/竖:$d');
|
||||
}
|
||||
expect(out.first, const Offset(0, 0));
|
||||
expect(out.last, const Offset(100, 50));
|
||||
});
|
||||
|
||||
test('连线几何:无折点自动单拐角;有折点按折点走台阶', () {
|
||||
const ArchShape a = ArchShape(
|
||||
id: 'A',
|
||||
type: ArchShapeType.rect,
|
||||
rect: Rect.fromLTWH(0, 0, 80, 60),
|
||||
);
|
||||
const ArchShape b = ArchShape(
|
||||
id: 'B',
|
||||
type: ArchShapeType.rect,
|
||||
rect: Rect.fromLTWH(300, 200, 80, 60),
|
||||
);
|
||||
final ArchDoc doc =
|
||||
ArchDoc.empty.copyWith(shapes: <ArchShape>[a, b]);
|
||||
final ArchConnector c1 = ArchConnector(
|
||||
id: 'C1',
|
||||
fromId: 'A',
|
||||
from: a.rect.center,
|
||||
toId: 'B',
|
||||
to: b.rect.center,
|
||||
);
|
||||
final ArchConnGeometry g1 = archConnectorGeometry(doc, c1);
|
||||
for (int i = 0; i < g1.pts.length - 1; i++) {
|
||||
final Offset d = g1.pts[i + 1] - g1.pts[i];
|
||||
expect(d.dx.abs() < 0.01 || d.dy.abs() < 0.01, isTrue,
|
||||
reason: '无折点第 $i 段不是横/竖');
|
||||
}
|
||||
final ArchConnector c2 =
|
||||
c1.copyWith(mids: <Offset>[const Offset(150, 90)]);
|
||||
final ArchConnGeometry g2 = archConnectorGeometry(doc, c2);
|
||||
for (int i = 0; i < g2.pts.length - 1; i++) {
|
||||
final Offset d = g2.pts[i + 1] - g2.pts[i];
|
||||
expect(d.dx.abs() < 0.01 || d.dy.abs() < 0.01, isTrue,
|
||||
reason: '有折点第 $i 段不是横/竖');
|
||||
}
|
||||
final double dmin = g2.pts
|
||||
.map((Offset p) => (p - const Offset(150, 90)).distance)
|
||||
.reduce((double x, double y) => x < y ? x : y);
|
||||
expect(dmin, lessThan(2), reason: '路径应经过拖拽的角点');
|
||||
});
|
||||
});
|
||||
|
||||
group('橡皮擦', () {
|
||||
test('连续擦除计入一次撤销', () {
|
||||
final AppController c = AppController(project: Project.demo());
|
||||
addTearDown(c.dispose);
|
||||
c.addArchShape(const ArchShape(
|
||||
id: 'S1',
|
||||
type: ArchShapeType.rect,
|
||||
rect: Rect.fromLTWH(0, 0, 100, 60),
|
||||
));
|
||||
c.addArchShape(const ArchShape(
|
||||
id: 'S2',
|
||||
type: ArchShapeType.rect,
|
||||
rect: Rect.fromLTWH(200, 0, 100, 60),
|
||||
));
|
||||
c.beginArchErase();
|
||||
expect(c.eraseArchIds(<String>{'S1'}), 1);
|
||||
expect(c.eraseArchIds(<String>{'S2'}), 1);
|
||||
expect(c.arch.shapes, isEmpty);
|
||||
c.undo();
|
||||
expect(c.arch.shapes.length, 2, reason: '一次连续擦除应整步回退');
|
||||
});
|
||||
});
|
||||
|
||||
group('手绘识别模式', () {
|
||||
test('默认自动(桌面);可切换手动确认', () {
|
||||
final AppController c = AppController(project: Project.demo());
|
||||
addTearDown(c.dispose);
|
||||
expect(c.archAutoRecognize, isTrue); // Windows 测试环境
|
||||
c.setArchAutoRecognize(false);
|
||||
expect(c.archAutoRecognize, isFalse);
|
||||
expect(c.status, contains('手动'));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// ===================== 手绘样本生成(确定性抖动) =====================
|
||||
|
||||
Reference in New Issue
Block a user