Explorar el Código

- renamed the GeoEditor class/file to appGeoEditor from FlatCAMGeoEditor making it easier to see in the IDE tree structure
- some refactoring that lead to a working solution when using the Python 3.8 + PyQt 5.15

Marius hace 5 años
padre
commit
05df0a61c2

+ 2 - 0
CHANGELOG.md

@@ -10,6 +10,8 @@ CHANGELOG for FlatCAM beta
 8.06.2020
 8.06.2020
 
 
 - minor changes in the way that the tools are installed and connected
 - minor changes in the way that the tools are installed and connected
+- renamed the GeoEditor class/file to appGeoEditor from FlatCAMGeoEditor making it easier to see in the IDE tree structure
+- some refactoring that lead to a working solution when using the Python 3.8 + PyQt 5.15
 
 
 7.06.2020
 7.06.2020
 
 

+ 8 - 8
appEditors/FlatCAMExcEditor.py

@@ -10,7 +10,7 @@ from PyQt5.QtCore import Qt, QSettings
 
 
 from camlib import distance, arc, FlatCAMRTreeStorage
 from camlib import distance, arc, FlatCAMRTreeStorage
 from appGUI.GUIElements import FCEntry, FCComboBox, FCTable, FCDoubleSpinner, RadioSet, FCSpinner
 from appGUI.GUIElements import FCEntry, FCComboBox, FCTable, FCDoubleSpinner, RadioSet, FCSpinner
-from appEditors.FlatCAMGeoEditor import FCShapeTool, DrawTool, DrawToolShape, DrawToolUtilityShape, FlatCAMGeoEditor
+from appEditors.appGeoEditor import FCShapeTool, DrawTool, DrawToolShape, DrawToolUtilityShape, appGeoEditor
 from appParsers.ParseExcellon import Excellon
 from appParsers.ParseExcellon import Excellon
 
 
 from shapely.geometry import LineString, LinearRing, MultiLineString, Polygon, MultiPolygon, Point
 from shapely.geometry import LineString, LinearRing, MultiLineString, Polygon, MultiPolygon, Point
@@ -935,7 +935,7 @@ class FCDrillResize(FCShapeTool):
             return
             return
 
 
         if new_dia not in self.draw_app.olddia_newdia:
         if new_dia not in self.draw_app.olddia_newdia:
-            self.destination_storage = FlatCAMGeoEditor.make_storage()
+            self.destination_storage = appGeoEditor.make_storage()
             self.draw_app.storage_dict[new_dia] = self.destination_storage
             self.draw_app.storage_dict[new_dia] = self.destination_storage
 
 
             # self.olddia_newdia dict keeps the evidence on current tools diameters as keys and gets updated on values
             # self.olddia_newdia dict keeps the evidence on current tools diameters as keys and gets updated on values
@@ -2560,7 +2560,7 @@ class FlatCAMExcEditor(QtCore.QObject):
                     return
                     return
 
 
         if tool_dia not in self.olddia_newdia:
         if tool_dia not in self.olddia_newdia:
-            storage_elem = FlatCAMGeoEditor.make_storage()
+            storage_elem = appGeoEditor.make_storage()
             self.storage_dict[tool_dia] = storage_elem
             self.storage_dict[tool_dia] = storage_elem
 
 
             # self.olddia_newdia dict keeps the evidence on current tools diameters as keys and gets updated on values
             # self.olddia_newdia dict keeps the evidence on current tools diameters as keys and gets updated on values
@@ -2615,7 +2615,7 @@ class FlatCAMExcEditor(QtCore.QObject):
         for deleted_tool_dia in deleted_tool_dia_list:
         for deleted_tool_dia in deleted_tool_dia_list:
 
 
             # delete the storage used for that tool
             # delete the storage used for that tool
-            storage_elem = FlatCAMGeoEditor.make_storage()
+            storage_elem = appGeoEditor.make_storage()
             self.storage_dict[deleted_tool_dia] = storage_elem
             self.storage_dict[deleted_tool_dia] = storage_elem
             self.storage_dict.pop(deleted_tool_dia, None)
             self.storage_dict.pop(deleted_tool_dia, None)
 
 
@@ -2679,7 +2679,7 @@ class FlatCAMExcEditor(QtCore.QObject):
         # DESTINATION storage
         # DESTINATION storage
         # tool diameter is not used so we create a new tool with the desired diameter
         # tool diameter is not used so we create a new tool with the desired diameter
         if new_dia not in self.olddia_newdia:
         if new_dia not in self.olddia_newdia:
-            destination_storage = FlatCAMGeoEditor.make_storage()
+            destination_storage = appGeoEditor.make_storage()
             self.storage_dict[new_dia] = destination_storage
             self.storage_dict[new_dia] = destination_storage
 
 
             # self.olddia_newdia dict keeps the evidence on current tools diameters as keys and gets updated on values
             # self.olddia_newdia dict keeps the evidence on current tools diameters as keys and gets updated on values
@@ -2910,7 +2910,7 @@ class FlatCAMExcEditor(QtCore.QObject):
         self.mr = self.canvas.graph_event_connect('mouse_release', self.on_exc_click_release)
         self.mr = self.canvas.graph_event_connect('mouse_release', self.on_exc_click_release)
 
 
         # make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
         # make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
-        # but those from FlatCAMGeoEditor
+        # but those from appGeoEditor
         if self.app.is_legacy is False:
         if self.app.is_legacy is False:
             self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
             self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
             self.app.plotcanvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
             self.app.plotcanvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
@@ -3052,7 +3052,7 @@ class FlatCAMExcEditor(QtCore.QObject):
         # build the geometry for each tool-diameter, each drill will be represented by a '+' symbol
         # build the geometry for each tool-diameter, each drill will be represented by a '+' symbol
         # and then add it to the storage elements (each storage elements is a member of a list
         # and then add it to the storage elements (each storage elements is a member of a list
         for tool_dia in self.points_edit:
         for tool_dia in self.points_edit:
-            storage_elem = FlatCAMGeoEditor.make_storage()
+            storage_elem = appGeoEditor.make_storage()
             for point in self.points_edit[tool_dia]:
             for point in self.points_edit[tool_dia]:
                 # make a '+' sign, the line length is the tool diameter
                 # make a '+' sign, the line length is the tool diameter
                 start_hor_line = ((point.x - (tool_dia / 2)), point.y)
                 start_hor_line = ((point.x - (tool_dia / 2)), point.y)
@@ -3073,7 +3073,7 @@ class FlatCAMExcEditor(QtCore.QObject):
                 shape_geo = line_geo.buffer(buf_value)
                 shape_geo = line_geo.buffer(buf_value)
 
 
                 if tool_dia not in self.storage_dict:
                 if tool_dia not in self.storage_dict:
-                    storage_elem = FlatCAMGeoEditor.make_storage()
+                    storage_elem = appGeoEditor.make_storage()
                     self.storage_dict[tool_dia] = storage_elem
                     self.storage_dict[tool_dia] = storage_elem
 
 
                 if shape_geo is not None:
                 if shape_geo is not None:

+ 1 - 1
appEditors/FlatCAMGrbEditor.py

@@ -3778,7 +3778,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
         # Canvas events
         # Canvas events
 
 
         # make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
         # make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
-        # but those from FlatCAMGeoEditor
+        # but those from appGeoEditor
 
 
         # first connect to new, then disconnect the old handlers
         # first connect to new, then disconnect the old handlers
         # don't ask why but if there is nothing connected I've seen issues
         # don't ask why but if there is nothing connected I've seen issues

+ 18 - 18
appEditors/FlatCAMGeoEditor.py → appEditors/appGeoEditor.py

@@ -2523,12 +2523,12 @@ class FCSelect(DrawTool):
             # it will not work for 3rd method of click selection
             # it will not work for 3rd method of click selection
             if not over_shape_list:
             if not over_shape_list:
                 self.draw_app.selected = []
                 self.draw_app.selected = []
-                FlatCAMGeoEditor.draw_shape_idx = -1
+                appGeoEditor.draw_shape_idx = -1
             else:
             else:
                 # if there are shapes under our click then advance through the list of them, one at the time in a
                 # if there are shapes under our click then advance through the list of them, one at the time in a
                 # circular way
                 # circular way
-                FlatCAMGeoEditor.draw_shape_idx = (FlatCAMGeoEditor.draw_shape_idx + 1) % len(over_shape_list)
-                obj_to_add = over_shape_list[int(FlatCAMGeoEditor.draw_shape_idx)]
+                appGeoEditor.draw_shape_idx = (appGeoEditor.draw_shape_idx + 1) % len(over_shape_list)
+                obj_to_add = over_shape_list[int(appGeoEditor.draw_shape_idx)]
 
 
                 key_modifier = QtWidgets.QApplication.keyboardModifiers()
                 key_modifier = QtWidgets.QApplication.keyboardModifiers()
 
 
