Marius Stanciu 6 лет назад
Родитель
Сommit
b7023d8ef6
3 измененных файлов с 18 добавлено и 24 удалено
  1. 6 12
      FlatCAMObj.py
  2. 11 12
      ObjectCollection.py
  3. 1 0
      README.md

+ 6 - 12
FlatCAMObj.py

@@ -3036,6 +3036,9 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
         self.old_pp_state = ''
         self.old_pp_state = ''
         self.old_toolchangeg_state = ''
         self.old_toolchangeg_state = ''
 
 
+        # store here the default data for Geometry Data
+        self.default_data = {}
+
         # Attributes to be included in serialization
         # Attributes to be included in serialization
         # Always append to it because it carries contents
         # Always append to it because it carries contents
         # from predecessors.
         # from predecessors.
@@ -3394,11 +3397,11 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             try:
             try:
                 # works for CheckBoxes
                 # works for CheckBoxes
                 self.ui.grid3.itemAt(i).widget().stateChanged.connect(self.gui_form_to_storage)
                 self.ui.grid3.itemAt(i).widget().stateChanged.connect(self.gui_form_to_storage)
-            except:
+            except Exception as e:
                 # works for ComboBoxes
                 # works for ComboBoxes
                 try:
                 try:
                     self.ui.grid3.itemAt(i).widget().currentIndexChanged.connect(self.gui_form_to_storage)
                     self.ui.grid3.itemAt(i).widget().currentIndexChanged.connect(self.gui_form_to_storage)
-                except:
+                except Exception as e2:
                     # works for Entry
                     # works for Entry
                     try:
                     try:
                         self.ui.grid3.itemAt(i).widget().editingFinished.connect(self.gui_form_to_storage)
                         self.ui.grid3.itemAt(i).widget().editingFinished.connect(self.gui_form_to_storage)
@@ -3495,13 +3498,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
     def on_tool_add(self, dia=None):
     def on_tool_add(self, dia=None):
         self.ui_disconnect()
         self.ui_disconnect()
 
 
-        last_offset = None
-        last_offset_value = None
-        last_type = None
-        last_tool_type = None
-        last_data = None
-        last_solid_geometry = []
-
         # if a Tool diameter entered is a char instead a number the final message of Tool adding is changed
         # if a Tool diameter entered is a char instead a number the final message of Tool adding is changed
         # because the Default value for Tool is used.
         # because the Default value for Tool is used.
         change_message = False
         change_message = False
@@ -3550,7 +3546,7 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
             self.tools.update({
             self.tools.update({
                 self.tooluid: {
                 self.tooluid: {
                     'tooldia': tooldia,
                     'tooldia': tooldia,
-                    'offset': ('Path'),
+                    'offset': 'Path',
                     'offset_value': 0.0,
                     'offset_value': 0.0,
                     'type': _('Rough'),
                     'type': _('Rough'),
                     'tool_type': 'C1',
                     'tool_type': 'C1',
@@ -3559,7 +3555,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                 }
                 }
             })
             })
         else:
         else:
-            # print("LAST", self.tools[maxuid])
             last_data = self.tools[max_uid]['data']
             last_data = self.tools[max_uid]['data']
             last_offset = self.tools[max_uid]['offset']
             last_offset = self.tools[max_uid]['offset']
             last_offset_value = self.tools[max_uid]['offset_value']
             last_offset_value = self.tools[max_uid]['offset_value']
@@ -3583,7 +3578,6 @@ class FlatCAMGeometry(FlatCAMObj, Geometry):
                     'solid_geometry': deepcopy(last_solid_geometry)
                     'solid_geometry': deepcopy(last_solid_geometry)
                 }
                 }
             })
             })
-            # print("CURRENT", self.tools[-1])
 
 
         self.ui.tool_offset_entry.hide()
         self.ui.tool_offset_entry.hide()
         self.ui.tool_offset_lbl.hide()
         self.ui.tool_offset_lbl.hide()

+ 11 - 12
ObjectCollection.py

@@ -20,9 +20,9 @@ from PyQt5.QtCore import Qt
 
 
 import gettext
 import gettext
 import FlatCAMTranslation as fcTranslate
 import FlatCAMTranslation as fcTranslate
+import builtins
 
 
 fcTranslate.apply_language('strings')
 fcTranslate.apply_language('strings')
-import builtins
 if '_' not in builtins.__dict__:
 if '_' not in builtins.__dict__:
     _ = gettext.gettext
     _ = gettext.gettext
 
 
