2026-10-11 10:19:01 +08:00
|
|
|
|
/// 架构图模块侧栏内容:
|
|
|
|
|
|
/// - 左侧(工具):手绘识别、绘图辅助(F8 / F10)、网格吸附与粒度、
|
|
|
|
|
|
/// 参数化草图、连线走线方式、图形库、颜色、示例场景、操作提示;
|
|
|
|
|
|
/// - 右侧(属性):选中对象(支持多选)信息与操作。
|
|
|
|
|
|
///
|
|
|
|
|
|
/// 外层容器(宽度 / 边框 / 标题栏)由 `app_shell.dart` 负责,本文件只提供主体。
|
|
|
|
|
|
library;
|
|
|
|
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
|
|
|
|
import '../arch/arch_models.dart';
|
|
|
|
|
|
import '../sketch/sketch_models.dart';
|
|
|
|
|
|
import '../sketch/sketch_solver.dart';
|
|
|
|
|
|
import '../state/app_controller.dart';
|
|
|
|
|
|
import '../theme/tokens.dart';
|
|
|
|
|
|
import 'dialogs.dart';
|
|
|
|
|
|
|
|
|
|
|
|
/// 小节标题。
|
|
|
|
|
|
Widget _sec(Tokens t, String s) => Text(
|
|
|
|
|
|
s,
|
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text2,
|
|
|
|
|
|
fontSize: 11.5,
|
|
|
|
|
|
letterSpacing: 1.2,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/// 架构图左侧栏主体。
|
|
|
|
|
|
class ArchLeftBody extends StatelessWidget {
|
|
|
|
|
|
/// 构造左侧栏主体。
|
|
|
|
|
|
const ArchLeftBody({super.key, required this.controller});
|
|
|
|
|
|
|
|
|
|
|
|
/// 全局应用控制器。
|
|
|
|
|
|
final AppController controller;
|
|
|
|
|
|
|
|
|
|
|
|
/// 构建:手绘模式 → 网格 → 连线 → 图形库 → 颜色 → 示例 → 提示。
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final Tokens t = context.tok;
|
|
|
|
|
|
final AppController c = controller;
|
|
|
|
|
|
final ArchDoc doc = c.arch;
|
|
|
|
|
|
return Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_sec(t, '手绘识别'),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Text(
|
2026-10-11 11:22:01 +08:00
|
|
|
|
'笔迹一律扶正为标准图形(矩形 / 圆 / 箭头 / 折线 / 曲线):支持两笔组合、'
|
2026-10-11 21:38:18 +08:00
|
|
|
|
'圆柱拼接;识别不了的保留为墨迹,可用「橡皮」擦除。文字请双击图形 / 空白处直接输入。',
|
2026-10-11 10:19:01 +08:00
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10, height: 1.5),
|
|
|
|
|
|
),
|
2026-10-11 11:22:01 +08:00
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Text('松手自动识别',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 11)),
|
|
|
|
|
|
),
|
|
|
|
|
|
Switch(
|
|
|
|
|
|
value: c.archAutoRecognize,
|
|
|
|
|
|
onChanged: c.setArchAutoRecognize,
|
|
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
if (!c.archAutoRecognize)
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'已关闭:笔迹先保留为墨迹(${c.arch.strokes.length} 笔待识别),'
|
|
|
|
|
|
'点顶部「识别」按钮统一确认(平板手写推荐)。',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10, height: 1.5),
|
|
|
|
|
|
),
|
2026-10-11 10:19:01 +08:00
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
_sec(t, '绘图辅助(F8 / F10)'),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(10, 6, 6, 8),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: t.info,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
|
border: Border.all(color: t.line),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Icon(Icons.straighten, size: 15, color: t.accent),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Text('正交移动(F8)',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text,
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
)),
|
|
|
|
|
|
),
|
|
|
|
|
|
Switch(
|
|
|
|
|
|
value: c.archOrtho,
|
|
|
|
|
|
onChanged: c.setArchOrtho,
|
|
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Icon(Icons.polyline_outlined, size: 15, color: t.accent),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Text('极轴追踪(F10)',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text,
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
)),
|
|
|
|
|
|
),
|
|
|
|
|
|
Switch(
|
|
|
|
|
|
value: c.archPolar,
|
|
|
|
|
|
onChanged: c.setArchPolar,
|
|
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
if (c.archPolar)
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
padding: const EdgeInsets.only(bottom: 6),
|
|
|
|
|
|
child: Wrap(
|
|
|
|
|
|
spacing: 6,
|
|
|
|
|
|
runSpacing: 6,
|
|
|
|
|
|
crossAxisAlignment: WrapCrossAlignment.center,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Text('极轴角度', style: TextStyle(color: t.sub, fontSize: 10.5)),
|
|
|
|
|
|
for (final double a in <double>[5, 10, 15, 22.5, 30, 45])
|
|
|
|
|
|
_chip(
|
|
|
|
|
|
t,
|
|
|
|
|
|
'${a == a.roundToDouble() ? a.round() : a}°',
|
|
|
|
|
|
c.archPolarDeg == a,
|
|
|
|
|
|
() => c.setArchPolarDeg(a),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Icon(Icons.square_foot, size: 15, color: t.dim),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Text('四边标尺',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text,
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
)),
|
|
|
|
|
|
),
|
|
|
|
|
|
Switch(
|
|
|
|
|
|
value: c.archRulers,
|
|
|
|
|
|
onChanged: c.setArchRulers,
|
|
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
Text('正交:移动只走水平 / 垂直;极轴:移动方向吸附到角度倍数;'
|
|
|
|
|
|
'标尺上的滑动虚线指示鼠标位置。',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10, height: 1.5)),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
_sec(t, '网格'),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Container(
|
|
|
|
|
|
padding: const EdgeInsets.fromLTRB(10, 6, 6, 8),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: t.info,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
|
border: Border.all(color: t.line),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Icon(Icons.grid_4x4, size: 15, color: t.accent),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Text('吸附网格',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text,
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
)),
|
|
|
|
|
|
),
|
|
|
|
|
|
Switch(
|
|
|
|
|
|
value: doc.gridSnap,
|
|
|
|
|
|
onChanged: (bool v) => c.setArchGrid(snap: v),
|
|
|
|
|
|
materialTapTargetSize: MaterialTapTargetSize.shrinkWrap,
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Text('粒度',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 10.5)),
|
|
|
|
|
|
const SizedBox(width: 8),
|
|
|
|
|
|
for (final double g in <double>[10, 20, 40, 80])
|
|
|
|
|
|
Padding(
|
|
|
|
|
|
padding: const EdgeInsets.only(right: 6),
|
|
|
|
|
|
child: _chip(
|
|
|
|
|
|
t,
|
|
|
|
|
|
'${g.round()}',
|
|
|
|
|
|
doc.gridSize == g,
|
|
|
|
|
|
() => c.setArchGrid(size: g),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
Text('识别、移动与缩放时会优先对位到网格。',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10, height: 1.5)),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
_sec(t, '连线'),
|
|
|
|
|
|
const SizedBox(height: 6),
|
2026-10-11 11:22:01 +08:00
|
|
|
|
Text('画路径即出连线,一律横平竖直(正交);端点自动吸附图元边框,'
|
|
|
|
|
|
'选中后拖拽路径上的角点可调整走线位置。',
|
2026-10-11 10:19:01 +08:00
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10, height: 1.5)),
|
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
_sec(t, '图形库'),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Wrap(
|
|
|
|
|
|
spacing: 6,
|
|
|
|
|
|
runSpacing: 6,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_libBtn(t, Icons.crop_square, '矩形', ArchShapeType.rect),
|
|
|
|
|
|
_libBtn(t, Icons.rounded_corner, '圆角矩形', ArchShapeType.roundRect),
|
|
|
|
|
|
_libBtn(t, Icons.panorama_fish_eye, '椭圆', ArchShapeType.ellipse),
|
|
|
|
|
|
_libBtn(t, Icons.circle_outlined, '圆形', ArchShapeType.circle),
|
|
|
|
|
|
_libBtn(t, Icons.change_history, '三角形', ArchShapeType.triangle),
|
|
|
|
|
|
_libBtn(t, Icons.diamond_outlined, '菱形', ArchShapeType.diamond),
|
|
|
|
|
|
_libBtn(t, Icons.hexagon_outlined, '六边形', ArchShapeType.hexagon),
|
|
|
|
|
|
_libBtn(t, Icons.storage, '圆柱', ArchShapeType.cylinder),
|
|
|
|
|
|
_libBtn(t, Icons.cloud_outlined, '云', ArchShapeType.cloud),
|
|
|
|
|
|
_libBtn(t, Icons.text_fields, '文本', ArchShapeType.text),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 10),
|
|
|
|
|
|
Text('IT / 系统设计',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10)),
|
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
Wrap(
|
|
|
|
|
|
spacing: 6,
|
|
|
|
|
|
runSpacing: 6,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_libBtn(t, Icons.dns_outlined, '服务器', ArchShapeType.server),
|
|
|
|
|
|
_libBtn(t, Icons.desktop_windows_outlined, '客户端',
|
|
|
|
|
|
ArchShapeType.client),
|
|
|
|
|
|
_libBtn(t, Icons.smartphone, '移动端', ArchShapeType.mobile),
|
|
|
|
|
|
_libBtn(t, Icons.security, '防火墙', ArchShapeType.firewall),
|
|
|
|
|
|
_libBtn(t, Icons.lan_outlined, '交换机', ArchShapeType.netSwitch),
|
|
|
|
|
|
_libBtn(t, Icons.view_stream_outlined, '消息队列',
|
|
|
|
|
|
ArchShapeType.queue),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
_sec(t, '颜色'),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Wrap(
|
|
|
|
|
|
spacing: 8,
|
|
|
|
|
|
runSpacing: 8,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
for (final int col in kArchPalette) _colorDot(t, c, col),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
Text('影响新绘制的图形;选中图形后点色块可直接换色(支持多选)。',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10, height: 1.5)),
|
|
|
|
|
|
const SizedBox(height: 14),
|
2026-10-11 12:13:05 +08:00
|
|
|
|
SizedBox(
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
child: TextButton.icon(
|
|
|
|
|
|
onPressed: c.archClear,
|
|
|
|
|
|
icon: const Icon(Icons.delete_sweep_outlined, size: 15),
|
|
|
|
|
|
label: const Text('清空画布'),
|
|
|
|
|
|
style: TextButton.styleFrom(
|
|
|
|
|
|
foregroundColor: t.danger,
|
|
|
|
|
|
visualDensity: VisualDensity.compact,
|
|
|
|
|
|
textStyle: const TextStyle(
|
|
|
|
|
|
fontSize: 11.5,
|
|
|
|
|
|
fontFamily: 'Microsoft YaHei UI',
|
|
|
|
|
|
fontFamilyFallback: <String>[
|
|
|
|
|
|
'Microsoft YaHei',
|
|
|
|
|
|
'Segoe UI',
|
|
|
|
|
|
'sans-serif',
|
|
|
|
|
|
],
|
2026-10-11 10:19:01 +08:00
|
|
|
|
),
|
|
|
|
|
|
),
|
2026-10-11 12:13:05 +08:00
|
|
|
|
),
|
2026-10-11 10:19:01 +08:00
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
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.warn, fontSize: 11, fontWeight: FontWeight.w700)),
|
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
Text('手绘:按住拖动 → 松手自动识别',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 10, height: 1.6)),
|
|
|
|
|
|
Text('空白处左键拖拽 = 框选;中键 / 右键拖拽 = 平移',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 10, height: 1.6)),
|
|
|
|
|
|
Text('触屏:单指平移 · 长按框选 · 双指捏合缩放',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 10, height: 1.6)),
|
|
|
|
|
|
Text('双击图形 / 连线编辑文字 · Del 删除选中 · Ctrl+A 全选',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 10, height: 1.6)),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 粒度小圆片。
|
|
|
|
|
|
Widget _chip(Tokens t, String label, bool active, VoidCallback onTap) {
|
|
|
|
|
|
return InkWell(
|
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(7),
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 9, vertical: 4),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: active ? t.accent.withValues(alpha: 0.16) : t.panel2,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(7),
|
|
|
|
|
|
border: Border.all(color: active ? t.accent : t.line),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
label,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: active ? t.accent : t.sub,
|
|
|
|
|
|
fontSize: 10.5,
|
|
|
|
|
|
fontWeight: active ? FontWeight.w700 : FontWeight.w500,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 图形库按钮:点击后在视口中心插入一个标准图形。
|
|
|
|
|
|
Widget _libBtn(Tokens t, IconData icon, String label, ArchShapeType type) {
|
|
|
|
|
|
return InkWell(
|
|
|
|
|
|
onTap: () => _insert(type),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(9),
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
width: 82,
|
|
|
|
|
|
height: 56,
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: t.panel2,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(9),
|
|
|
|
|
|
border: Border.all(color: t.line),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
mainAxisAlignment: MainAxisAlignment.center,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Icon(icon, size: 18, color: t.sub),
|
|
|
|
|
|
const SizedBox(height: 3),
|
|
|
|
|
|
Text(label, style: TextStyle(color: t.sub, fontSize: 10.5)),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 在视口中心插入标准图形(位置按网格吸附)。
|
|
|
|
|
|
void _insert(ArchShapeType type) {
|
|
|
|
|
|
final AppController c = controller;
|
|
|
|
|
|
final ArchDoc doc = c.arch;
|
|
|
|
|
|
final Size vp = c.archViewport;
|
|
|
|
|
|
final Size d = archDefaultSize(type);
|
|
|
|
|
|
final Offset center = vp.width < 10 || vp.height < 10
|
|
|
|
|
|
? const Offset(400, 300)
|
|
|
|
|
|
: Offset(
|
|
|
|
|
|
(vp.width / 2 - doc.panX) / doc.zoom,
|
|
|
|
|
|
(vp.height / 2 - doc.panY) / doc.zoom,
|
|
|
|
|
|
);
|
|
|
|
|
|
Rect r = Rect.fromCenter(center: center, width: d.width, height: d.height);
|
|
|
|
|
|
if (doc.gridSnap && doc.gridSize > 1) {
|
|
|
|
|
|
final Offset tl = archSnapPoint(doc, r.topLeft);
|
|
|
|
|
|
r = Rect.fromLTWH(tl.dx, tl.dy, r.width, r.height);
|
|
|
|
|
|
}
|
|
|
|
|
|
final int color = c.archColor;
|
|
|
|
|
|
final ArchShape s = ArchShape(
|
|
|
|
|
|
id: archNewId('S', doc.allIds),
|
|
|
|
|
|
type: type,
|
|
|
|
|
|
rect: r,
|
|
|
|
|
|
radius: type == ArchShapeType.roundRect ? 16 : 0,
|
|
|
|
|
|
fill: type == ArchShapeType.text ? 0 : archFillOf(color),
|
|
|
|
|
|
stroke: color,
|
|
|
|
|
|
sw: 1.8,
|
|
|
|
|
|
text: type == ArchShapeType.text ? '文本' : '',
|
|
|
|
|
|
);
|
|
|
|
|
|
c.addArchShape(s);
|
|
|
|
|
|
c.selectArch(s.id);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 颜色圆点。
|
|
|
|
|
|
Widget _colorDot(Tokens t, AppController c, int col) {
|
|
|
|
|
|
final bool active = c.archColor == col;
|
|
|
|
|
|
return InkWell(
|
|
|
|
|
|
onTap: () => c.setArchColor(col),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(16),
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
width: 26,
|
|
|
|
|
|
height: 26,
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: Color(col),
|
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
|
border: Border.all(
|
|
|
|
|
|
color: active ? t.accent : t.line,
|
|
|
|
|
|
width: active ? 2.5 : 1,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 架构图右侧栏主体:选中对象属性(支持多选)。
|
|
|
|
|
|
class ArchRightBody extends StatelessWidget {
|
|
|
|
|
|
/// 构造右侧栏主体。
|
|
|
|
|
|
const ArchRightBody({super.key, required this.controller});
|
|
|
|
|
|
|
|
|
|
|
|
/// 全局应用控制器。
|
|
|
|
|
|
final AppController controller;
|
|
|
|
|
|
|
|
|
|
|
|
/// 构建:草图模式 → 草图面板;否则选中对象卡片 + 统计。
|
|
|
|
|
|
@override
|
|
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
|
|
final Tokens t = context.tok;
|
|
|
|
|
|
final AppController c = controller;
|
|
|
|
|
|
if (c.sketchMode) return _sketchBody(context, c);
|
|
|
|
|
|
final ArchDoc doc = c.arch;
|
|
|
|
|
|
final List<String> sel = c.archSelIds;
|
|
|
|
|
|
final ArchShape? s = sel.length == 1 ? doc.shapeById(sel.first) : null;
|
|
|
|
|
|
final ArchConnector? cn =
|
|
|
|
|
|
sel.length == 1 ? doc.connectorById(sel.first) : null;
|
|
|
|
|
|
final ArchStroke? st = sel.length == 1 ? doc.strokeById(sel.first) : null;
|
|
|
|
|
|
return Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_sec(t, '选中对象'),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
if (sel.length > 1)
|
|
|
|
|
|
_card(t, <Widget>[
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'已选中 ${sel.length} 个对象',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text,
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
Text('拖动任一选中图形可整体移动;改色作用于选中的图形。',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10.5, height: 1.5)),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_mini(t, '全选', c.selectAllArch),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
_mini(t, '取消选择', () => c.selectArch(null)),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Text('对齐 / 均布(以选中范围为参照;均布需 ≥3 个)',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10.5)),
|
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
Wrap(
|
|
|
|
|
|
spacing: 4,
|
|
|
|
|
|
runSpacing: 4,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_alignBtn(t, Icons.align_horizontal_left, '左对齐', ArchAlign.left, c),
|
|
|
|
|
|
_alignBtn(t, Icons.align_horizontal_center, '横向居中', ArchAlign.hCenter, c),
|
|
|
|
|
|
_alignBtn(t, Icons.align_horizontal_right, '右对齐', ArchAlign.right, c),
|
|
|
|
|
|
_alignBtn(t, Icons.align_vertical_top, '顶对齐', ArchAlign.top, c),
|
|
|
|
|
|
_alignBtn(t, Icons.align_vertical_center, '纵向居中', ArchAlign.vCenter, c),
|
|
|
|
|
|
_alignBtn(t, Icons.align_vertical_bottom, '底对齐', ArchAlign.bottom, c),
|
|
|
|
|
|
_alignBtn(t, Icons.horizontal_distribute, '横向均布', ArchAlign.distributeH, c),
|
|
|
|
|
|
_alignBtn(t, Icons.vertical_distribute, '纵向均布', ArchAlign.distributeV, c),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
_mini(t, '删除(Del)', c.removeArchSelection, danger: true),
|
|
|
|
|
|
])
|
|
|
|
|
|
else if (s != null)
|
|
|
|
|
|
_card(t, <Widget>[
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Icon(_iconOf(s.type), size: 15, color: Color(s.stroke)),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
'${archShapeTypeLabel(s.type)} · ${s.id}',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text,
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
if (!s.isLinear)
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'尺寸 ${s.rect.width.round()} × ${s.rect.height.round()} px',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10.5),
|
|
|
|
|
|
),
|
|
|
|
|
|
if (s.isLinear)
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'${s.type == ArchShapeType.line && s.a != null ? 2 : s.pts.length} 个折点'
|
|
|
|
|
|
'${s.arrow ? ' · 箭头' : ''}',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10.5),
|
|
|
|
|
|
),
|
|
|
|
|
|
if (s.text.isNotEmpty)
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'文字:${s.text.replaceAll('\n', ' / ')}',
|
|
|
|
|
|
maxLines: 2,
|
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 11),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 8),
|
2026-10-11 12:13:05 +08:00
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_mini(t, '编辑文字', () => _editText(context, c, s)),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
_mini(t, '上移一层', () => c.moveArchZ(s, 1)),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
_mini(t, '下移一层', () => c.moveArchZ(s, -1)),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
if (s.type == ArchShapeType.polyline ||
|
|
|
|
|
|
s.type == ArchShapeType.curve) ...<Widget>[
|
|
|
|
|
|
_mini(
|
|
|
|
|
|
t,
|
|
|
|
|
|
s.type == ArchShapeType.polyline ? '平滑为曲线' : '折线化',
|
|
|
|
|
|
() => _togglePolyCurve(c, s),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
],
|
|
|
|
|
|
_mini(t, '删除(Del)', c.removeArchSelection, danger: true),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
2026-10-11 10:19:01 +08:00
|
|
|
|
])
|
|
|
|
|
|
else if (cn != null)
|
|
|
|
|
|
_card(t, <Widget>[
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'连线 · ${cn.id}',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text,
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
cn.label.isEmpty ? '(无标签)' : '标签:${cn.label}',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 11),
|
|
|
|
|
|
),
|
2026-10-11 11:22:01 +08:00
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'走线:一律正交(横平竖直);拖拽路径上的角点可调整走线位置。',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10.5, height: 1.5),
|
2026-10-11 10:19:01 +08:00
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_mini(t, '编辑标签', () => _editConnLabel(context, c, cn)),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
_mini(t, '删除(Del)', c.removeArchSelection, danger: true),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
])
|
|
|
|
|
|
else if (st != null)
|
|
|
|
|
|
_card(t, <Widget>[
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'手绘墨迹 · ${st.id}',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text,
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'${st.pts.length} 个采样点(识别不了的笔迹保留为墨迹)',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 11),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_mini(t, '删除(Del)', c.removeArchSelection, danger: true),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
])
|
|
|
|
|
|
else
|
|
|
|
|
|
_card(t, <Widget>[
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'未选中任何对象',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text,
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.w600,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'点选图形 / 连线 / 墨迹查看属性;空白拖拽框选,双击图形编辑文字。',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10.5, height: 1.5),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
_mini(t, '全选(Ctrl+A)', c.selectAllArch),
|
|
|
|
|
|
]),
|
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_sec(t, '图层'),
|
|
|
|
|
|
const Spacer(),
|
|
|
|
|
|
InkWell(
|
|
|
|
|
|
onTap: c.addArchLayer,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(7),
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
padding:
|
|
|
|
|
|
const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: t.panel2,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(7),
|
|
|
|
|
|
border: Border.all(color: t.line),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
mainAxisSize: MainAxisSize.min,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
Icon(Icons.add, size: 13, color: t.sub),
|
|
|
|
|
|
const SizedBox(width: 3),
|
|
|
|
|
|
Text('新建', style: TextStyle(color: t.sub, fontSize: 10.5)),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
for (final ArchLayer ly in doc.layers) _layerRow(context, t, c, ly),
|
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
_sec(t, '统计'),
|
|
|
|
|
|
const SizedBox(height: 6),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'元件 ${doc.shapes.length} · 连线 ${doc.connectors.length} · 墨迹 ${doc.strokes.length}',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 11),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'架构图保存为独立文件(*.arch.json),不与时序图互通。',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10, height: 1.5),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 弹窗编辑图形文字(画布内也可双击图形直接编辑)。
|
|
|
|
|
|
Future<void> _editText(
|
|
|
|
|
|
BuildContext context,
|
|
|
|
|
|
AppController c,
|
|
|
|
|
|
ArchShape s,
|
|
|
|
|
|
) async {
|
|
|
|
|
|
final String? r =
|
|
|
|
|
|
await showTextEditDialog(context, title: '编辑图形文字', initial: s.text);
|
|
|
|
|
|
if (r != null && r != s.text) {
|
|
|
|
|
|
c.updateArchShape(s.copyWith(text: r), status: '编辑文字');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 弹窗编辑连线标签(画布内也可双击连线直接编辑)。
|
|
|
|
|
|
Future<void> _editConnLabel(
|
|
|
|
|
|
BuildContext context,
|
|
|
|
|
|
AppController c,
|
|
|
|
|
|
ArchConnector cn,
|
|
|
|
|
|
) async {
|
|
|
|
|
|
final String? r =
|
|
|
|
|
|
await showTextEditDialog(context, title: '编辑连线标签', initial: cn.label);
|
|
|
|
|
|
if (r != null && r != cn.label) {
|
|
|
|
|
|
c.updateArchConnector(cn.copyWith(label: r), status: '编辑连线标签');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 折线 ⇄ 曲线互转(同一组通过点)。
|
|
|
|
|
|
void _togglePolyCurve(AppController c, ArchShape s) {
|
|
|
|
|
|
if (s.type == ArchShapeType.polyline) {
|
|
|
|
|
|
c.updateArchShape(s.copyWith(type: ArchShapeType.curve),
|
|
|
|
|
|
status: '已平滑为曲线');
|
|
|
|
|
|
} else if (s.type == ArchShapeType.curve) {
|
|
|
|
|
|
c.updateArchShape(s.copyWith(type: ArchShapeType.polyline),
|
|
|
|
|
|
status: '已折线化');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 图层条目:可见 / 锁定 / 颜色 / 名称(单击设为活动、双击改名)/ 删除。
|
|
|
|
|
|
Widget _layerRow(
|
|
|
|
|
|
BuildContext context,
|
|
|
|
|
|
Tokens t,
|
|
|
|
|
|
AppController c,
|
|
|
|
|
|
ArchLayer ly,
|
|
|
|
|
|
) {
|
|
|
|
|
|
final ArchDoc doc = c.arch;
|
|
|
|
|
|
final bool active = doc.activeLayer == ly.id;
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
margin: const EdgeInsets.only(bottom: 4),
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 6, vertical: 2),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: active ? t.accent.withValues(alpha: 0.12) : t.panel2,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
|
border: Border.all(color: active ? t.accent : t.line),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_layerMiniIcon(
|
|
|
|
|
|
t,
|
|
|
|
|
|
ly.visible ? Icons.visibility_outlined : Icons.visibility_off_outlined,
|
|
|
|
|
|
ly.visible ? t.sub : t.dim,
|
|
|
|
|
|
() => c.toggleArchLayerVisible(ly.id),
|
|
|
|
|
|
ly.visible ? '隐藏图层' : '显示图层',
|
|
|
|
|
|
),
|
|
|
|
|
|
_layerMiniIcon(
|
|
|
|
|
|
t,
|
|
|
|
|
|
ly.locked ? Icons.lock_outline : Icons.lock_open_outlined,
|
|
|
|
|
|
ly.locked ? t.warn : t.sub,
|
|
|
|
|
|
() => c.toggleArchLayerLocked(ly.id),
|
|
|
|
|
|
ly.locked ? '解锁图层' : '锁定图层',
|
|
|
|
|
|
),
|
|
|
|
|
|
InkWell(
|
|
|
|
|
|
onTap: () => _pickLayerColor(context, c, ly),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
padding: const EdgeInsets.all(3),
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
width: 15,
|
|
|
|
|
|
height: 15,
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: Color(ly.color),
|
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
|
border: Border.all(color: t.line),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(width: 4),
|
|
|
|
|
|
Expanded(
|
|
|
|
|
|
child: GestureDetector(
|
|
|
|
|
|
onTap: () => c.setArchActiveLayer(ly.id),
|
|
|
|
|
|
onDoubleTap: () => _renameLayer(context, c, ly),
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
ly.name,
|
|
|
|
|
|
maxLines: 1,
|
|
|
|
|
|
overflow: TextOverflow.ellipsis,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: active ? t.accent : t.text,
|
|
|
|
|
|
fontSize: 11.5,
|
|
|
|
|
|
fontWeight: active ? FontWeight.w700 : FontWeight.w500,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
if (doc.layers.length > 1)
|
|
|
|
|
|
_layerMiniIcon(
|
|
|
|
|
|
t,
|
|
|
|
|
|
Icons.close,
|
|
|
|
|
|
t.dim,
|
|
|
|
|
|
() => c.removeArchLayer(ly.id),
|
|
|
|
|
|
'删除图层(对象移入首层)',
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 图层行内小图标按钮。
|
|
|
|
|
|
Widget _layerMiniIcon(
|
|
|
|
|
|
Tokens t,
|
|
|
|
|
|
IconData icon,
|
|
|
|
|
|
Color color,
|
|
|
|
|
|
VoidCallback onTap,
|
|
|
|
|
|
String tip,
|
|
|
|
|
|
) {
|
|
|
|
|
|
return Tooltip(
|
|
|
|
|
|
message: tip,
|
|
|
|
|
|
child: InkWell(
|
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(6),
|
|
|
|
|
|
child: Padding(
|
|
|
|
|
|
padding: const EdgeInsets.all(4),
|
|
|
|
|
|
child: Icon(icon, size: 14, color: color),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 重命名图层(弹窗)。
|
|
|
|
|
|
Future<void> _renameLayer(
|
|
|
|
|
|
BuildContext context,
|
|
|
|
|
|
AppController c,
|
|
|
|
|
|
ArchLayer ly,
|
|
|
|
|
|
) async {
|
|
|
|
|
|
final String? r =
|
|
|
|
|
|
await showTextEditDialog(context, title: '重命名图层', initial: ly.name);
|
|
|
|
|
|
if (r != null && r.trim().isNotEmpty && r != ly.name) {
|
|
|
|
|
|
c.updateArchLayer(ly.copyWith(name: r.trim()), status: '图层已重命名');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 选择图层颜色(调色板弹窗)。
|
|
|
|
|
|
Future<void> _pickLayerColor(
|
|
|
|
|
|
BuildContext context,
|
|
|
|
|
|
AppController c,
|
|
|
|
|
|
ArchLayer ly,
|
|
|
|
|
|
) async {
|
|
|
|
|
|
final int? picked = await showDialog<int>(
|
|
|
|
|
|
context: context,
|
|
|
|
|
|
builder: (BuildContext ctx) {
|
|
|
|
|
|
final Tokens tt = ctx.tok;
|
|
|
|
|
|
return AlertDialog(
|
|
|
|
|
|
backgroundColor: tt.dialog,
|
|
|
|
|
|
title: Text('图层颜色',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: tt.text, fontSize: 15, fontWeight: FontWeight.w700)),
|
|
|
|
|
|
content: Wrap(
|
|
|
|
|
|
spacing: 10,
|
|
|
|
|
|
runSpacing: 10,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
for (final int col in kArchPalette)
|
|
|
|
|
|
InkWell(
|
|
|
|
|
|
onTap: () => Navigator.of(ctx).pop(col),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(18),
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
width: 30,
|
|
|
|
|
|
height: 30,
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: Color(col),
|
|
|
|
|
|
shape: BoxShape.circle,
|
|
|
|
|
|
border: Border.all(
|
|
|
|
|
|
color: col == ly.color ? tt.accent : tt.line,
|
|
|
|
|
|
width: col == ly.color ? 2.5 : 1,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
actions: <Widget>[
|
|
|
|
|
|
TextButton(
|
|
|
|
|
|
onPressed: () => Navigator.of(ctx).pop(),
|
|
|
|
|
|
child: const Text('取消')),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
},
|
|
|
|
|
|
);
|
|
|
|
|
|
if (picked != null) {
|
|
|
|
|
|
c.updateArchLayer(ly.copyWith(color: picked), status: '图层颜色已更新');
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 卡片容器。
|
|
|
|
|
|
/// 草图模式的右侧栏:选中对象 / 统计 / 提示。
|
|
|
|
|
|
Widget _sketchBody(BuildContext context, AppController c) {
|
|
|
|
|
|
final Tokens t = context.tok;
|
|
|
|
|
|
final SketchDoc d = c.sketch;
|
|
|
|
|
|
final List<String> sel = c.sketchSelIds;
|
|
|
|
|
|
final int consCount =
|
|
|
|
|
|
d.constraints.where((SketchConstraint k) => !k.internal).length;
|
|
|
|
|
|
return Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_sec(t, '草图 · 选中对象'),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
_card(t, <Widget>[
|
|
|
|
|
|
Text(
|
|
|
|
|
|
sel.isEmpty ? '未选中任何草图对象' : '已选中 ${sel.length} 个对象',
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: t.text,
|
|
|
|
|
|
fontSize: 12,
|
|
|
|
|
|
fontWeight: FontWeight.w700,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
'点 / 实体 / 尺寸都可选中;拖动点或图形会按约束实时求解,'
|
|
|
|
|
|
'双击尺寸标签可直接改值。',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10.5, height: 1.5),
|
|
|
|
|
|
),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
Row(
|
|
|
|
|
|
children: <Widget>[
|
|
|
|
|
|
_mini(t, '全选', c.selectAllSketch),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
_mini(t, '取消选择', () => c.selectSketchIds(const <String>[])),
|
|
|
|
|
|
const SizedBox(width: 6),
|
|
|
|
|
|
_mini(t, '删除(Del)', c.deleteSketchSelection, danger: true),
|
|
|
|
|
|
],
|
|
|
|
|
|
),
|
|
|
|
|
|
]),
|
|
|
|
|
|
const SizedBox(height: 14),
|
|
|
|
|
|
_sec(t, '草图统计'),
|
|
|
|
|
|
const SizedBox(height: 8),
|
|
|
|
|
|
_card(t, <Widget>[
|
|
|
|
|
|
Text('点 ${d.points.length} · 实体 ${d.entities.length}',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 11.5)),
|
|
|
|
|
|
Text('约束 $consCount · 尺寸 ${d.dims.length}',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 11.5)),
|
|
|
|
|
|
Text('剩余自由度 ${sketchDofCount(d)}',
|
|
|
|
|
|
style: TextStyle(color: t.sub, fontSize: 11.5)),
|
|
|
|
|
|
const SizedBox(height: 4),
|
|
|
|
|
|
Text(
|
|
|
|
|
|
sketchDofCount(d) == 0
|
|
|
|
|
|
? '已全约束:几何被尺寸 / 约束完全驱动。'
|
|
|
|
|
|
: '欠约束:可继续添加约束 / 尺寸,或直接拖动试解。',
|
|
|
|
|
|
style: TextStyle(color: t.dim, fontSize: 10.5, height: 1.5),
|
|
|
|
|
|
),
|
|
|
|
|
|
]),
|
|
|
|
|
|
],
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 属性卡片容器。
|
|
|
|
|
|
Widget _card(Tokens t, List<Widget> children) {
|
|
|
|
|
|
return Container(
|
|
|
|
|
|
width: double.infinity,
|
|
|
|
|
|
padding: const EdgeInsets.all(10),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: t.panel2,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(10),
|
|
|
|
|
|
border: Border.all(color: t.line),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Column(
|
|
|
|
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
|
|
|
|
children: children,
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 小按钮。
|
|
|
|
|
|
Widget _mini(
|
|
|
|
|
|
Tokens t,
|
|
|
|
|
|
String label,
|
|
|
|
|
|
VoidCallback onTap, {
|
|
|
|
|
|
bool danger = false,
|
|
|
|
|
|
bool active = false,
|
|
|
|
|
|
}) {
|
|
|
|
|
|
return InkWell(
|
|
|
|
|
|
onTap: onTap,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6),
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: danger
|
|
|
|
|
|
? t.danger.withValues(alpha: 0.12)
|
|
|
|
|
|
: (active ? t.accent.withValues(alpha: 0.16) : t.panel),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(8),
|
|
|
|
|
|
border: Border.all(
|
|
|
|
|
|
color: danger
|
|
|
|
|
|
? t.danger.withValues(alpha: 0.45)
|
|
|
|
|
|
: (active ? t.accent : t.line),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Text(
|
|
|
|
|
|
label,
|
|
|
|
|
|
style: TextStyle(
|
|
|
|
|
|
color: danger ? t.danger : (active ? t.accent : t.sub),
|
|
|
|
|
|
fontSize: 11,
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 对齐 / 均布小按钮(图标 + 悬浮提示)。
|
|
|
|
|
|
Widget _alignBtn(
|
|
|
|
|
|
Tokens t,
|
|
|
|
|
|
IconData icon,
|
|
|
|
|
|
String tip,
|
|
|
|
|
|
ArchAlign mode,
|
|
|
|
|
|
AppController c,
|
|
|
|
|
|
) {
|
|
|
|
|
|
return Tooltip(
|
|
|
|
|
|
message: tip,
|
|
|
|
|
|
child: InkWell(
|
|
|
|
|
|
onTap: () => c.alignArchSelection(mode),
|
|
|
|
|
|
borderRadius: BorderRadius.circular(7),
|
|
|
|
|
|
child: Container(
|
|
|
|
|
|
width: 30,
|
|
|
|
|
|
height: 28,
|
|
|
|
|
|
decoration: BoxDecoration(
|
|
|
|
|
|
color: t.panel,
|
|
|
|
|
|
borderRadius: BorderRadius.circular(7),
|
|
|
|
|
|
border: Border.all(color: t.line),
|
|
|
|
|
|
),
|
|
|
|
|
|
child: Icon(icon, size: 15, color: t.sub),
|
|
|
|
|
|
),
|
|
|
|
|
|
),
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// 图形类型对应的小图标。
|
|
|
|
|
|
IconData _iconOf(ArchShapeType type) {
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
case ArchShapeType.rect:
|
|
|
|
|
|
return Icons.crop_square;
|
|
|
|
|
|
case ArchShapeType.roundRect:
|
|
|
|
|
|
return Icons.rounded_corner;
|
|
|
|
|
|
case ArchShapeType.ellipse:
|
|
|
|
|
|
return Icons.panorama_fish_eye;
|
|
|
|
|
|
case ArchShapeType.circle:
|
|
|
|
|
|
return Icons.circle_outlined;
|
|
|
|
|
|
case ArchShapeType.triangle:
|
|
|
|
|
|
return Icons.change_history;
|
|
|
|
|
|
case ArchShapeType.diamond:
|
|
|
|
|
|
return Icons.diamond_outlined;
|
|
|
|
|
|
case ArchShapeType.cylinder:
|
|
|
|
|
|
return Icons.storage;
|
|
|
|
|
|
case ArchShapeType.cloud:
|
|
|
|
|
|
return Icons.cloud_outlined;
|
|
|
|
|
|
case ArchShapeType.hexagon:
|
|
|
|
|
|
return Icons.hexagon_outlined;
|
|
|
|
|
|
case ArchShapeType.text:
|
|
|
|
|
|
return Icons.text_fields;
|
|
|
|
|
|
case ArchShapeType.line:
|
|
|
|
|
|
return Icons.trending_flat;
|
|
|
|
|
|
case ArchShapeType.polyline:
|
|
|
|
|
|
return Icons.polyline;
|
|
|
|
|
|
case ArchShapeType.curve:
|
|
|
|
|
|
return Icons.gesture;
|
|
|
|
|
|
case ArchShapeType.server:
|
|
|
|
|
|
return Icons.dns_outlined;
|
|
|
|
|
|
case ArchShapeType.client:
|
|
|
|
|
|
return Icons.desktop_windows_outlined;
|
|
|
|
|
|
case ArchShapeType.mobile:
|
|
|
|
|
|
return Icons.smartphone;
|
|
|
|
|
|
case ArchShapeType.firewall:
|
|
|
|
|
|
return Icons.security;
|
|
|
|
|
|
case ArchShapeType.netSwitch:
|
|
|
|
|
|
return Icons.lan_outlined;
|
|
|
|
|
|
case ArchShapeType.queue:
|
|
|
|
|
|
return Icons.view_stream_outlined;
|
|
|
|
|
|
case ArchShapeType.symbol:
|
|
|
|
|
|
return Icons.extension_outlined;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|