ObjectUI.py 27 KB

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