ToolsNCCPrefGroupUI.py 15 KB

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