Bladeren bron

- when creating a new FlatCAM object, the options will be updated with FlatCAM tools properties that relate to them
- updated the Tools DB class by separating the Tools DB UI into it's own class
- Tools DB - added the parameters for Drilling Tool

Marius Stanciu 5 jaren geleden
bovenliggende
commit
0d886955f8
8 gewijzigde bestanden met toevoegingen van 578 en 228 verwijderingen
  1. 6 0
      CHANGELOG.md
  2. 514 201
      appDatabase.py
  3. 45 14
      appObjects/AppObject.py
  4. 3 3
      appObjects/FlatCAMGeometry.py
  5. 3 3
      appTools/ToolIsolation.py
  6. 3 3
      appTools/ToolNCC.py
  7. 3 3
      appTools/ToolPaint.py
  8. 1 1
      app_Main.py

+ 6 - 0
CHANGELOG.md

@@ -7,6 +7,12 @@ CHANGELOG for FlatCAM beta
 
 =================================================
 
+12.07.2020
+
+- when creating a new FlatCAM object, the options will be updated with FlatCAM tools properties that relate to them
+- updated the Tools DB class by separating the Tools DB UI into it's own class
+- Tools DB - added the parameters for Drilling Tool
+
 11.07.2020
 
 - moved all Excellon Advanced Prefeences to Drilling Tool Preferences

File diff suppressed because it is too large
+ 514 - 201
appDatabase.py


+ 45 - 14
appObjects/AppObject.py

@@ -67,18 +67,19 @@ class AppObject(QtCore.QObject):
               when appending it to the collection. There is no need to handle
               name conflicts here.
 
-        :param kind: The kind of object to create. One of 'gerber', 'excellon', 'cncjob' and 'geometry'.
-        :type kind: str
-        :param name: Name for the object.
-        :type name: str
-        :param initialize: Function to run after creation of the object but before it is attached to the application.
-        The function is called with 2 parameters: the new object and the App instance.
-        :type initialize: function
-        :param plot: If to plot the resulting object
-        :param autoselected: if the resulting object is autoselected in the Project tab and therefore in the
-        self.collection
-        :return: None
-        :rtype: None
+        :param kind:            The kind of object to create. One of 'gerber', 'excellon', 'cncjob' and 'geometry'.
+        :type kind:             str
+        :param name:            Name for the object.
+        :type name:             str
+        :param initialize:      Function to run after creation of the object but before it is attached to the
+                                application.
+                                The function is called with 2 parameters: the new object and the App instance.
+        :type initialize:       function
+        :param plot:            If to plot the resulting object
+        :param autoselected:    if the resulting object is autoselected in the Project tab and therefore in the
+                                self.collection
+        :return:                Either the object or the string 'fail'
+        :rtype:                 object
         """
 
         log.debug("AppObject.new_object()")
@@ -102,7 +103,12 @@ class AppObject(QtCore.QObject):
         # Object creation/instantiation
         obj = classdict[kind](name)
 
+        # ############################################################################################################
+        # adding object PROPERTIES
+        # ############################################################################################################
         obj.units = self.app.options["units"]
+        obj.isHovering = False
+        obj.notHovering = True
 
         # IMPORTANT
         # The key names in defaults and options dictionary's are not random:
@@ -113,13 +119,29 @@ class AppObject(QtCore.QObject):
         # let's say "excellon_toolchange", it will strip the excellon_) and to the obj.options the key will become
         # "toolchange"
 
+        # ############################################################################################################
+        # this section copies the application defaults related to the object to the object OPTIONS
+        # ############################################################################################################
         for option in self.app.options:
             if option.find(kind + "_") == 0:
                 oname = option[len(kind) + 1:]
                 obj.options[oname] = self.app.options[option]
 
-        obj.isHovering = False
-        obj.notHovering = True
+        # add some of the FlatCAM Tools related properties
+        if kind == 'excellon':
+            for option in self.app.options:
+                if option.find('tools_drill_') == 0 or option.find('tools_mill_') == 0:
+                    obj.options[option] = self.app.options[option]
+        if kind == 'gerber':
+            for option in self.app.options:
+                if option.find('tools_iso_') == 0:
+                    obj.options[option] = self.app.options[option]
+        if kind == 'geometry':
+            for option in self.app.options:
+                if option.find('tools_mill_') == 0:
+                    obj.options[option] = self.app.options[option]
+        # ############################################################################################################
+        # ############################################################################################################
 
         # Initialize as per user request
         # User must take care to implement initialize
@@ -127,6 +149,7 @@ class AppObject(QtCore.QObject):
         # have been invoked in a separate thread.
         t1 = time.time()
         log.debug("%f seconds before initialize()." % (t1 - t0))
+
         try:
             return_value = initialize(obj, self.app)
         except Exception as e:
@@ -145,16 +168,20 @@ class AppObject(QtCore.QObject):
             log.debug("Object (%s) parsing and/or geometry creation failed." % kind)
             return "fail"
 
+        # ############################################################################################################
         # Check units and convert if necessary
         # This condition CAN be true because initialize() can change obj.units
+        # ############################################################################################################
         if self.app.options["units"].upper() != obj.units.upper():
             self.app.inform.emit('%s: %s' % (_("Converting units to "), self.app.options["units"]))
             obj.convert_units(self.app.options["units"])
             t3 = time.time()
             log.debug("%f seconds converting units." % (t3 - t2))
 
+        # ############################################################################################################
         # Create the bounding box for the object and then add the results to the obj.options
         # But not for Scripts or for Documents
+        # ############################################################################################################
         if kind != 'document' and kind != 'script':
             try:
                 xmin, ymin, xmax, ymax = obj.bounds()
@@ -177,12 +204,16 @@ class AppObject(QtCore.QObject):
             except Exception as e:
                 log.warning("AppObject.new_object() -> setting colors error. %s" % str(e))
 
+        # ############################################################################################################
         # update the KeyWords list with the name of the file
+        # ############################################################################################################
         self.app.myKeywords.append(obj.options['name'])
 
         log.debug("Moving new object back to main thread.")
 
+        # ############################################################################################################
         # Move the object to the main thread and let the app know that it is available.
+        # ############################################################################################################
         obj.moveToThread(self.app.main_thread)
         self.object_created.emit(obj, obj_plot, obj_autoselected)
 

+ 3 - 3
appObjects/FlatCAMGeometry.py

@@ -1032,9 +1032,9 @@ class GeometryObject(FlatCAMObj, Geometry):
                 break
         self.app.on_tools_database()
         self.app.tools_db_tab.ok_to_add = True
-        self.app.tools_db_tab.buttons_frame.hide()
-        self.app.tools_db_tab.add_tool_from_db.show()
-        self.app.tools_db_tab.cancel_tool_from_db.show()
+        self.app.tools_db_tab.ui.buttons_frame.hide()
+        self.app.tools_db_tab.ui.add_tool_from_db.show()
+        self.app.tools_db_tab.ui.cancel_tool_from_db.show()
 
     def on_tool_from_db_inserted(self, tool):
         """

