diff options
author | jaseg <git@jaseg.de> | 2021-11-11 12:10:56 +0100 |
---|---|---|
committer | jaseg <git@jaseg.de> | 2021-11-11 12:10:56 +0100 |
commit | 7415f9a5848853fb7a2b5b91bbe438d85728e33a (patch) | |
tree | 8fe096b83b81e6bccbcfd3efe288af49f2d5995b /gerbonara/gerber/apertures.py | |
parent | f833483b72cd4fdf56cd4130dc9174ebfac8673d (diff) | |
download | gerbonara-7415f9a5848853fb7a2b5b91bbe438d85728e33a.tar.gz gerbonara-7415f9a5848853fb7a2b5b91bbe438d85728e33a.tar.bz2 gerbonara-7415f9a5848853fb7a2b5b91bbe438d85728e33a.zip |
Aperture macro parser works
Diffstat (limited to 'gerbonara/gerber/apertures.py')
-rw-r--r-- | gerbonara/gerber/apertures.py | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/gerbonara/gerber/apertures.py b/gerbonara/gerber/apertures.py new file mode 100644 index 0000000..aa2764e --- /dev/null +++ b/gerbonara/gerber/apertures.py @@ -0,0 +1,85 @@ + +from dataclasses import dataclass + +from primitives import Primitive + +def _flash_hole(self, x, y): + if self.hole_rect_h is not None: + return self.primitives(x, y), Rectangle((x, y), (self.hole_dia, self.hole_rect_h), polarity_dark=False) + else: + return self.primitives(x, y), Circle((x, y), self.hole_dia, polarity_dark=False) + +class Aperture: + @property + def hole_shape(self): + if self.hole_rect_h is not None: + return 'rect' + else: + return 'circle' + + @property + def hole_size(self): + return (self.hole_dia, self.hole_rect_h) + + def flash(self, x, y): + return self.primitives(x, y) + + +@dataclass +class ApertureCircle(Aperture): + diameter : float + hole_dia : float = 0 + hole_rect_h : float = None + + def primitives(self, x, y): + return Circle((x, y), self.diameter, polarity_dark=True), + + flash = _flash_hole + + +@dataclass +class ApertureRectangle(Aperture): + w : float + h : float + hole_dia : float = 0 + hole_rect_h : float = None + + def primitives(self, x, y): + return Rectangle((x, y), (self.w, self.h), polarity_dark=True), + + flash = _flash_hole + + +@dataclass +class ApertureObround(Aperture): + w : float + h : float + hole_dia : float = 0 + hole_rect_h : float = None + + def primitives(self, x, y): + return Obround((x, y), self.w, self.h, polarity_dark=True) + + flash = _flash_hole + + +@dataclass +class AperturePolygon(Aperture): + diameter : float + n_vertices : int + hole_dia : float = 0 + hole_rect_h : float = None + + def primitives(self, x, y): + return Polygon((x, y), diameter, n_vertices, rotation, polarity_dark=True), + + flash = _flash_hole + +class MacroAperture(Aperture): + parameters : [float] + self.macro : ApertureMacro + + def primitives(self, x, y): + return self.macro.execute(x, y, self.parameters) + + |