@@ -526,8 +526,8 @@ class ObjectCollection(QtCore.QAbstractItemModel):
                 ymin = min([ymin, gymin])
                 ymin = min([ymin, gymin])
                 xmax = max([xmax, gxmax])
                 xmax = max([xmax, gxmax])
                 ymax = max([ymax, gymax])
                 ymax = max([ymax, gymax])
-            except:
-                FlatCAMApp.App.log.warning("DEV WARNING: Tried to get bounds of empty geometry.")
+            except Exception as e:
+                FlatCAMApp.App.log.warning("DEV WARNING: Tried to get bounds of empty geometry. %s" % str(e))
 
 
         return [xmin, ymin, xmax, ymax]
         return [xmin, ymin, xmax, ymax]
 
 
@@ -537,12 +537,12 @@ class ObjectCollection(QtCore.QAbstractItemModel):
 
 
         :param name: The name of the object.
         :param name: The name of the object.
         :type name: str
         :type name: str
+        :param isCaseSensitive: whether searching of the object is done by name where the name is case sensitive
         :return: The requested object or None if no such object.
         :return: The requested object or None if no such object.
         :rtype: FlatCAMObj or None
         :rtype: FlatCAMObj or None
         """
         """
         FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + "--> OC.get_by_name()")
         FlatCAMApp.App.log.debug(str(inspect.stack()[1][3]) + "--> OC.get_by_name()")
 
 
-
         if isCaseSensitive is None or isCaseSensitive is True:
         if isCaseSensitive is None or isCaseSensitive is True:
             for obj in self.get_list():
             for obj in self.get_list():
                 if obj.options['name'] == name:
                 if obj.options['name'] == name:
@@ -570,10 +570,9 @@ class ObjectCollection(QtCore.QAbstractItemModel):
             self.app.myKeywords.remove(name)
             self.app.myKeywords.remove(name)
             self.app.shell._edit.set_model_data(self.app.myKeywords)
             self.app.shell._edit.set_model_data(self.app.myKeywords)
             self.app.ui.code_editor.set_model_data(self.app.myKeywords)
             self.app.ui.code_editor.set_model_data(self.app.myKeywords)
-        except:
+        except Exception as e:
             log.debug(
             log.debug(
-                "delete_active() --> Could not remove the old object name from auto-completer model list")
-
+                "delete_active() --> Could not remove the old object name from auto-completer model list. %s" % str(e))
 
 
         self.beginRemoveRows(self.index(group.row(), 0, QtCore.QModelIndex()), active.row(), active.row())
         self.beginRemoveRows(self.index(group.row(), 0, QtCore.QModelIndex()), active.row(), active.row())
 
 
@@ -650,12 +649,12 @@ class ObjectCollection(QtCore.QAbstractItemModel):
         :return: List of objects
         :return: List of objects
         """
         """
 
 
-        l = self.get_list()
+        obj_list = self.get_list()
 
 
         for sel in self.get_selected():
         for sel in self.get_selected():
-            l.remove(sel)
+            obj_list.remove(sel)
 
 
-        return l
+        return obj_list
 
 
     def set_active(self, name):
     def set_active(self, name):
         """
         """
@@ -732,8 +731,8 @@ class ObjectCollection(QtCore.QAbstractItemModel):
             self.app.inform.emit('')
             self.app.inform.emit('')
             try:
             try:
                 self.app.ui.selected_scroll_area.takeWidget()
                 self.app.ui.selected_scroll_area.takeWidget()
-            except:
-                FlatCAMApp.App.log.debug("Nothing to remove")
+            except Exception as e:
+                FlatCAMApp.App.log.debug("Nothing to remove. %s" % str(e))
 
 
             self.app.setup_component_editor()
             self.app.setup_component_editor()
             return
             return

+ 1 - 0
README.md

@@ -15,6 +15,7 @@ CAD program, and create G-Code for Isolation routing.
 - solved issue #292 where a new geometry renamed with many underscores failed to store the name in a saved project
 - solved issue #292 where a new geometry renamed with many underscores failed to store the name in a saved project
 - the name for the saved projects are updated to the current time and not to the time of the app startup
 - the name for the saved projects are updated to the current time and not to the time of the app startup
 - some PEP8 changes related to comments starting with only one '#' symbol
 - some PEP8 changes related to comments starting with only one '#' symbol
+- more PEP8 cleanup
 
 
 24.05.2019
 24.05.2019