From 670dd481273ab87b849cbc8b1984047442bceecb Mon Sep 17 00:00:00 2001 From: Juan Pablo Caram Date: Sun, 18 Jan 2015 21:10:19 -0500 Subject: [PATCH] Added "excellon_zeros" application default. It get propagated to the Excellon class. --- FlatCAMApp.py | 22 ++++++++++++++++++---- camlib.py | 8 ++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index d5ff4dd7..5a176529 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -242,7 +242,8 @@ class App(QtCore.QObject): "zoom_in_key": '3', "zoom_ratio": 1.5, "point_clipboard_format": "(%.4f, %.4f)", - "zdownrate": None # + "zdownrate": None, + "excellon_zeros": "L" }) ############################### @@ -1765,13 +1766,26 @@ class App(QtCore.QObject): def propagate_defaults(self): + self.log.debug("propagate_defaults()") + # Which objects to update the given parameters. routes = { - "zdownrate": CNCjob + "zdownrate": CNCjob, + "excellon_zeros": Excellon } for param in routes: - routes[param].defaults[param] = self.defaults[param] + if param in routes[param].defaults: + routes[param].defaults[param] = self.defaults[param] + self.log.debug(" " + param + " OK") + else: + # Try extracting the name: + # classname_param here is param in the object + if param.find(routes[param].__name__.lower() + "_") == 0: + p = param[len(routes[param].__name__) + 1:] + if p in routes[param].defaults: + routes[param].defaults[p] = self.defaults[param] + self.log.debug(" " + param + " OK!") def plot_all(self): """ @@ -2239,7 +2253,7 @@ class App(QtCore.QObject): if param in self.defaults: self.defaults[param] = value self.propagate_defaults() - return + return "Ok" return "ERROR: No such system parameter." diff --git a/camlib.py b/camlib.py index 0a92c72a..8251659f 100644 --- a/camlib.py +++ b/camlib.py @@ -1778,7 +1778,11 @@ class Excellon(Geometry): ================ ==================================== """ - def __init__(self, zeros="L"): + defaults = { + "zeros": "L" + } + + def __init__(self, zeros=None): """ The constructor takes no parameters. @@ -1797,7 +1801,7 @@ class Excellon(Geometry): # Trailing "T" or leading "L" (default) #self.zeros = "T" - self.zeros = zeros + self.zeros = zeros or self.defaults["zeros"] # Attributes to be included in serialization # Always append to it because it carries contents