summaryrefslogtreecommitdiff
path: root/gerbonara/cad/kicad/pcb.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2024-07-19 19:15:52 +0200
committerjaseg <git@jaseg.de>2024-07-19 19:15:52 +0200
commitd7efa577320cbb1af3d4399b008b5901309b5ea4 (patch)
tree67820c886ee48192ff44ff9873f179234dafe371 /gerbonara/cad/kicad/pcb.py
parent689ce748dba83102775871df0e49bdf615f8fe7e (diff)
downloadgerbonara-d7efa577320cbb1af3d4399b008b5901309b5ea4.tar.gz
gerbonara-d7efa577320cbb1af3d4399b008b5901309b5ea4.tar.bz2
gerbonara-d7efa577320cbb1af3d4399b008b5901309b5ea4.zip
kicad: Add bounding box support to lots of s-expr objects
Diffstat (limited to 'gerbonara/cad/kicad/pcb.py')
-rw-r--r--gerbonara/cad/kicad/pcb.py16
1 files changed, 3 insertions, 13 deletions
diff --git a/gerbonara/cad/kicad/pcb.py b/gerbonara/cad/kicad/pcb.py
index ef86a71..11abf3c 100644
--- a/gerbonara/cad/kicad/pcb.py
+++ b/gerbonara/cad/kicad/pcb.py
@@ -157,7 +157,7 @@ class Net:
@sexp_type('segment')
-class TrackSegment:
+class TrackSegment(BBoxMixin):
start: Rename(XYCoord) = field(default_factory=XYCoord)
end: Rename(XYCoord) = field(default_factory=XYCoord)
width: Named(float) = 0.5
@@ -200,7 +200,7 @@ class TrackSegment:
@sexp_type('arc')
-class TrackArc:
+class TrackArc(BBoxMixin):
start: Rename(XYCoord) = field(default_factory=XYCoord)
mid: Rename(XYCoord) = field(default_factory=XYCoord)
end: Rename(XYCoord) = field(default_factory=XYCoord)
@@ -245,7 +245,7 @@ class TrackArc:
@sexp_type('via')
-class Via:
+class Via(BBoxMixin):
via_type: AtomChoice(Atom.blind, Atom.micro) = None
locked: Flag() = False
at: Rename(XYCoord) = field(default_factory=XYCoord)
@@ -345,7 +345,6 @@ class Board:
_ : SEXP_END = None
original_filename: str = None
- _bounding_box: tuple = None
_trace_index: rtree.index.Index = None
_trace_index_map: dict = None
@@ -789,15 +788,6 @@ class Board:
fe.offset(x, -y, MM)
layer_stack.drill_pth.append(fe)
- def bounding_box(self, unit=MM):
- if not self._bounding_box:
- stack = LayerStack()
- layer_map = {kc_id: gn_id for kc_id, gn_id in LAYER_MAP_K2G.items() if gn_id in stack}
- self.render(stack, layer_map, x=0, y=0, rotation=0, flip=False, text=False, variables={})
- self._bounding_box = stack.bounding_box(unit)
- return self._bounding_box
-
-
@dataclass
class BoardInstance(cad_pr.Positioned):
sexp: Board = None