瀏覽代碼

- added a GUI element in the Preferences to control the possibility to edit with mouse cursor objects in the Project Tab. It is named: "Allow Edit"

Marius Stanciu 5 年之前
父節點
當前提交
ea1b47bf89

+ 5 - 0
CHANGELOG.md

@@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta
 
 =================================================
 
+6.06.2020
+
+- NCC Tool - added a message to warn the user that he needs at least one tool with clearing operation
+- added a GUI element in the Preferences to control the possibility to edit with mouse cursor objects in the Project Tab. It is named: "Allow Edit"
+
 5.06.2020
 
 - fixed a small issue in the Panelization Tool that blocked the usage of a Geometry object as panelization reference

+ 2 - 1
appGUI/preferences/PreferencesUIManager.py

@@ -91,7 +91,7 @@ class PreferencesUIManager:
             "global_proj_item_dis_color": self.ui.general_defaults_form.general_gui_group.proj_color_dis_entry,
             "global_project_autohide": self.ui.general_defaults_form.general_gui_group.project_autohide_cb,
 
-            # General GUI Settings
+            # General APP Settings
             "global_gridx": self.ui.general_defaults_form.general_app_set_group.gridx_entry,
             "global_gridy": self.ui.general_defaults_form.general_app_set_group.gridy_entry,
             "global_snap_max": self.ui.general_defaults_form.general_app_set_group.snap_max_dist_entry,
@@ -107,6 +107,7 @@ class PreferencesUIManager:
             "global_pan_button": self.ui.general_defaults_form.general_app_set_group.pan_button_radio,
             "global_mselect_key": self.ui.general_defaults_form.general_app_set_group.mselect_radio,
             "global_delete_confirmation": self.ui.general_defaults_form.general_app_set_group.delete_conf_cb,
+            "global_allow_edit_in_project_tab": self.ui.general_defaults_form.general_app_set_group.allow_edit_cb,
             "global_open_style": self.ui.general_defaults_form.general_app_set_group.open_style_cb,
             "global_toggle_tooltips": self.ui.general_defaults_form.general_app_set_group.toggle_tooltips_cb,
             "global_machinist_setting": self.ui.general_defaults_form.general_app_set_group.machinist_cb,

+ 15 - 7
appGUI/preferences/general/GeneralAPPSetGroupUI.py

@@ -384,6 +384,14 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
         )
         grid0.addWidget(self.delete_conf_cb, 30, 0, 1, 2)
 
+        self.allow_edit_cb = FCCheckBox(_("Allow Edit"))
+        self.allow_edit_cb.setToolTip(
+            _("When cheched, the user can edit the objects in the Project Tab\n"
+              "by using the left mouse button click on the object name.\n"
+              "Active after restart.")
+        )
+        grid0.addWidget(self.allow_edit_cb, 31, 0, 1, 2)
+
         # Open behavior
         self.open_style_cb = FCCheckBox('%s' % _('"Open" behavior'))
         self.open_style_cb.setToolTip(
@@ -393,7 +401,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
               "path for saving files or the path for opening files.")
         )
 
-        grid0.addWidget(self.open_style_cb, 31, 0, 1, 2)
+        grid0.addWidget(self.open_style_cb, 32, 0, 1, 2)
 
         # Enable/Disable ToolTips globally
         self.toggle_tooltips_cb = FCCheckBox(label=_('Enable ToolTips'))
@@ -402,7 +410,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
               "when hovering with mouse over items throughout the App.")
         )
 
-        grid0.addWidget(self.toggle_tooltips_cb, 32, 0, 1, 2)
+        grid0.addWidget(self.toggle_tooltips_cb, 33, 0, 1, 2)
 
         # Machinist settings that allow unsafe settings
         self.machinist_cb = FCCheckBox(_("Allow Machinist Unsafe Settings"))
@@ -414,7 +422,7 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
               "<<WARNING>>: Don't change this unless you know what you are doing !!!")
         )
 
-        grid0.addWidget(self.machinist_cb, 33, 0, 1, 2)
+        grid0.addWidget(self.machinist_cb, 34, 0, 1, 2)
 
         # Bookmarks Limit in the Help Menu
         self.bm_limit_spinner = FCSpinner()
@@ -426,8 +434,8 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
               "but the menu will hold only so much.")
         )
 
