diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b6fb3c7..da9875a1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ CHANGELOG for FlatCAM beta - in CNCJob UI Autolevelling - added a mini gcode sender for the GRBL to be able to send the probing GCode and get the height map (I may make a small and light app for that so it does not need to have FlatCAM on the GCode sender PC) - in CNCJob UI Autolevelling finished the probing GCode generation for MACH/LinuxCNC controllers; this GCode can also be viewed - in CNCJob UI Autolevelling - Probing GCode has now a header +- in CNCJob UI Autolevelling - Added entries in Preferences 14.08.2020 diff --git a/appGUI/ObjectUI.py b/appGUI/ObjectUI.py index 1d2f3743..95fa6f5b 100644 --- a/appGUI/ObjectUI.py +++ b/appGUI/ObjectUI.py @@ -2028,7 +2028,7 @@ class CNCObjectUI(ObjectUI): grid0.addWidget(self.pdepth_entry, 20, 1) # Probe feedrate - self.feedrate_probe_label = QtWidgets.QLabel('%s:' % _("Feedrate Probe")) + self.feedrate_probe_label = QtWidgets.QLabel('%s:' % _("Probe Feedrate")) self.feedrate_probe_label.setToolTip( _("The feedrate used while the probe is probing.") ) @@ -2045,7 +2045,7 @@ class CNCObjectUI(ObjectUI): grid0.addWidget(separator_line, 23, 0, 1, 2) self.al_controller_label = FCLabel('%s:' % _("Controller")) - self.al_rows_label.setToolTip( + self.al_controller_label.setToolTip( _("The kind of controller for which to generate\n" "height map gcode.") ) @@ -2350,21 +2350,25 @@ class CNCObjectUI(ObjectUI): # self.custom_box.addLayout(h_lay) # Review GCode Button - self.review_gcode_button = QtWidgets.QPushButton(_('Review')) - self.review_gcode_button.setToolTip( - _("Review CNC Code.") - ) - self.custom_box.addWidget(self.review_gcode_button) + g_export_lay = QtWidgets.QHBoxLayout() # Save Button - self.export_gcode_button = QtWidgets.QPushButton(_('Save CNC Code')) + self.export_gcode_button = FCButton(_('Save CNC Code')) self.export_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/save_as.png')) self.export_gcode_button.setToolTip( _("Opens dialog to save G-Code\n" "file.") ) + self.export_gcode_button.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.MinimumExpanding) - self.custom_box.addWidget(self.export_gcode_button) + g_export_lay.addWidget(self.export_gcode_button) + + self.review_gcode_button = QtWidgets.QToolButton() + self.review_gcode_button.setToolTip(_("Review CNC Code.")) + self.review_gcode_button.setIcon(QtGui.QIcon(self.app.resource_location + '/find32.png')) + g_export_lay.addWidget(self.review_gcode_button) + + self.custom_box.addLayout(g_export_lay) self.custom_box.addStretch() self.al_probe_points_table.setRowCount(0) diff --git a/appGUI/preferences/PreferencesUIManager.py b/appGUI/preferences/PreferencesUIManager.py index 1448da23..75264a9e 100644 --- a/appGUI/preferences/PreferencesUIManager.py +++ b/appGUI/preferences/PreferencesUIManager.py @@ -306,8 +306,16 @@ class PreferencesUIManager: "cncjob_annotation": self.ui.cncjob_defaults_form.cncjob_opt_group.annotation_cb, # CNC Job Advanced Options - "cncjob_annotation_fontsize": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.annotation_fontsize_sp, + "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, + # Autolevelling + "cncjob_al_mode": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.al_mode_radio, + "cncjob_al_rows": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.al_rows_entry, + "cncjob_al_columns": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.al_columns_entry, + "cncjob_al_travelz": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.ptravelz_entry, + "cncjob_al_probe_depth": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.pdepth_entry, + "cncjob_al_probe_fr": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.feedrate_probe_entry, + "cncjob_al_controller": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.al_controller_combo, # CNC Job (GCode) Editor "cncjob_prepend": self.ui.cncjob_defaults_form.cncjob_editor_group.prepend_text, diff --git a/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py b/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py index 28462eb0..1be15193 100644 --- a/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py +++ b/appGUI/preferences/cncjob/CNCJobAdvOptPrefGroupUI.py @@ -1,7 +1,7 @@ from PyQt5 import QtWidgets, QtGui from PyQt5.QtCore import QSettings, Qt -from appGUI.GUIElements import FCTextArea, FCCheckBox, FCComboBox, FCSpinner, FCColorEntry +from appGUI.GUIElements import FCComboBox, FCSpinner, FCColorEntry, FCLabel, FCDoubleSpinner, RadioSet from appGUI.preferences.OptionsGroupUI import OptionsGroupUI import gettext import appTranslation as fcTranslate @@ -26,30 +26,29 @@ class CNCJobAdvOptPrefGroupUI(OptionsGroupUI): self.setTitle(str(_("CNC Job Adv. Options"))) + grid0 = QtWidgets.QGridLayout() + grid0.setColumnStretch(0, 0) + grid0.setColumnStretch(1, 1) + self.layout.addLayout(grid0) + # ## Export G-Code - self.export_gcode_label = QtWidgets.QLabel("%s:" % _("Export CNC Code")) + self.export_gcode_label = QtWidgets.QLabel("%s:" % _("Parameters")) self.export_gcode_label.setToolTip( _("Export and save G-Code to\n" "make this object to a file.") ) - self.layout.addWidget(self.export_gcode_label) - - grid0 = QtWidgets.QGridLayout() - self.layout.addLayout(grid0) - - grid0.addWidget(QtWidgets.QLabel(''), 1, 0, 1, 2) + grid0.addWidget(self.export_gcode_label, 0, 0, 1, 2) # Annotation Font Size self.annotation_fontsize_label = QtWidgets.QLabel('%s:' % _("Annotation Size")) self.annotation_fontsize_label.setToolTip( _("The font size of the annotation text. In pixels.") ) - grid0.addWidget(self.annotation_fontsize_label, 2, 0) self.annotation_fontsize_sp = FCSpinner() self.annotation_fontsize_sp.set_range(0, 9999) + grid0.addWidget(self.annotation_fontsize_label, 2, 0) grid0.addWidget(self.annotation_fontsize_sp, 2, 1) - grid0.addWidget(QtWidgets.QLabel(''), 2, 2) # Annotation Font Color self.annotation_color_label = QtWidgets.QLabel('%s:' % _('Annotation Color')) @@ -58,10 +57,103 @@ class CNCJobAdvOptPrefGroupUI(OptionsGroupUI): ) self.annotation_fontcolor_entry = FCColorEntry() - grid0.addWidget(self.annotation_color_label, 3, 0) - grid0.addWidget(self.annotation_fontcolor_entry, 3, 1) + grid0.addWidget(self.annotation_color_label, 4, 0) + grid0.addWidget(self.annotation_fontcolor_entry, 4, 1) + + # ## Autolevelling + self.autolevelling_gcode_label = QtWidgets.QLabel("%s" % _("Autolevelling")) + self.autolevelling_gcode_label.setToolTip( + _("Parameters for the autolevelling.") + ) + grid0.addWidget(self.autolevelling_gcode_label, 6, 0, 1, 2) + + # Probe points mode + al_mode_lbl = FCLabel('%s:' % _("Mode")) + al_mode_lbl.setToolTip(_("Choose a mode for height map generation.\n" + "- Manual: will pick a selection of probe points by clicking on canvas\n" + "- Grid: will automatically generate a grid of probe points")) + + self.al_mode_radio = RadioSet( + [ + {'label': _('Manual'), 'value': 'manual'}, + {'label': _('Grid'), 'value': 'grid'} + ]) + grid0.addWidget(al_mode_lbl, 8, 0) + grid0.addWidget(self.al_mode_radio, 8, 1) + + # ## Columns + self.al_columns_entry = FCSpinner() + + self.al_columns_label = QtWidgets.QLabel('%s:' % _("Columns")) + self.al_columns_label.setToolTip( + _("The number of grid columns.") + ) + grid0.addWidget(self.al_columns_label, 10, 0) + grid0.addWidget(self.al_columns_entry, 10, 1) + + # ## Rows + self.al_rows_entry = FCSpinner() + + self.al_rows_label = QtWidgets.QLabel('%s:' % _("Rows")) + self.al_rows_label.setToolTip( + _("The number of gird rows.") + ) + grid0.addWidget(self.al_rows_label, 12, 0) + grid0.addWidget(self.al_rows_entry, 12, 1) + + # Travel Z Probe + self.ptravelz_label = QtWidgets.QLabel('%s:' % _("Probe Z travel")) + self.ptravelz_label.setToolTip( + _("The safe Z for probe travelling between probe points.") + ) + self.ptravelz_entry = FCDoubleSpinner() + self.ptravelz_entry.set_precision(self.decimals) + self.ptravelz_entry.set_range(0.0000, 9999.9999) + + grid0.addWidget(self.ptravelz_label, 14, 0) + grid0.addWidget(self.ptravelz_entry, 14, 1) + + # Probe depth + self.pdepth_label = QtWidgets.QLabel('%s:' % _("Probe Z depth")) + self.pdepth_label.setToolTip( + _("The maximum depth that the probe is allowed\n" + "to probe. Negative value, in current units.") + ) + self.pdepth_entry = FCDoubleSpinner() + self.pdepth_entry.set_precision(self.decimals) + self.pdepth_entry.set_range(-99999.9999, 0.0000) + + grid0.addWidget(self.pdepth_label, 16, 0) + grid0.addWidget(self.pdepth_entry, 16, 1) + + # Probe feedrate + self.feedrate_probe_label = QtWidgets.QLabel('%s:' % _("Probe Feedrate")) + self.feedrate_probe_label.setToolTip( + _("The feedrate used while the probe is probing.") + ) + self.feedrate_probe_entry = FCDoubleSpinner() + self.feedrate_probe_entry.set_precision(self.decimals) + self.feedrate_probe_entry.set_range(0, 99999.9999) + + grid0.addWidget(self.feedrate_probe_label, 18, 0) + grid0.addWidget(self.feedrate_probe_entry, 18, 1) + + separator_line = QtWidgets.QFrame() + separator_line.setFrameShape(QtWidgets.QFrame.HLine) + separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) + grid0.addWidget(separator_line, 20, 0, 1, 2) + + self.al_controller_label = FCLabel('%s:' % _("Controller")) + self.al_controller_label.setToolTip( + _("The kind of controller for which to generate\n" + "height map gcode.") + ) + + self.al_controller_combo = FCComboBox() + self.al_controller_combo.addItems(["MACH3", "MACH4", "LinuxCNC", "GRBL"]) + grid0.addWidget(self.al_controller_label, 22, 0) + grid0.addWidget(self.al_controller_combo, 22, 1) - grid0.addWidget(QtWidgets.QLabel(''), 3, 2) self.layout.addStretch() self.annotation_fontcolor_entry.editingFinished.connect(self.on_annotation_fontcolor_entry) diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index a3d5de1f..b0e5d469 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -474,12 +474,19 @@ class CNCJobObject(FlatCAMObj, CNCjob): # self.ui.toolchange_cb.toggled.connect(self.on_toolchange_custom_clicked) self.form_fields.update({ - "plot": self.ui.plot_cb, - "tooldia": self.ui.tooldia_entry, - # "append": self.ui.append_text, - # "prepend": self.ui.prepend_text, + "plot": self.ui.plot_cb, + "tooldia": self.ui.tooldia_entry, + # "append": self.ui.append_text, + # "prepend": self.ui.prepend_text, # "toolchange_macro": self.ui.toolchange_text, - # "toolchange_macro_enable": self.ui.toolchange_cb + # "toolchange_macro_enable": self.ui.toolchange_cb, + "al_travelz": self.ui.ptravelz_entry, + "al_probe_depth": self.ui.pdepth_entry, + "al_probe_fr": self.ui.feedrate_probe_entry, + "al_controller": self.ui.al_controller_combo, + "al_mode": self.ui.al_mode_radio, + "al_rows": self.ui.al_rows_entry, + "al_columns": self.ui.al_columns_entry, }) self.append_snippet = self.app.defaults['cncjob_append'] @@ -572,7 +579,7 @@ class CNCJobObject(FlatCAMObj, CNCjob): gc = self.export_gcode(preamble=preamble, postamble=postamble, to_file=True) self.source_file = gc.getvalue() - self.ui.al_mode_radio.set_value('grid') + self.ui.al_mode_radio.set_value(self.options['al_mode']) self.on_controller_change() # def on_cnc_custom_parameters(self, signal_text): diff --git a/defaults.py b/defaults.py index 0d516fa0..297839f8 100644 --- a/defaults.py +++ b/defaults.py @@ -375,6 +375,14 @@ class FlatCAMDefaults: # CNC Job Advanced Options "cncjob_annotation_fontsize": 9, "cncjob_annotation_fontcolor": '#990000', + # Autolevelling + "cncjob_al_mode": 'grid', + "cncjob_al_rows": 4, + "cncjob_al_columns": 4, + "cncjob_al_travelz": 2.0, + "cncjob_al_probe_depth": -1.0, + "cncjob_al_probe_fr": 120, + "cncjob_al_controller": 'MACH3', # CNC Job (GCode) Editor "cncjob_prepend": "",