Преглед изворни кода

Added "excellon_zeros" application default. It get propagated to the Excellon class.

Juan Pablo Caram пре 11 година
родитељ
комит
670dd48127
2 измењених фајлова са 24 додато и 6 уклоњено
  1. 18 4
      FlatCAMApp.py
  2. 6 2
      camlib.py

+ 18 - 4
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."
 

+ 6 - 2
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