diff --git a/FlatCAMApp.py b/FlatCAMApp.py index fb00dfbd..131a26e0 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -457,8 +457,6 @@ class App(QtCore.QObject): 'mm': [0.1, 0.2, 0.5, 1, 2.54] }, - "global_plot_fill": '#BBF268BF', - "global_plot_line": '#006E20BF', "global_sel_fill": '#a5a5ffbf', "global_sel_line": '#0000ffbf', "global_alt_sel_fill": '#BBF268BF', @@ -525,6 +523,9 @@ class App(QtCore.QObject): "gerber_clean_apertures": True, "gerber_extra_buffering": True, + "gerber_plot_fill": '#BBF268BF', + "gerber_plot_line": '#006E20BF', + "gerber_def_units": 'IN', "gerber_def_zeros": 'L', "gerber_save_filters": "Gerber File (*.gbr);;Gerber File (*.bot);;Gerber File (*.bsm);;" @@ -1118,8 +1119,6 @@ class App(QtCore.QObject): "global_workspaceT": self.ui.general_defaults_form.general_gui_group.wk_cb, "global_workspace_orientation": self.ui.general_defaults_form.general_gui_group.wk_orientation_radio, - "global_plot_fill": self.ui.general_defaults_form.general_gui_group.pf_color_entry, - "global_plot_line": self.ui.general_defaults_form.general_gui_group.pl_color_entry, "global_sel_fill": self.ui.general_defaults_form.general_gui_group.sf_color_entry, "global_sel_line": self.ui.general_defaults_form.general_gui_group.sl_color_entry, "global_alt_sel_fill": self.ui.general_defaults_form.general_gui_group.alt_sf_color_entry, @@ -1160,6 +1159,8 @@ class App(QtCore.QObject): "gerber_def_zeros": self.ui.gerber_defaults_form.gerber_gen_group.gerber_zeros_radio, "gerber_clean_apertures": self.ui.gerber_defaults_form.gerber_gen_group.gerber_clean_cb, "gerber_extra_buffering": self.ui.gerber_defaults_form.gerber_gen_group.gerber_extra_buffering, + "gerber_plot_fill": self.ui.gerber_defaults_form.gerber_gen_group.pf_color_entry, + "gerber_plot_line": self.ui.gerber_defaults_form.gerber_gen_group.pl_color_entry, # Gerber Options "gerber_isotooldia": self.ui.gerber_defaults_form.gerber_opt_group.iso_tool_dia_entry, @@ -2009,19 +2010,6 @@ class App(QtCore.QObject): # ############################# GUI COLORS SIGNALS ############################ # ############################################################################# - # Setting plot colors signals - self.ui.general_defaults_form.general_gui_group.pf_color_entry.editingFinished.connect( - self.on_pf_color_entry) - self.ui.general_defaults_form.general_gui_group.pf_color_button.clicked.connect( - self.on_pf_color_button) - self.ui.general_defaults_form.general_gui_group.pf_color_alpha_spinner.valueChanged.connect( - self.on_pf_color_spinner) - self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.valueChanged.connect( - self.on_pf_color_slider) - self.ui.general_defaults_form.general_gui_group.pl_color_entry.editingFinished.connect( - self.on_pl_color_entry) - self.ui.general_defaults_form.general_gui_group.pl_color_button.clicked.connect( - self.on_pl_color_button) # Setting selection (left - right) colors signals self.ui.general_defaults_form.general_gui_group.sf_color_entry.editingFinished.connect( self.on_sf_color_entry) @@ -2035,6 +2023,7 @@ class App(QtCore.QObject): self.on_sl_color_entry) self.ui.general_defaults_form.general_gui_group.sl_color_button.clicked.connect( self.on_sl_color_button) + # Setting selection (right - left) colors signals self.ui.general_defaults_form.general_gui_group.alt_sf_color_entry.editingFinished.connect( self.on_alt_sf_color_entry) @@ -2048,6 +2037,7 @@ class App(QtCore.QObject): self.on_alt_sl_color_entry) self.ui.general_defaults_form.general_gui_group.alt_sl_color_button.clicked.connect( self.on_alt_sl_color_button) + # Setting Editor Draw colors signals self.ui.general_defaults_form.general_gui_group.draw_color_entry.editingFinished.connect( self.on_draw_color_entry) @@ -6271,19 +6261,19 @@ class App(QtCore.QObject): def init_color_pickers_in_preferences_gui(self): # Init Plot Colors - self.ui.general_defaults_form.general_gui_group.pf_color_entry.set_value(self.defaults['global_plot_fill']) - self.ui.general_defaults_form.general_gui_group.pf_color_button.setStyleSheet( + self.ui.gerber_defaults_form.gerber_gen_group.pf_color_entry.set_value(self.defaults['gerber_plot_fill']) + self.ui.gerber_defaults_form.gerber_gen_group.pf_color_button.setStyleSheet( "background-color:%s;" - "border-color: dimgray" % str(self.defaults['global_plot_fill'])[:7]) - self.ui.general_defaults_form.general_gui_group.pf_color_alpha_spinner.set_value( - int(self.defaults['global_plot_fill'][7:9], 16)) - self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.setValue( - int(self.defaults['global_plot_fill'][7:9], 16)) + "border-color: dimgray" % str(self.defaults['gerber_plot_fill'])[:7]) + self.ui.gerber_defaults_form.gerber_gen_group.pf_color_alpha_spinner.set_value( + int(self.defaults['gerber_plot_fill'][7:9], 16)) + self.ui.gerber_defaults_form.gerber_gen_group.pf_color_alpha_slider.setValue( + int(self.defaults['gerber_plot_fill'][7:9], 16)) - self.ui.general_defaults_form.general_gui_group.pl_color_entry.set_value(self.defaults['global_plot_line']) - self.ui.general_defaults_form.general_gui_group.pl_color_button.setStyleSheet( + self.ui.gerber_defaults_form.gerber_gen_group.pl_color_entry.set_value(self.defaults['gerber_plot_line']) + self.ui.gerber_defaults_form.gerber_gen_group.pl_color_button.setStyleSheet( "background-color:%s;" - "border-color: dimgray" % str(self.defaults['global_plot_line'])[:7]) + "border-color: dimgray" % str(self.defaults['gerber_plot_line'])[:7]) # Init Left-Right Selection colors self.ui.general_defaults_form.general_gui_group.sf_color_entry.set_value(self.defaults['global_sel_fill']) @@ -6516,68 +6506,6 @@ class App(QtCore.QObject): ) self.on_excellon_format_changed() - # Setting plot colors handlers - def on_pf_color_entry(self): - self.defaults['global_plot_fill'] = \ - self.ui.general_defaults_form.general_gui_group.pf_color_entry.get_value()[:7] + \ - self.defaults['global_plot_fill'][7:9] - self.ui.general_defaults_form.general_gui_group.pf_color_button.setStyleSheet( - "background-color:%s" % str(self.defaults['global_plot_fill'])[:7]) - - def on_pf_color_button(self): - current_color = QtGui.QColor(self.defaults['global_plot_fill'][:7]) - - c_dialog = QtWidgets.QColorDialog() - plot_fill_color = c_dialog.getColor(initial=current_color) - - if plot_fill_color.isValid() is False: - return - - self.ui.general_defaults_form.general_gui_group.pf_color_button.setStyleSheet( - "background-color:%s" % str(plot_fill_color.name())) - - new_val = str(plot_fill_color.name()) + str(self.defaults['global_plot_fill'][7:9]) - self.ui.general_defaults_form.general_gui_group.pf_color_entry.set_value(new_val) - self.defaults['global_plot_fill'] = new_val - - def on_pf_color_spinner(self): - spinner_value = self.ui.general_defaults_form.general_gui_group.pf_color_alpha_spinner.value() - self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.setValue(spinner_value) - self.defaults['global_plot_fill'] = \ - self.defaults['global_plot_fill'][:7] + \ - (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') - self.defaults['global_plot_line'] = \ - self.defaults['global_plot_line'][:7] + \ - (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') - - def on_pf_color_slider(self): - slider_value = self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value() - self.ui.general_defaults_form.general_gui_group.pf_color_alpha_spinner.setValue(slider_value) - - def on_pl_color_entry(self): - self.defaults['global_plot_line'] = \ - self.ui.general_defaults_form.general_gui_group.pl_color_entry.get_value()[:7] + \ - self.defaults['global_plot_line'][7:9] - self.ui.general_defaults_form.general_gui_group.pl_color_button.setStyleSheet( - "background-color:%s" % str(self.defaults['global_plot_line'])[:7]) - - def on_pl_color_button(self): - current_color = QtGui.QColor(self.defaults['global_plot_line'][:7]) - # print(current_color) - - c_dialog = QtWidgets.QColorDialog() - plot_line_color = c_dialog.getColor(initial=current_color) - - if plot_line_color.isValid() is False: - return - - self.ui.general_defaults_form.general_gui_group.pl_color_button.setStyleSheet( - "background-color:%s" % str(plot_line_color.name())) - - new_val_line = str(plot_line_color.name()) + str(self.defaults['global_plot_line'][7:9]) - self.ui.general_defaults_form.general_gui_group.pl_color_entry.set_value(new_val_line) - self.defaults['global_plot_line'] = new_val_line - # Setting selection colors (left - right) handlers def on_sf_color_entry(self): self.defaults['global_sel_fill'] = \ @@ -10534,7 +10462,7 @@ class App(QtCore.QObject): mirror=None) if obj.kind.lower() == 'gerber': - # color = self.defaults["global_plot_fill"][:-2] + # color = self.defaults["gerber_plot_fill"][:-2] color = obj.fill_color[:-2] elif obj.kind.lower() == 'excellon': color = '#C40000' @@ -12447,7 +12375,7 @@ class App(QtCore.QObject): self.clear_pool() def on_set_color_action_triggered(self): - new_color = self.defaults['global_plot_fill'] + new_color = self.defaults['gerber_plot_fill'] act_name = self.sender().text().lower() sel_obj_list = self.collection.get_selected() @@ -12475,7 +12403,7 @@ class App(QtCore.QObject): str(hex(self.ui.general_defaults_form.general_gui_group.pf_color_alpha_slider.value())[2:]) if act_name == 'custom': - new_color = QtGui.QColor(self.defaults['global_plot_fill'][:7]) + new_color = QtGui.QColor(self.defaults['gerber_plot_fill'][:7]) c_dialog = QtWidgets.QColorDialog() plot_fill_color = c_dialog.getColor(initial=new_color) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 3f76f37d..9021140c 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -659,8 +659,8 @@ class FlatCAMGerber(FlatCAMObj, Gerber): self.units_found = self.app.defaults['units'] - self.fill_color = self.app.defaults['global_plot_fill'] - self.outline_color = self.app.defaults['global_plot_line'] + self.fill_color = self.app.defaults['gerber_plot_fill'] + self.outline_color = self.app.defaults['gerber_plot_line'] # Attributes to be included in serialization # Always append to it because it carries contents @@ -1790,7 +1790,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber): if 'color' in kwargs: color = kwargs['color'] else: - color = self.app.defaults['global_plot_fill'] + color = self.app.defaults['gerber_plot_fill'] if 'marked_aperture' not in kwargs: return diff --git a/README.md b/README.md index 817f4f1c..975bd17c 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ CAD program, and create G-Code for Isolation routing. - added a clean_up() method in all the Editor Tools that need it, to be run when aborting using the ESC key - fixed an error in the Gerber parser; it did not took into consideration the aperture size declared before the beginning of a Gerber region. Detected for Gerber files generated by KiCAD 5.x - in Panelize Tool made sure that for Gerber objects if one of the apertures is without geometry then it is ignored +- further modifications in Preferences -> General GUI 25.12.2019 diff --git a/flatcamGUI/PreferencesUI.py b/flatcamGUI/PreferencesUI.py index ee8ae5b4..dae8e722 100644 --- a/flatcamGUI/PreferencesUI.py +++ b/flatcamGUI/PreferencesUI.py @@ -472,71 +472,6 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI): grid0.addWidget(self.wk_orientation_label, 8, 0) grid0.addWidget(self.wk_orientation_radio, 8, 1) - separator_line = QtWidgets.QFrame() - separator_line.setFrameShape(QtWidgets.QFrame.HLine) - separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) - grid0.addWidget(separator_line, 9, 0, 1, 2) - - self.gerber_color_label = QtWidgets.QLabel('%s' % _('Gerber Object Color')) - grid0.addWidget(self.gerber_color_label, 10, 0, 1, 2) - - # Plot Line Color - self.pl_color_label = QtWidgets.QLabel('%s:' % _('Outline')) - self.pl_color_label.setToolTip( - _("Set the line color for plotted objects.") - ) - self.pl_color_entry = FCEntry() - self.pl_color_button = QtWidgets.QPushButton() - self.pl_color_button.setFixedSize(15, 15) - - self.form_box_child_2 = QtWidgets.QHBoxLayout() - self.form_box_child_2.addWidget(self.pl_color_entry) - self.form_box_child_2.addWidget(self.pl_color_button) - self.form_box_child_2.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) - - grid0.addWidget(self.pl_color_label, 11, 0) - grid0.addLayout(self.form_box_child_2, 11, 1) - - # Plot Fill Color - self.pf_color_label = QtWidgets.QLabel('%s:' % _('Fill')) - self.pf_color_label.setToolTip( - _("Set the fill color for plotted objects.\n" - "First 6 digits are the color and the last 2\n" - "digits are for alpha (transparency) level.") - ) - self.pf_color_entry = FCEntry() - self.pf_color_button = QtWidgets.QPushButton() - self.pf_color_button.setFixedSize(15, 15) - - self.form_box_child_1 = QtWidgets.QHBoxLayout() - self.form_box_child_1.addWidget(self.pf_color_entry) - self.form_box_child_1.addWidget(self.pf_color_button) - self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) - - grid0.addWidget(self.pf_color_label, 12, 0) - grid0.addLayout(self.form_box_child_1, 12, 1) - - # Plot Fill Transparency Level - self.pf_alpha_label = QtWidgets.QLabel('%s:' % _('Alpha')) - self.pf_alpha_label.setToolTip( - _("Set the fill transparency for plotted objects.") - ) - self.pf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) - self.pf_color_alpha_slider.setMinimum(0) - self.pf_color_alpha_slider.setMaximum(255) - self.pf_color_alpha_slider.setSingleStep(1) - - self.pf_color_alpha_spinner = FCSpinner() - self.pf_color_alpha_spinner.setMinimumWidth(70) - self.pf_color_alpha_spinner.set_range(0, 255) - - self.form_box_child_3 = QtWidgets.QHBoxLayout() - self.form_box_child_3.addWidget(self.pf_color_alpha_slider) - self.form_box_child_3.addWidget(self.pf_color_alpha_spinner) - - grid0.addWidget(self.pf_alpha_label, 13, 0) - grid0.addLayout(self.form_box_child_3, 13, 1) - separator_line = QtWidgets.QFrame() separator_line.setFrameShape(QtWidgets.QFrame.HLine) separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) @@ -1701,8 +1636,138 @@ class GerberGenPrefGroupUI(OptionsGroupUI): ) grid0.addWidget(self.gerber_extra_buffering, 8, 0, 1, 3) + separator_line = QtWidgets.QFrame() + separator_line.setFrameShape(QtWidgets.QFrame.HLine) + separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) + grid0.addWidget(separator_line, 9, 0, 1, 3) + + # Gerber Object Color + self.gerber_color_label = QtWidgets.QLabel('%s' % _('Gerber Object Color')) + grid0.addWidget(self.gerber_color_label, 10, 0, 1, 3) + + # Plot Line Color + self.pl_color_label = QtWidgets.QLabel('%s:' % _('Outline')) + self.pl_color_label.setToolTip( + _("Set the line color for plotted objects.") + ) + self.pl_color_entry = FCEntry() + self.pl_color_button = QtWidgets.QPushButton() + self.pl_color_button.setFixedSize(15, 15) + + self.form_box_child_2 = QtWidgets.QHBoxLayout() + self.form_box_child_2.addWidget(self.pl_color_entry) + self.form_box_child_2.addWidget(self.pl_color_button) + self.form_box_child_2.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) + + grid0.addWidget(self.pl_color_label, 11, 0) + grid0.addLayout(self.form_box_child_2, 11, 1, 1, 2) + + # Plot Fill Color + self.pf_color_label = QtWidgets.QLabel('%s:' % _('Fill')) + self.pf_color_label.setToolTip( + _("Set the fill color for plotted objects.\n" + "First 6 digits are the color and the last 2\n" + "digits are for alpha (transparency) level.") + ) + self.pf_color_entry = FCEntry() + self.pf_color_button = QtWidgets.QPushButton() + self.pf_color_button.setFixedSize(15, 15) + + self.form_box_child_1 = QtWidgets.QHBoxLayout() + self.form_box_child_1.addWidget(self.pf_color_entry) + self.form_box_child_1.addWidget(self.pf_color_button) + self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) + + grid0.addWidget(self.pf_color_label, 12, 0) + grid0.addLayout(self.form_box_child_1, 12, 1, 1, 2) + + # Plot Fill Transparency Level + self.pf_alpha_label = QtWidgets.QLabel('%s:' % _('Alpha')) + self.pf_alpha_label.setToolTip( + _("Set the fill transparency for plotted objects.") + ) + self.pf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal) + self.pf_color_alpha_slider.setMinimum(0) + self.pf_color_alpha_slider.setMaximum(255) + self.pf_color_alpha_slider.setSingleStep(1) + + self.pf_color_alpha_spinner = FCSpinner() + self.pf_color_alpha_spinner.setMinimumWidth(70) + self.pf_color_alpha_spinner.set_range(0, 255) + + self.form_box_child_3 = QtWidgets.QHBoxLayout() + self.form_box_child_3.addWidget(self.pf_color_alpha_slider) + self.form_box_child_3.addWidget(self.pf_color_alpha_spinner) + + grid0.addWidget(self.pf_alpha_label, 13, 0) + grid0.addLayout(self.form_box_child_3, 13, 1, 1, 2) + self.layout.addStretch() + # Setting plot colors signals + self.pl_color_entry.editingFinished.connect(self.on_pl_color_entry) + self.pl_color_button.clicked.connect(self.on_pl_color_button) + self.pf_color_entry.editingFinished.connect(self.on_pf_color_entry) + self.pf_color_button.clicked.connect(self.on_pf_color_button) + self.pf_color_alpha_spinner.valueChanged.connect(self.on_pf_color_spinner) + self.pf_color_alpha_slider.valueChanged.connect(self.on_pf_color_slider) + + # Setting plot colors handlers + def on_pf_color_entry(self): + self.app.defaults['gerber_plot_fill'] = self.pf_color_entry.get_value()[:7] + \ + self.app.defaults['gerber_plot_fill'][7:9] + self.pf_color_button.setStyleSheet("background-color:%s" % str(self.defaults['gerber_plot_fill'])[:7]) + + def on_pf_color_button(self): + current_color = QtGui.QColor(self.app.defaults['gerber_plot_fill'][:7]) + + c_dialog = QtWidgets.QColorDialog() + plot_fill_color = c_dialog.getColor(initial=current_color) + + if plot_fill_color.isValid() is False: + return + + self.pf_color_button.setStyleSheet("background-color:%s" % str(plot_fill_color.name())) + + new_val = str(plot_fill_color.name()) + str(self.app.defaults['gerber_plot_fill'][7:9]) + self.pf_color_entry.set_value(new_val) + self.app.defaults['gerber_plot_fill'] = new_val + + def on_pf_color_spinner(self): + spinner_value = self.pf_color_alpha_spinner.value() + self.pf_color_alpha_slider.setValue(spinner_value) + self.app.defaults['gerber_plot_fill'] = \ + self.app.defaults['gerber_plot_fill'][:7] + \ + (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') + self.app.defaults['gerber_plot_line'] = \ + self.app.defaults['gerber_plot_line'][:7] + \ + (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00') + + def on_pf_color_slider(self): + slider_value = self.pf_color_alpha_slider.value() + self.pf_color_alpha_spinner.setValue(slider_value) + + def on_pl_color_entry(self): + self.app.defaults['gerber_plot_line'] = self.pl_color_entry.get_value()[:7] + \ + self.app.defaults['gerber_plot_line'][7:9] + self.pl_color_button.setStyleSheet("background-color:%s" % str(self.defaults['gerber_plot_line'])[:7]) + + def on_pl_color_button(self): + current_color = QtGui.QColor(self.app.defaults['gerber_plot_line'][:7]) + # print(current_color) + + c_dialog = QtWidgets.QColorDialog() + plot_line_color = c_dialog.getColor(initial=current_color) + + if plot_line_color.isValid() is False: + return + + self.pl_color_button.setStyleSheet("background-color:%s" % str(plot_line_color.name())) + + new_val_line = str(plot_line_color.name()) + str(self.app.defaults['gerber_plot_line'][7:9]) + self.pl_color_entry.set_value(new_val_line) + self.app.defaults['gerber_plot_line'] = new_val_line + class GerberOptPrefGroupUI(OptionsGroupUI): def __init__(self, decimals=4, parent=None):