ToolsNCCPrefGroupUI.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. from PyQt5 import QtWidgets
  2. from flatcamGUI.GUIElements import FCEntry, RadioSet, FCDoubleSpinner, FCComboBox, FCCheckBox
  3. from flatcamGUI.preferences.OptionsGroupUI import OptionsGroupUI
  4. class ToolsNCCPrefGroupUI(OptionsGroupUI):
  5. def __init__(self, decimals=4, parent=None):
  6. # OptionsGroupUI.__init__(self, "NCC Tool Options", parent=parent)
  7. super(ToolsNCCPrefGroupUI, self).__init__(self)
  8. self.setTitle(str(_("NCC Tool Options")))
  9. self.decimals = decimals
  10. # ## Clear non-copper regions
  11. self.clearcopper_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
  12. self.clearcopper_label.setToolTip(
  13. _("Create a Geometry object with\n"
  14. "toolpaths to cut all non-copper regions.")
  15. )
  16. self.layout.addWidget(self.clearcopper_label)
  17. grid0 = QtWidgets.QGridLayout()
  18. self.layout.addLayout(grid0)
  19. ncctdlabel = QtWidgets.QLabel('<b><font color="green">%s:</font></b>' % _('Tools Dia'))
  20. ncctdlabel.setToolTip(
  21. _("Diameters of the tools, separated by comma.\n"
  22. "The value of the diameter has to use the dot decimals separator.\n"
  23. "Valid values: 0.3, 1.0")
  24. )
  25. grid0.addWidget(ncctdlabel, 0, 0)
  26. self.ncc_tool_dia_entry = FCEntry(border_color='#0069A9')
  27. self.ncc_tool_dia_entry.setPlaceholderText(_("Comma separated values"))
  28. grid0.addWidget(self.ncc_tool_dia_entry, 0, 1)
  29. # Tool Type Radio Button
  30. self.tool_type_label = QtWidgets.QLabel('%s:' % _('Tool Type'))
  31. self.tool_type_label.setToolTip(
  32. _("Default tool type:\n"
  33. "- 'V-shape'\n"
  34. "- Circular")
  35. )
  36. self.tool_type_radio = RadioSet([{'label': _('V-shape'), 'value': 'V'},
  37. {'label': _('Circular'), 'value': 'C1'}])
  38. self.tool_type_radio.setToolTip(
  39. _("Default tool type:\n"
  40. "- 'V-shape'\n"
  41. "- Circular")
  42. )
  43. grid0.addWidget(self.tool_type_label, 1, 0)
  44. grid0.addWidget(self.tool_type_radio, 1, 1)
  45. # Tip Dia
  46. self.tipdialabel = QtWidgets.QLabel('%s:' % _('V-Tip Dia'))
  47. self.tipdialabel.setToolTip(
  48. _("The tip diameter for V-Shape Tool"))
  49. self.tipdia_entry = FCDoubleSpinner()
  50. self.tipdia_entry.set_precision(self.decimals)
  51. self.tipdia_entry.set_range(0, 1000)
  52. self.tipdia_entry.setSingleStep(0.1)
  53. grid0.addWidget(self.tipdialabel, 2, 0)
  54. grid0.addWidget(self.tipdia_entry, 2, 1)
  55. # Tip Angle
  56. self.tipanglelabel = QtWidgets.QLabel('%s:' % _('V-Tip Angle'))
  57. self.tipanglelabel.setToolTip(
  58. _("The tip angle for V-Shape Tool.\n"
  59. "In degree."))
  60. self.tipangle_entry = FCDoubleSpinner()
  61. self.tipangle_entry.set_precision(self.decimals)
  62. self.tipangle_entry.set_range(1, 180)
  63. self.tipangle_entry.setSingleStep(5)
  64. self.tipangle_entry.setWrapping(True)
  65. grid0.addWidget(self.tipanglelabel, 3, 0)
  66. grid0.addWidget(self.tipangle_entry, 3, 1)
  67. # Cut Z entry
  68. cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
  69. cutzlabel.setToolTip(
  70. _("Depth of cut into material. Negative value.\n"
  71. "In FlatCAM units.")
  72. )
  73. self.cutz_entry = FCDoubleSpinner()
  74. self.cutz_entry.set_precision(self.decimals)
  75. self.cutz_entry.set_range(-9999.9999, 0.0000)
  76. self.cutz_entry.setSingleStep(0.1)
  77. self.cutz_entry.setToolTip(
  78. _("Depth of cut into material. Negative value.\n"
  79. "In FlatCAM units.")
  80. )
  81. grid0.addWidget(cutzlabel, 4, 0)
  82. grid0.addWidget(self.cutz_entry, 4, 1)
  83. # New Diameter
  84. self.newdialabel = QtWidgets.QLabel('%s:' % _('New Dia'))
  85. self.newdialabel.setToolTip(
  86. _("Diameter for the new tool to add in the Tool Table.\n"
  87. "If the tool is V-shape type then this value is automatically\n"
  88. "calculated from the other parameters.")
  89. )
  90. self.newdia_entry = FCDoubleSpinner()
  91. self.newdia_entry.set_precision(self.decimals)
  92. self.newdia_entry.set_range(0.0001, 9999.9999)
  93. self.newdia_entry.setSingleStep(0.1)
  94. grid0.addWidget(self.newdialabel, 5, 0)
  95. grid0.addWidget(self.newdia_entry, 5, 1)
  96. separator_line = QtWidgets.QFrame()
  97. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  98. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  99. grid0.addWidget(separator_line, 6, 0, 1, 2)
  100. # Milling Type Radio Button
  101. self.milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type'))
  102. self.milling_type_label.setToolTip(
  103. _("Milling type when the selected tool is of type: 'iso_op':\n"
  104. "- climb / best for precision milling and to reduce tool usage\n"
  105. "- conventional / useful when there is no backlash compensation")
  106. )
  107. self.milling_type_radio = RadioSet([{'label': _('Climb'), 'value': 'cl'},
  108. {'label': _('Conventional'), 'value': 'cv'}])
  109. self.milling_type_radio.setToolTip(
  110. _("Milling type when the selected tool is of type: 'iso_op':\n"
  111. "- climb / best for precision milling and to reduce tool usage\n"
  112. "- conventional / useful when there is no backlash compensation")
  113. )
  114. grid0.addWidget(self.milling_type_label, 7, 0)
  115. grid0.addWidget(self.milling_type_radio, 7, 1)
  116. # Tool order Radio Button
  117. self.ncc_order_label = QtWidgets.QLabel('%s:' % _('Tool order'))
  118. self.ncc_order_label.setToolTip(_("This set the way that the tools in the tools table are used.\n"
  119. "'No' --> means that the used order is the one in the tool table\n"
  120. "'Forward' --> means that the tools will be ordered from small to big\n"
  121. "'Reverse' --> means that the tools will ordered from big to small\n\n"
  122. "WARNING: using rest machining will automatically set the order\n"
  123. "in reverse and disable this control."))
  124. self.ncc_order_radio = RadioSet([{'label': _('No'), 'value': 'no'},
  125. {'label': _('Forward'), 'value': 'fwd'},
  126. {'label': _('Reverse'), 'value': 'rev'}])
  127. self.ncc_order_radio.setToolTip(_("This set the way that the tools in the tools table are used.\n"
  128. "'No' --> means that the used order is the one in the tool table\n"
  129. "'Forward' --> means that the tools will be ordered from small to big\n"
  130. "'Reverse' --> means that the tools will ordered from big to small\n\n"
  131. "WARNING: using rest machining will automatically set the order\n"
  132. "in reverse and disable this control."))
  133. grid0.addWidget(self.ncc_order_label, 8, 0)
  134. grid0.addWidget(self.ncc_order_radio, 8, 1)
  135. separator_line = QtWidgets.QFrame()
  136. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  137. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  138. grid0.addWidget(separator_line, 9, 0, 1, 2)
  139. # Overlap Entry
  140. nccoverlabel = QtWidgets.QLabel('%s:' % _('Overlap'))
  141. nccoverlabel.setToolTip(
  142. _("How much (percentage) of the tool width to overlap each tool pass.\n"
  143. "Adjust the value starting with lower values\n"
  144. "and increasing it if areas that should be cleared are still \n"
  145. "not cleared.\n"
  146. "Lower values = faster processing, faster execution on CNC.\n"
  147. "Higher values = slow processing and slow execution on CNC\n"
  148. "due of too many paths.")
  149. )
  150. self.ncc_overlap_entry = FCDoubleSpinner(suffix='%')
  151. self.ncc_overlap_entry.set_precision(self.decimals)
  152. self.ncc_overlap_entry.setWrapping(True)
  153. self.ncc_overlap_entry.setRange(0.0000, 99.9999)
  154. self.ncc_overlap_entry.setSingleStep(0.1)
  155. grid0.addWidget(nccoverlabel, 10, 0)
  156. grid0.addWidget(self.ncc_overlap_entry, 10, 1)
  157. # Margin entry
  158. nccmarginlabel = QtWidgets.QLabel('%s:' % _('Margin'))
  159. nccmarginlabel.setToolTip(
  160. _("Bounding box margin.")
  161. )
  162. self.ncc_margin_entry = FCDoubleSpinner()
  163. self.ncc_margin_entry.set_precision(self.decimals)
  164. self.ncc_margin_entry.set_range(-10000, 10000)
  165. self.ncc_margin_entry.setSingleStep(0.1)
  166. grid0.addWidget(nccmarginlabel, 11, 0)
  167. grid0.addWidget(self.ncc_margin_entry, 11, 1)
  168. # Method
  169. methodlabel = QtWidgets.QLabel('%s:' % _('Method'))
  170. methodlabel.setToolTip(
  171. _("Algorithm for copper clearing:\n"
  172. "- Standard: Fixed step inwards.\n"
  173. "- Seed-based: Outwards from seed.\n"
  174. "- Line-based: Parallel lines.")
  175. )
  176. # self.ncc_method_radio = RadioSet([
  177. # {"label": _("Standard"), "value": "standard"},
  178. # {"label": _("Seed-based"), "value": "seed"},
  179. # {"label": _("Straight lines"), "value": "lines"}
  180. # ], orientation='vertical', stretch=False)
  181. self.ncc_method_combo = FCComboBox()
  182. self.ncc_method_combo.addItems(
  183. [_("Standard"), _("Seed"), _("Lines")]
  184. )
  185. grid0.addWidget(methodlabel, 12, 0)
  186. grid0.addWidget(self.ncc_method_combo, 12, 1)
  187. # Connect lines
  188. self.ncc_connect_cb = FCCheckBox('%s' % _("Connect"))
  189. self.ncc_connect_cb.setToolTip(
  190. _("Draw lines between resulting\n"
  191. "segments to minimize tool lifts.")
  192. )
  193. grid0.addWidget(self.ncc_connect_cb, 13, 0)
  194. # Contour Checkbox
  195. self.ncc_contour_cb = FCCheckBox('%s' % _("Contour"))
  196. self.ncc_contour_cb.setToolTip(
  197. _("Cut around the perimeter of the polygon\n"
  198. "to trim rough edges.")
  199. )
  200. grid0.addWidget(self.ncc_contour_cb, 13, 1)
  201. # ## NCC Offset choice
  202. self.ncc_choice_offset_cb = FCCheckBox('%s' % _("Offset"))
  203. self.ncc_choice_offset_cb.setToolTip(
  204. _("If used, it will add an offset to the copper features.\n"
  205. "The copper clearing will finish to a distance\n"
  206. "from the copper features.\n"
  207. "The value can be between 0 and 10 FlatCAM units.")
  208. )
  209. grid0.addWidget(self.ncc_choice_offset_cb, 14, 0, 1, 2)
  210. # ## NCC Offset value
  211. self.ncc_offset_label = QtWidgets.QLabel('%s:' % _("Offset value"))
  212. self.ncc_offset_label.setToolTip(
  213. _("If used, it will add an offset to the copper features.\n"
  214. "The copper clearing will finish to a distance\n"
  215. "from the copper features.\n"
  216. "The value can be between 0.0 and 9999.9 FlatCAM units.")
  217. )
  218. self.ncc_offset_spinner = FCDoubleSpinner()
  219. self.ncc_offset_spinner.set_range(0.00, 9999.9999)
  220. self.ncc_offset_spinner.set_precision(self.decimals)
  221. self.ncc_offset_spinner.setWrapping(True)
  222. self.ncc_offset_spinner.setSingleStep(0.1)
  223. grid0.addWidget(self.ncc_offset_label, 15, 0)
  224. grid0.addWidget(self.ncc_offset_spinner, 15, 1)
  225. separator_line = QtWidgets.QFrame()
  226. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  227. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  228. grid0.addWidget(separator_line, 16, 0, 1, 2)
  229. # Rest machining CheckBox
  230. self.ncc_rest_cb = FCCheckBox('%s' % _("Rest Machining"))
  231. self.ncc_rest_cb.setToolTip(
  232. _("If checked, use 'rest machining'.\n"
  233. "Basically it will clear copper outside PCB features,\n"
  234. "using the biggest tool and continue with the next tools,\n"
  235. "from bigger to smaller, to clear areas of copper that\n"
  236. "could not be cleared by previous tool, until there is\n"
  237. "no more copper to clear or there are no more tools.\n"
  238. "If not checked, use the standard algorithm.")
  239. )
  240. grid0.addWidget(self.ncc_rest_cb, 17, 0, 1, 2)
  241. # ## Reference
  242. # self.reference_radio = RadioSet([{'label': _('Itself'), 'value': 'itself'},
  243. # {"label": _("Area Selection"), "value": "area"},
  244. # {'label': _('Reference Object'), 'value': 'box'}],
  245. # orientation='vertical',
  246. # stretch=None)
  247. self.select_combo = FCComboBox()
  248. self.select_combo.addItems(
  249. [_("Itself"), _("Area Selection"), _("Reference Object")]
  250. )
  251. select_label = QtWidgets.QLabel('%s:' % _("Selection"))
  252. select_label.setToolTip(
  253. _("Selection of area to be processed.\n"
  254. "- 'Itself' - the processing extent is based on the object that is processed.\n "
  255. "- 'Area Selection' - left mouse click to start selection of the area to be processed.\n"
  256. "- 'Reference Object' - will process the area specified by another object.")
  257. )
  258. grid0.addWidget(select_label, 18, 0)
  259. grid0.addWidget(self.select_combo, 18, 1)
  260. self.area_shape_label = QtWidgets.QLabel('%s:' % _("Shape"))
  261. self.area_shape_label.setToolTip(
  262. _("The kind of selection shape used for area selection.")
  263. )
  264. self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
  265. {'label': _("Polygon"), 'value': 'polygon'}])
  266. grid0.addWidget(self.area_shape_label, 19, 0)
  267. grid0.addWidget(self.area_shape_radio, 19, 1)
  268. separator_line = QtWidgets.QFrame()
  269. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  270. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  271. grid0.addWidget(separator_line, 20, 0, 1, 2)
  272. # ## Plotting type
  273. self.ncc_plotting_radio = RadioSet([{'label': _('Normal'), 'value': 'normal'},
  274. {"label": _("Progressive"), "value": "progressive"}])
  275. plotting_label = QtWidgets.QLabel('%s:' % _("NCC Plotting"))
  276. plotting_label.setToolTip(
  277. _("- 'Normal' - normal plotting, done at the end of the NCC job\n"
  278. "- 'Progressive' - after each shape is generated it will be plotted.")
  279. )
  280. grid0.addWidget(plotting_label, 21, 0)
  281. grid0.addWidget(self.ncc_plotting_radio, 21, 1)
  282. self.layout.addStretch()