-        grid0.addWidget(self.bm_limit_label, 34, 0)
-        grid0.addWidget(self.bm_limit_spinner, 34, 1)
+        grid0.addWidget(self.bm_limit_label, 35, 0)
+        grid0.addWidget(self.bm_limit_spinner, 35, 1)
 
         # Activity monitor icon
         self.activity_label = QtWidgets.QLabel('%s:' % _("Activity Icon"))
@@ -437,8 +445,8 @@ class GeneralAPPSetGroupUI(OptionsGroupUI):
         self.activity_combo = FCComboBox()
         self.activity_combo.addItems(['Ball black', 'Ball green', 'Arrow green', 'Eclipse green'])
 
-        grid0.addWidget(self.activity_label, 35, 0)
-        grid0.addWidget(self.activity_combo, 35, 1)
+        grid0.addWidget(self.activity_label, 36, 0)
+        grid0.addWidget(self.activity_combo, 36, 1)
 
         self.layout.addStretch()
 

+ 7 - 2
appObjects/ObjectCollection.py

@@ -50,11 +50,10 @@ class KeySensitiveListView(QtWidgets.QTreeView):
     def __init__(self, app, parent=None):
         super(KeySensitiveListView, self).__init__(parent)
         self.setHeaderHidden(True)
-        # self.setEditTriggers(QtWidgets.QTreeView.SelectedClicked)     # allow Edit on Tree
-        self.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers)
 
         # self.setRootIsDecorated(False)
         # self.setExpandsOnDoubleClick(False)
+        self.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers)    # No edit in the Project Tab Tree
 
         # Enable dragging and dropping onto the appGUI
         self.setAcceptDrops(True)
@@ -309,6 +308,12 @@ class ObjectCollection(QtCore.QAbstractItemModel):
 
         self.view.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
         self.view.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
+
+        if self.app.defaults["global_allow_edit_in_project_tab"] is True:
+            self.view.setEditTriggers(QtWidgets.QTreeView.SelectedClicked)  # allow Edit on Tree
+        else:
+            self.view.setEditTriggers(QtWidgets.QTreeView.NoEditTriggers)
+
         # self.view.setDragDropMode(QtWidgets.QAbstractItemView.InternalMove)
         # self.view.setDragEnabled(True)
         # self.view.setAcceptDrops(True)

+ 16 - 23
appTools/ToolNCC.py

@@ -766,6 +766,7 @@ class NonCopperClear(AppTool, Gerber):
         try:
             current_uid = int(self.tools_table.item(current_row, 3).text())
             self.ncc_tools[current_uid]['data']['tools_nccoperation'] = val
+            # TODO got a crash here, a KeyError exception; need to see it again and find out the why
         except AttributeError:
             return
 
@@ -1639,6 +1640,7 @@ class NonCopperClear(AppTool, Gerber):
                                                                     "use a number."))
                         continue
 
+                # find out which tools is for isolation and which are for copper clearing
                 for uid_k, uid_v in self.ncc_tools.items():
                     if round(uid_v['tooldia'], self.decimals) == round(self.tooldia, self.decimals):
                         if uid_v['data']['tools_nccoperation'] == "iso":
@@ -2300,23 +2302,30 @@ class NonCopperClear(AppTool, Gerber):
             self.app.inform.emit('[ERROR_NOTCL] %s' % _('Geometry could not be cleared completely'))
             return None
 
