ObjectUI.py 24 KB

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