diff --git a/CHANGELOG.md b/CHANGELOG.md index 90839fd2..1128c258 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta ================================================= +1.12.2020 + +- in Milling Tool fixed the UI change as a result of preprocessor change +- in Isolation Tool added possibility to have tools with the same diameter; remade the sorting of the tools storage + 29.11.2020 - in Geometry Editor - improvements and some issues are solved diff --git a/appTools/ToolIsolation.py b/appTools/ToolIsolation.py index ee0a8165..e6319485 100644 --- a/appTools/ToolIsolation.py +++ b/appTools/ToolIsolation.py @@ -456,52 +456,41 @@ class ToolIsolation(AppTool, Gerber): self.ui_disconnect() # updated units - self.units = self.app.defaults['units'].upper() + units = self.app.defaults['units'].upper() + self.units = units - sorted_tools = [] - for k, v in self.iso_tools.items(): - sorted_tools.append(self.app.dec_format(float(v['tooldia']), self.decimals)) + self.sort_iso_tools() - order = self.ui.order_radio.get_value() - if order == 'fwd': - sorted_tools.sort(reverse=False) - elif order == 'rev': - sorted_tools.sort(reverse=True) - else: - pass - - n = len(sorted_tools) + n = len(self.iso_tools) self.ui.tools_table.setRowCount(n) tool_id = 0 - for tool_sorted in sorted_tools: - for tooluid_key, tooluid_value in self.iso_tools.items(): - truncated_dia = self.app.dec_format(tooluid_value['tooldia'], self.decimals) - if truncated_dia == tool_sorted: - tool_id += 1 + for tooluid_key, tooluid_value in self.iso_tools.items(): + tool_id += 1 - # Tool name/id - id_ = QtWidgets.QTableWidgetItem('%d' % int(tool_id)) - id_.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) - row_no = tool_id - 1 - self.ui.tools_table.setItem(row_no, 0, id_) + # Tool name/id + id_ = QtWidgets.QTableWidgetItem('%d' % int(tool_id)) + id_.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) + row_no = tool_id - 1 + self.ui.tools_table.setItem(row_no, 0, id_) - # Diameter - dia = QtWidgets.QTableWidgetItem(str(truncated_dia)) - dia.setFlags(QtCore.Qt.ItemIsEnabled) - self.ui.tools_table.setItem(row_no, 1, dia) + # Diameter + truncated_dia = self.app.dec_format(tooluid_value['tooldia'], self.decimals) + dia = QtWidgets.QTableWidgetItem(str(truncated_dia)) + dia.setFlags(QtCore.Qt.ItemIsEnabled) + self.ui.tools_table.setItem(row_no, 1, dia) - # Tool Type - tool_type_item = FCComboBox() - tool_type_item.addItems(self.tool_type_item_options) - idx = tool_type_item.findText(tooluid_value['tool_type']) - tool_type_item.setCurrentIndex(idx) - self.ui.tools_table.setCellWidget(row_no, 2, tool_type_item) + # Tool Type + tool_type_item = FCComboBox() + tool_type_item.addItems(self.tool_type_item_options) + idx = tool_type_item.findText(tooluid_value['tool_type']) + tool_type_item.setCurrentIndex(idx) + self.ui.tools_table.setCellWidget(row_no, 2, tool_type_item) - # Tool unique ID - # REMEMBER: THIS COLUMN IS HIDDEN - tool_uid_item = QtWidgets.QTableWidgetItem(str(int(tooluid_key))) - self.ui.tools_table.setItem(row_no, 3, tool_uid_item) + # Tool unique ID + # REMEMBER: THIS COLUMN IS HIDDEN + tool_uid_item = QtWidgets.QTableWidgetItem(str(int(tooluid_key))) + self.ui.tools_table.setItem(row_no, 3, tool_uid_item) # make the diameter column editable for row in range(tool_id): @@ -631,6 +620,27 @@ class ToolIsolation(AppTool, Gerber): except (TypeError, ValueError): pass + def sort_iso_tools(self): + order = self.ui.order_radio.get_value() + if order == 'no': + return + + # sort the tools dictionary having the 'tooldia' as sorting key + new_tools_list = [] + if order == 'fwd': + new_tools_list = deepcopy(sorted(self.iso_tools.items(), key=lambda x: x[1]['tooldia'], reverse=False)) + elif order == 'rev': + new_tools_list = deepcopy(sorted(self.iso_tools.items(), key=lambda x: x[1]['tooldia'], reverse=True)) + + # clear the tools dictionary + self.iso_tools.clear() + + # recreate the tools dictionary in a ordered fashion + new_toolid = 0 + for tool in new_tools_list: + new_toolid += 1 + self.iso_tools[new_toolid] = tool[1] + def on_toggle_all_rows(self): """ will toggle the selection of all rows in Tools table @@ -883,8 +893,7 @@ class ToolIsolation(AppTool, Gerber): self.ui.rest_cb.setDisabled(False) def on_order_changed(self, order): - if order != 'no': - self.build_ui() + self.build_ui() def on_rest_machining_check(self, state): if state: @@ -1173,10 +1182,10 @@ class ToolIsolation(AppTool, Gerber): truncated_tooldia = self.app.dec_format(tool_dia, self.decimals) # if new tool diameter already in the Tool List then abort - if truncated_tooldia in tool_dias: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) - self.blockSignals(False) - return + # if truncated_tooldia in tool_dias: + # self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + # self.blockSignals(False) + # return # load the database tools from the file try: @@ -1260,10 +1269,10 @@ class ToolIsolation(AppTool, Gerber): return # if new tool diameter found in Tools Database already in the Tool List then abort - if updated_tooldia is not None and updated_tooldia in tool_dias: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) - self.blockSignals(False) - return + # if updated_tooldia is not None and updated_tooldia in tool_dias: + # self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + # self.blockSignals(False) + # return new_tdia = deepcopy(updated_tooldia) if updated_tooldia is not None else deepcopy(truncated_tooldia) self.iso_tools.update({ @@ -1317,13 +1326,14 @@ class ToolIsolation(AppTool, Gerber): tool_dias.append(self.app.dec_format(v[tool_v], self.decimals)) truncated_tooldia = self.app.dec_format(tool_dia, self.decimals) - if truncated_tooldia in tool_dias: - if muted is None: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) - # self.ui.tools_table.itemChanged.connect(self.on_tool_edit) - self.blockSignals(False) - return + # if truncated_tooldia in tool_dias: + # if muted is None: + # self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + # # self.ui.tools_table.itemChanged.connect(self.on_tool_edit) + # self.blockSignals(False) + # return + # print("before", self.iso_tools) self.iso_tools.update({ int(self.tooluid): { 'tooldia': truncated_tooldia, @@ -1335,6 +1345,7 @@ class ToolIsolation(AppTool, Gerber): 'solid_geometry': [] } }) + # print("after", self.iso_tools) self.blockSignals(False) self.build_ui() @@ -2741,10 +2752,10 @@ class ToolIsolation(AppTool, Gerber): tool_dias.append(self.app.dec_format(v[tool_v], self.decimals)) truncated_tooldia = self.app.dec_format(tooldia, self.decimals) - if truncated_tooldia in tool_dias: - self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) - self.ui_connect() - return 'fail' + # if truncated_tooldia in tool_dias: + # self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Tool already in Tool Table.")) + # self.ui_connect() + # return 'fail' self.iso_tools.update({ tooluid: { diff --git a/appTools/ToolMilling.py b/appTools/ToolMilling.py index 8e0ab971..78568a26 100644 --- a/appTools/ToolMilling.py +++ b/appTools/ToolMilling.py @@ -103,7 +103,7 @@ class ToolMilling(AppTool, Excellon): self.grid_status_memory = self.app.ui.grid_snap_btn.isChecked() # store here the state of the exclusion checkbox state to be restored after building the UI - # TODO add this in the sel.app.defaults dict and in Preferences + # TODO add this in the self.app.defaults dict and in Preferences self.exclusion_area_cb_is_checked = False # store here solid_geometry when there are tool with isolation job @@ -211,6 +211,7 @@ class ToolMilling(AppTool, Excellon): # ############################################################################# self.builduiSig.connect(self.build_ui) + # add Tool self.ui.search_and_add_btn.clicked.connect(self.on_tool_add) self.ui.deltool_btn.clicked.connect(self.on_tool_delete) self.ui.addtool_from_db_btn.clicked.connect(self.on_tool_add_from_db_clicked) @@ -218,6 +219,7 @@ class ToolMilling(AppTool, Excellon): self.ui.target_radio.activated_custom.connect(self.on_target_changed) self.ui.operation_type_combo.currentIndexChanged.connect(self.on_operation_changed) self.ui.offset_type_combo.currentIndexChanged.connect(self.on_offset_type_changed) + self.ui.pp_geo_name_cb.activated.connect(self.on_pp_changed) # V tool shape params changed self.ui.tipdia_entry.valueChanged.connect(self.on_update_cutz) @@ -2194,23 +2196,19 @@ class ToolMilling(AppTool, Excellon): if 'laser' in current_pp.lower(): self.ui.cutzlabel.hide() self.ui.cutz_entry.hide() + + self.ui.endz_label.hide() + self.ui.endz_entry.hide() + + self.ui.travelzlabel.hide() + self.ui.travelz_entry.hide() + try: self.ui.mpass_cb.hide() self.ui.maxdepth_entry.hide() except AttributeError: pass - if 'marlin' in current_pp.lower(): - self.ui.travelzlabel.setText('%s:' % _("Focus Z")) - self.ui.endz_label.show() - self.ui.endz_entry.show() - else: - self.ui.travelzlabel.hide() - self.ui.travelz_entry.hide() - - self.ui.endz_label.hide() - self.ui.endz_entry.hide() - try: self.ui.frzlabel.hide() self.ui.feedrate_z_entry.hide() @@ -2231,7 +2229,6 @@ class ToolMilling(AppTool, Excellon): pass self.ui.travelzlabel.setText('%s:' % _('Travel Z')) - self.ui.travelzlabel.show() self.ui.travelz_entry.show() @@ -2248,6 +2245,14 @@ class ToolMilling(AppTool, Excellon): self.ui.spindle_label.setText('%s:' % _('Spindle speed')) + if ('marlin' in current_pp.lower() and 'laser' in current_pp.lower()) or 'z_laser' in current_pp.lower(): + self.ui.travelzlabel.setText('%s:' % _("Focus Z")) + self.ui.travelzlabel.show() + self.ui.travelz_entry.show() + + self.ui.endz_label.show() + self.ui.endz_entry.show() + def on_cnc_button_click(self): self.obj_name = self.ui.object_combo.currentText()