ToolsCutoutPrefGroupUI.py 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import QSettings
  3. from appGUI.GUIElements import FCDoubleSpinner, FCCheckBox, RadioSet, FCComboBox, FCLabel
  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 = FCLabel("<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 = FCLabel('%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, 10000.0000)
  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 = FCLabel('%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(-10000.0000, 0.0000)
  56. else:
  57. self.cutz_entry.setRange(-10000.0000, 10000.0000)
  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, 10000.0000)
  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 = FCLabel('%s:' % _('Kind'))
  80. kindlabel.setToolTip(
  81. _("Choice of what kind the object we want to cutout is.\n"
  82. "- Single: contain a single PCB Gerber outline object.\n"
  83. "- Panel: 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 = FCLabel('%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(-10000.0000, 10000.0000)
  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. # Gap Size
  105. gaplabel = FCLabel('%s:' % _('Gap size'))
  106. gaplabel.setToolTip(
  107. _("The size of the bridge gaps in the cutout\n"
  108. "used to keep the board connected to\n"
  109. "the surrounding material (the one \n"
  110. "from which the PCB is cutout).")
  111. )
  112. self.cutout_gap_entry = FCDoubleSpinner()
  113. self.cutout_gap_entry.set_range(0.000001, 10000.0000)
  114. self.cutout_gap_entry.set_precision(self.decimals)
  115. self.cutout_gap_entry.setSingleStep(0.1)
  116. grid0.addWidget(gaplabel, 5, 0)
  117. grid0.addWidget(self.cutout_gap_entry, 5, 1)
  118. # Gap Type
  119. self.gaptype_label = FCLabel('%s:' % _("Gap type"))
  120. self.gaptype_label.setToolTip(
  121. _("The type of gap:\n"
  122. "- Bridge -> the cutout will be interrupted by bridges\n"
  123. "- Thin -> same as 'bridge' but it will be thinner by partially milling the gap\n"
  124. "- M-Bites -> 'Mouse Bites' - same as 'bridge' but covered with drill holes")
  125. )
  126. self.gaptype_radio = RadioSet(
  127. [
  128. {'label': _('Bridge'), 'value': 'b'},
  129. {'label': _('Thin'), 'value': 'bt'},
  130. {'label': "M-Bites", 'value': 'mb'}
  131. ],
  132. stretch=True
  133. )
  134. grid0.addWidget(self.gaptype_label, 7, 0)
  135. grid0.addWidget(self.gaptype_radio, 7, 1)
  136. # Thin gaps Depth
  137. self.thin_depth_label = FCLabel('%s:' % _("Depth"))
  138. self.thin_depth_label.setToolTip(
  139. _("The depth until the milling is done\n"
  140. "in order to thin the gaps.")
  141. )
  142. self.thin_depth_entry = FCDoubleSpinner()
  143. self.thin_depth_entry.set_precision(self.decimals)
  144. if machinist_setting == 0:
  145. self.thin_depth_entry.setRange(-10000.0000, -0.00001)
  146. else:
  147. self.thin_depth_entry.setRange(-10000.0000, 10000.0000)
  148. self.thin_depth_entry.setSingleStep(0.1)
  149. grid0.addWidget(self.thin_depth_label, 9, 0)
  150. grid0.addWidget(self.thin_depth_entry, 9, 1)
  151. # Mouse Bites Tool Diameter
  152. self.mb_dia_label = FCLabel('%s:' % _("Tool Diameter"))
  153. self.mb_dia_label.setToolTip(
  154. _("The drill hole diameter when doing mouse bites.")
  155. )
  156. self.mb_dia_entry = FCDoubleSpinner()
  157. self.mb_dia_entry.set_precision(self.decimals)
  158. self.mb_dia_entry.setRange(0, 100.0000)
  159. grid0.addWidget(self.mb_dia_label, 11, 0)
  160. grid0.addWidget(self.mb_dia_entry, 11, 1)
  161. # Mouse Bites Holes Spacing
  162. self.mb_spacing_label = FCLabel('%s:' % _("Spacing"))
  163. self.mb_spacing_label.setToolTip(
  164. _("The spacing between drill holes when doing mouse bites.")
  165. )
  166. self.mb_spacing_entry = FCDoubleSpinner()
  167. self.mb_spacing_entry.set_precision(self.decimals)
  168. self.mb_spacing_entry.setRange(0, 100.0000)
  169. grid0.addWidget(self.mb_spacing_label, 13, 0)
  170. grid0.addWidget(self.mb_spacing_entry, 13, 1)
  171. gaps_label = FCLabel('%s:' % _('Gaps'))
  172. gaps_label.setToolTip(
  173. _("Number of gaps used for the cutout.\n"
  174. "There can be maximum 8 bridges/gaps.\n"
  175. "The choices are:\n"
  176. "- None - no gaps\n"
  177. "- lr - left + right\n"
  178. "- tb - top + bottom\n"
  179. "- 4 - left + right +top + bottom\n"
  180. "- 2lr - 2*left + 2*right\n"
  181. "- 2tb - 2*top + 2*bottom\n"
  182. "- 8 - 2*left + 2*right +2*top + 2*bottom")
  183. )
  184. self.gaps_combo = FCComboBox()
  185. grid0.addWidget(gaps_label, 15, 0)
  186. grid0.addWidget(self.gaps_combo, 15, 1)
  187. gaps_items = ['None', 'LR', 'TB', '4', '2LR', '2TB', '8']
  188. for it in gaps_items:
  189. self.gaps_combo.addItem(it)
  190. # self.gaps_combo.setStyleSheet('background-color: rgb(255,255,255)')
  191. # Surrounding convex box shape
  192. self.convex_box = FCCheckBox('%s' % _("Convex Shape"))
  193. self.convex_box.setToolTip(
  194. _("Create a convex shape surrounding the entire PCB.\n"
  195. "Used only if the source object type is Gerber.")
  196. )
  197. grid0.addWidget(self.convex_box, 17, 0, 1, 2)
  198. self.big_cursor_cb = FCCheckBox('%s' % _("Big cursor"))
  199. self.big_cursor_cb.setToolTip(
  200. _("Use a big cursor when adding manual gaps."))
  201. grid0.addWidget(self.big_cursor_cb, 19, 0, 1, 2)
  202. self.layout.addStretch()