CNC job options
This commit is contained in:
parent
17eaa6e8ad
commit
5304cd1ac9
|
@ -1,8 +1,10 @@
|
|||
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, \
|
||||
FCSliderWithSpinner, FCDoubleSpinner, FloatEntry
|
||||
FCSliderWithSpinner, FCDoubleSpinner, FloatEntry, FCTextArea
|
||||
|
||||
import gettext
|
||||
import FlatCAMTranslation as fcTranslate
|
||||
|
@ -67,13 +69,13 @@ class LineEntryOptionUI(BasicOptionUI):
|
|||
def build_entry_widget(self) -> QtWidgets.QWidget:
|
||||
return FCEntry()
|
||||
|
||||
|
||||
# Not sure why this is needed over DoubleSpinnerOptionUI
|
||||
class FloatEntryOptionUI(BasicOptionUI):
|
||||
def build_entry_widget(self) -> QtWidgets.QWidget:
|
||||
return FloatEntry()
|
||||
|
||||
|
||||
|
||||
class RadioSetOptionUI(BasicOptionUI):
|
||||
|
||||
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)
|
||||
|
||||
|
||||
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):
|
||||
|
||||
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,
|
||||
|
||||
|
||||
|
||||
# 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
|
||||
"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,
|
||||
|
|
|
@ -1,80 +1,39 @@
|
|||
from PyQt5 import QtWidgets, QtGui
|
||||
from PyQt5.QtCore import QSettings
|
||||
|
||||
from flatcamGUI.GUIElements import FCTextArea
|
||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
|
||||
from flatcamGUI.preferences.OptionUI import *
|
||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
|
||||
|
||||
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 CNCJobOptPrefGroupUI(OptionsGroupUI2):
|
||||
|
||||
class CNCJobOptPrefGroupUI(OptionsGroupUI):
|
||||
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")))
|
||||
def __init__(self, decimals=4, **kwargs):
|
||||
self.decimals = decimals
|
||||
super().__init__(**kwargs)
|
||||
self.setTitle(str(_("CNC Job Options")))
|
||||
|
||||
# ## Export G-Code
|
||||
self.export_gcode_label = QtWidgets.QLabel("<b>%s:</b>" % _("Export G-Code"))
|
||||
self.export_gcode_label.setToolTip(
|
||||
_("Export and save G-Code to\n"
|
||||
"make this object to a file.")
|
||||
)
|
||||
self.layout.addWidget(self.export_gcode_label)
|
||||
|
||||
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)
|
||||
|
||||
# Prepend to G-Code
|
||||
prependlabel = QtWidgets.QLabel('%s:' % _('Prepend to G-Code'))
|
||||
prependlabel.setToolTip(
|
||||
_("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()
|
||||
def build_options(self) -> [OptionUI]:
|
||||
return [
|
||||
HeadingOptionUI(
|
||||
label_text="Export G-Code",
|
||||
label_tooltip="Export and save G-Code to\n"
|
||||
"make this object to a file."
|
||||
),
|
||||
TextAreaOptionUI(
|
||||
option="cncjob_prepend",
|
||||
label_text="Prepend to G-Code",
|
||||
label_tooltip="Type here any G-Code commands you would\n"
|
||||
"like to add at the beginning of the G-Code file."
|
||||
),
|
||||
TextAreaOptionUI(
|
||||
option="cncjob_append",
|
||||
label_text="Append to G-Code",
|
||||
label_tooltip="Type here any G-Code commands you would\n"
|
||||
"like to append to the generated file.\n"
|
||||
"I.e.: M2 (End of program)"
|
||||
)
|
||||
]
|
||||
|
|
|
@ -18,14 +18,13 @@ class CNCJobPreferencesUI(PreferencesSectionUI):
|
|||
|
||||
def __init__(self, decimals, **kwargs):
|
||||
self.decimals = decimals
|
||||
self.cncjob_opt_group = CNCJobOptPrefGroupUI(decimals=self.decimals)
|
||||
self.cncjob_adv_opt_group = CNCJobAdvOptPrefGroupUI(decimals=self.decimals)
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def build_groups(self) -> [OptionsGroupUI]:
|
||||
return [
|
||||
CNCJobGenPrefGroupUI(decimals=self.decimals),
|
||||
self.cncjob_opt_group,
|
||||
CNCJobOptPrefGroupUI(decimals=self.decimals),
|
||||
self.cncjob_adv_opt_group
|
||||
]
|
||||
|
||||
|
|
Loading…
Reference in New Issue