gerber editor prefs

This commit is contained in:
David Robertson 2020-05-09 15:59:21 +01:00
parent 126ed47783
commit 3db52093f0
3 changed files with 130 additions and 253 deletions

View File

@ -63,6 +63,14 @@ class BasicOptionUI(OptionUI):
return self.entry_widget return self.entry_widget
class LineEntryOptionUI(BasicOptionUI):
def __init__(self, option: str, label_text: str, **kwargs):
super().__init__(option=option, label_text=label_text, **kwargs)
def build_entry_widget(self) -> QtWidgets.QWidget:
return FCEntry()
class RadioSetOptionUI(BasicOptionUI): class RadioSetOptionUI(BasicOptionUI):
def __init__(self, option: str, label_text: str, choices: list, orientation='horizontal', **kwargs): def __init__(self, option: str, label_text: str, choices: list, orientation='horizontal', **kwargs):
@ -126,6 +134,7 @@ class SliderWithSpinnerOptionUI(BasicOptionUI):
entry = FCSliderWithSpinner(min=self.min_value, max=self.max_value, step=self.step) entry = FCSliderWithSpinner(min=self.min_value, max=self.max_value, step=self.step)
return entry return entry
class ColorAlphaSliderOptionUI(SliderWithSpinnerOptionUI): class ColorAlphaSliderOptionUI(SliderWithSpinnerOptionUI):
def __init__(self, applies_to: List[str], group, label_text: str, **kwargs): def __init__(self, applies_to: List[str], group, label_text: str, **kwargs):
self.applies_to = applies_to self.applies_to = applies_to

View File

@ -49,29 +49,6 @@ class PreferencesUIManager:
# 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 Advanced Options
# "gerber_aperture_scale_factor": self.ui.gerber_defaults_form.gerber_adv_opt_group.scale_aperture_entry,
# "gerber_aperture_buffer_factor": self.ui.gerber_defaults_form.gerber_adv_opt_group.buffer_aperture_entry,
# Gerber Editor
"gerber_editor_sel_limit": self.ui.gerber_defaults_form.gerber_editor_group.sel_limit_entry,
"gerber_editor_newcode": self.ui.gerber_defaults_form.gerber_editor_group.addcode_entry,
"gerber_editor_newsize": self.ui.gerber_defaults_form.gerber_editor_group.addsize_entry,
"gerber_editor_newtype": self.ui.gerber_defaults_form.gerber_editor_group.addtype_combo,
"gerber_editor_newdim": self.ui.gerber_defaults_form.gerber_editor_group.adddim_entry,
"gerber_editor_array_size": self.ui.gerber_defaults_form.gerber_editor_group.grb_array_size_entry,
"gerber_editor_lin_axis": self.ui.gerber_defaults_form.gerber_editor_group.grb_axis_radio,
"gerber_editor_lin_pitch": self.ui.gerber_defaults_form.gerber_editor_group.grb_pitch_entry,
"gerber_editor_lin_angle": self.ui.gerber_defaults_form.gerber_editor_group.grb_angle_entry,
"gerber_editor_circ_dir": self.ui.gerber_defaults_form.gerber_editor_group.grb_circular_dir_radio,
"gerber_editor_circ_angle":
self.ui.gerber_defaults_form.gerber_editor_group.grb_circular_angle_entry,
"gerber_editor_scale_f": self.ui.gerber_defaults_form.gerber_editor_group.grb_scale_entry,
"gerber_editor_buff_f": self.ui.gerber_defaults_form.gerber_editor_group.grb_buff_entry,
"gerber_editor_ma_low": self.ui.gerber_defaults_form.gerber_editor_group.grb_ma_low_entry,
"gerber_editor_ma_high": self.ui.gerber_defaults_form.gerber_editor_group.grb_ma_high_entry,
# Excellon General # Excellon General
"excellon_plot": self.ui.excellon_defaults_form.excellon_gen_group.plot_cb, "excellon_plot": self.ui.excellon_defaults_form.excellon_gen_group.plot_cb,
"excellon_solid": self.ui.excellon_defaults_form.excellon_gen_group.solid_cb, "excellon_solid": self.ui.excellon_defaults_form.excellon_gen_group.solid_cb,

View File