+ 3 - 3
appTools/ToolIsolation.py

@@ -2440,9 +2440,9 @@ class ToolIsolation(AppTool, Gerber):
                 break
         self.app.on_tools_database(source='iso')
         self.app.tools_db_tab.ok_to_add = True
-        self.app.tools_db_tab.buttons_frame.hide()
-        self.app.tools_db_tab.add_tool_from_db.show()
-        self.app.tools_db_tab.cancel_tool_from_db.show()
+        self.app.tools_db_tab.ui.buttons_frame.hide()
+        self.app.tools_db_tab.ui.add_tool_from_db.show()
+        self.app.tools_db_tab.ui.cancel_tool_from_db.show()
 
     def reset_fields(self):
         self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))

+ 3 - 3
appTools/ToolNCC.py

@@ -3577,9 +3577,9 @@ class NonCopperClear(AppTool, Gerber):
                 break
         self.app.on_tools_database(source='ncc')
         self.app.tools_db_tab.ok_to_add = True
-        self.app.tools_db_tab.buttons_frame.hide()
-        self.app.tools_db_tab.add_tool_from_db.show()
-        self.app.tools_db_tab.cancel_tool_from_db.show()
+        self.app.tools_db_tab.ui.buttons_frame.hide()
+        self.app.tools_db_tab.ui.add_tool_from_db.show()
+        self.app.tools_db_tab.ui.cancel_tool_from_db.show()
 
     def reset_fields(self):
         self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))

+ 3 - 3
appTools/ToolPaint.py

@@ -2706,9 +2706,9 @@ class ToolPaint(AppTool, Gerber):
                 break
         self.app.on_tools_database(source='paint')
         self.app.tools_db_tab.ok_to_add = True
-        self.app.tools_db_tab.buttons_frame.hide()
-        self.app.tools_db_tab.add_tool_from_db.show()
-        self.app.tools_db_tab.cancel_tool_from_db.show()
+        self.app.tools_db_tab.ui.buttons_frame.hide()
+        self.app.tools_db_tab.ui.add_tool_from_db.show()
+        self.app.tools_db_tab.ui.cancel_tool_from_db.show()
 
     def reset_fields(self):
         self.ui.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))

+ 1 - 1
app_Main.py

@@ -5643,7 +5643,7 @@ class App(QtCore.QObject):
         for idx in range(self.ui.plot_tab_area.count()):
             if self.ui.plot_tab_area.tabText(idx) == _("Tools Database"):
                 self.ui.plot_tab_area.tabBar.setTabTextColor(idx, QtGui.QColor('red'))
-                self.tools_db_tab.save_db_btn.setStyleSheet("QPushButton {color: red;}")
+                self.tools_db_tab.ui.save_db_btn.setStyleSheet("QPushButton {color: red;}")
 
         self.tools_db_changed_flag = True
 

Some files were not shown because too many files changed in this diff