GerberOptPrefGroupUI.py 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import QSettings
  3. from appGUI.GUIElements import FCDoubleSpinner, FCSpinner, RadioSet, FCCheckBox, FCComboBox
  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 GerberOptPrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. # OptionsGroupUI.__init__(self, "Gerber Options Preferences", parent=parent)
  19. super(GerberOptPrefGroupUI, self).__init__(self, parent=parent)
  20. self.decimals = decimals
  21. self.setTitle(str(_("Gerber Options")))
  22. # ## Clear non-copper regions
  23. self.clearcopper_label = QtWidgets.QLabel("<b>%s:</b>" % _("Non-copper regions"))
  24. self.clearcopper_label.setToolTip(
  25. _("Create polygons covering the\n"
  26. "areas without copper on the PCB.\n"
  27. "Equivalent to the inverse of this\n"
  28. "object. Can be used to remove all\n"
  29. "copper from a specified region.")
  30. )
  31. self.layout.addWidget(self.clearcopper_label)
  32. grid1 = QtWidgets.QGridLayout()
  33. self.layout.addLayout(grid1)
  34. # Margin
  35. bmlabel = QtWidgets.QLabel('%s:' % _('Boundary Margin'))
  36. bmlabel.setToolTip(
  37. _("Specify the edge of the PCB\n"
  38. "by drawing a box around all\n"
  39. "objects with this minimum\n"
  40. "distance.")
  41. )
  42. grid1.addWidget(bmlabel, 0, 0)
  43. self.noncopper_margin_entry = FCDoubleSpinner()
  44. self.noncopper_margin_entry.set_precision(self.decimals)
  45. self.noncopper_margin_entry.setSingleStep(0.1)
  46. self.noncopper_margin_entry.set_range(-9999, 9999)
  47. grid1.addWidget(self.noncopper_margin_entry, 0, 1)
  48. # Rounded corners
  49. self.noncopper_rounded_cb = FCCheckBox(label=_("Rounded Geo"))
  50. self.noncopper_rounded_cb.setToolTip(
  51. _("Resulting geometry will have rounded corners.")
  52. )
  53. grid1.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  54. separator_line = QtWidgets.QFrame()
  55. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  56. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  57. grid1.addWidget(separator_line, 2, 0, 1, 2)
  58. # ## Bounding box
  59. self.boundingbox_label = QtWidgets.QLabel('<b>%s:</b>' % _('Bounding Box'))
  60. self.layout.addWidget(self.boundingbox_label)
  61. grid2 = QtWidgets.QGridLayout()
  62. self.layout.addLayout(grid2)
  63. bbmargin = QtWidgets.QLabel('%s:' % _('Boundary Margin'))
  64. bbmargin.setToolTip(
  65. _("Distance of the edges of the box\n"
  66. "to the nearest polygon.")
  67. )
  68. self.bbmargin_entry = FCDoubleSpinner()
  69. self.bbmargin_entry.set_precision(self.decimals)
  70. self.bbmargin_entry.setSingleStep(0.1)
  71. self.bbmargin_entry.set_range(-9999, 9999)
  72. grid2.addWidget(bbmargin, 0, 0)
  73. grid2.addWidget(self.bbmargin_entry, 0, 1)
  74. self.bbrounded_cb = FCCheckBox(label='%s' % _("Rounded Geo"))
  75. self.bbrounded_cb.setToolTip(
  76. _("If the bounding box is \n"
  77. "to have rounded corners\n"
  78. "their radius is equal to\n"
  79. "the margin.")
  80. )
  81. grid2.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  82. self.layout.addStretch()