ObjectUI.py 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731
  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 = LengthEntry()
  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', icon_file='share/drill32.png', parent=parent)
  309. #### Plot options ####
  310. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  311. self.custom_box.addWidget(self.plot_options_label)
  312. grid0 = QtGui.QGridLayout()
  313. self.custom_box.addLayout(grid0)
  314. self.plot_cb = FCCheckBox(label='Plot')
  315. self.plot_cb.setToolTip(
  316. "Plot (show) this object."
  317. )
  318. grid0.addWidget(self.plot_cb, 0, 0)
  319. self.solid_cb = FCCheckBox(label='Solid')
  320. self.solid_cb.setToolTip(
  321. "Solid circles."
  322. )
  323. grid0.addWidget(self.solid_cb, 0, 1)
  324. #### Tools ####
  325. self.tools_table_label = QtGui.QLabel('<b>Tools</b>')
  326. self.tools_table_label.setToolTip(
  327. "Tools in this Excellon object."
  328. )
  329. self.custom_box.addWidget(self.tools_table_label)
  330. self.tools_table = QtGui.QTableWidget()
  331. self.tools_table.setFixedHeight(100)
  332. self.custom_box.addWidget(self.tools_table)
  333. #### Create CNC Job ####
  334. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job</b>')
  335. self.cncjob_label.setToolTip(
  336. "Create a CNC Job object\n"
  337. "for this drill object."
  338. )
  339. self.custom_box.addWidget(self.cncjob_label)
  340. grid1 = QtGui.QGridLayout()
  341. self.custom_box.addLayout(grid1)
  342. cutzlabel = QtGui.QLabel('Cut Z:')
  343. cutzlabel.setToolTip(
  344. "Drill depth (negative)\n"
  345. "below the copper surface."
  346. )
  347. grid1.addWidget(cutzlabel, 0, 0)
  348. self.cutz_entry = LengthEntry()
  349. grid1.addWidget(self.cutz_entry, 0, 1)
  350. travelzlabel = QtGui.QLabel('Travel Z:')
  351. travelzlabel.setToolTip(
  352. "Tool height when travelling\n"
  353. "across the XY plane."
  354. )
  355. grid1.addWidget(travelzlabel, 1, 0)
  356. self.travelz_entry = LengthEntry()
  357. grid1.addWidget(self.travelz_entry, 1, 1)
  358. frlabel = QtGui.QLabel('Feed rate:')
  359. frlabel.setToolTip(
  360. "Tool speed while drilling\n"
  361. "(in units per minute)."
  362. )
  363. grid1.addWidget(frlabel, 2, 0)
  364. self.feedrate_entry = LengthEntry()
  365. grid1.addWidget(self.feedrate_entry, 2, 1)
  366. # Tool change:
  367. toolchlabel = QtGui.QLabel("Tool change:")
  368. toolchlabel.setToolTip(
  369. "Include tool-change sequence\n"
  370. "in G-Code (Pause for tool change)."
  371. )
  372. self.toolchange_cb = FCCheckBox()
  373. grid1.addWidget(toolchlabel, 3, 0)
  374. grid1.addWidget(self.toolchange_cb, 3, 1)
  375. # Tool change Z:
  376. toolchzlabel = QtGui.QLabel("Tool change Z:")
  377. toolchzlabel.setToolTip(
  378. "Z-axis position (height) for\n"
  379. "tool change."
  380. )
  381. grid1.addWidget(toolchzlabel, 4, 0)
  382. self.toolchangez_entry = LengthEntry()
  383. grid1.addWidget(self.toolchangez_entry, 4, 1)
  384. self.ois_tcz = OptionalInputSection(self.toolchange_cb, [self.toolchangez_entry])
  385. # Spindlespeed
  386. spdlabel = QtGui.QLabel('Spindle speed:')
  387. spdlabel.setToolTip(
  388. "Speed of the spindle\n"
  389. "in RPM (optional)"
  390. )
  391. grid1.addWidget(spdlabel, 5, 0)
  392. self.spindlespeed_entry = LengthEntry()
  393. grid1.addWidget(self.spindlespeed_entry, 5, 1)
  394. choose_tools_label = QtGui.QLabel(
  395. "Select from the tools section above\n"
  396. "the tools you want to include."
  397. )
  398. self.custom_box.addWidget(choose_tools_label)
  399. self.generate_cnc_button = QtGui.QPushButton('Generate')
  400. self.generate_cnc_button.setToolTip(
  401. "Generate the CNC Job."
  402. )
  403. self.custom_box.addWidget(self.generate_cnc_button)
  404. #### Milling Holes ####
  405. self.mill_hole_label = QtGui.QLabel('<b>Mill Holes</b>')
  406. self.mill_hole_label.setToolTip(
  407. "Create Geometry for milling holes."
  408. )
  409. self.custom_box.addWidget(self.mill_hole_label)
  410. grid1 = QtGui.QGridLayout()
  411. self.custom_box.addLayout(grid1)
  412. tdlabel = QtGui.QLabel('Tool dia:')
  413. tdlabel.setToolTip(
  414. "Diameter of the cutting tool."
  415. )
  416. grid1.addWidget(tdlabel, 0, 0)
  417. self.tooldia_entry = LengthEntry()
  418. grid1.addWidget(self.tooldia_entry, 0, 1)
  419. choose_tools_label2 = QtGui.QLabel(
  420. "Select from the tools section above\n"
  421. "the tools you want to include."
  422. )
  423. self.custom_box.addWidget(choose_tools_label2)
  424. self.generate_milling_button = QtGui.QPushButton('Generate Geometry')
  425. self.generate_milling_button.setToolTip(
  426. "Create the Geometry Object\n"
  427. "for milling toolpaths."
  428. )
  429. self.custom_box.addWidget(self.generate_milling_button)
  430. class GerberObjectUI(ObjectUI):
  431. """
  432. User interface for Gerber objects.
  433. """
  434. def __init__(self, parent=None):
  435. ObjectUI.__init__(self, title='Gerber Object', parent=parent)
  436. ## Plot options
  437. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  438. self.custom_box.addWidget(self.plot_options_label)
  439. grid0 = QtGui.QGridLayout()
  440. self.custom_box.addLayout(grid0)
  441. # Plot CB
  442. self.plot_cb = FCCheckBox(label='Plot')
  443. self.plot_options_label.setToolTip(
  444. "Plot (show) this object."
  445. )
  446. grid0.addWidget(self.plot_cb, 0, 0)
  447. # Solid CB
  448. self.solid_cb = FCCheckBox(label='Solid')
  449. self.solid_cb.setToolTip(
  450. "Solid color polygons."
  451. )
  452. grid0.addWidget(self.solid_cb, 0, 1)
  453. # Multicolored CB
  454. self.multicolored_cb = FCCheckBox(label='Multicolored')
  455. self.multicolored_cb.setToolTip(
  456. "Draw polygons in different colors."
  457. )
  458. grid0.addWidget(self.multicolored_cb, 0, 2)
  459. ## Isolation Routing
  460. self.isolation_routing_label = QtGui.QLabel("<b>Isolation Routing:</b>")
  461. self.isolation_routing_label.setToolTip(
  462. "Create a Geometry object with\n"
  463. "toolpaths to cut outside polygons."
  464. )
  465. self.custom_box.addWidget(self.isolation_routing_label)
  466. grid1 = QtGui.QGridLayout()
  467. self.custom_box.addLayout(grid1)
  468. tdlabel = QtGui.QLabel('Tool dia:')
  469. tdlabel.setToolTip(
  470. "Diameter of the cutting tool."
  471. )
  472. grid1.addWidget(tdlabel, 0, 0)
  473. self.iso_tool_dia_entry = LengthEntry()
  474. grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
  475. passlabel = QtGui.QLabel('Width (# passes):')
  476. passlabel.setToolTip(
  477. "Width of the isolation gap in\n"
  478. "number (integer) of tool widths."
  479. )
  480. grid1.addWidget(passlabel, 1, 0)
  481. self.iso_width_entry = IntEntry()
  482. grid1.addWidget(self.iso_width_entry, 1, 1)
  483. overlabel = QtGui.QLabel('Pass overlap:')
  484. overlabel.setToolTip(
  485. "How much (fraction of tool width)\n"
  486. "to overlap each pass."
  487. )
  488. grid1.addWidget(overlabel, 2, 0)
  489. self.iso_overlap_entry = FloatEntry()
  490. grid1.addWidget(self.iso_overlap_entry, 2, 1)
  491. # combine all passes CB
  492. self.combine_passes_cb = FCCheckBox(label='Combine Passes')
  493. self.combine_passes_cb.setToolTip(
  494. "Combine all passes into one object"
  495. )
  496. grid1.addWidget(self.combine_passes_cb, 3, 0)
  497. self.generate_iso_button = QtGui.QPushButton('Generate Geometry')
  498. self.generate_iso_button.setToolTip(
  499. "Create the Geometry Object\n"
  500. "for isolation routing."
  501. )
  502. self.custom_box.addWidget(self.generate_iso_button)
  503. ## Board cuttout
  504. self.board_cutout_label = QtGui.QLabel("<b>Board cutout:</b>")
  505. self.board_cutout_label.setToolTip(
  506. "Create toolpaths to cut around\n"
  507. "the PCB and separate it from\n"
  508. "the original board."
  509. )
  510. self.custom_box.addWidget(self.board_cutout_label)
  511. grid2 = QtGui.QGridLayout()
  512. self.custom_box.addLayout(grid2)
  513. tdclabel = QtGui.QLabel('Tool dia:')
  514. tdclabel.setToolTip(
  515. "Diameter of the cutting tool."
  516. )
  517. grid2.addWidget(tdclabel, 0, 0)
  518. self.cutout_tooldia_entry = LengthEntry()
  519. grid2.addWidget(self.cutout_tooldia_entry, 0, 1)
  520. marginlabel = QtGui.QLabel('Margin:')
  521. marginlabel.setToolTip(
  522. "Distance from objects at which\n"
  523. "to draw the cutout."
  524. )
  525. grid2.addWidget(marginlabel, 1, 0)
  526. self.cutout_margin_entry = LengthEntry()
  527. grid2.addWidget(self.cutout_margin_entry, 1, 1)
  528. gaplabel = QtGui.QLabel('Gap size:')
  529. gaplabel.setToolTip(
  530. "Size of the gaps in the toolpath\n"
  531. "that will remain to hold the\n"
  532. "board in place."
  533. )
  534. grid2.addWidget(gaplabel, 2, 0)
  535. self.cutout_gap_entry = LengthEntry()
  536. grid2.addWidget(self.cutout_gap_entry, 2, 1)
  537. gapslabel = QtGui.QLabel('Gaps:')
  538. gapslabel.setToolTip(
  539. "Where to place the gaps, Top/Bottom\n"
  540. "Left/Rigt, or on all 4 sides."
  541. )
  542. grid2.addWidget(gapslabel, 3, 0)
  543. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  544. {'label': '2 (L/R)', 'value': 'lr'},
  545. {'label': '4', 'value': '4'}])
  546. grid2.addWidget(self.gaps_radio, 3, 1)
  547. self.generate_cutout_button = QtGui.QPushButton('Generate Geometry')
  548. self.generate_cutout_button.setToolTip(
  549. "Generate the geometry for\n"
  550. "the board cutout."
  551. )
  552. self.custom_box.addWidget(self.generate_cutout_button)
  553. ## Non-copper regions
  554. self.noncopper_label = QtGui.QLabel("<b>Non-copper regions:</b>")
  555. self.noncopper_label.setToolTip(
  556. "Create polygons covering the\n"
  557. "areas without copper on the PCB.\n"
  558. "Equivalent to the inverse of this\n"
  559. "object. Can be used to remove all\n"
  560. "copper from a specified region."
  561. )
  562. self.custom_box.addWidget(self.noncopper_label)
  563. grid3 = QtGui.QGridLayout()
  564. self.custom_box.addLayout(grid3)
  565. # Margin
  566. bmlabel = QtGui.QLabel('Boundary Margin:')
  567. bmlabel.setToolTip(
  568. "Specify the edge of the PCB\n"
  569. "by drawing a box around all\n"
  570. "objects with this minimum\n"
  571. "distance."
  572. )
  573. grid3.addWidget(bmlabel, 0, 0)
  574. self.noncopper_margin_entry = LengthEntry()
  575. grid3.addWidget(self.noncopper_margin_entry, 0, 1)
  576. # Rounded corners
  577. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  578. self.noncopper_rounded_cb.setToolTip(
  579. "Creates a Geometry objects with polygons\n"
  580. "covering the copper-free areas of the PCB."
  581. )
  582. grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  583. self.generate_noncopper_button = QtGui.QPushButton('Generate Geometry')
  584. self.custom_box.addWidget(self.generate_noncopper_button)
  585. ## Bounding box
  586. self.boundingbox_label = QtGui.QLabel('<b>Bounding Box:</b>')
  587. self.custom_box.addWidget(self.boundingbox_label)
  588. grid4 = QtGui.QGridLayout()
  589. self.custom_box.addLayout(grid4)
  590. bbmargin = QtGui.QLabel('Boundary Margin:')
  591. bbmargin.setToolTip(
  592. "Distance of the edges of the box\n"
  593. "to the nearest polygon."
  594. )
  595. grid4.addWidget(bbmargin, 0, 0)
  596. self.bbmargin_entry = LengthEntry()
  597. grid4.addWidget(self.bbmargin_entry, 0, 1)
  598. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  599. self.bbrounded_cb.setToolTip(
  600. "If the bounding box is \n"
  601. "to have rounded corners\n"
  602. "their radius is equal to\n"
  603. "the margin."
  604. )
  605. grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  606. self.generate_bb_button = QtGui.QPushButton('Generate Geometry')
  607. self.generate_bb_button.setToolTip(
  608. "Genrate the Geometry object."
  609. )
  610. self.custom_box.addWidget(self.generate_bb_button)
  611. # def main():
  612. #
  613. # app = QtGui.QApplication(sys.argv)
  614. # fc = GerberObjectUI()
  615. # sys.exit(app.exec_())
  616. #
  617. #
  618. # if __name__ == '__main__':
  619. # main()