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

- remade the Properties Tool such that it works with the new Gerber data structure in the obj.apertures. Also changed the view for the Gerber object in Properties
- fixed issue with false warning that the Gerber object has no geometry after an empty Gerber was edited and added geometry elements

Marius Stanciu 6 лет назад
Родитель
Сommit
630d9c733d
4 измененных файлов с 35 добавлено и 28 удалено
  1. 5 16
      FlatCAMApp.py
  2. 3 1
      README.md
  3. 6 1
      flatcamEditors/FlatCAMGrbEditor.py
  4. 21 10
      flatcamTools/ToolProperties.py

+ 5 - 16
FlatCAMApp.py

@@ -95,7 +95,7 @@ class App(QtCore.QObject):
 
 
     # Version
     # Version
     version = 8.917
     version = 8.917
-    version_date = "2019/05/16"
+    version_date = "2019/05/18"
     beta = True
     beta = True
 
 
     # current date now
     # current date now
@@ -2272,30 +2272,18 @@ class App(QtCore.QObject):
                             self.inform.emit(_("[WARNING] Object empty after edit."))
                             self.inform.emit(_("[WARNING] Object empty after edit."))
                             log.debug("App.editor2object() --> Geometry --> %s" % str(e))
                             log.debug("App.editor2object() --> Geometry --> %s" % str(e))
                     elif isinstance(edited_obj, FlatCAMGerber):
                     elif isinstance(edited_obj, FlatCAMGerber):
-                        new_obj = self.collection.get_active()
                         obj_type = "Gerber"
                         obj_type = "Gerber"
                         if cleanup is None:
                         if cleanup is None:
                             self.grb_editor.update_fcgerber(edited_obj)
                             self.grb_editor.update_fcgerber(edited_obj)
-                            self.grb_editor.update_options(new_obj)
+                            self.grb_editor.update_options(edited_obj)
                         self.grb_editor.deactivate_grb_editor()
                         self.grb_editor.deactivate_grb_editor()
 
 
                         # delete the old object (the source object) if it was an empty one
                         # delete the old object (the source object) if it was an empty one
-                        if not edited_obj.solid_geometry:
+                        if len(edited_obj.solid_geometry) == 0:
                             old_name = edited_obj.options['name']
                             old_name = edited_obj.options['name']
                             self.collection.set_active(old_name)
                             self.collection.set_active(old_name)
                             self.collection.delete_active()
                             self.collection.delete_active()
-                        else:
-                            # update the geo object options so it is including the bounding box values
-                            # but don't do this for objects that are made out of empty source objects, it will fail
-                            try:
-                                xmin, ymin, xmax, ymax = new_obj.bounds()
-                                new_obj.options['xmin'] = xmin
-                                new_obj.options['ymin'] = ymin
-                                new_obj.options['xmax'] = xmax
-                                new_obj.options['ymax'] = ymax
-                            except Exception as e:
-                                self.inform.emit(_("[WARNING] Object empty after edit."))
-                                log.debug("App.editor2object() --> Gerber --> %s" % str(e))
+
                     elif isinstance(edited_obj, FlatCAMExcellon):
                     elif isinstance(edited_obj, FlatCAMExcellon):
                         obj_type = "Excellon"
                         obj_type = "Excellon"
                         if cleanup is None:
                         if cleanup is None:
@@ -2992,6 +2980,7 @@ class App(QtCore.QObject):
             grb_obj.multigeo = False
             grb_obj.multigeo = False
             grb_obj.follow = False
             grb_obj.follow = False
             grb_obj.apertures = {}
             grb_obj.apertures = {}
+            grb_obj.solid_geometry = []
 
 
             try:
             try:
                 grb_obj.options['xmin'] = 0
                 grb_obj.options['xmin'] = 0

+ 3 - 1
README.md

@@ -12,8 +12,10 @@ CAD program, and create G-Code for Isolation routing.
 17.05.2019
 17.05.2019
 
 
 - remade the Tool Cutout to work on panels
 - remade the Tool Cutout to work on panels