-    def clear_copper(self, ncc_obj, sel_obj=None, ncctooldia=None, isotooldia=None, outname=None, order=None,
+    def clear_copper(self, ncc_obj, ncctooldia, isotooldia, sel_obj=None, outname=None, order=None,
                      tools_storage=None, run_threaded=True):
         """
         Clear the excess copper from the entire object.
 
         :param ncc_obj:         ncc cleared object
+        :type ncc_obj:          appObjects.FlatCAMGerber.GerberObject
+        :param ncctooldia:      a list of diameters of the tools to be used to ncc clear
+        :type ncctooldia:       list
+        :param isotooldia:      a list of diameters of the tools to be used for isolation
+        :type isotooldia:       list
         :param sel_obj:
-        :param ncctooldia:      a tuple or single element made out of diameters of the tools to be used to ncc clear
-        :param isotooldia:      a tuple or single element made out of diameters of the tools to be used for isolation
+        :type sel_obj:
         :param outname:         name of the resulting object
+        :type outname:          str
         :param order:           Tools order
         :param tools_storage:   whether to use the current tools_storage self.ncc_tools or a different one.
                                 Usage of the different one is related to when this function is called
                                 from a TcL command.
+        :type tools_storage:    dict
 
         :param run_threaded:    If True the method will be run in a threaded way suitable for GUI usage; if False
                                 it will run non-threaded for TclShell usage
+        :type run_threaded:     bool
         :return:
         """
         log.debug("Executing the handler ...")
@@ -2338,29 +2347,13 @@ class NonCopperClear(AppTool, Gerber):
 
         # determine if to use the progressive plotting
         prog_plot = True if self.app.defaults["tools_ncc_plotting"] == 'progressive' else False
-        tools_storage = tools_storage if tools_storage is not None else self.ncc_tools
 
-        # ######################################################################################################
-        # # Read the tooldia parameter and create a sorted list out them - they may be more than one diameter ##
-        # ######################################################################################################
-        sorted_clear_tools = []
-        if ncctooldia is not None:
-            try:
-                sorted_clear_tools = [float(eval(dia)) for dia in ncctooldia.split(",") if dia != '']
-            except AttributeError:
-                if not isinstance(ncctooldia, list):
-                    sorted_clear_tools = [float(ncctooldia)]
-                else:
-                    sorted_clear_tools = ncctooldia
-        else:
-            # for row in range(self.tools_table.rowCount()):
-            #     if self.tools_table.cellWidget(row, 1).currentText() == 'clear_op':
-            #         sorted_clear_tools.append(float(self.tools_table.item(row, 1).text()))
-            for tooluid in self.ncc_tools:
-                if self.ncc_tools[tooluid]['data']['tools_nccoperation'] == 'clear':
-                    sorted_clear_tools.append(self.ncc_tools[tooluid]['tooldia'])
+        tools_storage = tools_storage if tools_storage is not None else self.ncc_tools
+        sorted_clear_tools = ncctooldia
 
         if not sorted_clear_tools:
+            self.app.inform.emit('[ERROR_NOTCL] %s' % _("There is no copper clearing tool in the selection "
+                                                        "and at least one is needed."))
             return 'fail'
 
         # ########################################################################################################

+ 3 - 3
app_Main.py

@@ -162,9 +162,9 @@ class App(QtCore.QObject):
     # ###############################################################################################################
     # ################################### Version and VERSION DATE ##################################################
     # ###############################################################################################################
-    # version = "Unstable Version"
-    version = 8.993
-    version_date = "2020/06/05"
+    version = "Unstable Version"
+    # version = 8.994
+    version_date = "2020/07/05"
     beta = True
 
     engine = '3D'

+ 72 - 63
defaults.py

@@ -22,70 +22,15 @@ log = logging.getLogger('FlatCAMDefaults')
 class FlatCAMDefaults:
 
     factory_defaults = {
-        # Global APP Preferences
-        "decimals_inch": 4,
-        "decimals_metric": 4,
-        "version": 8.992,   # defaults format version, not necessarily equal to app version
+        # Global
+        "version": 8.992,  # defaults format version, not necessarily equal to app version
         "first_run": True,
-        "units": "MM",
         "root_folder_path": '',
         "global_serial": 0,
         "global_stats": dict(),
         "global_tabs_detachable": True,
         "global_jump_ref": 'abs',
         "global_locate_pt": 'bl',
-        "global_tpdf_tmargin": 15.0,
-        "global_tpdf_bmargin": 10.0,
-        "global_tpdf_lmargin": 20.0,
-        "global_tpdf_rmargin": 20.0,
-        "global_autosave": False,
-        "global_autosave_timeout": 300000,
-
-        # General
-        "global_graphic_engine": '3D',
-        "global_hud": True,
-        "global_app_level": 'b',
-        "global_portable": False,
-        "global_language": 'English',
-        "global_version_check": True,
-        "global_send_stats": True,
-        "global_pan_button": '2',
-        "global_mselect_key": 'Control',
-        "global_project_at_startup": False,
-        "global_systray_icon": True,
-        "global_project_autohide": True,
-        "global_toggle_tooltips": True,
-        "global_worker_number": 2,
-        "global_tolerance": 0.005,
-        "global_open_style": True,
-        "global_delete_confirmation": True,
-        "global_compression_level": 3,
-        "global_save_compressed": True,
-
-        "global_machinist_setting": False,
-
-        # Global GUI Preferences
-        "global_gridx": 1.0,
-        "global_gridy": 1.0,
-        "global_snap_max": 0.05,
-        "global_workspace": False,
-        "global_workspaceT": "A4",
-        "global_workspace_orientation": 'p',
-
-        "global_grid_context_menu": {
-            'in': [0.01, 0.02, 0.025, 0.05, 0.1],
-            'mm': [0.1, 0.2, 0.5, 1, 2.54]
-        },
-
-        "global_sel_fill": '#a5a5ffbf',
-        "global_sel_line": '#0000ffbf',
-        "global_alt_sel_fill": '#BBF268BF',
-        "global_alt_sel_line": '#006E20BF',
-        "global_draw_color": '#FF0000',
-        "global_sel_draw_color": '#0000FF',
-        "global_proj_item_color": '#000000',
-        "global_proj_item_dis_color": '#b7b7cb',
-        "global_activity_icon": 'Ball green',
 
         "global_toolbar_view": 511,
 
@@ -95,6 +40,12 @@ class FlatCAMDefaults:
         # 1 = show trace(show trace always),
         # 2 = (For the future).
 
+        "global_grid_context_menu": {
+            'in': [0.01, 0.02, 0.025, 0.05, 0.1],
+            'mm': [0.1, 0.2, 0.5, 1, 2.54]
+        },
+        "global_hud": True,
+
         # Persistence
         "global_last_folder": None,
         "global_last_save_folder": None,
@@ -109,12 +60,8 @@ class FlatCAMDefaults:
         # Constants...
         "global_defaults_save_period_ms": 20000,  # Time between default saves.
         "global_shell_shape": [500, 300],  # Shape of the shell in pixels.
-        "global_shell_at_startup": False,  # Show the shell at startup.
         "global_recent_limit": 10,  # Max. items in recent list.
 
-        "global_bookmarks": dict(),
-        "global_bookmarks_limit": 10,
-
         "fit_key": 'V',
         "zoom_out_key": '-',
         "zoom_in_key": '=',
@@ -125,18 +72,80 @@ class FlatCAMDefaults:
 
         "global_tcl_path": '',
 
-        # General GUI Settings
+        # General APP Preferences
+        "units": "MM",
+        "decimals_inch": 4,
+        "decimals_metric": 4,
+        "global_graphic_engine": '3D',
+        "global_app_level": 'b',
+
+        "global_portable": False,
+        "global_language": 'English',
+
+
+        "global_systray_icon": True,
+        "global_shell_at_startup": False,  # Show the shell at startup.
+        "global_project_at_startup": False,
+        "global_version_check": True,
+        "global_send_stats": True,
+        "global_worker_number": 2,
+        "global_tolerance": 0.005,
+
+        "global_save_compressed": True,
+        "global_compression_level": 3,
+        "global_autosave": False,
+        "global_autosave_timeout": 300000,
+
+        "global_tpdf_tmargin": 15.0,
+        "global_tpdf_bmargin": 10.0,
+        "global_tpdf_lmargin": 20.0,
+        "global_tpdf_rmargin": 20.0,
+
+        # General GUI Preferences
         "global_theme": 'white',
         "global_gray_icons": False,
+
+        "global_layout": "compact",
         "global_hover": False,
         "global_selection_shape": True,
-        "global_layout": "compact",
+
+        "global_sel_fill": '#a5a5ffbf',
+        "global_sel_line": '#0000ffbf',
+        "global_alt_sel_fill": '#BBF268BF',
+        "global_alt_sel_line": '#006E20BF',
+        "global_draw_color": '#FF0000',
+        "global_sel_draw_color": '#0000FF',
+        "global_proj_item_color": '#000000',
+        "global_proj_item_dis_color": '#b7b7cb',
+        "global_project_autohide": True,
+
+        # General App Settings
+        "global_gridx": 1.0,
+        "global_gridy": 1.0,
+        "global_snap_max": 0.05,
+
+        "global_workspace": False,
+        "global_workspaceT": "A4",
+        "global_workspace_orientation": 'p',
+
         "global_cursor_type": "small",
         "global_cursor_size": 20,
         "global_cursor_width": 2,
         "global_cursor_color": '#FF0000',
         "global_cursor_color_enabled": True,
 
+        "global_pan_button": '2',
+        "global_mselect_key": 'Control',
+
+        "global_delete_confirmation": True,
+        "global_allow_edit_in_project_tab": False,
+        "global_open_style": True,
+        "global_toggle_tooltips": True,
+        "global_machinist_setting": False,
+        "global_bookmarks": dict(),
+        "global_bookmarks_limit": 10,
+        "global_activity_icon": 'Ball green',
+
         # Gerber General
         "gerber_plot": True,
         "gerber_solid": True,