GerberAdvOptPrefGroupUI.py 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import QSettings
  3. from appGUI.GUIElements import FCCheckBox, RadioSet, FCDoubleSpinner, FCSpinner, OptionalInputSection
  4. from appGUI.preferences.OptionsGroupUI import OptionsGroupUI
  5. import gettext
  6. import appTranslation as fcTranslate
  7. import builtins
  8. fcTranslate.apply_language('strings')
  9. if '_' not in builtins.__dict__:
  10. _ = gettext.gettext
  11. settings = QSettings("Open Source", "FlatCAM")
  12. if settings.contains("machinist"):
  13. machinist_setting = settings.value('machinist', type=int)
  14. else:
  15. machinist_setting = 0
  16. class GerberAdvOptPrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. # OptionsGroupUI.__init__(self, "Gerber Adv. Options Preferences", parent=parent)
  19. super(GerberAdvOptPrefGroupUI, self).__init__(self, parent=parent)
  20. self.setTitle(str(_("Gerber Adv. Options")))
  21. self.decimals = decimals
  22. # ## Advanced Gerber Parameters
  23. self.adv_param_label = QtWidgets.QLabel('<b>%s:</b>' % _('Advanced Options'))
  24. self.adv_param_label.setToolTip(
  25. _("A list of Gerber advanced parameters.\n"
  26. "Those parameters are available only for\n"
  27. "Advanced App. Level.")
  28. )
  29. self.layout.addWidget(self.adv_param_label)
  30. grid0 = QtWidgets.QGridLayout()
  31. self.layout.addLayout(grid0)
  32. # Follow Attribute
  33. self.follow_cb = FCCheckBox(label=_('"Follow"'))
  34. self.follow_cb.setToolTip(
  35. _("Generate a 'Follow' geometry.\n"
  36. "This means that it will cut through\n"
  37. "the middle of the trace.")
  38. )
  39. grid0.addWidget(self.follow_cb, 0, 0, 1, 2)
  40. # Aperture Table Visibility CB
  41. self.aperture_table_visibility_cb = FCCheckBox(label=_('Table Show/Hide'))
  42. self.aperture_table_visibility_cb.setToolTip(
  43. _("Toggle the display of the Gerber Apertures Table.\n"
  44. "Also, on hide, it will delete all mark shapes\n"
  45. "that are drawn on canvas.")
  46. )
  47. grid0.addWidget(self.aperture_table_visibility_cb, 1, 0, 1, 2)
  48. separator_line = QtWidgets.QFrame()
  49. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  50. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  51. grid0.addWidget(separator_line, 2, 0, 1, 2)
  52. # Buffering Type
  53. buffering_label = QtWidgets.QLabel('%s:' % _('Buffering'))
  54. buffering_label.setToolTip(
  55. _("Buffering type:\n"
  56. "- None --> best performance, fast file loading but no so good display\n"
  57. "- Full --> slow file loading but good visuals. This is the default.\n"
  58. "<<WARNING>>: Don't change this unless you know what you are doing !!!")
  59. )
  60. self.buffering_radio = RadioSet([{'label': _('None'), 'value': 'no'},
  61. {'label': _('Full'), 'value': 'full'}])
  62. grid0.addWidget(buffering_label, 9, 0)
  63. grid0.addWidget(self.buffering_radio, 9, 1)
  64. # Delayed Buffering
  65. self.delayed_buffer_cb = FCCheckBox(label=_('Delayed Buffering'))
  66. self.delayed_buffer_cb.setToolTip(
  67. _("When checked it will do the buffering in background.")
  68. )
  69. grid0.addWidget(self.delayed_buffer_cb, 10, 0, 1, 2)
  70. # Simplification
  71. self.simplify_cb = FCCheckBox(label=_('Simplify'))
  72. self.simplify_cb.setToolTip(
  73. _("When checked all the Gerber polygons will be\n"
  74. "loaded with simplification having a set tolerance.\n"
  75. "<<WARNING>>: Don't change this unless you know what you are doing !!!")
  76. )
  77. grid0.addWidget(self.simplify_cb, 11, 0, 1, 2)
  78. # Simplification tolerance
  79. self.simplification_tol_label = QtWidgets.QLabel(_('Tolerance'))
  80. self.simplification_tol_label.setToolTip(_("Tolerance for polygon simplification."))
  81. self.simplification_tol_spinner = FCDoubleSpinner()
  82. self.simplification_tol_spinner.set_precision(self.decimals + 1)
  83. self.simplification_tol_spinner.setWrapping(True)
  84. self.simplification_tol_spinner.setRange(0.00000, 0.01000)
  85. self.simplification_tol_spinner.setSingleStep(0.0001)
  86. grid0.addWidget(self.simplification_tol_label, 12, 0)
  87. grid0.addWidget(self.simplification_tol_spinner, 12, 1)
  88. self.ois_simplif = OptionalInputSection(
  89. self.simplify_cb,
  90. [
  91. self.simplification_tol_label, self.simplification_tol_spinner
  92. ],
  93. logic=True)
  94. self.layout.addStretch()
  95. # signals
  96. self.buffering_radio.activated_custom.connect(self.on_buffering_change)
  97. def on_buffering_change(self, val):
  98. if val == 'no':
  99. self.delayed_buffer_cb.setDisabled(False)
  100. else:
  101. self.delayed_buffer_cb.setDisabled(True)