Fix GerberFile.bounds when board origin is negative

This commit is contained in:
Paulo Henrique Silva 2015-02-20 13:57:19 -02:00
parent d830375c4c
commit 5d764a6890

View file

@ -88,22 +88,19 @@ class GerberFile(CamFile):
@property
def bounds(self):
xbounds = [0.0, 0.0]
ybounds = [0.0, 0.0]
for stmt in [stmt for stmt in self.statements
if isinstance(stmt, CoordStmt)]:
if stmt.x is not None:
if stmt.x < xbounds[0]:
xbounds[0] = stmt.x
elif stmt.x > xbounds[1]:
xbounds[1] = stmt.x
if stmt.y is not None:
if stmt.y < ybounds[0]:
ybounds[0] = stmt.y
elif stmt.y > ybounds[1]:
ybounds[1] = stmt.y
return (xbounds, ybounds)
min_x = min_y = 1000000
max_x = max_y = -1000000
for stmt in [stmt for stmt in self.statements if isinstance(stmt, CoordStmt)]:
if stmt.x is not None:
min_x = min(stmt.x, min_x)
max_x = max(stmt.x, max_x)
if stmt.y is not None:
min_y = min(stmt.y, min_y)
max_y = max(stmt.y, max_y)
return ((min_x, max_x), (min_y, max_y))
def write(self, filename, settings=None):
""" Write data out to a gerber file