Revert "Preferences refactoring (pull request #309)"
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5 import QtWidgets, QtGui, QtCore
|
||||
from PyQt5.QtCore import QSettings, Qt
|
||||
|
||||
from flatcamGUI.preferences.OptionUI import *
|
||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
|
||||
from flatcamGUI.GUIElements import FCTextArea, FCCheckBox, FCComboBox, FCSpinner, FCEntry
|
||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
|
||||
import gettext
|
||||
import FlatCAMTranslation as fcTranslate
|
||||
import builtins
|
||||
@@ -10,18 +11,93 @@ 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 CNCJobAdvOptPrefGroupUI(OptionsGroupUI2):
|
||||
|
||||
def __init__(self, decimals=4, **kwargs):
|
||||
class CNCJobAdvOptPrefGroupUI(OptionsGroupUI):
|
||||
def __init__(self, decimals=4, parent=None):
|
||||
# OptionsGroupUI.__init__(self, "CNC Job Advanced Options Preferences", parent=None)
|
||||
super(CNCJobAdvOptPrefGroupUI, self).__init__(self, parent=parent)
|
||||
self.decimals = decimals
|
||||
super().__init__(**kwargs)
|
||||
|
||||
self.setTitle(str(_("CNC Job Adv. Options")))
|
||||
|
||||
self.toolchange_text = self.option_dict()["cncjob_toolchange_macro"].get_field()
|
||||
# ## Export G-Code
|
||||
self.export_gcode_label = QtWidgets.QLabel("<b>%s:</b>" % _("Export CNC 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)
|
||||
|
||||
# Prepend to G-Code
|
||||
toolchangelabel = QtWidgets.QLabel('%s' % _('Toolchange G-Code'))
|
||||
toolchangelabel.setToolTip(
|
||||
_(
|
||||
"Type here any G-Code commands you would\n"
|
||||
"like to be executed when Toolchange event is encountered.\n"
|
||||
"This will constitute a Custom Toolchange GCode,\n"
|
||||
"or a Toolchange Macro.\n"
|
||||
"The FlatCAM variables are surrounded by '%' symbol.\n\n"
|
||||
"WARNING: it can be used only with a preprocessor file\n"
|
||||
"that has 'toolchange_custom' in it's name and this is built\n"
|
||||
"having as template the 'Toolchange Custom' posprocessor file."
|
||||
)
|
||||
)
|
||||
self.layout.addWidget(toolchangelabel)
|
||||
|
||||
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)
|
||||
|
||||
self.toolchange_text = FCTextArea()
|
||||
self.toolchange_text.setPlaceholderText(
|
||||
_(
|
||||
"Type here any G-Code commands you would "
|
||||
"like to be executed when Toolchange event is encountered.\n"
|
||||
"This will constitute a Custom Toolchange GCode, "
|
||||
"or a Toolchange Macro.\n"
|
||||
"The FlatCAM variables are surrounded by '%' symbol.\n"
|
||||
"WARNING: it can be used only with a preprocessor file "
|
||||
"that has 'toolchange_custom' in it's name."
|
||||
)
|
||||
)
|
||||
self.layout.addWidget(self.toolchange_text)
|
||||
self.toolchange_text.setFont(font)
|
||||
|
||||
hlay = QtWidgets.QHBoxLayout()
|
||||
self.layout.addLayout(hlay)
|
||||
|
||||
# Toolchange Replacement GCode
|
||||
self.toolchange_cb = FCCheckBox(label='%s' % _('Use Toolchange Macro'))
|
||||
self.toolchange_cb.setToolTip(
|
||||
_("Check this box if you want to use\n"
|
||||
"a Custom Toolchange GCode (macro).")
|
||||
)
|
||||
hlay.addWidget(self.toolchange_cb)
|
||||
hlay.addStretch()
|
||||
|
||||
hlay1 = QtWidgets.QHBoxLayout()
|
||||
self.layout.addLayout(hlay1)
|
||||
|
||||
# Variable list
|
||||
self.tc_variable_combo = FCComboBox()
|
||||
self.tc_variable_combo.setToolTip(
|
||||
_("A list of the FlatCAM variables that can be used\n"
|
||||
"in the Toolchange event.\n"
|
||||
"They have to be surrounded by the '%' symbol")
|
||||
)
|
||||
hlay1.addWidget(self.tc_variable_combo)
|
||||
|
||||
# Populate the Combo Box
|
||||
self.tc_variable_combo = self.option_dict()["__toolchange_variable"].get_field()
|
||||
variables = [_('Parameters'), 'tool', 'tooldia', 't_drills', 'x_toolchange', 'y_toolchange', 'z_toolchange',
|
||||
'z_cut', 'z_move', 'z_depthpercut', 'spindlespeed', 'dwelltime']
|
||||
self.tc_variable_combo.addItems(variables)
|
||||
@@ -50,58 +126,83 @@ class CNCJobAdvOptPrefGroupUI(OptionsGroupUI2):
|
||||
_("dwelltime = time to dwell to allow the spindle to reach it's set RPM"),
|
||||
Qt.ToolTipRole)
|
||||
|
||||
# hlay1.addStretch()
|
||||
|
||||
# Insert Variable into the Toolchange G-Code Text Box
|
||||
# self.tc_insert_buton = FCButton("Insert")
|
||||
# self.tc_insert_buton.setToolTip(
|
||||
# "Insert the variable in the GCode Box\n"
|
||||
# "surrounded by the '%' symbol."
|
||||
# )
|
||||
# hlay1.addWidget(self.tc_insert_buton)
|
||||
|
||||
grid0 = QtWidgets.QGridLayout()
|
||||
self.layout.addLayout(grid0)
|
||||
|
||||
grid0.addWidget(QtWidgets.QLabel(''), 1, 0, 1, 2)
|
||||
|
||||
# Annotation Font Size
|
||||
self.annotation_fontsize_label = QtWidgets.QLabel('%s:' % _("Annotation Size"))
|
||||
self.annotation_fontsize_label.setToolTip(
|
||||
_("The font size of the annotation text. In pixels.")
|
||||
)
|
||||
grid0.addWidget(self.annotation_fontsize_label, 2, 0)
|
||||
self.annotation_fontsize_sp = FCSpinner()
|
||||
self.annotation_fontsize_sp.set_range(0, 9999)
|
||||
|
||||
grid0.addWidget(self.annotation_fontsize_sp, 2, 1)
|
||||
grid0.addWidget(QtWidgets.QLabel(''), 2, 2)
|
||||
|
||||
# Annotation Font Color
|
||||
self.annotation_color_label = QtWidgets.QLabel('%s:' % _('Annotation Color'))
|
||||
self.annotation_color_label.setToolTip(
|
||||
_("Set the font color for the annotation texts.")
|
||||
)
|
||||
self.annotation_fontcolor_entry = FCEntry()
|
||||
self.annotation_fontcolor_button = QtWidgets.QPushButton()
|
||||
self.annotation_fontcolor_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child.setContentsMargins(0, 0, 0, 0)
|
||||
self.form_box_child.addWidget(self.annotation_fontcolor_entry)
|
||||
self.form_box_child.addWidget(self.annotation_fontcolor_button, alignment=Qt.AlignRight)
|
||||
self.form_box_child.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
color_widget = QtWidgets.QWidget()
|
||||
color_widget.setLayout(self.form_box_child)
|
||||
grid0.addWidget(self.annotation_color_label, 3, 0)
|
||||
grid0.addWidget(color_widget, 3, 1)
|
||||
grid0.addWidget(QtWidgets.QLabel(''), 3, 2)
|
||||
|
||||
self.layout.addStretch()
|
||||
|
||||
self.tc_variable_combo.currentIndexChanged[str].connect(self.on_cnc_custom_parameters)
|
||||
|
||||
def build_options(self) -> [OptionUI]:
|
||||
return [
|
||||
HeadingOptionUI(
|
||||
label_text="Export CNC Code",
|
||||
label_tooltip="Export and save G-Code to\n"
|
||||
"make this object to a file."
|
||||
),
|
||||
CheckboxOptionUI(
|
||||
option="cncjob_toolchange_macro_enable",
|
||||
label_text="Use Toolchange Macro",
|
||||
label_tooltip="Check this box if you want to use\n"
|
||||
"a Custom Toolchange GCode (macro)."
|
||||
),
|
||||
TextAreaOptionUI(
|
||||
option="cncjob_toolchange_macro",
|
||||
label_text="Toolchange G-Code",
|
||||
label_tooltip="Type here any G-Code commands you would "
|
||||
"like to be executed when Toolchange event is encountered.\n"
|
||||
"This will constitute a Custom Toolchange GCode, "
|
||||
"or a Toolchange Macro.\n"
|
||||
"The FlatCAM variables are surrounded by '%' symbol.\n"
|
||||
"WARNING: it can be used only with a preprocessor file "
|
||||
"that has 'toolchange_custom' in it's name."
|
||||
),
|
||||
ComboboxOptionUI(
|
||||
option="__toolchange_variable",
|
||||
label_text="Insert variable",
|
||||
label_tooltip="A list of the FlatCAM variables that can be used\n"
|
||||
"in the Toolchange event.\n"
|
||||
"They have to be surrounded by the '%' symbol",
|
||||
choices=[] # see init.
|
||||
),
|
||||
|
||||
SpinnerOptionUI(
|
||||
option="cncjob_annotation_fontsize",
|
||||
label_text="Annotation Size",
|
||||
label_tooltip="The font size of the annotation text. In pixels.",
|
||||
min_value=1, max_value=9999, step=1
|
||||
),
|
||||
ColorOptionUI(
|
||||
option="cncjob_annotation_fontcolor",
|
||||
label_text="Annotation Color",
|
||||
label_tooltip="Set the font color for the annotation texts."
|
||||
)
|
||||
]
|
||||
self.annotation_fontcolor_entry.editingFinished.connect(self.on_annotation_fontcolor_entry)
|
||||
self.annotation_fontcolor_button.clicked.connect(self.on_annotation_fontcolor_button)
|
||||
|
||||
def on_cnc_custom_parameters(self, signal_text):
|
||||
if signal_text == _("Parameters"):
|
||||
if signal_text == 'Parameters':
|
||||
return
|
||||
else:
|
||||
self.toolchange_text.insertPlainText('%%%s%%' % signal_text)
|
||||
self.tc_variable_combo.set_value(_("Parameters"))
|
||||
|
||||
def on_annotation_fontcolor_entry(self):
|
||||
self.app.defaults['cncjob_annotation_fontcolor'] = self.annotation_fontcolor_entry.get_value()
|
||||
self.annotation_fontcolor_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.app.defaults['cncjob_annotation_fontcolor']))
|
||||
|
||||
def on_annotation_fontcolor_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['cncjob_annotation_fontcolor'])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
annotation_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if annotation_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.annotation_fontcolor_button.setStyleSheet("background-color:%s" % str(annotation_color.name()))
|
||||
|
||||
new_val_sel = str(annotation_color.name())
|
||||
self.annotation_fontcolor_entry.set_value(new_val_sel)
|
||||
self.app.defaults['cncjob_annotation_fontcolor'] = new_val_sel
|
||||
|
||||
@@ -1,142 +1,389 @@
|
||||
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, RadioSet, FCSpinner, FCDoubleSpinner, FCEntry
|
||||
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 CNCJobGenPrefGroupUI(OptionsGroupUI2):
|
||||
|
||||
def __init__(self, decimals=4, **kwargs):
|
||||
self.decimals = decimals
|
||||
super().__init__(**kwargs)
|
||||
class CNCJobGenPrefGroupUI(OptionsGroupUI):
|
||||
def __init__(self, decimals=4, parent=None):
|
||||
# OptionsGroupUI.__init__(self, "CNC Job General Preferences", parent=None)
|
||||
super(CNCJobGenPrefGroupUI, self).__init__(self, parent=parent)
|
||||
|
||||
self.setTitle(str(_("CNC Job General")))
|
||||
self.decimals = decimals
|
||||
|
||||
# ## Plot options
|
||||
self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
|
||||
self.layout.addWidget(self.plot_options_label)
|
||||
|
||||
grid0 = QtWidgets.QGridLayout()
|
||||
self.layout.addLayout(grid0)
|
||||
grid0.setColumnStretch(0, 0)
|
||||
grid0.setColumnStretch(1, 1)
|
||||
|
||||
# Plot CB
|
||||
# self.plot_cb = QtWidgets.QCheckBox('Plot')
|
||||
self.plot_cb = FCCheckBox(_('Plot Object'))
|
||||
self.plot_cb.setToolTip(_("Plot (show) this object."))
|
||||
grid0.addWidget(self.plot_cb, 0, 0, 1, 2)
|
||||
|
||||
# Plot Kind
|
||||
self.cncplot_method_label = QtWidgets.QLabel('%s:' % _("Plot kind"))
|
||||
self.cncplot_method_label.setToolTip(
|
||||
_("This selects the kind of geometries on the canvas to plot.\n"
|
||||
"Those can be either of type 'Travel' which means the moves\n"
|
||||
"above the work piece or it can be of type 'Cut',\n"
|
||||
"which means the moves that cut into the material.")
|
||||
)
|
||||
|
||||
self.cncplot_method_radio = RadioSet([
|
||||
{"label": _("All"), "value": "all"},
|
||||
{"label": _("Travel"), "value": "travel"},
|
||||
{"label": _("Cut"), "value": "cut"}
|
||||
], orientation='vertical')
|
||||
|
||||
grid0.addWidget(self.cncplot_method_label, 1, 0)
|
||||
grid0.addWidget(self.cncplot_method_radio, 1, 1)
|
||||
grid0.addWidget(QtWidgets.QLabel(''), 1, 2)
|
||||
|
||||
# Display Annotation
|
||||
self.annotation_cb = FCCheckBox(_("Display Annotation"))
|
||||
self.annotation_cb.setToolTip(
|
||||
_("This selects if to display text annotation on the plot.\n"
|
||||
"When checked it will display numbers in order for each end\n"
|
||||
"of a travel line."
|
||||
)
|
||||
)
|
||||
|
||||
grid0.addWidget(self.annotation_cb, 2, 0, 1, 3)
|
||||
|
||||
# ###################################################################
|
||||
# Number of circle steps for circular aperture linear approximation #
|
||||
# ###################################################################
|
||||
self.steps_per_circle_label = QtWidgets.QLabel('%s:' % _("Circle Steps"))
|
||||
self.steps_per_circle_label.setToolTip(
|
||||
_("The number of circle steps for <b>GCode</b> \n"
|
||||
"circle and arc shapes linear approximation.")
|
||||
)
|
||||
grid0.addWidget(self.steps_per_circle_label, 3, 0)
|
||||
self.steps_per_circle_entry = FCSpinner()
|
||||
self.steps_per_circle_entry.set_range(0, 99999)
|
||||
grid0.addWidget(self.steps_per_circle_entry, 3, 1)
|
||||
|
||||
# Tool dia for plot
|
||||
tdlabel = QtWidgets.QLabel('%s:' % _('Travel dia'))
|
||||
tdlabel.setToolTip(
|
||||
_("The width of the travel lines to be\n"
|
||||
"rendered in the plot.")
|
||||
)
|
||||
self.tooldia_entry = FCDoubleSpinner()
|
||||
self.tooldia_entry.set_range(0, 99999)
|
||||
self.tooldia_entry.set_precision(self.decimals)
|
||||
self.tooldia_entry.setSingleStep(0.1)
|
||||
self.tooldia_entry.setWrapping(True)
|
||||
|
||||
grid0.addWidget(tdlabel, 4, 0)
|
||||
grid0.addWidget(self.tooldia_entry, 4, 1)
|
||||
|
||||
# add a space
|
||||
grid0.addWidget(QtWidgets.QLabel('<b>%s:</b>' % _("G-code Decimals")), 5, 0, 1, 2)
|
||||
|
||||
# Number of decimals to use in GCODE coordinates
|
||||
cdeclabel = QtWidgets.QLabel('%s:' % _('Coordinates'))
|
||||
cdeclabel.setToolTip(
|
||||
_("The number of decimals to be used for \n"
|
||||
"the X, Y, Z coordinates in CNC code (GCODE, etc.)")
|
||||
)
|
||||
self.coords_dec_entry = FCSpinner()
|
||||
self.coords_dec_entry.set_range(0, 9)
|
||||
self.coords_dec_entry.setWrapping(True)
|
||||
|
||||
grid0.addWidget(cdeclabel, 6, 0)
|
||||
grid0.addWidget(self.coords_dec_entry, 6, 1)
|
||||
|
||||
# Number of decimals to use in GCODE feedrate
|
||||
frdeclabel = QtWidgets.QLabel('%s:' % _('Feedrate'))
|
||||
frdeclabel.setToolTip(
|
||||
_("The number of decimals to be used for \n"
|
||||
"the Feedrate parameter in CNC code (GCODE, etc.)")
|
||||
)
|
||||
self.fr_dec_entry = FCSpinner()
|
||||
self.fr_dec_entry.set_range(0, 9)
|
||||
self.fr_dec_entry.setWrapping(True)
|
||||
|
||||
grid0.addWidget(frdeclabel, 7, 0)
|
||||
grid0.addWidget(self.fr_dec_entry, 7, 1)
|
||||
|
||||
# The type of coordinates used in the Gcode: Absolute or Incremental
|
||||
coords_type_label = QtWidgets.QLabel('%s:' % _('Coordinates type'))
|
||||
coords_type_label.setToolTip(
|
||||
_("The type of coordinates to be used in Gcode.\n"
|
||||
"Can be:\n"
|
||||
"- Absolute G90 -> the reference is the origin x=0, y=0\n"
|
||||
"- Incremental G91 -> the reference is the previous position")
|
||||
)
|
||||
self.coords_type_radio = RadioSet([
|
||||
{"label": _("Absolute G90"), "value": "G90"},
|
||||
{"label": _("Incremental G91"), "value": "G91"}
|
||||
], orientation='vertical', stretch=False)
|
||||
grid0.addWidget(coords_type_label, 8, 0)
|
||||
grid0.addWidget(self.coords_type_radio, 8, 1)
|
||||
|
||||
# hidden for the time being, until implemented
|
||||
self.option_dict()["cncjob_coords_type"].label_widget.hide()
|
||||
self.option_dict()["cncjob_coords_type"].get_field().hide()
|
||||
coords_type_label.hide()
|
||||
self.coords_type_radio.hide()
|
||||
|
||||
def build_options(self) -> [OptionUI]:
|
||||
return [
|
||||
HeadingOptionUI(label_text="Plot Options"),
|
||||
CheckboxOptionUI(
|
||||
option="cncjob_plot",
|
||||
label_text="Plot Object",
|
||||
label_tooltip="Plot (show) this object."
|
||||
),
|
||||
RadioSetOptionUI(
|
||||
option="cncjob_plot_kind",
|
||||
label_text="Plot kind",
|
||||
label_tooltip="This selects the kind of geometries on the canvas to plot.\n"
|
||||
"Those can be either of type 'Travel' which means the moves\n"
|
||||
"above the work piece or it can be of type 'Cut',\n"
|
||||
"which means the moves that cut into the material.",
|
||||
choices=[
|
||||
{"label": _("All"), "value": "all"},
|
||||
{"label": _("Travel"), "value": "travel"},
|
||||
{"label": _("Cut"), "value": "cut"}
|
||||
],
|
||||
orientation="vertical"
|
||||
),
|
||||
CheckboxOptionUI(
|
||||
option="cncjob_annotation",
|
||||
label_text="Display Annotation",
|
||||
label_tooltip="This selects if to display text annotation on the plot.\n"
|
||||
"When checked it will display numbers in order for each end\n"
|
||||
"of a travel line."
|
||||
),
|
||||
SpinnerOptionUI(
|
||||
option="cncjob_steps_per_circle",
|
||||
label_text="Circle Steps",
|
||||
label_tooltip="The number of circle steps for <b>GCode</b> \n"
|
||||
"circle and arc shapes linear approximation.",
|
||||
min_value=3, max_value=99999, step=1
|
||||
),
|
||||
DoubleSpinnerOptionUI(
|
||||
option="cncjob_tooldia",
|
||||
label_text="Travel dia",
|
||||
label_tooltip="The width of the travel lines to be\n"
|
||||
"rendered in the plot.",
|
||||
min_value=0, max_value=99999, step=0.1, decimals=self.decimals
|
||||
),
|
||||
# Line Endings
|
||||
self.line_ending_cb = FCCheckBox(_("Force Windows style line-ending"))
|
||||
self.line_ending_cb.setToolTip(
|
||||
_("When checked will force a Windows style line-ending\n"
|
||||
"(\\r\\n) on non-Windows OS's.")
|
||||
)
|
||||
|
||||
HeadingOptionUI(label_text="G-code Decimals"),
|
||||
SpinnerOptionUI(
|
||||
option="cncjob_coords_decimals",
|
||||
label_text="Coordinates",
|
||||
label_tooltip="The number of decimals to be used for \n"
|
||||
"the X, Y, Z coordinates in CNC code (GCODE, etc.)",
|
||||
min_value=0, max_value=9, step=1
|
||||
),
|
||||
SpinnerOptionUI(
|
||||
option="cncjob_fr_decimals",
|
||||
label_text="Feedrate",
|
||||
label_tooltip="The number of decimals to be used for \n"
|
||||
"the Feedrate parameter in CNC code (GCODE, etc.)",
|
||||
min_value=0, max_value=9, step=1
|
||||
),
|
||||
RadioSetOptionUI(
|
||||
option="cncjob_coords_type",
|
||||
label_text="Coordinates type",
|
||||
label_tooltip="The type of coordinates to be used in Gcode.\n"
|
||||
"Can be:\n"
|
||||
"- Absolute G90 -> the reference is the origin x=0, y=0\n"
|
||||
"- Incremental G91 -> the reference is the previous position",
|
||||
choices=[
|
||||
{"label": _("Absolute G90"), "value": "G90"},
|
||||
{"label": _("Incremental G91"), "value": "G91"}
|
||||
],
|
||||
orientation="vertical"
|
||||
),
|
||||
CheckboxOptionUI(
|
||||
option="cncjob_line_ending",
|
||||
label_text="Force Windows style line-ending",
|
||||
label_tooltip="When checked will force a Windows style line-ending\n"
|
||||
"(\\r\\n) on non-Windows OS's."
|
||||
),
|
||||
SeparatorOptionUI(),
|
||||
grid0.addWidget(self.line_ending_cb, 9, 0, 1, 3)
|
||||
|
||||
HeadingOptionUI(label_text="Travel Line Color"),
|
||||
ColorOptionUI(
|
||||
option="cncjob_travel_line",
|
||||
label_text="Outline",
|
||||
label_tooltip="Set the line color for plotted objects.",
|
||||
),
|
||||
ColorOptionUI(
|
||||
option="cncjob_travel_fill",
|
||||
label_text="Fill",
|
||||
label_tooltip="Set the fill color for plotted objects.\n"
|
||||
"First 6 digits are the color and the last 2\n"
|
||||
"digits are for alpha (transparency) level."
|
||||
),
|
||||
ColorAlphaSliderOptionUI(
|
||||
applies_to=["cncjob_travel_line", "cncjob_travel_fill"],
|
||||
group=self,
|
||||
label_text="Alpha",
|
||||
label_tooltip="Set the transparency for plotted objects."
|
||||
),
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 12, 0, 1, 2)
|
||||
|
||||
HeadingOptionUI(label_text="CNCJob Object Color"),
|
||||
ColorOptionUI(
|
||||
option="cncjob_plot_line",
|
||||
label_text="Outline",
|
||||
label_tooltip="Set the line color for plotted objects.",
|
||||
),
|
||||
ColorOptionUI(
|
||||
option="cncjob_plot_fill",
|
||||
label_text="Fill",
|
||||
label_tooltip="Set the fill color for plotted objects.\n"
|
||||
"First 6 digits are the color and the last 2\n"
|
||||
"digits are for alpha (transparency) level."
|
||||
),
|
||||
ColorAlphaSliderOptionUI(
|
||||
applies_to=["cncjob_plot_line", "cncjob_plot_fill"],
|
||||
group=self,
|
||||
label_text="Alpha",
|
||||
label_tooltip="Set the transparency for plotted objects."
|
||||
)
|
||||
]
|
||||
# Travel Line Color
|
||||
self.travel_color_label = QtWidgets.QLabel('<b>%s</b>' % _('Travel Line Color'))
|
||||
grid0.addWidget(self.travel_color_label, 13, 0, 1, 2)
|
||||
|
||||
# Plot Line Color
|
||||
self.tline_color_label = QtWidgets.QLabel('%s:' % _('Outline'))
|
||||
self.tline_color_label.setToolTip(
|
||||
_("Set the travel line color for plotted objects.")
|
||||
)
|
||||
self.tline_color_entry = FCEntry()
|
||||
self.tline_color_button = QtWidgets.QPushButton()
|
||||
self.tline_color_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_2 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_2.addWidget(self.tline_color_entry)
|
||||
self.form_box_child_2.addWidget(self.tline_color_button)
|
||||
self.form_box_child_2.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.tline_color_label, 14, 0)
|
||||
grid0.addLayout(self.form_box_child_2, 14, 1)
|
||||
|
||||
# Plot Fill Color
|
||||
self.tfill_color_label = QtWidgets.QLabel('%s:' % _('Fill'))
|
||||
self.tfill_color_label.setToolTip(
|
||||
_("Set the fill color for plotted objects.\n"
|
||||
"First 6 digits are the color and the last 2\n"
|
||||
"digits are for alpha (transparency) level.")
|
||||
)
|
||||
self.tfill_color_entry = FCEntry()
|
||||
self.tfill_color_button = QtWidgets.QPushButton()
|
||||
self.tfill_color_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_1 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_1.addWidget(self.tfill_color_entry)
|
||||
self.form_box_child_1.addWidget(self.tfill_color_button)
|
||||
self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.tfill_color_label, 15, 0)
|
||||
grid0.addLayout(self.form_box_child_1, 15, 1)
|
||||
|
||||
# Plot Fill Transparency Level
|
||||
self.alpha_label = QtWidgets.QLabel('%s:' % _('Alpha'))
|
||||
self.alpha_label.setToolTip(
|
||||
_("Set the fill transparency for plotted objects.")
|
||||
)
|
||||
self.tcolor_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
|
||||
self.tcolor_alpha_slider.setMinimum(0)
|
||||
self.tcolor_alpha_slider.setMaximum(255)
|
||||
self.tcolor_alpha_slider.setSingleStep(1)
|
||||
|
||||
self.tcolor_alpha_spinner = FCSpinner()
|
||||
self.tcolor_alpha_spinner.setMinimumWidth(70)
|
||||
self.tcolor_alpha_spinner.set_range(0, 255)
|
||||
|
||||
self.form_box_child_3 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_3.addWidget(self.tcolor_alpha_slider)
|
||||
self.form_box_child_3.addWidget(self.tcolor_alpha_spinner)
|
||||
|
||||
grid0.addWidget(self.alpha_label, 16, 0)
|
||||
grid0.addLayout(self.form_box_child_3, 16, 1)
|
||||
|
||||
separator_line = QtWidgets.QFrame()
|
||||
separator_line.setFrameShape(QtWidgets.QFrame.HLine)
|
||||
separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
|
||||
grid0.addWidget(separator_line, 17, 0, 1, 2)
|
||||
|
||||
# CNCJob Object Color
|
||||
self.cnc_color_label = QtWidgets.QLabel('<b>%s</b>' % _('CNCJob Object Color'))
|
||||
grid0.addWidget(self.cnc_color_label, 18, 0, 1, 2)
|
||||
|
||||
# Plot Line Color
|
||||
self.line_color_label = QtWidgets.QLabel('%s:' % _('Outline'))
|
||||
self.line_color_label.setToolTip(
|
||||
_("Set the 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, 19, 0)
|
||||
grid0.addLayout(self.form_box_child_2, 19, 1)
|
||||
|
||||
# Plot Fill Color
|
||||
self.fill_color_label = QtWidgets.QLabel('%s:' % _('Fill'))
|
||||
self.fill_color_label.setToolTip(
|
||||
_("Set the fill color for plotted objects.\n"
|
||||
"First 6 digits are the color and the last 2\n"
|
||||
"digits are for alpha (transparency) level.")
|
||||
)
|
||||
self.fill_color_entry = FCEntry()
|
||||
self.fill_color_button = QtWidgets.QPushButton()
|
||||
self.fill_color_button.setFixedSize(15, 15)
|
||||
|
||||
self.form_box_child_1 = QtWidgets.QHBoxLayout()
|
||||
self.form_box_child_1.addWidget(self.fill_color_entry)
|
||||
self.form_box_child_1.addWidget(self.fill_color_button)
|
||||
self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
|
||||
|
||||
grid0.addWidget(self.fill_color_label, 20, 0)
|
||||
grid0.addLayout(self.form_box_child_1, 20, 1)
|
||||
|
||||
self.layout.addStretch()
|
||||
|
||||
# Setting plot colors signals
|
||||
self.tline_color_entry.editingFinished.connect(self.on_tline_color_entry)
|
||||
self.tline_color_button.clicked.connect(self.on_tline_color_button)
|
||||
self.tfill_color_entry.editingFinished.connect(self.on_tfill_color_entry)
|
||||
self.tfill_color_button.clicked.connect(self.on_tfill_color_button)
|
||||
self.tcolor_alpha_spinner.valueChanged.connect(self.on_tcolor_spinner)
|
||||
self.tcolor_alpha_slider.valueChanged.connect(self.on_tcolor_slider)
|
||||
|
||||
self.line_color_entry.editingFinished.connect(self.on_line_color_entry)
|
||||
self.line_color_button.clicked.connect(self.on_line_color_button)
|
||||
self.fill_color_entry.editingFinished.connect(self.on_fill_color_entry)
|
||||
self.fill_color_button.clicked.connect(self.on_fill_color_button)
|
||||
|
||||
# ------------------------------------------------------
|
||||
# Setting travel colors handlers
|
||||
# ------------------------------------------------------
|
||||
def on_tfill_color_entry(self):
|
||||
self.app.defaults['cncjob_travel_fill'] = self.tfill_color_entry.get_value()[:7] + \
|
||||
self.app.defaults['cncjob_travel_fill'][7:9]
|
||||
self.tfill_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.app.defaults['cncjob_travel_fill'])[:7])
|
||||
|
||||
def on_tfill_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['cncjob_travel_fill'][:7])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
plot_fill_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if plot_fill_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.tfill_color_button.setStyleSheet("background-color:%s" % str(plot_fill_color.name()))
|
||||
|
||||
new_val = str(plot_fill_color.name()) + str(self.app.defaults['cncjob_travel_fill'][7:9])
|
||||
self.tfill_color_entry.set_value(new_val)
|
||||
self.app.defaults['cncjob_travel_fill'] = new_val
|
||||
|
||||
def on_tcolor_spinner(self):
|
||||
spinner_value = self.tcolor_alpha_spinner.value()
|
||||
self.tcolor_alpha_slider.setValue(spinner_value)
|
||||
self.app.defaults['cncjob_travel_fill'] = \
|
||||
self.app.defaults['cncjob_travel_fill'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
self.app.defaults['cncjob_travel_line'] = \
|
||||
self.app.defaults['cncjob_travel_line'][:7] + \
|
||||
(hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
|
||||
|
||||
def on_tcolor_slider(self):
|
||||
slider_value = self.tcolor_alpha_slider.value()
|
||||
self.tcolor_alpha_spinner.setValue(slider_value)
|
||||
|
||||
def on_tline_color_entry(self):
|
||||
self.app.defaults['cncjob_travel_line'] = self.tline_color_entry.get_value()[:7] + \
|
||||
self.app.defaults['cncjob_travel_line'][7:9]
|
||||
self.tline_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.app.defaults['cncjob_travel_line'])[:7])
|
||||
|
||||
def on_tline_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['cncjob_travel_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.tline_color_button.setStyleSheet("background-color:%s" % str(plot_line_color.name()))
|
||||
|
||||
new_val_line = str(plot_line_color.name()) + str(self.app.defaults['cncjob_travel_line'][7:9])
|
||||
self.tline_color_entry.set_value(new_val_line)
|
||||
self.app.defaults['cncjob_travel_line'] = new_val_line
|
||||
|
||||
# ------------------------------------------------------
|
||||
# Setting plot colors handlers
|
||||
# ------------------------------------------------------
|
||||
def on_fill_color_entry(self):
|
||||
self.app.defaults['cncjob_plot_fill'] = self.fill_color_entry.get_value()[:7] + \
|
||||
self.app.defaults['cncjob_plot_fill'][7:9]
|
||||
self.fill_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.app.defaults['cncjob_plot_fill'])[:7])
|
||||
|
||||
def on_fill_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['cncjob_plot_fill'][:7])
|
||||
|
||||
c_dialog = QtWidgets.QColorDialog()
|
||||
plot_fill_color = c_dialog.getColor(initial=current_color)
|
||||
|
||||
if plot_fill_color.isValid() is False:
|
||||
return
|
||||
|
||||
self.fill_color_button.setStyleSheet("background-color:%s" % str(plot_fill_color.name()))
|
||||
|
||||
new_val = str(plot_fill_color.name()) + str(self.app.defaults['cncjob_plot_fill'][7:9])
|
||||
self.fill_color_entry.set_value(new_val)
|
||||
self.app.defaults['cncjob_plot_fill'] = new_val
|
||||
|
||||
def on_line_color_entry(self):
|
||||
self.app.defaults['cncjob_plot_line'] = self.line_color_entry.get_value()[:7] + \
|
||||
self.app.defaults['cncjob_plot_line'][7:9]
|
||||
self.line_color_button.setStyleSheet(
|
||||
"background-color:%s" % str(self.app.defaults['cncjob_plot_line'])[:7])
|
||||
|
||||
def on_line_color_button(self):
|
||||
current_color = QtGui.QColor(self.app.defaults['cncjob_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['cncjob_plot_line'][7:9])
|
||||
self.line_color_entry.set_value(new_val_line)
|
||||
self.app.defaults['cncjob_plot_line'] = new_val_line
|
||||
|
||||
@@ -1,39 +1,80 @@
|
||||
from flatcamGUI.preferences.OptionUI import *
|
||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
|
||||
from PyQt5 import QtWidgets, QtGui
|
||||
from PyQt5.QtCore import QSettings
|
||||
|
||||
from flatcamGUI.GUIElements import FCTextArea
|
||||
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 CNCJobOptPrefGroupUI(OptionsGroupUI2):
|
||||
|
||||
def __init__(self, decimals=4, **kwargs):
|
||||
self.decimals = decimals
|
||||
super().__init__(**kwargs)
|
||||
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")))
|
||||
self.decimals = decimals
|
||||
|
||||
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)"
|
||||
)
|
||||
]
|
||||
# ## 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()
|
||||
|
||||
@@ -1,33 +1,27 @@
|
||||
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
|
||||
from flatcamGUI.preferences.PreferencesSectionUI import PreferencesSectionUI
|
||||
from PyQt5 import QtWidgets
|
||||
|
||||
from flatcamGUI.preferences.cncjob.CNCJobAdvOptPrefGroupUI import CNCJobAdvOptPrefGroupUI
|
||||
from flatcamGUI.preferences.cncjob.CNCJobOptPrefGroupUI import CNCJobOptPrefGroupUI
|
||||
from flatcamGUI.preferences.cncjob.CNCJobGenPrefGroupUI import CNCJobGenPrefGroupUI
|
||||
|
||||
import gettext
|
||||
import FlatCAMTranslation as fcTranslate
|
||||
import builtins
|
||||
fcTranslate.apply_language('strings')
|
||||
if '_' not in builtins.__dict__:
|
||||
_ = gettext.gettext
|
||||
|
||||
class CNCJobPreferencesUI(QtWidgets.QWidget):
|
||||
|
||||
class CNCJobPreferencesUI(PreferencesSectionUI):
|
||||
|
||||
def __init__(self, decimals, **kwargs):
|
||||
def __init__(self, decimals, parent=None):
|
||||
QtWidgets.QWidget.__init__(self, parent=parent)
|
||||
self.layout = QtWidgets.QHBoxLayout()
|
||||
self.setLayout(self.layout)
|
||||
self.decimals = decimals
|
||||
super().__init__(**kwargs)
|
||||
|
||||
def build_groups(self) -> [OptionsGroupUI]:
|
||||
return [
|
||||
CNCJobGenPrefGroupUI(decimals=self.decimals),
|
||||
CNCJobOptPrefGroupUI(decimals=self.decimals),
|
||||
CNCJobAdvOptPrefGroupUI(decimals=self.decimals)
|
||||
]
|
||||
self.cncjob_gen_group = CNCJobGenPrefGroupUI(decimals=self.decimals)
|
||||
self.cncjob_gen_group.setMinimumWidth(260)
|
||||
self.cncjob_opt_group = CNCJobOptPrefGroupUI(decimals=self.decimals)
|
||||
self.cncjob_opt_group.setMinimumWidth(260)
|
||||
self.cncjob_adv_opt_group = CNCJobAdvOptPrefGroupUI(decimals=self.decimals)
|
||||
self.cncjob_adv_opt_group.setMinimumWidth(260)
|
||||
|
||||
def get_tab_id(self):
|
||||
# FIXME this doesn't seem right
|
||||
return "text_editor_tab"
|
||||
self.layout.addWidget(self.cncjob_gen_group)
|
||||
self.layout.addWidget(self.cncjob_opt_group)
|
||||
self.layout.addWidget(self.cncjob_adv_opt_group)
|
||||
|
||||
def get_tab_label(self):
|
||||
return _("CNC-JOB")
|
||||
self.layout.addStretch()
|
||||
|
||||
Reference in New Issue
Block a user