excellon export
This commit is contained in:
parent
73479e75b6
commit
d464fa5878
|
@ -60,14 +60,6 @@ class PreferencesUIManager:
|
||||||
"excellon_f_plunge": self.ui.excellon_defaults_form.excellon_adv_opt_group.fplunge_cb,
|
"excellon_f_plunge": self.ui.excellon_defaults_form.excellon_adv_opt_group.fplunge_cb,
|
||||||
"excellon_f_retract": self.ui.excellon_defaults_form.excellon_adv_opt_group.fretract_cb,
|
"excellon_f_retract": self.ui.excellon_defaults_form.excellon_adv_opt_group.fretract_cb,
|
||||||
|
|
||||||
# Excellon Export
|
|
||||||
"excellon_exp_units": self.ui.excellon_defaults_form.excellon_exp_group.excellon_units_radio,
|
|
||||||
"excellon_exp_format": self.ui.excellon_defaults_form.excellon_exp_group.format_radio,
|
|
||||||
"excellon_exp_integer": self.ui.excellon_defaults_form.excellon_exp_group.format_whole_entry,
|
|
||||||
"excellon_exp_decimals": self.ui.excellon_defaults_form.excellon_exp_group.format_dec_entry,
|
|
||||||
"excellon_exp_zeros": self.ui.excellon_defaults_form.excellon_exp_group.zeros_radio,
|
|
||||||
"excellon_exp_slot_type": self.ui.excellon_defaults_form.excellon_exp_group.slot_type_radio,
|
|
||||||
|
|
||||||
# Excellon Editor
|
# Excellon Editor
|
||||||
"excellon_editor_sel_limit": self.ui.excellon_defaults_form.excellon_editor_group.sel_limit_entry,
|
"excellon_editor_sel_limit": self.ui.excellon_defaults_form.excellon_editor_group.sel_limit_entry,
|
||||||
"excellon_editor_newdia": self.ui.excellon_defaults_form.excellon_editor_group.addtool_entry,
|
"excellon_editor_newdia": self.ui.excellon_defaults_form.excellon_editor_group.addtool_entry,
|
||||||
|
|
|
@ -1,168 +1,86 @@
|
||||||
from PyQt5 import QtWidgets, QtCore
|
from flatcamGUI.preferences.OptionUI import *
|
||||||
from PyQt5.QtCore import QSettings
|
from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI2
|
||||||
|
|
||||||
from flatcamGUI.GUIElements import RadioSet, FCSpinner
|
|
||||||
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 ExcellonExpPrefGroupUI(OptionsGroupUI2):
|
||||||
|
|
||||||
class ExcellonExpPrefGroupUI(OptionsGroupUI):
|
def __init__(self, decimals=4, **kwargs):
|
||||||
|
|
||||||
def __init__(self, decimals=4, parent=None):
|
|
||||||
super(ExcellonExpPrefGroupUI, self).__init__(self, parent=parent)
|
|
||||||
|
|
||||||
self.setTitle(str(_("Excellon Export")))
|
|
||||||
self.decimals = decimals
|
self.decimals = decimals
|
||||||
|
super().__init__(**kwargs)
|
||||||
|
self.setTitle(str(_("Excellon Export")))
|
||||||
|
|
||||||
# Plot options
|
self.option_dict()["excellon_exp_format"].get_field().activated_custom.connect(self.optimization_selection)
|
||||||
self.export_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Export Options"))
|
|
||||||
self.export_options_label.setToolTip(
|
|
||||||
_("The parameters set here are used in the file exported\n"
|
|
||||||
"when using the File -> Export -> Export Excellon menu entry.")
|
|
||||||
)
|
|
||||||
self.layout.addWidget(self.export_options_label)
|
|
||||||
|
|
||||||
form = QtWidgets.QFormLayout()
|
def build_options(self) -> [OptionUI]:
|
||||||
self.layout.addLayout(form)
|
return [
|
||||||
|
HeadingOptionUI(
|
||||||
# Excellon Units
|
label_text="Export Options",
|
||||||
self.excellon_units_label = QtWidgets.QLabel('%s:' % _('Units'))
|
label_tooltip="The parameters set here are used in the file exported\n"
|
||||||
self.excellon_units_label.setToolTip(
|
"when using the File -> Export -> Export Excellon menu entry."
|
||||||
_("The units used in the Excellon file.")
|
),
|
||||||
)
|
RadioSetOptionUI(
|
||||||
|
option="excellon_exp_units",
|
||||||
self.excellon_units_radio = RadioSet([{'label': _('INCH'), 'value': 'INCH'},
|
label_text="Units",
|
||||||
{'label': _('MM'), 'value': 'METRIC'}])
|
label_tooltip="The units used in the Excellon file.",
|
||||||
self.excellon_units_radio.setToolTip(
|
choices=[{'label': _('INCH'), 'value': 'INCH'},
|
||||||
_("The units used in the Excellon file.")
|
{'label': _('MM'), 'value': 'METRIC'}]
|
||||||
)
|
),
|
||||||
|
SpinnerOptionUI(
|
||||||
form.addRow(self.excellon_units_label, self.excellon_units_radio)
|
option="excellon_exp_integer",
|
||||||
|
label_text="Int",
|
||||||
# Excellon non-decimal format
|
label_tooltip="This number signifies the number of digits in\nthe whole part of Excellon coordinates.",
|
||||||
self.digits_label = QtWidgets.QLabel("%s:" % _("Int/Decimals"))
|
min_value=0, max_value=9, step=1
|
||||||
self.digits_label.setToolTip(
|
),
|
||||||
_("The NC drill files, usually named Excellon files\n"
|
SpinnerOptionUI(
|
||||||
"are files that can be found in different formats.\n"
|
option="excellon_exp_decimals",
|
||||||
"Here we set the format used when the provided\n"
|
label_text="Decimals",
|
||||||
"coordinates are not using period.")
|
label_tooltip="This number signifies the number of digits in\nthe decimal part of Excellon coordinates.",
|
||||||
)
|
min_value=0, max_value=9, step=1
|
||||||
|
),
|
||||||
hlay1 = QtWidgets.QHBoxLayout()
|
RadioSetOptionUI(
|
||||||
|
option="excellon_exp_format",
|
||||||
self.format_whole_entry = FCSpinner()
|
label_text="Format",
|
||||||
self.format_whole_entry.set_range(0, 9)
|
label_tooltip="Select the kind of coordinates format used.\n"
|
||||||
self.format_whole_entry.setMinimumWidth(30)
|
"Coordinates can be saved with decimal point or without.\n"
|
||||||
self.format_whole_entry.setToolTip(
|
"When there is no decimal point, it is required to specify\n"
|
||||||
_("This numbers signify the number of digits in\n"
|
"the number of digits for integer part and the number of decimals.\n"
|
||||||
"the whole part of Excellon coordinates.")
|
"Also it will have to be specified if LZ = leading zeros are kept\n"
|
||||||
)
|
"or TZ = trailing zeros are kept.",
|
||||||
hlay1.addWidget(self.format_whole_entry, QtCore.Qt.AlignLeft)
|
choices=[{'label': _('Decimal'), 'value': 'dec'},
|
||||||
|
{'label': _('No-Decimal'), 'value': 'ndec'}]
|
||||||
excellon_separator_label = QtWidgets.QLabel(':')
|
),
|
||||||
excellon_separator_label.setFixedWidth(5)
|
RadioSetOptionUI(
|
||||||
hlay1.addWidget(excellon_separator_label, QtCore.Qt.AlignLeft)
|
option="excellon_exp_zeros",
|
||||||
|
label_text="Zeros",
|
||||||
self.format_dec_entry = FCSpinner()
|
label_tooltip="This sets the type of Excellon zeros.\n"
|
||||||
self.format_dec_entry.set_range(0, 9)
|
"If LZ then Leading Zeros are kept and\n"
|
||||||
self.format_dec_entry.setMinimumWidth(30)
|
"Trailing Zeros are removed.\n"
|
||||||
self.format_dec_entry.setToolTip(
|
"If TZ is checked then Trailing Zeros are kept\n"
|
||||||
_("This numbers signify the number of digits in\n"
|
"and Leading Zeros are removed.",
|
||||||
"the decimal part of Excellon coordinates.")
|
choices=[{'label': _('LZ'), 'value': 'LZ'},
|
||||||
)
|
{'label': _('TZ'), 'value': 'TZ'}]
|
||||||
hlay1.addWidget(self.format_dec_entry, QtCore.Qt.AlignLeft)
|
),
|
||||||
hlay1.addStretch()
|
RadioSetOptionUI(
|
||||||
|
option="excellon_exp_slot_type",
|
||||||
form.addRow(self.digits_label, hlay1)
|
label_text="Slot type",
|
||||||
|
label_tooltip="This sets how the slots will be exported.\n"
|
||||||
# Select the Excellon Format
|
"If ROUTED then the slots will be routed\n"
|
||||||
self.format_label = QtWidgets.QLabel("%s:" % _("Format"))
|
"using M15/M16 commands.\n"
|
||||||
self.format_label.setToolTip(
|
"If DRILLED(G85) the slots will be exported\n"
|
||||||
_("Select the kind of coordinates format used.\n"
|
"using the Drilled slot command (G85).",
|
||||||
"Coordinates can be saved with decimal point or without.\n"
|
choices=[{'label': _('Routed'), 'value': 'routing'},
|
||||||
"When there is no decimal point, it is required to specify\n"
|
{'label': _('Drilled(G85)'), 'value': 'drilling'}]
|
||||||
"the number of digits for integer part and the number of decimals.\n"
|
)
|
||||||
"Also it will have to be specified if LZ = leading zeros are kept\n"
|
]
|
||||||
"or TZ = trailing zeros are kept.")
|
|
||||||
)
|
|
||||||
self.format_radio = RadioSet([{'label': _('Decimal'), 'value': 'dec'},
|
|
||||||
{'label': _('No-Decimal'), 'value': 'ndec'}])
|
|
||||||
self.format_radio.setToolTip(
|
|
||||||
_("Select the kind of coordinates format used.\n"
|
|
||||||
"Coordinates can be saved with decimal point or without.\n"
|
|
||||||
"When there is no decimal point, it is required to specify\n"
|
|
||||||
"the number of digits for integer part and the number of decimals.\n"
|
|
||||||
"Also it will have to be specified if LZ = leading zeros are kept\n"
|
|
||||||
"or TZ = trailing zeros are kept.")
|
|
||||||
)
|
|
||||||
|
|
||||||
form.addRow(self.format_label, self.format_radio)
|
|
||||||
|
|
||||||
# Excellon Zeros
|
|
||||||
self.zeros_label = QtWidgets.QLabel('%s:' % _('Zeros'))
|
|
||||||
self.zeros_label.setAlignment(QtCore.Qt.AlignLeft)
|
|
||||||
self.zeros_label.setToolTip(
|
|
||||||
_("This sets the type of Excellon zeros.\n"
|
|
||||||
"If LZ then Leading Zeros are kept and\n"
|
|
||||||
"Trailing Zeros are removed.\n"
|
|
||||||
"If TZ is checked then Trailing Zeros are kept\n"
|
|
||||||
"and Leading Zeros are removed.")
|
|
||||||
)
|
|
||||||
|
|
||||||
self.zeros_radio = RadioSet([{'label': _('LZ'), 'value': 'LZ'},
|
|
||||||
{'label': _('TZ'), 'value': 'TZ'}])
|
|
||||||
self.zeros_radio.setToolTip(
|
|
||||||
_("This sets the default type of Excellon zeros.\n"
|
|
||||||
"If LZ then Leading Zeros are kept and\n"
|
|
||||||
"Trailing Zeros are removed.\n"
|
|
||||||
"If TZ is checked then Trailing Zeros are kept\n"
|
|
||||||
"and Leading Zeros are removed.")
|
|
||||||
)
|
|
||||||
|
|
||||||
form.addRow(self.zeros_label, self.zeros_radio)
|
|
||||||
|
|
||||||
# Slot type
|
|
||||||
self.slot_type_label = QtWidgets.QLabel('%s:' % _('Slot type'))
|
|
||||||
self.slot_type_label.setAlignment(QtCore.Qt.AlignLeft)
|
|
||||||
self.slot_type_label.setToolTip(
|
|
||||||
_("This sets how the slots will be exported.\n"
|
|
||||||
"If ROUTED then the slots will be routed\n"
|
|
||||||
"using M15/M16 commands.\n"
|
|
||||||
"If DRILLED(G85) the slots will be exported\n"
|
|
||||||
"using the Drilled slot command (G85).")
|
|
||||||
)
|
|
||||||
|
|
||||||
self.slot_type_radio = RadioSet([{'label': _('Routed'), 'value': 'routing'},
|
|
||||||
{'label': _('Drilled(G85)'), 'value': 'drilling'}])
|
|
||||||
self.slot_type_radio.setToolTip(
|
|
||||||
_("This sets how the slots will be exported.\n"
|
|
||||||
"If ROUTED then the slots will be routed\n"
|
|
||||||
"using M15/M16 commands.\n"
|
|
||||||
"If DRILLED(G85) the slots will be exported\n"
|
|
||||||
"using the Drilled slot command (G85).")
|
|
||||||
)
|
|
||||||
|
|
||||||
form.addRow(self.slot_type_label, self.slot_type_radio)
|
|
||||||
|
|
||||||
self.layout.addStretch()
|
|
||||||
self.format_radio.activated_custom.connect(self.optimization_selection)
|
|
||||||
|
|
||||||
def optimization_selection(self):
|
def optimization_selection(self):
|
||||||
if self.format_radio.get_value() == 'dec':
|
disable_zeros = self.option_dict()["excellon_exp_format"].get_field().get_value() == "dec"
|
||||||
self.zeros_label.setDisabled(True)
|
self.option_dict()["excellon_exp_zeros"].label_widget.setDisabled(disable_zeros)
|
||||||
self.zeros_radio.setDisabled(True)
|
self.option_dict()["excellon_exp_zeros"].get_field().setDisabled(disable_zeros)
|
||||||
else:
|
|
||||||
self.zeros_label.setDisabled(False)
|
|
||||||
self.zeros_radio.setDisabled(False)
|
|
||||||
|
|
|
@ -18,24 +18,21 @@ class ExcellonPreferencesUI(PreferencesSectionUI):
|
||||||
|
|
||||||
def __init__(self, decimals, **kwargs):
|
def __init__(self, decimals, **kwargs):
|
||||||
self.decimals = decimals
|
self.decimals = decimals
|
||||||
self.excellon_gen_group = ExcellonGenPrefGroupUI(decimals=self.decimals)
|
|
||||||
|
|
||||||
# FIXME: remove the need for external access to excellon_opt_group
|
# FIXME: remove the need for external access to excellon_opt_group
|
||||||
self.excellon_opt_group = ExcellonOptPrefGroupUI(decimals=self.decimals)
|
self.excellon_opt_group = ExcellonOptPrefGroupUI(decimals=self.decimals)
|
||||||
|
|
||||||
self.excellon_exp_group = ExcellonExpPrefGroupUI(decimals=self.decimals)
|
|
||||||
self.excellon_adv_opt_group = ExcellonAdvOptPrefGroupUI(decimals=self.decimals)
|
self.excellon_adv_opt_group = ExcellonAdvOptPrefGroupUI(decimals=self.decimals)
|
||||||
self.excellon_editor_group = ExcellonEditorPrefGroupUI(decimals=self.decimals)
|
self.excellon_editor_group = ExcellonEditorPrefGroupUI(decimals=self.decimals)
|
||||||
|
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
self.init_sync_export()
|
self.init_sync_export()
|
||||||
|
|
||||||
|
|
||||||
def build_groups(self) -> [OptionsGroupUI]:
|
def build_groups(self) -> [OptionsGroupUI]:
|
||||||
return [
|
return [
|
||||||
self.excellon_gen_group,
|
ExcellonGenPrefGroupUI(decimals=self.decimals),
|
||||||
self.excellon_opt_group,
|
self.excellon_opt_group,
|
||||||
self.excellon_exp_group,
|
ExcellonExpPrefGroupUI(decimals=self.decimals),
|
||||||
self.excellon_adv_opt_group,
|
self.excellon_adv_opt_group,
|
||||||
self.excellon_editor_group
|
self.excellon_editor_group
|
||||||
]
|
]
|
||||||
|
@ -60,13 +57,19 @@ class ExcellonPreferencesUI(PreferencesSectionUI):
|
||||||
# User has disabled sync.
|
# User has disabled sync.
|
||||||
return
|
return
|
||||||
|
|
||||||
self.excellon_exp_group.zeros_radio.set_value(self.option_dict()["excellon_zeros"].get_field().get_value() + 'Z')
|
zeros = self.option_dict()["excellon_zeros"].get_field().get_value() + 'Z'
|
||||||
self.excellon_exp_group.excellon_units_radio.set_value(self.option_dict()["excellon_units"].get_field().get_value())
|
self.option_dict()["excellon_exp_zeros"].get_field().set_value(zeros)
|
||||||
if self.option_dict()["excellon_units"].get_field().get_value().upper() == 'METRIC':
|
|
||||||
self.excellon_exp_group.format_whole_entry.set_value(self.option_dict()["excellon_format_upper_mm"].get_field().get_value())
|
units = self.option_dict()["excellon_units"].get_field().get_value()
|
||||||
self.excellon_exp_group.format_dec_entry.set_value(self.option_dict()["excellon_format_lower_mm"].get_field().get_value())
|
self.option_dict()["excellon_exp_units"].get_field().set_value(units)
|
||||||
|
|
||||||
|
if units.upper() == 'METRIC':
|
||||||
|
whole = self.option_dict()["excellon_format_upper_mm"].get_field().get_value()
|
||||||
|
dec = self.option_dict()["excellon_format_lower_mm"].get_field().get_value()
|
||||||
else:
|
else:
|
||||||
self.excellon_exp_group.format_whole_entry.set_value(self.option_dict()["excellon_format_upper_in"].get_field().get_value())
|
whole = self.option_dict()["excellon_format_upper_in"].get_field().get_value()
|
||||||
self.excellon_exp_group.format_dec_entry.set_value(self.option_dict()["excellon_format_lower_in"].get_field().get_value())
|
dec = self.option_dict()["excellon_format_lower_in"].get_field().get_value()
|
||||||
|
self.option_dict()["excellon_exp_integer"].get_field().set_value(whole)
|
||||||
|
self.option_dict()["excellon_exp_decimals"].get_field().set_value(dec)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue