ObjectUI.py 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875
  1. import sys
  2. from PyQt4 import QtGui, QtCore
  3. #from GUIElements import *
  4. from GUIElements import FCEntry, FloatEntry, EvalEntry, FCCheckBox, \
  5. LengthEntry, FCTextArea, IntEntry, RadioSet, OptionalInputSection
  6. class ObjectUI(QtGui.QWidget):
  7. """
  8. Base class for the UI of FlatCAM objects. Deriving classes should
  9. put UI elements in ObjectUI.custom_box (QtGui.QLayout).
  10. """
  11. def __init__(self, icon_file='share/flatcam_icon32.png', title='FlatCAM Object', parent=None):
  12. QtGui.QWidget.__init__(self, parent=parent)
  13. layout = QtGui.QVBoxLayout()
  14. self.setLayout(layout)
  15. ## Page Title box (spacing between children)
  16. self.title_box = QtGui.QHBoxLayout()
  17. layout.addLayout(self.title_box)
  18. ## Page Title icon
  19. pixmap = QtGui.QPixmap(icon_file)
  20. self.icon = QtGui.QLabel()
  21. self.icon.setPixmap(pixmap)
  22. self.title_box.addWidget(self.icon, stretch=0)
  23. ## Title label
  24. self.title_label = QtGui.QLabel("<font size=5><b>" + title + "</b></font>")
  25. self.title_label.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  26. self.title_box.addWidget(self.title_label, stretch=1)
  27. ## Object name
  28. self.name_box = QtGui.QHBoxLayout()
  29. layout.addLayout(self.name_box)
  30. name_label = QtGui.QLabel("Name:")
  31. self.name_box.addWidget(name_label)
  32. self.name_entry = FCEntry()
  33. self.name_box.addWidget(self.name_entry)
  34. ## Box box for custom widgets
  35. # This gets populated in offspring implementations.
  36. self.custom_box = QtGui.QVBoxLayout()
  37. layout.addLayout(self.custom_box)
  38. ###########################
  39. ## Common to all objects ##
  40. ###########################
  41. #### Scale ####
  42. self.scale_label = QtGui.QLabel('<b>Scale:</b>')
  43. self.scale_label.setToolTip(
  44. "Change the size of the object."
  45. )
  46. layout.addWidget(self.scale_label)
  47. self.scale_grid = QtGui.QGridLayout()
  48. layout.addLayout(self.scale_grid)
  49. # Factor
  50. faclabel = QtGui.QLabel('Factor:')
  51. faclabel.setToolTip(
  52. "Factor by which to multiply\n"
  53. "geometric features of this object."
  54. )
  55. self.scale_grid.addWidget(faclabel, 0, 0)
  56. self.scale_entry = FloatEntry()
  57. self.scale_entry.set_value(1.0)
  58. self.scale_grid.addWidget(self.scale_entry, 0, 1)
  59. # GO Button
  60. self.scale_button = QtGui.QPushButton('Scale')
  61. self.scale_button.setToolTip(
  62. "Perform scaling operation."
  63. )
  64. layout.addWidget(self.scale_button)
  65. #### Offset ####
  66. self.offset_label = QtGui.QLabel('<b>Offset:</b>')
  67. self.offset_label.setToolTip(
  68. "Change the position of this object."
  69. )
  70. layout.addWidget(self.offset_label)
  71. self.offset_grid = QtGui.QGridLayout()
  72. layout.addLayout(self.offset_grid)
  73. self.offset_vectorlabel = QtGui.QLabel('Vector:')
  74. self.offset_vectorlabel.setToolTip(
  75. "Amount by which to move the object\n"
  76. "in the x and y axes in (x, y) format."
  77. )
  78. self.offset_grid.addWidget(self.offset_vectorlabel, 0, 0)
  79. self.offsetvector_entry = EvalEntry()
  80. self.offsetvector_entry.setText("(0.0, 0.0)")
  81. self.offset_grid.addWidget(self.offsetvector_entry, 0, 1)
  82. self.offset_button = QtGui.QPushButton('Offset')
  83. self.offset_button.setToolTip(
  84. "Perform the offset operation."
  85. )
  86. layout.addWidget(self.offset_button)
  87. self.auto_offset_button = QtGui.QPushButton('Offset auto')
  88. self.auto_offset_button.setToolTip(
  89. "Align the object with the x and y axes."
  90. )
  91. layout.addWidget(self.auto_offset_button)
  92. #### Mirror ####
  93. self.mirror_label = QtGui.QLabel('<b>Mirror:</b>')
  94. self.mirror_label.setToolTip(
  95. "Flip the object along an axis."
  96. )
  97. layout.addWidget(self.mirror_label)
  98. self.mirror_axis_grid = QtGui.QGridLayout()
  99. layout.addLayout(self.mirror_axis_grid)
  100. axislabel = QtGui.QLabel('Axis:')
  101. axislabel.setToolTip(
  102. "Mirror axis parallel to the x or y axis."
  103. )
  104. self.mirror_axis_grid.addWidget(axislabel, 0, 0)
  105. self.mirror_axis_radio = RadioSet([{'label': 'X', 'value': 'X'},
  106. {'label': 'Y', 'value': 'Y'}])
  107. self.mirror_axis_radio.set_value('Y')
  108. self.mirror_axis_grid.addWidget(self.mirror_axis_radio, 0, 1)
  109. self.mirror_auto_center_cb = FCCheckBox(label='Center axis automatically')
  110. self.mirror_auto_center_cb.setToolTip(
  111. "Place the mirror axis on the middle of the object."
  112. )
  113. self.mirror_auto_center_cb.set_value(True)
  114. layout.addWidget(self.mirror_auto_center_cb)
  115. self.mirror_button = QtGui.QPushButton('Mirror')
  116. self.mirror_button.setToolTip(
  117. "Perform the mirror operation."
  118. )
  119. layout.addWidget(self.mirror_button)
  120. layout.addStretch()
  121. class CNCObjectUI(ObjectUI):
  122. """
  123. User interface for CNCJob objects.
  124. """
  125. def __init__(self, parent=None):
  126. """
  127. Creates the user interface for CNCJob objects. GUI elements should
  128. be placed in ``self.custom_box`` to preserve the layout.
  129. """
  130. ObjectUI.__init__(self, title='CNC Job Object', icon_file='share/cnc32.png', parent=parent)
  131. # Scale and offset are not available for CNCJob objects.
  132. # Hiding from the GUI.
  133. for i in range(0, self.scale_grid.count()):
  134. self.scale_grid.itemAt(i).widget().hide()
  135. self.scale_label.hide()
  136. self.scale_button.hide()
  137. for i in range(0, self.offset_grid.count()):
  138. self.offset_grid.itemAt(i).widget().hide()
  139. self.offset_label.hide()
  140. self.offset_button.hide()
  141. self.auto_offset_button.hide()
  142. self.mirror_label.hide()
  143. for i in range(0, self.mirror_axis_grid.count()):
  144. self.mirror_axis_grid.itemAt(i).widget().hide()
  145. self.mirror_auto_center_cb.hide()
  146. self.mirror_button.hide()
  147. ## Plot options
  148. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  149. self.custom_box.addWidget(self.plot_options_label)
  150. grid0 = QtGui.QGridLayout()
  151. self.custom_box.addLayout(grid0)
  152. # Plot CB
  153. # self.plot_cb = QtGui.QCheckBox('Plot')
  154. self.plot_cb = FCCheckBox('Plot')
  155. self.plot_cb.setToolTip(
  156. "Plot (show) this object."
  157. )
  158. grid0.addWidget(self.plot_cb, 0, 0)
  159. # Tool dia for plot
  160. tdlabel = QtGui.QLabel('Tool dia:')
  161. tdlabel.setToolTip(
  162. "Diameter of the tool to be\n"
  163. "rendered in the plot."
  164. )
  165. grid0.addWidget(tdlabel, 1, 0)
  166. self.tooldia_entry = LengthEntry()
  167. grid0.addWidget(self.tooldia_entry, 1, 1)
  168. # Update plot button
  169. self.updateplot_button = QtGui.QPushButton('Update Plot')
  170. self.updateplot_button.setToolTip(
  171. "Update the plot."
  172. )
  173. self.custom_box.addWidget(self.updateplot_button)
  174. ##################
  175. ## Export G-Code
  176. ##################
  177. self.export_gcode_label = QtGui.QLabel("<b>Export G-Code:</b>")
  178. self.export_gcode_label.setToolTip(
  179. "Export and save G-Code to\n"
  180. "make this object to a file."
  181. )
  182. self.custom_box.addWidget(self.export_gcode_label)
  183. # Prepend text to Gerber
  184. prependlabel = QtGui.QLabel('Prepend to G-Code:')
  185. prependlabel.setToolTip(
  186. "Type here any G-Code commands you would\n"
  187. "like to add to the beginning of the generated file."
  188. )
  189. self.custom_box.addWidget(prependlabel)
  190. self.prepend_text = FCTextArea()
  191. self.custom_box.addWidget(self.prepend_text)
  192. # Append text to Gerber
  193. appendlabel = QtGui.QLabel('Append to G-Code:')
  194. appendlabel.setToolTip(
  195. "Type here any G-Code commands you would\n"
  196. "like to append to the generated file.\n"
  197. "I.e.: M2 (End of program)"
  198. )
  199. self.custom_box.addWidget(appendlabel)
  200. self.append_text = FCTextArea()
  201. self.custom_box.addWidget(self.append_text)
  202. processorlabel = QtGui.QLabel('Postprocessing-Script:')
  203. processorlabel.setToolTip(
  204. "Enter a Postprocessing Script here.\n"
  205. "It gets applied to the G-Code after it\n"
  206. "is generated."
  207. )
  208. self.custom_box.addWidget(processorlabel)
  209. self.process_script = FCTextArea()
  210. self.custom_box.addWidget(self.process_script)
  211. # Dwell
  212. grid1 = QtGui.QGridLayout()
  213. self.custom_box.addLayout(grid1)
  214. dwelllabel = QtGui.QLabel('Dwell:')
  215. dwelllabel.setToolTip(
  216. "Pause to allow the spindle to reach its\n"
  217. "speed before cutting."
  218. )
  219. dwelltime = QtGui.QLabel('Duration [sec.]:')
  220. dwelltime.setToolTip(
  221. "Number of second to dwell."
  222. )
  223. self.dwell_cb = FCCheckBox()
  224. self.dwelltime_entry = FCEntry()
  225. grid1.addWidget(dwelllabel, 0, 0)
  226. grid1.addWidget(self.dwell_cb, 0, 1)
  227. grid1.addWidget(dwelltime, 1, 0)
  228. grid1.addWidget(self.dwelltime_entry, 1, 1)
  229. # GO Button
  230. self.export_gcode_button = QtGui.QPushButton('Export G-Code')
  231. self.export_gcode_button.setToolTip(
  232. "Opens dialog to save G-Code\n"
  233. "file."
  234. )
  235. self.custom_box.addWidget(self.export_gcode_button)
  236. class GeometryObjectUI(ObjectUI):
  237. """
  238. User interface for Geometry objects.
  239. """
  240. def __init__(self, parent=None):
  241. super(GeometryObjectUI, self).__init__(title='Geometry Object', icon_file='share/geometry32.png', parent=parent)
  242. ## Plot options
  243. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  244. self.custom_box.addWidget(self.plot_options_label)
  245. # Plot CB
  246. self.plot_cb = FCCheckBox(label='Plot')
  247. self.plot_cb.setToolTip(
  248. "Plot (show) this object."
  249. )
  250. self.custom_box.addWidget(self.plot_cb)
  251. #-----------------------------------
  252. # Create CNC Job
  253. #-----------------------------------
  254. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job:</b>')
  255. self.cncjob_label.setToolTip(
  256. "Create a CNC Job object\n"
  257. "tracing the contours of this\n"
  258. "Geometry object."
  259. )
  260. self.custom_box.addWidget(self.cncjob_label)
  261. grid1 = QtGui.QGridLayout()
  262. self.custom_box.addLayout(grid1)
  263. cutzlabel = QtGui.QLabel('Cut Z:')
  264. cutzlabel.setToolTip(
  265. "Cutting depth (negative)\n"
  266. "below the copper surface."
  267. )
  268. grid1.addWidget(cutzlabel, 0, 0)
  269. self.cutz_entry = LengthEntry()
  270. grid1.addWidget(self.cutz_entry, 0, 1)
  271. # Travel Z
  272. travelzlabel = QtGui.QLabel('Travel Z:')
  273. travelzlabel.setToolTip(
  274. "Height of the tool when\n"
  275. "moving without cutting."
  276. )
  277. grid1.addWidget(travelzlabel, 1, 0)
  278. self.travelz_entry = LengthEntry()
  279. grid1.addWidget(self.travelz_entry, 1, 1)
  280. # Feedrate
  281. frlabel = QtGui.QLabel('Feed Rate:')
  282. frlabel.setToolTip(
  283. "Cutting speed in the XY\n"
  284. "plane in units per minute"
  285. )
  286. grid1.addWidget(frlabel, 2, 0)
  287. self.cncfeedrate_entry = LengthEntry()
  288. grid1.addWidget(self.cncfeedrate_entry, 2, 1)
  289. # Tooldia
  290. tdlabel = QtGui.QLabel('Tool dia:')
  291. tdlabel.setToolTip(
  292. "The diameter of the cutting\n"
  293. "tool (just for display)."
  294. )
  295. grid1.addWidget(tdlabel, 3, 0)
  296. self.cnctooldia_entry = LengthEntry()
  297. grid1.addWidget(self.cnctooldia_entry, 3, 1)
  298. # Spindlespeed
  299. spdlabel = QtGui.QLabel('Spindle speed:')
  300. spdlabel.setToolTip(
  301. "Speed of the spindle\n"
  302. "in RPM (optional)"
  303. )
  304. grid1.addWidget(spdlabel, 4, 0)
  305. self.cncspindlespeed_entry = IntEntry(allow_empty=True)
  306. grid1.addWidget(self.cncspindlespeed_entry, 4, 1)
  307. # Multi-pass
  308. mpasslabel = QtGui.QLabel('Multi-Depth:')
  309. mpasslabel.setToolTip(
  310. "Use multiple passes to limit\n"
  311. "the cut depth in each pass. Will\n"
  312. "cut multiple times until Cut Z is\n"
  313. "reached."
  314. )
  315. grid1.addWidget(mpasslabel, 5, 0)
  316. self.mpass_cb = FCCheckBox()
  317. grid1.addWidget(self.mpass_cb, 5, 1)
  318. maxdepthlabel = QtGui.QLabel('Depth/pass:')
  319. maxdepthlabel.setToolTip(
  320. "Depth of each pass (positive)."
  321. )
  322. grid1.addWidget(maxdepthlabel, 6, 0)
  323. self.maxdepth_entry = LengthEntry()
  324. grid1.addWidget(self.maxdepth_entry, 6, 1)
  325. self.ois_mpass = OptionalInputSection(self.mpass_cb, [self.maxdepth_entry])
  326. # Button
  327. self.generate_cnc_button = QtGui.QPushButton('Generate')
  328. self.generate_cnc_button.setToolTip(
  329. "Generate the CNC Job object."
  330. )
  331. self.custom_box.addWidget(self.generate_cnc_button)
  332. #------------------------------
  333. # Paint area
  334. #------------------------------
  335. self.paint_label = QtGui.QLabel('<b>Paint Area:</b>')
  336. self.paint_label.setToolTip(
  337. "Creates tool paths to cover the\n"
  338. "whole area of a polygon (remove\n"
  339. "all copper). You will be asked\n"
  340. "to click on the desired polygon."
  341. )
  342. self.custom_box.addWidget(self.paint_label)
  343. grid2 = QtGui.QGridLayout()
  344. self.custom_box.addLayout(grid2)
  345. # Tool dia
  346. ptdlabel = QtGui.QLabel('Tool dia:')
  347. ptdlabel.setToolTip(
  348. "Diameter of the tool to\n"
  349. "be used in the operation."
  350. )
  351. grid2.addWidget(ptdlabel, 0, 0)
  352. self.painttooldia_entry = LengthEntry()
  353. grid2.addWidget(self.painttooldia_entry, 0, 1)
  354. # Overlap
  355. ovlabel = QtGui.QLabel('Overlap:')
  356. ovlabel.setToolTip(
  357. "How much (fraction) of the tool\n"
  358. "width to overlap each tool pass."
  359. )
  360. grid2.addWidget(ovlabel, 1, 0)
  361. self.paintoverlap_entry = LengthEntry()
  362. grid2.addWidget(self.paintoverlap_entry, 1, 1)
  363. # Margin
  364. marginlabel = QtGui.QLabel('Margin:')
  365. marginlabel.setToolTip(
  366. "Distance by which to avoid\n"
  367. "the edges of the polygon to\n"
  368. "be painted."
  369. )
  370. grid2.addWidget(marginlabel, 2, 0)
  371. self.paintmargin_entry = LengthEntry()
  372. grid2.addWidget(self.paintmargin_entry, 2, 1)
  373. # Method
  374. methodlabel = QtGui.QLabel('Method:')
  375. methodlabel.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
  376. methodlabel.setToolTip(
  377. "Algorithm to paint the polygon:<BR>"
  378. "<B>Standard</B>: Fixed step inwards.<BR>"
  379. "<B>Seed-based</B>: Outwards from seed."
  380. )
  381. grid2.addWidget(methodlabel, 3, 0)
  382. self.paintmethod_combo = RadioSet([
  383. {"label": "Standard", "value": "standard"},
  384. {"label": "Seed-based", "value": "seed"},
  385. {"label": "Straight lines", "value": "lines"}
  386. ], orientation='vertical')
  387. grid2.addWidget(self.paintmethod_combo, 3, 1)
  388. # Connect lines
  389. pathconnectlabel = QtGui.QLabel("Connect:")
  390. pathconnectlabel.setToolTip(
  391. "Draw lines between resulting\n"
  392. "segments to minimize tool lifts."
  393. )
  394. grid2.addWidget(pathconnectlabel, 4, 0)
  395. self.pathconnect_cb = FCCheckBox()
  396. grid2.addWidget(self.pathconnect_cb, 4, 1)
  397. contourlabel = QtGui.QLabel("Contour:")
  398. contourlabel.setToolTip(
  399. "Cut around the perimeter of the polygon\n"
  400. "to trim rough edges."
  401. )
  402. grid2.addWidget(contourlabel, 5, 0)
  403. self.paintcontour_cb = FCCheckBox()
  404. grid2.addWidget(self.paintcontour_cb, 5, 1)
  405. # Polygon selection
  406. selectlabel = QtGui.QLabel('Selection:')
  407. selectlabel.setToolTip(
  408. "How to select the polygons to paint."
  409. )
  410. grid2.addWidget(selectlabel, 6, 0)
  411. #grid3 = QtGui.QGridLayout()
  412. self.selectmethod_combo = RadioSet([
  413. {"label": "Single", "value": "single"},
  414. {"label": "All", "value": "all"},
  415. #{"label": "Rectangle", "value": "rectangle"}
  416. ])
  417. grid2.addWidget(self.selectmethod_combo, 6, 1)
  418. # GO Button
  419. self.generate_paint_button = QtGui.QPushButton('Generate')
  420. self.generate_paint_button.setToolTip(
  421. "After clicking here, click inside\n"
  422. "the polygon you wish to be painted.\n"
  423. "A new Geometry object with the tool\n"
  424. "paths will be created."
  425. )
  426. self.custom_box.addWidget(self.generate_paint_button)
  427. class ExcellonObjectUI(ObjectUI):
  428. """
  429. User interface for Excellon objects.
  430. """
  431. def __init__(self, parent=None):
  432. ObjectUI.__init__(self, title='Excellon Object',
  433. icon_file='share/drill32.png',
  434. parent=parent)
  435. #### Plot options ####
  436. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  437. self.custom_box.addWidget(self.plot_options_label)
  438. grid0 = QtGui.QGridLayout()
  439. self.custom_box.addLayout(grid0)
  440. self.plot_cb = FCCheckBox(label='Plot')
  441. self.plot_cb.setToolTip(
  442. "Plot (show) this object."
  443. )
  444. grid0.addWidget(self.plot_cb, 0, 0)
  445. self.solid_cb = FCCheckBox(label='Solid')
  446. self.solid_cb.setToolTip(
  447. "Solid circles."
  448. )
  449. grid0.addWidget(self.solid_cb, 0, 1)
  450. #### Tools ####
  451. self.tools_table_label = QtGui.QLabel('<b>Tools</b>')
  452. self.tools_table_label.setToolTip(
  453. "Tools in this Excellon object."
  454. )
  455. self.custom_box.addWidget(self.tools_table_label)
  456. self.tools_table = QtGui.QTableWidget()
  457. self.tools_table.setFixedHeight(100)
  458. self.custom_box.addWidget(self.tools_table)
  459. #### Create CNC Job ####
  460. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job</b>')
  461. self.cncjob_label.setToolTip(
  462. "Create a CNC Job object\n"
  463. "for this drill object."
  464. )
  465. self.custom_box.addWidget(self.cncjob_label)
  466. grid1 = QtGui.QGridLayout()
  467. self.custom_box.addLayout(grid1)
  468. cutzlabel = QtGui.QLabel('Cut Z:')
  469. cutzlabel.setToolTip(
  470. "Drill depth (negative)\n"
  471. "below the copper surface."
  472. )
  473. grid1.addWidget(cutzlabel, 0, 0)
  474. self.cutz_entry = LengthEntry()
  475. grid1.addWidget(self.cutz_entry, 0, 1)
  476. travelzlabel = QtGui.QLabel('Travel Z:')
  477. travelzlabel.setToolTip(
  478. "Tool height when travelling\n"
  479. "across the XY plane."
  480. )
  481. grid1.addWidget(travelzlabel, 1, 0)
  482. self.travelz_entry = LengthEntry()
  483. grid1.addWidget(self.travelz_entry, 1, 1)
  484. frlabel = QtGui.QLabel('Feed rate:')
  485. frlabel.setToolTip(
  486. "Tool speed while drilling\n"
  487. "(in units per minute)."
  488. )
  489. grid1.addWidget(frlabel, 2, 0)
  490. self.feedrate_entry = LengthEntry()
  491. grid1.addWidget(self.feedrate_entry, 2, 1)
  492. # Tool change:
  493. toolchlabel = QtGui.QLabel("Tool change:")
  494. toolchlabel.setToolTip(
  495. "Include tool-change sequence\n"
  496. "in G-Code (Pause for tool change)."
  497. )
  498. self.toolchange_cb = FCCheckBox()
  499. grid1.addWidget(toolchlabel, 3, 0)
  500. grid1.addWidget(self.toolchange_cb, 3, 1)
  501. # Tool change Z:
  502. toolchzlabel = QtGui.QLabel("Tool change Z:")
  503. toolchzlabel.setToolTip(
  504. "Z-axis position (height) for\n"
  505. "tool change."
  506. )
  507. grid1.addWidget(toolchzlabel, 4, 0)
  508. self.toolchangez_entry = LengthEntry()
  509. grid1.addWidget(self.toolchangez_entry, 4, 1)
  510. self.ois_tcz = OptionalInputSection(self.toolchange_cb, [self.toolchangez_entry])
  511. # Spindlespeed
  512. spdlabel = QtGui.QLabel('Spindle speed:')
  513. spdlabel.setToolTip(
  514. "Speed of the spindle\n"
  515. "in RPM (optional)"
  516. )
  517. grid1.addWidget(spdlabel, 5, 0)
  518. self.spindlespeed_entry = IntEntry(allow_empty=True)
  519. grid1.addWidget(self.spindlespeed_entry, 5, 1)
  520. choose_tools_label = QtGui.QLabel(
  521. "Select from the tools section above\n"
  522. "the tools you want to include."
  523. )
  524. self.custom_box.addWidget(choose_tools_label)
  525. self.generate_cnc_button = QtGui.QPushButton('Generate')
  526. self.generate_cnc_button.setToolTip(
  527. "Generate the CNC Job."
  528. )
  529. self.custom_box.addWidget(self.generate_cnc_button)
  530. #### Milling Holes ####
  531. self.mill_hole_label = QtGui.QLabel('<b>Mill Holes</b>')
  532. self.mill_hole_label.setToolTip(
  533. "Create Geometry for milling holes."
  534. )
  535. self.custom_box.addWidget(self.mill_hole_label)
  536. grid1 = QtGui.QGridLayout()
  537. self.custom_box.addLayout(grid1)
  538. tdlabel = QtGui.QLabel('Tool dia:')
  539. tdlabel.setToolTip(
  540. "Diameter of the cutting tool."
  541. )
  542. grid1.addWidget(tdlabel, 0, 0)
  543. self.tooldia_entry = LengthEntry()
  544. grid1.addWidget(self.tooldia_entry, 0, 1)
  545. choose_tools_label2 = QtGui.QLabel(
  546. "Select from the tools section above\n"
  547. "the tools you want to include."
  548. )
  549. self.custom_box.addWidget(choose_tools_label2)
  550. self.generate_milling_button = QtGui.QPushButton('Generate Geometry')
  551. self.generate_milling_button.setToolTip(
  552. "Create the Geometry Object\n"
  553. "for milling toolpaths."
  554. )
  555. self.custom_box.addWidget(self.generate_milling_button)
  556. class GerberObjectUI(ObjectUI):
  557. """
  558. User interface for Gerber objects.
  559. """
  560. def __init__(self, parent=None):
  561. ObjectUI.__init__(self, title='Gerber Object', parent=parent)
  562. ## Plot options
  563. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  564. self.custom_box.addWidget(self.plot_options_label)
  565. grid0 = QtGui.QGridLayout()
  566. self.custom_box.addLayout(grid0)
  567. # Plot CB
  568. self.plot_cb = FCCheckBox(label='Plot')
  569. self.plot_options_label.setToolTip(
  570. "Plot (show) this object."
  571. )
  572. grid0.addWidget(self.plot_cb, 0, 0)
  573. # Solid CB
  574. self.solid_cb = FCCheckBox(label='Solid')
  575. self.solid_cb.setToolTip(
  576. "Solid color polygons."
  577. )
  578. grid0.addWidget(self.solid_cb, 0, 1)
  579. # Multicolored CB
  580. self.multicolored_cb = FCCheckBox(label='Multicolored')
  581. self.multicolored_cb.setToolTip(
  582. "Draw polygons in different colors."
  583. )
  584. grid0.addWidget(self.multicolored_cb, 0, 2)
  585. ## Isolation Routing
  586. self.isolation_routing_label = QtGui.QLabel("<b>Isolation Routing:</b>")
  587. self.isolation_routing_label.setToolTip(
  588. "Create a Geometry object with\n"
  589. "toolpaths to cut outside polygons."
  590. )
  591. self.custom_box.addWidget(self.isolation_routing_label)
  592. grid1 = QtGui.QGridLayout()
  593. self.custom_box.addLayout(grid1)
  594. tdlabel = QtGui.QLabel('Tool dia:')
  595. tdlabel.setToolTip(
  596. "Diameter of the cutting tool."
  597. )
  598. grid1.addWidget(tdlabel, 0, 0)
  599. self.iso_tool_dia_entry = LengthEntry()
  600. grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
  601. passlabel = QtGui.QLabel('Width (# passes):')
  602. passlabel.setToolTip(
  603. "Width of the isolation gap in\n"
  604. "number (integer) of tool widths."
  605. )
  606. grid1.addWidget(passlabel, 1, 0)
  607. self.iso_width_entry = IntEntry()
  608. grid1.addWidget(self.iso_width_entry, 1, 1)
  609. overlabel = QtGui.QLabel('Pass overlap:')
  610. overlabel.setToolTip(
  611. "How much (fraction of tool width)\n"
  612. "to overlap each pass."
  613. )
  614. grid1.addWidget(overlabel, 2, 0)
  615. self.iso_overlap_entry = FloatEntry()
  616. grid1.addWidget(self.iso_overlap_entry, 2, 1)
  617. # combine all passes CB
  618. self.combine_passes_cb = FCCheckBox(label='Combine Passes')
  619. self.combine_passes_cb.setToolTip(
  620. "Combine all passes into one object"
  621. )
  622. grid1.addWidget(self.combine_passes_cb, 3, 0)
  623. self.generate_iso_button = QtGui.QPushButton('Generate Geometry')
  624. self.generate_iso_button.setToolTip(
  625. "Create the Geometry Object\n"
  626. "for isolation routing."
  627. )
  628. self.custom_box.addWidget(self.generate_iso_button)
  629. ## Board cuttout
  630. self.board_cutout_label = QtGui.QLabel("<b>Board cutout:</b>")
  631. self.board_cutout_label.setToolTip(
  632. "Create toolpaths to cut around\n"
  633. "the PCB and separate it from\n"
  634. "the original board."
  635. )
  636. self.custom_box.addWidget(self.board_cutout_label)
  637. grid2 = QtGui.QGridLayout()
  638. self.custom_box.addLayout(grid2)
  639. tdclabel = QtGui.QLabel('Tool dia:')
  640. tdclabel.setToolTip(
  641. "Diameter of the cutting tool."
  642. )
  643. grid2.addWidget(tdclabel, 0, 0)
  644. self.cutout_tooldia_entry = LengthEntry()
  645. grid2.addWidget(self.cutout_tooldia_entry, 0, 1)
  646. marginlabel = QtGui.QLabel('Margin:')
  647. marginlabel.setToolTip(
  648. "Distance from objects at which\n"
  649. "to draw the cutout."
  650. )
  651. grid2.addWidget(marginlabel, 1, 0)
  652. self.cutout_margin_entry = LengthEntry()
  653. grid2.addWidget(self.cutout_margin_entry, 1, 1)
  654. gaplabel = QtGui.QLabel('Gap size:')
  655. gaplabel.setToolTip(
  656. "Size of the gaps in the toolpath\n"
  657. "that will remain to hold the\n"
  658. "board in place."
  659. )
  660. grid2.addWidget(gaplabel, 2, 0)
  661. self.cutout_gap_entry = LengthEntry()
  662. grid2.addWidget(self.cutout_gap_entry, 2, 1)
  663. gapslabel = QtGui.QLabel('Gaps:')
  664. gapslabel.setToolTip(
  665. "Where to place the gaps, Top/Bottom\n"
  666. "Left/Rigt, or on all 4 sides."
  667. )
  668. grid2.addWidget(gapslabel, 3, 0)
  669. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  670. {'label': '2 (L/R)', 'value': 'lr'},
  671. {'label': '4', 'value': '4'}])
  672. grid2.addWidget(self.gaps_radio, 3, 1)
  673. self.generate_cutout_button = QtGui.QPushButton('Generate Geometry')
  674. self.generate_cutout_button.setToolTip(
  675. "Generate the geometry for\n"
  676. "the board cutout."
  677. )
  678. self.custom_box.addWidget(self.generate_cutout_button)
  679. ## Non-copper regions
  680. self.noncopper_label = QtGui.QLabel("<b>Non-copper regions:</b>")
  681. self.noncopper_label.setToolTip(
  682. "Create polygons covering the\n"
  683. "areas without copper on the PCB.\n"
  684. "Equivalent to the inverse of this\n"
  685. "object. Can be used to remove all\n"
  686. "copper from a specified region."
  687. )
  688. self.custom_box.addWidget(self.noncopper_label)
  689. grid3 = QtGui.QGridLayout()
  690. self.custom_box.addLayout(grid3)
  691. # Margin
  692. bmlabel = QtGui.QLabel('Boundary Margin:')
  693. bmlabel.setToolTip(
  694. "Specify the edge of the PCB\n"
  695. "by drawing a box around all\n"
  696. "objects with this minimum\n"
  697. "distance."
  698. )
  699. grid3.addWidget(bmlabel, 0, 0)
  700. self.noncopper_margin_entry = LengthEntry()
  701. grid3.addWidget(self.noncopper_margin_entry, 0, 1)
  702. # Rounded corners
  703. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  704. self.noncopper_rounded_cb.setToolTip(
  705. "Creates a Geometry objects with polygons\n"
  706. "covering the copper-free areas of the PCB."
  707. )
  708. grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  709. self.generate_noncopper_button = QtGui.QPushButton('Generate Geometry')
  710. self.custom_box.addWidget(self.generate_noncopper_button)
  711. ## Bounding box
  712. self.boundingbox_label = QtGui.QLabel('<b>Bounding Box:</b>')
  713. self.custom_box.addWidget(self.boundingbox_label)
  714. grid4 = QtGui.QGridLayout()
  715. self.custom_box.addLayout(grid4)
  716. bbmargin = QtGui.QLabel('Boundary Margin:')
  717. bbmargin.setToolTip(
  718. "Distance of the edges of the box\n"
  719. "to the nearest polygon."
  720. )
  721. grid4.addWidget(bbmargin, 0, 0)
  722. self.bbmargin_entry = LengthEntry()
  723. grid4.addWidget(self.bbmargin_entry, 0, 1)
  724. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  725. self.bbrounded_cb.setToolTip(
  726. "If the bounding box is \n"
  727. "to have rounded corners\n"
  728. "their radius is equal to\n"
  729. "the margin."
  730. )
  731. grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  732. self.generate_bb_button = QtGui.QPushButton('Generate Geometry')
  733. self.generate_bb_button.setToolTip(
  734. "Generate the Geometry object."
  735. )
  736. self.custom_box.addWidget(self.generate_bb_button)
  737. # def main():
  738. #
  739. # app = QtGui.QApplication(sys.argv)
  740. # fc = GerberObjectUI()
  741. # sys.exit(app.exec_())
  742. #
  743. #
  744. # if __name__ == '__main__':
  745. # main()