ToolsCutoutPrefGroupUI.py 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import QSettings
  3. from AppGUI.GUIElements import FCDoubleSpinner, FCCheckBox, RadioSet, FCComboBox
  4. from AppGUI.preferences import machinist_setting
  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 ToolsCutoutPrefGroupUI(OptionsGroupUI):
  18. def __init__(self, decimals=4, parent=None):
  19. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  20. super(ToolsCutoutPrefGroupUI, self).__init__(self, parent=parent)
  21. self.setTitle(str(_("Cutout Tool Options")))
  22. self.decimals = decimals
  23. # ## Board cutout
  24. self.board_cutout_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
  25. self.board_cutout_label.setToolTip(
  26. _("Create toolpaths to cut around\n"
  27. "the PCB and separate it from\n"
  28. "the original board.")
  29. )
  30. self.layout.addWidget(self.board_cutout_label)
  31. grid0 = QtWidgets.QGridLayout()
  32. self.layout.addLayout(grid0)
  33. tdclabel = QtWidgets.QLabel('%s:' % _('Tool Diameter'))
  34. tdclabel.setToolTip(
  35. _("Diameter of the tool used to cutout\n"
  36. "the PCB shape out of the surrounding material.")
  37. )
  38. self.cutout_tooldia_entry = FCDoubleSpinner()
  39. self.cutout_tooldia_entry.set_range(0.000001, 9999.9999)
  40. self.cutout_tooldia_entry.set_precision(self.decimals)
  41. self.cutout_tooldia_entry.setSingleStep(0.1)
  42. grid0.addWidget(tdclabel, 0, 0)
  43. grid0.addWidget(self.cutout_tooldia_entry, 0, 1)
  44. # Cut Z
  45. cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
  46. cutzlabel.setToolTip(
  47. _(
  48. "Cutting depth (negative)\n"
  49. "below the copper surface."
  50. )
  51. )
  52. self.cutz_entry = FCDoubleSpinner()
  53. self.cutz_entry.set_precision(self.decimals)
  54. if machinist_setting == 0:
  55. self.cutz_entry.setRange(-9999.9999, 0.0000)
  56. else:
  57. self.cutz_entry.setRange(-9999.9999, 9999.9999)
  58. self.cutz_entry.setSingleStep(0.1)
  59. grid0.addWidget(cutzlabel, 1, 0)
  60. grid0.addWidget(self.cutz_entry, 1, 1)
  61. # Multi-pass
  62. self.mpass_cb = FCCheckBox('%s:' % _("Multi-Depth"))
  63. self.mpass_cb.setToolTip(
  64. _(
  65. "Use multiple passes to limit\n"
  66. "the cut depth in each pass. Will\n"
  67. "cut multiple times until Cut Z is\n"
  68. "reached."
  69. )
  70. )
  71. self.maxdepth_entry = FCDoubleSpinner()
  72. self.maxdepth_entry.set_precision(self.decimals)
  73. self.maxdepth_entry.setRange(0, 9999.9999)
  74. self.maxdepth_entry.setSingleStep(0.1)
  75. self.maxdepth_entry.setToolTip(_("Depth of each pass (positive)."))
  76. grid0.addWidget(self.mpass_cb, 2, 0)
  77. grid0.addWidget(self.maxdepth_entry, 2, 1)
  78. # Object kind
  79. kindlabel = QtWidgets.QLabel('%s:' % _('Object kind'))
  80. kindlabel.setToolTip(
  81. _("Choice of what kind the object we want to cutout is.<BR>"
  82. "- <B>Single</B>: contain a single PCB Gerber outline object.<BR>"
  83. "- <B>Panel</B>: a panel PCB Gerber object, which is made\n"
  84. "out of many individual PCB outlines.")
  85. )
  86. self.obj_kind_combo = RadioSet([
  87. {"label": _("Single"), "value": "single"},
  88. {"label": _("Panel"), "value": "panel"},
  89. ])
  90. grid0.addWidget(kindlabel, 3, 0)
  91. grid0.addWidget(self.obj_kind_combo, 3, 1)
  92. marginlabel = QtWidgets.QLabel('%s:' % _('Margin'))
  93. marginlabel.setToolTip(
  94. _("Margin over bounds. A positive value here\n"
  95. "will make the cutout of the PCB further from\n"
  96. "the actual PCB border")
  97. )
  98. self.cutout_margin_entry = FCDoubleSpinner()
  99. self.cutout_margin_entry.set_range(-9999.9999, 9999.9999)
  100. self.cutout_margin_entry.set_precision(self.decimals)
  101. self.cutout_margin_entry.setSingleStep(0.1)
  102. grid0.addWidget(marginlabel, 4, 0)
  103. grid0.addWidget(self.cutout_margin_entry, 4, 1)
  104. gaplabel = QtWidgets.QLabel('%s:' % _('Gap size'))
  105. gaplabel.setToolTip(
  106. _("The size of the bridge gaps in the cutout\n"
  107. "used to keep the board connected to\n"
  108. "the surrounding material (the one \n"
  109. "from which the PCB is cutout).")
  110. )
  111. self.cutout_gap_entry = FCDoubleSpinner()
  112. self.cutout_gap_entry.set_range(0.000001, 9999.9999)
  113. self.cutout_gap_entry.set_precision(self.decimals)
  114. self.cutout_gap_entry.setSingleStep(0.1)
  115. grid0.addWidget(gaplabel, 5, 0)
  116. grid0.addWidget(self.cutout_gap_entry, 5, 1)
  117. gaps_label = QtWidgets.QLabel('%s:' % _('Gaps'))
  118. gaps_label.setToolTip(
  119. _("Number of gaps used for the cutout.\n"
  120. "There can be maximum 8 bridges/gaps.\n"
  121. "The choices are:\n"
  122. "- None - no gaps\n"
  123. "- lr - left + right\n"
  124. "- tb - top + bottom\n"
  125. "- 4 - left + right +top + bottom\n"
  126. "- 2lr - 2*left + 2*right\n"
  127. "- 2tb - 2*top + 2*bottom\n"
  128. "- 8 - 2*left + 2*right +2*top + 2*bottom")
  129. )
  130. self.gaps_combo = FCComboBox()
  131. grid0.addWidget(gaps_label, 6, 0)
  132. grid0.addWidget(self.gaps_combo, 6, 1)
  133. gaps_items = ['None', 'LR', 'TB', '4', '2LR', '2TB', '8']
  134. for it in gaps_items:
  135. self.gaps_combo.addItem(it)
  136. self.gaps_combo.setStyleSheet('background-color: rgb(255,255,255)')
  137. # Surrounding convex box shape
  138. self.convex_box = FCCheckBox('%s' % _("Convex Shape"))
  139. self.convex_box.setToolTip(
  140. _("Create a convex shape surrounding the entire PCB.\n"
  141. "Used only if the source object type is Gerber.")
  142. )
  143. grid0.addWidget(self.convex_box, 7, 0, 1, 2)
  144. self.layout.addStretch()