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,150 +1,246 @@
from flatcamGUI.preferences.OptionUI import *
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
from PyQt5 import QtWidgets
from PyQt5.QtCore import QSettings
from flatcamGUI.GUIElements import FCEntry, FloatEntry, FCDoubleSpinner, FCCheckBox, RadioSet, FCLabel
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 GeometryAdvOptPrefGroupUI(OptionsGroupUI2):
def __init__(self, decimals=4, **kwargs):
self.decimals = decimals
super().__init__(**kwargs)
class GeometryAdvOptPrefGroupUI(OptionsGroupUI):
def __init__(self, decimals=4, parent=None):
# OptionsGroupUI.__init__(self, "Geometry Advanced Options Preferences", parent=parent)
super(GeometryAdvOptPrefGroupUI, self).__init__(self, parent=parent)
self.setTitle(str(_("Geometry Adv. Options")))
self.decimals = decimals
def build_options(self) -> [OptionUI]:
return [
HeadingOptionUI(
label_text="Advanced Options",
label_tooltip="A list of Geometry advanced parameters.\n"
"Those parameters are available only for\n"
"Advanced App. Level."
),
LineEntryOptionUI(
option="geometry_toolchangexy",
label_text="Toolchange X-Y",
label_tooltip="Toolchange X,Y position."
),
FloatEntryOptionUI(
option="geometry_startz",
label_text="Start Z",
label_tooltip="Height of the tool just after starting the work.\n"
"Delete the value if you don't need this feature."
),
DoubleSpinnerOptionUI(
option="geometry_feedrate_rapid",
label_text="Feedrate Rapids",
label_tooltip="Cutting speed in the XY plane\n"
"(in units per minute).\n"
"This is for the rapid move G00.\n"
"It is useful only for Marlin,\n"
"ignore for any other cases.",
min_value=0, max_value=99999.9999, step=10, decimals=self.decimals
),
CheckboxOptionUI(
option="geometry_extracut",
label_text="Re-cut",
label_tooltip="In order to remove possible\n"
"copper leftovers where first cut\n"
"meet with last cut, we generate an\n"
"extended cut over the first cut section."
),
DoubleSpinnerOptionUI(
option="geometry_extracut_length",
label_text="Re-cut length",
label_tooltip="In order to remove possible\n"
"copper leftovers where first cut\n"
"meet with last cut, we generate an\n"
"extended cut over the first cut section.",
min_value=0, max_value=99999, step=0.1, decimals=self.decimals
),
DoubleSpinnerOptionUI(
option="geometry_z_pdepth",
label_text="Probe Z depth",
label_tooltip="The maximum depth that the probe is allowed\n"
"to probe. Negative value, in current units.",
min_value=-99999, max_value=0.0, step=0.1, decimals=self.decimals
),
DoubleSpinnerOptionUI(
option="geometry_feedrate_probe",
label_text="Feedrate Probe",
label_tooltip="The feedrate used while the probe is probing.",
min_value=0, max_value=99999.9999, step=0.1, decimals=self.decimals
),
RadioSetOptionUI(
option="geometry_spindledir",
label_text="Spindle direction",
label_tooltip="This sets the direction that the spindle is rotating.\n"
"It can be either:\n"
"- CW = clockwise or\n"
"- CCW = counter clockwise",
choices=[{'label': _('CW'), 'value': 'CW'},
{'label': _('CCW'), 'value': 'CCW'}]
),
CheckboxOptionUI(
option="geometry_f_plunge",
label_text="Fast Plunge",
label_tooltip="By checking this, the vertical move from\n"
"Z_Toolchange to Z_move is done with G0,\n"
"meaning the fastest speed available.\n"
"WARNING: the move is done at Toolchange X,Y coords."
),
DoubleSpinnerOptionUI(
option="geometry_segx",
label_text="Segment X size",
label_tooltip="The size of the trace segment on the X axis.\n"
"Useful for auto-leveling.\n"
"A value of 0 means no segmentation on the X axis.",
min_value=0, max_value=99999, step=0.1, decimals=self.decimals
),
DoubleSpinnerOptionUI(
option="geometry_segy",
label_text="Segment Y size",
label_tooltip="The size of the trace segment on the Y axis.\n"
"Useful for auto-leveling.\n"
"A value of 0 means no segmentation on the Y axis.",
min_value=0, max_value=99999, step=0.1, decimals=self.decimals
),
# ------------------------------
# ## Advanced Options
# ------------------------------
self.geo_label = QtWidgets.QLabel('<b>%s:</b>' % _('Advanced Options'))
self.geo_label.setToolTip(
_("A list of Geometry advanced parameters.\n"
"Those parameters are available only for\n"
"Advanced App. Level.")
)
self.layout.addWidget(self.geo_label)
HeadingOptionUI(
label_text="Area Exclusion",
label_tooltip="Area exclusion parameters.\n"
"Those parameters are available only for\n"
"Advanced App. Level."
),
CheckboxOptionUI(
option="geometry_area_exclusion",
label_text="Exclusion areas",
label_tooltip="Include exclusion areas.\n"
"In those areas the travel of the tools\n"
"is forbidden."
),
RadioSetOptionUI(
option="geometry_area_shape",
label_text="Shape",
label_tooltip="The kind of selection shape used for area selection.",
choices=[{'label': _("Square"), 'value': 'square'},
{'label': _("Polygon"), 'value': 'polygon'}]
),
RadioSetOptionUI(
option="geometry_area_strategy",
label_text="Strategy",
label_tooltip="The strategy followed when encountering an exclusion area.\n"
"Can be:\n"
"- Over -> when encountering the area, the tool will go to a set height\n"
"- Around -> will avoid the exclusion area by going around the area",
choices=[{'label': _('Over'), 'value': 'over'},
{'label': _('Around'), 'value': 'around'}]
),
DoubleSpinnerOptionUI(
option="geometry_area_overz",
label_text="Over Z",
label_tooltip="The height Z to which the tool will rise in order to avoid\n"
"an interdiction area.",
min_value=0.0, max_value=9999.9999, step=0.5, decimals=self.decimals
grid1 = QtWidgets.QGridLayout()
self.layout.addLayout(grid1)
# Toolchange X,Y
toolchange_xy_label = QtWidgets.QLabel('%s:' % _('Toolchange X-Y'))
toolchange_xy_label.setToolTip(
_("Toolchange X,Y position.")
)
grid1.addWidget(toolchange_xy_label, 1, 0)
self.toolchangexy_entry = FCEntry()
grid1.addWidget(self.toolchangexy_entry, 1, 1)
# Start move Z
startzlabel = QtWidgets.QLabel('%s:' % _('Start Z'))
startzlabel.setToolTip(
_("Height of the tool just after starting the work.\n"
"Delete the value if you don't need this feature.")
)
grid1.addWidget(startzlabel, 2, 0)
self.gstartz_entry = FloatEntry()
grid1.addWidget(self.gstartz_entry, 2, 1)
# Feedrate rapids
fr_rapid_label = QtWidgets.QLabel('%s:' % _('Feedrate Rapids'))
fr_rapid_label.setToolTip(
_("Cutting speed in the XY plane\n"
"(in units per minute).\n"
"This is for the rapid move G00.\n"
"It is useful only for Marlin,\n"
"ignore for any other cases.")
)
self.feedrate_rapid_entry = FCDoubleSpinner()
self.feedrate_rapid_entry.set_range(0, 99999.9999)
self.feedrate_rapid_entry.set_precision(self.decimals)
self.feedrate_rapid_entry.setSingleStep(0.1)
self.feedrate_rapid_entry.setWrapping(True)
grid1.addWidget(fr_rapid_label, 4, 0)
grid1.addWidget(self.feedrate_rapid_entry, 4, 1)
# End move extra cut
self.extracut_cb = FCCheckBox('%s' % _('Re-cut'))
self.extracut_cb.setToolTip(
_("In order to remove possible\n"
"copper leftovers where first cut\n"
"meet with last cut, we generate an\n"
"extended cut over the first cut section.")
)
self.e_cut_entry = FCDoubleSpinner()
self.e_cut_entry.set_range(0, 99999)
self.e_cut_entry.set_precision(self.decimals)
self.e_cut_entry.setSingleStep(0.1)
self.e_cut_entry.setWrapping(True)
self.e_cut_entry.setToolTip(
_("In order to remove possible\n"
"copper leftovers where first cut\n"
"meet with last cut, we generate an\n"
"extended cut over the first cut section.")
)
grid1.addWidget(self.extracut_cb, 5, 0)
grid1.addWidget(self.e_cut_entry, 5, 1)
# Probe depth
self.pdepth_label = QtWidgets.QLabel('%s:' % _("Probe Z depth"))
self.pdepth_label.setToolTip(
_("The maximum depth that the probe is allowed\n"
"to probe. Negative value, in current units.")
)
self.pdepth_entry = FCDoubleSpinner()
self.pdepth_entry.set_range(-99999, 0.0000)
self.pdepth_entry.set_precision(self.decimals)
self.pdepth_entry.setSingleStep(0.1)
self.pdepth_entry.setWrapping(True)
grid1.addWidget(self.pdepth_label, 6, 0)
grid1.addWidget(self.pdepth_entry, 6, 1)
# Probe feedrate
self.feedrate_probe_label = QtWidgets.QLabel('%s:' % _("Feedrate Probe"))
self.feedrate_probe_label.setToolTip(
_("The feedrate used while the probe is probing.")
)
self.feedrate_probe_entry = FCDoubleSpinner()
self.feedrate_probe_entry.set_range(0, 99999.9999)
self.feedrate_probe_entry.set_precision(self.decimals)
self.feedrate_probe_entry.setSingleStep(0.1)
self.feedrate_probe_entry.setWrapping(True)
grid1.addWidget(self.feedrate_probe_label, 7, 0)
grid1.addWidget(self.feedrate_probe_entry, 7, 1)
# Spindle direction
spindle_dir_label = QtWidgets.QLabel('%s:' % _('Spindle direction'))
spindle_dir_label.setToolTip(
_("This sets the direction that the spindle is rotating.\n"
"It can be either:\n"
"- CW = clockwise or\n"
"- CCW = counter clockwise")
)
self.spindledir_radio = RadioSet([{'label': _('CW'), 'value': 'CW'},
{'label': _('CCW'), 'value': 'CCW'}])
grid1.addWidget(spindle_dir_label, 8, 0)
grid1.addWidget(self.spindledir_radio, 8, 1)
# Fast Move from Z Toolchange
self.fplunge_cb = FCCheckBox('%s' % _('Fast Plunge'))
self.fplunge_cb.setToolTip(
_("By checking this, the vertical move from\n"
"Z_Toolchange to Z_move is done with G0,\n"
"meaning the fastest speed available.\n"
"WARNING: the move is done at Toolchange X,Y coords.")
)
grid1.addWidget(self.fplunge_cb, 9, 0, 1, 2)
# Size of trace segment on X axis
segx_label = QtWidgets.QLabel('%s:' % _("Segment X size"))
segx_label.setToolTip(
_("The size of the trace segment on the X axis.\n"
"Useful for auto-leveling.\n"
"A value of 0 means no segmentation on the X axis.")
)
self.segx_entry = FCDoubleSpinner()
self.segx_entry.set_range(0, 99999)
self.segx_entry.set_precision(self.decimals)
self.segx_entry.setSingleStep(0.1)
self.segx_entry.setWrapping(True)
grid1.addWidget(segx_label, 10, 0)
grid1.addWidget(self.segx_entry, 10, 1)
# Size of trace segment on Y axis
segy_label = QtWidgets.QLabel('%s:' % _("Segment Y size"))
segy_label.setToolTip(
_("The size of the trace segment on the Y axis.\n"
"Useful for auto-leveling.\n"
"A value of 0 means no segmentation on the Y axis.")
)
self.segy_entry = FCDoubleSpinner()
self.segy_entry.set_range(0, 99999)
self.segy_entry.set_precision(self.decimals)
self.segy_entry.setSingleStep(0.1)
self.segy_entry.setWrapping(True)
grid1.addWidget(segy_label, 11, 0)
grid1.addWidget(self.segy_entry, 11, 1)
# -----------------------------
# --- Area Exclusion ----------
# -----------------------------
self.adv_label = QtWidgets.QLabel('<b>%s:</b>' % _('Area Exclusion'))
self.adv_label.setToolTip(
_("Area exclusion parameters.\n"
"Those parameters are available only for\n"
"Advanced App. Level.")
)
grid1.addWidget(self.adv_label, 12, 0, 1, 2)
# Exclusion Area CB
self.exclusion_cb = FCCheckBox('%s:' % _("Exclusion areas"))
self.exclusion_cb.setToolTip(
_(
"Include exclusion areas.\n"
"In those areas the travel of the tools\n"
"is forbidden."
)
]
)
grid1.addWidget(self.exclusion_cb, 13, 0, 1, 2)
# Area Selection shape
self.area_shape_label = QtWidgets.QLabel('%s:' % _("Shape"))
self.area_shape_label.setToolTip(
_("The kind of selection shape used for area selection.")
)
self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
{'label': _("Polygon"), 'value': 'polygon'}])
grid1.addWidget(self.area_shape_label, 14, 0)
grid1.addWidget(self.area_shape_radio, 14, 1)
# Chose Strategy
self.strategy_label = FCLabel('%s:' % _("Strategy"))
self.strategy_label.setToolTip(_("The strategy followed when encountering an exclusion area.\n"
"Can be:\n"
"- Over -> when encountering the area, the tool will go to a set height\n"
"- Around -> will avoid the exclusion area by going around the area"))
self.strategy_radio = RadioSet([{'label': _('Over'), 'value': 'over'},
{'label': _('Around'), 'value': 'around'}])
grid1.addWidget(self.strategy_label, 15, 0)
grid1.addWidget(self.strategy_radio, 15, 1)
# Over Z
self.over_z_label = FCLabel('%s:' % _("Over Z"))
self.over_z_label.setToolTip(_("The height Z to which the tool will rise in order to avoid\n"
"an interdiction area."))
self.over_z_entry = FCDoubleSpinner()
self.over_z_entry.set_range(0.000, 9999.9999)
self.over_z_entry.set_precision(self.decimals)
grid1.addWidget(self.over_z_label, 18, 0)
grid1.addWidget(self.over_z_entry, 18, 1)
self.layout.addStretch()

View File

@@ -1,41 +1,67 @@
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, 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 GeometryEditorPrefGroupUI(OptionsGroupUI2):
def __init__(self, decimals=4, **kwargs):
self.decimals = decimals
super().__init__(**kwargs)
class GeometryEditorPrefGroupUI(OptionsGroupUI):
def __init__(self, decimals=4, parent=None):
# OptionsGroupUI.__init__(self, "Gerber Adv. Options Preferences", parent=parent)
super(GeometryEditorPrefGroupUI, self).__init__(self, parent=parent)
self.setTitle(str(_("Geometry Editor")))
self.decimals = decimals
def build_options(self) -> [OptionUI]:
return [
HeadingOptionUI(label_text="Parameters"),
SpinnerOptionUI(
option="geometry_editor_sel_limit",
label_text="Selection limit",
label_tooltip="Set the number of selected 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
),
RadioSetOptionUI(
option="geometry_editor_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'}]
)
]
# Advanced Geometry Parameters
self.param_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
self.param_label.setToolTip(
_("A list of Geometry Editor parameters.")
)
self.layout.addWidget(self.param_label)
grid0 = QtWidgets.QGridLayout()
self.layout.addLayout(grid0)
# Selection Limit
self.sel_limit_label = QtWidgets.QLabel('%s:' % _("Selection limit"))
self.sel_limit_label.setToolTip(
_("Set the number of selected 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)
grid0.addWidget(self.sel_limit_label, 0, 0)
grid0.addWidget(self.sel_limit_entry, 0, 1)
# 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")
)
self.milling_type_radio = RadioSet([{'label': _('Climb'), 'value': 'cl'},
{'label': _('Conventional'), 'value': 'cv'}])
grid0.addWidget(milling_type_label, 1, 0)
grid0.addWidget(self.milling_type_radio, 1, 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, QtGui
from PyQt5.QtCore import QSettings
from flatcamGUI.GUIElements import FCCheckBox, FCSpinner, FCEntry
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
import gettext
import FlatCAMTranslation as fcTranslate
@@ -9,46 +12,112 @@ 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 GeometryGenPrefGroupUI(OptionsGroupUI2):
def __init__(self, decimals=4, **kwargs):
self.decimals = decimals
super().__init__(**kwargs)
class GeometryGenPrefGroupUI(OptionsGroupUI):
def __init__(self, decimals=4, parent=None):
# OptionsGroupUI.__init__(self, "Geometry General Preferences", parent=parent)
super(GeometryGenPrefGroupUI, self).__init__(self, parent=parent)
self.setTitle(str(_("Geometry General")))
self.decimals = decimals
def build_options(self) -> [OptionUI]:
return [
HeadingOptionUI(label_text="Plot Options"),
CheckboxOptionUI(
option="geometry_plot",
label_text="Plot",
label_tooltip="Plot (show) this object."
),
SpinnerOptionUI(
option="geometry_circle_steps",
label_text="Circle Steps",
label_tooltip="The number of circle steps for <b>Geometry</b> \n"
"circle and arc shapes linear approximation.",
min_value=0, max_value=9999, step=1
),
HeadingOptionUI(label_text="Tools"),
LineEntryOptionUI(
option="geometry_cnctooldia",
label_text="Tools Dia",
label_color="green",
label_bold=True,
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"
),
SeparatorOptionUI(),
# ## Plot options
self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
self.layout.addWidget(self.plot_options_label)
HeadingOptionUI(label_text="Geometry Object Color"),
ColorOptionUI(
option="geometry_plot_line",
label_text="Outline",
# Plot CB
self.plot_cb = FCCheckBox(label=_('Plot'))
self.plot_cb.setToolTip(
_("Plot (show) this object.")
)
self.layout.addWidget(self.plot_cb)
label_tooltip="Set the line color for plotted objects.",
),
]
grid0 = QtWidgets.QGridLayout()
self.layout.addLayout(grid0)
grid0.setColumnStretch(0, 0)
grid0.setColumnStretch(1, 1)
# 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 <b>Geometry</b> \n"
"circle and arc shapes linear approximation.")
)
self.circle_steps_entry = FCSpinner()
self.circle_steps_entry.set_range(0, 999)
grid0.addWidget(self.circle_steps_label, 1, 0)
grid0.addWidget(self.circle_steps_entry, 1, 1)
# Tools
self.tools_label = QtWidgets.QLabel("<b>%s:</b>" % _("Tools"))
grid0.addWidget(self.tools_label, 2, 0, 1, 2)
# Tooldia
tdlabel = QtWidgets.QLabel('<b><font color="green">%s:</font></b>' % _('Tools Dia'))
tdlabel.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")
)
self.cnctooldia_entry = FCEntry()
grid0.addWidget(tdlabel, 3, 0)
grid0.addWidget(self.cnctooldia_entry, 3, 1)
separator_line = QtWidgets.QFrame()
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
grid0.addWidget(separator_line, 9, 0, 1, 2)
# Geometry Object Color
self.gerber_color_label = QtWidgets.QLabel('<b>%s</b>' % _('Geometry Object Color'))
grid0.addWidget(self.gerber_color_label, 10, 0, 1, 2)
# Plot Line Color
self.line_color_label = QtWidgets.QLabel('%s:' % _('Outline'))
self.line_color_label.setToolTip(
_("Set the line color for plotted objects.")
)
self.line_color_entry = FCEntry()
self.line_color_button = QtWidgets.QPushButton()
self.line_color_button.setFixedSize(15, 15)
self.form_box_child_2 = QtWidgets.QHBoxLayout()
self.form_box_child_2.addWidget(self.line_color_entry)
self.form_box_child_2.addWidget(self.line_color_button)
self.form_box_child_2.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
grid0.addWidget(self.line_color_label, 11, 0)
grid0.addLayout(self.form_box_child_2, 11, 1)
self.layout.addStretch()
# Setting plot colors signals
self.line_color_entry.editingFinished.connect(self.on_line_color_entry)
self.line_color_button.clicked.connect(self.on_line_color_button)
def on_line_color_entry(self):
self.app.defaults['geometry_plot_line'] = self.line_color_entry.get_value()[:7] + 'FF'
self.line_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['geometry_plot_line'])[:7])
def on_line_color_button(self):
current_color = QtGui.QColor(self.app.defaults['geometry_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.line_color_button.setStyleSheet("background-color:%s" % str(plot_line_color.name()))
new_val_line = str(plot_line_color.name()) + str(self.app.defaults['geometry_plot_line'][7:9])
self.line_color_entry.set_value(new_val_line)

View File

@@ -1,13 +1,14 @@
from PyQt5.QtCore import QSettings
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt, QSettings
from flatcamGUI.GUIElements import OptionalInputSection
from flatcamGUI.GUIElements import FCDoubleSpinner, FCCheckBox, OptionalInputSection, FCEntry, FCSpinner, FCComboBox
from flatcamGUI.preferences import machinist_setting
from flatcamGUI.preferences.OptionUI import *
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
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
@@ -19,135 +20,246 @@ else:
machinist_setting = 0
class GeometryOptPrefGroupUI(OptionsGroupUI2):
class GeometryOptPrefGroupUI(OptionsGroupUI):
def __init__(self, decimals=4, parent=None):
# OptionsGroupUI.__init__(self, "Geometry Options Preferences", parent=parent)
super(GeometryOptPrefGroupUI, self).__init__(self, parent=parent)
def __init__(self, decimals=4, **kwargs):
self.decimals = decimals
super().__init__(**kwargs)
self.setTitle(str(_("Geometry Options")))
self.pp_geometry_name_cb = self.option_dict()["geometry_ppname_g"].get_field()
self.decimals = decimals
# ------------------------------
# ## Create CNC Job
# ------------------------------
self.cncjob_label = QtWidgets.QLabel('<b>%s:</b>' % _('Create CNC Job'))
self.cncjob_label.setToolTip(
_("Create a CNC Job object\n"
"tracing the contours of this\n"
"Geometry object.")
)
self.layout.addWidget(self.cncjob_label)
grid1 = QtWidgets.QGridLayout()
self.layout.addLayout(grid1)
grid1.setColumnStretch(0, 0)
grid1.setColumnStretch(1, 1)
# Cut Z
cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
cutzlabel.setToolTip(
_("Cutting depth (negative)\n"
"below the copper surface.")
)
self.cutz_entry = FCDoubleSpinner()
if machinist_setting == 0:
self.cutz_entry.set_range(-9999.9999, 0.0000)
else:
self.cutz_entry.set_range(-9999.9999, 9999.9999)
self.cutz_entry.set_precision(self.decimals)
self.cutz_entry.setSingleStep(0.1)
self.cutz_entry.setWrapping(True)
grid1.addWidget(cutzlabel, 0, 0)
grid1.addWidget(self.cutz_entry, 0, 1)
# Multidepth CheckBox
self.multidepth_cb = FCCheckBox(label=_('Multi-Depth'))
self.multidepth_cb.setToolTip(
_(
"Use multiple passes to limit\n"
"the cut depth in each pass. Will\n"
"cut multiple times until Cut Z is\n"
"reached."
)
)
grid1.addWidget(self.multidepth_cb, 1, 0)
# Depth/pass
dplabel = QtWidgets.QLabel('%s:' % _('Depth/Pass'))
dplabel.setToolTip(
_("The depth to cut on each pass,\n"
"when multidepth is enabled.\n"
"It has positive value although\n"
"it is a fraction from the depth\n"
"which has negative value.")
)
self.depthperpass_entry = FCDoubleSpinner()
self.depthperpass_entry.set_range(0, 99999)
self.depthperpass_entry.set_precision(self.decimals)
self.depthperpass_entry.setSingleStep(0.1)
self.depthperpass_entry.setWrapping(True)
grid1.addWidget(dplabel, 2, 0)
grid1.addWidget(self.depthperpass_entry, 2, 1)
self.multidepth_cb = self.option_dict()["geometry_multidepth"].get_field()
self.depthperpass_entry = self.option_dict()["geometry_depthperpass"].get_field()
self.ois_multidepth = OptionalInputSection(self.multidepth_cb, [self.depthperpass_entry])
self.dwell_cb = self.option_dict()["geometry_dwell"].get_field()
self.dwelltime_entry = self.option_dict()["geometry_dwelltime"].get_field()
# Travel Z
travelzlabel = QtWidgets.QLabel('%s:' % _('Travel Z'))
travelzlabel.setToolTip(
_("Height of the tool when\n"
"moving without cutting.")
)
self.travelz_entry = FCDoubleSpinner()
if machinist_setting == 0:
self.travelz_entry.set_range(0.0001, 9999.9999)
else:
self.travelz_entry.set_range(-9999.9999, 9999.9999)
self.travelz_entry.set_precision(self.decimals)
self.travelz_entry.setSingleStep(0.1)
self.travelz_entry.setWrapping(True)
grid1.addWidget(travelzlabel, 3, 0)
grid1.addWidget(self.travelz_entry, 3, 1)
# Tool change:
self.toolchange_cb = FCCheckBox('%s' % _("Tool change"))
self.toolchange_cb.setToolTip(
_(
"Include tool-change sequence\n"
"in the Machine Code (Pause for tool change)."
)
)
grid1.addWidget(self.toolchange_cb, 4, 0, 1, 2)
# Toolchange Z
toolchangezlabel = QtWidgets.QLabel('%s:' % _('Toolchange Z'))
toolchangezlabel.setToolTip(
_(
"Z-axis position (height) for\n"
"tool change."
)
)
self.toolchangez_entry = FCDoubleSpinner()
if machinist_setting == 0:
self.toolchangez_entry.set_range(0.000, 9999.9999)
else:
self.toolchangez_entry.set_range(-9999.9999, 9999.9999)
self.toolchangez_entry.set_precision(self.decimals)
self.toolchangez_entry.setSingleStep(0.1)
self.toolchangez_entry.setWrapping(True)
grid1.addWidget(toolchangezlabel, 5, 0)
grid1.addWidget(self.toolchangez_entry, 5, 1)
# End move Z
endz_label = QtWidgets.QLabel('%s:' % _('End move Z'))
endz_label.setToolTip(
_("Height of the tool after\n"
"the last move at the end of the job.")
)
self.endz_entry = FCDoubleSpinner()
if machinist_setting == 0:
self.endz_entry.set_range(0.000, 9999.9999)
else:
self.endz_entry.set_range(-9999.9999, 9999.9999)
self.endz_entry.set_precision(self.decimals)
self.endz_entry.setSingleStep(0.1)
self.endz_entry.setWrapping(True)
grid1.addWidget(endz_label, 6, 0)
grid1.addWidget(self.endz_entry, 6, 1)
# End Move X,Y
endmove_xy_label = QtWidgets.QLabel('%s:' % _('End move X,Y'))
endmove_xy_label.setToolTip(
_("End move X,Y position. In format (x,y).\n"
"If no value is entered then there is no move\n"
"on X,Y plane at the end of the job.")
)
self.endxy_entry = FCEntry()
grid1.addWidget(endmove_xy_label, 7, 0)
grid1.addWidget(self.endxy_entry, 7, 1)
# Feedrate X-Y
frlabel = QtWidgets.QLabel('%s:' % _('Feedrate X-Y'))
frlabel.setToolTip(
_("Cutting speed in the XY\n"
"plane in units per minute")
)
self.cncfeedrate_entry = FCDoubleSpinner()
self.cncfeedrate_entry.set_range(0, 99999.9999)
self.cncfeedrate_entry.set_precision(self.decimals)
self.cncfeedrate_entry.setSingleStep(0.1)
self.cncfeedrate_entry.setWrapping(True)
grid1.addWidget(frlabel, 8, 0)
grid1.addWidget(self.cncfeedrate_entry, 8, 1)
# Feedrate Z (Plunge)
frz_label = QtWidgets.QLabel('%s:' % _('Feedrate Z'))
frz_label.setToolTip(
_("Cutting speed in the XY\n"
"plane in units per minute.\n"
"It is called also Plunge.")
)
self.feedrate_z_entry = FCDoubleSpinner()
self.feedrate_z_entry.set_range(0, 99999.9999)
self.feedrate_z_entry.set_precision(self.decimals)
self.feedrate_z_entry.setSingleStep(0.1)
self.feedrate_z_entry.setWrapping(True)
grid1.addWidget(frz_label, 9, 0)
grid1.addWidget(self.feedrate_z_entry, 9, 1)
# Spindle Speed
spdlabel = QtWidgets.QLabel('%s:' % _('Spindle speed'))
spdlabel.setToolTip(
_(
"Speed of the spindle in RPM (optional).\n"
"If LASER preprocessor is used,\n"
"this value is the power of laser."
)
)
self.cncspindlespeed_entry = FCSpinner()
self.cncspindlespeed_entry.set_range(0, 1000000)
self.cncspindlespeed_entry.set_step(100)
grid1.addWidget(spdlabel, 10, 0)
grid1.addWidget(self.cncspindlespeed_entry, 10, 1)
# Dwell
self.dwell_cb = FCCheckBox(label='%s' % _('Enable Dwell'))
self.dwell_cb.setToolTip(
_("Pause to allow the spindle to reach its\n"
"speed before cutting.")
)
dwelltime = QtWidgets.QLabel('%s:' % _('Duration'))
dwelltime.setToolTip(
_("Number of time units for spindle to dwell.")
)
self.dwelltime_entry = FCDoubleSpinner()
self.dwelltime_entry.set_range(0, 99999)
self.dwelltime_entry.set_precision(self.decimals)
self.dwelltime_entry.setSingleStep(0.1)
self.dwelltime_entry.setWrapping(True)
grid1.addWidget(self.dwell_cb, 11, 0)
grid1.addWidget(dwelltime, 12, 0)
grid1.addWidget(self.dwelltime_entry, 12, 1)
self.ois_dwell = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
def build_options(self) -> [OptionUI]:
return [
HeadingOptionUI(
label_text="Create CNC Job",
label_tooltip="Create a CNC Job object\n"
"tracing the contours of this\n"
"Geometry object."
),
DoubleSpinnerOptionUI(
option="geometry_cutz",
label_text="Cut Z",
label_tooltip="Cutting depth (negative)\n"
"below the copper surface.",
min_value=-9999.9999, max_value=(9999.999 if machinist_setting else 0.0),
decimals=self.decimals, step=0.1
),
CheckboxOptionUI(
option="geometry_multidepth",
label_text="Multi-Depth",
label_tooltip="Use multiple passes to limit\n"
"the cut depth in each pass. Will\n"
"cut multiple times until Cut Z is\n"
"reached."
),
DoubleSpinnerOptionUI(
option="geometry_depthperpass",
label_text="Depth/Pass",
label_tooltip="The depth to cut on each pass,\n"
"when multidepth is enabled.\n"
"It has positive value although\n"
"it is a fraction from the depth\n"
"which has negative value.",
min_value=0, max_value=99999, step=0.1, decimals=self.decimals
# preprocessor selection
pp_label = QtWidgets.QLabel('%s:' % _("Preprocessor"))
pp_label.setToolTip(
_("The Preprocessor file that dictates\n"
"the Machine Code (like GCode, RML, HPGL) output.")
)
self.pp_geometry_name_cb = FCComboBox()
self.pp_geometry_name_cb.setFocusPolicy(Qt.StrongFocus)
),
DoubleSpinnerOptionUI(
option="geometry_travelz",
label_text="Travel Z",
label_tooltip="Height of the tool when\n"
"moving without cutting.",
min_value=(-9999.9999 if machinist_setting else 0.0001), max_value=9999.9999,
step=0.1, decimals=self.decimals
),
CheckboxOptionUI(
option="geometry_toolchange",
label_text="Tool change",
label_tooltip="Include tool-change sequence\n"
"in the Machine Code (Pause for tool change)."
),
DoubleSpinnerOptionUI(
option="geometry_toolchangez",
label_text="Toolchange Z",
label_tooltip="Z-axis position (height) for\n"
"tool change.",
min_value=(-9999.9999 if machinist_setting else 0.0), max_value=9999.9999,
step=0.1, decimals=self.decimals
),
DoubleSpinnerOptionUI(
option="geometry_endz",
label_text="End move Z",
label_tooltip="Height of the tool after\n"
"the last move at the end of the job.",
min_value=(-9999.9999 if machinist_setting else 0.0), max_value=9999.9999,
step=0.1, decimals=self.decimals
),
LineEntryOptionUI(
option="geometry_endxy",
label_text="End move X,Y",
label_tooltip="End move X,Y position. In format (x,y).\n"
"If no value is entered then there is no move\n"
"on X,Y plane at the end of the job."
),
DoubleSpinnerOptionUI(
option="geometry_feedrate",
label_text="Feedrate X-Y",
label_tooltip="Cutting speed in the XY\n"
"plane in units per minute",
min_value=0, max_value=99999.9999, step=0.1, decimals=self.decimals
),
DoubleSpinnerOptionUI(
option="geometry_feedrate_z",
label_text="Feedrate Z",
label_tooltip="Cutting speed in the XY\n"
"plane in units per minute.\n"
"It is called also Plunge.",
min_value=0, max_value=99999.9999, step=0.1, decimals=self.decimals
),
SpinnerOptionUI(
option="geometry_spindlespeed",
label_text="Spindle speed",
label_tooltip="Speed of the spindle in RPM (optional).\n"
"If LASER preprocessor is used,\n"
"this value is the power of laser.",
min_value=0, max_value=1000000, step=100
),
CheckboxOptionUI(
option="geometry_dwell",
label_text="Enable Dwell",
label_tooltip="Pause to allow the spindle to reach its\n"
"speed before cutting."
),
DoubleSpinnerOptionUI(
option="geometry_dwelltime",
label_text="Duration",
label_tooltip="Number of time units for spindle to dwell.",
min_value=0, max_value=999999, step=0.5, decimals=self.decimals
),
ComboboxOptionUI(
option="geometry_ppname_g",
label_text="Preprocessor",
label_tooltip="The Preprocessor file that dictates\n"
"the Machine Code (like GCode, RML, HPGL) output.",
choices=[] # Populated in App (FIXME)
)
]
grid1.addWidget(pp_label, 13, 0)
grid1.addWidget(self.pp_geometry_name_cb, 13, 1)
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.geometry.GeometryEditorPrefGroupUI import GeometryEditorPrefGroupUI
from flatcamGUI.preferences.geometry.GeometryAdvOptPrefGroupUI import GeometryAdvOptPrefGroupUI
from flatcamGUI.preferences.geometry.GeometryOptPrefGroupUI import GeometryOptPrefGroupUI
@@ -8,30 +9,38 @@ from flatcamGUI.preferences.geometry.GeometryGenPrefGroupUI import GeometryGenPr
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 GeometryPreferencesUI(PreferencesSectionUI):
def __init__(self, decimals, **kwargs):
class GeometryPreferencesUI(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
# FIXME: remove the need for external access to geometry_opt_group
self.geometry_gen_group = GeometryGenPrefGroupUI(decimals=self.decimals)
self.geometry_gen_group.setMinimumWidth(220)
self.geometry_opt_group = GeometryOptPrefGroupUI(decimals=self.decimals)
super().__init__(**kwargs)
self.geometry_opt_group.setMinimumWidth(300)
self.geometry_adv_opt_group = GeometryAdvOptPrefGroupUI(decimals=self.decimals)
self.geometry_adv_opt_group.setMinimumWidth(270)
self.geometry_editor_group = GeometryEditorPrefGroupUI(decimals=self.decimals)
self.geometry_editor_group.setMinimumWidth(250)
def build_groups(self) -> [OptionsGroupUI]:
return [
GeometryGenPrefGroupUI(decimals=self.decimals),
self.geometry_opt_group,
GeometryAdvOptPrefGroupUI(decimals=self.decimals),
GeometryEditorPrefGroupUI(decimals=self.decimals)
]
def get_tab_id(self):
return "geometry_tab"
def get_tab_label(self):
return _("GEOMETRY")
self.layout.addWidget(self.geometry_gen_group)
self.layout.addWidget(self.geometry_opt_group)
self.layout.addWidget(self.geometry_adv_opt_group)
self.layout.addWidget(self.geometry_editor_group)
self.layout.addStretch()