ソースを参照

- Gerber Editor - working in conversion to the new data format

Marius Stanciu 6 年 前
コミット
820f75e20c
2 ファイル変更41 行追加45 行削除
  1. 1 43
      camlib.py
  2. 40 2
      flatcamEditors/FlatCAMGrbEditor.py

+ 1 - 43
camlib.py

@@ -2691,7 +2691,7 @@ class Gerber (Geometry):
                             else:
                                 width = self.apertures[last_path_aperture]["size"]
 
-                            if self.apertures[last_path_aperture]["type"] is not 'R':
+                            if self.apertures[last_path_aperture]["type"] != 'R':
                                 geo_f = LineString(path)
                                 follow_buffer.append(geo_f)
 
@@ -3027,48 +3027,6 @@ class Gerber (Geometry):
                         self.apertures[last_path_aperture]['geometry'] = []
                         self.apertures[last_path_aperture]['geometry'].append(geo_dict)
 
-            # TODO: make sure to keep track of units changes because right now it seems to happen in a weird way
-            # find out the conversion factor used to convert inside the self.apertures keys: size, width, height
-
-            file_units = gerber_units if gerber_units else 'IN'
-            app_units = self.app.defaults['units']
-            conversion_factor = 25.4 if file_units == 'IN' else (1/25.4) if file_units != app_units else 1
-
-            # --- the following section is useful for Gerber editor only --- #
-            log.warning("Applying clear geometry in the apertures dict.")
-            # list of clear geos that are to be applied to the entire file
-            global_clear_geo = []
-
-            for apid in self.apertures:
-                if 'geometry' in self.apertures[apid]:
-                    for elem in self.apertures[apid]['geometry']:
-                        if 'clear' in elem:
-                            global_clear_geo.append(elem['clear'])
-            log.warning("Found %d clear polygons." % len(global_clear_geo))
-
-            for apid in self.apertures:
-                if 'geometry' in self.apertures[apid]:
-                    for elem in self.apertures[apid]['geometry']:
-                        if 'solid' in elem:
-                            for clear_geo in global_clear_geo:
-                                # Make sure that the clear_geo is within the solid_geo otherwise we loose
-                                # the solid_geometry. We want for clear_geometry just to cut into solid_geometry not to
-                                # delete it
-                                if clear_geo.within(elem['solid']):
-                                    elem['solid'] = elem['solid'].difference(clear_geo)
-
-            log.warning("Polygon difference done for %d apertures." % len(self.apertures))
-
-            # for apid in self.apertures:
-            #     # scale de aperture geometries according to the used units
-            #     for k, v in self.apertures[apid].items():
-            #         if k == 'size' or k == 'width' or k == 'height':
-            #             self.apertures[apid][k] = v * conversion_factor
-            # -------------------------------------------------------------
-
-            # for t in self.apertures:
-            #     print(t, self.apertures[t]['size'])
-
             # --- Apply buffer ---
             # this treats the case when we are storing geometry as paths
             self.follow_geometry = follow_buffer

+ 40 - 2
flatcamEditors/FlatCAMGrbEditor.py

@@ -3245,6 +3245,44 @@ class FlatCAMGrbEditor(QtCore.QObject):
         except Exception as e:
             log.debug("FlatCAMGrbEditor.edit_fcgerber() --> %s" % str(e))
 
+
+        # # --- the following section is useful for Gerber editor only --- #
+        # log.warning("Applying clear geometry in the apertures dict.")
+        # # list of clear geos that are to be applied to the entire file
+        # global_clear_geo = []
+        #
+        # for apid in self.apertures:
+        #     if 'geometry' in self.apertures[apid]:
+        #         for elem in self.apertures[apid]['geometry']:
+        #             if 'clear' in elem:
+        #                 global_clear_geo.append(elem['clear'])
+        # log.warning("Found %d clear polygons." % len(global_clear_geo))
+        #
+        # for apid in self.apertures:
+        #     geo_list = []
+        #     if 'geometry' in self.apertures[apid]:
+        #         for elem in self.apertures[apid]['geometry']:
+        #             if 'solid' in elem:
+        #                 for clear_geo in global_clear_geo:
+        #                     new_elem = dict()
+        #                     # Make sure that the clear_geo is within the solid_geo otherwise we loose
+        #                     # the solid_geometry. We want for clear_geometry just to cut into solid_geometry not to
+        #                     # delete it
+        #                     if clear_geo.within(elem['solid']):
+        #                         new_elem['solid'] = elem['solid'].difference(clear_geo)
+        #                     else:
+        #                         new_elem['solid'] = elem['solid']
+        #             if 'follow' in elem:
+        #                 new_elem['follow'] = elem['follow']
+        #             if 'clear' in elem:
+        #                 new_elem['clear'] = elem['clear']
+        #             geo_list.append(deepcopy(new_elem))
+        #         self.apertures[apid]['geometry'] = deepcopy(geo_list)
+        #         geo_list[:] = []
+        #
+        # log.warning("Polygon difference done for %d apertures." % len(self.apertures))
+
+
         # and then add it to the storage elements (each storage elements is a member of a list
 
         def job_thread(self, apid):
@@ -3276,11 +3314,12 @@ class FlatCAMGrbEditor(QtCore.QObject):
             self.grb_plot_promises.append(apid)
             self.app.worker_task.emit({'fcn': job_thread, 'params': [self, apid]})
 
+        self.set_ui()
+
         # do the delayed plot only if there is something to plot (the gerber is not empty)
         if bool(self.gerber_obj.apertures):
             self.start_delayed_plot(check_period=1000)
         else:
-            self.set_ui()
             # now that we have data (empty data actually), create the GUI interface and add it to the Tool Tab
             self.build_ui(first_run=True)
             # and add the first aperture to have something to play with
@@ -3940,7 +3979,6 @@ class FlatCAMGrbEditor(QtCore.QObject):
     def setup_ui_after_delayed_plot(self):
         self.plot_finished.disconnect()
 
-        self.set_ui()
         # now that we have data, create the GUI interface and add it to the Tool Tab
         self.build_ui(first_run=True)
         self.plot_all()