diff options
Diffstat (limited to 'gerber')
-rwxr-xr-x | gerber/excellon.py | 5 | ||||
-rw-r--r-- | gerber/excellon_statements.py | 6 | ||||
-rw-r--r-- | gerber/render/cairo_backend.py | 12 | ||||
-rw-r--r-- | gerber/tests/test_excellon.py | 2 |
4 files changed, 17 insertions, 8 deletions
diff --git a/gerber/excellon.py b/gerber/excellon.py index 87eaf03..a7f3a27 100755 --- a/gerber/excellon.py +++ b/gerber/excellon.py @@ -265,6 +265,11 @@ class ExcellonParser(object): elif line[0] == 'R' and self.state != 'HEADER':
stmt = RepeatHoleStmt.from_excellon(line, self._settings())
self.statements.append(stmt)
+ for i in xrange(stmt.count):
+ self.pos[0] += stmt.xdelta
+ self.pos[1] += stmt.ydelta
+ self.hits.append((self.active_tool, tuple(self.pos)))
+ self.active_tool._hit()
elif line[0] in ['X', 'Y']:
stmt = CoordinateStmt.from_excellon(line, self._settings())
diff --git a/gerber/excellon_statements.py b/gerber/excellon_statements.py index a56c4a5..7e2772c 100644 --- a/gerber/excellon_statements.py +++ b/gerber/excellon_statements.py @@ -296,16 +296,16 @@ class RepeatHoleStmt(ExcellonStatement): if stmt['ydelta'] is not '' else None) return cls(count, xdelta, ydelta) - def __init__(self, count, xdelta=None, ydelta=None): + def __init__(self, count, xdelta=0.0, ydelta=0.0): self.count = count self.xdelta = xdelta self.ydelta = ydelta def to_excellon(self, settings): stmt = 'R%d' % self.count - if self.xdelta is not None: + if self.xdelta != 0.0: stmt += 'X%s' % write_gerber_value(self.xdelta, settings.format, settings.zero_suppression) - if self.ydelta is not None: + if self.ydelta != 0.0: stmt += 'Y%s' % write_gerber_value(self.ydelta, settings.format, settings.zero_suppression) return stmt diff --git a/gerber/render/cairo_backend.py b/gerber/render/cairo_backend.py index 999269b..18d1ceb 100644 --- a/gerber/render/cairo_backend.py +++ b/gerber/render/cairo_backend.py @@ -22,7 +22,7 @@ import math from ..primitives import *
-SCALE = 400.
+SCALE = 4000.
class GerberCairoContext(GerberContext):
@@ -42,10 +42,12 @@ class GerberCairoContext(GerberContext): self.background = False
def set_bounds(self, bounds):
- xbounds, ybounds = bounds
- self.ctx.rectangle(SCALE * xbounds[0], SCALE * ybounds[0], SCALE * (xbounds[1]- xbounds[0]), SCALE * (ybounds[1] - ybounds[0]))
- self.ctx.set_source_rgb(0,0,0)
- self.ctx.fill()
+ if not self.background:
+ xbounds, ybounds = bounds
+ self.ctx.rectangle(SCALE * xbounds[0], SCALE * ybounds[0], SCALE * (xbounds[1]- xbounds[0]), SCALE * (ybounds[1] - ybounds[0]))
+ self.ctx.set_source_rgb(0,0,0)
+ self.ctx.fill()
+ self.background = True
def _render_line(self, line, color):
start = map(mul, line.start, self.scale)
diff --git a/gerber/tests/test_excellon.py b/gerber/tests/test_excellon.py index de45b44..ea067b5 100644 --- a/gerber/tests/test_excellon.py +++ b/gerber/tests/test_excellon.py @@ -4,6 +4,7 @@ # Author: Hamilton Kibbe <ham@hamiltonkib.be> from ..cam import FileSettings from ..excellon import read, detect_excellon_format, ExcellonFile, ExcellonParser +from ..excellon_statements import ExcellonTool from tests import * import os @@ -120,6 +121,7 @@ def test_parse_absolute_mode(): def test_parse_repeat_hole(): p = ExcellonParser(FileSettings()) + p.active_tool = ExcellonTool(FileSettings(), number=8) p._parse('R03X1.5Y1.5') assert_equal(p.statements[0].count, 3) |