ObjectUI.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692
  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. # Append text to Gerber
  141. appendlabel = QtGui.QLabel('Append to G-Code:')
  142. appendlabel.setToolTip(
  143. "Type here any G-Code commands you would\n"
  144. "like to append to the generated file.\n"
  145. "I.e.: M2 (End of program)"
  146. )
  147. self.custom_box.addWidget(appendlabel)
  148. self.append_text = FCTextArea()
  149. self.custom_box.addWidget(self.append_text)
  150. # GO Button
  151. self.export_gcode_button = QtGui.QPushButton('Export G-Code')
  152. self.export_gcode_button.setToolTip(
  153. "Opens dialog to save G-Code\n"
  154. "file."
  155. )
  156. self.custom_box.addWidget(self.export_gcode_button)
  157. class GeometryObjectUI(ObjectUI):
  158. """
  159. User interface for Geometry objects.
  160. """
  161. def __init__(self, parent=None):
  162. super(GeometryObjectUI, self).__init__(title='Geometry Object', icon_file='share/geometry32.png', parent=parent)
  163. ## Plot options
  164. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  165. self.custom_box.addWidget(self.plot_options_label)
  166. # Plot CB
  167. self.plot_cb = FCCheckBox(label='Plot')
  168. self.plot_cb.setToolTip(
  169. "Plot (show) this object."
  170. )
  171. self.custom_box.addWidget(self.plot_cb)
  172. ## Create CNC Job
  173. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job:</b>')
  174. self.cncjob_label.setToolTip(
  175. "Create a CNC Job object\n"
  176. "tracing the contours of this\n"
  177. "Geometry object."
  178. )
  179. self.custom_box.addWidget(self.cncjob_label)
  180. grid1 = QtGui.QGridLayout()
  181. self.custom_box.addLayout(grid1)
  182. cutzlabel = QtGui.QLabel('Cut Z:')
  183. cutzlabel.setToolTip(
  184. "Cutting depth (negative)\n"
  185. "below the copper surface."
  186. )
  187. grid1.addWidget(cutzlabel, 0, 0)
  188. self.cutz_entry = LengthEntry()
  189. grid1.addWidget(self.cutz_entry, 0, 1)
  190. # Travel Z
  191. travelzlabel = QtGui.QLabel('Travel Z:')
  192. travelzlabel.setToolTip(
  193. "Height of the tool when\n"
  194. "moving without cutting."
  195. )
  196. grid1.addWidget(travelzlabel, 1, 0)
  197. self.travelz_entry = LengthEntry()
  198. grid1.addWidget(self.travelz_entry, 1, 1)
  199. # Feedrate
  200. frlabel = QtGui.QLabel('Feed Rate:')
  201. frlabel.setToolTip(
  202. "Cutting speed in the XY\n"
  203. "plane in units per minute"
  204. )
  205. grid1.addWidget(frlabel, 2, 0)
  206. self.cncfeedrate_entry = LengthEntry()
  207. grid1.addWidget(self.cncfeedrate_entry, 2, 1)
  208. # Tooldia
  209. tdlabel = QtGui.QLabel('Tool dia:')
  210. tdlabel.setToolTip(
  211. "The diameter of the cutting\n"
  212. "tool (just for display)."
  213. )
  214. grid1.addWidget(tdlabel, 3, 0)
  215. self.cnctooldia_entry = LengthEntry()
  216. grid1.addWidget(self.cnctooldia_entry, 3, 1)
  217. self.generate_cnc_button = QtGui.QPushButton('Generate')
  218. self.generate_cnc_button.setToolTip(
  219. "Generate the CNC Job object."
  220. )
  221. self.custom_box.addWidget(self.generate_cnc_button)
  222. ################
  223. ## Paint area ##
  224. ################
  225. self.paint_label = QtGui.QLabel('<b>Paint Area:</b>')
  226. self.paint_label.setToolTip(
  227. "Creates tool paths to cover the\n"
  228. "whole area of a polygon (remove\n"
  229. "all copper). You will be asked\n"
  230. "to click on the desired polygon."
  231. )
  232. self.custom_box.addWidget(self.paint_label)
  233. grid2 = QtGui.QGridLayout()
  234. self.custom_box.addLayout(grid2)
  235. # Tool dia
  236. ptdlabel = QtGui.QLabel('Tool dia:')
  237. ptdlabel.setToolTip(
  238. "Diameter of the tool to\n"
  239. "be used in the operation."
  240. )
  241. grid2.addWidget(ptdlabel, 0, 0)
  242. self.painttooldia_entry = LengthEntry()
  243. grid2.addWidget(self.painttooldia_entry, 0, 1)
  244. # Overlap
  245. ovlabel = QtGui.QLabel('Overlap:')
  246. ovlabel.setToolTip(
  247. "How much (fraction) of the tool\n"
  248. "width to overlap each tool pass."
  249. )
  250. grid2.addWidget(ovlabel, 1, 0)
  251. self.paintoverlap_entry = LengthEntry()
  252. grid2.addWidget(self.paintoverlap_entry, 1, 1)
  253. # Margin
  254. marginlabel = QtGui.QLabel('Margin:')
  255. marginlabel.setToolTip(
  256. "Distance by which to avoid\n"
  257. "the edges of the polygon to\n"
  258. "be painted."
  259. )
  260. grid2.addWidget(marginlabel, 2, 0)
  261. self.paintmargin_entry = LengthEntry()
  262. grid2.addWidget(self.paintmargin_entry, 2, 1)
  263. # Method
  264. methodlabel = QtGui.QLabel('Method:')
  265. methodlabel.setToolTip(
  266. "Algorithm to paint the polygon:<BR>"
  267. "<B>Standard</B>: Fixed step inwards.<BR>"
  268. "<B>Seed-based</B>: Outwards from seed."
  269. )
  270. grid2.addWidget(methodlabel, 3, 0)
  271. self.paintmethod_combo = RadioSet([
  272. {"label": "Standard", "value": "standard"},
  273. {"label": "Seed-based", "value": "seed"}
  274. ])
  275. grid2.addWidget(self.paintmethod_combo, 3, 1)
  276. # GO Button
  277. self.generate_paint_button = QtGui.QPushButton('Generate')
  278. self.generate_paint_button.setToolTip(
  279. "After clicking here, click inside\n"
  280. "the polygon you wish to be painted.\n"
  281. "A new Geometry object with the tool\n"
  282. "paths will be created."
  283. )
  284. self.custom_box.addWidget(self.generate_paint_button)
  285. class ExcellonObjectUI(ObjectUI):
  286. """
  287. User interface for Excellon objects.
  288. """
  289. def __init__(self, parent=None):
  290. ObjectUI.__init__(self, title='Excellon Object', icon_file='share/drill32.png', parent=parent)
  291. #### Plot options ####
  292. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  293. self.custom_box.addWidget(self.plot_options_label)
  294. grid0 = QtGui.QGridLayout()
  295. self.custom_box.addLayout(grid0)
  296. self.plot_cb = FCCheckBox(label='Plot')
  297. self.plot_cb.setToolTip(
  298. "Plot (show) this object."
  299. )
  300. grid0.addWidget(self.plot_cb, 0, 0)
  301. self.solid_cb = FCCheckBox(label='Solid')
  302. self.solid_cb.setToolTip(
  303. "Solid circles."
  304. )
  305. grid0.addWidget(self.solid_cb, 0, 1)
  306. #### Tools ####
  307. self.tools_table_label = QtGui.QLabel('<b>Tools</b>')
  308. self.tools_table_label.setToolTip(
  309. "Tools in this Excellon object."
  310. )
  311. self.custom_box.addWidget(self.tools_table_label)
  312. self.tools_table = QtGui.QTableWidget()
  313. self.tools_table.setFixedHeight(100)
  314. self.custom_box.addWidget(self.tools_table)
  315. #### Create CNC Job ####
  316. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job</b>')
  317. self.cncjob_label.setToolTip(
  318. "Create a CNC Job object\n"
  319. "for this drill object."
  320. )
  321. self.custom_box.addWidget(self.cncjob_label)
  322. grid1 = QtGui.QGridLayout()
  323. self.custom_box.addLayout(grid1)
  324. cutzlabel = QtGui.QLabel('Cut Z:')
  325. cutzlabel.setToolTip(
  326. "Drill depth (negative)\n"
  327. "below the copper surface."
  328. )
  329. grid1.addWidget(cutzlabel, 0, 0)
  330. self.cutz_entry = LengthEntry()
  331. grid1.addWidget(self.cutz_entry, 0, 1)
  332. travelzlabel = QtGui.QLabel('Travel Z:')
  333. travelzlabel.setToolTip(
  334. "Tool height when travelling\n"
  335. "across the XY plane."
  336. )
  337. grid1.addWidget(travelzlabel, 1, 0)
  338. self.travelz_entry = LengthEntry()
  339. grid1.addWidget(self.travelz_entry, 1, 1)
  340. frlabel = QtGui.QLabel('Feed rate:')
  341. frlabel.setToolTip(
  342. "Tool speed while drilling\n"
  343. "(in units per minute)."
  344. )
  345. grid1.addWidget(frlabel, 2, 0)
  346. self.feedrate_entry = LengthEntry()
  347. grid1.addWidget(self.feedrate_entry, 2, 1)
  348. # Tool change:
  349. toolchlabel = QtGui.QLabel("Tool change:")
  350. toolchlabel.setToolTip(
  351. "Include tool-change sequence\n"
  352. "in G-Code (Pause for tool change)."
  353. )
  354. self.toolchange_cb = FCCheckBox()
  355. grid1.addWidget(toolchlabel, 3, 0)
  356. grid1.addWidget(self.toolchange_cb, 3, 1)
  357. # Tool change Z:
  358. toolchzlabel = QtGui.QLabel("Tool change Z:")
  359. toolchzlabel.setToolTip(
  360. "Z-axis position (height) for\n"
  361. "tool change."
  362. )
  363. grid1.addWidget(toolchzlabel, 4, 0)
  364. self.toolchangez_entry = LengthEntry()
  365. grid1.addWidget(self.toolchangez_entry, 4, 1)
  366. self.ois_tcz = OptionalInputSection(self.toolchange_cb, [self.toolchangez_entry])
  367. choose_tools_label = QtGui.QLabel(
  368. "Select from the tools section above\n"
  369. "the tools you want to include."
  370. )
  371. self.custom_box.addWidget(choose_tools_label)
  372. self.generate_cnc_button = QtGui.QPushButton('Generate')
  373. self.generate_cnc_button.setToolTip(
  374. "Generate the CNC Job."
  375. )
  376. self.custom_box.addWidget(self.generate_cnc_button)
  377. #### Milling Holes ####
  378. self.mill_hole_label = QtGui.QLabel('<b>Mill Holes</b>')
  379. self.mill_hole_label.setToolTip(
  380. "Create Geometry for milling holes."
  381. )
  382. self.custom_box.addWidget(self.mill_hole_label)
  383. grid1 = QtGui.QGridLayout()
  384. self.custom_box.addLayout(grid1)
  385. tdlabel = QtGui.QLabel('Tool dia:')
  386. tdlabel.setToolTip(
  387. "Diameter of the cutting tool."
  388. )
  389. grid1.addWidget(tdlabel, 0, 0)
  390. self.tooldia_entry = LengthEntry()
  391. grid1.addWidget(self.tooldia_entry, 0, 1)
  392. choose_tools_label2 = QtGui.QLabel(
  393. "Select from the tools section above\n"
  394. "the tools you want to include."
  395. )
  396. self.custom_box.addWidget(choose_tools_label2)
  397. self.generate_milling_button = QtGui.QPushButton('Generate Geometry')
  398. self.generate_milling_button.setToolTip(
  399. "Create the Geometry Object\n"
  400. "for milling toolpaths."
  401. )
  402. self.custom_box.addWidget(self.generate_milling_button)
  403. class GerberObjectUI(ObjectUI):
  404. """
  405. User interface for Gerber objects.
  406. """
  407. def __init__(self, parent=None):
  408. ObjectUI.__init__(self, title='Gerber Object', parent=parent)
  409. ## Plot options
  410. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  411. self.custom_box.addWidget(self.plot_options_label)
  412. grid0 = QtGui.QGridLayout()
  413. self.custom_box.addLayout(grid0)
  414. # Plot CB
  415. self.plot_cb = FCCheckBox(label='Plot')
  416. self.plot_options_label.setToolTip(
  417. "Plot (show) this object."
  418. )
  419. grid0.addWidget(self.plot_cb, 0, 0)
  420. # Solid CB
  421. self.solid_cb = FCCheckBox(label='Solid')
  422. self.solid_cb.setToolTip(
  423. "Solid color polygons."
  424. )
  425. grid0.addWidget(self.solid_cb, 0, 1)
  426. # Multicolored CB
  427. self.multicolored_cb = FCCheckBox(label='Multicolored')
  428. self.multicolored_cb.setToolTip(
  429. "Draw polygons in different colors."
  430. )
  431. grid0.addWidget(self.multicolored_cb, 0, 2)
  432. ## Isolation Routing
  433. self.isolation_routing_label = QtGui.QLabel("<b>Isolation Routing:</b>")
  434. self.isolation_routing_label.setToolTip(
  435. "Create a Geometry object with\n"
  436. "toolpaths to cut outside polygons."
  437. )
  438. self.custom_box.addWidget(self.isolation_routing_label)
  439. grid1 = QtGui.QGridLayout()
  440. self.custom_box.addLayout(grid1)
  441. tdlabel = QtGui.QLabel('Tool dia:')
  442. tdlabel.setToolTip(
  443. "Diameter of the cutting tool."
  444. )
  445. grid1.addWidget(tdlabel, 0, 0)
  446. self.iso_tool_dia_entry = LengthEntry()
  447. grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
  448. passlabel = QtGui.QLabel('Width (# passes):')
  449. passlabel.setToolTip(
  450. "Width of the isolation gap in\n"
  451. "number (integer) of tool widths."
  452. )
  453. grid1.addWidget(passlabel, 1, 0)
  454. self.iso_width_entry = IntEntry()
  455. grid1.addWidget(self.iso_width_entry, 1, 1)
  456. overlabel = QtGui.QLabel('Pass overlap:')
  457. overlabel.setToolTip(
  458. "How much (fraction of tool width)\n"
  459. "to overlap each pass."
  460. )
  461. grid1.addWidget(overlabel, 2, 0)
  462. self.iso_overlap_entry = FloatEntry()
  463. grid1.addWidget(self.iso_overlap_entry, 2, 1)
  464. self.generate_iso_button = QtGui.QPushButton('Generate Geometry')
  465. self.generate_iso_button.setToolTip(
  466. "Create the Geometry Object\n"
  467. "for isolation routing."
  468. )
  469. self.custom_box.addWidget(self.generate_iso_button)
  470. ## Board cuttout
  471. self.board_cutout_label = QtGui.QLabel("<b>Board cutout:</b>")
  472. self.board_cutout_label.setToolTip(
  473. "Create toolpaths to cut around\n"
  474. "the PCB and separate it from\n"
  475. "the original board."
  476. )
  477. self.custom_box.addWidget(self.board_cutout_label)
  478. grid2 = QtGui.QGridLayout()
  479. self.custom_box.addLayout(grid2)
  480. tdclabel = QtGui.QLabel('Tool dia:')
  481. tdclabel.setToolTip(
  482. "Diameter of the cutting tool."
  483. )
  484. grid2.addWidget(tdclabel, 0, 0)
  485. self.cutout_tooldia_entry = LengthEntry()
  486. grid2.addWidget(self.cutout_tooldia_entry, 0, 1)
  487. marginlabel = QtGui.QLabel('Margin:')
  488. marginlabel.setToolTip(
  489. "Distance from objects at which\n"
  490. "to draw the cutout."
  491. )
  492. grid2.addWidget(marginlabel, 1, 0)
  493. self.cutout_margin_entry = LengthEntry()
  494. grid2.addWidget(self.cutout_margin_entry, 1, 1)
  495. gaplabel = QtGui.QLabel('Gap size:')
  496. gaplabel.setToolTip(
  497. "Size of the gaps in the toolpath\n"
  498. "that will remain to hold the\n"
  499. "board in place."
  500. )
  501. grid2.addWidget(gaplabel, 2, 0)
  502. self.cutout_gap_entry = LengthEntry()
  503. grid2.addWidget(self.cutout_gap_entry, 2, 1)
  504. gapslabel = QtGui.QLabel('Gaps:')
  505. gapslabel.setToolTip(
  506. "Where to place the gaps, Top/Bottom\n"
  507. "Left/Rigt, or on all 4 sides."
  508. )
  509. grid2.addWidget(gapslabel, 3, 0)
  510. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  511. {'label': '2 (L/R)', 'value': 'lr'},
  512. {'label': '4', 'value': '4'}])
  513. grid2.addWidget(self.gaps_radio, 3, 1)
  514. self.generate_cutout_button = QtGui.QPushButton('Generate Geometry')
  515. self.generate_cutout_button.setToolTip(
  516. "Generate the geometry for\n"
  517. "the board cutout."
  518. )
  519. self.custom_box.addWidget(self.generate_cutout_button)
  520. ## Non-copper regions
  521. self.noncopper_label = QtGui.QLabel("<b>Non-copper regions:</b>")
  522. self.noncopper_label.setToolTip(
  523. "Create polygons covering the\n"
  524. "areas without copper on the PCB.\n"
  525. "Equivalent to the inverse of this\n"
  526. "object. Can be used to remove all\n"
  527. "copper from a specified region."
  528. )
  529. self.custom_box.addWidget(self.noncopper_label)
  530. grid3 = QtGui.QGridLayout()
  531. self.custom_box.addLayout(grid3)
  532. # Margin
  533. bmlabel = QtGui.QLabel('Boundary Margin:')
  534. bmlabel.setToolTip(
  535. "Specify the edge of the PCB\n"
  536. "by drawing a box around all\n"
  537. "objects with this minimum\n"
  538. "distance."
  539. )
  540. grid3.addWidget(bmlabel, 0, 0)
  541. self.noncopper_margin_entry = LengthEntry()
  542. grid3.addWidget(self.noncopper_margin_entry, 0, 1)
  543. # Rounded corners
  544. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  545. self.noncopper_rounded_cb.setToolTip(
  546. "Creates a Geometry objects with polygons\n"
  547. "covering the copper-free areas of the PCB."
  548. )
  549. grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  550. self.generate_noncopper_button = QtGui.QPushButton('Generate Geometry')
  551. self.custom_box.addWidget(self.generate_noncopper_button)
  552. ## Bounding box
  553. self.boundingbox_label = QtGui.QLabel('<b>Bounding Box:</b>')
  554. self.custom_box.addWidget(self.boundingbox_label)
  555. grid4 = QtGui.QGridLayout()
  556. self.custom_box.addLayout(grid4)
  557. bbmargin = QtGui.QLabel('Boundary Margin:')
  558. bbmargin.setToolTip(
  559. "Distance of the edges of the box\n"
  560. "to the nearest polygon."
  561. )
  562. grid4.addWidget(bbmargin, 0, 0)
  563. self.bbmargin_entry = LengthEntry()
  564. grid4.addWidget(self.bbmargin_entry, 0, 1)
  565. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  566. self.bbrounded_cb.setToolTip(
  567. "If the bounding box is \n"
  568. "to have rounded corners\n"
  569. "their radius is equal to\n"
  570. "the margin."
  571. )
  572. grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  573. self.generate_bb_button = QtGui.QPushButton('Generate Geometry')
  574. self.generate_bb_button.setToolTip(
  575. "Genrate the Geometry object."
  576. )
  577. self.custom_box.addWidget(self.generate_bb_button)
  578. # def main():
  579. #
  580. # app = QtGui.QApplication(sys.argv)
  581. # fc = GerberObjectUI()
  582. # sys.exit(app.exec_())
  583. #
  584. #
  585. # if __name__ == '__main__':
  586. # main()