diff options
author | Paulo Henrique Silva <ph.silva@gmail.com> | 2014-09-28 20:02:30 -0300 |
---|---|---|
committer | Paulo Henrique Silva <ph.silva@gmail.com> | 2014-09-28 20:02:30 -0300 |
commit | 14e71e2c0c078eaba016c0bca73b6268ee103c6c (patch) | |
tree | 0a8d7673ac30655205f6e369a6fecdaf24ae4986 /gerber/render.py | |
parent | bd38028b01fdb6701195f023adfc72820a6f5ce5 (diff) | |
parent | 43b599106f746dd42423eda1f91a592813ecc224 (diff) | |
download | gerbonara-14e71e2c0c078eaba016c0bca73b6268ee103c6c.tar.gz gerbonara-14e71e2c0c078eaba016c0bca73b6268ee103c6c.tar.bz2 gerbonara-14e71e2c0c078eaba016c0bca73b6268ee103c6c.zip |
Merge pull request #3 from hamiltonkibbe/excellon_support
Add Excellon support
Diffstat (limited to 'gerber/render.py')
-rw-r--r-- | gerber/render.py | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/gerber/render.py b/gerber/render.py index dd30ae0..183a59f 100644 --- a/gerber/render.py +++ b/gerber/render.py @@ -15,6 +15,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from .parser import CommentStmt, UnknownStmt, EofStmt, ParamStmt, CoordStmt, ApertureStmt IMAGE_POLARITY_POSITIVE = 1 IMAGE_POLARITY_NEGATIVE = 2 @@ -138,3 +139,50 @@ class GerberContext(object): def flash(self, x, y): pass + + def drill(self, x, y, diameter): + pass + + def evaluate(self, stmt): + if isinstance(stmt, (CommentStmt, UnknownStmt, EofStmt)): + return + + elif isinstance(stmt, ParamStmt): + self._evaluate_param(stmt) + + elif isinstance(stmt, CoordStmt): + self._evaluate_coord(stmt) + + elif isinstance(stmt, ApertureStmt): + self._evaluate_aperture(stmt) + + else: + raise Exception("Invalid statement to evaluate") + + def _evaluate_param(self, stmt): + if stmt.param == "FS": + self.set_coord_format(stmt.zero, stmt.x, stmt.y) + self.set_coord_notation(stmt.notation) + elif stmt.param == "MO:": + self.set_coord_unit(stmt.mo) + elif stmt.param == "IP:": + self.set_image_polarity(stmt.ip) + elif stmt.param == "LP:": + self.set_level_polarity(stmt.lp) + elif stmt.param == "AD": + self.define_aperture(stmt.d, stmt.shape, stmt.modifiers) + + def _evaluate_coord(self, stmt): + + if stmt.function in ("G01", "G1", "G02", "G2", "G03", "G3"): + self.set_interpolation(stmt.function) + + if stmt.op == "D01": + self.stroke(stmt.x, stmt.y) + elif stmt.op == "D02": + self.move(stmt.x, stmt.y) + elif stmt.op == "D03": + self.flash(stmt.x, stmt.y) + + def _evaluate_aperture(self, stmt): + self.set_aperture(stmt.d) |