ObjectUI.py 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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. choose_tools_label = QtGui.QLabel(
  349. "Select from the tools section above\n"
  350. "the tools you want to include."
  351. )
  352. self.custom_box.addWidget(choose_tools_label)
  353. self.generate_cnc_button = QtGui.QPushButton('Generate')
  354. self.generate_cnc_button.setToolTip(
  355. "Generate the CNC Job."
  356. )
  357. self.custom_box.addWidget(self.generate_cnc_button)
  358. ## Milling Holes
  359. self.mill_hole_label = QtGui.QLabel('<b>Mill Holes</b>')
  360. self.mill_hole_label.setToolTip(
  361. "Create Geometry for milling holes."
  362. )
  363. self.custom_box.addWidget(self.mill_hole_label)
  364. grid1 = QtGui.QGridLayout()
  365. self.custom_box.addLayout(grid1)
  366. tdlabel = QtGui.QLabel('Tool dia:')
  367. tdlabel.setToolTip(
  368. "Diameter of the cutting tool."
  369. )
  370. grid1.addWidget(tdlabel, 0, 0)
  371. self.tooldia_entry = LengthEntry()
  372. grid1.addWidget(self.tooldia_entry, 0, 1)
  373. choose_tools_label2 = QtGui.QLabel(
  374. "Select from the tools section above\n"
  375. "the tools you want to include."
  376. )
  377. self.custom_box.addWidget(choose_tools_label2)
  378. self.generate_milling_button = QtGui.QPushButton('Generate Geometry')
  379. self.generate_milling_button.setToolTip(
  380. "Create the Geometry Object\n"
  381. "for milling toolpaths."
  382. )
  383. self.custom_box.addWidget(self.generate_milling_button)
  384. class GerberObjectUI(ObjectUI):
  385. """
  386. User interface for Gerber objects.
  387. """
  388. def __init__(self, parent=None):
  389. ObjectUI.__init__(self, title='Gerber Object', parent=parent)
  390. ## Plot options
  391. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  392. self.custom_box.addWidget(self.plot_options_label)
  393. grid0 = QtGui.QGridLayout()
  394. self.custom_box.addLayout(grid0)
  395. # Plot CB
  396. self.plot_cb = FCCheckBox(label='Plot')
  397. self.plot_options_label.setToolTip(
  398. "Plot (show) this object."
  399. )
  400. grid0.addWidget(self.plot_cb, 0, 0)
  401. # Solid CB
  402. self.solid_cb = FCCheckBox(label='Solid')
  403. self.solid_cb.setToolTip(
  404. "Solid color polygons."
  405. )
  406. grid0.addWidget(self.solid_cb, 0, 1)
  407. # Multicolored CB
  408. self.multicolored_cb = FCCheckBox(label='Multicolored')
  409. self.multicolored_cb.setToolTip(
  410. "Draw polygons in different colors."
  411. )
  412. grid0.addWidget(self.multicolored_cb, 0, 2)
  413. ## Isolation Routing
  414. self.isolation_routing_label = QtGui.QLabel("<b>Isolation Routing:</b>")
  415. self.isolation_routing_label.setToolTip(
  416. "Create a Geometry object with\n"
  417. "toolpaths to cut outside polygons."
  418. )
  419. self.custom_box.addWidget(self.isolation_routing_label)
  420. grid1 = QtGui.QGridLayout()
  421. self.custom_box.addLayout(grid1)
  422. tdlabel = QtGui.QLabel('Tool dia:')
  423. tdlabel.setToolTip(
  424. "Diameter of the cutting tool."
  425. )
  426. grid1.addWidget(tdlabel, 0, 0)
  427. self.iso_tool_dia_entry = LengthEntry()
  428. grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
  429. passlabel = QtGui.QLabel('Width (# passes):')
  430. passlabel.setToolTip(
  431. "Width of the isolation gap in\n"
  432. "number (integer) of tool widths."
  433. )
  434. grid1.addWidget(passlabel, 1, 0)
  435. self.iso_width_entry = IntEntry()
  436. grid1.addWidget(self.iso_width_entry, 1, 1)
  437. overlabel = QtGui.QLabel('Pass overlap:')
  438. overlabel.setToolTip(
  439. "How much (fraction of tool width)\n"
  440. "to overlap each pass."
  441. )
  442. grid1.addWidget(overlabel, 2, 0)
  443. self.iso_overlap_entry = FloatEntry()
  444. grid1.addWidget(self.iso_overlap_entry, 2, 1)
  445. self.generate_iso_button = QtGui.QPushButton('Generate Geometry')
  446. self.generate_iso_button.setToolTip(
  447. "Create the Geometry Object\n"
  448. "for isolation routing."
  449. )
  450. self.custom_box.addWidget(self.generate_iso_button)
  451. ## Board cuttout
  452. self.board_cutout_label = QtGui.QLabel("<b>Board cutout:</b>")
  453. self.board_cutout_label.setToolTip(
  454. "Create toolpaths to cut around\n"
  455. "the PCB and separate it from\n"
  456. "the original board."
  457. )
  458. self.custom_box.addWidget(self.board_cutout_label)
  459. grid2 = QtGui.QGridLayout()
  460. self.custom_box.addLayout(grid2)
  461. tdclabel = QtGui.QLabel('Tool dia:')
  462. tdclabel.setToolTip(
  463. "Diameter of the cutting tool."
  464. )
  465. grid2.addWidget(tdclabel, 0, 0)
  466. self.cutout_tooldia_entry = LengthEntry()
  467. grid2.addWidget(self.cutout_tooldia_entry, 0, 1)
  468. marginlabel = QtGui.QLabel('Margin:')
  469. marginlabel.setToolTip(
  470. "Distance from objects at which\n"
  471. "to draw the cutout."
  472. )
  473. grid2.addWidget(marginlabel, 1, 0)
  474. self.cutout_margin_entry = LengthEntry()
  475. grid2.addWidget(self.cutout_margin_entry, 1, 1)
  476. gaplabel = QtGui.QLabel('Gap size:')
  477. gaplabel.setToolTip(
  478. "Size of the gaps in the toolpath\n"
  479. "that will remain to hold the\n"
  480. "board in place."
  481. )
  482. grid2.addWidget(gaplabel, 2, 0)
  483. self.cutout_gap_entry = LengthEntry()
  484. grid2.addWidget(self.cutout_gap_entry, 2, 1)
  485. gapslabel = QtGui.QLabel('Gaps:')
  486. gapslabel.setToolTip(
  487. "Where to place the gaps, Top/Bottom\n"
  488. "Left/Rigt, or on all 4 sides."
  489. )
  490. grid2.addWidget(gapslabel, 3, 0)
  491. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  492. {'label': '2 (L/R)', 'value': 'lr'},
  493. {'label': '4', 'value': '4'}])
  494. grid2.addWidget(self.gaps_radio, 3, 1)
  495. self.generate_cutout_button = QtGui.QPushButton('Generate Geometry')
  496. self.generate_cutout_button.setToolTip(
  497. "Generate the geometry for\n"
  498. "the board cutout."
  499. )
  500. self.custom_box.addWidget(self.generate_cutout_button)
  501. ## Non-copper regions
  502. self.noncopper_label = QtGui.QLabel("<b>Non-copper regions:</b>")
  503. self.noncopper_label.setToolTip(
  504. "Create polygons covering the\n"
  505. "areas without copper on the PCB.\n"
  506. "Equivalent to the inverse of this\n"
  507. "object. Can be used to remove all\n"
  508. "copper from a specified region."
  509. )
  510. self.custom_box.addWidget(self.noncopper_label)
  511. grid3 = QtGui.QGridLayout()
  512. self.custom_box.addLayout(grid3)
  513. # Margin
  514. bmlabel = QtGui.QLabel('Boundary Margin:')
  515. bmlabel.setToolTip(
  516. "Specify the edge of the PCB\n"
  517. "by drawing a box around all\n"
  518. "objects with this minimum\n"
  519. "distance."
  520. )
  521. grid3.addWidget(bmlabel, 0, 0)
  522. self.noncopper_margin_entry = LengthEntry()
  523. grid3.addWidget(self.noncopper_margin_entry, 0, 1)
  524. # Rounded corners
  525. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  526. self.noncopper_rounded_cb.setToolTip(
  527. "Creates a Geometry objects with polygons\n"
  528. "covering the copper-free areas of the PCB."
  529. )
  530. grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  531. self.generate_noncopper_button = QtGui.QPushButton('Generate Geometry')
  532. self.custom_box.addWidget(self.generate_noncopper_button)
  533. ## Bounding box
  534. self.boundingbox_label = QtGui.QLabel('<b>Bounding Box:</b>')
  535. self.custom_box.addWidget(self.boundingbox_label)
  536. grid4 = QtGui.QGridLayout()
  537. self.custom_box.addLayout(grid4)
  538. bbmargin = QtGui.QLabel('Boundary Margin:')
  539. bbmargin.setToolTip(
  540. "Distance of the edges of the box\n"
  541. "to the nearest polygon."
  542. )
  543. grid4.addWidget(bbmargin, 0, 0)
  544. self.bbmargin_entry = LengthEntry()
  545. grid4.addWidget(self.bbmargin_entry, 0, 1)
  546. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  547. self.bbrounded_cb.setToolTip(
  548. "If the bounding box is \n"
  549. "to have rounded corners\n"
  550. "their radius is equal to\n"
  551. "the margin."
  552. )
  553. grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  554. self.generate_bb_button = QtGui.QPushButton('Generate Geometry')
  555. self.generate_bb_button.setToolTip(
  556. "Genrate the Geometry object."
  557. )
  558. self.custom_box.addWidget(self.generate_bb_button)
  559. # def main():
  560. #
  561. # app = QtGui.QApplication(sys.argv)
  562. # fc = GerberObjectUI()
  563. # sys.exit(app.exec_())
  564. #
  565. #
  566. # if __name__ == '__main__':
  567. # main()