Revert "Preferences refactoring (pull request #309)"

This commit is contained in:
Marius Stanciu
2020-06-01 12:57:10 +00:00
parent 3c102f7753
commit 612aa6a48f
52 changed files with 6162 additions and 3951 deletions

View File

@@ -1,6 +1,8 @@
from flatcamGUI.GUIElements import OptionalInputSection
from flatcamGUI.preferences.OptionUI import *
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
from PyQt5 import QtWidgets
from PyQt5.QtCore import QSettings
from flatcamGUI.GUIElements import FCCheckBox, RadioSet, FCDoubleSpinner, FCSpinner, OptionalInputSection
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
import FlatCAMTranslation as fcTranslate
@@ -10,113 +12,175 @@ 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 GerberAdvOptPrefGroupUI(OptionsGroupUI2):
def __init__(self, decimals=4, **kwargs):
self.decimals = decimals
super().__init__(**kwargs)
class GerberAdvOptPrefGroupUI(OptionsGroupUI):
def __init__(self, decimals=4, parent=None):
# OptionsGroupUI.__init__(self, "Gerber Adv. Options Preferences", parent=parent)
super(GerberAdvOptPrefGroupUI, self).__init__(self, parent=parent)
self.setTitle(str(_("Gerber Adv. Options")))
self.decimals = decimals
self.simplify_cb = self.option_dict()["gerber_simplification"].get_field()
self.simplification_tol_label = self.option_dict()["gerber_simp_tolerance"].label_widget
self.simplification_tol_spinner = self.option_dict()["gerber_simp_tolerance"].get_field()
self.ois_simplif = OptionalInputSection(self.simplify_cb, [self.simplification_tol_label, self.simplification_tol_spinner], logic=True)
# ## Advanced Gerber Parameters
self.adv_param_label = QtWidgets.QLabel('<b>%s:</b>' % _('Advanced Options'))
self.adv_param_label.setToolTip(
_("A list of Gerber advanced parameters.\n"
"Those parameters are available only for\n"
"Advanced App. Level.")
)
self.layout.addWidget(self.adv_param_label)
def build_options(self) -> [OptionUI]:
return [
HeadingOptionUI(
label_text="Advanced Options",
label_tooltip="A list of Gerber advanced parameters.\n"
"Those parameters are available only for\n"
"Advanced App. Level."
),
CheckboxOptionUI(
option="gerber_follow",
label_text='"Follow"',
label_tooltip="Generate a 'Follow' geometry.\n"
"This means that it will cut through\n"
"the middle of the trace."
),
CheckboxOptionUI(
option="gerber_aperture_display",
label_text="Table Show/Hide",
label_tooltip="Toggle the display of the Gerber Apertures Table.\n"
"Also, on hide, it will delete all mark shapes\n"
"that are drawn on canvas."
),
SeparatorOptionUI(),
grid0 = QtWidgets.QGridLayout()
self.layout.addLayout(grid0)
RadioSetOptionUI(
option="gerber_tool_type",
label_text="Tool Type",
label_bold=True,
label_tooltip="Choose which tool to use for Gerber isolation:\n"
"'Circular' or 'V-shape'.\n"
"When the 'V-shape' is selected then the tool\n"
"diameter will depend on the chosen cut depth.",
choices=[{'label': 'Circular', 'value': 'circular'},
{'label': 'V-Shape', 'value': 'v'}]
),
DoubleSpinnerOptionUI(
option="gerber_vtipdia",
label_text="V-Tip Dia",
label_tooltip="The tip diameter for V-Shape Tool",
min_value=-99.9999, max_value=99.9999, step=0.1, decimals=self.decimals
),
SpinnerOptionUI(
option="gerber_vtipangle",
label_text="V-Tip Angle",
label_tooltip="The tip angle for V-Shape Tool.\n"
"In degrees.",
min_value=1, max_value=180, step=5
),
DoubleSpinnerOptionUI(
option="gerber_vcutz",
label_text="Cut Z",
label_tooltip="Cutting depth (negative)\n"
"below the copper surface.",
min_value=-99.9999, max_value=0.0000, step=0.1, decimals=self.decimals
),
# Follow Attribute
self.follow_cb = FCCheckBox(label=_('"Follow"'))
self.follow_cb.setToolTip(
_("Generate a 'Follow' geometry.\n"
"This means that it will cut through\n"
"the middle of the trace.")
)
grid0.addWidget(self.follow_cb, 0, 0, 1, 2)
RadioSetOptionUI(
option="gerber_iso_type",
label_text="Isolation Type",
label_tooltip="Choose how the isolation will be executed:\n"
"- 'Full' -> complete isolation of polygons\n"
"- 'Ext' -> will isolate only on the outside\n"
"- 'Int' -> will isolate only on the inside\n"
"'Exterior' isolation is almost always possible\n"
"(with the right tool) but 'Interior'\n"
"isolation can be done only when there is an opening\n"
"inside of the polygon (e.g polygon is a 'doughnut' shape).",
choices=[{'label': _('Full'), 'value': 'full'},
{'label': _('Exterior'), 'value': 'ext'},
{'label': _('Interior'), 'value': 'int'}]
),
SeparatorOptionUI(),
# Aperture Table Visibility CB
self.aperture_table_visibility_cb = FCCheckBox(label=_('Table Show/Hide'))
self.aperture_table_visibility_cb.setToolTip(
_("Toggle the display of the Gerber Apertures Table.\n"
"Also, on hide, it will delete all mark shapes\n"
"that are drawn on canvas.")
RadioSetOptionUI(
option="gerber_buffering",
label_text="Buffering",
label_tooltip="Buffering type:\n"
"- None --> best performance, fast file loading but no so good display\n"
"- Full --> slow file loading but good visuals. This is the default.\n"
"<<WARNING>>: Don't change this unless you know what you are doing !!!",
choices=[{'label': _('None'), 'value': 'no'},
{'label': _('Full'), 'value': 'full'}]
),
CheckboxOptionUI(
option="gerber_simplification",
label_text="Simplify",
label_tooltip="When checked all the Gerber polygons will be\n"
"loaded with simplification having a set tolerance.\n"
"<<WARNING>>: Don't change this unless you know what you are doing !!!"
),
DoubleSpinnerOptionUI(
option="gerber_simp_tolerance",
label_text="Tolerance",
label_tooltip="Tolerance for polygon simplification.",
min_value=0.0, max_value=0.01, step=0.0001, decimals=self.decimals+1
)
]
)
grid0.addWidget(self.aperture_table_visibility_cb, 1, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 2, 0, 1, 2)
# Tool Type
self.tool_type_label = QtWidgets.QLabel('<b>%s</b>' % _('Tool Type'))
self.tool_type_label.setToolTip(
_("Choose which tool to use for Gerber isolation:\n"
"'Circular' or 'V-shape'.\n"
"When the 'V-shape' is selected then the tool\n"
"diameter will depend on the chosen cut depth.")
)
self.tool_type_radio = RadioSet([{'label': 'Circular', 'value': 'circular'},
{'label': 'V-Shape', 'value': 'v'}])
grid0.addWidget(self.tool_type_label, 3, 0)
grid0.addWidget(self.tool_type_radio, 3, 1, 1, 2)
# Tip Dia
self.tipdialabel = QtWidgets.QLabel('%s:' % _('V-Tip Dia'))
self.tipdialabel.setToolTip(
_("The tip diameter for V-Shape Tool")
)
self.tipdia_spinner = FCDoubleSpinner()
self.tipdia_spinner.set_precision(self.decimals)
self.tipdia_spinner.set_range(-99.9999, 99.9999)
self.tipdia_spinner.setSingleStep(0.1)
self.tipdia_spinner.setWrapping(True)
grid0.addWidget(self.tipdialabel, 4, 0)
grid0.addWidget(self.tipdia_spinner, 4, 1, 1, 2)
# Tip Angle
self.tipanglelabel = QtWidgets.QLabel('%s:' % _('V-Tip Angle'))
self.tipanglelabel.setToolTip(
_("The tip angle for V-Shape Tool.\n"
"In degree.")
)
self.tipangle_spinner = FCSpinner()
self.tipangle_spinner.set_range(1, 180)
self.tipangle_spinner.set_step(5)
self.tipangle_spinner.setWrapping(True)
grid0.addWidget(self.tipanglelabel, 5, 0)
grid0.addWidget(self.tipangle_spinner, 5, 1, 1, 2)
# Cut Z
self.cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
self.cutzlabel.setToolTip(
_("Cutting depth (negative)\n"
"below the copper surface.")
)
self.cutz_spinner = FCDoubleSpinner()
self.cutz_spinner.set_precision(self.decimals)
self.cutz_spinner.set_range(-99.9999, 0.0000)
self.cutz_spinner.setSingleStep(0.1)
self.cutz_spinner.setWrapping(True)
grid0.addWidget(self.cutzlabel, 6, 0)
grid0.addWidget(self.cutz_spinner, 6, 1, 1, 2)
# Isolation Type
self.iso_type_label = QtWidgets.QLabel('%s:' % _('Isolation Type'))
self.iso_type_label.setToolTip(
_("Choose how the isolation will be executed:\n"
"- 'Full' -> complete isolation of polygons\n"
"- 'Ext' -> will isolate only on the outside\n"
"- 'Int' -> will isolate only on the inside\n"
"'Exterior' isolation is almost always possible\n"
"(with the right tool) but 'Interior'\n"
"isolation can be done only when there is an opening\n"
"inside of the polygon (e.g polygon is a 'doughnut' shape).")
)
self.iso_type_radio = RadioSet([{'label': _('Full'), 'value': 'full'},
{'label': _('Exterior'), 'value': 'ext'},
{'label': _('Interior'), 'value': 'int'}])
grid0.addWidget(self.iso_type_label, 7, 0,)
grid0.addWidget(self.iso_type_radio, 7, 1, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 8, 0, 1, 2)
# Buffering Type
buffering_label = QtWidgets.QLabel('%s:' % _('Buffering'))
buffering_label.setToolTip(
_("Buffering type:\n"
"- None --> best performance, fast file loading but no so good display\n"
"- Full --> slow file loading but good visuals. This is the default.\n"
"<<WARNING>>: Don't change this unless you know what you are doing !!!")
)
self.buffering_radio = RadioSet([{'label': _('None'), 'value': 'no'},
{'label': _('Full'), 'value': 'full'}])
grid0.addWidget(buffering_label, 9, 0)
grid0.addWidget(self.buffering_radio, 9, 1)
# Simplification
self.simplify_cb = FCCheckBox(label=_('Simplify'))
self.simplify_cb.setToolTip(
_("When checked all the Gerber polygons will be\n"
"loaded with simplification having a set tolerance.\n"
"<<WARNING>>: Don't change this unless you know what you are doing !!!")
)
grid0.addWidget(self.simplify_cb, 10, 0, 1, 2)
# Simplification tolerance
self.simplification_tol_label = QtWidgets.QLabel(_('Tolerance'))
self.simplification_tol_label.setToolTip(_("Tolerance for polygon simplification."))
self.simplification_tol_spinner = FCDoubleSpinner()
self.simplification_tol_spinner.set_precision(self.decimals + 1)
self.simplification_tol_spinner.setWrapping(True)
self.simplification_tol_spinner.setRange(0.00000, 0.01000)
self.simplification_tol_spinner.setSingleStep(0.0001)
grid0.addWidget(self.simplification_tol_label, 11, 0)
grid0.addWidget(self.simplification_tol_spinner, 11, 1)
self.ois_simplif = OptionalInputSection(
self.simplify_cb,
[
self.simplification_tol_label, self.simplification_tol_spinner
],
logic=True)
self.layout.addStretch()

