summaryrefslogtreecommitdiff
path: root/gerbonara/gerber/apertures.py
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2021-12-30 16:40:14 +0100
committerjaseg <git@jaseg.de>2021-12-30 16:40:14 +0100
commitf4b2e74923cc95c683cd7f5c4732d92e4aafd3ba (patch)
treef713a247d3cc2c11463be1af54ff42b0cd9dfb44 /gerbonara/gerber/apertures.py
parente4941dd5e371e8c9e729a72b8ec30d021bceb0cc (diff)
downloadgerbonara-f4b2e74923cc95c683cd7f5c4732d92e4aafd3ba.tar.gz
gerbonara-f4b2e74923cc95c683cd7f5c4732d92e4aafd3ba.tar.bz2
gerbonara-f4b2e74923cc95c683cd7f5c4732d92e4aafd3ba.zip
Fix rotation bugs, all tests run through
Diffstat (limited to 'gerbonara/gerber/apertures.py')
-rw-r--r--gerbonara/gerber/apertures.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/gerbonara/gerber/apertures.py b/gerbonara/gerber/apertures.py
index 0b43822..9e5c23a 100644
--- a/gerbonara/gerber/apertures.py
+++ b/gerbonara/gerber/apertures.py
@@ -89,7 +89,7 @@ class CircleAperture(Aperture):
return self.to_macro(self.rotation)
def to_macro(self):
- return ApertureMacroInstance(GenericMacros.circle, *self.params)
+ return ApertureMacroInstance(GenericMacros.circle, self.params)
@property
def params(self):
@@ -122,12 +122,13 @@ class RectangleAperture(Aperture):
if math.isclose(self.rotation % math.pi, 0):
return self
elif math.isclose(self.rotation % math.pi, math.pi/2):
- return replace(self, w=self.h, h=self.w, **self._rotate_hole_90())
+ return replace(self, w=self.h, h=self.w, **self._rotate_hole_90(), rotation=0)
else: # odd angle
return self.to_macro()
def to_macro(self):
- return ApertureMacroInstance(GenericMacros.rect, *self.params)
+ return ApertureMacroInstance(GenericMacros.rect,
+ [self.w, self.h, self.hole_dia or 0, self.hole_rect_h or 0, self.rotation])
@property
def params(self):
@@ -156,14 +157,15 @@ class ObroundAperture(Aperture):
if math.isclose(self.rotation % math.pi, 0):
return self
elif math.isclose(self.rotation % math.pi, math.pi/2):
- return replace(self, w=self.h, h=self.w, **self._rotate_hole_90())
+ return replace(self, w=self.h, h=self.w, **self._rotate_hole_90(), rotation=0)
else:
return self.to_macro()
- def to_macro(self, rotation:'radians'=0):
+ def to_macro(self):
# generic macro only supports w > h so flip x/y if h > w
- inst = self if self.w > self.h else replace(self, w=self.h, h=self.w, **_rotate_hole_90(self))
- return ApertureMacroInstance(GenericMacros.obround, *inst.params)
+ inst = self if self.w > self.h else replace(self, w=self.h, h=self.w, **_rotate_hole_90(self), rotation=self.rotation-90)
+ return ApertureMacroInstance(GenericMacros.obround,
+ [inst.w, ints.h, inst.hole_dia, inst.hole_rect_h, inst.rotation])
@property
def params(self):
@@ -190,7 +192,7 @@ class PolygonAperture(Aperture):
return self
def to_macro(self):
- return ApertureMacroInstance(GenericMacros.polygon, *self.params)
+ return ApertureMacroInstance(GenericMacros.polygon, self.params)
@property
def params(self):
@@ -226,7 +228,7 @@ class ApertureMacroInstance(Aperture):
return self.to_macro()
def to_macro(self):
- return replace(self, macro=macro.rotated(self.rotation))
+ return replace(self, macro=self.macro.rotated(self.rotation), rotation=0)
def __eq__(self, other):
return hasattr(other, 'macro') and self.macro == other.macro and \