Some work on gerber prefs

This commit is contained in:
David Robertson
2020-05-06 04:03:27 +01:00
parent 1c0dc433a7
commit 44fb91633a
4 changed files with 166 additions and 390 deletions

View File

@@ -10552,7 +10552,7 @@ class App(QtCore.QObject):
alpha_level = str(hex( alpha_level = str(hex(
self.ui.excellon_defaults_form.excellon_gen_group.color_alpha_slider.value())[2:]) self.ui.excellon_defaults_form.excellon_gen_group.color_alpha_slider.value())[2:])
elif sel_obj.kind == 'gerber': elif sel_obj.kind == 'gerber':
alpha_level = str(hex(self.ui.gerber_defaults_form.gerber_gen_group.pf_color_alpha_slider.value())[2:]) alpha_level = self.defaults["gerber_plot_fill"][7:]
elif sel_obj.kind == 'geometry': elif sel_obj.kind == 'geometry':
alpha_level = 'FF' alpha_level = 'FF'
else: else:

View File

@@ -48,17 +48,6 @@ class PreferencesUIManager:
# when adding entries here read the comments in the method found below named: # when adding entries here read the comments in the method found below named:
# def new_object(self, kind, name, initialize, active=True, fit=True, plot=True) # def new_object(self, kind, name, initialize, active=True, fit=True, plot=True)
self.defaults_form_fields = { self.defaults_form_fields = {
# Gerber General
"gerber_plot": self.ui.gerber_defaults_form.gerber_gen_group.plot_cb,
"gerber_solid": self.ui.gerber_defaults_form.gerber_gen_group.solid_cb,
"gerber_multicolored": self.ui.gerber_defaults_form.gerber_gen_group.multicolored_cb,
"gerber_circle_steps": self.ui.gerber_defaults_form.gerber_gen_group.circle_steps_entry,
"gerber_def_units": self.ui.gerber_defaults_form.gerber_gen_group.gerber_units_radio,
"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 Options
"gerber_isotooldia": self.ui.gerber_defaults_form.gerber_opt_group.iso_tool_dia_entry, "gerber_isotooldia": self.ui.gerber_defaults_form.gerber_opt_group.iso_tool_dia_entry,
@@ -87,11 +76,6 @@ class PreferencesUIManager:
"gerber_simplification": self.ui.gerber_defaults_form.gerber_adv_opt_group.simplify_cb, "gerber_simplification": self.ui.gerber_defaults_form.gerber_adv_opt_group.simplify_cb,
"gerber_simp_tolerance": self.ui.gerber_defaults_form.gerber_adv_opt_group.simplification_tol_spinner, "gerber_simp_tolerance": self.ui.gerber_defaults_form.gerber_adv_opt_group.simplification_tol_spinner,
# Gerber Export
"gerber_exp_units": self.ui.gerber_defaults_form.gerber_exp_group.gerber_units_radio,
"gerber_exp_integer": self.ui.gerber_defaults_form.gerber_exp_group.format_whole_entry,
"gerber_exp_decimals": self.ui.gerber_defaults_form.gerber_exp_group.format_dec_entry,
"gerber_exp_zeros": self.ui.gerber_defaults_form.gerber_exp_group.zeros_radio,
# Gerber Editor # Gerber Editor
"gerber_editor_sel_limit": self.ui.gerber_defaults_form.gerber_editor_group.sel_limit_entry, "gerber_editor_sel_limit": self.ui.gerber_defaults_form.gerber_editor_group.sel_limit_entry,
@@ -639,21 +623,6 @@ class PreferencesUIManager:
log.debug("Finished Preferences GUI form initialization.") log.debug("Finished Preferences GUI form initialization.")
def __init_color_pickers(self): def __init_color_pickers(self):
# Init Gerber Plot Colors
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['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.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['gerber_plot_line'])[:7])
# Init Excellon Plot Colors # Init Excellon Plot Colors
self.ui.excellon_defaults_form.excellon_gen_group.fill_color_entry.set_value( self.ui.excellon_defaults_form.excellon_gen_group.fill_color_entry.set_value(
self.defaults['excellon_plot_fill']) self.defaults['excellon_plot_fill'])

View File

@@ -1,8 +1,5 @@
from PyQt5 import QtWidgets, QtCore from flatcamGUI.preferences.OptionUI import *
from PyQt5.QtCore import QSettings from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
from flatcamGUI.GUIElements import RadioSet, FCSpinner
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext import gettext
import FlatCAMTranslation as fcTranslate import FlatCAMTranslation as fcTranslate
@@ -12,107 +9,49 @@ fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__: if '_' not in builtins.__dict__:
_ = gettext.gettext _ = gettext.gettext
settings = QSettings("Open Source", "FlatCAM")
if settings.contains("machinist"):
machinist_setting = settings.value('machinist', type=int)
else:
machinist_setting = 0
class GerberExpPrefGroupUI(OptionsGroupUI2):
class GerberExpPrefGroupUI(OptionsGroupUI): def __init__(self, decimals=4, **kwargs):
def __init__(self, decimals=4, parent=None):
super(GerberExpPrefGroupUI, self).__init__(self, parent=parent)
self.setTitle(str(_("Gerber Export")))
self.decimals = decimals self.decimals = decimals
super().__init__(**kwargs)
self.setTitle(str(_("Gerber Export")))
# Plot options def build_options(self) -> [OptionUI]:
self.export_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Export Options")) return [
self.export_options_label.setToolTip( HeadingOptionUI(
_("The parameters set here are used in the file exported\n" label_text="Export Options",
"when using the File -> Export -> Export Gerber menu entry.") label_tooltip="The parameters set here are used in the file exported\n"
) "when using the File -> Export -> Export Gerber menu entry."
self.layout.addWidget(self.export_options_label) ),
RadioSetOptionUI(
form = QtWidgets.QFormLayout() option="gerber_exp_units",
self.layout.addLayout(form) label_text="Units",
label_tooltip="The units used in the Gerber file.",
# Gerber Units choices=[{'label': _('INCH'), 'value': 'IN'},
self.gerber_units_label = QtWidgets.QLabel('%s:' % _('Units')) {'label': _('MM'), 'value': 'MM'}]
self.gerber_units_label.setToolTip( ),
_("The units used in the Gerber file.") SpinnerOptionUI(
) option="gerber_exp_integer",
label_text="Int",
self.gerber_units_radio = RadioSet([{'label': _('INCH'), 'value': 'IN'}, label_tooltip="The number of digits in the whole part of Gerber coordinates",
{'label': _('MM'), 'value': 'MM'}]) min_value=0, max_value=9, step=1
self.gerber_units_radio.setToolTip( ),
_("The units used in the Gerber file.") SpinnerOptionUI(
) option="gerber_exp_decimals",
label_text="Decimals",
form.addRow(self.gerber_units_label, self.gerber_units_radio) label_tooltip="The number of digits in the decimal part of Gerber coordinates",
min_value=0, max_value=9, step=1
# Gerber format ),
self.digits_label = QtWidgets.QLabel("%s:" % _("Int/Decimals")) RadioSetOptionUI(
self.digits_label.setToolTip( option="gerber_exp_zeros",
_("The number of digits in the whole part of the number\n" label_text="Zeros",
"and in the fractional part of the number.") label_tooltip="This sets the type of Gerber zeros.\n"
)
hlay1 = QtWidgets.QHBoxLayout()
self.format_whole_entry = FCSpinner()
self.format_whole_entry.set_range(0, 9)
self.format_whole_entry.set_step(1)
self.format_whole_entry.setWrapping(True)
self.format_whole_entry.setMinimumWidth(30)
self.format_whole_entry.setToolTip(
_("This numbers signify the number of digits in\n"
"the whole part of Gerber coordinates.")
)
hlay1.addWidget(self.format_whole_entry, QtCore.Qt.AlignLeft)
gerber_separator_label = QtWidgets.QLabel(':')
gerber_separator_label.setFixedWidth(5)
hlay1.addWidget(gerber_separator_label, QtCore.Qt.AlignLeft)
self.format_dec_entry = FCSpinner()
self.format_dec_entry.set_range(0, 9)
self.format_dec_entry.set_step(1)
self.format_dec_entry.setWrapping(True)
self.format_dec_entry.setMinimumWidth(30)
self.format_dec_entry.setToolTip(
_("This numbers signify the number of digits in\n"
"the decimal part of Gerber coordinates.")
)
hlay1.addWidget(self.format_dec_entry, QtCore.Qt.AlignLeft)
hlay1.addStretch()
form.addRow(self.digits_label, hlay1)
# Gerber Zeros
self.zeros_label = QtWidgets.QLabel('%s:' % _('Zeros'))
self.zeros_label.setAlignment(QtCore.Qt.AlignLeft)
self.zeros_label.setToolTip(
_("This sets the type of Gerber zeros.\n"
"If LZ then Leading Zeros are removed and\n" "If LZ then Leading Zeros are removed and\n"
"Trailing Zeros are kept.\n" "Trailing Zeros are kept.\n"
"If TZ is checked then Trailing Zeros are removed\n" "If TZ is checked then Trailing Zeros are removed\n"
"and Leading Zeros are kept.") "and Leading Zeros are kept.",
choices=[{'label': _('LZ'), 'value': 'L'},
{'label': _('TZ'), 'value': 'T'}]
) )
]
self.zeros_radio = RadioSet([{'label': _('LZ'), 'value': 'L'},
{'label': _('TZ'), 'value': 'T'}])
self.zeros_radio.setToolTip(
_("This sets the type of Gerber zeros.\n"
"If LZ then Leading Zeros are removed and\n"
"Trailing Zeros are kept.\n"
"If TZ is checked then Trailing Zeros are removed\n"
"and Leading Zeros are kept.")
)
form.addRow(self.zeros_label, self.zeros_radio)
self.layout.addStretch()

View File

@@ -1,273 +1,141 @@
from PyQt5 import QtWidgets, QtCore, QtGui from PyQt5 import QtCore, QtGui
from PyQt5.QtCore import QSettings from flatcamGUI.preferences.OptionUI import *
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
from flatcamGUI.GUIElements import FCCheckBox, FCSpinner, RadioSet, FCEntry
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext import gettext
import FlatCAMTranslation as fcTranslate import FlatCAMTranslation as fcTranslate
import builtins import builtins
fcTranslate.apply_language('strings') fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__: if '_' not in builtins.__dict__:
_ = gettext.gettext _ = gettext.gettext
settings = QSettings("Open Source", "FlatCAM")
if settings.contains("machinist"):
machinist_setting = settings.value('machinist', type=int)
else:
machinist_setting = 0
class GerberGenPrefGroupUI(OptionsGroupUI2):
class GerberGenPrefGroupUI(OptionsGroupUI): def __init__(self, decimals=4, **kwargs):
def __init__(self, decimals=4, parent=None):
# OptionsGroupUI.__init__(self, "Gerber General Preferences", parent=parent)
super(GerberGenPrefGroupUI, self).__init__(self, parent=parent)
self.setTitle(str(_("Gerber General")))
self.decimals = decimals self.decimals = decimals
super().__init__(**kwargs)
self.setTitle(str(_("Gerber General")))
# ## Plot options self.plot_line_field = self.option_dict()["gerber_plot_line"].get_field()
self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options")) self.plot_fill_field = self.option_dict()["gerber_plot_fill"].get_field()
self.layout.addWidget(self.plot_options_label) self.plot_alpha_field = self.option_dict()["_gerber_plot_alpha"].get_field()
self.plot_alpha_field.spinner.valueChanged.connect(self.on_plot_alpha_change)
grid0 = QtWidgets.QGridLayout() def build_options(self) -> [OptionUI]:
self.layout.addLayout(grid0) return [
HeadingOptionUI(label_text="Plot Options"),
CheckboxOptionUI(
option="gerber_solid",
label_text="Solid",
label_tooltip="Solid color polygons."
),
CheckboxOptionUI(
option="gerber_multicolored",
label_text="M-Color",
label_tooltip="Draw polygons in different colors."
),
CheckboxOptionUI(
option="gerber_plot",
label_text="Plot",
label_tooltip="Plot (show) this object."
),
SpinnerOptionUI(
option="gerber_circle_steps",
label_text="Circle Steps",
label_tooltip="The number of circle steps for Gerber \n"
"circular aperture linear approximation.",
min_value=0, max_value=9999, step=1
),
SeparatorOptionUI(),
# Solid CB HeadingOptionUI(
self.solid_cb = FCCheckBox(label='%s' % _('Solid')) label_text="Default Values",
self.solid_cb.setToolTip( label_tooltip="Those values will be used as fallback values\n"
_("Solid color polygons.") "in case that they are not found in the Gerber file."
) ),
grid0.addWidget(self.solid_cb, 0, 0) RadioSetOptionUI(
option="gerber_def_units",
# Multicolored CB label_text="Units",
self.multicolored_cb = FCCheckBox(label='%s' % _('M-Color')) label_tooltip="The units used in the Gerber file.",
self.multicolored_cb.setToolTip( choices=[{'label': _('INCH'), 'value': 'IN'},
_("Draw polygons in different colors.") {'label': _('MM'), 'value': 'MM'}]
) ),
grid0.addWidget(self.multicolored_cb, 0, 1) RadioSetOptionUI(
option="gerber_def_zeros",
# Plot CB label_text="Zeros",
self.plot_cb = FCCheckBox(label='%s' % _('Plot')) label_tooltip="This sets the type of Gerber zeros.\n"
self.plot_options_label.setToolTip(
_("Plot (show) this object.")
)
grid0.addWidget(self.plot_cb, 0, 2)
# Number of circle steps for circular aperture linear approximation
self.circle_steps_label = QtWidgets.QLabel('%s:' % _("Circle Steps"))
self.circle_steps_label.setToolTip(
_("The number of circle steps for Gerber \n"
"circular aperture linear approximation.")
)
self.circle_steps_entry = FCSpinner()
self.circle_steps_entry.set_range(0, 9999)
grid0.addWidget(self.circle_steps_label, 1, 0)
grid0.addWidget(self.circle_steps_entry, 1, 1, 1, 2)
grid0.addWidget(QtWidgets.QLabel(''), 2, 0, 1, 3)
# Default format for Gerber
self.gerber_default_label = QtWidgets.QLabel('<b>%s:</b>' % _('Default Values'))
self.gerber_default_label.setToolTip(
_("Those values will be used as fallback values\n"
"in case that they are not found in the Gerber file.")
)
grid0.addWidget(self.gerber_default_label, 3, 0, 1, 3)
# Gerber Units
self.gerber_units_label = QtWidgets.QLabel('%s:' % _('Units'))
self.gerber_units_label.setToolTip(
_("The units used in the Gerber file.")
)
self.gerber_units_radio = RadioSet([{'label': _('INCH'), 'value': 'IN'},
{'label': _('MM'), 'value': 'MM'}])
self.gerber_units_radio.setToolTip(
_("The units used in the Gerber file.")
)
grid0.addWidget(self.gerber_units_label, 4, 0)
grid0.addWidget(self.gerber_units_radio, 4, 1, 1, 2)
# Gerber Zeros
self.gerber_zeros_label = QtWidgets.QLabel('%s:' % _('Zeros'))
self.gerber_zeros_label.setAlignment(QtCore.Qt.AlignLeft)
self.gerber_zeros_label.setToolTip(
_("This sets the type of Gerber zeros.\n"
"If LZ then Leading Zeros are removed and\n" "If LZ then Leading Zeros are removed and\n"
"Trailing Zeros are kept.\n" "Trailing Zeros are kept.\n"
"If TZ is checked then Trailing Zeros are removed\n" "If TZ is checked then Trailing Zeros are removed\n"
"and Leading Zeros are kept.") "and Leading Zeros are kept.",
) choices=[{'label': _('LZ'), 'value': 'L'},
{'label': _('TZ'), 'value': 'T'}]
),
SeparatorOptionUI(),
self.gerber_zeros_radio = RadioSet([{'label': _('LZ'), 'value': 'L'}, CheckboxOptionUI(
{'label': _('TZ'), 'value': 'T'}]) option="gerber_clean_apertures",
self.gerber_zeros_radio.setToolTip( label_text="Clean Apertures",
_("This sets the type of Gerber zeros.\n" label_tooltip="Will remove apertures that do not have geometry\n"
"If LZ then Leading Zeros are removed and\n" "thus lowering the number of apertures in the Gerber object."
"Trailing Zeros are kept.\n" ),
"If TZ is checked then Trailing Zeros are removed\n" CheckboxOptionUI(
"and Leading Zeros are kept.") option="gerber_extra_buffering",
) label_text="Polarity change buffer",
label_tooltip="Will apply extra buffering for the\n"
grid0.addWidget(self.gerber_zeros_label, 5, 0)
grid0.addWidget(self.gerber_zeros_radio, 5, 1, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 6, 0, 1, 3)
# Apertures Cleaning
self.gerber_clean_cb = FCCheckBox(label='%s' % _('Clean Apertures'))
self.gerber_clean_cb.setToolTip(
_("Will remove apertures that do not have geometry\n"
"thus lowering the number of apertures in the Gerber object.")
)
grid0.addWidget(self.gerber_clean_cb, 7, 0, 1, 3)
# Apply Extra Buffering
self.gerber_extra_buffering = FCCheckBox(label='%s' % _('Polarity change buffer'))
self.gerber_extra_buffering.setToolTip(
_("Will apply extra buffering for the\n"
"solid geometry when we have polarity changes.\n" "solid geometry when we have polarity changes.\n"
"May help loading Gerber files that otherwise\n" "May help loading Gerber files that otherwise\n"
"do not load correctly.") "do not load correctly."
) ),
grid0.addWidget(self.gerber_extra_buffering, 8, 0, 1, 3) SeparatorOptionUI(),
separator_line = QtWidgets.QFrame() HeadingOptionUI(label_text="Gerber Object Color"),
separator_line.setFrameShape(QtWidgets.QFrame.HLine) ColorOptionUI(
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken) option="gerber_plot_line",
grid0.addWidget(separator_line, 9, 0, 1, 3) label_text="Outline",
label_tooltip="Set the line color for plotted objects.",
# Gerber Object Color ),
self.gerber_color_label = QtWidgets.QLabel('<b>%s</b>' % _('Gerber Object Color')) ColorOptionUI(
grid0.addWidget(self.gerber_color_label, 10, 0, 1, 3) option="gerber_plot_fill",
label_text="Fill",
# Plot Line Color label_tooltip="Set the fill color for plotted objects.\n"
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" "First 6 digits are the color and the last 2\n"
"digits are for alpha (transparency) level.") "digits are for alpha (transparency) level."
),
SliderWithSpinnerOptionUI(
option="_gerber_plot_alpha",
label_text="Alpha",
label_tooltip="Set the transparency for plotted objects.",
min_value=0, max_value=255, step=1
) )
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() def on_plot_alpha_change(self):
self.form_box_child_1.addWidget(self.pf_color_entry) alpha = self.plot_alpha_field.get_value()
self.form_box_child_1.addWidget(self.pf_color_button) fill = self._modify_color_alpha(color=self.plot_fill_field.get_value(), alpha=alpha)
self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter) self.plot_fill_field.set_value(fill)
line = self._modify_color_alpha(color=self.plot_line_field.get_value(), alpha=alpha)
self.plot_line_field.set_value(line)
grid0.addWidget(self.pf_color_label, 12, 0) def _modify_color_alpha(self, color: str, alpha: int):
grid0.addLayout(self.form_box_child_1, 12, 1, 1, 2) color_without_alpha = color[:7]
if alpha > 255:
return color_without_alpha + "FF"
elif alpha < 0:
return color_without_alpha + "00"
else:
hexalpha = hex(alpha)[2:]
if len(hexalpha) == 1:
hexalpha = "0" + hexalpha
return color_without_alpha + hexalpha
# 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() # def on_pf_color_alpha_spinner(self):
self.pf_color_alpha_spinner.setMinimumWidth(70) # self.pf_color_alpha_slider.setValue(spinner_value)
self.pf_color_alpha_spinner.set_range(0, 255) # 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')
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.app.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.app.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