View File

@@ -1,138 +1,247 @@
from flatcamGUI.preferences.OptionUI import *
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
from PyQt5 import QtWidgets
from PyQt5.QtCore import QSettings
from flatcamGUI.GUIElements import FCSpinner, FCDoubleSpinner, FCComboBox, FCEntry, RadioSet
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
import FlatCAMTranslation 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 GerberEditorPrefGroupUI(OptionsGroupUI2):
def __init__(self, decimals=4, **kwargs):
self.decimals = decimals
super().__init__(**kwargs)
class GerberEditorPrefGroupUI(OptionsGroupUI):
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
def build_options(self) -> [OptionUI]:
return [
HeadingOptionUI(
label_text="Parameters",
label_tooltip="A list of Gerber Editor parameters."
),
SpinnerOptionUI(
option="gerber_editor_sel_limit",
label_text="Selection limit",
label_tooltip="Set the number of selected Gerber geometry\n"
"items above which the utility geometry\n"
"becomes just a selection rectangle.\n"
"Increases the performance when moving a\n"
"large number of geometric elements.",
min_value=0, max_value=9999, step=1
),
SpinnerOptionUI(
option="gerber_editor_newcode",
label_text="New Aperture code",
label_tooltip="Code for the new aperture",
min_value=10, max_value=99, step=1
),
DoubleSpinnerOptionUI(
option="gerber_editor_newsize",
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
),
ComboboxOptionUI(
option="gerber_editor_newtype",
label_text="New Aperture type",
label_tooltip="Type for the new aperture.\n"
"Can be 'C', 'R' or 'O'.",
choices=['C', 'R', 'O']
),
SpinnerOptionUI(
option="gerber_editor_array_size",
label_text="Nr of pads",
label_tooltip="Specify how many pads to be in the array.",
min_value=0, max_value=9999, step=1
),
LineEntryOptionUI(
option="gerber_editor_newdim",
label_text="Aperture Dimensions",
label_tooltip="Diameters of the tools, separated by comma.\n"
"The value of the diameter has to use the dot decimals separator.\n"
"Valid values: 0.3, 1.0"
),
# Advanced Gerber Parameters
self.param_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
self.param_label.setToolTip(
_("A list of Gerber Editor parameters.")
)
self.layout.addWidget(self.param_label)
HeadingOptionUI(label_text="Linear Pad Array"),
RadioSetOptionUI(
option="gerber_editor_lin_axis",
label_text="Linear Direction",
label_tooltip="Direction on which the linear array is oriented:\n"
"- 'X' - horizontal axis \n"
"- 'Y' - vertical axis or \n"
"- 'Angle' - a custom angle for the array inclination",
choices=[{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'},
{'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 = QtWidgets.QGridLayout()
self.layout.addLayout(grid0)
HeadingOptionUI(label_text="Circular Pad Array"),
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
),
# 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"
"becomes just a selection rectangle.\n"
"Increases the performance when moving a\n"
"large number of geometric elements.")
)
self.sel_limit_entry = FCSpinner()
self.sel_limit_entry.set_range(0, 9999)
HeadingOptionUI(label_text="Buffer Tool"),
DoubleSpinnerOptionUI(
option="gerber_editor_buff_f",
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
),
grid0.addWidget(self.sel_limit_label, 0, 0)
grid0.addWidget(self.sel_limit_entry, 0, 1)
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
),
# New aperture code
self.addcode_entry_lbl = QtWidgets.QLabel('%s:' % _('New Aperture code'))
self.addcode_entry_lbl.setToolTip(
_("Code for the new aperture")
)
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.addcode_entry = FCSpinner()
self.addcode_entry.set_range(10, 99)
self.addcode_entry.setWrapping(True)
grid0.addWidget(self.addcode_entry_lbl, 1, 0)
grid0.addWidget(self.addcode_entry, 1, 1)
# New aperture size
self.addsize_entry_lbl = QtWidgets.QLabel('%s:' % _('New Aperture size'))
self.addsize_entry_lbl.setToolTip(
_("Size for the new aperture")
)
self.addsize_entry = FCDoubleSpinner()
self.addsize_entry.set_range(0, 100)
self.addsize_entry.set_precision(self.decimals)
grid0.addWidget(self.addsize_entry_lbl, 2, 0)
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"
"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'))
grid0.addWidget(self.grb_array_linear_label, 6, 0, 1, 2)
# Linear Pad Array direction
self.grb_axis_label = QtWidgets.QLabel('%s:' % _('Linear Direction'))
self.grb_axis_label.setToolTip(
_("Direction on which the linear array is oriented:\n"
"- 'X' - horizontal axis \n"
"- 'Y' - vertical axis or \n"
"- 'Angle' - a custom angle for the array inclination")
)
self.grb_axis_radio = RadioSet([{'label': _('X'), 'value': 'X'},
{'label': _('Y'), 'value': 'Y'},
{'label': _('Angle'), 'value': 'A'}])
grid0.addWidget(self.grb_axis_label, 7, 0)
grid0.addWidget(self.grb_axis_radio, 7, 1)
# Linear Pad Array pitch distance
self.grb_pitch_label = QtWidgets.QLabel('%s:' % _('Pitch'))
self.grb_pitch_label.setToolTip(
_("Pitch = Distance between elements of the array.")
)
# 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()

View File

@@ -1,5 +1,8 @@
from flatcamGUI.preferences.OptionUI import *
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
from PyQt5 import QtWidgets, QtCore
from PyQt5.QtCore import QSettings
from flatcamGUI.GUIElements import RadioSet, FCSpinner
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
import FlatCAMTranslation as fcTranslate
@@ -9,49 +12,107 @@ 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 GerberExpPrefGroupUI(OptionsGroupUI2):
def __init__(self, decimals=4, **kwargs):
self.decimals = decimals
super().__init__(**kwargs)
class GerberExpPrefGroupUI(OptionsGroupUI):
def __init__(self, decimals=4, parent=None):
super(GerberExpPrefGroupUI, self).__init__(self, parent=parent)
self.setTitle(str(_("Gerber Export")))
self.decimals = decimals
def build_options(self) -> [OptionUI]:
return [
HeadingOptionUI(
label_text="Export Options",
label_tooltip="The parameters set here are used in the file exported\n"
"when using the File -> Export -> Export Gerber menu entry."
),
RadioSetOptionUI(
option="gerber_exp_units",
label_text="Units",
label_tooltip="The units used in the Gerber file.",
choices=[{'label': _('INCH'), 'value': 'IN'},
{'label': _('MM'), 'value': 'MM'}]
),
SpinnerOptionUI(
option="gerber_exp_integer",
label_text="Int",
label_tooltip="The number of digits in the whole part of Gerber coordinates",
min_value=0, max_value=9, step=1
),
SpinnerOptionUI(
option="gerber_exp_decimals",
label_text="Decimals",
label_tooltip="The number of digits in the decimal part of Gerber coordinates",
min_value=0, max_value=9, step=1
),
RadioSetOptionUI(
option="gerber_exp_zeros",
label_text="Zeros",
label_tooltip="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.",
choices=[{'label': _('LZ'), 'value': 'L'},
{'label': _('TZ'), 'value': 'T'}]
)
]
# Plot options
self.export_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Export Options"))
self.export_options_label.setToolTip(
_("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)
form = QtWidgets.QFormLayout()
self.layout.addLayout(form)
# 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.")
)
form.addRow(self.gerber_units_label, self.gerber_units_radio)
# Gerber format
self.digits_label = QtWidgets.QLabel("%s:" % _("Int/Decimals"))
self.digits_label.setToolTip(
_("The number of digits in the whole part of the number\n"
"and in the fractional part of the number.")
)
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"
"Trailing Zeros are kept.\n"
"If TZ is checked then Trailing Zeros are removed\n"
"and Leading Zeros are kept.")
)
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,106 +1,273 @@
from flatcamGUI.preferences.OptionUI import *
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtCore import QSettings
from flatcamGUI.GUIElements import FCCheckBox, FCSpinner, RadioSet, FCEntry
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
import FlatCAMTranslation 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 GerberGenPrefGroupUI(OptionsGroupUI):
def __init__(self, decimals=4, parent=None):
# OptionsGroupUI.__init__(self, "Gerber General Preferences", parent=parent)
super(GerberGenPrefGroupUI, self).__init__(self, parent=parent)
class GerberGenPrefGroupUI(OptionsGroupUI2):
def __init__(self, decimals=4, **kwargs):
self.decimals = decimals
super().__init__(**kwargs)
self.setTitle(str(_("Gerber General")))
self.decimals = decimals
def build_options(self) -> [OptionUI]:
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(),
# ## Plot options
self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
self.layout.addWidget(self.plot_options_label)
HeadingOptionUI(
label_text="Default Values",
label_tooltip="Those values will be used as fallback values\n"
"in case that they are not found in the Gerber file."
),
RadioSetOptionUI(
option="gerber_def_units",
label_text="Units",
label_tooltip="The units used in the Gerber file.",
choices=[{'label': _('INCH'), 'value': 'IN'},
{'label': _('MM'), 'value': 'MM'}]
),
RadioSetOptionUI(
option="gerber_def_zeros",
label_text="Zeros",
label_tooltip="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.",
choices=[{'label': _('LZ'), 'value': 'L'},
{'label': _('TZ'), 'value': 'T'}]
),
SeparatorOptionUI(),
grid0 = QtWidgets.QGridLayout()
self.layout.addLayout(grid0)
CheckboxOptionUI(
option="gerber_clean_apertures",
label_text="Clean Apertures",
label_tooltip="Will remove apertures that do not have geometry\n"
"thus lowering the number of apertures in the Gerber object."
),
CheckboxOptionUI(
option="gerber_extra_buffering",
label_text="Polarity change buffer",
label_tooltip="Will apply extra buffering for the\n"
"solid geometry when we have polarity changes.\n"
"May help loading Gerber files that otherwise\n"
"do not load correctly."
),
SeparatorOptionUI(),
# Solid CB
self.solid_cb = FCCheckBox(label='%s' % _('Solid'))
self.solid_cb.setToolTip(
_("Solid color polygons.")
)
grid0.addWidget(self.solid_cb, 0, 0)
HeadingOptionUI(label_text="Gerber Object Color"),
ColorOptionUI(
option="gerber_plot_line",
label_text="Outline",
label_tooltip="Set the line color for plotted objects.",
),
ColorOptionUI(
option="gerber_plot_fill",
label_text="Fill",
label_tooltip="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."
),
ColorAlphaSliderOptionUI(
applies_to=["gerber_plot_line", "gerber_plot_fill"],
group=self,
label_text="Alpha",
label_tooltip="Set the transparency for plotted objects."
)
]
# Multicolored CB
self.multicolored_cb = FCCheckBox(label='%s' % _('M-Color'))
self.multicolored_cb.setToolTip(
_("Draw polygons in different colors.")
)
grid0.addWidget(self.multicolored_cb, 0, 1)
# Plot CB
self.plot_cb = FCCheckBox(label='%s' % _('Plot'))
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"
"Trailing Zeros are kept.\n"
"If TZ is checked then Trailing Zeros are removed\n"
"and Leading Zeros are kept.")
)
self.gerber_zeros_radio = RadioSet([{'label': _('LZ'), 'value': 'L'},
{'label': _('TZ'), 'value': 'T'}])
self.gerber_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.")
)
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"
"May help loading Gerber files that otherwise\n"
"do not load correctly.")
)
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('<b>%s</b>' % _('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.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

View File

@@ -1,5 +1,8 @@
from flatcamGUI.preferences.OptionUI import *
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
from PyQt5 import QtWidgets
from PyQt5.QtCore import QSettings
from flatcamGUI.GUIElements import FCDoubleSpinner, FCSpinner, RadioSet, FCCheckBox
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
import FlatCAMTranslation as fcTranslate
@@ -9,103 +12,176 @@ 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 GerberOptPrefGroupUI(OptionsGroupUI2):
def __init__(self, decimals=4, **kwargs):
class GerberOptPrefGroupUI(OptionsGroupUI):
def __init__(self, decimals=4, parent=None):
# OptionsGroupUI.__init__(self, "Gerber Options Preferences", parent=parent)
super(GerberOptPrefGroupUI, self).__init__(self, parent=parent)
self.decimals = decimals
super().__init__(**kwargs)
self.setTitle(str(_("Gerber Options")))
def build_options(self) -> [OptionUI]:
return [
HeadingOptionUI(
label_text="Isolation Routing",
label_tooltip="Create a Geometry object with\n"
"toolpaths to cut outside polygons."
),
DoubleSpinnerOptionUI(
option="gerber_isotooldia",
label_text="Tool dia",
label_tooltip="Diameter of the cutting tool.",
min_value=0.0, max_value=9999.9, step=0.1, decimals=self.decimals
),
SpinnerOptionUI(
option="gerber_isopasses",
label_text="# Passes",
label_tooltip="Width of the isolation gap in\n"
"number (integer) of tool widths.",
min_value=1, max_value=999, step=1
),
DoubleSpinnerOptionUI(
option="gerber_isooverlap",
label_text="Pass overlap",
label_tooltip="How much (percentage) of the tool width to overlap each tool pass.",
min_value=0.0, max_value=99.9999, step=0.1, decimals=self.decimals, suffix="%"
),
RadioSetOptionUI(
option="gerber_iso_scope",
label_text="Scope",
label_tooltip="Isolation scope. Choose what to isolate:\n"
"- 'All' -> Isolate all the polygons in the object\n"
"- 'Selection' -> Isolate a selection of polygons.",
choices=[{'label': _('All'), 'value': 'all'},
{'label': _('Selection'), 'value': 'single'}]
),
RadioSetOptionUI(
option="gerber_milling_type",
label_text="Milling Type",
label_tooltip="Milling type:\n"
"- climb / best for precision milling and to reduce tool usage\n"
"- conventional / useful when there is no backlash compensation",
choices=[{'label': _('Climb'), 'value': 'cl'},
{'label': _('Conventional'), 'value': 'cv'}]
),
CheckboxOptionUI(
option="gerber_combine_passes",
label_text="Combine Passes",
label_tooltip="Combine all passes into one object"
),
SeparatorOptionUI(),
# ## Isolation Routing
self.isolation_routing_label = QtWidgets.QLabel("<b>%s:</b>" % _("Isolation Routing"))
self.isolation_routing_label.setToolTip(
_("Create a Geometry object with\n"
"toolpaths to cut outside polygons.")
)
self.layout.addWidget(self.isolation_routing_label)
HeadingOptionUI(
label_text="Non-copper regions",
label_tooltip="Create polygons covering the\n"
"areas without copper on the PCB.\n"
"Equivalent to the inverse of this\n"
"object. Can be used to remove all\n"
"copper from a specified region."
),
DoubleSpinnerOptionUI(
option="gerber_noncoppermargin",
label_text="Boundary Margin",
label_tooltip="Specify the edge of the PCB\n"
"by drawing a box around all\n"
"objects with this minimum\n"
"distance.",
min_value=-9999, max_value=9999, step=0.1, decimals=self.decimals
),
CheckboxOptionUI(
option="gerber_noncopperrounded",
label_text="Rounded Geo",
label_tooltip="Resulting geometry will have rounded corners."
),
SeparatorOptionUI(),
# Cutting Tool Diameter
grid0 = QtWidgets.QGridLayout()
self.layout.addLayout(grid0)
HeadingOptionUI(label_text="Bounding Box"),
DoubleSpinnerOptionUI(
option="gerber_bboxmargin",
label_text="Boundary Margin",
label_tooltip="Distance of the edges of the box\n"
"to the nearest polygon.",
min_value=-9999, max_value=9999, step=0.1, decimals=self.decimals
),
CheckboxOptionUI(
option="gerber_bboxrounded",
label_text="Rounded Geo",
label_tooltip="If the bounding box is \n"
"to have rounded corners\n"
"their radius is equal to\n"
"the margin."
),
]
tdlabel = QtWidgets.QLabel('%s:' % _('Tool dia'))
tdlabel.setToolTip(
_("Diameter of the cutting tool.")
)
grid0.addWidget(tdlabel, 0, 0)
self.iso_tool_dia_entry = FCDoubleSpinner()
self.iso_tool_dia_entry.set_precision(self.decimals)
self.iso_tool_dia_entry.setSingleStep(0.1)
self.iso_tool_dia_entry.set_range(-9999, 9999)
grid0.addWidget(self.iso_tool_dia_entry, 0, 1)
# Nr of passes
passlabel = QtWidgets.QLabel('%s:' % _('# Passes'))
passlabel.setToolTip(
_("Width of the isolation gap in\n"
"number (integer) of tool widths.")
)
self.iso_width_entry = FCSpinner()
self.iso_width_entry.set_range(1, 999)
grid0.addWidget(passlabel, 1, 0)
grid0.addWidget(self.iso_width_entry, 1, 1)
# Pass overlap
overlabel = QtWidgets.QLabel('%s:' % _('Pass overlap'))
overlabel.setToolTip(
_("How much (percentage) of the tool width to overlap each tool pass.")
)
self.iso_overlap_entry = FCDoubleSpinner(suffix='%')
self.iso_overlap_entry.set_precision(self.decimals)
self.iso_overlap_entry.setWrapping(True)
self.iso_overlap_entry.setRange(0.0000, 99.9999)
self.iso_overlap_entry.setSingleStep(0.1)
grid0.addWidget(overlabel, 2, 0)
grid0.addWidget(self.iso_overlap_entry, 2, 1)
# Isolation Scope
self.iso_scope_label = QtWidgets.QLabel('%s:' % _('Scope'))
self.iso_scope_label.setToolTip(
_("Isolation scope. Choose what to isolate:\n"
"- 'All' -> Isolate all the polygons in the object\n"
"- 'Selection' -> Isolate a selection of polygons.")
)
self.iso_scope_radio = RadioSet([{'label': _('All'), 'value': 'all'},
{'label': _('Selection'), 'value': 'single'}])
grid0.addWidget(self.iso_scope_label, 3, 0)
grid0.addWidget(self.iso_scope_radio, 3, 1, 1, 2)
# Milling Type
milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type'))
milling_type_label.setToolTip(
_("Milling type:\n"
"- climb / best for precision milling and to reduce tool usage\n"
"- conventional / useful when there is no backlash compensation")
)
grid0.addWidget(milling_type_label, 4, 0)
self.milling_type_radio = RadioSet([{'label': _('Climb'), 'value': 'cl'},
{'label': _('Conventional'), 'value': 'cv'}])
grid0.addWidget(self.milling_type_radio, 4, 1)
# Combine passes
self.combine_passes_cb = FCCheckBox(label=_('Combine Passes'))
self.combine_passes_cb.setToolTip(
_("Combine all passes into one object")
)
grid0.addWidget(self.combine_passes_cb, 5, 0, 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, 2)
# ## Clear non-copper regions
self.clearcopper_label = QtWidgets.QLabel("<b>%s:</b>" % _("Non-copper regions"))
self.clearcopper_label.setToolTip(
_("Create polygons covering the\n"
"areas without copper on the PCB.\n"
"Equivalent to the inverse of this\n"
"object. Can be used to remove all\n"
"copper from a specified region.")
)
self.layout.addWidget(self.clearcopper_label)
grid1 = QtWidgets.QGridLayout()
self.layout.addLayout(grid1)
# Margin
bmlabel = QtWidgets.QLabel('%s:' % _('Boundary Margin'))
bmlabel.setToolTip(
_("Specify the edge of the PCB\n"
"by drawing a box around all\n"
"objects with this minimum\n"
"distance.")
)
grid1.addWidget(bmlabel, 0, 0)
self.noncopper_margin_entry = FCDoubleSpinner()
self.noncopper_margin_entry.set_precision(self.decimals)
self.noncopper_margin_entry.setSingleStep(0.1)
self.noncopper_margin_entry.set_range(-9999, 9999)
grid1.addWidget(self.noncopper_margin_entry, 0, 1)
# Rounded corners
self.noncopper_rounded_cb = FCCheckBox(label=_("Rounded Geo"))
self.noncopper_rounded_cb.setToolTip(
_("Resulting geometry will have rounded corners.")
)
grid1.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid1.addWidget(separator_line, 2, 0, 1, 2)
# ## Bounding box
self.boundingbox_label = QtWidgets.QLabel('<b>%s:</b>' % _('Bounding Box'))
self.layout.addWidget(self.boundingbox_label)
grid2 = QtWidgets.QGridLayout()
self.layout.addLayout(grid2)
bbmargin = QtWidgets.QLabel('%s:' % _('Boundary Margin'))
bbmargin.setToolTip(
_("Distance of the edges of the box\n"
"to the nearest polygon.")
)
self.bbmargin_entry = FCDoubleSpinner()
self.bbmargin_entry.set_precision(self.decimals)
self.bbmargin_entry.setSingleStep(0.1)
self.bbmargin_entry.set_range(-9999, 9999)
grid2.addWidget(bbmargin, 0, 0)
grid2.addWidget(self.bbmargin_entry, 0, 1)
self.bbrounded_cb = FCCheckBox(label='%s' % _("Rounded Geo"))
self.bbrounded_cb.setToolTip(
_("If the bounding box is \n"
"to have rounded corners\n"
"their radius is equal to\n"
"the margin.")
)
grid2.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
self.layout.addStretch()

View File

@@ -1,5 +1,6 @@
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
from flatcamGUI.preferences.PreferencesSectionUI import PreferencesSectionUI
from PyQt5 import QtWidgets
from PyQt5.QtCore import QSettings
from flatcamGUI.preferences.gerber.GerberEditorPrefGroupUI import GerberEditorPrefGroupUI
from flatcamGUI.preferences.gerber.GerberExpPrefGroupUI import GerberExpPrefGroupUI
from flatcamGUI.preferences.gerber.GerberAdvOptPrefGroupUI import GerberAdvOptPrefGroupUI
@@ -9,30 +10,44 @@ from flatcamGUI.preferences.gerber.GerberGenPrefGroupUI import GerberGenPrefGrou
import gettext
import FlatCAMTranslation 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 GerberPreferencesUI(PreferencesSectionUI):
def __init__(self, decimals, **kwargs):
class GerberPreferencesUI(QtWidgets.QWidget):
def __init__(self, decimals, parent=None):
QtWidgets.QWidget.__init__(self, parent=parent)
self.layout = QtWidgets.QHBoxLayout()
self.setLayout(self.layout)
self.decimals = decimals
super().__init__(**kwargs)
def build_groups(self) -> [OptionsGroupUI]:
return [
GerberGenPrefGroupUI(decimals=self.decimals),
self.gerber_gen_group = GerberGenPrefGroupUI(decimals=self.decimals)
self.gerber_gen_group.setMinimumWidth(250)
self.gerber_opt_group = GerberOptPrefGroupUI(decimals=self.decimals)
self.gerber_opt_group.setMinimumWidth(250)
self.gerber_exp_group = GerberExpPrefGroupUI(decimals=self.decimals)
self.gerber_exp_group.setMinimumWidth(230)
self.gerber_adv_opt_group = GerberAdvOptPrefGroupUI(decimals=self.decimals)
self.gerber_adv_opt_group.setMinimumWidth(200)
self.gerber_editor_group = GerberEditorPrefGroupUI(decimals=self.decimals)
self.gerber_editor_group.setMinimumWidth(200)
GerberOptPrefGroupUI(decimals=self.decimals), # FIXME vertical layout with opt and exp
GerberExpPrefGroupUI(decimals=self.decimals),
self.vlay = QtWidgets.QVBoxLayout()
self.vlay.addWidget(self.gerber_opt_group)
self.vlay.addWidget(self.gerber_exp_group)
GerberAdvOptPrefGroupUI(decimals=self.decimals),
GerberEditorPrefGroupUI(decimals=self.decimals)
]
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)
def get_tab_id(self):
return "gerber_tab"
def get_tab_label(self):
return _("GERBER")
self.layout.addStretch()