summaryrefslogtreecommitdiff
path: root/gerber/gerber_statements.py
diff options
context:
space:
mode:
authorGarret Fick <garret@fickworkshop.com>2016-11-11 15:54:42 +0800
committerGitHub <noreply@github.com>2016-11-11 15:54:42 +0800
commit1e868763a1c4030bedd51553468cbe25f272bef9 (patch)
tree59cef68f1449a5be8d2a9a8ed352e3d9974a3edb /gerber/gerber_statements.py
parent5af19af190c1fb0f0c5be029d46d63e657dde4d9 (diff)
parent60d08dc8ad72f5bb0a14d4821451d7dce20b9639 (diff)
downloadgerbonara-1e868763a1c4030bedd51553468cbe25f272bef9.tar.gz
gerbonara-1e868763a1c4030bedd51553468cbe25f272bef9.tar.bz2
gerbonara-1e868763a1c4030bedd51553468cbe25f272bef9.zip
Merge pull request #5 from hamiltonkibbe/merge-curtacircuitos
Merge curtacircuitos
Diffstat (limited to 'gerber/gerber_statements.py')
-rw-r--r--gerber/gerber_statements.py53
1 files changed, 27 insertions, 26 deletions
diff --git a/gerber/gerber_statements.py b/gerber/gerber_statements.py
index 33fb4ec..7322b3c 100644
--- a/gerber/gerber_statements.py
+++ b/gerber/gerber_statements.py
@@ -95,10 +95,10 @@ class ParamStmt(Statement):
class FSParamStmt(ParamStmt):
""" FS - Gerber Format Specification Statement
"""
-
+
@classmethod
def from_settings(cls, settings):
-
+
return cls('FS', settings.zero_suppression, settings.notation, settings.format)
@classmethod
@@ -173,7 +173,7 @@ class FSParamStmt(ParamStmt):
class MOParamStmt(ParamStmt):
""" MO - Gerber Mode (measurement units) Statement.
"""
-
+
@classmethod
def from_units(cls, units):
return cls(None, units)
@@ -235,7 +235,7 @@ class LPParamStmt(ParamStmt):
param = stmt_dict['param']
lp = 'clear' if stmt_dict.get('lp') == 'C' else 'dark'
return cls(param, lp)
-
+
@classmethod
def from_region(cls, region):
#todo what is the first param?
@@ -272,34 +272,34 @@ class LPParamStmt(ParamStmt):
class ADParamStmt(ParamStmt):
""" AD - Gerber Aperture Definition Statement
"""
-
+
@classmethod
def rect(cls, dcode, width, height):
'''Create a rectangular aperture definition statement'''
return cls('AD', dcode, 'R', ([width, height],))
-
+
@classmethod
def circle(cls, dcode, diameter, hole_diameter):
'''Create a circular aperture definition statement'''
-
+
if hole_diameter != None:
return cls('AD', dcode, 'C', ([diameter, hole_diameter],))
return cls('AD', dcode, 'C', ([diameter],))
-
+
@classmethod
def obround(cls, dcode, width, height):
'''Create an obround aperture definition statement'''
return cls('AD', dcode, 'O', ([width, height],))
-
+
@classmethod
def polygon(cls, dcode, diameter, num_vertices, rotation, hole_diameter):
'''Create a polygon aperture definition statement'''
return cls('AD', dcode, 'P', ([diameter, num_vertices, rotation, hole_diameter],))
-
+
@classmethod
def macro(cls, dcode, name):
return cls('AD', dcode, name, '')
-
+
@classmethod
def from_dict(cls, stmt_dict):
param = stmt_dict.get('param')
@@ -435,8 +435,9 @@ class AMParamStmt(ParamStmt):
self.primitives.append(
AMThermalPrimitive.from_gerber(primitive))
else:
- self.primitives.append(AMUnsupportPrimitive.from_gerber(primitive))
-
+ self.primitives.append(
+ AMUnsupportPrimitive.from_gerber(primitive))
+
return AMGroup(self.primitives, stmt=self, units=self.units)
def to_inch(self):
@@ -864,10 +865,10 @@ class CoordStmt(Statement):
""" Coordinate Data Block
"""
- OP_DRAW = 'D01'
+ OP_DRAW = 'D01'
OP_MOVE = 'D02'
OP_FLASH = 'D03'
-
+
FUNC_LINEAR = 'G01'
FUNC_ARC_CW = 'G02'
FUNC_ARC_CCW = 'G03'
@@ -894,26 +895,26 @@ class CoordStmt(Statement):
j = parse_gerber_value(stmt_dict.get('j'), settings.format,
settings.zero_suppression)
return cls(function, x, y, i, j, op, settings)
-
+
@classmethod
def move(cls, func, point):
if point:
return cls(func, point[0], point[1], None, None, CoordStmt.OP_MOVE, None)
# No point specified, so just write the function. This is normally for ending a region (D02*)
return cls(func, None, None, None, None, CoordStmt.OP_MOVE, None)
-
+
@classmethod
def line(cls, func, point):
return cls(func, point[0], point[1], None, None, CoordStmt.OP_DRAW, None)
-
+
@classmethod
def mode(cls, func):
return cls(func, None, None, None, None, None, None)
-
+
@classmethod
def arc(cls, func, point, center):
return cls(func, point[0], point[1], center[0], center[1], CoordStmt.OP_DRAW, None)
-
+
@classmethod
def flash(cls, point):
if point:
@@ -1043,13 +1044,13 @@ class CoordStmt(Statement):
coord_str += 'Op: %s' % op
return '<Coordinate Statement: %s>' % coord_str
-
+
@property
def only_function(self):
"""
Returns if the statement only set the function.
"""
-
+
# TODO I would like to refactor this so that the function is handled separately and then
# TODO this isn't required
return self.function != None and self.op == None and self.x == None and self.y == None and self.i == None and self.j == None
@@ -1104,11 +1105,11 @@ class EofStmt(Statement):
class QuadrantModeStmt(Statement):
-
+
@classmethod
def single(cls):
return cls('single-quadrant')
-
+
@classmethod
def multi(cls):
return cls('multi-quadrant')
@@ -1140,11 +1141,11 @@ class RegionModeStmt(Statement):
if 'G36' not in line and 'G37' not in line:
raise ValueError('%s is not a valid region mode statement' % line)
return (cls('on') if line[:3] == 'G36' else cls('off'))
-
+
@classmethod
def on(cls):
return cls('on')
-
+
@classmethod
def off(cls):
return cls('off')