mobile-eda/lib/data/models/schema.dart

157 lines
2.5 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;
}