Bläddra i källkod

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

Marius Stanciu 5 år sedan
förälder
incheckning
a6bdf04937
5 ändrade filer med 28 tillägg och 31 borttagningar
  1. 2 0
      AppEditors/FlatCAMExcEditor.py
  2. 4 2
      AppEditors/FlatCAMGeoEditor.py
  3. 11 11
      AppEditors/FlatCAMGrbEditor.py
  4. 9 18
      App_Main.py
  5. 2 0
      CHANGELOG.md

+ 2 - 0
AppEditors/FlatCAMExcEditor.py

@@ -3342,9 +3342,11 @@ class FlatCAMExcEditor(QtCore.QObject):
                                                                   filename=None,
                                                                   use_thread=False)
             except Exception as e:
+                self.deactivate()
                 log.error("Error on Edited object creation: %s" % str(e))
                 return
 
+            self.deactivate()
             self.app.inform.emit('[success] %s' % _("Excellon editing finished."))
 
     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
         object. The geometry already in the object are removed.
 
-        :param fcgeometry: GeometryObject
-        :return: None
+        :param fcgeometry:  GeometryObject
+        :return:            None
         """
         if self.multigeo_tool:
             fcgeometry.tools[self.multigeo_tool]['solid_geometry'] = []
@@ -4770,6 +4770,8 @@ class FlatCAMGeoEditor(QtCore.QObject):
                 new_geo = linemerge(new_geo)
             fcgeometry.solid_geometry.append(new_geo)
 
+        self.deactivate()
+
     def update_options(self, obj):
         if 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.draw_app.app.jump_signal.disconnect()
-
         self.draw_app.app.inform.emit('[success] %s' % _("Done."))
 
     def clean_up(self):
@@ -1221,12 +1220,10 @@ class FCTrack(FCRegion):
         new_geo_el = {}
 
         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)
         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)
 
         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"
 
         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
     def update_options(obj):
@@ -4240,9 +4238,10 @@ class FlatCAMGrbEditor(QtCore.QObject):
         """
         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
         """
 
@@ -4334,11 +4333,11 @@ class FlatCAMGrbEditor(QtCore.QObject):
                 self.app.inform.emit('[ERROR_NOTCL] %s' %
                                      _("There are no Aperture definitions in the file. Aborting Gerber creation."))
             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()
                 app_obj.inform.emit(msg)
                 raise
+
             grb_obj.source_file = self.app.export_gerber(obj_name=out_name, filename=None,
                                                          local_use=grb_obj, use_thread=False)
 
@@ -4351,9 +4350,10 @@ class FlatCAMGrbEditor(QtCore.QObject):
                 self.results = []
                 return
 
-            self.app.inform.emit('[success] %s' % _("Done. Gerber editing finished."))
             # make sure to clean the previous results
             self.results = []
+            self.deactivate_grb_editor()
+            self.app.inform.emit('[success] %s' % _("Done. Gerber editing finished."))
 
     def on_tool_select(self, tool):
         """

+ 9 - 18
App_Main.py

@@ -2214,11 +2214,8 @@ class App(QtCore.QObject):
 
                     if isinstance(edited_obj, GeometryObject):
                         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
                         # Remove anything else in the AppGUI
@@ -2240,17 +2237,14 @@ class App(QtCore.QObject):
 
                     elif isinstance(edited_obj, GerberObject):
                         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
                         try:
                             if len(edited_obj.solid_geometry) == 0:
                                 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:
                             # 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
@@ -2265,11 +2259,8 @@ class App(QtCore.QObject):
 
                     elif isinstance(edited_obj, ExcellonObject):
                         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
                         # 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.build_ui()
                 # Switch notebook to Selected page
-                self.ui.notebook.setCurrentWidget(self.ui.selected_tab)
+                # self.ui.notebook.setCurrentWidget(self.ui.selected_tab)
             else:
                 if isinstance(edited_obj, GeometryObject):
                     self.geo_editor.deactivate()
@@ -2334,7 +2325,7 @@ class App(QtCore.QObject):
             # restore the call_source to 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.protectTab(0)
 

+ 2 - 0
CHANGELOG.md

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