ToolsISOPrefGroupUI.py 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import QSettings
  3. from appGUI.GUIElements import RadioSet, FCDoubleSpinner, FCComboBox, FCCheckBox, FCSpinner, NumericalEvalTupleEntry
  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 ToolsISOPrefGroupUI(OptionsGroupUI):
  17. def __init__(self, decimals=4, parent=None):
  18. super(ToolsISOPrefGroupUI, self).__init__(self, parent=parent)
  19. self.setTitle(str(_("Isolation Tool Options")))
  20. self.decimals = decimals
  21. # ## Clear non-copper regions
  22. self.iso_label = QtWidgets.QLabel("<b>%s:</b>" % _("Parameters"))
  23. self.iso_label.setToolTip(
  24. _("Create a Geometry object with\n"
  25. "toolpaths to cut around polygons.")
  26. )
  27. self.layout.addWidget(self.iso_label)
  28. grid0 = QtWidgets.QGridLayout()
  29. self.layout.addLayout(grid0)
  30. # Tool Dias
  31. isotdlabel = QtWidgets.QLabel('<b><font color="green">%s:</font></b>' % _('Tools Dia'))
  32. isotdlabel.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. self.tool_dia_entry = NumericalEvalTupleEntry(border_color='#0069A9')
  38. self.tool_dia_entry.setPlaceholderText(_("Comma separated values"))
  39. grid0.addWidget(isotdlabel, 0, 0)
  40. grid0.addWidget(self.tool_dia_entry, 0, 1, 1, 2)
  41. # Tool order Radio Button
  42. self.order_label = QtWidgets.QLabel('%s:' % _('Tool order'))
  43. self.order_label.setToolTip(_("This set the way that the tools in the tools table are used.\n"
  44. "'No' --> means that the used order is the one in the tool table\n"
  45. "'Forward' --> means that the tools will be ordered from small to big\n"
  46. "'Reverse' --> means that the tools will ordered from big to small\n\n"
  47. "WARNING: using rest machining will automatically set the order\n"
  48. "in reverse and disable this control."))
  49. self.order_radio = RadioSet([{'label': _('No'), 'value': 'no'},
  50. {'label': _('Forward'), 'value': 'fwd'},
  51. {'label': _('Reverse'), 'value': 'rev'}])
  52. grid0.addWidget(self.order_label, 1, 0)
  53. grid0.addWidget(self.order_radio, 1, 1, 1, 2)
  54. # Tool Type Radio Button
  55. self.tool_type_label = QtWidgets.QLabel('%s:' % _('Tool Type'))
  56. self.tool_type_label.setToolTip(
  57. _("Default tool type:\n"
  58. "- 'V-shape'\n"
  59. "- Circular")
  60. )
  61. self.tool_type_radio = RadioSet([{'label': _('V-shape'), 'value': 'V'},
  62. {'label': _('Circular'), 'value': 'C1'}])
  63. self.tool_type_radio.setToolTip(
  64. _("Default tool type:\n"
  65. "- 'V-shape'\n"
  66. "- Circular")
  67. )
  68. grid0.addWidget(self.tool_type_label, 2, 0)
  69. grid0.addWidget(self.tool_type_radio, 2, 1, 1, 2)
  70. # Tip Dia
  71. self.tipdialabel = QtWidgets.QLabel('%s:' % _('V-Tip Dia'))
  72. self.tipdialabel.setToolTip(
  73. _("The tip diameter for V-Shape Tool"))
  74. self.tipdia_entry = FCDoubleSpinner()
  75. self.tipdia_entry.set_precision(self.decimals)
  76. self.tipdia_entry.set_range(0, 1000)
  77. self.tipdia_entry.setSingleStep(0.1)
  78. grid0.addWidget(self.tipdialabel, 3, 0)
  79. grid0.addWidget(self.tipdia_entry, 3, 1, 1, 2)
  80. # Tip Angle
  81. self.tipanglelabel = QtWidgets.QLabel('%s:' % _('V-Tip Angle'))
  82. self.tipanglelabel.setToolTip(
  83. _("The tip angle for V-Shape Tool.\n"
  84. "In degrees."))
  85. self.tipangle_entry = FCDoubleSpinner()
  86. self.tipangle_entry.set_precision(self.decimals)
  87. self.tipangle_entry.set_range(1, 180)
  88. self.tipangle_entry.setSingleStep(5)
  89. self.tipangle_entry.setWrapping(True)
  90. grid0.addWidget(self.tipanglelabel, 4, 0)
  91. grid0.addWidget(self.tipangle_entry, 4, 1, 1, 2)
  92. # Cut Z entry
  93. cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
  94. cutzlabel.setToolTip(
  95. _("Depth of cut into material. Negative value.\n"
  96. "In FlatCAM units.")
  97. )
  98. self.cutz_entry = FCDoubleSpinner()
  99. self.cutz_entry.set_precision(self.decimals)
  100. self.cutz_entry.set_range(-9999.9999, 0.0000)
  101. self.cutz_entry.setSingleStep(0.1)
  102. self.cutz_entry.setToolTip(
  103. _("Depth of cut into material. Negative value.\n"
  104. "In FlatCAM units.")
  105. )
  106. grid0.addWidget(cutzlabel, 5, 0)
  107. grid0.addWidget(self.cutz_entry, 5, 1, 1, 2)
  108. # New Diameter
  109. self.newdialabel = QtWidgets.QLabel('%s:' % _('New Dia'))
  110. self.newdialabel.setToolTip(
  111. _("Diameter for the new tool to add in the Tool Table.\n"
  112. "If the tool is V-shape type then this value is automatically\n"
  113. "calculated from the other parameters.")
  114. )
  115. self.newdia_entry = FCDoubleSpinner()
  116. self.newdia_entry.set_precision(self.decimals)
  117. self.newdia_entry.set_range(0.0001, 9999.9999)
  118. self.newdia_entry.setSingleStep(0.1)
  119. grid0.addWidget(self.newdialabel, 6, 0)
  120. grid0.addWidget(self.newdia_entry, 6, 1, 1, 2)
  121. separator_line = QtWidgets.QFrame()
  122. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  123. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  124. grid0.addWidget(separator_line, 7, 0, 1, 3)
  125. # Passes
  126. passlabel = QtWidgets.QLabel('%s:' % _('Passes'))
  127. passlabel.setToolTip(
  128. _("Width of the isolation gap in\n"
  129. "number (integer) of tool widths.")
  130. )
  131. self.passes_entry = FCSpinner()
  132. self.passes_entry.set_range(1, 999)
  133. self.passes_entry.setObjectName("i_passes")
  134. grid0.addWidget(passlabel, 8, 0)
  135. grid0.addWidget(self.passes_entry, 8, 1, 1, 2)
  136. # Overlap Entry
  137. overlabel = QtWidgets.QLabel('%s:' % _('Overlap'))
  138. overlabel.setToolTip(
  139. _("How much (percentage) of the tool width to overlap each tool pass.")
  140. )
  141. self.overlap_entry = FCDoubleSpinner(suffix='%')
  142. self.overlap_entry.set_precision(self.decimals)
  143. self.overlap_entry.setWrapping(True)
  144. self.overlap_entry.set_range(0.0000, 99.9999)
  145. self.overlap_entry.setSingleStep(0.1)
  146. self.overlap_entry.setObjectName("i_overlap")
  147. grid0.addWidget(overlabel, 9, 0)
  148. grid0.addWidget(self.overlap_entry, 9, 1, 1, 2)
  149. # Milling Type Radio Button
  150. self.milling_type_label = QtWidgets.QLabel('%s:' % _('Milling Type'))
  151. self.milling_type_label.setToolTip(
  152. _("Milling type when the selected tool is of type: 'iso_op':\n"
  153. "- climb / best for precision milling and to reduce tool usage\n"
  154. "- conventional / useful when there is no backlash compensation")
  155. )
  156. self.milling_type_radio = RadioSet([{'label': _('Climb'), 'value': 'cl'},
  157. {'label': _('Conventional'), 'value': 'cv'}])
  158. self.milling_type_radio.setToolTip(
  159. _("Milling type when the selected tool is of type: 'iso_op':\n"
  160. "- climb / best for precision milling and to reduce tool usage\n"
  161. "- conventional / useful when there is no backlash compensation")
  162. )
  163. grid0.addWidget(self.milling_type_label, 10, 0)
  164. grid0.addWidget(self.milling_type_radio, 10, 1, 1, 2)
  165. # Follow
  166. self.follow_label = QtWidgets.QLabel('%s:' % _('Follow'))
  167. self.follow_label.setToolTip(
  168. _("Generate a 'Follow' geometry.\n"
  169. "This means that it will cut through\n"
  170. "the middle of the trace.")
  171. )
  172. self.follow_cb = FCCheckBox()
  173. self.follow_cb.setToolTip(_("Generate a 'Follow' geometry.\n"
  174. "This means that it will cut through\n"
  175. "the middle of the trace."))
  176. self.follow_cb.setObjectName("i_follow")
  177. grid0.addWidget(self.follow_label, 11, 0)
  178. grid0.addWidget(self.follow_cb, 11, 1, 1, 2)
  179. # Isolation Type
  180. self.iso_type_label = QtWidgets.QLabel('%s:' % _('Isolation Type'))
  181. self.iso_type_label.setToolTip(
  182. _("Choose how the isolation will be executed:\n"
  183. "- 'Full' -> complete isolation of polygons\n"
  184. "- 'Ext' -> will isolate only on the outside\n"
  185. "- 'Int' -> will isolate only on the inside\n"
  186. "'Exterior' isolation is almost always possible\n"
  187. "(with the right tool) but 'Interior'\n"
  188. "isolation can be done only when there is an opening\n"
  189. "inside of the polygon (e.g polygon is a 'doughnut' shape).")
  190. )
  191. self.iso_type_radio = RadioSet([{'label': _('Full'), 'value': 'full'},
  192. {'label': _('Ext'), 'value': 'ext'},
  193. {'label': _('Int'), 'value': 'int'}])
  194. self.iso_type_radio.setObjectName("i_type")
  195. grid0.addWidget(self.iso_type_label, 12, 0)
  196. grid0.addWidget(self.iso_type_radio, 12, 1, 1, 2)
  197. separator_line = QtWidgets.QFrame()
  198. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  199. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  200. grid0.addWidget(separator_line, 13, 0, 1, 3)
  201. # Rest machining CheckBox
  202. self.rest_cb = FCCheckBox('%s' % _("Rest"))
  203. self.rest_cb.setObjectName("i_rest_machining")
  204. self.rest_cb.setToolTip(
  205. _("If checked, use 'rest machining'.\n"
  206. "Basically it will isolate outside PCB features,\n"
  207. "using the biggest tool and continue with the next tools,\n"
  208. "from bigger to smaller, to isolate the copper features that\n"
  209. "could not be cleared by previous tool, until there is\n"
  210. "no more copper features to isolate or there are no more tools.\n"
  211. "If not checked, use the standard algorithm.")
  212. )
  213. grid0.addWidget(self.rest_cb, 17, 0)
  214. # Combine All Passes
  215. self.combine_passes_cb = FCCheckBox(label=_('Combine'))
  216. self.combine_passes_cb.setToolTip(
  217. _("Combine all passes into one object")
  218. )
  219. self.combine_passes_cb.setObjectName("i_combine")
  220. grid0.addWidget(self.combine_passes_cb, 17, 1)
  221. # Exception Areas
  222. self.except_cb = FCCheckBox(label=_('Except'))
  223. self.except_cb.setToolTip(_("When the isolation geometry is generated,\n"
  224. "by checking this, the area of the object below\n"
  225. "will be subtracted from the isolation geometry."))
  226. self.except_cb.setObjectName("i_except")
  227. grid0.addWidget(self.except_cb, 17, 2)
  228. # Isolation Scope
  229. self.select_label = QtWidgets.QLabel('%s:' % _("Selection"))
  230. self.select_label.setToolTip(
  231. _("Isolation scope. Choose what to isolate:\n"
  232. "- 'All' -> Isolate all the polygons in the object\n"
  233. "- 'Area Selection' -> Isolate polygons within a selection area.\n"
  234. "- 'Polygon Selection' -> Isolate a selection of polygons.\n"
  235. "- 'Reference Object' - will process the area specified by another object.")
  236. )
  237. self.select_combo = FCComboBox()
  238. self.select_combo.addItems(
  239. [_("All"), _("Area Selection"), _("Polygon Selection"), _("Reference Object")]
  240. )
  241. self.select_combo.setObjectName("i_selection")
  242. grid0.addWidget(self.select_label, 20, 0)
  243. grid0.addWidget(self.select_combo, 20, 1, 1, 2)
  244. # Area Shape
  245. self.area_shape_label = QtWidgets.QLabel('%s:' % _("Shape"))
  246. self.area_shape_label.setToolTip(
  247. _("The kind of selection shape used for area selection.")
  248. )
  249. self.area_shape_radio = RadioSet([{'label': _("Square"), 'value': 'square'},
  250. {'label': _("Polygon"), 'value': 'polygon'}])
  251. grid0.addWidget(self.area_shape_label, 21, 0)
  252. grid0.addWidget(self.area_shape_radio, 21, 1, 1, 2)
  253. separator_line = QtWidgets.QFrame()
  254. separator_line.setFrameShape(QtWidgets.QFrame.HLine)
  255. separator_line.setFrameShadow(QtWidgets.QFrame.Sunken)
  256. grid0.addWidget(separator_line, 22, 0, 1, 3)
  257. # ## Plotting type
  258. self.plotting_radio = RadioSet([{'label': _('Normal'), 'value': 'normal'},
  259. {"label": _("Progressive"), "value": "progressive"}])
  260. plotting_label = QtWidgets.QLabel('%s:' % _("Plotting"))
  261. plotting_label.setToolTip(
  262. _("- 'Normal' - normal plotting, done at the end of the job\n"
  263. "- 'Progressive' - each shape is plotted after it is generated")
  264. )
  265. grid0.addWidget(plotting_label, 23, 0)
  266. grid0.addWidget(self.plotting_radio, 23, 1, 1, 2)
  267. self.layout.addStretch()