Fix units statement. Keep track of original macro statement in the AMGroup

This commit is contained in:
Garret Fick 2016-05-28 12:36:31 +08:00
parent d1d112f2f1
commit c9c1313d59
3 changed files with 11 additions and 6 deletions

View file

@ -176,7 +176,7 @@ class MOParamStmt(ParamStmt):
@classmethod
def from_units(cls, units):
return cls(None, 'inch')
return cls(None, units)
@classmethod
def from_dict(cls, stmt_dict):
@ -425,7 +425,7 @@ class AMParamStmt(ParamStmt):
else:
self.primitives.append(AMUnsupportPrimitive.from_gerber(primitive))
return AMGroup(self.primitives, units=self.units)
return AMGroup(self.primitives, stmt=self, units=self.units)
def to_inch(self):
if self.units == 'metric':

View file

@ -763,9 +763,9 @@ class Polygon(Primitive):
return points
def equivalent(self, other, offset):
'''
"""
Is this the outline the same as the other, ignoring the position offset?
'''
"""
# Quick check if it even makes sense to compare them
if type(self) != type(other) or self.sides != other.sides or self.radius != other.radius:
@ -779,7 +779,11 @@ class Polygon(Primitive):
class AMGroup(Primitive):
"""
"""
def __init__(self, amprimitives, **kwargs):
def __init__(self, amprimitives, stmt = None, **kwargs):
"""
stmt : The original statment that generated this, since it is really hard to re-generate from primitives
"""
super(AMGroup, self).__init__(**kwargs)
self.primitives = []
@ -792,6 +796,7 @@ class AMGroup(Primitive):
self.primitives.append(prim)
self._position = None
self._to_convert = ['primitives']
self.stmt = stmt
@property
def flashed(self):

View file

@ -14,7 +14,7 @@ class AMGroupContext(object):
def render(self, amgroup, name):
# Clone ourselves, then offset by the psotion so that
# our render doesn't have to consider offset. Just makes things simplder
# our render doesn't have to consider offset. Just makes things simpler
nooffset_group = deepcopy(amgroup)
nooffset_group.position = (0, 0)