ExcellonOptPrefGroupUI.py 11 KB

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