@@ -2550,7 +2550,7 @@ class FCSelect(DrawTool):
                     self.draw_app.selected = []
                     self.draw_app.selected = []
                     self.draw_app.selected.append(obj_to_add)
                     self.draw_app.selected.append(obj_to_add)
         except Exception as e:
         except Exception as e:
-            log.error("[ERROR] FlatCAMGeoEditor.FCSelect.click_release() -> Something went bad. %s" % str(e))
+            log.error("[ERROR] appGeoEditor.FCSelect.click_release() -> Something went bad. %s" % str(e))
 
 
         # if selection is done on canvas update the Tree in Selected Tab with the selection
         # if selection is done on canvas update the Tree in Selected Tab with the selection
         try:
         try:
@@ -2788,9 +2788,9 @@ class FCMove(FCShapeTool):
             else:
             else:
                 # if there are shapes under our click then advance through the list of them, one at the time in a
                 # if there are shapes under our click then advance through the list of them, one at the time in a
                 # circular way
                 # circular way
-                self.draw_app.draw_shape_idx = (FlatCAMGeoEditor.draw_shape_idx + 1) % len(over_shape_list)
+                self.draw_app.draw_shape_idx = (appGeoEditor.draw_shape_idx + 1) % len(over_shape_list)
                 try:
                 try:
-                    obj_to_add = over_shape_list[int(FlatCAMGeoEditor.draw_shape_idx)]
+                    obj_to_add = over_shape_list[int(appGeoEditor.draw_shape_idx)]
                 except IndexError:
                 except IndexError:
                     return
                     return
 
 
@@ -3230,7 +3230,7 @@ class FCTransform(FCShapeTool):
 # ###############################################
 # ###############################################
 # ################ Main Application #############
 # ################ Main Application #############
 # ###############################################
 # ###############################################
-class FlatCAMGeoEditor(QtCore.QObject):
+class appGeoEditor(QtCore.QObject):
 
 
     # will emit the name of the object that was just selected
     # will emit the name of the object that was just selected
     item_selected = QtCore.pyqtSignal(str)
     item_selected = QtCore.pyqtSignal(str)
@@ -3243,7 +3243,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
         # assert isinstance(app, FlatCAMApp.App), \
         # assert isinstance(app, FlatCAMApp.App), \
         #     "Expected the app to be a FlatCAMApp.App, got %s" % type(app)
         #     "Expected the app to be a FlatCAMApp.App, got %s" % type(app)
 
 
-        super(FlatCAMGeoEditor, self).__init__()
+        super(appGeoEditor, self).__init__()
 
 
         self.app = app
         self.app = app
         self.canvas = app.plotcanvas
         self.canvas = app.plotcanvas
@@ -3316,7 +3316,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
         # # ## Data
         # # ## Data
         self.active_tool = None
         self.active_tool = None
 
 
-        self.storage = FlatCAMGeoEditor.make_storage()
+        self.storage = appGeoEditor.make_storage()
         self.utility = []
         self.utility = []
 
 
         # VisPy visuals
         # VisPy visuals
@@ -3415,7 +3415,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
                 self.options[opt] = float(text_value)
                 self.options[opt] = float(text_value)
             except Exception as e:
             except Exception as e:
                 entry.set_value(self.app.defaults[opt])
                 entry.set_value(self.app.defaults[opt])
-                log.debug("FlatCAMGeoEditor.__init__().entry2option() --> %s" % str(e))
+                log.debug("appGeoEditor.__init__().entry2option() --> %s" % str(e))
                 return
                 return
 
 
         def grid_changed(goption, gentry):
         def grid_changed(goption, gentry):
@@ -3588,7 +3588,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
         self.connect_canvas_event_handlers()
         self.connect_canvas_event_handlers()
 
 
         # initialize working objects
         # initialize working objects
-        self.storage = FlatCAMGeoEditor.make_storage()
+        self.storage = appGeoEditor.make_storage()
         self.utility = []
         self.utility = []
         self.selected = []
         self.selected = []
 
 
@@ -3701,7 +3701,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
         #     for w in sel_tab_widget_list:
         #     for w in sel_tab_widget_list:
         #         w.setEnabled(True)
         #         w.setEnabled(True)
         # except Exception as e:
         # except Exception as e:
-        #     log.debug("FlatCAMGeoEditor.deactivate() --> %s" % str(e))
+        #     log.debug("appGeoEditor.deactivate() --> %s" % str(e))
 
 
         # Show original geometry
         # Show original geometry
         if self.fcgeometry:
         if self.fcgeometry:
@@ -3727,7 +3727,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
 
 
         if self.app.is_legacy is False:
         if self.app.is_legacy is False:
             # make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
             # make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
-            # but those from FlatCAMGeoEditor
+            # but those from appGeoEditor
             self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
             self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
             self.app.plotcanvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
             self.app.plotcanvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
             self.app.plotcanvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
             self.app.plotcanvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
@@ -3958,7 +3958,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
         self.shapes.clear(update=True)
         self.shapes.clear(update=True)
         self.tool_shape.clear(update=True)
         self.tool_shape.clear(update=True)
 
 
-        # self.storage = FlatCAMGeoEditor.make_storage()
+        # self.storage = appGeoEditor.make_storage()
         self.replot()
         self.replot()
 
 
     def edit_fcgeometry(self, fcgeometry, multigeo_tool=None):
     def edit_fcgeometry(self, fcgeometry, multigeo_tool=None):
@@ -4567,10 +4567,10 @@ class FlatCAMGeoEditor(QtCore.QObject):
                 elif isinstance(geom, LineString) and geom is not None:
                 elif isinstance(geom, LineString) and geom is not None:
                     geom = LineString(geom.coords[::-1])
                     geom = LineString(geom.coords[::-1])
                 else:
                 else:
-                    log.debug("FlatCAMGeoEditor.on_shape_complete() Error --> Unexpected Geometry %s" %
+                    log.debug("appGeoEditor.on_shape_complete() Error --> Unexpected Geometry %s" %
                               type(geom))
                               type(geom))
             except Exception as e:
             except Exception as e:
-                log.debug("FlatCAMGeoEditor.on_shape_complete() Error --> %s" % str(e))
+                log.debug("appGeoEditor.on_shape_complete() Error --> %s" % str(e))
                 return 'fail'
                 return 'fail'
 
 
         shape_list = []
         shape_list = []
@@ -4757,7 +4757,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
         try:
         try:
             results = geo_shapes[0].geo
             results = geo_shapes[0].geo
         except Exception as e:
         except Exception as e:
-            log.debug("FlatCAMGeoEditor.intersection() --> %s" % str(e))
+            log.debug("appGeoEditor.intersection() --> %s" % str(e))
             self.app.inform.emit('[WARNING_NOTCL] %s' %
             self.app.inform.emit('[WARNING_NOTCL] %s' %
                                  _("A selection of at least 2 geo items is required to do Intersection."))
                                  _("A selection of at least 2 geo items is required to do Intersection."))
             self.select_tool('select')
             self.select_tool('select')
@@ -4792,7 +4792,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
         try:
         try:
             intersector = geo_shapes[0].geo
             intersector = geo_shapes[0].geo
         except Exception as e:
         except Exception as e:
-            log.debug("FlatCAMGeoEditor.intersection() --> %s" % str(e))
+            log.debug("appGeoEditor.intersection() --> %s" % str(e))
             self.app.inform.emit('[WARNING_NOTCL] %s' %
             self.app.inform.emit('[WARNING_NOTCL] %s' %
                                  _("A selection of at least 2 geo items is required to do Intersection."))
                                  _("A selection of at least 2 geo items is required to do Intersection."))
             self.select_tool('select')
             self.select_tool('select')

+ 1 - 1
appGUI/MainGUI.py

@@ -19,7 +19,7 @@ from appGUI.preferences.excellon.ExcellonPreferencesUI import ExcellonPreference
 from appGUI.preferences.general.GeneralPreferencesUI import GeneralPreferencesUI
 from appGUI.preferences.general.GeneralPreferencesUI import GeneralPreferencesUI
 from appGUI.preferences.geometry.GeometryPreferencesUI import GeometryPreferencesUI
 from appGUI.preferences.geometry.GeometryPreferencesUI import GeometryPreferencesUI
 from appGUI.preferences.gerber.GerberPreferencesUI import GerberPreferencesUI
 from appGUI.preferences.gerber.GerberPreferencesUI import GerberPreferencesUI
-from appEditors.FlatCAMGeoEditor import FCShapeTool
+from appEditors.appGeoEditor import FCShapeTool
 from matplotlib.backend_bases import KeyEvent as mpl_key_event
 from matplotlib.backend_bases import KeyEvent as mpl_key_event
 
 
 import webbrowser
 import webbrowser

+ 1 - 1
appTools/ToolDistance.py

@@ -15,7 +15,7 @@ from shapely.geometry import Point, MultiLineString, Polygon
 
 
 import appTranslation as fcTranslate
 import appTranslation as fcTranslate
 from camlib import FlatCAMRTreeStorage
 from camlib import FlatCAMRTreeStorage
