diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bd6c6e0..f34d487b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta ================================================= +12.09.2021 + +- some UI changes in the Milling and Drilling Plugins +- working on the Excellon side from Milling Plugin + 10.09.2021 - minor changes in Film Plugin diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index 4387c34f..fb2ea956 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -369,7 +369,7 @@ class PreferencesUIManager: "tools_al_grbl_travelz": self.ui.plugin_eng_pref_form.tools_level_group.jog_travelz_entry, # Drilling Tool - "tools_drill_tool_order": self.ui.plugin_pref_form.tools_drill_group.order_radio, + "tools_drill_tool_order": self.ui.plugin_pref_form.tools_drill_group.order_combo, "tools_drill_cutz": self.ui.plugin_pref_form.tools_drill_group.cutz_entry, "tools_drill_multidepth": self.ui.plugin_pref_form.tools_drill_group.mpass_cb, "tools_drill_depthperpass": self.ui.plugin_pref_form.tools_drill_group.maxdepth_entry, diff --git a/appGUI/preferences/tools/ToolsDrillPrefGroupUI.py b/appGUI/preferences/tools/ToolsDrillPrefGroupUI.py index 3c2daec2..95be8f65 100644 --- a/appGUI/preferences/tools/ToolsDrillPrefGroupUI.py +++ b/appGUI/preferences/tools/ToolsDrillPrefGroupUI.py @@ -2,7 +2,7 @@ from PyQt6 import QtWidgets, QtCore from PyQt6.QtCore import Qt from appGUI.GUIElements import RadioSet, FCDoubleSpinner, FCComboBox, FCCheckBox, FCSpinner, NumericalEvalTupleEntry, \ - OptionalInputSection, NumericalEvalEntry, FCLabel, FCGridLayout + OptionalInputSection, NumericalEvalEntry, FCLabel, FCGridLayout, FCComboBox2 from appGUI.preferences.OptionsGroupUI import OptionsGroupUI import gettext @@ -35,18 +35,17 @@ class ToolsDrillPrefGroupUI(OptionsGroupUI): # Tool order Radio Button self.order_label = FCLabel('%s:' % _('Tool order')) self.order_label.setToolTip(_("This set the way that the tools in the tools table are used.\n" - "'No' --> means that the used order is the one in the tool table\n" - "'Forward' --> means that the tools will be ordered from small to big\n" - "'Reverse' --> means that the tools will ordered from big to small\n\n" + "'Default' --> the order from the Excellon file\n" + "'Forward' --> tools will be ordered from small to big\n" + "'Reverse' --> tools will ordered from big to small\n\n" "WARNING: using rest machining will automatically set the order\n" "in reverse and disable this control.")) - self.order_radio = RadioSet([{'label': _('No'), 'value': 'no'}, - {'label': _('Forward'), 'value': 'fwd'}, - {'label': _('Reverse'), 'value': 'rev'}]) + self.order_combo = FCComboBox2() + self.order_combo.addItems([_('Default'), _('Forward'), _('Reverse')]) grid0.addWidget(self.order_label, 1, 0) - grid0.addWidget(self.order_radio, 1, 1, 1, 2) + grid0.addWidget(self.order_combo, 1, 1, 1, 2) # Cut Z cutzlabel = FCLabel('%s:' % _('Cut Z')) diff --git a/appPlugins/ToolDrilling.py b/appPlugins/ToolDrilling.py index 59242d55..292f307a 100644 --- a/appPlugins/ToolDrilling.py +++ b/appPlugins/ToolDrilling.py @@ -442,7 +442,7 @@ class ToolDrilling(AppTool, Excellon): for it in range(self.ui.pp_excellon_name_cb.count()): self.ui.pp_excellon_name_cb.setItemData(it, self.ui.pp_excellon_name_cb.itemText(it), QtCore.Qt.ItemDataRole.ToolTipRole) - self.ui.order_radio.set_value(self.app.defaults["tools_drill_tool_order"]) + self.ui.order_combo.set_value(self.app.defaults["tools_drill_tool_order"]) if loaded_obj: outname = loaded_obj.options['name'] @@ -673,10 +673,10 @@ class ToolDrilling(AppTool, Excellon): for k, v in self.excellon_tools.items(): sorted_tools.append(self.dec_format(float(v['tooldia']))) - order = self.ui.order_radio.get_value() - if order == 'fwd': + order = self.ui.order_combo.get_value() + if order == 1: # 'fwd' sorted_tools.sort(reverse=False) - elif order == 'rev': + elif order == 2: # 'rev' sorted_tools.sort(reverse=True) else: pass @@ -1024,7 +1024,7 @@ class ToolDrilling(AppTool, Excellon): elif isinstance(current_widget2, NumericalEvalTupleEntry): current_widget2.editingFinished.connect(self.form_to_storage) - self.ui.order_radio.activated_custom[str].connect(self.on_order_changed) + self.ui.order_combo.currentIndexChanged.connect(self.on_order_changed) # Exclusion Table widgets connect for row in range(self.ui.exclusion_table.rowCount()): @@ -1116,7 +1116,7 @@ class ToolDrilling(AppTool, Excellon): except (TypeError, ValueError): pass try: - self.ui.order_radio.activated_custom[str].disconnect() + self.ui.order_combo.currentIndexChanged.disconnect() except (TypeError, ValueError): pass @@ -1457,7 +1457,7 @@ class ToolDrilling(AppTool, Excellon): self.blockSignals(False) def on_order_changed(self, order): - if order != 'no': + if order != 0: # 'default' self.build_tool_ui() def on_tooltable_cellwidget_change(self): @@ -1940,7 +1940,7 @@ class ToolDrilling(AppTool, Excellon): for tool_as_key, v in list(self.excellon_tools.items()): all_tools.append((int(tool_as_key), float(v['tooldia']))) - order = self.ui.order_radio.get_value() + order = self.ui.order_combo.get_value() if order == 'fwd': sorted_tools = sorted(all_tools, key=lambda t1: t1[1]) elif order == 'rev': @@ -2360,18 +2360,17 @@ class DrillingUI: # Tool order self.order_label = FCLabel('%s:' % _('Tool order')) self.order_label.setToolTip(_("This set the way that the tools in the tools table are used.\n" - "'No' --> means that the used order is the one in the tool table\n" - "'Forward' --> means that the tools will be ordered from small to big\n" - "'Reverse' --> means that the tools will ordered from big to small\n\n" + "'Default' --> the order from the Excellon file\n" + "'Forward' --> tools will be ordered from small to big\n" + "'Reverse' --> tools will ordered from big to small\n\n" "WARNING: using rest machining will automatically set the order\n" "in reverse and disable this control.")) - self.order_radio = RadioSet([{'label': _('No'), 'value': 'no'}, - {'label': _('Forward'), 'value': 'fwd'}, - {'label': _('Reverse'), 'value': 'rev'}]) + self.order_combo = FCComboBox2() + self.order_combo.addItems([_('Default'), _('Forward'), _('Reverse')]) grid1.addWidget(self.order_label, 2, 0) - grid1.addWidget(self.order_radio, 2, 1) + grid1.addWidget(self.order_combo, 2, 1) # Manual Load of Tools from DB self.search_load_db_btn = FCButton(_("Search DB")) @@ -2879,7 +2878,7 @@ class DrillingUI: # separator_line.setFrameShadow(QtWidgets.QFrame.Shadow.Sunken) # grid3.addWidget(separator_line, 25, 0, 1, 2) - FCGridLayout.set_common_column_size([grid0, grid1, grid2, grid3, grid_a1], 0) + FCGridLayout.set_common_column_size([grid0, grid1, grid2, grid3], 0) self.generate_cnc_button = QtWidgets.QPushButton(_('Generate CNCJob object')) self.generate_cnc_button.setIcon(QtGui.QIcon(self.app.resource_location + '/cnc16.png')) diff --git a/appPlugins/ToolMilling.py b/appPlugins/ToolMilling.py index 95b2d7d4..54d7ffbb 100644 --- a/appPlugins/ToolMilling.py +++ b/appPlugins/ToolMilling.py @@ -571,7 +571,7 @@ class ToolMilling(AppTool, Excellon): self.ui.tools_frame.show() - self.ui.order_radio.set_value(self.app.defaults["tools_drill_tool_order"]) + self.ui.order_combo.set_value(self.app.defaults["tools_drill_tool_order"]) self.ui.milling_type_radio.set_value(self.app.defaults["tools_mill_milling_type"]) # init the working variables @@ -1061,6 +1061,29 @@ class ToolMilling(AppTool, Excellon): if self.target_obj: self.ui.param_frame.setDisabled(False) + # order the tools by tool diameter if it's the case + sorted_tools = [] + for k, v in self.obj_tools.items(): + sorted_tools.append(self.app.dec_format(float(v['tooldia']))) + + order = self.ui.order_combo.get_value() + if order == 1: # 'fwd' + sorted_tools.sort(reverse=False) + elif order == 2: # 'rev' + sorted_tools.sort(reverse=True) + else: + pass + + # remake the excellon_tools dict in the order above + new_id = 1 + new_tools = {} + for tooldia in sorted_tools: + for old_tool in self.obj_tools: + if self.app.dec_format(float(self.obj_tools[old_tool]['tooldia'])) == tooldia: + new_tools[new_id] = deepcopy(self.obj_tools[old_tool]) + new_id += 1 + + self.obj_tools = new_tools tools = [k for k in self.obj_tools] else: @@ -1212,7 +1235,7 @@ class ToolMilling(AppTool, Excellon): if val == 'exc': self.ui.tools_table.show() self.ui.order_label.show() - self.ui.order_radio.show() + self.ui.order_combo.show() self.ui.geo_tools_table.hide() @@ -1238,7 +1261,7 @@ class ToolMilling(AppTool, Excellon): else: self.ui.tools_table.hide() self.ui.order_label.hide() - self.ui.order_radio.hide() + self.ui.order_combo.hide() self.ui.geo_tools_table.show() @@ -1425,7 +1448,7 @@ class ToolMilling(AppTool, Excellon): elif isinstance(current_widget, FCComboBox2): current_widget.currentIndexChanged.connect(self.form_to_storage) - self.ui.order_radio.activated_custom[str].connect(self.on_order_changed) + self.ui.order_combo.currentIndexChanged.connect(self.on_order_changed) # Exclusion Table widgets connect for row in range(self.ui.exclusion_table.rowCount()): @@ -1534,7 +1557,7 @@ class ToolMilling(AppTool, Excellon): pass try: - self.ui.order_radio.activated_custom[str].disconnect() + self.ui.order_combo.currentIndexChanged.disconnect() except (TypeError, ValueError): pass @@ -1936,7 +1959,7 @@ class ToolMilling(AppTool, Excellon): self.ui_connect() def on_order_changed(self, order): - if order != 'no': + if order != 0: # "default" self.build_ui() def on_tool_add(self, clicked_state, dia=None, new_geo=None): @@ -3719,18 +3742,17 @@ class MillingUI: # Tool order self.order_label = FCLabel('%s:' % _('Tool order')) self.order_label.setToolTip(_("This set the way that the tools in the tools table are used.\n" - "'No' --> means that the used order is the one in the tool table\n" - "'Forward' --> means that the tools will be ordered from small to big\n" - "'Reverse' --> means that the tools will ordered from big to small\n\n" + "'Default' --> the order from the Excellon file\n" + "'Forward' --> tools will be ordered from small to big\n" + "'Reverse' --> tools will ordered from big to small\n\n" "WARNING: using rest machining will automatically set the order\n" "in reverse and disable this control.")) - self.order_radio = RadioSet([{'label': _('No'), 'value': 'no'}, - {'label': _('Forward'), 'value': 'fwd'}, - {'label': _('Reverse'), 'value': 'rev'}]) + self.order_combo = FCComboBox2() + self.order_combo.addItems([_('Default'), _('Forward'), _('Reverse')]) grid1.addWidget(self.order_label, 2, 0) - grid1.addWidget(self.order_radio, 2, 1) + grid1.addWidget(self.order_combo, 2, 1) # ************************************************************************ # ************** Geometry Tool Table ************************************* @@ -3772,7 +3794,7 @@ class MillingUI: self.tools_table.hide() self.geo_tools_table.hide() self.order_label.hide() - self.order_radio.hide() + self.order_combo.hide() # ############################################################################################################# # ADD TOOLS FOR GEOMETRY OBJECT @@ -3900,7 +3922,7 @@ class MillingUI: self.milling_type_radio.setObjectName("milling_type") grid2.addWidget(self.mill_type_label, 0, 0) - grid2.addWidget(self.milling_type_radio, 0, 1) + grid2.addWidget(self.milling_type_radio, 1, 0, 1, 2) # Milling Diameter self.mill_dia_label = FCLabel('%s:' % _('Milling Diameter')) @@ -4594,7 +4616,7 @@ class MillingUI: # ------------------------------------------------------------------------------------------------------------ FCGridLayout.set_common_column_size( - [grid0, grid_title_tool_table, grid1, grid_add_tool, button_grid, grid2, grid3, grid_a1], 0) + [grid0, grid_title_tool_table, grid1, grid_add_tool, button_grid, grid2, grid3], 0) # ############################################################################################################# # Generate CNC Job object