@ -1,247 +1,138 @@
from PyQt5 import QtWidgets from flatcamGUI.preferences.OptionUI import *
from PyQt5.QtCore import QSettings from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
from flatcamGUI.GUIElements import FCSpinner, FCDoubleSpinner, FCComboBox, FCEntry, RadioSet
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 GerberEditorPrefGroupUI(OptionsGroupUI2):
class GerberEditorPrefGroupUI(OptionsGroupUI): def __init__(self, decimals=4, **kwargs):
def __init__(self, decimals=4, parent=None):
# OptionsGroupUI.__init__(self, "Gerber Adv. Options Preferences", parent=parent)
super(GerberEditorPrefGroupUI, self).__init__(self, parent=parent)
self.setTitle(str(_("Gerber Editor")))
self.decimals = decimals self.decimals = decimals
super().__init__(**kwargs)
self.setTitle(str(_("Gerber Editor")))
# Advanced Gerber Parameters def build_options(self) -> [OptionUI]:
self.param_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters")) return [
self.param_label.setToolTip( HeadingOptionUI(
_("A list of Gerber Editor parameters.") label_text="Parameters",
) label_tooltip="A list of Gerber Editor parameters."
self.layout.addWidget(self.param_label) ),
SpinnerOptionUI(
grid0 = QtWidgets.QGridLayout() option="gerber_editor_sel_limit",
self.layout.addLayout(grid0) label_text="Selection limit",
label_tooltip="Set the number of selected Gerber geometry\n"
# Selection Limit
self.sel_limit_label = QtWidgets.QLabel('%s:' % _("Selection limit"))
self.sel_limit_label.setToolTip(
_("Set the number of selected Gerber geometry\n"
"items above which the utility geometry\n" "items above which the utility geometry\n"
"becomes just a selection rectangle.\n" "becomes just a selection rectangle.\n"
"Increases the performance when moving a\n" "Increases the performance when moving a\n"
"large number of geometric elements.") "large number of geometric elements.",
) min_value=0, max_value=9999, step=1
self.sel_limit_entry = FCSpinner() ),
self.sel_limit_entry.set_range(0, 9999) SpinnerOptionUI(
option="gerber_editor_newcode",
grid0.addWidget(self.sel_limit_label, 0, 0) label_text="New Aperture code",
grid0.addWidget(self.sel_limit_entry, 0, 1) label_tooltip="Code for the new aperture",
min_value=10, max_value=99, step=1
# New aperture code ),
self.addcode_entry_lbl = QtWidgets.QLabel('%s:' % _('New Aperture code')) DoubleSpinnerOptionUI(
self.addcode_entry_lbl.setToolTip( option="gerber_editor_newsize",
_("Code for the new aperture") label_text="New Aperture size",
) label_tooltip="Size for the new aperture",
min_value=0.0, max_value=100.0, step=0.1, decimals=self.decimals
self.addcode_entry = FCSpinner() ),
self.addcode_entry.set_range(10, 99) ComboboxOptionUI(
self.addcode_entry.setWrapping(True) option="gerber_editor_newtype",
label_text="New Aperture type",
grid0.addWidget(self.addcode_entry_lbl, 1, 0) label_tooltip="Type for the new aperture.\n"
grid0.addWidget(self.addcode_entry, 1, 1) "Can be 'C', 'R' or 'O'.",
choices=['C', 'R', 'O']
# New aperture size ),
self.addsize_entry_lbl = QtWidgets.QLabel('%s:' % _('New Aperture size')) SpinnerOptionUI(
self.addsize_entry_lbl.setToolTip( option="gerber_editor_array_size",
_("Size for the new aperture") label_text="Nr of pads",
) label_tooltip="Specify how many pads to be in the array.",
min_value=0, max_value=9999, step=1
self.addsize_entry = FCDoubleSpinner() ),
self.addsize_entry.set_range(0, 100) LineEntryOptionUI(
self.addsize_entry.set_precision(self.decimals) option="gerber_editor_newdim",
label_text="Aperture Dimensions",
grid0.addWidget(self.addsize_entry_lbl, 2, 0) label_tooltip="Diameters of the tools, separated by comma.\n"
grid0.addWidget(self.addsize_entry, 2, 1)
# New aperture type
self.addtype_combo_lbl = QtWidgets.QLabel('%s:' % _('New Aperture type'))
self.addtype_combo_lbl.setToolTip(
_("Type for the new aperture.\n"
"Can be 'C', 'R' or 'O'.")
)
self.addtype_combo = FCComboBox()
self.addtype_combo.addItems(['C', 'R', 'O'])
grid0.addWidget(self.addtype_combo_lbl, 3, 0)
grid0.addWidget(self.addtype_combo, 3, 1)
# Number of pads in a pad array
self.grb_array_size_label = QtWidgets.QLabel('%s:' % _('Nr of pads'))
self.grb_array_size_label.setToolTip(
_("Specify how many pads to be in the array.")
)
self.grb_array_size_entry = FCSpinner()
self.grb_array_size_entry.set_range(0, 9999)
grid0.addWidget(self.grb_array_size_label, 4, 0)
grid0.addWidget(self.grb_array_size_entry, 4, 1)
self.adddim_label = QtWidgets.QLabel('%s:' % _('Aperture Dimensions'))
self.adddim_label.setToolTip(
_("Diameters of the tools, separated by comma.\n"
"The value of the diameter has to use the dot decimals separator.\n" "The value of the diameter has to use the dot decimals separator.\n"
"Valid values: 0.3, 1.0") "Valid values: 0.3, 1.0"
) ),
grid0.addWidget(self.adddim_label, 5, 0)
self.adddim_entry = FCEntry()
grid0.addWidget(self.adddim_entry, 5, 1)
self.grb_array_linear_label = QtWidgets.QLabel('<b>%s:</b>' % _('Linear Pad Array')) HeadingOptionUI(label_text="Linear Pad Array"),
grid0.addWidget(self.grb_array_linear_label, 6, 0, 1, 2) RadioSetOptionUI(
option="gerber_editor_lin_axis",
# Linear Pad Array direction label_text="Linear Direction",
self.grb_axis_label = QtWidgets.QLabel('%s:' % _('Linear Direction')) label_tooltip="Direction on which the linear array is oriented:\n"
self.grb_axis_label.setToolTip(
_("Direction on which the linear array is oriented:\n"
"- 'X' - horizontal axis \n" "- 'X' - horizontal axis \n"
"- 'Y' - vertical axis or \n" "- 'Y' - vertical axis or \n"
"- 'Angle' - a custom angle for the array inclination") "- 'Angle' - a custom angle for the array inclination",
) choices=[{'label': _('X'), 'value': 'X'},
self.grb_axis_radio = RadioSet([{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'}, {'label': _('Y'), 'value': 'Y'},
{'label': _('Angle'), 'value': 'A'}]) {'label': _('Angle'), 'value': 'A'}]
),
DoubleSpinnerOptionUI(
option="gerber_editor_lin_pitch",
label_text="Pitch",
label_tooltip="Pitch = Distance between elements of the array.",
min_value=-9999.99, max_value=9999.99, step=0.1, decimals=self.decimals
),
DoubleSpinnerOptionUI(
option="gerber_editor_lin_angle",
label_text="Angle",
label_tooltip="Angle at which each element in circular array is placed.", # FIXME: this seems wrong
min_value=-360, max_value=360, step=5, decimals=self.decimals
),
grid0.addWidget(self.grb_axis_label, 7, 0) HeadingOptionUI(label_text="Circular Pad Array"),
grid0.addWidget(self.grb_axis_radio, 7, 1) RadioSetOptionUI(
option="gerber_editor_circ_dir",
label_text="Circular Direction",
label_tooltip="Direction for circular array.\n"
"Can be CW = clockwise or CCW = counter clockwise.",
choices=[{'label': _('CW'), 'value': 'CW'},
{'label': _('CCW'), 'value': 'CCW'}]
),
DoubleSpinnerOptionUI(
option="gerber_editor_circ_angle",
label_text="Circular Angle",
label_tooltip="Angle at which each element in circular array is placed.",
min_value=-360, max_value=360, step=5, decimals=self.decimals
),
# Linear Pad Array pitch distance HeadingOptionUI(label_text="Buffer Tool"),
self.grb_pitch_label = QtWidgets.QLabel('%s:' % _('Pitch')) DoubleSpinnerOptionUI(
self.grb_pitch_label.setToolTip( option="gerber_editor_buff_f",
_("Pitch = Distance between elements of the array.") label_text="Buffer distance",
label_tooltip="Distance at which to buffer the Gerber element.",
min_value=-9999, max_value=9999, step=0.1, decimals=self.decimals
),
HeadingOptionUI(label_text="Scale Tool"),
DoubleSpinnerOptionUI(
option="gerber_editor_scale_f",
label_text="Scale factor",
label_tooltip="Factor to scale the Gerber element.",
min_value=0, max_value=9999, step=0.1, decimals=self.decimals
),
HeadingOptionUI(label_text="Mark Area Tool"),
DoubleSpinnerOptionUI(
option="gerber_editor_ma_low",
label_text="Threshold low",
label_tooltip="Threshold value under which the apertures are not marked.",
min_value=0, max_value=9999, step=0.1, decimals=self.decimals
),
DoubleSpinnerOptionUI(
option="gerber_editor_ma_high",
label_text="Threshold high",
label_tooltip="Threshold value over which the apertures are not marked.",
min_value=0, max_value=9999, step=0.1, decimals=self.decimals
) )
# self.drill_pitch_label.setMinimumWidth(100) ]
self.grb_pitch_entry = FCDoubleSpinner()
self.grb_pitch_entry.set_precision(self.decimals)
grid0.addWidget(self.grb_pitch_label, 8, 0)
grid0.addWidget(self.grb_pitch_entry, 8, 1)
# Linear Pad Array custom angle
self.grb_angle_label = QtWidgets.QLabel('%s:' % _('Angle'))
self.grb_angle_label.setToolTip(
_("Angle at which each element in circular array is placed.")
)
self.grb_angle_entry = FCDoubleSpinner()
self.grb_angle_entry.set_precision(self.decimals)
self.grb_angle_entry.set_range(-360, 360)
self.grb_angle_entry.setSingleStep(5)
grid0.addWidget(self.grb_angle_label, 9, 0)
grid0.addWidget(self.grb_angle_entry, 9, 1)
self.grb_array_circ_label = QtWidgets.QLabel('<b>%s:</b>' % _('Circular Pad Array'))
grid0.addWidget(self.grb_array_circ_label, 10, 0, 1, 2)
# Circular Pad Array direction
self.grb_circular_direction_label = QtWidgets.QLabel('%s:' % _('Circular Direction'))
self.grb_circular_direction_label.setToolTip(
_("Direction for circular array.\n"
"Can be CW = clockwise or CCW = counter clockwise.")
)
self.grb_circular_dir_radio = RadioSet([{'label': _('CW'), 'value': 'CW'},
{'label': _('CCW'), 'value': 'CCW'}])
grid0.addWidget(self.grb_circular_direction_label, 11, 0)
grid0.addWidget(self.grb_circular_dir_radio, 11, 1)
# Circular Pad Array Angle
self.grb_circular_angle_label = QtWidgets.QLabel('%s:' % _('Circular Angle'))
self.grb_circular_angle_label.setToolTip(
_("Angle at which each element in circular array is placed.")
)
self.grb_circular_angle_entry = FCDoubleSpinner()
self.grb_circular_angle_entry.set_precision(self.decimals)
self.grb_circular_angle_entry.set_range(-360, 360)
self.grb_circular_angle_entry.setSingleStep(5)
grid0.addWidget(self.grb_circular_angle_label, 12, 0)
grid0.addWidget(self.grb_circular_angle_entry, 12, 1)
self.grb_array_tools_b_label = QtWidgets.QLabel('<b>%s:</b>' % _('Buffer Tool'))
grid0.addWidget(self.grb_array_tools_b_label, 13, 0, 1, 2)
# Buffer Distance
self.grb_buff_label = QtWidgets.QLabel('%s:' % _('Buffer distance'))
self.grb_buff_label.setToolTip(
_("Distance at which to buffer the Gerber element.")
)
self.grb_buff_entry = FCDoubleSpinner()
self.grb_buff_entry.set_precision(self.decimals)
self.grb_buff_entry.set_range(-9999, 9999)
grid0.addWidget(self.grb_buff_label, 14, 0)
grid0.addWidget(self.grb_buff_entry, 14, 1)
self.grb_array_tools_s_label = QtWidgets.QLabel('<b>%s:</b>' % _('Scale Tool'))
grid0.addWidget(self.grb_array_tools_s_label, 15, 0, 1, 2)
# Scale Factor
self.grb_scale_label = QtWidgets.QLabel('%s:' % _('Scale factor'))
self.grb_scale_label.setToolTip(
_("Factor to scale the Gerber element.")
)
self.grb_scale_entry = FCDoubleSpinner()
self.grb_scale_entry.set_precision(self.decimals)
self.grb_scale_entry.set_range(0, 9999)
grid0.addWidget(self.grb_scale_label, 16, 0)
grid0.addWidget(self.grb_scale_entry, 16, 1)
self.grb_array_tools_ma_label = QtWidgets.QLabel('<b>%s:</b>' % _('Mark Area Tool'))
grid0.addWidget(self.grb_array_tools_ma_label, 17, 0, 1, 2)
# Mark area Tool low threshold
self.grb_ma_low_label = QtWidgets.QLabel('%s:' % _('Threshold low'))
self.grb_ma_low_label.setToolTip(
_("Threshold value under which the apertures are not marked.")
)
self.grb_ma_low_entry = FCDoubleSpinner()
self.grb_ma_low_entry.set_precision(self.decimals)
self.grb_ma_low_entry.set_range(0, 9999)
grid0.addWidget(self.grb_ma_low_label, 18, 0)
grid0.addWidget(self.grb_ma_low_entry, 18, 1)
# Mark area Tool high threshold
self.grb_ma_high_label = QtWidgets.QLabel('%s:' % _('Threshold high'))
self.grb_ma_high_label.setToolTip(
_("Threshold value over which the apertures are not marked.")
)
self.grb_ma_high_entry = FCDoubleSpinner()
self.grb_ma_high_entry.set_precision(self.decimals)
self.grb_ma_high_entry.set_range(0, 9999)
grid0.addWidget(self.grb_ma_high_label, 19, 0)
grid0.addWidget(self.grb_ma_high_entry, 19, 1)
self.layout.addStretch()