-from appEditors.FlatCAMGeoEditor import DrawToolShape
+from appEditors.appGeoEditor import DrawToolShape
 
 
 from copy import copy
 from copy import copy
 import math
 import math

+ 9 - 10
app_Main.py

@@ -78,7 +78,7 @@ from appGUI.GUIElements import FCFileSaveDialog, message_dialog, FlatCAMSystemTr
 from appPreProcessor import load_preprocessors
 from appPreProcessor import load_preprocessors
 
 
 # FlatCAM appEditors
 # FlatCAM appEditors
-from appEditors.FlatCAMGeoEditor import FlatCAMGeoEditor
+from appEditors.appGeoEditor import appGeoEditor
 from appEditors.FlatCAMExcEditor import FlatCAMExcEditor
 from appEditors.FlatCAMExcEditor import FlatCAMExcEditor
 from appEditors.FlatCAMGrbEditor import FlatCAMGrbEditor
 from appEditors.FlatCAMGrbEditor import FlatCAMGrbEditor
 from appEditors.FlatCAMTextEditor import TextEditor
 from appEditors.FlatCAMTextEditor import TextEditor
@@ -1321,7 +1321,6 @@ class App(QtCore.QObject):
         # ########################################## Tools and Plugins ##############################################
         # ########################################## Tools and Plugins ##############################################
         # ###########################################################################################################
         # ###########################################################################################################
 
 
-
         self.shell = None
         self.shell = None
         self.dblsidedtool = None
         self.dblsidedtool = None
         self.distance_tool = None
         self.distance_tool = None
@@ -1553,7 +1552,7 @@ class App(QtCore.QObject):
         # watch out for the position of the editors instantiation ... if it is done before a save of the default values
         # watch out for the position of the editors instantiation ... if it is done before a save of the default values
         # at the first launch of the App , the editors will not be functional.
         # at the first launch of the App , the editors will not be functional.
         try:
         try:
-            self.geo_editor = FlatCAMGeoEditor(self)
+            self.geo_editor = appGeoEditor(self)
         except Exception as es:
         except Exception as es:
             log.debug("app_Main.__init__() --> Geo Editor Error: %s" % str(es))
             log.debug("app_Main.__init__() --> Geo Editor Error: %s" % str(es))
 
 
@@ -3396,12 +3395,12 @@ class App(QtCore.QObject):
 
 
         # When the main event loop is not started yet in which case the qApp.quit() will do nothing
         # When the main event loop is not started yet in which case the qApp.quit() will do nothing
         # we use the following command
         # we use the following command
-        minor_v = sys.version_info.minor
-        if minor_v < 8:
-            # make sure that the app closes
-            sys.exit(0)
-        else:
-            os._exit(0)  # fix to work with Python 3.8
+        # minor_v = sys.version_info.minor
+        # if minor_v < 8:
+        #     # make sure that the app closes
+        #     sys.exit(0)
+        # else:
+        #     os._exit(0)  # fix to work with Python 3.8
 
 
     @staticmethod
     @staticmethod
     def kill_app():
     def kill_app():
@@ -6594,7 +6593,7 @@ class App(QtCore.QObject):
         if self.call_source != 'app':
         if self.call_source != 'app':
             self.editor2object(cleanup=True)
             self.editor2object(cleanup=True)
             # ## EDITOR section
             # ## EDITOR section
-            self.geo_editor = FlatCAMGeoEditor(self)
+            self.geo_editor = appGeoEditor(self)
             self.exc_editor = FlatCAMExcEditor(self)
             self.exc_editor = FlatCAMExcEditor(self)
             self.grb_editor = FlatCAMGrbEditor(self)
             self.grb_editor = FlatCAMGrbEditor(self)
 
 

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 176 - 176
locale/de/LC_MESSAGES/strings.po


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 176 - 176
locale/en/LC_MESSAGES/strings.po


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 176 - 176
locale/es/LC_MESSAGES/strings.po


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 176 - 176
locale/fr/LC_MESSAGES/strings.po


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 195 - 195
locale/hu/LC_MESSAGES/strings.po


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 176 - 176
locale/it/LC_MESSAGES/strings.po


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 176 - 176
locale/pt_BR/LC_MESSAGES/strings.po


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 176 - 176
locale/ro/LC_MESSAGES/strings.po


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 176 - 176
locale/ru/LC_MESSAGES/strings.po


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 195 - 195
locale_template/strings.pot


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio