CNC job options
This commit is contained in:
parent
17eaa6e8ad
commit
5304cd1ac9
|
@ -1,8 +1,10 @@
|
||||||
from typing import Union, Sequence, List
|
from typing import Union, Sequence, List
|
||||||
|
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets, QtGui
|
||||||
|
from PyQt5.QtCore import QSettings
|
||||||
|
|
||||||
from flatcamGUI.GUIElements import RadioSet, FCCheckBox, FCButton, FCComboBox, FCEntry, FCSpinner, FCColorEntry, \
|
from flatcamGUI.GUIElements import RadioSet, FCCheckBox, FCButton, FCComboBox, FCEntry, FCSpinner, FCColorEntry, \
|
||||||
FCSliderWithSpinner, FCDoubleSpinner, FloatEntry
|
FCSliderWithSpinner, FCDoubleSpinner, FloatEntry, FCTextArea
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
import FlatCAMTranslation as fcTranslate
|
import FlatCAMTranslation as fcTranslate
|
||||||
|
@ -67,13 +69,13 @@ class LineEntryOptionUI(BasicOptionUI):
|
||||||
def build_entry_widget(self) -> QtWidgets.QWidget:
|
def build_entry_widget(self) -> QtWidgets.QWidget:
|
||||||
return FCEntry()
|
return FCEntry()
|
||||||
|
|
||||||
|
|
||||||
# Not sure why this is needed over DoubleSpinnerOptionUI
|
# Not sure why this is needed over DoubleSpinnerOptionUI
|
||||||
class FloatEntryOptionUI(BasicOptionUI):
|
class FloatEntryOptionUI(BasicOptionUI):
|
||||||
def build_entry_widget(self) -> QtWidgets.QWidget:
|
def build_entry_widget(self) -> QtWidgets.QWidget:
|
||||||
return FloatEntry()
|
return FloatEntry()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class RadioSetOptionUI(BasicOptionUI):
|
class RadioSetOptionUI(BasicOptionUI):
|
||||||
|
|
||||||
def __init__(self, option: str, label_text: str, choices: list, orientation='horizontal', **kwargs):
|
def __init__(self, option: str, label_text: str, choices: list, orientation='horizontal', **kwargs):
|
||||||
|
@ -85,6 +87,44 @@ class RadioSetOptionUI(BasicOptionUI):
|
||||||
return RadioSet(choices=self.choices, orientation=self.orientation)
|
return RadioSet(choices=self.choices, orientation=self.orientation)
|
||||||
|
|
||||||
|
|
||||||
|
class TextAreaOptionUI(OptionUI):
|
||||||
|
|
||||||
|
def __init__(self, option: str, label_text: str, label_tooltip: str):
|
||||||
|
super().__init__(option=option)
|
||||||
|
self.label_text = label_text
|
||||||
|
self.label_tooltip = label_tooltip
|
||||||
|
self.label_widget = self.build_label_widget()
|
||||||
|
self.textarea_widget = self.build_textarea_widget()
|
||||||
|
|
||||||
|
def build_label_widget(self):
|
||||||
|
label = QtWidgets.QLabel(_(self.label_text))
|
||||||
|
label.setToolTip(_(self.label_tooltip))
|
||||||
|
return label
|
||||||
|
|
||||||
|
def build_textarea_widget(self):
|
||||||
|
textarea = FCTextArea()
|
||||||
|
textarea.setPlaceholderText(_(self.label_tooltip))
|
||||||
|
|
||||||
|
qsettings = QSettings("Open Source", "FlatCAM")
|
||||||
|
if qsettings.contains("textbox_font_size"):
|
||||||
|
tb_fsize = qsettings.value('textbox_font_size', type=int)
|
||||||
|
else:
|
||||||
|
tb_fsize = 10
|
||||||
|
font = QtGui.QFont()
|
||||||
|
font.setPointSize(tb_fsize)
|
||||||
|
textarea.setFont(font)
|
||||||
|
|
||||||
|
return textarea
|
||||||
|
|
||||||
|
def get_field(self):
|
||||||
|
return self.textarea_widget
|
||||||
|
|
||||||
|
def add_to_grid(self, grid: QtWidgets.QGridLayout, row: int) -> int:
|
||||||
|
grid.addWidget(self.label_widget, row, 0, 1, 3)
|
||||||
|
grid.addWidget(self.textarea_widget, row+1, 0, 1, 3)
|
||||||
|
return 2
|
||||||
|
|
||||||
|
|
||||||
class CheckboxOptionUI(OptionUI):
|
class CheckboxOptionUI(OptionUI):
|
||||||
|
|
||||||
def __init__(self, option: str, label_text: str, label_tooltip: str):
|
def __init__(self, option: str, label_text: str, label_tooltip: str):
|
||||||
|
|
|
@ -142,11 +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,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# CNC Job Options
|
|
||||||
"cncjob_prepend": self.ui.cncjob_defaults_form.cncjob_opt_group.prepend_text,
|
|
||||||
"cncjob_append": self.ui.cncjob_defaults_form.cncjob_opt_group.append_text,
|
|
||||||
|
|
||||||
# CNC Job Advanced Options
|
# CNC Job Advanced Options
|
||||||
"cncjob_toolchange_macro": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.toolchange_text,
|
"cncjob_toolchange_macro": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.toolchange_text,
|
||||||
"cncjob_toolchange_macro_enable": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.toolchange_cb,
|
"cncjob_toolchange_macro_enable": self.ui.cncjob_defaults_form.cncjob_adv_opt_group.toolchange_cb,
|
||||||
|
|
|
@ -1,80 +1,39 @@
|
||||||
from PyQt5 import QtWidgets, QtGui
|
from flatcamGUI.preferences.OptionUI import *
|
||||||
from PyQt5.QtCore import QSettings
|
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
|
||||||
|
|
||||||
from flatcamGUI.GUIElements import FCTextArea
|
|
||||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
|
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
import FlatCAMTranslation as fcTranslate
|
import FlatCAMTranslation as fcTranslate
|
||||||
import builtins
|
import builtins
|
||||||
|
|
||||||
fcTranslate.apply_language('strings')
|
fcTranslate.apply_language('strings')
|
||||||
if '_' not in builtins.__dict__:
|
if '_' not in builtins.__dict__:
|
||||||
_ = gettext.gettext
|
_ = gettext.gettext
|
||||||
|
|
||||||
settings = QSettings("Open Source", "FlatCAM")
|
|
||||||
if settings.contains("machinist"):
|
|
||||||
machinist_setting = settings.value('machinist', type=int)
|
|
||||||
else:
|
|
||||||
machinist_setting = 0
|
|
||||||
|
|
||||||
|
class CNCJobOptPrefGroupUI(OptionsGroupUI2):
|
||||||
|
|
||||||
class CNCJobOptPrefGroupUI(OptionsGroupUI):
|
def __init__(self, decimals=4, **kwargs):
|
||||||
def __init__(self, decimals=4, parent=None):
|
|
||||||
# OptionsGroupUI.__init__(self, "CNC Job Options Preferences", parent=None)
|
|
||||||
super(CNCJobOptPrefGroupUI, self).__init__(self, parent=parent)
|
|
||||||
|
|
||||||
self.setTitle(str(_("CNC Job Options")))
|
|
||||||
self.decimals = decimals
|
self.decimals = decimals
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.setTitle(str(_("CNC Job Options")))
|
||||||
|
|
||||||
# ## Export G-Code
|
def build_options(self) -> [OptionUI]:
|
||||||
self.export_gcode_label = QtWidgets.QLabel("<b>%s:</b>" % _("Export G-Code"))
|
return [
|
||||||
self.export_gcode_label.setToolTip(
|
HeadingOptionUI(
|
||||||
_("Export and save G-Code to\n"
|
label_text="Export G-Code",
|
||||||
"make this object to a file.")
|
label_tooltip="Export and save G-Code to\n"
|
||||||
)
|
"make this object to a file."
|
||||||
self.layout.addWidget(self.export_gcode_label)
|
),
|
||||||
|
TextAreaOptionUI(
|
||||||
qsettings = QSettings("Open Source", "FlatCAM")
|
option="cncjob_prepend",
|
||||||
if qsettings.contains("textbox_font_size"):
|
label_text="Prepend to G-Code",
|
||||||
tb_fsize = qsettings.value('textbox_font_size', type=int)
|
label_tooltip="Type here any G-Code commands you would\n"
|
||||||
else:
|
"like to add at the beginning of the G-Code file."
|
||||||
tb_fsize = 10
|
),
|
||||||
font = QtGui.QFont()
|
TextAreaOptionUI(
|
||||||
font.setPointSize(tb_fsize)
|
option="cncjob_append",
|
||||||
|
label_text="Append to G-Code",
|
||||||
# Prepend to G-Code
|
label_tooltip="Type here any G-Code commands you would\n"
|
||||||
prependlabel = QtWidgets.QLabel('%s:' % _('Prepend to G-Code'))
|
"like to append to the generated file.\n"
|
||||||
prependlabel.setToolTip(
|
"I.e.: M2 (End of program)"
|
||||||
_("Type here any G-Code commands you would\n"
|
)
|
||||||
"like to add at the beginning of the G-Code file.")
|
]
|
||||||
)
|
|
||||||
self.layout.addWidget(prependlabel)
|
|
||||||
|
|
||||||
self.prepend_text = FCTextArea()
|
|
||||||
self.prepend_text.setPlaceholderText(
|
|
||||||
_("Type here any G-Code commands you would "
|
|
||||||
"like to add at the beginning of the G-Code file.")
|
|
||||||
)
|
|
||||||
self.layout.addWidget(self.prepend_text)
|
|
||||||
self.prepend_text.setFont(font)
|
|
||||||
|
|
||||||
# Append text to G-Code
|
|
||||||
appendlabel = QtWidgets.QLabel('%s:' % _('Append to G-Code'))
|
|
||||||
appendlabel.setToolTip(
|
|
||||||
_("Type here any G-Code commands you would\n"
|
|
||||||
"like to append to the generated file.\n"
|
|
||||||
"I.e.: M2 (End of program)")
|
|
||||||
)
|
|
||||||
self.layout.addWidget(appendlabel)
|
|
||||||
|
|
||||||
self.append_text = FCTextArea()
|
|
||||||
self.append_text.setPlaceholderText(
|
|
||||||
_("Type here any G-Code commands you would "
|
|
||||||
"like to append to the generated file.\n"
|
|
||||||
"I.e.: M2 (End of program)")
|
|
||||||
)
|
|
||||||
self.layout.addWidget(self.append_text)
|
|
||||||
self.append_text.setFont(font)
|
|
||||||
|
|
||||||
self.layout.addStretch()
|
|
||||||
|
|
|
@ -18,14 +18,13 @@ class CNCJobPreferencesUI(PreferencesSectionUI):
|
||||||
|
|
||||||
def __init__(self, decimals, **kwargs):
|
def __init__(self, decimals, **kwargs):
|
||||||
self.decimals = decimals
|
self.decimals = decimals
|
||||||
self.cncjob_opt_group = CNCJobOptPrefGroupUI(decimals=self.decimals)
|
|
||||||
self.cncjob_adv_opt_group = CNCJobAdvOptPrefGroupUI(decimals=self.decimals)
|
self.cncjob_adv_opt_group = CNCJobAdvOptPrefGroupUI(decimals=self.decimals)
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def build_groups(self) -> [OptionsGroupUI]:
|
def build_groups(self) -> [OptionsGroupUI]:
|
||||||
return [
|
return [
|
||||||
CNCJobGenPrefGroupUI(decimals=self.decimals),
|
CNCJobGenPrefGroupUI(decimals=self.decimals),
|
||||||
self.cncjob_opt_group,
|
CNCJobOptPrefGroupUI(decimals=self.decimals),
|
||||||
self.cncjob_adv_opt_group
|
self.cncjob_adv_opt_group
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue