Просмотр исходного кода

- starting to work on storing the solid_geometry for each tool in part in Excellon Object

Marius Stanciu 7 лет назад
Родитель
Сommit
02793f7ae2
4 измененных файлов с 48 добавлено и 17 удалено
  1. 8 3
      FlatCAMApp.py
  2. 31 12
      FlatCAMObj.py
  3. 1 0
      README.md
  4. 8 2
      camlib.py

+ 8 - 3
FlatCAMApp.py

@@ -6012,9 +6012,14 @@ class App(QtCore.QObject):
                 log.debug("Could not create geometry for Excellon object.")
                 return "fail"
 
-            if excellon_obj.is_empty():
-                app_obj.inform.emit("[ERROR_NOTCL] No geometry found in file: " + filename)
-                return "fail"
+            # if excellon_obj.is_empty():
+            #     app_obj.inform.emit("[ERROR_NOTCL] No geometry found in file: " + filename)
+            #     return "fail"
+            for tool in excellon_obj.tools:
+                if excellon_obj.tools[tool]['solid_geometry']:
+                    return
+            app_obj.inform.emit("[ERROR_NOTCL] No geometry found in file: " + filename)
+            return "fail"
 
         with self.proc_container.new("Opening Excellon."):
 

+ 31 - 12
FlatCAMObj.py

@@ -1882,27 +1882,45 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
         if not FlatCAMObj.plot(self):
             return
 
-        try:
-            _ = iter(self.solid_geometry)
-        except TypeError:
-            self.solid_geometry = [self.solid_geometry]
-
         try:
             # Plot excellon (All polygons?)
             if self.options["solid"]:
-                for geo in self.solid_geometry:
-                    self.add_shape(shape=geo, color='#750000BF', face_color='#C40000BF', visible=self.options['plot'],
-                                   layer=2)
+                for tool in self.tools:
+                    for geo in self.tools[tool]['solid_geometry']:
+                        self.add_shape(shape=geo, color='#750000BF', face_color='#C40000BF', visible=self.options['plot'],
+                                       layer=2)
             else:
-                for geo in self.solid_geometry:
-                    self.add_shape(shape=geo.exterior, color='red', visible=self.options['plot'])
-                    for ints in geo.interiors:
-                        self.add_shape(shape=ints, color='green', visible=self.options['plot'])
+                for tool in self.tools:
+                    for geo in self.tools[tool]['solid_geometry']:
+                        self.add_shape(shape=geo.exterior, color='red', visible=self.options['plot'])
+                        for ints in geo.interiors:
+                            self.add_shape(shape=ints, color='green', visible=self.options['plot'])
 
             self.shapes.redraw()
         except (ObjectDeleted, AttributeError):
             self.shapes.clear(update=True)
 
+        # try:
+        #     _ = iter(self.solid_geometry)
+        # except TypeError:
+        #     self.solid_geometry = [self.solid_geometry]
+        #
+        # try:
+        #     # Plot excellon (All polygons?)
+        #     if self.options["solid"]:
+        #         for geo in self.solid_geometry:
+        #             self.add_shape(shape=geo, color='#750000BF', face_color='#C40000BF', visible=self.options['plot'],
+        #                            layer=2)
+        #     else:
+        #         for geo in self.solid_geometry:
+        #             self.add_shape(shape=geo.exterior, color='red', visible=self.options['plot'])
+        #             for ints in geo.interiors:
+        #                 self.add_shape(shape=ints, color='green', visible=self.options['plot'])
+        #
+        #     self.shapes.redraw()
+        # except (ObjectDeleted, AttributeError):
+        #     self.shapes.clear(update=True)
+
         # try:
         #     # Plot excellon (All polygons?)
         #     if self.options["solid"]:
@@ -4118,6 +4136,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             self.ui.plot_cb.setChecked(True)
         self.ui_connect()
 
+
 class FlatCAMCNCjob(FlatCAMObj, CNCjob):
     """
     Represents G-Code.

+ 1 - 0
README.md

@@ -16,6 +16,7 @@ CAD program, and create G-Code for Isolation routing.
 - added a new parameter named Offset in the Excellon tool table - work in progress
 - finished work on Offset parameter in Excellon Object (Excellon Editor, camlib, FlatCAMObj updated to take this param in consideration)
 - fixed a bug where in Excellon editor when editing a file, a tool was automatically added. That is supposed to happen only for empty newly created Excellon Objects.
+- starting to work on storing the solid_geometry for each tool in part in Excellon Object
 
 10.02.2019
 

+ 8 - 2
camlib.py

@@ -3510,6 +3510,7 @@ class Excellon(Geometry):
                                 spec = {"C": float(match.group(2))}
                                 self.tools[str(name_tool)] = spec
                                 log.debug("  Tool definition: %s %s" % (name_tool, spec))
+                            spec['solid_geometry'] = []
                             continue
                     else:
                         log.warning("Line ignored, it's a comment: %s" % eline)
@@ -3569,6 +3570,7 @@ class Excellon(Geometry):
                                 spec = {
                                     "C": float(match.group(2)),
                                 }
+                                spec['solid_geometry'] = []
                                 self.tools[name] = spec
                                 log.debug("  Tool definition out of header: %s %s" % (name, spec))
 
@@ -3914,6 +3916,7 @@ class Excellon(Geometry):
                             # "H": float(match.group(6)),
                             # "Z": float(match.group(7))
                         }
+                        spec['solid_geometry'] = []
                         self.tools[name] = spec
                         log.debug("  Tool definition: %s %s" % (name, spec))
                         continue
@@ -4082,7 +4085,8 @@ class Excellon(Geometry):
                     continue
                 tooldia = self.tools[drill['tool']]['C']
                 poly = drill['point'].buffer(tooldia / 2.0, int(int(self.geo_steps_per_circle) / 4))
-                self.solid_geometry.append(poly)
+                # self.solid_geometry.append(poly)
+                self.tools[drill['tool']]['solid_geometry'].append(poly)
 
             for slot in self.slots:
                 slot_tooldia = self.tools[slot['tool']]['C']
@@ -4091,7 +4095,9 @@ class Excellon(Geometry):
 
                 lines_string = LineString([start, stop])
                 poly = lines_string.buffer(slot_tooldia / 2.0, int(int(self.geo_steps_per_circle) / 4))
-                self.solid_geometry.append(poly)
+                # self.solid_geometry.append(poly)
+                self.tools[drill['tool']]['solid_geometry'].append(poly)
+
         except Exception as e:
             log.debug("Excellon geometry creation failed due of ERROR: %s" % str(e))
             return "fail"