157 lines
2.5 KiB
Dart
157 lines
2.5 KiB
Dart
import 'package:isar/isar.dart';
|
||
|
||
part 'schema.g.dart';
|
||
|
||
/// 项目模型
|
||
@collection
|
||
class Project {
|
||
Id id = Isar.autoIncrement;
|
||
|
||
@Index()
|
||
late String name;
|
||
|
||
late String description;
|
||
|
||
late DateTime createdAt;
|
||
|
||
late DateTime updatedAt;
|
||
|
||
late String thumbnailPath;
|
||
|
||
@Backlink(to: 'project')
|
||
final schematics = IsarLinks<Schematic>();
|
||
}
|
||
|
||
/// 原理图模型
|
||
@collection
|
||
class Schematic {
|
||
Id id = Isar.autoIncrement;
|
||
|
||
late String name;
|
||
|
||
final project = IsarLink<Project>();
|
||
|
||
late DateTime createdAt;
|
||
|
||
late DateTime updatedAt;
|
||
|
||
/// 元件列表
|
||
@Index()
|
||
final components = IsarLinks<Component>();
|
||
|
||
/// 网络列表
|
||
final nets = IsarLinks<Net>();
|
||
|
||
/// 画布缩放状态
|
||
late double zoomLevel;
|
||
|
||
/// 画布偏移
|
||
late double offsetX;
|
||
late double offsetY;
|
||
}
|
||
|
||
/// 元件模型
|
||
@collection
|
||
class Component {
|
||
Id id = Isar.autoIncrement;
|
||
|
||
@Index()
|
||
late String name;
|
||
|
||
@Index()
|
||
late String value;
|
||
|
||
@Index()
|
||
late String footprint;
|
||
|
||
final schematic = IsarLink<Schematic>();
|
||
|
||
/// 位置坐标
|
||
late double x;
|
||
late double y;
|
||
|
||
/// 旋转角度
|
||
late double rotation;
|
||
|
||
/// 镜像状态
|
||
late bool mirrored;
|
||
|
||
/// 引脚定义
|
||
final pins = IsarLinks<Pin>();
|
||
}
|
||
|
||
/// 引脚模型
|
||
@embedded
|
||
class Pin {
|
||
late String name;
|
||
late int number;
|
||
late double x;
|
||
late double y;
|
||
late bool isPower;
|
||
}
|
||
|
||
/// 网络模型
|
||
@collection
|
||
class Net {
|
||
Id id = Isar.autoIncrement;
|
||
|
||
late String name;
|
||
|
||
final schematic = IsarLink<Schematic>();
|
||
|
||
final connections = IsarLinks<Connection>();
|
||
}
|
||
|
||
/// 连接模型
|
||
@embedded
|
||
class Connection {
|
||
late double x1;
|
||
late double y1;
|
||
late double x2;
|
||
late double y2;
|
||
late String componentId;
|
||
late String pinName;
|
||
}
|
||
|
||
/// 应用设置模型
|
||
@collection
|
||
class Settings {
|
||
Id id = Isar.autoIncrement;
|
||
|
||
@Index()
|
||
late String id; // 'app_settings'
|
||
|
||
/// 主题模式:system, light, dark
|
||
late String themeMode;
|
||
|
||
/// 语言:system, chineseSimple, chineseTraditional, english, arabic
|
||
late String language;
|
||
|
||
/// 网格大小
|
||
double gridSize = 10.0;
|
||
|
||
/// 显示网格
|
||
bool showGrid = true;
|
||
|
||
/// 吸附到网格
|
||
bool snapToGrid = true;
|
||
|
||
/// 自动保存
|
||
bool autoSave = true;
|
||
|
||
/// 自动保存间隔(分钟)
|
||
int autoSaveInterval = 5;
|
||
|
||
/// 启用动画
|
||
bool enableAnimations = true;
|
||
|
||
/// 启用抗锯齿
|
||
bool enableAntialiasing = true;
|
||
|
||
/// 渲染质量:high, balanced, performance
|
||
String renderQuality = 'balanced';
|
||
|
||
/// 更新时间
|
||
late DateTime updatedAt;
|
||
}
|