summaryrefslogtreecommitdiff
path: root/gerber/gerber_statements.py
diff options
context:
space:
mode:
authorHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-18 23:13:23 -0500
committerHamilton Kibbe <hamilton.kibbe@gmail.com>2015-02-18 23:13:23 -0500
commit5966d7830bda7f37ed5ddcc1bfccb93e7f780eaa (patch)
treeb5d96312c9dab598ec342d2215d235f2b00e8a48 /gerber/gerber_statements.py
parent4b92e1b59dcaff48bda4e1c906506432651fcd4f (diff)
downloadgerbonara-5966d7830bda7f37ed5ddcc1bfccb93e7f780eaa.tar.gz
gerbonara-5966d7830bda7f37ed5ddcc1bfccb93e7f780eaa.tar.bz2
gerbonara-5966d7830bda7f37ed5ddcc1bfccb93e7f780eaa.zip
Add offset operation
Diffstat (limited to 'gerber/gerber_statements.py')
-rw-r--r--gerber/gerber_statements.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/gerber/gerber_statements.py b/gerber/gerber_statements.py
index f8385c0..89f4f84 100644
--- a/gerber/gerber_statements.py
+++ b/gerber/gerber_statements.py
@@ -58,6 +58,9 @@ class Statement(object):
def to_metric(self):
pass
+ def offset(self, x_offset=0, y_offset=0):
+ pass
+
def __eq__(self, other):
return self.__dict__ == other.__dict__
@@ -626,6 +629,12 @@ class OFParamStmt(ParamStmt):
if self.b is not None:
self.b = metric(self.b)
+ def offset(self, x_offset=0, y_offset=0):
+ if self.a is not None:
+ self.a += x_offset
+ if self.b is not None:
+ self.b += y_offset
+
def __str__(self):
offset_str = ''
if self.a is not None:
@@ -690,6 +699,12 @@ class SFParamStmt(ParamStmt):
if self.b is not None:
self.b = metric(self.b)
+ def offset(self, x_offset=0, y_offset=0):
+ if self.a is not None:
+ self.a += x_offset
+ if self.b is not None:
+ self.b += y_offset
+
def __str__(self):
scale_factor = ''
if self.a is not None:
@@ -836,6 +851,16 @@ class CoordStmt(Statement):
if self.function == "G70":
self.function = "G71"
+ def offset(self, x_offset=0, y_offset=0):
+ if self.x is not None:
+ self.x += x_offset
+ if self.y is not None:
+ self.y += y_offset
+ if self.i is not None:
+ self.i += x_offset
+ if self.j is not None:
+ self.j += y_offset
+
def __str__(self):
coord_str = ''
if self.function: