Geometry options

This commit is contained in:
David Robertson
2020-05-09 17:43:53 +01:00
parent 805a1567d8
commit 6a6674c368
2 changed files with 126 additions and 253 deletions

View File

@@ -142,21 +142,6 @@ class PreferencesUIManager:
self.ui.excellon_defaults_form.excellon_editor_group.slot_array_circular_angle_entry, self.ui.excellon_defaults_form.excellon_editor_group.slot_array_circular_angle_entry,
# Geometry Options
"geometry_cutz": self.ui.geometry_defaults_form.geometry_opt_group.cutz_entry,
"geometry_travelz": self.ui.geometry_defaults_form.geometry_opt_group.travelz_entry,
"geometry_feedrate": self.ui.geometry_defaults_form.geometry_opt_group.cncfeedrate_entry,
"geometry_feedrate_z": self.ui.geometry_defaults_form.geometry_opt_group.feedrate_z_entry,
"geometry_spindlespeed": self.ui.geometry_defaults_form.geometry_opt_group.cncspindlespeed_entry,
"geometry_dwell": self.ui.geometry_defaults_form.geometry_opt_group.dwell_cb,
"geometry_dwelltime": self.ui.geometry_defaults_form.geometry_opt_group.dwelltime_entry,
"geometry_ppname_g": self.ui.geometry_defaults_form.geometry_opt_group.pp_geometry_name_cb,
"geometry_toolchange": self.ui.geometry_defaults_form.geometry_opt_group.toolchange_cb,
"geometry_toolchangez": self.ui.geometry_defaults_form.geometry_opt_group.toolchangez_entry,
"geometry_endz": self.ui.geometry_defaults_form.geometry_opt_group.endz_entry,
"geometry_endxy": self.ui.geometry_defaults_form.geometry_opt_group.endxy_entry,
"geometry_depthperpass": self.ui.geometry_defaults_form.geometry_opt_group.depthperpass_entry,
"geometry_multidepth": self.ui.geometry_defaults_form.geometry_opt_group.multidepth_cb,
# Geometry Advanced Options # Geometry Advanced Options
"geometry_toolchangexy": self.ui.geometry_defaults_form.geometry_adv_opt_group.toolchangexy_entry, "geometry_toolchangexy": self.ui.geometry_defaults_form.geometry_adv_opt_group.toolchangexy_entry,

View File

@@ -1,14 +1,13 @@
from PyQt5 import QtWidgets
from PyQt5.QtCore import Qt, QSettings from PyQt5.QtCore import Qt, QSettings
from flatcamGUI.GUIElements import FCDoubleSpinner, FCCheckBox, OptionalInputSection, FCEntry, FCSpinner, FCComboBox from flatcamGUI.GUIElements import OptionalInputSection
from flatcamGUI.preferences import machinist_setting from flatcamGUI.preferences import machinist_setting
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI from flatcamGUI.preferences.OptionUI import *
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
import gettext import gettext
import FlatCAMTranslation as fcTranslate import FlatCAMTranslation as fcTranslate
import builtins import builtins
fcTranslate.apply_language('strings') fcTranslate.apply_language('strings')
if '_' not in builtins.__dict__: if '_' not in builtins.__dict__:
_ = gettext.gettext _ = gettext.gettext
@@ -20,246 +19,135 @@ else:
machinist_setting = 0 machinist_setting = 0
class GeometryOptPrefGroupUI(OptionsGroupUI): class GeometryOptPrefGroupUI(OptionsGroupUI2):
def __init__(self, decimals=4, parent=None):
# OptionsGroupUI.__init__(self, "Geometry Options Preferences", parent=parent)
super(GeometryOptPrefGroupUI, self).__init__(self, parent=parent)
self.setTitle(str(_("Geometry Options"))) def __init__(self, decimals=4, **kwargs):
self.decimals = decimals 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.multidepth_cb = self.option_dict()["geometry_multidepth"].get_field()
# ## Create CNC Job self.depthperpass_entry = self.option_dict()["geometry_depthperpass"].get_field()
# ------------------------------ self.ois_multidepth = OptionalInputSection(self.multidepth_cb, [self.depthperpass_entry])
self.cncjob_label = QtWidgets.QLabel('<b>%s:</b>' % _('Create CNC Job'))
self.cncjob_label.setToolTip( self.dwell_cb = self.option_dict()["geometry_dwell"].get_field()
_("Create a CNC Job object\n" self.dwelltime_entry = self.option_dict()["geometry_dwelltime"].get_field()
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" "tracing the contours of this\n"
"Geometry object.") "Geometry object."
) ),
self.layout.addWidget(self.cncjob_label) DoubleSpinnerOptionUI(
option="geometry_cutz",
grid1 = QtWidgets.QGridLayout() label_text="Cut Z",
self.layout.addLayout(grid1) label_tooltip="Cutting depth (negative)\n"
grid1.setColumnStretch(0, 0) "below the copper surface.",
grid1.setColumnStretch(1, 1) min_value=-9999.9999, max_value=(9999.999 if machinist_setting else 0.0),
decimals=self.decimals, step=0.1
# Cut Z ),
cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z')) CheckboxOptionUI(
cutzlabel.setToolTip( option="geometry_multidepth",
_("Cutting depth (negative)\n" label_text="Multi-Depth",
"below the copper surface.") label_tooltip="Use multiple passes to limit\n"
)
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" "the cut depth in each pass. Will\n"
"cut multiple times until Cut Z is\n" "cut multiple times until Cut Z is\n"
"reached." "reached."
) ),
) DoubleSpinnerOptionUI(
grid1.addWidget(self.multidepth_cb, 1, 0) option="geometry_depthperpass",
label_text="Depth/Pass",
# Depth/pass label_tooltip="The depth to cut on each pass,\n"
dplabel = QtWidgets.QLabel('%s:' % _('Depth/Pass'))
dplabel.setToolTip(
_("The depth to cut on each pass,\n"
"when multidepth is enabled.\n" "when multidepth is enabled.\n"
"It has positive value although\n" "It has positive value although\n"
"it is a fraction from the depth\n" "it is a fraction from the depth\n"
"which has negative value.") "which has negative value.",
) min_value=0, max_value=99999, step=0.1, decimals=self.decimals
self.depthperpass_entry = FCDoubleSpinner() ),
self.depthperpass_entry.set_range(0, 99999) DoubleSpinnerOptionUI(
self.depthperpass_entry.set_precision(self.decimals) option="geometry_travelz",
self.depthperpass_entry.setSingleStep(0.1) label_text="Travel Z",
self.depthperpass_entry.setWrapping(True) label_tooltip="Height of the tool when\n"
"moving without cutting.",
grid1.addWidget(dplabel, 2, 0) min_value=(-9999.9999 if machinist_setting else 0.0001), max_value=9999.9999,
grid1.addWidget(self.depthperpass_entry, 2, 1) step=0.1, decimals=self.decimals
),
self.ois_multidepth = OptionalInputSection(self.multidepth_cb, [self.depthperpass_entry]) CheckboxOptionUI(
option="geometry_toolchange",
# Travel Z label_text="Tool change",
travelzlabel = QtWidgets.QLabel('%s:' % _('Travel Z')) label_tooltip="Include tool-change sequence\n"
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)." "in the Machine Code (Pause for tool change)."
) ),
) DoubleSpinnerOptionUI(
grid1.addWidget(self.toolchange_cb, 4, 0, 1, 2) option="geometry_toolchangez",
label_text="Toolchange Z",
# Toolchange Z label_tooltip="Z-axis position (height) for\n"
toolchangezlabel = QtWidgets.QLabel('%s:' % _('Toolchange Z')) "tool change.",
toolchangezlabel.setToolTip( min_value=(-9999.9999 if machinist_setting else 0.0), max_value=9999.9999,
_( step=0.1, decimals=self.decimals
"Z-axis position (height) for\n" ),
"tool change." DoubleSpinnerOptionUI(
) option="geometry_endz",
) label_text="End move Z",
self.toolchangez_entry = FCDoubleSpinner() label_tooltip="Height of the tool after\n"
"the last move at the end of the job.",
if machinist_setting == 0: min_value=(-9999.9999 if machinist_setting else 0.0), max_value=9999.9999,
self.toolchangez_entry.set_range(0.000, 9999.9999) step=0.1, decimals=self.decimals
else: ),
self.toolchangez_entry.set_range(-9999.9999, 9999.9999) LineEntryOptionUI(
option="geometry_endxy",
self.toolchangez_entry.set_precision(self.decimals) label_text="End move X,Y",
self.toolchangez_entry.setSingleStep(0.1) label_tooltip="End move X,Y position. In format (x,y).\n"
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" "If no value is entered then there is no move\n"
"on X,Y plane at the end of the job.") "on X,Y plane at the end of the job."
) ),
self.endxy_entry = FCEntry() DoubleSpinnerOptionUI(
option="geometry_feedrate",
grid1.addWidget(endmove_xy_label, 7, 0) label_text="Feedrate X-Y",
grid1.addWidget(self.endxy_entry, 7, 1) label_tooltip="Cutting speed in the XY\n"
"plane in units per minute",
# Feedrate X-Y min_value=0, max_value=99999.9999, step=0.1, decimals=self.decimals
frlabel = QtWidgets.QLabel('%s:' % _('Feedrate X-Y')) ),
frlabel.setToolTip( DoubleSpinnerOptionUI(
_("Cutting speed in the XY\n" option="geometry_feedrate_z",
"plane in units per minute") label_text="Feedrate Z",
) label_tooltip="Cutting speed in the XY\n"
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" "plane in units per minute.\n"
"It is called also Plunge.") "It is called also Plunge.",
) min_value=0, max_value=99999.9999, step=0.1, decimals=self.decimals
self.feedrate_z_entry = FCDoubleSpinner() ),
self.feedrate_z_entry.set_range(0, 99999.9999) SpinnerOptionUI(
self.feedrate_z_entry.set_precision(self.decimals) option="geometry_spindlespeed",
self.feedrate_z_entry.setSingleStep(0.1) label_text="Spindle speed",
self.feedrate_z_entry.setWrapping(True) label_tooltip="Speed of the spindle in RPM (optional).\n"
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" "If LASER preprocessor is used,\n"
"this value is the power of laser." "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)
) )
) ]
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])
# 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)
grid1.addWidget(pp_label, 13, 0)
grid1.addWidget(self.pp_geometry_name_cb, 13, 1)
self.layout.addStretch()