Prechádzať zdrojové kódy

- fixed unreliable work of Gerber Editor and optimized the App.editor2object() method

Marius Stanciu 5 rokov pred
rodič
commit
a6bdf04937

+ 2 - 0
AppEditors/FlatCAMExcEditor.py

@@ -3342,9 +3342,11 @@ class FlatCAMExcEditor(QtCore.QObject):
                                                                   filename=None,
                                                                   filename=None,
                                                                   use_thread=False)
                                                                   use_thread=False)
             except Exception as e:
             except Exception as e:
+                self.deactivate()
                 log.error("Error on Edited object creation: %s" % str(e))
                 log.error("Error on Edited object creation: %s" % str(e))
                 return
                 return
 
 
+            self.deactivate()
             self.app.inform.emit('[success] %s' % _("Excellon editing finished."))
             self.app.inform.emit('[success] %s' % _("Excellon editing finished."))
 
 
     def on_tool_select(self, tool):
     def on_tool_select(self, tool):

+ 4 - 2
AppEditors/FlatCAMGeoEditor.py

@@ -4744,8 +4744,8 @@ class FlatCAMGeoEditor(QtCore.QObject):
         Transfers the geometry tool shape buffer to the selected geometry
         Transfers the geometry tool shape buffer to the selected geometry
         object. The geometry already in the object are removed.
         object. The geometry already in the object are removed.
 
 
-        :param fcgeometry: GeometryObject
-        :return: None
+        :param fcgeometry:  GeometryObject
+        :return:            None
         """
         """
         if self.multigeo_tool:
         if self.multigeo_tool:
             fcgeometry.tools[self.multigeo_tool]['solid_geometry'] = []
             fcgeometry.tools[self.multigeo_tool]['solid_geometry'] = []
@@ -4770,6 +4770,8 @@ class FlatCAMGeoEditor(QtCore.QObject):
                 new_geo = linemerge(new_geo)
                 new_geo = linemerge(new_geo)
             fcgeometry.solid_geometry.append(new_geo)
             fcgeometry.solid_geometry.append(new_geo)
 
 
+        self.deactivate()
+
     def update_options(self, obj):
     def update_options(self, obj):
         if self.paint_tooldia:
         if self.paint_tooldia:
             obj.options['cnctooldia'] = deepcopy(str(self.paint_tooldia))
             obj.options['cnctooldia'] = deepcopy(str(self.paint_tooldia))

+ 11 - 11
AppEditors/FlatCAMGrbEditor.py

@@ -1198,7 +1198,6 @@ class FCTrack(FCRegion):
         self.complete = True
         self.complete = True
 
 
         self.draw_app.app.jump_signal.disconnect()
         self.draw_app.app.jump_signal.disconnect()
-
         self.draw_app.app.inform.emit('[success] %s' % _("Done."))
         self.draw_app.app.inform.emit('[success] %s' % _("Done."))
 
 
     def clean_up(self):
     def clean_up(self):
@@ -1221,12 +1220,10 @@ class FCTrack(FCRegion):
         new_geo_el = {}
         new_geo_el = {}
 
 
         if len(self.temp_points) == 1:
         if len(self.temp_points) == 1:
-            new_geo_el['solid'] = Point(self.temp_points).buffer(self.buf_val,
-                                                                 resolution=int(self.steps_per_circle / 4))
+            new_geo_el['solid'] = Point(self.temp_points).buffer(self.buf_val, int(self.steps_per_circle / 4))
             new_geo_el['follow'] = Point(self.temp_points)
             new_geo_el['follow'] = Point(self.temp_points)
         else:
         else:
