ExcellonOptPrefGroupUI.py 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. from PyQt5 import QtWidgets
  2. from PyQt5.QtCore import Qt, QSettings
  3. from appGUI.GUIElements import RadioSet, FCDoubleSpinner, FCCheckBox, FCEntry, FCSpinner, OptionalInputSection, \
  4. FCComboBox, NumericalEvalTupleEntry
  5. from appGUI.preferences import machinist_setting
  6. from appGUI.preferences.OptionsGroupUI import OptionsGroupUI
  7. import gettext
  8. import appTranslation as fcTranslate
  9. import builtins
  10. fcTranslate.apply_language('strings')
  11. if '_' not in builtins.__dict__:
  12. _ = gettext.gettext
  13. settings = QSettings("Open Source", "FlatCAM")
  14. if settings.contains("machinist"):
  15. machinist_setting = settings.value('machinist', type=int)
  16. else:
  17. machinist_setting = 0
  18. class ExcellonOptPrefGroupUI(OptionsGroupUI):
  19. def __init__(self, decimals=4, parent=None):
  20. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  21. super(ExcellonOptPrefGroupUI, self).__init__(self, parent=parent)
  22. self.setTitle(str(_("Excellon Options")))
  23. self.decimals = decimals
  24. # ## Create CNC Job
  25. self.cncjob_label = QtWidgets.QLabel('<b>%s</b>' % _('Create CNC Job'))
  26. self.cncjob_label.setToolTip(
  27. _("Parameters used to create a CNC Job object\n"
  28. "for this drill object.")
  29. )
  30. self.layout.addWidget(self.cncjob_label)
  31. grid2 = QtWidgets.QGridLayout()
  32. self.layout.addLayout(grid2)
  33. grid2.setColumnStretch(0, 0)
  34. grid2.setColumnStretch(1, 1)
  35. # Operation Type
  36. self.operation_label = QtWidgets.QLabel('<b>%s:</b>' % _('Operation'))
  37. self.operation_label.setToolTip(
  38. _("Operation type:\n"
  39. "- Drilling -> will drill the drills/slots associated with this tool\n"
  40. "- Milling -> will mill the drills/slots")
  41. )
  42. self.operation_radio = RadioSet(
  43. [
  44. {'label': _('Drilling'), 'value': 'drill'},
  45. {'label': _("Milling"), 'value': 'mill'}
  46. ]
  47. )
  48. grid2.addWidget(self.operation_label, 0, 0)
  49. grid2.addWidget(self.operation_radio, 0, 1)
  50. self.mill_type_label = QtWidgets.QLabel('%s:' % _('Milling Type'))
  51. self.mill_type_label.setToolTip(
  52. _("Milling type:\n"
  53. "- Drills -> will mill the drills associated with this tool\n"
  54. "- Slots -> will mill the slots associated with this tool\n"
  55. "- Both -> will mill both drills and mills or whatever is available")
  56. )
  57. self.milling_type_radio = RadioSet(
  58. [
  59. {'label': _('Drills'), 'value': 'drills'},
  60. {'label': _("Slots"), 'value': 'slots'},
  61. {'label': _("Both"), 'value': 'both'},
  62. ]
  63. )
  64. grid2.addWidget(self.mill_type_label, 1, 0)
  65. grid2.addWidget(self.milling_type_radio, 1, 1)
  66. self.mill_dia_label = QtWidgets.QLabel('%s:' % _('Milling Diameter'))
  67. self.mill_dia_label.setToolTip(
  68. _("The diameter of the tool who will do the milling")
  69. )
  70. self.mill_dia_entry = FCDoubleSpinner()
  71. self.mill_dia_entry.set_precision(self.decimals)
  72. self.mill_dia_entry.set_range(0.0000, 9999.9999)
  73. grid2.addWidget(self.mill_dia_label, 2, 0)
  74. grid2.addWidget(self.mill_dia_entry, 2, 1)
  75. # Cut Z
  76. cutzlabel = QtWidgets.QLabel('%s:' % _('Cut Z'))
  77. cutzlabel.setToolTip(
  78. _("Drill depth (negative)\n"
  79. "below the copper surface.")
  80. )
  81. self.cutz_entry = FCDoubleSpinner()
  82. if machinist_setting == 0:
  83. self.cutz_entry.set_range(-9999.9999, 0.0000)
  84. else:
  85. self.cutz_entry.set_range(-9999.9999, 9999.9999)
  86. self.cutz_entry.setSingleStep(0.1)
  87. self.cutz_entry.set_precision(self.decimals)
  88. grid2.addWidget(cutzlabel, 3, 0)
  89. grid2.addWidget(self.cutz_entry, 3, 1)
  90. # Multi-Depth
  91. self.mpass_cb = FCCheckBox('%s:' % _("Multi-Depth"))
  92. self.mpass_cb.setToolTip(
  93. _(
  94. "Use multiple passes to limit\n"
  95. "the cut depth in each pass. Will\n"
  96. "cut multiple times until Cut Z is\n"
  97. "reached."
  98. )
  99. )
  100. self.maxdepth_entry = FCDoubleSpinner()
  101. self.maxdepth_entry.set_precision(self.decimals)
  102. self.maxdepth_entry.set_range(0, 9999.9999)
  103. self.maxdepth_entry.setSingleStep(0.1)
  104. self.maxdepth_entry.setToolTip(_("Depth of each pass (positive)."))
  105. grid2.addWidget(self.mpass_cb, 4, 0)
  106. grid2.addWidget(self.maxdepth_entry, 4, 1)
  107. # Travel Z
  108. travelzlabel = QtWidgets.QLabel('%s:' % _('Travel Z'))
  109. travelzlabel.setToolTip(
  110. _("Tool height when travelling\n"
  111. "across the XY plane.")
  112. )
  113. self.travelz_entry = FCDoubleSpinner()
  114. self.travelz_entry.set_precision(self.decimals)
  115. if machinist_setting == 0:
  116. self.travelz_entry.set_range(0.0001, 9999.9999)
  117. else:
  118. self.travelz_entry.set_range(-9999.9999, 9999.9999)
  119. grid2.addWidget(travelzlabel, 5, 0)
  120. grid2.addWidget(self.travelz_entry, 5, 1)
  121. # Tool change:
  122. self.toolchange_cb = FCCheckBox('%s' % _("Tool change"))
  123. self.toolchange_cb.setToolTip(
  124. _("Include tool-change sequence\n"
  125. "in G-Code (Pause for tool change).")
  126. )
  127. grid2.addWidget(self.toolchange_cb, 6, 0, 1, 2)
  128. # Tool Change Z
  129. toolchangezlabel = QtWidgets.QLabel('%s:' % _('Toolchange Z'))
  130. toolchangezlabel.setToolTip(
  131. _("Z-axis position (height) for\n"
  132. "tool change.")
  133. )
  134. self.toolchangez_entry = FCDoubleSpinner()
  135. self.toolchangez_entry.set_precision(self.decimals)
  136. if machinist_setting == 0:
  137. self.toolchangez_entry.set_range(0.0001, 9999.9999)
  138. else:
  139. self.toolchangez_entry.set_range(-9999.9999, 9999.9999)
  140. grid2.addWidget(toolchangezlabel, 7, 0)
  141. grid2.addWidget(self.toolchangez_entry, 7, 1)
  142. # End Move Z
  143. endz_label = QtWidgets.QLabel('%s:' % _('End move Z'))
  144. endz_label.setToolTip(
  145. _("Height of the tool after\n"
  146. "the last move at the end of the job.")
  147. )
  148. self.endz_entry = FCDoubleSpinner()
  149. self.endz_entry.set_precision(self.decimals)
  150. if machinist_setting == 0:
  151. self.endz_entry.set_range(0.0000, 9999.9999)
  152. else:
  153. self.endz_entry.set_range(-9999.9999, 9999.9999)
  154. grid2.addWidget(endz_label, 8, 0)
  155. grid2.addWidget(self.endz_entry, 8, 1)
  156. # End Move X,Y
  157. endmove_xy_label = QtWidgets.QLabel('%s:' % _('End move X,Y'))
  158. endmove_xy_label.setToolTip(
  159. _("End move X,Y position. In format (x,y).\n"
  160. "If no value is entered then there is no move\n"
  161. "on X,Y plane at the end of the job.")
  162. )
  163. self.endxy_entry = NumericalEvalTupleEntry(border_color='#0069A9')
  164. grid2.addWidget(endmove_xy_label, 9, 0)
  165. grid2.addWidget(self.endxy_entry, 9, 1)
  166. # Feedrate Z
  167. frlabel = QtWidgets.QLabel('%s:' % _('Feedrate Z'))
  168. frlabel.setToolTip(
  169. _("Tool speed while drilling\n"
  170. "(in units per minute).\n"
  171. "So called 'Plunge' feedrate.\n"
  172. "This is for linear move G01.")
  173. )
  174. self.feedrate_z_entry = FCDoubleSpinner()
  175. self.feedrate_z_entry.set_precision(self.decimals)
  176. self.feedrate_z_entry.set_range(0, 99999.9999)
  177. grid2.addWidget(frlabel, 10, 0)
  178. grid2.addWidget(self.feedrate_z_entry, 10, 1)
  179. # Spindle speed
  180. spdlabel = QtWidgets.QLabel('%s:' % _('Spindle Speed'))
  181. spdlabel.setToolTip(
  182. _("Speed of the spindle\n"
  183. "in RPM (optional)")
  184. )
  185. self.spindlespeed_entry = FCSpinner()
  186. self.spindlespeed_entry.set_range(0, 1000000)
  187. self.spindlespeed_entry.set_step(100)
  188. grid2.addWidget(spdlabel, 11, 0)
  189. grid2.addWidget(self.spindlespeed_entry, 11, 1)
  190. # Dwell
  191. self.dwell_cb = FCCheckBox('%s' % _('Enable Dwell'))
  192. self.dwell_cb .setToolTip(
  193. _("Pause to allow the spindle to reach its\n"
  194. "speed before cutting.")
  195. )
  196. grid2.addWidget(self.dwell_cb, 12, 0, 1, 2)
  197. # Dwell Time
  198. dwelltime = QtWidgets.QLabel('%s:' % _('Duration'))
  199. dwelltime.setToolTip(_("Number of time units for spindle to dwell."))
  200. self.dwelltime_entry = FCDoubleSpinner()
  201. self.dwelltime_entry.set_precision(self.decimals)
  202. self.dwelltime_entry.set_range(0, 99999.9999)
  203. grid2.addWidget(dwelltime, 13, 0)
  204. grid2.addWidget(self.dwelltime_entry, 13, 1)
  205. self.ois_dwell_exc = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  206. # preprocessor selection
  207. pp_excellon_label = QtWidgets.QLabel('%s:' % _("Preprocessor"))
  208. pp_excellon_label.setToolTip(
  209. _("The preprocessor JSON file that dictates\n"
  210. "Gcode output.")
  211. )
  212. self.pp_excellon_name_cb = FCComboBox()
  213. self.pp_excellon_name_cb.setFocusPolicy(Qt.StrongFocus)
  214. grid2.addWidget(pp_excellon_label, 14, 0)
  215. grid2.addWidget(self.pp_excellon_name_cb, 14, 1)
  216. # ### Choose what to use for Gcode creation: Drills, Slots or Both
  217. excellon_gcode_type_label = QtWidgets.QLabel('<b>%s</b>' % _('Gcode'))
  218. excellon_gcode_type_label.setToolTip(
  219. _("Choose what to use for GCode generation:\n"
  220. "'Drills', 'Slots' or 'Both'.\n"
  221. "When choosing 'Slots' or 'Both', slots will be\n"
  222. "converted to drills.")
  223. )
  224. self.excellon_gcode_type_radio = RadioSet([{'label': 'Drills', 'value': 'drills'},
  225. {'label': 'Slots', 'value': 'slots'},
  226. {'label': 'Both', 'value': 'both'}])
  227. grid2.addWidget(excellon_gcode_type_label, 15, 0)
  228. grid2.addWidget(self.excellon_gcode_type_radio, 15, 1)
  229. # until I decide to implement this feature those remain disabled
  230. excellon_gcode_type_label.hide()
  231. self.excellon_gcode_type_radio.setVisible(False)
  232. # ### Milling Holes ## ##
  233. self.mill_hole_label = QtWidgets.QLabel('<b>%s</b>' % _('Mill Holes'))
  234. self.mill_hole_label.setToolTip(
  235. _("Create Geometry for milling holes.")
  236. )
  237. grid2.addWidget(self.mill_hole_label, 16, 0, 1, 2)
  238. tdlabel = QtWidgets.QLabel('%s:' % _('Drill Tool dia'))
  239. tdlabel.setToolTip(
  240. _("Diameter of the cutting tool.")
  241. )
  242. self.tooldia_entry = FCDoubleSpinner()
  243. self.tooldia_entry.set_precision(self.decimals)
  244. self.tooldia_entry.set_range(0, 999.9999)
  245. grid2.addWidget(tdlabel, 18, 0)
  246. grid2.addWidget(self.tooldia_entry, 18, 1)
  247. stdlabel = QtWidgets.QLabel('%s:' % _('Slot Tool dia'))
  248. stdlabel.setToolTip(
  249. _("Diameter of the cutting tool\n"
  250. "when milling slots.")
  251. )
  252. self.slot_tooldia_entry = FCDoubleSpinner()
  253. self.slot_tooldia_entry.set_precision(self.decimals)
  254. self.slot_tooldia_entry.set_range(0, 999.9999)
  255. grid2.addWidget(stdlabel, 21, 0)
  256. grid2.addWidget(self.slot_tooldia_entry, 21, 1)
  257. self.layout.addStretch()