ObjectUI.py 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. ############################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # http://caram.cl/software/flatcam #
  4. # Author: Juan Pablo Caram (c) #
  5. # Date: 2/5/2014 #
  6. # MIT Licence #
  7. ############################################################
  8. from gi.repository import Gtk
  9. from GUIElements import *
  10. class ObjectUI(Gtk.VBox):
  11. """
  12. Base class for the UI of FlatCAM objects.
  13. """
  14. def __init__(self, icon_file='share/flatcam_icon32.png', title='FlatCAM Object'):
  15. Gtk.VBox.__init__(self, spacing=3, margin=5, vexpand=False)
  16. ## Page Title box (spacing between children)
  17. self.title_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 2)
  18. self.pack_start(self.title_box, expand=False, fill=False, padding=2)
  19. ## Page Title icon
  20. self.icon = Gtk.Image.new_from_file(icon_file)
  21. self.title_box.pack_start(self.icon, expand=False, fill=False, padding=2)
  22. ## Title label
  23. self.title_label = Gtk.Label()
  24. self.title_label.set_markup("<b>" + title + "</b>")
  25. self.title_label.set_justify(Gtk.Justification.CENTER)
  26. self.title_box.pack_start(self.title_label, expand=False, fill=False, padding=2)
  27. ## Object name
  28. self.name_box = Gtk.Box.new(Gtk.Orientation.HORIZONTAL, 2)
  29. self.pack_start(self.name_box, expand=False, fill=False, padding=2)
  30. name_label = Gtk.Label('Name:')
  31. name_label.set_justify(Gtk.Justification.RIGHT)
  32. self.name_box.pack_start(name_label,
  33. expand=False, fill=False, padding=2)
  34. self.name_entry = FCEntry()
  35. self.name_box.pack_start(self.name_entry, expand=True, fill=False, padding=2)
  36. ## Box box for custom widgets
  37. self.custom_box = Gtk.VBox(spacing=3, margin=0, vexpand=False)
  38. self.pack_start(self.custom_box, expand=False, fill=False, padding=0)
  39. ## Common to all objects
  40. ## Scale
  41. self.scale_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  42. self.scale_label.set_markup('<b>Scale:</b>')
  43. self.scale_label.set_tooltip_markup(
  44. "Change the size of the object."
  45. )
  46. self.pack_start(self.scale_label, expand=False, fill=False, padding=2)
  47. grid5 = Gtk.Grid(column_spacing=3, row_spacing=2)
  48. self.pack_start(grid5, expand=False, fill=False, padding=2)
  49. # Factor
  50. l10 = Gtk.Label('Factor:', xalign=1)
  51. l10.set_tooltip_markup(
  52. "Factor by which to multiply\n"
  53. "geometric features of this object."
  54. )
  55. grid5.attach(l10, 0, 0, 1, 1)
  56. self.scale_entry = FloatEntry()
  57. self.scale_entry.set_text("1.0")
  58. grid5.attach(self.scale_entry, 1, 0, 1, 1)
  59. # GO Button
  60. self.scale_button = Gtk.Button(label='Scale')
  61. self.scale_button.set_tooltip_markup(
  62. "Perform scaling operation."
  63. )
  64. self.pack_start(self.scale_button, expand=False, fill=False, padding=2)
  65. ## Offset
  66. self.offset_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  67. self.offset_label.set_markup('<b>Offset:</b>')
  68. self.offset_label.set_tooltip_markup(
  69. "Change the position of this object."
  70. )
  71. self.pack_start(self.offset_label, expand=False, fill=False, padding=2)
  72. grid6 = Gtk.Grid(column_spacing=3, row_spacing=2)
  73. self.pack_start(grid6, expand=False, fill=False, padding=2)
  74. # Vector
  75. l11 = Gtk.Label('Offset Vector:', xalign=1)
  76. l11.set_tooltip_markup(
  77. "Amount by which to move the object\n"
  78. "in the x and y axes in (x, y) format."
  79. )
  80. grid6.attach(l11, 0, 0, 1, 1)
  81. self.offsetvector_entry = EvalEntry()
  82. self.offsetvector_entry.set_text("(0.0, 0.0)")
  83. grid6.attach(self.offsetvector_entry, 1, 0, 1, 1)
  84. self.offset_button = Gtk.Button(label='Scale')
  85. self.offset_button.set_tooltip_markup(
  86. "Perform the offset operation."
  87. )
  88. self.pack_start(self.offset_button, expand=False, fill=False, padding=2)
  89. def set_field(self, name, value):
  90. getattr(self, name).set_value(value)
  91. def get_field(self, name):
  92. return getattr(self, name).get_value()
  93. class CNCObjectUI(ObjectUI):
  94. """
  95. User interface for CNCJob objects.
  96. """
  97. def __init__(self):
  98. ObjectUI.__init__(self, title='CNC Job Object', icon_file='share/cnc32.png')
  99. ## Plot options
  100. self.plot_options_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  101. self.plot_options_label.set_markup("<b>Plot Options:</b>")
  102. self.custom_box.pack_start(self.plot_options_label, expand=False, fill=True, padding=2)
  103. grid0 = Gtk.Grid(column_spacing=3, row_spacing=2)
  104. self.custom_box.pack_start(grid0, expand=False, fill=False, padding=2)
  105. # Plot CB
  106. self.plot_cb = FCCheckBox(label='Plot')
  107. self.plot_cb.set_tooltip_markup(
  108. "Plot (show) this object."
  109. )
  110. grid0.attach(self.plot_cb, 0, 0, 2, 1)
  111. # Tool dia for plot
  112. l1 = Gtk.Label('Tool dia:', xalign=1)
  113. l1.set_tooltip_markup(
  114. "Diameter of the tool to be\n"
  115. "rendered in the plot."
  116. )
  117. grid0.attach(l1, 0, 1, 1, 1)
  118. self.tooldia_entry = LengthEntry()
  119. grid0.attach(self.tooldia_entry, 1, 1, 1, 1)
  120. # Update plot button
  121. self.updateplot_button = Gtk.Button(label='Update Plot')
  122. self.updateplot_button.set_tooltip_markup(
  123. "Update the plot."
  124. )
  125. self.custom_box.pack_start(self.updateplot_button, expand=False, fill=False, padding=2)
  126. ## Export G-Code
  127. self.export_gcode_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  128. self.export_gcode_label.set_markup("<b>Export G-Code:</b>")
  129. self.export_gcode_label.set_tooltip_markup(
  130. "Export and save G-Code to\n"
  131. "make this object to a file."
  132. )
  133. self.custom_box.pack_start(self.export_gcode_label, expand=False, fill=False, padding=2)
  134. # GO Button
  135. self.export_gcode_button = Gtk.Button(label='Export G-Code')
  136. self.export_gcode_button.set_tooltip_markup(
  137. "Opens dialog to save G-Code\n"
  138. "file."
  139. )
  140. self.custom_box.pack_start(self.export_gcode_button, expand=False, fill=False, padding=2)
  141. class GeometryObjectUI(ObjectUI):
  142. """
  143. User interface for Geometry objects.
  144. """
  145. def __init__(self):
  146. ObjectUI.__init__(self, title='Geometry Object', icon_file='share/geometry32.png')
  147. ## Plot options
  148. self.plot_options_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  149. self.plot_options_label.set_markup("<b>Plot Options:</b>")
  150. self.custom_box.pack_start(self.plot_options_label, expand=False, fill=True, padding=2)
  151. grid0 = Gtk.Grid(column_spacing=3, row_spacing=2)
  152. self.custom_box.pack_start(grid0, expand=True, fill=False, padding=2)
  153. # Plot CB
  154. self.plot_cb = FCCheckBox(label='Plot')
  155. self.plot_cb.set_tooltip_markup(
  156. "Plot (show) this object."
  157. )
  158. grid0.attach(self.plot_cb, 0, 0, 1, 1)
  159. ## Create CNC Job
  160. self.cncjob_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  161. self.cncjob_label.set_markup('<b>Create CNC Job:</b>')
  162. self.cncjob_label.set_tooltip_markup(
  163. "Create a CNC Job object\n"
  164. "tracing the contours of this\n"
  165. "Geometry object."
  166. )
  167. self.custom_box.pack_start(self.cncjob_label, expand=True, fill=False, padding=2)
  168. grid1 = Gtk.Grid(column_spacing=3, row_spacing=2)
  169. self.custom_box.pack_start(grid1, expand=True, fill=False, padding=2)
  170. # Cut Z
  171. l1 = Gtk.Label('Cut Z:', xalign=1)
  172. l1.set_tooltip_markup(
  173. "Cutting depth (negative)\n"
  174. "below the copper surface."
  175. )
  176. grid1.attach(l1, 0, 0, 1, 1)
  177. self.cutz_entry = LengthEntry()
  178. grid1.attach(self.cutz_entry, 1, 0, 1, 1)
  179. # Travel Z
  180. l2 = Gtk.Label('Travel Z:', xalign=1)
  181. l2.set_tooltip_markup(
  182. "Height of the tool when\n"
  183. "moving without cutting."
  184. )
  185. grid1.attach(l2, 0, 1, 1, 1)
  186. self.travelz_entry = LengthEntry()
  187. grid1.attach(self.travelz_entry, 1, 1, 1, 1)
  188. l3 = Gtk.Label('Feed rate:', xalign=1)
  189. l3.set_tooltip_markup(
  190. "Cutting speed in the XY\n"
  191. "plane in units per minute"
  192. )
  193. grid1.attach(l3, 0, 2, 1, 1)
  194. self.cncfeedrate_entry = LengthEntry()
  195. grid1.attach(self.cncfeedrate_entry, 1, 2, 1, 1)
  196. l4 = Gtk.Label('Tool dia:', xalign=1)
  197. l4.set_tooltip_markup(
  198. "The diameter of the cutting\n"
  199. "tool (just for display)."
  200. )
  201. grid1.attach(l4, 0, 3, 1, 1)
  202. self.cnctooldia_entry = LengthEntry()
  203. grid1.attach(self.cnctooldia_entry, 1, 3, 1, 1)
  204. self.generate_cnc_button = Gtk.Button(label='Generate')
  205. self.generate_cnc_button.set_tooltip_markup(
  206. "Generate the CNC Job object."
  207. )
  208. self.custom_box.pack_start(self.generate_cnc_button, expand=True, fill=False, padding=2)
  209. ## Paint Area
  210. self.paint_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  211. self.paint_label.set_markup('<b>Paint Area:</b>')
  212. self.paint_label.set_tooltip_markup(
  213. "Creates tool paths to cover the\n"
  214. "whole area of a polygon (remove\n"
  215. "all copper). You will be asked\n"
  216. "to click on the desired polygon."
  217. )
  218. self.custom_box.pack_start(self.paint_label, expand=True, fill=False, padding=2)
  219. grid2 = Gtk.Grid(column_spacing=3, row_spacing=2)
  220. self.custom_box.pack_start(grid2, expand=True, fill=False, padding=2)
  221. # Tool dia
  222. l5 = Gtk.Label('Tool dia:', xalign=1)
  223. l5.set_tooltip_markup(
  224. "Diameter of the tool to\n"
  225. "be used in the operation."
  226. )
  227. grid2.attach(l5, 0, 0, 1, 1)
  228. self.painttooldia_entry = LengthEntry()
  229. grid2.attach(self.painttooldia_entry, 1, 0, 1, 1)
  230. # Overlap
  231. l6 = Gtk.Label('Overlap:', xalign=1)
  232. l6.set_tooltip_markup(
  233. "How much (fraction) of the tool\n"
  234. "width to overlap each tool pass."
  235. )
  236. grid2.attach(l6, 0, 1, 1, 1)
  237. self.paintoverlap_entry = LengthEntry()
  238. grid2.attach(self.paintoverlap_entry, 1, 1, 1, 1)
  239. # Margin
  240. l7 = Gtk.Label('Margin:', xalign=1)
  241. l7.set_tooltip_markup(
  242. "Distance by which to avoid\n"
  243. "the edges of the polygon to\n"
  244. "be painted."
  245. )
  246. grid2.attach(l7, 0, 2, 1, 1)
  247. self.paintmargin_entry = LengthEntry()
  248. grid2.attach(self.paintmargin_entry, 1, 2, 1, 1)
  249. # GO Button
  250. self.generate_paint_button = Gtk.Button(label='Generate')
  251. self.generate_paint_button.set_tooltip_markup(
  252. "After clicking here, click inside\n"
  253. "the polygon you wish to be painted.\n"
  254. "A new Geometry object with the tool\n"
  255. "paths will be created."
  256. )
  257. self.custom_box.pack_start(self.generate_paint_button, expand=True, fill=False, padding=2)
  258. class ExcellonObjectUI(ObjectUI):
  259. """
  260. User interface for Excellon objects.
  261. """
  262. def __init__(self):
  263. ObjectUI.__init__(self, title='Excellon Object', icon_file='share/drill32.png')
  264. ## Plot options
  265. self.plot_options_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  266. self.plot_options_label.set_markup("<b>Plot Options:</b>")
  267. self.custom_box.pack_start(self.plot_options_label, expand=False, fill=True, padding=2)
  268. grid0 = Gtk.Grid(column_spacing=3, row_spacing=2)
  269. self.custom_box.pack_start(grid0, expand=True, fill=False, padding=2)
  270. self.plot_cb = FCCheckBox(label='Plot')
  271. self.plot_cb.set_tooltip_markup(
  272. "Plot (show) this object."
  273. )
  274. grid0.attach(self.plot_cb, 0, 0, 1, 1)
  275. self.solid_cb = FCCheckBox(label='Solid')
  276. self.solid_cb.set_tooltip_markup(
  277. "Solid circles."
  278. )
  279. grid0.attach(self.solid_cb, 1, 0, 1, 1)
  280. ## Create CNC Job
  281. self.cncjob_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  282. self.cncjob_label.set_markup('<b>Create CNC Job</b>')
  283. self.cncjob_label.set_tooltip_markup(
  284. "Create a CNC Job object\n"
  285. "for this drill object."
  286. )
  287. self.custom_box.pack_start(self.cncjob_label, expand=True, fill=False, padding=2)
  288. grid1 = Gtk.Grid(column_spacing=3, row_spacing=2)
  289. self.custom_box.pack_start(grid1, expand=True, fill=False, padding=2)
  290. l1 = Gtk.Label('Cut Z:', xalign=1)
  291. l1.set_tooltip_markup(
  292. "Drill depth (negative)\n"
  293. "below the copper surface."
  294. )
  295. grid1.attach(l1, 0, 0, 1, 1)
  296. self.cutz_entry = LengthEntry()
  297. grid1.attach(self.cutz_entry, 1, 0, 1, 1)
  298. l2 = Gtk.Label('Travel Z:', xalign=1)
  299. l2.set_tooltip_markup(
  300. "Tool height when travelling\n"
  301. "across the XY plane."
  302. )
  303. grid1.attach(l2, 0, 1, 1, 1)
  304. self.travelz_entry = LengthEntry()
  305. grid1.attach(self.travelz_entry, 1, 1, 1, 1)
  306. l3 = Gtk.Label('Feed rate:', xalign=1)
  307. l3.set_tooltip_markup(
  308. "Tool speed while drilling\n"
  309. "(in units per minute)."
  310. )
  311. grid1.attach(l3, 0, 2, 1, 1)
  312. self.feedrate_entry = LengthEntry()
  313. grid1.attach(self.feedrate_entry, 1, 2, 1, 1)
  314. l4 = Gtk.Label('Tools:', xalign=1)
  315. l4.set_tooltip_markup(
  316. "Which tools to include\n"
  317. "in the CNC Job."
  318. )
  319. grid1.attach(l4, 0, 3, 1, 1)
  320. boxt = Gtk.Box()
  321. grid1.attach(boxt, 1, 3, 1, 1)
  322. self.tools_entry = FCEntry()
  323. boxt.pack_start(self.tools_entry, expand=True, fill=False, padding=2)
  324. self.choose_tools_button = Gtk.Button(label='Choose...')
  325. self.choose_tools_button.set_tooltip_markup(
  326. "Choose the tools\n"
  327. "from a list."
  328. )
  329. boxt.pack_start(self.choose_tools_button, expand=True, fill=False, padding=2)
  330. self.generate_cnc_button = Gtk.Button(label='Generate')
  331. self.generate_cnc_button.set_tooltip_markup(
  332. "Generate the CNC Job."
  333. )
  334. self.custom_box.pack_start(self.generate_cnc_button, expand=True, fill=False, padding=2)
  335. class GerberObjectUI(ObjectUI):
  336. """
  337. User interface for Gerber objects.
  338. """
  339. def __init__(self):
  340. ObjectUI.__init__(self, title='Gerber Object')
  341. ## Plot options
  342. self.plot_options_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  343. self.plot_options_label.set_markup("<b>Plot Options:</b>")
  344. self.custom_box.pack_start(self.plot_options_label, expand=False, fill=True, padding=2)
  345. grid0 = Gtk.Grid(column_spacing=3, row_spacing=2)
  346. self.custom_box.pack_start(grid0, expand=True, fill=False, padding=2)
  347. # Plot CB
  348. self.plot_cb = FCCheckBox(label='Plot')
  349. self.plot_cb.set_tooltip_markup(
  350. "Plot (show) this object."
  351. )
  352. grid0.attach(self.plot_cb, 0, 0, 1, 1)
  353. # Solid CB
  354. self.solid_cb = FCCheckBox(label='Solid')
  355. self.solid_cb.set_tooltip_markup(
  356. "Solid color polygons."
  357. )
  358. grid0.attach(self.solid_cb, 1, 0, 1, 1)
  359. # Multicolored CB
  360. self.multicolored_cb = FCCheckBox(label='Multicolored')
  361. self.multicolored_cb.set_tooltip_markup(
  362. "Draw polygons in different colors."
  363. )
  364. grid0.attach(self.multicolored_cb, 2, 0, 1, 1)
  365. ## Isolation Routing
  366. self.isolation_routing_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  367. self.isolation_routing_label.set_markup("<b>Isolation Routing:</b>")
  368. self.isolation_routing_label.set_tooltip_markup(
  369. "Create a Geometry object with\n"
  370. "toolpaths to cut outside polygons."
  371. )
  372. self.custom_box.pack_start(self.isolation_routing_label, expand=True, fill=False, padding=2)
  373. grid = Gtk.Grid(column_spacing=3, row_spacing=2)
  374. self.custom_box.pack_start(grid, expand=True, fill=False, padding=2)
  375. l1 = Gtk.Label('Tool diam:', xalign=1)
  376. l1.set_tooltip_markup(
  377. "Diameter of the cutting tool."
  378. )
  379. grid.attach(l1, 0, 0, 1, 1)
  380. self.iso_tool_dia_entry = LengthEntry()
  381. grid.attach(self.iso_tool_dia_entry, 1, 0, 1, 1)
  382. l2 = Gtk.Label('Width (# passes):', xalign=1)
  383. l2.set_tooltip_markup(
  384. "Width of the isolation gap in\n"
  385. "number (integer) of tool widths."
  386. )
  387. grid.attach(l2, 0, 1, 1, 1)
  388. self.iso_width_entry = IntEntry()
  389. grid.attach(self.iso_width_entry, 1, 1, 1, 1)
  390. l3 = Gtk.Label('Pass overlap:', xalign=1)
  391. l3.set_tooltip_markup(
  392. "How much (fraction of tool width)\n"
  393. "to overlap each pass."
  394. )
  395. grid.attach(l3, 0, 2, 1, 1)
  396. self.iso_overlap_entry = FloatEntry()
  397. grid.attach(self.iso_overlap_entry, 1, 2, 1, 1)
  398. self.generate_iso_button = Gtk.Button(label='Generate Geometry')
  399. self.generate_iso_button.set_tooltip_markup(
  400. "Create the Geometry Object\n"
  401. "for isolation routing."
  402. )
  403. self.custom_box.pack_start(self.generate_iso_button, expand=True, fill=False, padding=2)
  404. ## Board cuttout
  405. self.board_cutout_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  406. self.board_cutout_label.set_markup("<b>Board cutout:</b>")
  407. self.board_cutout_label.set_tooltip_markup(
  408. "Create toolpaths to cut around\n"
  409. "the PCB and separate it from\n"
  410. "the original board."
  411. )
  412. self.custom_box.pack_start(self.board_cutout_label, expand=True, fill=False, padding=2)
  413. grid2 = Gtk.Grid(column_spacing=3, row_spacing=2)
  414. self.custom_box.pack_start(grid2, expand=True, fill=False, padding=2)
  415. l4 = Gtk.Label('Tool dia:', xalign=1)
  416. l4.set_tooltip_markup(
  417. "Diameter of the cutting tool."
  418. )
  419. grid2.attach(l4, 0, 0, 1, 1)
  420. self.cutout_tooldia_entry = LengthEntry()
  421. grid2.attach(self.cutout_tooldia_entry, 1, 0, 1, 1)
  422. l5 = Gtk.Label('Margin:', xalign=1)
  423. l5.set_tooltip_markup(
  424. "Distance from objects at which\n"
  425. "to draw the cutout."
  426. )
  427. grid2.attach(l5, 0, 1, 1, 1)
  428. self.cutout_margin_entry = LengthEntry()
  429. grid2.attach(self.cutout_margin_entry, 1, 1, 1, 1)
  430. l6 = Gtk.Label('Gap size:', xalign=1)
  431. l6.set_tooltip_markup(
  432. "Size of the gaps in the toolpath\n"
  433. "that will remain to hold the\n"
  434. "board in place."
  435. )
  436. grid2.attach(l6, 0, 2, 1, 1)
  437. self.cutout_gap_entry = LengthEntry()
  438. grid2.attach(self.cutout_gap_entry, 1, 2, 1, 1)
  439. l7 = Gtk.Label('Gaps:', xalign=1)
  440. l7.set_tooltip_markup(
  441. "Where to place the gaps, Top/Bottom\n"
  442. "Left/Rigt, or on all 4 sides."
  443. )
  444. grid2.attach(l7, 0, 3, 1, 1)
  445. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  446. {'label': '2 (L/R)', 'value': 'lr'},
  447. {'label': '4', 'value': '4'}])
  448. grid2.attach(self.gaps_radio, 1, 3, 1, 1)
  449. self.generate_cutout_button = Gtk.Button(label='Generate Geometry')
  450. self.generate_cutout_button.set_tooltip_markup(
  451. "Generate the geometry for\n"
  452. "the board cutout."
  453. )
  454. self.custom_box.pack_start(self.generate_cutout_button, expand=True, fill=False, padding=2)
  455. ## Non-copper regions
  456. self.noncopper_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  457. self.noncopper_label.set_markup("<b>Non-copper regions:</b>")
  458. self.noncopper_label.set_tooltip_markup(
  459. "Create polygons covering the\n"
  460. "areas without copper on the PCB.\n"
  461. "Equivalent to the inverse of this\n"
  462. "object. Can be used to remove all\n"
  463. "copper from a specified region."
  464. )
  465. self.custom_box.pack_start(self.noncopper_label, expand=True, fill=False, padding=2)
  466. grid3 = Gtk.Grid(column_spacing=3, row_spacing=2)
  467. self.custom_box.pack_start(grid3, expand=True, fill=False, padding=2)
  468. l8 = Gtk.Label('Boundary margin:', xalign=1)
  469. l8.set_tooltip_markup(
  470. "Specify the edge of the PCB\n"
  471. "by drawing a box around all\n"
  472. "objects with this minimum\n"
  473. "distance."
  474. )
  475. grid3.attach(l8, 0, 0, 1, 1)
  476. self.noncopper_margin_entry = LengthEntry()
  477. grid3.attach(self.noncopper_margin_entry, 1, 0, 1, 1)
  478. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  479. self.noncopper_rounded_cb.set_tooltip_markup(
  480. "If the boundary of the board\n"
  481. "is to have rounded corners\n"
  482. "their radius is equal to the margin."
  483. )
  484. grid3.attach(self.noncopper_rounded_cb, 0, 1, 2, 1)
  485. self.generate_noncopper_button = Gtk.Button(label='Generate Geometry')
  486. self.generate_noncopper_button.set_tooltip_markup(
  487. "Creates a Geometry objects with polygons\n"
  488. "covering the copper-free areas of the PCB."
  489. )
  490. self.custom_box.pack_start(self.generate_noncopper_button, expand=True, fill=False, padding=2)
  491. ## Bounding box
  492. self.boundingbox_label = Gtk.Label(justify=Gtk.Justification.LEFT, xalign=0, margin_top=5)
  493. self.boundingbox_label.set_markup('<b>Bounding Box:</b>')
  494. self.boundingbox_label.set_tooltip_markup(
  495. "Create a Geometry object with a rectangle\n"
  496. "enclosing all polygons at a given distance."
  497. )
  498. self.custom_box.pack_start(self.boundingbox_label, expand=True, fill=False, padding=2)
  499. grid4 = Gtk.Grid(column_spacing=3, row_spacing=2)
  500. self.custom_box.pack_start(grid4, expand=True, fill=False, padding=2)
  501. l9 = Gtk.Label('Boundary Margin:', xalign=1)
  502. l9.set_tooltip_markup(
  503. "Distance of the edges of the box\n"
  504. "to the nearest polygon."
  505. )
  506. grid4.attach(l9, 0, 0, 1, 1)
  507. self.bbmargin_entry = LengthEntry()
  508. grid4.attach(self.bbmargin_entry, 1, 0, 1, 1)
  509. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  510. self.bbrounded_cb.set_tooltip_markup(
  511. "If the bounding box is \n"
  512. "to have rounded corners\n"
  513. "their radius is equal to\n"
  514. "the margin."
  515. )
  516. grid4.attach(self.bbrounded_cb, 0, 1, 2, 1)
  517. self.generate_bb_button = Gtk.Button(label='Generate Geometry')
  518. self.generate_bb_button.set_tooltip_markup(
  519. "Genrate the Geometry object."
  520. )
  521. self.custom_box.pack_start(self.generate_bb_button, expand=True, fill=False, padding=2)