ObjectUI.py 24 KB

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