Files
altium-render-engine/backend/app/models/schematic.py
T
nearology 56c5ee23d3
Verify / test (push) Failing after 2m54s
first commit
2026-11-05 17:31:17 +03:30

157 خطوط
3.6 KiB
Python

"""Versioned, JSON-native contract. Coordinates are 10 mil, X right, Y down."""
from typing import Literal
from pydantic import BaseModel, Field
class Point(BaseModel):
x: float
y: float
class Bounds(BaseModel):
x: float
y: float
width: float
height: float
class Diagnostic(BaseModel):
severity: Literal["info", "warning", "error"]
code: str
message: str
record_id: str | None = None
record_type: int | None = None
count: int = 1
class Primitive(BaseModel):
id: str
kind: Literal["path", "text", "image"]
bounds: Bounds
clip: Bounds | None = None
path: str = ""
text: str = ""
image_data: str = ""
keep_aspect: bool = True
position: Point = Field(default_factory=lambda: Point(x=0, y=0))
rotation: float = 0
mirrored: bool = False
stroke: str = "#000000"
fill: str = "none"
width: float = 0.4
dash: list[float] = Field(default_factory=list)
font_family: str = "Arial"
font_size: float = 10
bold: bool = False
italic: bool = False
underline: bool = False
anchor: Literal["start", "middle", "end"] = "start"
baseline: Literal["alphabetic", "middle", "hanging"] = "alphabetic"
layer_id: str | None = None
net_id: str | None = None
role: str = ""
fill_rule: Literal["nonzero", "evenodd"] = "nonzero"
object_id: str
component_id: str | None = None
class SchematicObject(BaseModel):
id: str
kind: str
record_type: int
source_stream: str
source_index: int
owner_id: str | None = None
component_id: str | None = None
visible: bool = True
layer_id: str | None = None
net_id: str | None = None
position: Point
bounds: Bounds
properties: dict[str, str]
primitive_ids: list[str] = Field(default_factory=list)
connection_points: list[Point] = Field(default_factory=list)
class Pin(BaseModel):
id: str
name: str
number: str
electrical_type: str
position: Point
connection: Point
length: float
rotation: float
visible: bool
active: bool
net_id: str | None = None
class Component(BaseModel):
id: str
symbol_id: str
designator: str = ""
name: str = ""
value: str = ""
comment: str = ""
description: str = ""
library_reference: str = ""
source_library: str = ""
position: Point
rotation: float = 0
mirrored: bool = False
current_part: int = 1
bounds: Bounds
pins: list[Pin] = Field(default_factory=list)
parameters: dict[str, str] = Field(default_factory=dict)
primitive_ids: list[str] = Field(default_factory=list)
object_ids: list[str] = Field(default_factory=list)
class Symbol(BaseModel):
id: str
component_id: str
primitive_ids: list[str]
class Sheet(BaseModel):
id: str = "sheet-0"
name: str
background: str = "#fffcf8"
bounds: Bounds
properties: dict[str, str]
class BoardLayer(BaseModel):
id: str
name: str
color: str
category: str
visible: bool
order: int
object_count: int = 0
class Net(BaseModel):
id: str
name: str
properties: dict[str, str] = Field(default_factory=dict)
class Document(BaseModel):
schema_version: str = "1.0"
document_type: Literal["schematic", "pcb"] = "schematic"
layers: list[BoardLayer] = Field(default_factory=list)
nets: list[Net] = Field(default_factory=list)
id: str
filename: str
metadata: dict
sheet: Sheet
bounds: Bounds
components: list[Component]
symbols: list[Symbol]
objects: list[SchematicObject]
primitives: list[Primitive]
diagnostics: list[Diagnostic]