-- remade the Tool Cutour such that on multiple applications on the same object it will yield the same result
+- remade the Tool Cutout such that on multiple applications on the same object it will yield the same result
 - fixed an issue in the remade Cutout Tool where when applied on a single Gerber object, the Freeform Cutout produced no cutout Geometry object
 - fixed an issue in the remade Cutout Tool where when applied on a single Gerber object, the Freeform Cutout produced no cutout Geometry object
+- remade the Properties Tool such that it works with the new Gerber data structure in the obj.apertures. Also changed the view for the Gerber object in Properties
+- fixed issue with false warning that the Gerber object has no geometry after an empty Gerber was edited and added geometry elements
 
 
 16.05.2019
 16.05.2019
 
 

+ 6 - 1
flatcamEditors/FlatCAMGrbEditor.py

@@ -3522,8 +3522,13 @@ class FlatCAMGrbEditor(QtCore.QObject):
             new_poly = MultiPolygon(poly_buffer)
             new_poly = MultiPolygon(poly_buffer)
             new_poly = new_poly.buffer(0.00000001)
             new_poly = new_poly.buffer(0.00000001)
             new_poly = new_poly.buffer(-0.00000001)
             new_poly = new_poly.buffer(-0.00000001)
-            grb_obj.solid_geometry = deepcopy(new_poly)
 
 
+            try:
+                _ = iter(new_poly)
+            except TypeError:
+                new_poly = [new_poly]
+
+            grb_obj.solid_geometry = deepcopy(new_poly)
             grb_obj.follow_geometry = deepcopy(follow_buffer)
             grb_obj.follow_geometry = deepcopy(follow_buffer)
 
 
             for k, v in self.gerber_obj_options.items():
             for k, v in self.gerber_obj_options.items():

+ 21 - 10
flatcamTools/ToolProperties.py

@@ -175,16 +175,27 @@ class Properties(FlatCAMTool):
             for ap in obj.apertures:
             for ap in obj.apertures:
                 temp_ap.clear()
                 temp_ap.clear()
                 temp_ap = deepcopy(obj.apertures[ap])
                 temp_ap = deepcopy(obj.apertures[ap])
-                if obj.apertures[ap]['solid_geometry']:
-                    elems = len(obj.apertures[ap]['solid_geometry'])
-                    temp_ap['solid_geometry'] = '%s Polygons' % str(elems)
-                try:
-                    if obj.apertures[ap]['follow_geometry']:
-                        elems = len(obj.apertures[ap]['follow_geometry'])
-                        temp_ap['follow_geometry'] = '%s Polygons' % str(elems)
-                except KeyError:
-                    pass
-                self.addChild(apertures, [str(ap), str(temp_ap)], True)
+                temp_ap.pop('geometry', None)
+                if obj.apertures[ap]['geometry']:
+                    solid_nr = 0
+                    follow_nr = 0
+                    clear_nr = 0
+
+                    for el in obj.apertures[ap]['geometry']:
+                        if 'solid' in el:
+                            solid_nr += 1
+                        if 'follow' in el:
+                            follow_nr += 1
+                        if 'clear' in el:
+                            clear_nr += 1
+                    temp_ap['Solid_Geo'] = '%s Polygons' % str(solid_nr)
+                    temp_ap['Follow_Geo'] = '%s Polygons' % str(follow_nr)
+                    temp_ap['Clear_Geo'] = '%s Polygons' % str(clear_nr)
+
+                apid = self.addParent(apertures, str(ap), expanded=False, color=QtGui.QColor("#000000"), font=font)
+                for key in temp_ap:
+                    self.addChild(apid, [str(key), str(temp_ap[key])], True)
+
         elif obj.kind.lower() == 'excellon':
         elif obj.kind.lower() == 'excellon':
             for tool, value in obj.tools.items():
             for tool, value in obj.tools.items():
                 self.addChild(tools, [str(tool), str(value['C'])], True)
                 self.addChild(tools, [str(tool), str(value['C'])], True)