summaryrefslogtreecommitdiff
path: root/gerbonara/cad/primitives.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-04-05 17:44:31 +0200
committerjaseg <git@jaseg.de>2023-04-10 23:57:15 +0200
commit60e893c82d9c1c00bfbaf2cb5121098ccda88fe7 (patch)
treeaaf26a56e64f1af3131e3118aa8c4800d35d5aa4 /gerbonara/cad/primitives.py
parentd9b3fafa806722efbbf838a54329902554155d3d (diff)
downloadgerbonara-60e893c82d9c1c00bfbaf2cb5121098ccda88fe7.tar.gz
gerbonara-60e893c82d9c1c00bfbaf2cb5121098ccda88fe7.tar.bz2
gerbonara-60e893c82d9c1c00bfbaf2cb5121098ccda88fe7.zip
cad: Add pad numbering for protoboards
Diffstat (limited to 'gerbonara/cad/primitives.py')
-rw-r--r--gerbonara/cad/primitives.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/gerbonara/cad/primitives.py b/gerbonara/cad/primitives.py
index 9000910..78fc238 100644
--- a/gerbonara/cad/primitives.py
+++ b/gerbonara/cad/primitives.py
@@ -80,9 +80,6 @@ class Board:
warnings.warn(msg)
elif keepout_errors == 'raise':
raise KeepoutError(obj, ko, msg)
- else:
- import sys
- #print('skip', obj.bounding_box(MM), ko, file=sys.stderr)
return
obj.parent = self
@@ -190,10 +187,16 @@ class ObjectGroup(Positioned):
bottom_paste: list = field(default_factory=list)
drill_npth: list = field(default_factory=list)
drill_pth: list = field(default_factory=list)
+ objects: list = field(default_factory=list)
def render(self, layer_stack):
x, y, rotation = self.abs_pos
top, bottom = ('bottom', 'top') if self.side == 'bottom' else ('top', 'bottom')
+
+ for obj in self.objects:
+ obj.parent = self
+ obj.render(layer_stack)
+
for target, source in [
(layer_stack[top, 'copper'], self.top_copper),
(layer_stack[top, 'mask'], self.top_mask),
@@ -205,6 +208,7 @@ class ObjectGroup(Positioned):
(layer_stack[bottom, 'paste'], self.bottom_paste),
(layer_stack.drill_pth, self.drill_pth),
(layer_stack.drill_npth, self.drill_npth)]:
+
for fe in source:
fe = copy(fe)
fe.rotate(rotation)
@@ -237,6 +241,9 @@ class Text(Positioned):
newstroke_font = Newstroke()
strokes = list(newstroke_font.render(self.text, size=self.font_size))
+ if not strokes:
+ return
+
xs = [x for points in strokes for x, _y in points]
ys = [y for points in strokes for _x, y in points]
min_x, min_y, max_x, max_y = min(xs), min(ys), max(xs), max(ys)
@@ -251,19 +258,25 @@ class Text(Positioned):
raise ValueError('h_align must be one of "left", "center", or "right".')
if self.v_align == 'top':
- y0 = -max_y
+ y0 = -(max_y - min_y)
elif self.v_align == 'middle':
- y0 = -max_y/2
+ y0 = -(max_y - min_y)/2
elif self.v_align == 'bottom':
y0 = 0
else:
raise ValueError('v_align must be one of "top", "middle", or "bottom".')
+ if self.side == 'bottom':
+ x0 += min_x + max_x
+ x_sign = -1
+ else:
+ x_sign = 1
+
ap = CircleAperture(self.stroke_width, unit=self.unit)
for stroke in strokes:
for (x1, y1), (x2, y2) in zip(stroke[:-1], stroke[1:]):
- obj = Line(x0+x1, y0-y1, x0+x2, y0-y2, aperture=ap, unit=self.unit, polarity_dark=self.polarity_dark)
+ obj = Line(x0+x_sign*x1, y0-y1, x0+x_sign*x2, y0-y2, aperture=ap, unit=self.unit, polarity_dark=self.polarity_dark)
obj.rotate(rotation)
obj.offset(obj_x, obj_y)
layer_stack[self.side, self.layer].objects.append(obj)