Gerber opt pref group

This commit is contained in:
David Robertson
2020-05-07 02:56:22 +01:00
parent 98675e7f06
commit 21756bea9c
3 changed files with 98 additions and 185 deletions

View File

@@ -188,15 +188,16 @@ class SpinnerOptionUI(BasicOptionUI):
class DoubleSpinnerOptionUI(BasicOptionUI): class DoubleSpinnerOptionUI(BasicOptionUI):
def __init__(self, option: str, label_text: str, step: float, decimals: int, min_value=None, max_value=None, **kwargs): def __init__(self, option: str, label_text: str, step: float, decimals: int, min_value=None, max_value=None, suffix=None, **kwargs):
self.min_value = min_value self.min_value = min_value
self.max_value = max_value self.max_value = max_value
self.step = step self.step = step
self.suffix = suffix
self.decimals = decimals self.decimals = decimals
super().__init__(option=option, label_text=label_text, **kwargs) super().__init__(option=option, label_text=label_text, **kwargs)
def build_entry_widget(self) -> QtWidgets.QWidget: def build_entry_widget(self) -> QtWidgets.QWidget:
entry = FCDoubleSpinner() entry = FCDoubleSpinner(suffix=self.suffix)
entry.set_precision(self.decimals) entry.set_precision(self.decimals)
entry.setSingleStep(self.step) entry.setSingleStep(self.step)
if self.min_value is None: if self.min_value is None:

View File

@@ -49,18 +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 Options
"gerber_isotooldia": self.ui.gerber_defaults_form.gerber_opt_group.iso_tool_dia_entry,
"gerber_isopasses": self.ui.gerber_defaults_form.gerber_opt_group.iso_width_entry,
"gerber_isooverlap": self.ui.gerber_defaults_form.gerber_opt_group.iso_overlap_entry,
"gerber_combine_passes": self.ui.gerber_defaults_form.gerber_opt_group.combine_passes_cb,
"gerber_iso_scope": self.ui.gerber_defaults_form.gerber_opt_group.iso_scope_radio,
"gerber_milling_type": self.ui.gerber_defaults_form.gerber_opt_group.milling_type_radio,
"gerber_noncoppermargin": self.ui.gerber_defaults_form.gerber_opt_group.noncopper_margin_entry,
"gerber_noncopperrounded": self.ui.gerber_defaults_form.gerber_opt_group.noncopper_rounded_cb,
"gerber_bboxmargin": self.ui.gerber_defaults_form.gerber_opt_group.bbmargin_entry,
"gerber_bboxrounded": self.ui.gerber_defaults_form.gerber_opt_group.bbrounded_cb,
# Gerber Advanced Options # Gerber Advanced Options
"gerber_aperture_display": self.ui.gerber_defaults_form.gerber_adv_opt_group.aperture_table_visibility_cb, "gerber_aperture_display": self.ui.gerber_defaults_form.gerber_adv_opt_group.aperture_table_visibility_cb,
# "gerber_aperture_scale_factor": self.ui.gerber_defaults_form.gerber_adv_opt_group.scale_aperture_entry, # "gerber_aperture_scale_factor": self.ui.gerber_defaults_form.gerber_adv_opt_group.scale_aperture_entry,

View File

@@ -1,8 +1,5 @@
from PyQt5 import QtWidgets from flatcamGUI.preferences.OptionUI import *
from PyQt5.QtCore import QSettings from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
from flatcamGUI.GUIElements import FCDoubleSpinner, FCSpinner, RadioSet, FCCheckBox
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext import gettext
import FlatCAMTranslation as fcTranslate import FlatCAMTranslation as fcTranslate
@@ -12,176 +9,103 @@ 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 GerberOptPrefGroupUI(OptionsGroupUI2):
class GerberOptPrefGroupUI(OptionsGroupUI): def __init__(self, decimals=4, **kwargs):
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 self.decimals = decimals
super().__init__(**kwargs)
self.setTitle(str(_("Gerber Options"))) self.setTitle(str(_("Gerber Options")))
# ## Isolation Routing def build_options(self) -> [OptionUI]:
self.isolation_routing_label = QtWidgets.QLabel("<b>%s:</b>" % _("Isolation Routing")) return [
self.isolation_routing_label.setToolTip( HeadingOptionUI(
_("Create a Geometry object with\n" label_text="Isolation Routing",
"toolpaths to cut outside polygons.") label_tooltip="Create a Geometry object with\n"
) "toolpaths to cut outside polygons."
self.layout.addWidget(self.isolation_routing_label) ),
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(),
# Cutting Tool Diameter HeadingOptionUI(
grid0 = QtWidgets.QGridLayout() label_text="Non-copper regions",
self.layout.addLayout(grid0) 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(),
tdlabel = QtWidgets.QLabel('%s:' % _('Tool dia')) HeadingOptionUI(label_text="Bounding Box"),
tdlabel.setToolTip( DoubleSpinnerOptionUI(
_("Diameter of the cutting tool.") option="gerber_bboxmargin",
) label_text="Boundary Margin",
grid0.addWidget(tdlabel, 0, 0) label_tooltip="Distance of the edges of the box\n"
self.iso_tool_dia_entry = FCDoubleSpinner() "to the nearest polygon.",
self.iso_tool_dia_entry.set_precision(self.decimals) min_value=-9999, max_value=9999, step=0.1, decimals=self.decimals
self.iso_tool_dia_entry.setSingleStep(0.1) ),
self.iso_tool_dia_entry.set_range(-9999, 9999) CheckboxOptionUI(
option="gerber_bboxrounded",
grid0.addWidget(self.iso_tool_dia_entry, 0, 1) label_text="Rounded Geo",
label_tooltip="If the bounding box is \n"
# Nr of passes "to have rounded corners\n"
passlabel = QtWidgets.QLabel('%s:' % _('# Passes')) "their radius is equal to\n"
passlabel.setToolTip( "the margin."
_("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()