ObjectUI.py 23 KB

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