ExcellonGenPrefGroupUI.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. import platform
  2. from PyQt5 import QtWidgets, QtCore, QtGui
  3. from PyQt5.QtCore import QSettings
  4. from AppGUI.GUIElements import FCCheckBox, FCSpinner, RadioSet, FCEntry
  5. from AppGUI.preferences.OptionsGroupUI import OptionsGroupUI
  6. import gettext
  7. import AppTranslation as fcTranslate
  8. import builtins
  9. fcTranslate.apply_language('strings')
  10. if '_' not in builtins.__dict__:
  11. _ = gettext.gettext
  12. settings = QSettings("Open Source", "FlatCAM")
  13. if settings.contains("machinist"):
  14. machinist_setting = settings.value('machinist', type=int)
  15. else:
  16. machinist_setting = 0
  17. class ExcellonGenPrefGroupUI(OptionsGroupUI):
  18. def __init__(self, decimals=4, parent=None):
  19. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  20. super(ExcellonGenPrefGroupUI, self).__init__(self, parent=parent)
  21. self.setTitle(str(_("Excellon General")))
  22. self.decimals = decimals
  23. # Plot options
  24. self.plot_options_label = QtWidgets.QLabel("<b>%s:</b>" % _("Plot Options"))
  25. self.layout.addWidget(self.plot_options_label)
  26. grid1 = QtWidgets.QGridLayout()
  27. self.layout.addLayout(grid1)
  28. self.plot_cb = FCCheckBox(label=_('Plot'))
  29. self.plot_cb.setToolTip(
  30. "Plot (show) this object."
  31. )
  32. grid1.addWidget(self.plot_cb, 0, 0)
  33. self.solid_cb = FCCheckBox(label=_('Solid'))
  34. self.solid_cb.setToolTip(
  35. "Plot as solid circles."
  36. )
  37. grid1.addWidget(self.solid_cb, 0, 1)
  38. separator_line = QtWidgets.QFrame()
  39. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  40. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  41. grid1.addWidget(separator_line, 1, 0, 1, 2)
  42. grid2 = QtWidgets.QGridLayout()
  43. self.layout.addLayout(grid2)
  44. grid2.setColumnStretch(0, 0)
  45. grid2.setColumnStretch(1, 1)
  46. # Excellon format
  47. self.excellon_format_label = QtWidgets.QLabel("<b>%s:</b>" % _("Excellon Format"))
  48. self.excellon_format_label.setToolTip(
  49. _("The NC drill files, usually named Excellon files\n"
  50. "are files that can be found in different formats.\n"
  51. "Here we set the format used when the provided\n"
  52. "coordinates are not using period.\n"
  53. "\n"
  54. "Possible presets:\n"
  55. "\n"
  56. "PROTEUS 3:3 MM LZ\n"
  57. "DipTrace 5:2 MM TZ\n"
  58. "DipTrace 4:3 MM LZ\n"
  59. "\n"
  60. "EAGLE 3:3 MM TZ\n"
  61. "EAGLE 4:3 MM TZ\n"
  62. "EAGLE 2:5 INCH TZ\n"
  63. "EAGLE 3:5 INCH TZ\n"
  64. "\n"
  65. "ALTIUM 2:4 INCH LZ\n"
  66. "Sprint Layout 2:4 INCH LZ"
  67. "\n"
  68. "KiCAD 3:5 INCH TZ")
  69. )
  70. grid2.addWidget(self.excellon_format_label, 0, 0, 1, 2)
  71. self.excellon_format_in_label = QtWidgets.QLabel('%s:' % _("INCH"))
  72. self.excellon_format_in_label.setToolTip(_("Default values for INCH are 2:4"))
  73. hlay1 = QtWidgets.QHBoxLayout()
  74. self.excellon_format_upper_in_entry = FCSpinner()
  75. self.excellon_format_upper_in_entry.set_range(0, 9)
  76. self.excellon_format_upper_in_entry.setMinimumWidth(30)
  77. self.excellon_format_upper_in_entry.setToolTip(
  78. _("This numbers signify the number of digits in\n"
  79. "the whole part of Excellon coordinates.")
  80. )
  81. hlay1.addWidget(self.excellon_format_upper_in_entry)
  82. excellon_separator_in_label = QtWidgets.QLabel(':')
  83. excellon_separator_in_label.setFixedWidth(5)
  84. hlay1.addWidget(excellon_separator_in_label)
  85. self.excellon_format_lower_in_entry = FCSpinner()
  86. self.excellon_format_lower_in_entry.set_range(0, 9)
  87. self.excellon_format_lower_in_entry.setMinimumWidth(30)
  88. self.excellon_format_lower_in_entry.setToolTip(
  89. _("This numbers signify the number of digits in\n"
  90. "the decimal part of Excellon coordinates.")
  91. )
  92. hlay1.addWidget(self.excellon_format_lower_in_entry)
  93. grid2.addWidget(self.excellon_format_in_label, 1, 0)
  94. grid2.addLayout(hlay1, 1, 1)
  95. self.excellon_format_mm_label = QtWidgets.QLabel('%s:' % _("METRIC"))
  96. self.excellon_format_mm_label.setToolTip(_("Default values for METRIC are 3:3"))
  97. hlay2 = QtWidgets.QHBoxLayout()
  98. self.excellon_format_upper_mm_entry = FCSpinner()
  99. self.excellon_format_upper_mm_entry.set_range(0, 9)
  100. self.excellon_format_upper_mm_entry.setMinimumWidth(30)
  101. self.excellon_format_upper_mm_entry.setToolTip(
  102. _("This numbers signify the number of digits in\n"
  103. "the whole part of Excellon coordinates.")
  104. )
  105. hlay2.addWidget(self.excellon_format_upper_mm_entry)
  106. excellon_separator_mm_label = QtWidgets.QLabel(':')
  107. excellon_separator_mm_label.setFixedWidth(5)
  108. hlay2.addWidget(excellon_separator_mm_label, QtCore.Qt.AlignLeft)
  109. self.excellon_format_lower_mm_entry = FCSpinner()
  110. self.excellon_format_lower_mm_entry.set_range(0, 9)
  111. self.excellon_format_lower_mm_entry.setMinimumWidth(30)
  112. self.excellon_format_lower_mm_entry.setToolTip(
  113. _("This numbers signify the number of digits in\n"
  114. "the decimal part of Excellon coordinates.")
  115. )
  116. hlay2.addWidget(self.excellon_format_lower_mm_entry)
  117. grid2.addWidget(self.excellon_format_mm_label, 2, 0)
  118. grid2.addLayout(hlay2, 2, 1)
  119. self.excellon_zeros_label = QtWidgets.QLabel('%s:' % _('Zeros'))
  120. self.excellon_zeros_label.setAlignment(QtCore.Qt.AlignLeft)
  121. self.excellon_zeros_label.setToolTip(
  122. _("This sets the type of Excellon zeros.\n"
  123. "If LZ then Leading Zeros are kept and\n"
  124. "Trailing Zeros are removed.\n"
  125. "If TZ is checked then Trailing Zeros are kept\n"
  126. "and Leading Zeros are removed.\n\n"
  127. "This is used when there is no information\n"
  128. "stored in the Excellon file.")
  129. )
  130. grid2.addWidget(self.excellon_zeros_label, 3, 0)
  131. self.excellon_zeros_radio = RadioSet([{'label': _('LZ'), 'value': 'L'},
  132. {'label': _('TZ'), 'value': 'T'}])
  133. grid2.addWidget(self.excellon_zeros_radio, 3, 1)
  134. self.excellon_units_label = QtWidgets.QLabel('%s:' % _('Units'))
  135. self.excellon_units_label.setAlignment(QtCore.Qt.AlignLeft)
  136. self.excellon_units_label.setToolTip(
  137. _("This sets the default units of Excellon files.\n"
  138. "If it is not detected in the parsed file the value here\n"
  139. "will be used."
  140. "Some Excellon files don't have an header\n"
  141. "therefore this parameter will be used.")
  142. )
  143. self.excellon_units_radio = RadioSet([{'label': _('INCH'), 'value': 'INCH'},
  144. {'label': _('MM'), 'value': 'METRIC'}])
  145. self.excellon_units_radio.setToolTip(
  146. _("This sets the units of Excellon files.\n"
  147. "Some Excellon files don't have an header\n"
  148. "therefore this parameter will be used.")
  149. )
  150. grid2.addWidget(self.excellon_units_label, 4, 0)
  151. grid2.addWidget(self.excellon_units_radio, 4, 1)
  152. self.update_excellon_cb = FCCheckBox(label=_('Update Export settings'))
  153. self.update_excellon_cb.setToolTip(
  154. "If checked, the Excellon Export settings will be updated with the ones above."
  155. )
  156. grid2.addWidget(self.update_excellon_cb, 5, 0, 1, 2)
  157. # Adding the Excellon Format Defaults Button
  158. self.excellon_defaults_button = QtWidgets.QPushButton()
  159. self.excellon_defaults_button.setText(str(_("Restore Defaults")))
  160. self.excellon_defaults_button.setMinimumWidth(80)
  161. grid2.addWidget(self.excellon_defaults_button, 6, 0, 1, 2)
  162. separator_line = QtWidgets.QFrame()
  163. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  164. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  165. grid2.addWidget(separator_line, 7, 0, 1, 2)
  166. self.excellon_general_label = QtWidgets.QLabel("<b>%s:</b>" % _("Excellon Optimization"))
  167. grid2.addWidget(self.excellon_general_label, 8, 0, 1, 2)
  168. self.excellon_optimization_label = QtWidgets.QLabel(_('Algorithm:'))
  169. self.excellon_optimization_label.setToolTip(
  170. _("This sets the optimization type for the Excellon drill path.\n"
  171. "If <<MetaHeuristic>> is checked then Google OR-Tools algorithm with\n"
  172. "MetaHeuristic Guided Local Path is used. Default search time is 3sec.\n"
  173. "If <<Basic>> is checked then Google OR-Tools Basic algorithm is used.\n"
  174. "If <<TSA>> is checked then Travelling Salesman algorithm is used for\n"
  175. "drill path optimization.\n"
  176. "\n"
  177. "If this control is disabled, then FlatCAM works in 32bit mode and it uses\n"
  178. "Travelling Salesman algorithm for path optimization.")
  179. )
  180. self.excellon_optimization_radio = RadioSet([{'label': _('MetaHeuristic'), 'value': 'M'},
  181. {'label': _('Basic'), 'value': 'B'},
  182. {'label': _('TSA'), 'value': 'T'}],
  183. orientation='vertical', stretch=False)
  184. self.excellon_optimization_radio.setToolTip(
  185. _("This sets the optimization type for the Excellon drill path.\n"
  186. "If <<MetaHeuristic>> is checked then Google OR-Tools algorithm with\n"
  187. "MetaHeuristic Guided Local Path is used. Default search time is 3sec.\n"
  188. "If <<Basic>> is checked then Google OR-Tools Basic algorithm is used.\n"
  189. "If <<TSA>> is checked then Travelling Salesman algorithm is used for\n"
  190. "drill path optimization.\n"
  191. "\n"
  192. "If this control is disabled, then FlatCAM works in 32bit mode and it uses\n"
  193. "Travelling Salesman algorithm for path optimization.")
  194. )
  195. grid2.addWidget(self.excellon_optimization_label, 9, 0)
  196. grid2.addWidget(self.excellon_optimization_radio, 9, 1)
  197. self.optimization_time_label = QtWidgets.QLabel('%s:' % _('Duration'))
  198. self.optimization_time_label.setAlignment(QtCore.Qt.AlignLeft)
  199. self.optimization_time_label.setToolTip(
  200. _("When OR-Tools Metaheuristic (MH) is enabled there is a\n"
  201. "maximum threshold for how much time is spent doing the\n"
  202. "path optimization. This max duration is set here.\n"
  203. "In seconds.")
  204. )
  205. self.optimization_time_entry = FCSpinner()
  206. self.optimization_time_entry.set_range(0, 999)
  207. grid2.addWidget(self.optimization_time_label, 10, 0)
  208. grid2.addWidget(self.optimization_time_entry, 10, 1)
  209. separator_line = QtWidgets.QFrame()
  210. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  211. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  212. grid2.addWidget(separator_line, 11, 0, 1, 2)
  213. # Excellon Object Color
  214. self.gerber_color_label = QtWidgets.QLabel('<b>%s</b>' % _('Excellon Object Color'))
  215. grid2.addWidget(self.gerber_color_label, 12, 0, 1, 2)
  216. # Plot Line Color
  217. self.line_color_label = QtWidgets.QLabel('%s:' % _('Outline'))
  218. self.line_color_label.setToolTip(
  219. _("Set the line color for plotted objects.")
  220. )
  221. self.line_color_entry = FCEntry()
  222. self.line_color_button = QtWidgets.QPushButton()
  223. self.line_color_button.setFixedSize(15, 15)
  224. self.form_box_child_2 = QtWidgets.QHBoxLayout()
  225. self.form_box_child_2.addWidget(self.line_color_entry)
  226. self.form_box_child_2.addWidget(self.line_color_button)
  227. self.form_box_child_2.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  228. grid2.addWidget(self.line_color_label, 13, 0)
  229. grid2.addLayout(self.form_box_child_2, 13, 1)
  230. # Plot Fill Color
  231. self.fill_color_label = QtWidgets.QLabel('%s:' % _('Fill'))
  232. self.fill_color_label.setToolTip(
  233. _("Set the fill color for plotted objects.\n"
  234. "First 6 digits are the color and the last 2\n"
  235. "digits are for alpha (transparency) level.")
  236. )
  237. self.fill_color_entry = FCEntry()
  238. self.fill_color_button = QtWidgets.QPushButton()
  239. self.fill_color_button.setFixedSize(15, 15)
  240. self.form_box_child_1 = QtWidgets.QHBoxLayout()
  241. self.form_box_child_1.addWidget(self.fill_color_entry)
  242. self.form_box_child_1.addWidget(self.fill_color_button)
  243. self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  244. grid2.addWidget(self.fill_color_label, 14, 0)
  245. grid2.addLayout(self.form_box_child_1, 14, 1)
  246. # Plot Fill Transparency Level
  247. self.alpha_label = QtWidgets.QLabel('%s:' % _('Alpha'))
  248. self.alpha_label.setToolTip(
  249. _("Set the fill transparency for plotted objects.")
  250. )
  251. self.color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  252. self.color_alpha_slider.setMinimum(0)
  253. self.color_alpha_slider.setMaximum(255)
  254. self.color_alpha_slider.setSingleStep(1)
  255. self.color_alpha_spinner = FCSpinner()
  256. self.color_alpha_spinner.setMinimumWidth(70)
  257. self.color_alpha_spinner.set_range(0, 255)
  258. self.form_box_child_3 = QtWidgets.QHBoxLayout()
  259. self.form_box_child_3.addWidget(self.color_alpha_slider)
  260. self.form_box_child_3.addWidget(self.color_alpha_spinner)
  261. grid2.addWidget(self.alpha_label, 15, 0)
  262. grid2.addLayout(self.form_box_child_3, 15, 1)
  263. self.layout.addStretch()
  264. current_platform = platform.architecture()[0]
  265. if current_platform == '64bit':
  266. self.excellon_optimization_label.setDisabled(False)
  267. self.excellon_optimization_radio.setDisabled(False)
  268. self.optimization_time_label.setDisabled(False)
  269. self.optimization_time_entry.setDisabled(False)
  270. self.excellon_optimization_radio.activated_custom.connect(self.optimization_selection)
  271. else:
  272. self.excellon_optimization_label.setDisabled(True)
  273. self.excellon_optimization_radio.setDisabled(True)
  274. self.optimization_time_label.setDisabled(True)
  275. self.optimization_time_entry.setDisabled(True)
  276. # Setting plot colors signals
  277. self.line_color_entry.editingFinished.connect(self.on_line_color_entry)
  278. self.line_color_button.clicked.connect(self.on_line_color_button)
  279. self.fill_color_entry.editingFinished.connect(self.on_fill_color_entry)
  280. self.fill_color_button.clicked.connect(self.on_fill_color_button)
  281. self.color_alpha_spinner.valueChanged.connect(self.on_color_spinner)
  282. self.color_alpha_slider.valueChanged.connect(self.on_color_slider)
  283. # Load the defaults values into the Excellon Format and Excellon Zeros fields
  284. self.excellon_defaults_button.clicked.connect(self.on_excellon_defaults_button)
  285. # Make sure that when the Excellon loading parameters are changed, the change is reflected in the
  286. # Export Excellon parameters.
  287. self.update_excellon_cb.stateChanged.connect(self.on_update_exc_export)
  288. # call it once to make sure it is updated at startup
  289. self.on_update_exc_export(state=self.app.defaults["excellon_update"])
  290. def optimization_selection(self):
  291. if self.excellon_optimization_radio.get_value() == 'M':
  292. self.optimization_time_label.setDisabled(False)
  293. self.optimization_time_entry.setDisabled(False)
  294. else:
  295. self.optimization_time_label.setDisabled(True)
  296. self.optimization_time_entry.setDisabled(True)
  297. # Setting plot colors handlers
  298. def on_fill_color_entry(self):
  299. self.app.defaults['excellon_plot_fill'] = self.fill_color_entry.get_value()[:7] + \
  300. self.app.defaults['excellon_plot_fill'][7:9]
  301. self.fill_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['excellon_plot_fill'])[:7])
  302. def on_fill_color_button(self):
  303. current_color = QtGui.QColor(self.app.defaults['excellon_plot_fill'][:7])
  304. c_dialog = QtWidgets.QColorDialog()
  305. plot_fill_color = c_dialog.getColor(initial=current_color)
  306. if plot_fill_color.isValid() is False:
  307. return
  308. self.fill_color_button.setStyleSheet("background-color:%s" % str(plot_fill_color.name()))
  309. new_val = str(plot_fill_color.name()) + str(self.app.defaults['excellon_plot_fill'][7:9])
  310. self.fill_color_entry.set_value(new_val)
  311. self.app.defaults['excellon_plot_fill'] = new_val
  312. def on_color_spinner(self):
  313. spinner_value = self.color_alpha_spinner.value()
  314. self.color_alpha_slider.setValue(spinner_value)
  315. self.app.defaults['excellon_plot_fill'] = \
  316. self.app.defaults['excellon_plot_fill'][:7] + \
  317. (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
  318. self.app.defaults['excellon_plot_line'] = \
  319. self.app.defaults['excellon_plot_line'][:7] + \
  320. (hex(spinner_value)[2:] if int(hex(spinner_value)[2:], 16) > 0 else '00')
  321. def on_color_slider(self):
  322. slider_value = self.color_alpha_slider.value()
  323. self.color_alpha_spinner.setValue(slider_value)
  324. def on_line_color_entry(self):
  325. self.app.defaults['excellon_plot_line'] = self.line_color_entry.get_value()[:7] + \
  326. self.app.defaults['excellon_plot_line'][7:9]
  327. self.line_color_button.setStyleSheet("background-color:%s" % str(self.app.defaults['excellon_plot_line'])[:7])
  328. def on_line_color_button(self):
  329. current_color = QtGui.QColor(self.app.defaults['excellon_plot_line'][:7])
  330. # print(current_color)
  331. c_dialog = QtWidgets.QColorDialog()
  332. plot_line_color = c_dialog.getColor(initial=current_color)
  333. if plot_line_color.isValid() is False:
  334. return
  335. self.line_color_button.setStyleSheet("background-color:%s" % str(plot_line_color.name()))
  336. new_val_line = str(plot_line_color.name()) + str(self.app.defaults['excellon_plot_line'][7:9])
  337. self.line_color_entry.set_value(new_val_line)
  338. self.app.defaults['excellon_plot_line'] = new_val_line
  339. def on_excellon_defaults_button(self):
  340. self.app.preferencesUiManager.defaults_form_fields["excellon_format_lower_in"].set_value('4')
  341. self.app.preferencesUiManager.defaults_form_fields["excellon_format_upper_in"].set_value('2')
  342. self.app.preferencesUiManager.defaults_form_fields["excellon_format_lower_mm"].set_value('3')
  343. self.app.preferencesUiManager.defaults_form_fields["excellon_format_upper_mm"].set_value('3')
  344. self.app.preferencesUiManager.defaults_form_fields["excellon_zeros"].set_value('L')
  345. self.app.preferencesUiManager.defaults_form_fields["excellon_units"].set_value('INCH')
  346. def on_update_exc_export(self, state):
  347. """
  348. This is handling the update of Excellon Export parameters based on the ones in the Excellon General but only
  349. if the update_excellon_cb checkbox is checked
  350. :param state: state of the checkbox whose signals is tied to his slot
  351. :return:
  352. """
  353. if state:
  354. # first try to disconnect
  355. try:
  356. self.excellon_format_upper_in_entry.returnPressed.disconnect(self.on_excellon_format_changed)
  357. except TypeError:
  358. pass
  359. try:
  360. self.excellon_format_lower_in_entry.returnPressed.disconnect(self.on_excellon_format_changed)
  361. except TypeError:
  362. pass
  363. try:
  364. self.excellon_format_upper_mm_entry.returnPressed.disconnect(self.on_excellon_format_changed)
  365. except TypeError:
  366. pass
  367. try:
  368. self.excellon_format_lower_mm_entry.returnPressed.disconnect(self.on_excellon_format_changed)
  369. except TypeError:
  370. pass
  371. try:
  372. self.excellon_zeros_radio.activated_custom.disconnect(self.on_excellon_zeros_changed)
  373. except TypeError:
  374. pass
  375. try:
  376. self.excellon_units_radio.activated_custom.disconnect(self.on_excellon_zeros_changed)
  377. except TypeError:
  378. pass
  379. # the connect them
  380. self.excellon_format_upper_in_entry.returnPressed.connect(self.on_excellon_format_changed)
  381. self.excellon_format_lower_in_entry.returnPressed.connect(self.on_excellon_format_changed)
  382. self.excellon_format_upper_mm_entry.returnPressed.connect(self.on_excellon_format_changed)
  383. self.excellon_format_lower_mm_entry.returnPressed.connect(self.on_excellon_format_changed)
  384. self.excellon_zeros_radio.activated_custom.connect(self.on_excellon_zeros_changed)
  385. self.excellon_units_radio.activated_custom.connect(self.on_excellon_units_changed)
  386. else:
  387. # disconnect the signals
  388. try:
  389. self.excellon_format_upper_in_entry.returnPressed.disconnect(self.on_excellon_format_changed)
  390. except TypeError:
  391. pass
  392. try:
  393. self.excellon_format_lower_in_entry.returnPressed.disconnect(self.on_excellon_format_changed)
  394. except TypeError:
  395. pass
  396. try:
  397. self.excellon_format_upper_mm_entry.returnPressed.disconnect(self.on_excellon_format_changed)
  398. except TypeError:
  399. pass
  400. try:
  401. self.excellon_format_lower_mm_entry.returnPressed.disconnect(self.on_excellon_format_changed)
  402. except TypeError:
  403. pass
  404. try:
  405. self.excellon_zeros_radio.activated_custom.disconnect(self.on_excellon_zeros_changed)
  406. except TypeError:
  407. pass
  408. try:
  409. self.excellon_units_radio.activated_custom.disconnect(self.on_excellon_zeros_changed)
  410. except TypeError:
  411. pass
  412. def on_excellon_format_changed(self):
  413. """
  414. Slot activated when the user changes the Excellon format values in Preferences -> Excellon -> Excellon General
  415. :return: None
  416. """
  417. if self.excellon_units_radio.get_value().upper() == 'METRIC':
  418. self.app.ui.excellon_defaults_form.excellon_exp_group.format_whole_entry.set_value(
  419. self.excellon_format_upper_mm_entry.get_value())
  420. self.app.ui.excellon_defaults_form.excellon_exp_group.format_dec_entry.set_value(
  421. self.excellon_format_lower_mm_entry.get_value())
  422. else:
  423. self.app.ui.excellon_defaults_form.excellon_exp_group.format_whole_entry.set_value(
  424. self.excellon_format_upper_in_entry.get_value())
  425. self.app.ui.excellon_defaults_form.excellon_exp_group.format_dec_entry.set_value(
  426. self.excellon_format_lower_in_entry.get_value())
  427. def on_excellon_zeros_changed(self, val):
  428. """
  429. Slot activated when the user changes the Excellon zeros values in Preferences -> Excellon -> Excellon General
  430. :return: None
  431. """
  432. self.app.ui.excellon_defaults_form.excellon_exp_group.zeros_radio.set_value(val + 'Z')
  433. def on_excellon_units_changed(self, val):
  434. """
  435. Slot activated when the user changes the Excellon unit values in Preferences -> Excellon -> Excellon General
  436. :return: None
  437. """
  438. self.app.ui.excellon_defaults_form.excellon_exp_group.excellon_units_radio.set_value(val)
  439. self.on_excellon_format_changed()