diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f697a2d..d37a5f72 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta ================================================= +4.08.2020 + +- removed the Toolchange Macro feature (in the future it will be replaced by full preprocessor customization) +- modified GUI in Preferences + 3.08.2020 - GCode Editor - GCode tool selection when clicking on tool in Tools table is working. The only issue is that the first tool gcode includes the start gcode which confuse the algorithm diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index 2eff2b2d..1448da23 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -289,8 +289,6 @@ class PreferencesUIManager: # CNCJob General "cncjob_plot": self.ui.cncjob_defaults_form.cncjob_gen_group.plot_cb, - "cncjob_plot_kind": self.ui.cncjob_defaults_form.cncjob_gen_group.cncplot_method_radio, - "cncjob_annotation": self.ui.cncjob_defaults_form.cncjob_gen_group.annotation_cb, "cncjob_tooldia": self.ui.cncjob_defaults_form.cncjob_gen_group.tooldia_entry, "cncjob_coords_type": self.ui.cncjob_defaults_form.cncjob_gen_group.coords_type_radio, @@ -304,15 +302,17 @@ class PreferencesUIManager: "cncjob_travel_fill": self.ui.cncjob_defaults_form.cncjob_gen_group.tfill_color_entry, # CNC Job Options - "cncjob_prepend": self.ui.cncjob_defaults_form.cncjob_opt_group.prepend_text, - "cncjob_append": self.ui.cncjob_defaults_form.cncjob_opt_group.append_text, + "cncjob_plot_kind": self.ui.cncjob_defaults_form.cncjob_opt_group.cncplot_method_radio, + "cncjob_annotation": self.ui.cncjob_defaults_form.cncjob_opt_group.annotation_cb, # CNC Job Advanced Options - "cncjob_toolchange_macro": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.toolchange_text, - "cncjob_toolchange_macro_enable": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.toolchange_cb, "cncjob_annotation_fontsize": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.annotation_fontsize_sp, "cncjob_annotation_fontcolor": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.annotation_fontcolor_entry, + # CNC Job (GCode) Editor + "cncjob_prepend": self.ui.cncjob_defaults_form.cncjob_editor_group.prepend_text, + "cncjob_append": self.ui.cncjob_defaults_form.cncjob_editor_group.append_text, + # Isolation Routing Tool "tools_iso_tooldia": self.ui.tools_defaults_form.tools_iso_group.tool_dia_entry, "tools_iso_order": self.ui.tools_defaults_form.tools_iso_group.order_radio, diff --git a/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py b/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py index 24daf08f..28462eb0 100644 --- a/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py +++ b/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py @@ -34,108 +34,6 @@ class CNCJobAdvOptPrefGroupUI(OptionsGroupUI): ) self.layout.addWidget(self.export_gcode_label) - # Prepend to G-Code - toolchangelabel = QtWidgets.QLabel('%s' % _('Toolchange G-Code')) - toolchangelabel.setToolTip( - _( - "Type here any G-Code commands you would\n" - "like to be executed when Toolchange event is encountered.\n" - "This will constitute a Custom Toolchange GCode,\n" - "or a Toolchange Macro.\n" - "The FlatCAM variables are surrounded by '%' symbol.\n\n" - "WARNING: it can be used only with a preprocessor file\n" - "that has 'toolchange_custom' in it's name and this is built\n" - "having as template the 'Toolchange Custom' posprocessor file." - ) - ) - self.layout.addWidget(toolchangelabel) - - qsettings = QSettings("Open Source", "FlatCAM") - if qsettings.contains("textbox_font_size"): - tb_fsize = qsettings.value('textbox_font_size', type=int) - else: - tb_fsize = 10 - font = QtGui.QFont() - font.setPointSize(tb_fsize) - - self.toolchange_text = FCTextArea() - self.toolchange_text.setPlaceholderText( - _( - "Type here any G-Code commands you would " - "like to be executed when Toolchange event is encountered.\n" - "This will constitute a Custom Toolchange GCode, " - "or a Toolchange Macro.\n" - "The FlatCAM variables are surrounded by '%' symbol.\n" - "WARNING: it can be used only with a preprocessor file " - "that has 'toolchange_custom' in it's name." - ) - ) - self.layout.addWidget(self.toolchange_text) - self.toolchange_text.setFont(font) - - hlay = QtWidgets.QHBoxLayout() - self.layout.addLayout(hlay) - - # Toolchange Replacement GCode - self.toolchange_cb = FCCheckBox(label='%s' % _('Use Toolchange Macro')) - self.toolchange_cb.setToolTip( - _("Check this box if you want to use\n" - "a Custom Toolchange GCode (macro).") - ) - hlay.addWidget(self.toolchange_cb) - hlay.addStretch() - - hlay1 = QtWidgets.QHBoxLayout() - self.layout.addLayout(hlay1) - - # Variable list - self.tc_variable_combo = FCComboBox() - self.tc_variable_combo.setToolTip( - _("A list of the FlatCAM variables that can be used\n" - "in the Toolchange event.\n" - "They have to be surrounded by the '%' symbol") - ) - hlay1.addWidget(self.tc_variable_combo) - - # Populate the Combo Box - variables = [_('Parameters'), 'tool', 'tooldia', 't_drills', 'x_toolchange', 'y_toolchange', 'z_toolchange', - 'z_cut', 'z_move', 'z_depthpercut', 'spindlespeed', 'dwelltime'] - self.tc_variable_combo.addItems(variables) - self.tc_variable_combo.insertSeparator(1) - - self.tc_variable_combo.setItemData(0, _("FlatCAM CNC parameters"), Qt.ToolTipRole) - fnt = QtGui.QFont() - fnt.setBold(True) - self.tc_variable_combo.setItemData(0, fnt, Qt.FontRole) - - self.tc_variable_combo.setItemData(2, 'tool = %s' % _("tool number"), Qt.ToolTipRole) - self.tc_variable_combo.setItemData(3, 'tooldia = %s' % _("tool diameter"), Qt.ToolTipRole) - self.tc_variable_combo.setItemData(4, 't_drills = %s' % _("for Excellon, total number of drills"), - Qt.ToolTipRole) - self.tc_variable_combo.setItemData(5, 'x_toolchange = %s' % _("X coord for Toolchange"), Qt.ToolTipRole) - self.tc_variable_combo.setItemData(6, 'y_toolchange = %s' % _("Y coord for Toolchange"), - Qt.ToolTipRole) - self.tc_variable_combo.setItemData(7, 'z_toolchange = %s' % _("Z coord for Toolchange"), Qt.ToolTipRole) - self.tc_variable_combo.setItemData(8, 'z_cut = %s' % _("Z depth for the cut"), Qt.ToolTipRole) - self.tc_variable_combo.setItemData(9, 'z_move = %s' % _("Z height for travel"), Qt.ToolTipRole) - self.tc_variable_combo.setItemData(10, 'z_depthpercut = %s' % _("the step value for multidepth cut"), - Qt.ToolTipRole) - self.tc_variable_combo.setItemData(11, 'spindlesspeed = %s' % _("the value for the spindle speed"), - Qt.ToolTipRole) - self.tc_variable_combo.setItemData(12, - _("dwelltime = time to dwell to allow the spindle to reach it's set RPM"), - Qt.ToolTipRole) - - # hlay1.addStretch() - - # Insert Variable into the Toolchange G-Code Text Box - # self.tc_insert_buton = FCButton("Insert") - # self.tc_insert_buton.setToolTip( - # "Insert the variable in the GCode Box\n" - # "surrounded by the '%' symbol." - # ) - # hlay1.addWidget(self.tc_insert_buton) - grid0 = QtWidgets.QGridLayout() self.layout.addLayout(grid0) @@ -166,14 +64,7 @@ class CNCJobAdvOptPrefGroupUI(OptionsGroupUI): grid0.addWidget(QtWidgets.QLabel(''), 3, 2) self.layout.addStretch() - self.tc_variable_combo.currentIndexChanged[str].connect(self.on_cnc_custom_parameters) self.annotation_fontcolor_entry.editingFinished.connect(self.on_annotation_fontcolor_entry) - def on_cnc_custom_parameters(self, signal_text): - if signal_text == 'Parameters': - return - else: - self.toolchange_text.insertPlainText('%%%s%%' % signal_text) - def on_annotation_fontcolor_entry(self): self.app.defaults['cncjob_annotation_fontcolor'] = self.annotation_fontcolor_entry.get_value() diff --git a/appGUI/preferences/cncjob/CNCJobEditorPrefGroupUI.py b/appGUI/preferences/cncjob/CNCJobEditorPrefGroupUI.py new file mode 100644 index 00000000..e329b436 --- /dev/null +++ b/appGUI/preferences/cncjob/CNCJobEditorPrefGroupUI.py @@ -0,0 +1,79 @@ +from PyQt5 import QtWidgets, QtGui +from PyQt5.QtCore import QSettings + +from appGUI.GUIElements import FCTextArea +from appGUI.preferences.OptionsGroupUI import OptionsGroupUI + +import gettext +import appTranslation as fcTranslate +import builtins + +fcTranslate.apply_language('strings') +if '_' not in builtins.__dict__: + _ = gettext.gettext + +settings = QSettings("Open Source", "FlatCAM") +if settings.contains("machinist"): + machinist_setting = settings.value('machinist', type=int) +else: + machinist_setting = 0 + + +class CNCJobEditorPrefGroupUI(OptionsGroupUI): + def __init__(self, decimals=4, parent=None): + # OptionsGroupUI.__init__(self, "CNC Job Options Preferences", parent=None) + super(CNCJobEditorPrefGroupUI, self).__init__(self, parent=parent) + + self.setTitle(str(_("CNC Job Editor"))) + self.decimals = decimals + + # Editor Parameters + self.param_label = QtWidgets.QLabel("%s:" % _("Parameters")) + self.param_label.setToolTip( + _("A list of Editor parameters.") + ) + self.layout.addWidget(self.param_label) + + qsettings = QSettings("Open Source", "FlatCAM") + if qsettings.contains("textbox_font_size"): + tb_fsize = qsettings.value('textbox_font_size', type=int) + else: + tb_fsize = 10 + font = QtGui.QFont() + font.setPointSize(tb_fsize) + + # Prepend to G-Code + prependlabel = QtWidgets.QLabel('%s:' % _('Prepend to G-Code')) + prependlabel.setToolTip( + _("Type here any G-Code commands you would\n" + "like to add at the beginning of the G-Code file.") + ) + self.layout.addWidget(prependlabel) + + self.prepend_text = FCTextArea() + self.prepend_text.setPlaceholderText( + _("Type here any G-Code commands you would " + "like to add at the beginning of the G-Code file.") + ) + self.layout.addWidget(self.prepend_text) + self.prepend_text.setFont(font) + + # Append text to G-Code + appendlabel = QtWidgets.QLabel('%s:' % _('Append to G-Code')) + appendlabel.setToolTip( + _("Type here any G-Code commands you would\n" + "like to append to the generated file.\n" + "I.e.: M2 (End of program)") + ) + self.layout.addWidget(appendlabel) + + self.append_text = FCTextArea() + self.append_text.setPlaceholderText( + _("Type here any G-Code commands you would " + "like to append to the generated file.\n" + "I.e.: M2 (End of program)") + ) + self.layout.addWidget(self.append_text) + self.append_text.setFont(font) + + self.layout.addStretch() diff --git a/appGUI/preferences/cncjob/CNCJobGenPrefGroupUI.py b/appGUI/preferences/cncjob/CNCJobGenPrefGroupUI.py index f27d62c7..84664fa4 100644 --- a/appGUI/preferences/cncjob/CNCJobGenPrefGroupUI.py +++ b/appGUI/preferences/cncjob/CNCJobGenPrefGroupUI.py @@ -41,36 +41,6 @@ class CNCJobGenPrefGroupUI(OptionsGroupUI): self.plot_cb.setToolTip(_("Plot (show) this object.")) grid0.addWidget(self.plot_cb, 0, 0, 1, 2) - # Plot Kind - self.cncplot_method_label = QtWidgets.QLabel('%s:' % _("Plot kind")) - self.cncplot_method_label.setToolTip( - _("This selects the kind of geometries on the canvas to plot.\n" - "Those can be either of type 'Travel' which means the moves\n" - "above the work piece or it can be of type 'Cut',\n" - "which means the moves that cut into the material.") - ) - - self.cncplot_method_radio = RadioSet([ - {"label": _("All"), "value": "all"}, - {"label": _("Travel"), "value": "travel"}, - {"label": _("Cut"), "value": "cut"} - ], orientation='vertical') - - grid0.addWidget(self.cncplot_method_label, 1, 0) - grid0.addWidget(self.cncplot_method_radio, 1, 1) - grid0.addWidget(QtWidgets.QLabel(''), 1, 2) - - # Display Annotation - self.annotation_cb = FCCheckBox(_("Display Annotation")) - self.annotation_cb.setToolTip( - _("This selects if to display text annotation on the plot.\n" - "When checked it will display numbers in order for each end\n" - "of a travel line." - ) - ) - - grid0.addWidget(self.annotation_cb, 2, 0, 1, 3) - # ################################################################### # Number of circle steps for circular aperture linear approximation # # ################################################################### diff --git a/appGUI/preferences/cncjob/CNCJobOptPrefGroupUI.py b/appGUI/preferences/cncjob/CNCJobOptPrefGroupUI.py index 60c16f44..8f74df65 100644 --- a/appGUI/preferences/cncjob/CNCJobOptPrefGroupUI.py +++ b/appGUI/preferences/cncjob/CNCJobOptPrefGroupUI.py @@ -1,7 +1,7 @@ from PyQt5 import QtWidgets, QtGui from PyQt5.QtCore import QSettings -from appGUI.GUIElements import FCTextArea +from appGUI.GUIElements import RadioSet, FCCheckBox from appGUI.preferences.OptionsGroupUI import OptionsGroupUI import gettext @@ -43,38 +43,39 @@ class CNCJobOptPrefGroupUI(OptionsGroupUI): font = QtGui.QFont() font.setPointSize(tb_fsize) - # Prepend to G-Code - prependlabel = QtWidgets.QLabel('%s:' % _('Prepend to G-Code')) - prependlabel.setToolTip( - _("Type here any G-Code commands you would\n" - "like to add at the beginning of the G-Code file.") - ) - self.layout.addWidget(prependlabel) + grid0 = QtWidgets.QGridLayout() + self.layout.addLayout(grid0) + grid0.setColumnStretch(0, 0) + grid0.setColumnStretch(1, 1) - self.prepend_text = FCTextArea() - self.prepend_text.setPlaceholderText( - _("Type here any G-Code commands you would " - "like to add at the beginning of the G-Code file.") + # Plot Kind + self.cncplot_method_label = QtWidgets.QLabel('%s:' % _("Plot kind")) + self.cncplot_method_label.setToolTip( + _("This selects the kind of geometries on the canvas to plot.\n" + "Those can be either of type 'Travel' which means the moves\n" + "above the work piece or it can be of type 'Cut',\n" + "which means the moves that cut into the material.") ) - self.layout.addWidget(self.prepend_text) - self.prepend_text.setFont(font) - # Append text to G-Code - appendlabel = QtWidgets.QLabel('%s:' % _('Append to G-Code')) - appendlabel.setToolTip( - _("Type here any G-Code commands you would\n" - "like to append to the generated file.\n" - "I.e.: M2 (End of program)") - ) - self.layout.addWidget(appendlabel) + self.cncplot_method_radio = RadioSet([ + {"label": _("All"), "value": "all"}, + {"label": _("Travel"), "value": "travel"}, + {"label": _("Cut"), "value": "cut"} + ], orientation='vertical', stretch=False) - self.append_text = FCTextArea() - self.append_text.setPlaceholderText( - _("Type here any G-Code commands you would " - "like to append to the generated file.\n" - "I.e.: M2 (End of program)") + grid0.addWidget(self.cncplot_method_label, 1, 0) + grid0.addWidget(self.cncplot_method_radio, 1, 1) + grid0.addWidget(QtWidgets.QLabel(''), 1, 2) + + # Display Annotation + self.annotation_cb = FCCheckBox(_("Display Annotation")) + self.annotation_cb.setToolTip( + _("This selects if to display text annotation on the plot.\n" + "When checked it will display numbers in order for each end\n" + "of a travel line." + ) ) - self.layout.addWidget(self.append_text) - self.append_text.setFont(font) + + grid0.addWidget(self.annotation_cb, 2, 0, 1, 3) self.layout.addStretch() diff --git a/appGUI/preferences/cncjob/CNCJobPreferencesUI.py b/appGUI/preferences/cncjob/CNCJobPreferencesUI.py index c919a8d8..fc8e3bfc 100644 --- a/appGUI/preferences/cncjob/CNCJobPreferencesUI.py +++ b/appGUI/preferences/cncjob/CNCJobPreferencesUI.py @@ -3,6 +3,7 @@ from PyQt5 import QtWidgets from appGUI.preferences.cncjob.CNCJobAdvOptPrefGroupUI import CNCJobAdvOptPrefGroupUI from appGUI.preferences.cncjob.CNCJobOptPrefGroupUI import CNCJobOptPrefGroupUI from appGUI.preferences.cncjob.CNCJobGenPrefGroupUI import CNCJobGenPrefGroupUI +from appGUI.preferences.cncjob.CNCJobEditorPrefGroupUI import CNCJobEditorPrefGroupUI class CNCJobPreferencesUI(QtWidgets.QWidget): @@ -15,13 +16,21 @@ class CNCJobPreferencesUI(QtWidgets.QWidget): self.cncjob_gen_group = CNCJobGenPrefGroupUI(decimals=self.decimals) self.cncjob_gen_group.setMinimumWidth(260) + self.cncjob_opt_group = CNCJobOptPrefGroupUI(decimals=self.decimals) self.cncjob_opt_group.setMinimumWidth(260) self.cncjob_adv_opt_group = CNCJobAdvOptPrefGroupUI(decimals=self.decimals) self.cncjob_adv_opt_group.setMinimumWidth(260) + self.cncjob_editor_group = CNCJobEditorPrefGroupUI(decimals=self.decimals) + self.cncjob_editor_group.setMinimumWidth(260) + + vlay = QtWidgets.QVBoxLayout() + vlay.addWidget(self.cncjob_opt_group) + vlay.addWidget(self.cncjob_adv_opt_group) + self.layout.addWidget(self.cncjob_gen_group) - self.layout.addWidget(self.cncjob_opt_group) - self.layout.addWidget(self.cncjob_adv_opt_group) + self.layout.addLayout(vlay) + self.layout.addWidget(self.cncjob_editor_group) self.layout.addStretch() diff --git a/appGUI/preferences/excellon/ExcellonPreferencesUI.py b/appGUI/preferences/excellon/ExcellonPreferencesUI.py index 39bf5006..ee237b09 100644 --- a/appGUI/preferences/excellon/ExcellonPreferencesUI.py +++ b/appGUI/preferences/excellon/ExcellonPreferencesUI.py @@ -43,11 +43,11 @@ class ExcellonPreferencesUI(QtWidgets.QWidget): self.vlay = QtWidgets.QVBoxLayout() self.vlay.addWidget(self.excellon_opt_group) + self.vlay.addWidget(self.excellon_adv_opt_group) self.vlay.addWidget(self.excellon_exp_group) self.layout.addWidget(self.excellon_gen_group) self.layout.addLayout(self.vlay) - self.layout.addWidget(self.excellon_adv_opt_group) self.layout.addWidget(self.excellon_editor_group) self.layout.addStretch() diff --git a/appGUI/preferences/geometry/GeometryEditorPrefGroupUI.py b/appGUI/preferences/geometry/GeometryEditorPrefGroupUI.py index aca5a4ef..a083bb1f 100644 --- a/appGUI/preferences/geometry/GeometryEditorPrefGroupUI.py +++ b/appGUI/preferences/geometry/GeometryEditorPrefGroupUI.py @@ -27,10 +27,10 @@ class GeometryEditorPrefGroupUI(OptionsGroupUI): self.setTitle(str(_("Geometry Editor"))) self.decimals = decimals - # Advanced Geometry Parameters + # Editor Parameters self.param_label = QtWidgets.QLabel("%s:" % _("Parameters")) self.param_label.setToolTip( - _("A list of Geometry Editor parameters.") + _("A list of Editor parameters.") ) self.layout.addWidget(self.param_label) diff --git a/appGUI/preferences/gerber/GerberPreferencesUI.py b/appGUI/preferences/gerber/GerberPreferencesUI.py index 6b6ad56f..d495ead3 100644 --- a/appGUI/preferences/gerber/GerberPreferencesUI.py +++ b/appGUI/preferences/gerber/GerberPreferencesUI.py @@ -43,12 +43,12 @@ class GerberPreferencesUI(QtWidgets.QWidget): self.vlay = QtWidgets.QVBoxLayout() self.vlay.addWidget(self.gerber_opt_group) + self.vlay.addWidget(self.gerber_adv_opt_group) self.vlay.addWidget(self.gerber_exp_group) self.vlay.addStretch() self.layout.addWidget(self.gerber_gen_group) self.layout.addLayout(self.vlay) - self.layout.addWidget(self.gerber_adv_opt_group) self.layout.addWidget(self.gerber_editor_group) self.layout.addStretch() diff --git a/defaults.py b/defaults.py index a731e191..0d516fa0 100644 --- a/defaults.py +++ b/defaults.py @@ -346,8 +346,6 @@ class FlatCAMDefaults: # CNC Job General "cncjob_plot": True, - "cncjob_plot_kind": 'all', - "cncjob_annotation": True, "cncjob_tooldia": 1.0, "cncjob_coords_type": "G90", "cncjob_coords_decimals": 4, @@ -371,15 +369,17 @@ class FlatCAMDefaults: "cncjob_travel_fill": '#F0E24D4C', # CNC Job Options - "cncjob_prepend": "", - "cncjob_append": "", + "cncjob_plot_kind": 'all', + "cncjob_annotation": True, # CNC Job Advanced Options - "cncjob_toolchange_macro": "", - "cncjob_toolchange_macro_enable": False, "cncjob_annotation_fontsize": 9, "cncjob_annotation_fontcolor": '#990000', + # CNC Job (GCode) Editor + "cncjob_prepend": "", + "cncjob_append": "", + # Isolation Routing Tool "tools_iso_tooldia": "0.1", "tools_iso_order": 'rev',