-            new_geo_el['solid'] = LineString(self.temp_points).buffer(self.buf_val,
-                                                                      resolution=int(self.steps_per_circle / 4))
+            new_geo_el['solid'] = LineString(self.temp_points).buffer(self.buf_val, int(self.steps_per_circle / 4))
             new_geo_el['follow'] = LineString(self.temp_points)
             new_geo_el['follow'] = LineString(self.temp_points)
 
 
         self.draw_app.add_gerber_shape(DrawToolShape(new_geo_el),
         self.draw_app.add_gerber_shape(DrawToolShape(new_geo_el),
@@ -4219,6 +4216,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
             new_grb_name = self.edited_obj_name + "_edit"
             new_grb_name = self.edited_obj_name + "_edit"
 
 
         self.app.worker_task.emit({'fcn': self.new_edited_gerber, 'params': [new_grb_name, self.storage_dict]})
         self.app.worker_task.emit({'fcn': self.new_edited_gerber, 'params': [new_grb_name, self.storage_dict]})
+        # self.new_edited_gerber(new_grb_name, self.storage_dict)
 
 
     @staticmethod
     @staticmethod
     def update_options(obj):
     def update_options(obj):
@@ -4240,9 +4238,10 @@ class FlatCAMGrbEditor(QtCore.QObject):
         """
         """
         Creates a new Gerber object for the edited Gerber. Thread-safe.
         Creates a new Gerber object for the edited Gerber. Thread-safe.
 
 
-        :param outname: Name of the resulting object. None causes the name to be that of the file.
-        :type outname: str
-        :param aperture_storage: a dictionary that holds all the objects geometry
+        :param outname:             Name of the resulting object. None causes the name to be that of the file.
+        :type outname:              str
+        :param aperture_storage:    a dictionary that holds all the objects geometry
+        :type aperture_storage:     dict
         :return: None
         :return: None
         """
         """
 
 
@@ -4334,11 +4333,11 @@ class FlatCAMGrbEditor(QtCore.QObject):
                 self.app.inform.emit('[ERROR_NOTCL] %s' %
                 self.app.inform.emit('[ERROR_NOTCL] %s' %
                                      _("There are no Aperture definitions in the file. Aborting Gerber creation."))
                                      _("There are no Aperture definitions in the file. Aborting Gerber creation."))
             except Exception:
             except Exception:
-                msg = '[ERROR] %s' % \
-                      _("An internal error has occurred. See shell.\n")
+                msg = '[ERROR] %s' % _("An internal error has occurred. See shell.\n")
                 msg += traceback.format_exc()
                 msg += traceback.format_exc()
                 app_obj.inform.emit(msg)
                 app_obj.inform.emit(msg)
                 raise
                 raise
+
             grb_obj.source_file = self.app.export_gerber(obj_name=out_name, filename=None,
             grb_obj.source_file = self.app.export_gerber(obj_name=out_name, filename=None,
                                                          local_use=grb_obj, use_thread=False)
                                                          local_use=grb_obj, use_thread=False)
 
 
@@ -4351,9 +4350,10 @@ class FlatCAMGrbEditor(QtCore.QObject):
                 self.results = []
                 self.results = []
                 return
                 return
 
 
-            self.app.inform.emit('[success] %s' % _("Done. Gerber editing finished."))
             # make sure to clean the previous results
             # make sure to clean the previous results
             self.results = []
             self.results = []
+            self.deactivate_grb_editor()
+            self.app.inform.emit('[success] %s' % _("Done. Gerber editing finished."))
 
 
     def on_tool_select(self, tool):
     def on_tool_select(self, tool):
         """
         """

+ 9 - 18
App_Main.py

@@ -2214,11 +2214,8 @@ class App(QtCore.QObject):
 
 
                     if isinstance(edited_obj, GeometryObject):
                     if isinstance(edited_obj, GeometryObject):
                         obj_type = "Geometry"
                         obj_type = "Geometry"
-                        if cleanup is None:
-                            self.geo_editor.update_fcgeometry(edited_obj)
-                            # self.geo_editor.update_options(edited_obj)
-
-                        self.geo_editor.deactivate()
+                        self.geo_editor.update_fcgeometry(edited_obj)
+                        # self.geo_editor.update_options(edited_obj)
 
 
                         # restore GUI to the Selected TAB
                         # restore GUI to the Selected TAB
                         # Remove anything else in the AppGUI
                         # Remove anything else in the AppGUI
@@ -2240,17 +2237,14 @@ class App(QtCore.QObject):
 
 
                     elif isinstance(edited_obj, GerberObject):
                     elif isinstance(edited_obj, GerberObject):
                         obj_type = "Gerber"
                         obj_type = "Gerber"
-                        if cleanup is None:
-                            self.grb_editor.update_fcgerber()
-                            self.grb_editor.update_options(edited_obj)
-                        self.grb_editor.deactivate_grb_editor()
+                        self.grb_editor.update_fcgerber()
+                        # self.grb_editor.update_options(edited_obj)
 
 
                         # 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
                         try:
                         try:
                             if len(edited_obj.solid_geometry) == 0:
                             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.delete_active()
+                                self.collection.delete_by_name(old_name)
                         except TypeError:
                         except TypeError:
                             # if the solid_geometry is a single Polygon the len() will not work
                             # if the solid_geometry is a single Polygon the len() will not work
                             # in any case, falling here means that we have something in the solid_geometry, even if only
                             # in any case, falling here means that we have something in the solid_geometry, even if only
@@ -2265,11 +2259,8 @@ class App(QtCore.QObject):
 
 
                     elif isinstance(edited_obj, ExcellonObject):
                     elif isinstance(edited_obj, ExcellonObject):
                         obj_type = "Excellon"
                         obj_type = "Excellon"
-                        if cleanup is None:
-                            self.exc_editor.update_fcexcellon(edited_obj)
-                            # self.exc_editor.update_options(edited_obj)
-
-                        self.exc_editor.deactivate()
+                        self.exc_editor.update_fcexcellon(edited_obj)
+                        # self.exc_editor.update_options(edited_obj)
 
 
                         # restore GUI to the Selected TAB
                         # restore GUI to the Selected TAB
                         # Remove anything else in the AppGUI
                         # Remove anything else in the AppGUI
@@ -2314,7 +2305,7 @@ class App(QtCore.QObject):
                 # edited_obj.set_ui(edited_obj.ui_type(decimals=self.decimals))
                 # edited_obj.set_ui(edited_obj.ui_type(decimals=self.decimals))
                 # edited_obj.build_ui()
                 # edited_obj.build_ui()
                 # Switch notebook to Selected page
                 # Switch notebook to Selected page
-                self.ui.notebook.setCurrentWidget(self.ui.selected_tab)
+                # self.ui.notebook.setCurrentWidget(self.ui.selected_tab)
             else:
             else:
                 if isinstance(edited_obj, GeometryObject):
                 if isinstance(edited_obj, GeometryObject):
                     self.geo_editor.deactivate()
                     self.geo_editor.deactivate()
@@ -2334,7 +2325,7 @@ class App(QtCore.QObject):
             # restore the call_source to app
             # restore the call_source to app
             self.call_source = 'app'
             self.call_source = 'app'
 
 
-            edited_obj.plot()
+            # edited_obj.plot()
             self.ui.plot_tab_area.setTabText(0, "Plot Area")
             self.ui.plot_tab_area.setTabText(0, "Plot Area")
             self.ui.plot_tab_area.protectTab(0)
             self.ui.plot_tab_area.protectTab(0)
 
 

+ 2 - 0
CHANGELOG.md

@@ -12,6 +12,8 @@ CHANGELOG for FlatCAM beta
 - changes some icons
 - changes some icons
 - added a new GUI element which is a evaluated LineEdit that accepts only float numbers and /,*,+,-,% chars
 - added a new GUI element which is a evaluated LineEdit that accepts only float numbers and /,*,+,-,% chars
 - finished the Etch Compensation Tool
 - finished the Etch Compensation Tool
+- fixed unreliable work of Gerber Editor and optimized the App.editor2object() method
+
 
 
 23.05.2020
 23.05.2020