FlatCAMGUI.py 106 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461
  1. ############################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # http://flatcam.org #
  4. # Author: Juan Pablo Caram (c) #
  5. # Date: 2/5/2014 #
  6. # MIT Licence #
  7. ############################################################
  8. from PyQt5 import QtGui, QtCore, QtWidgets
  9. from PyQt5.QtCore import Qt
  10. from GUIElements import *
  11. import platform
  12. class FlatCAMGUI(QtWidgets.QMainWindow):
  13. # Emitted when persistent window geometry needs to be retained
  14. geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate')
  15. final_save = QtCore.pyqtSignal(name='saveBeforeExit')
  16. def __init__(self, version, beta, app):
  17. super(FlatCAMGUI, self).__init__()
  18. self.app = app
  19. # Divine icon pack by Ipapun @ finicons.com
  20. #####################################
  21. ### BUILDING THE GUI IS DONE HERE ###
  22. #####################################
  23. ############
  24. ### Menu ###
  25. ############
  26. self.menu = self.menuBar()
  27. ### File ###
  28. self.menufile = self.menu.addMenu('&File')
  29. # New
  30. self.menufilenew = QtWidgets.QAction(QtGui.QIcon('share/file16.png'), '&New Project', self)
  31. self.menufile.addAction(self.menufilenew)
  32. self.menufile_open = self.menufile.addMenu(QtGui.QIcon('share/folder32_bis.png'), 'Open')
  33. # Open gerber ...
  34. self.menufileopengerber = QtWidgets.QAction(QtGui.QIcon('share/flatcam_icon24.png'), 'Open &Gerber ...', self)
  35. self.menufile_open.addAction(self.menufileopengerber)
  36. # Open gerber with follow...
  37. self.menufileopengerber_follow = QtWidgets.QAction(QtGui.QIcon('share/flatcam_icon24.png'),
  38. 'Open &Gerber (w/ Follow)', self)
  39. self.menufile_open.addAction(self.menufileopengerber_follow)
  40. self.menufile_open.addSeparator()
  41. # Open Excellon ...
  42. self.menufileopenexcellon = QtWidgets.QAction(QtGui.QIcon('share/open_excellon32.png'), 'Open &Excellon ...',
  43. self)
  44. self.menufile_open.addAction(self.menufileopenexcellon)
  45. # Open G-Code ...
  46. self.menufileopengcode = QtWidgets.QAction(QtGui.QIcon('share/code.png'), 'Open G-&Code ...', self)
  47. self.menufile_open.addAction(self.menufileopengcode)
  48. # Open Project ...
  49. self.menufileopenproject = QtWidgets.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Project ...', self)
  50. self.menufile_open.addAction(self.menufileopenproject)
  51. # Recent
  52. self.recent = self.menufile.addMenu(QtGui.QIcon('share/recent_files.png'), "Recent files")
  53. # Separator
  54. self.menufile.addSeparator()
  55. # Run Scripts
  56. self.menufilerunscript = QtWidgets.QAction(QtGui.QIcon('share/script16.png'), 'Run Script', self)
  57. self.menufile.addAction(self.menufilerunscript)
  58. # Separator
  59. self.menufile.addSeparator()
  60. # Import ...
  61. self.menufileimport = self.menufile.addMenu(QtGui.QIcon('share/import.png'), 'Import')
  62. self.menufileimportsvg = QtWidgets.QAction(QtGui.QIcon('share/svg16.png'),
  63. '&SVG as Geometry Object', self)
  64. self.menufileimport.addAction(self.menufileimportsvg)
  65. self.menufileimportsvg_as_gerber = QtWidgets.QAction(QtGui.QIcon('share/svg16.png'),
  66. '&SVG as Gerber Object', self)
  67. self.menufileimport.addAction(self.menufileimportsvg_as_gerber)
  68. self.menufileimport.addSeparator()
  69. self.menufileimportdxf = QtWidgets.QAction(QtGui.QIcon('share/dxf16.png'),
  70. '&DXF as Geometry Object', self)
  71. self.menufileimport.addAction(self.menufileimportdxf)
  72. self.menufileimportdxf_as_gerber = QtWidgets.QAction(QtGui.QIcon('share/dxf16.png'),
  73. '&DXF as Gerber Object', self)
  74. self.menufileimport.addAction(self.menufileimportdxf_as_gerber)
  75. self.menufileimport.addSeparator()
  76. # Export ...
  77. self.menufileexport = self.menufile.addMenu(QtGui.QIcon('share/export.png'), 'Export')
  78. self.menufileexportsvg = QtWidgets.QAction(QtGui.QIcon('share/export.png'), 'Export &SVG ...', self)
  79. self.menufileexport.addAction(self.menufileexportsvg)
  80. self.menufileexportdxf = QtWidgets.QAction(QtGui.QIcon('share/export.png'), 'Export DXF ...', self)
  81. self.menufileexport.addAction(self.menufileexportdxf)
  82. self.menufileexport.addSeparator()
  83. self.menufileexportpng = QtWidgets.QAction(QtGui.QIcon('share/export_png32.png'), 'Export &PNG ...', self)
  84. self.menufileexport.addAction(self.menufileexportpng)
  85. self.menufileexport.addSeparator()
  86. self.menufileexportexcellon = QtWidgets.QAction(QtGui.QIcon('share/drill32.png'), 'Export &Excellon ...', self)
  87. self.menufileexport.addAction(self.menufileexportexcellon)
  88. self.menufileexportexcellon_altium = QtWidgets.QAction(QtGui.QIcon('share/drill32.png'),
  89. 'Export Excellon 2:4 LZ INCH ...', self)
  90. self.menufileexport.addAction(self.menufileexportexcellon_altium)
  91. # Separator
  92. self.menufile.addSeparator()
  93. # Save Defaults
  94. self.menufilesavedefaults = QtWidgets.QAction(QtGui.QIcon('share/defaults.png'), 'Save &Defaults', self)
  95. self.menufile.addAction(self.menufilesavedefaults)
  96. # Separator
  97. self.menufile.addSeparator()
  98. self.menufile_save = self.menufile.addMenu(QtGui.QIcon('share/save_as.png'), 'Save')
  99. # Save Project
  100. self.menufilesaveproject = QtWidgets.QAction(QtGui.QIcon('share/floppy16.png'), '&Save Project', self)
  101. self.menufile_save.addAction(self.menufilesaveproject)
  102. # Save Project As ...
  103. self.menufilesaveprojectas = QtWidgets.QAction(QtGui.QIcon('share/save_as.png'), 'Save Project &As ...', self)
  104. self.menufile_save.addAction(self.menufilesaveprojectas)
  105. # Save Project Copy ...
  106. self.menufilesaveprojectcopy = QtWidgets.QAction(QtGui.QIcon('share/floppy16.png'), 'Save Project C&opy ...',
  107. self)
  108. self.menufile_save.addAction(self.menufilesaveprojectcopy)
  109. # Separator
  110. self.menufile.addSeparator()
  111. # Quit
  112. self.menufile_exit = QtWidgets.QAction(QtGui.QIcon('share/power16.png'), 'E&xit', self)
  113. # exitAction.setShortcut('Ctrl+Q')
  114. # exitAction.setStatusTip('Exit application')
  115. self.menufile.addAction(self.menufile_exit)
  116. ### Edit ###
  117. self.menuedit = self.menu.addMenu('&Edit')
  118. self.menueditnew = self.menuedit.addAction(QtGui.QIcon('share/new_geo16.png'), '&New Geometry')
  119. self.menueditnewexc = self.menuedit.addAction(QtGui.QIcon('share/new_geo16.png'), 'New Excellon')
  120. # Separator
  121. self.menuedit.addSeparator()
  122. self.menueditedit = self.menuedit.addAction(QtGui.QIcon('share/edit16.png'), 'Edit Object')
  123. self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), '&Update Object')
  124. # Separator
  125. self.menuedit.addSeparator()
  126. self.menuedit_convert = self.menuedit.addMenu(QtGui.QIcon('share/convert24.png'), 'Conversion')
  127. self.menuedit_convertjoin = self.menuedit_convert.addAction(
  128. QtGui.QIcon('share/join16.png'), '&Join Geo/Gerber/Exc -> Geo')
  129. self.menuedit_convertjoin.setToolTip(
  130. "Merge a selection of objects, which can be of type:\n"
  131. "- Gerber\n"
  132. "- Excellon\n"
  133. "- Geometry\n"
  134. "into a new combo Geometry object.")
  135. self.menuedit_convertjoinexc = self.menuedit_convert.addAction(
  136. QtGui.QIcon('share/join16.png'), 'Join Excellon(s) -> Excellon')
  137. self.menuedit_convertjoinexc.setToolTip(
  138. "Merge a selection of Excellon objects into a new combo Excellon object.")
  139. # Separator
  140. self.menuedit_convert.addSeparator()
  141. self.menuedit_convert_sg2mg = self.menuedit_convert.addAction(
  142. QtGui.QIcon('share/convert24.png'), 'Convert Single to MultiGeo')
  143. self.menuedit_convert_sg2mg.setToolTip(
  144. "Will convert a Geometry object from single_geometry type\n"
  145. "to a multi_geometry type.")
  146. self.menuedit_convert_mg2sg = self.menuedit_convert.addAction(
  147. QtGui.QIcon('share/convert24.png'), 'Convert Multi to SingleGeo')
  148. self.menuedit_convert_mg2sg.setToolTip(
  149. "Will convert a Geometry object from multi_geometry type\n"
  150. "to a single_geometry type.")
  151. self.menuedit_convert.setToolTipsVisible(True)
  152. # Separator
  153. self.menuedit.addSeparator()
  154. self.menueditdelete = self.menuedit.addAction(QtGui.QIcon('share/trash16.png'), '&Delete')
  155. # Separator
  156. self.menuedit.addSeparator()
  157. self.menueditcopyobject = self.menuedit.addAction(QtGui.QIcon('share/copy.png'), '&Copy Object')
  158. self.menueditcopyobjectasgeom = self.menuedit.addAction(QtGui.QIcon('share/copy_geo.png'),
  159. 'Copy as &Geom')
  160. # Separator
  161. self.menuedit.addSeparator()
  162. self.menueditorigin = self.menuedit.addAction(QtGui.QIcon('share/origin.png'), 'Se&t Origin')
  163. self.menueditjump = self.menuedit.addAction(QtGui.QIcon('share/jump_to16.png'), 'Jump to Location')
  164. # Separator
  165. self.menuedit.addSeparator()
  166. self.menueditselectall = self.menuedit.addAction(QtGui.QIcon('share/select_all.png'),
  167. '&Select All')
  168. # Separator
  169. self.menuedit.addSeparator()
  170. self.menueditpreferences = self.menuedit.addAction(QtGui.QIcon('share/pref.png'), '&Preferences')
  171. ### Options ###
  172. self.menuoptions = self.menu.addMenu('&Options')
  173. # self.menuoptions_transfer = self.menuoptions.addMenu(QtGui.QIcon('share/transfer.png'), 'Transfer options')
  174. # self.menuoptions_transfer_a2p = self.menuoptions_transfer.addAction("Application to Project")
  175. # self.menuoptions_transfer_p2a = self.menuoptions_transfer.addAction("Project to Application")
  176. # self.menuoptions_transfer_p2o = self.menuoptions_transfer.addAction("Project to Object")
  177. # self.menuoptions_transfer_o2p = self.menuoptions_transfer.addAction("Object to Project")
  178. # self.menuoptions_transfer_a2o = self.menuoptions_transfer.addAction("Application to Object")
  179. # self.menuoptions_transfer_o2a = self.menuoptions_transfer.addAction("Object to Application")
  180. # Separator
  181. # self.menuoptions.addSeparator()
  182. # self.menuoptions_transform = self.menuoptions.addMenu(QtGui.QIcon('share/transform.png'),
  183. # '&Transform Object')
  184. self.menuoptions_transform_rotate = self.menuoptions.addAction(QtGui.QIcon('share/rotate.png'),
  185. "&Rotate Selection")
  186. # Separator
  187. self.menuoptions.addSeparator()
  188. self.menuoptions_transform_skewx = self.menuoptions.addAction(QtGui.QIcon('share/skewX.png'),
  189. "&Skew on X axis")
  190. self.menuoptions_transform_skewy = self.menuoptions.addAction(QtGui.QIcon('share/skewY.png'),
  191. "S&kew on Y axis")
  192. # Separator
  193. self.menuoptions.addSeparator()
  194. self.menuoptions_transform_flipx = self.menuoptions.addAction(QtGui.QIcon('share/flipx.png'),
  195. "Flip on &X axis")
  196. self.menuoptions_transform_flipy = self.menuoptions.addAction(QtGui.QIcon('share/flipy.png'),
  197. "Flip on &Y axis")
  198. # Separator
  199. self.menuoptions.addSeparator()
  200. ### View ###
  201. self.menuview = self.menu.addMenu('&View')
  202. self.menuviewenable = self.menuview.addAction(QtGui.QIcon('share/replot16.png'), 'Enable all plots')
  203. self.menuviewdisableall = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  204. 'Disable all plots')
  205. self.menuviewdisableother = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  206. 'Disable non-selected')
  207. # Separator
  208. self.menuview.addSeparator()
  209. self.menuview_zoom_fit = self.menuview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "&Zoom Fit")
  210. self.menuview_zoom_in = self.menuview.addAction(QtGui.QIcon('share/zoom_in32.png'), "&Zoom In")
  211. self.menuview_zoom_out = self.menuview.addAction(QtGui.QIcon('share/zoom_out32.png'), "&Zoom Out")
  212. self.menuview.addSeparator()
  213. self.menuview_toggle_axis = self.menuview.addAction(QtGui.QIcon('share/axis32.png'), "&Toggle Axis")
  214. self.menuview_toggle_workspace = self.menuview.addAction(QtGui.QIcon('share/workspace24.png'),
  215. "Toggle Workspace")
  216. ### FlatCAM Editor menu ###
  217. # self.editor_menu = QtWidgets.QMenu("Editor")
  218. # self.menu.addMenu(self.editor_menu)
  219. self.geo_editor_menu = QtWidgets.QMenu("Geo Editor")
  220. self.menu.addMenu(self.geo_editor_menu)
  221. # self.select_menuitem = self.menu.addAction(QtGui.QIcon('share/pointer16.png'), "Select 'Esc'")
  222. self.geo_add_circle_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/circle32.png'), 'Add Circle')
  223. self.geo_add_arc_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/arc16.png'), 'Add Arc')
  224. self.geo_editor_menu.addSeparator()
  225. self.geo_add_rectangle_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/rectangle32.png'), 'Add Rectangle')
  226. self.geo_add_polygon_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/polygon32.png'), 'Add Polygon')
  227. self.geo_add_path_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/path32.png'), 'Add Path')
  228. self.geo_editor_menu.addSeparator()
  229. self.geo_add_text_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/text32.png'), 'Add Text')
  230. self.geo_editor_menu.addSeparator()
  231. self.geo_union_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/union16.png'), 'Polygon Union')
  232. self.geo_intersection_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/intersection16.png'),
  233. 'Polygon Intersection')
  234. self.geo_subtract_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/subtract16.png'), 'Polygon Subtraction')
  235. self.geo_editor_menu.addSeparator()
  236. self.geo_cutpath_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/cutpath16.png'), 'Cut Path')
  237. # self.move_menuitem = self.menu.addAction(QtGui.QIcon('share/move16.png'), "Move Objects 'm'")
  238. self.geo_copy_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/copy16.png'), "Copy Geom")
  239. self.geo_delete_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/deleteshape16.png'), "Delete Shape")
  240. self.geo_editor_menu.addSeparator()
  241. self.geo_buffer_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/buffer16.png'), "Buffer Selection")
  242. self.geo_paint_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/paint16.png'), "Paint Selection")
  243. self.geo_editor_menu.addSeparator()
  244. # self.exc_editor_menu = QtWidgets.QMenu("Excellon Editor")
  245. # self.menu.addMenu(self.exc_editor_menu)
  246. self.geo_editor_menu.setDisabled(True)
  247. # self.exc_editor_menu.setDisabled(True)
  248. ### Tool ###
  249. # self.menutool = self.menu.addMenu('&Tool')
  250. self.menutool = QtWidgets.QMenu('&Tool')
  251. self.menutoolaction = self.menu.addMenu(self.menutool)
  252. self.menutoolshell = self.menutool.addAction(QtGui.QIcon('share/shell16.png'), '&Command Line')
  253. ### Help ###
  254. self.menuhelp = self.menu.addMenu('&Help')
  255. self.menuhelp_about = self.menuhelp.addAction(QtGui.QIcon('share/tv16.png'), 'About FlatCAM')
  256. self.menuhelp_home = self.menuhelp.addAction(QtGui.QIcon('share/home16.png'), 'Home')
  257. self.menuhelp_manual = self.menuhelp.addAction(QtGui.QIcon('share/globe16.png'), 'Manual')
  258. self.menuhelp.addSeparator()
  259. self.menuhelp_shortcut_list = self.menuhelp.addAction(QtGui.QIcon('share/shortcuts24.png'), 'Shortcuts List')
  260. self.menuhelp_videohelp = self.menuhelp.addAction(QtGui.QIcon('share/videohelp24.png'), 'See on YouTube')
  261. ################################
  262. ### Project Tab Context menu ###
  263. ################################
  264. self.menuproject = QtWidgets.QMenu()
  265. self.menuprojectenable = self.menuproject.addAction(QtGui.QIcon('share/replot32.png'), 'Enable Plot')
  266. self.menuprojectdisable = self.menuproject.addAction(QtGui.QIcon('share/clear_plot32.png'), 'Disable Plot')
  267. self.menuproject.addSeparator()
  268. self.menuprojectgeneratecnc = self.menuproject.addAction(QtGui.QIcon('share/cnc32.png'), 'Generate CNC')
  269. self.menuproject.addSeparator()
  270. self.menuprojectcopy = self.menuproject.addAction(QtGui.QIcon('share/copy32.png'), 'Copy')
  271. self.menuprojectdelete = self.menuproject.addAction(QtGui.QIcon('share/delete32.png'), 'Delete')
  272. self.menuprojectedit = self.menuproject.addAction(QtGui.QIcon('share/edit_ok32.png'), 'Edit')
  273. self.menuproject.addSeparator()
  274. self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), 'Properties')
  275. ###############
  276. ### Toolbar ###
  277. ###############
  278. self.toolbarfile = QtWidgets.QToolBar('File Toolbar')
  279. self.addToolBar(self.toolbarfile)
  280. self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
  281. "Open GERBER")
  282. self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), "Open EXCELLON")
  283. self.toolbarfile.addSeparator()
  284. self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), "Open project")
  285. self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), "Save project")
  286. self.toolbargeo = QtWidgets.QToolBar('Edit Toolbar')
  287. self.addToolBar(self.toolbargeo)
  288. self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "New Blank Geometry")
  289. self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), "New Blank Excellon")
  290. self.toolbargeo.addSeparator()
  291. self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), "Editor")
  292. self.update_obj_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit_ok32_bis.png'), "Save Object")
  293. self.update_obj_btn.setEnabled(False)
  294. self.toolbargeo.addSeparator()
  295. self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), "&Delete")
  296. self.toolbarview = QtWidgets.QToolBar('View Toolbar')
  297. self.addToolBar(self.toolbarview)
  298. self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), "&Replot")
  299. self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), "&Clear plot")
  300. self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), "Zoom In")
  301. self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), "Zoom Out")
  302. self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
  303. # self.toolbarview.setVisible(False)
  304. self.toolbartools = QtWidgets.QToolBar('Tools Toolbar')
  305. self.addToolBar(self.toolbartools)
  306. self.shell_btn = self.toolbartools.addAction(QtGui.QIcon('share/shell32.png'), "&Command Line")
  307. ### Drill Editor Toolbar ###
  308. self.exc_edit_toolbar = QtWidgets.QToolBar('Excellon Editor Toolbar')
  309. self.addToolBar(self.exc_edit_toolbar)
  310. self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
  311. self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), 'Add Drill Hole')
  312. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  313. QtGui.QIcon('share/addarray16.png'), 'Add Drill Hole Array')
  314. self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), 'Resize Drill')
  315. self.exc_edit_toolbar.addSeparator()
  316. self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), 'Copy Drill')
  317. self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Drill")
  318. self.exc_edit_toolbar.addSeparator()
  319. self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Drill")
  320. self.exc_edit_toolbar.setDisabled(True)
  321. self.exc_edit_toolbar.setVisible(False)
  322. ### Geometry Editor Toolbar ###
  323. self.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
  324. self.geo_edit_toolbar.setVisible(False)
  325. self.addToolBar(self.geo_edit_toolbar)
  326. self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
  327. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), 'Add Circle')
  328. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), 'Add Arc')
  329. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'), 'Add Rectangle')
  330. self.geo_edit_toolbar.addSeparator()
  331. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), 'Add Path')
  332. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), 'Add Polygon')
  333. self.geo_edit_toolbar.addSeparator()
  334. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), 'Add Text')
  335. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), 'Add Buffer')
  336. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), 'Paint Shape')
  337. self.geo_edit_toolbar.addSeparator()
  338. self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), 'Polygon Union')
  339. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
  340. 'Polygon Intersection')
  341. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'), 'Polygon Subtraction')
  342. self.geo_edit_toolbar.addSeparator()
  343. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), 'Cut Path')
  344. self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), "Copy Objects 'c'")
  345. self.geo_rotate_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rotate.png'), "Rotate Objects 'Space'")
  346. self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Shape '-'")
  347. self.geo_edit_toolbar.addSeparator()
  348. self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Objects 'm'")
  349. ### Snap Toolbar ###
  350. self.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
  351. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  352. self.addToolBar(self.snap_toolbar)
  353. self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), 'Snap to grid')
  354. self.grid_gap_x_entry = FCEntry2()
  355. self.grid_gap_x_entry.setMaximumWidth(70)
  356. self.grid_gap_x_entry.setToolTip("Grid X distance")
  357. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  358. self.grid_gap_y_entry = FCEntry2()
  359. self.grid_gap_y_entry.setMaximumWidth(70)
  360. self.grid_gap_y_entry.setToolTip("Grid Y distance")
  361. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  362. self.grid_space_label = QtWidgets.QLabel(" ")
  363. self.snap_toolbar.addWidget(self.grid_space_label)
  364. self.grid_gap_link_cb = FCCheckBox()
  365. self.grid_gap_link_cb.setToolTip("When active, value on Grid_X\n"
  366. "is copied to the Grid_Y value.")
  367. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  368. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  369. self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), 'Snap to corner')
  370. self.snap_max_dist_entry = QtWidgets.QLineEdit()
  371. self.snap_max_dist_entry.setMaximumWidth(70)
  372. self.snap_max_dist_entry.setToolTip("Max. magnet distance")
  373. self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  374. self.grid_snap_btn.setCheckable(True)
  375. self.corner_snap_btn.setCheckable(True)
  376. ################
  377. ### Splitter ###
  378. ################
  379. self.splitter = QtWidgets.QSplitter()
  380. self.setCentralWidget(self.splitter)
  381. ################
  382. ### Notebook ###
  383. ################
  384. self.notebook = QtWidgets.QTabWidget()
  385. self.splitter.addWidget(self.notebook)
  386. ### Project ###
  387. self.project_tab = QtWidgets.QWidget()
  388. # project_tab.setMinimumWidth(250) # Hack
  389. self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_tab)
  390. self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
  391. self.notebook.addTab(self.project_tab, "Project")
  392. ### Selected ###
  393. self.selected_tab = QtWidgets.QWidget()
  394. self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab)
  395. self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
  396. self.selected_scroll_area = VerticalScrollArea()
  397. self.selected_tab_layout.addWidget(self.selected_scroll_area)
  398. self.notebook.addTab(self.selected_tab, "Selected")
  399. ### Tool ###
  400. self.tool_tab = QtWidgets.QWidget()
  401. self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab)
  402. self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
  403. self.notebook.addTab(self.tool_tab, "Tool")
  404. self.tool_scroll_area = VerticalScrollArea()
  405. self.tool_tab_layout.addWidget(self.tool_scroll_area)
  406. self.right_widget = QtWidgets.QWidget()
  407. self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
  408. self.splitter.addWidget(self.right_widget)
  409. self.right_lay = QtWidgets.QVBoxLayout()
  410. self.right_lay.setContentsMargins(0, 0, 0, 0)
  411. self.right_widget.setLayout(self.right_lay)
  412. self.plot_tab_area = FCTab()
  413. self.right_lay.addWidget(self.plot_tab_area)
  414. self.plot_tab_area.setTabsClosable(True)
  415. plot_tab = QtWidgets.QWidget()
  416. self.plot_tab_area.addTab(plot_tab, "Plot Area")
  417. self.right_layout = QtWidgets.QVBoxLayout()
  418. self.right_layout.setContentsMargins(2, 2, 2, 2)
  419. plot_tab.setLayout(self.right_layout)
  420. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  421. self.plot_tab_area.protectTab(0)
  422. ########################################
  423. ### HERE WE BUILD THE PREF. TAB AREA ###
  424. ########################################
  425. self.preferences_tab = QtWidgets.QWidget()
  426. self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
  427. self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
  428. self.pref_tab_area = FCTab()
  429. self.pref_tab_area.setTabsClosable(False)
  430. self.pref_tab_area_tabBar = self.pref_tab_area.tabBar()
  431. self.pref_tab_area_tabBar.setStyleSheet("QTabBar::tab{width:80px;}")
  432. self.pref_tab_area_tabBar.setExpanding(True)
  433. self.pref_tab_layout.addWidget(self.pref_tab_area)
  434. self.general_tab = QtWidgets.QWidget()
  435. self.pref_tab_area.addTab(self.general_tab, "General")
  436. self.general_tab_lay = QtWidgets.QVBoxLayout()
  437. self.general_tab_lay.setContentsMargins(2, 2, 2, 2)
  438. self.general_tab.setLayout(self.general_tab_lay)
  439. self.hlay1 = QtWidgets.QHBoxLayout()
  440. self.general_tab_lay.addLayout(self.hlay1)
  441. self.options_combo = QtWidgets.QComboBox()
  442. self.options_combo.addItem("APP. DEFAULTS")
  443. self.options_combo.addItem("PROJ. OPTIONS ")
  444. self.hlay1.addWidget(self.options_combo)
  445. self.hlay1.addStretch()
  446. self.general_scroll_area = VerticalScrollArea()
  447. self.general_tab_lay.addWidget(self.general_scroll_area)
  448. self.gerber_tab = QtWidgets.QWidget()
  449. self.pref_tab_area.addTab(self.gerber_tab, "GERBER")
  450. self.gerber_tab_lay = QtWidgets.QVBoxLayout()
  451. self.gerber_tab_lay.setContentsMargins(2, 2, 2, 2)
  452. self.gerber_tab.setLayout(self.gerber_tab_lay)
  453. self.gerber_scroll_area = VerticalScrollArea()
  454. self.gerber_tab_lay.addWidget(self.gerber_scroll_area)
  455. self.excellon_tab = QtWidgets.QWidget()
  456. self.pref_tab_area.addTab(self.excellon_tab, "EXCELLON")
  457. self.excellon_tab_lay = QtWidgets.QVBoxLayout()
  458. self.excellon_tab_lay.setContentsMargins(2, 2, 2, 2)
  459. self.excellon_tab.setLayout(self.excellon_tab_lay)
  460. self.excellon_scroll_area = VerticalScrollArea()
  461. self.excellon_tab_lay.addWidget(self.excellon_scroll_area)
  462. self.geometry_tab = QtWidgets.QWidget()
  463. self.pref_tab_area.addTab(self.geometry_tab, "GEOMETRY")
  464. self.geometry_tab_lay = QtWidgets.QVBoxLayout()
  465. self.geometry_tab_lay.setContentsMargins(2, 2, 2, 2)
  466. self.geometry_tab.setLayout(self.geometry_tab_lay)
  467. self.geometry_scroll_area = VerticalScrollArea()
  468. self.geometry_tab_lay.addWidget(self.geometry_scroll_area)
  469. self.cncjob_tab = QtWidgets.QWidget()
  470. self.pref_tab_area.addTab(self.cncjob_tab, "CNC-JOB")
  471. self.cncjob_tab_lay = QtWidgets.QVBoxLayout()
  472. self.cncjob_tab_lay.setContentsMargins(2, 2, 2, 2)
  473. self.cncjob_tab.setLayout(self.cncjob_tab_lay)
  474. self.cncjob_scroll_area = VerticalScrollArea()
  475. self.cncjob_tab_lay.addWidget(self.cncjob_scroll_area)
  476. self.pref_tab_bottom_layout = QtWidgets.QHBoxLayout()
  477. self.pref_tab_bottom_layout.setAlignment(QtCore.Qt.AlignVCenter)
  478. self.pref_tab_layout.addLayout(self.pref_tab_bottom_layout)
  479. self.pref_tab_bottom_layout_1 = QtWidgets.QHBoxLayout()
  480. self.pref_tab_bottom_layout_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  481. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_1)
  482. self.pref_import_button = QtWidgets.QPushButton()
  483. self.pref_import_button.setText("Import Preferences")
  484. self.pref_import_button.setFixedWidth(130)
  485. self.pref_import_button.setToolTip(
  486. "Import a full set of FlatCAM settings from a file\n"
  487. "previously saved on HDD.\n\n"
  488. "FlatCAM automatically save a 'factory_defaults' file\n"
  489. "on the first start. Do not delete that file.")
  490. self.pref_tab_bottom_layout_1.addWidget(self.pref_import_button)
  491. self.pref_export_button = QtWidgets.QPushButton()
  492. self.pref_export_button.setText("Export Preferences")
  493. self.pref_export_button.setFixedWidth(130)
  494. self.pref_export_button.setToolTip(
  495. "Export a full set of FlatCAM settings in a file\n"
  496. "that is saved on HDD.")
  497. self.pref_tab_bottom_layout_1.addWidget(self.pref_export_button)
  498. self.pref_open_button = QtWidgets.QPushButton()
  499. self.pref_open_button.setText("Open Pref Folder")
  500. self.pref_open_button.setFixedWidth(130)
  501. self.pref_open_button.setToolTip(
  502. "Open the folder where FlatCAM save the preferences files.")
  503. self.pref_tab_bottom_layout_1.addWidget(self.pref_open_button)
  504. self.pref_tab_bottom_layout_2 = QtWidgets.QHBoxLayout()
  505. self.pref_tab_bottom_layout_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  506. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_2)
  507. self.pref_save_button = QtWidgets.QPushButton()
  508. self.pref_save_button.setText("Save Preferences")
  509. self.pref_save_button.setFixedWidth(130)
  510. self.pref_save_button.setToolTip(
  511. "Save the current settings in the 'current_defaults' file\n"
  512. "which is the file storing the working default preferences.")
  513. self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
  514. ##############################################################
  515. ### HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS ###
  516. ##############################################################
  517. self.popMenu = QtWidgets.QMenu()
  518. self.cmenu_newmenu = self.popMenu.addMenu(QtGui.QIcon('share/file32.png'), "New")
  519. self.popmenu_new_geo = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "Geo Obj")
  520. self.popmenu_new_exc = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_exc32.png'), "Exc. Obj")
  521. self.cmenu_newmenu.addSeparator()
  522. self.popmenu_new_prj = self.cmenu_newmenu.addAction(QtGui.QIcon('share/file16.png'), "Project")
  523. self.popMenu.addSeparator()
  524. self.cmenu_gridmenu = self.popMenu.addMenu(QtGui.QIcon('share/grid32_menu.png'), "Grids")
  525. self.gridmenu_1 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.05")
  526. self.gridmenu_2 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.10")
  527. self.gridmenu_3 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.20")
  528. self.gridmenu_4 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.50")
  529. self.gridmenu_5 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "1.00")
  530. self.cmenu_viewmenu = self.popMenu.addMenu(QtGui.QIcon('share/view64.png'), "View")
  531. self.zoomfit = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
  532. self.clearplot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/clear_plot32.png'), "Clear Plot")
  533. self.replot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/replot32.png'), "Replot")
  534. self.popMenu.addSeparator()
  535. self.g_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/draw32.png'), "Geo Editor")
  536. self.draw_line = self.g_editor_cmenu.addAction(QtGui.QIcon('share/path32.png'), "Line")
  537. self.draw_rect = self.g_editor_cmenu.addAction(QtGui.QIcon('share/rectangle32.png'), "Rectangle")
  538. self.draw_cut = self.g_editor_cmenu.addAction(QtGui.QIcon('share/cutpath32.png'), "Cut")
  539. self.e_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/drill32.png'), "Exc Editor")
  540. self.drill = self.e_editor_cmenu.addAction(QtGui.QIcon('share/drill32.png'), "Add Drill")
  541. self.drill_array = self.e_editor_cmenu.addAction(QtGui.QIcon('share/addarray32.png'), "Add Drill Array")
  542. self.drill_copy = self.e_editor_cmenu.addAction(QtGui.QIcon('share/copy32.png'), "Copy Drill(s)")
  543. self.popMenu.addSeparator()
  544. self.popmenu_copy = self.popMenu.addAction(QtGui.QIcon('share/copy32.png'), "Copy")
  545. self.popmenu_delete = self.popMenu.addAction(QtGui.QIcon('share/delete32.png'), "Delete")
  546. self.popmenu_edit = self.popMenu.addAction(QtGui.QIcon('share/edit32.png'), "Edit")
  547. self.popmenu_save = self.popMenu.addAction(QtGui.QIcon('share/floppy32.png'), "Save && Close Edit")
  548. self.popmenu_save.setVisible(False)
  549. self.popMenu.addSeparator()
  550. self.popmenu_move = self.popMenu.addAction(QtGui.QIcon('share/move32.png'), "Move")
  551. self.popmenu_properties = self.popMenu.addAction(QtGui.QIcon('share/properties32.png'), "Properties")
  552. ####################################
  553. ### Here we build the CNCJob Tab ###
  554. ####################################
  555. self.cncjob_tab = QtWidgets.QWidget()
  556. self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_tab)
  557. self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
  558. self.cncjob_tab.setLayout(self.cncjob_tab_layout)
  559. self.code_editor = QtWidgets.QTextEdit()
  560. stylesheet = """
  561. QTextEdit { selection-background-color:yellow;
  562. selection-color:black;
  563. }
  564. """
  565. self.code_editor.setStyleSheet(stylesheet)
  566. self.buttonPreview = QtWidgets.QPushButton('Print Preview')
  567. self.buttonPrint = QtWidgets.QPushButton('Print CNC Code')
  568. self.buttonFind = QtWidgets.QPushButton('Find in CNC Code')
  569. self.buttonFind.setFixedWidth(100)
  570. self.buttonPreview.setFixedWidth(100)
  571. self.entryFind = FCEntry()
  572. self.entryFind.setMaximumWidth(200)
  573. self.buttonReplace = QtWidgets.QPushButton('Replace With')
  574. self.buttonReplace.setFixedWidth(100)
  575. self.entryReplace = FCEntry()
  576. self.entryReplace.setMaximumWidth(200)
  577. self.sel_all_cb = QtWidgets.QCheckBox('All')
  578. self.sel_all_cb.setToolTip(
  579. "When checked it will replace all instances in the 'Find' box\n"
  580. "with the text in the 'Replace' box.."
  581. )
  582. self.buttonOpen = QtWidgets.QPushButton('Open CNC Code')
  583. self.buttonSave = QtWidgets.QPushButton('Save CNC Code')
  584. self.cncjob_tab_layout.addWidget(self.code_editor, 0, 0, 1, 5)
  585. cnc_tab_lay_1 = QtWidgets.QHBoxLayout()
  586. cnc_tab_lay_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  587. cnc_tab_lay_1.addWidget(self.buttonFind)
  588. cnc_tab_lay_1.addWidget(self.entryFind)
  589. cnc_tab_lay_1.addWidget(self.buttonReplace)
  590. cnc_tab_lay_1.addWidget(self.entryReplace)
  591. cnc_tab_lay_1.addWidget(self.sel_all_cb)
  592. self.cncjob_tab_layout.addLayout(cnc_tab_lay_1, 1, 0, 1, 1, QtCore.Qt.AlignLeft)
  593. cnc_tab_lay_3 = QtWidgets.QHBoxLayout()
  594. cnc_tab_lay_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  595. cnc_tab_lay_3.addWidget(self.buttonPreview)
  596. cnc_tab_lay_3.addWidget(self.buttonPrint)
  597. self.cncjob_tab_layout.addLayout(cnc_tab_lay_3, 2, 0, 1, 1, QtCore.Qt.AlignLeft)
  598. cnc_tab_lay_4 = QtWidgets.QHBoxLayout()
  599. cnc_tab_lay_4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  600. cnc_tab_lay_4.addWidget(self.buttonOpen)
  601. cnc_tab_lay_4.addWidget(self.buttonSave)
  602. self.cncjob_tab_layout.addLayout(cnc_tab_lay_4, 2, 4, 1, 1)
  603. ##################################
  604. ### Build InfoBar is done here ###
  605. ##################################
  606. self.infobar = self.statusBar()
  607. self.fcinfo = FlatCAMInfoBar()
  608. self.infobar.addWidget(self.fcinfo, stretch=1)
  609. self.rel_position_label = QtWidgets.QLabel(
  610. "<b>Dx</b>: 0.0000&nbsp;&nbsp; <b>Dy</b>: 0.0000&nbsp;&nbsp;&nbsp;&nbsp;")
  611. self.rel_position_label.setMinimumWidth(110)
  612. self.rel_position_label.setToolTip("Relative neasurement.\nReference is last click position")
  613. self.infobar.addWidget(self.rel_position_label)
  614. self.position_label = QtWidgets.QLabel(
  615. "&nbsp;&nbsp;&nbsp;&nbsp;<b>X</b>: 0.0000&nbsp;&nbsp; <b>Y</b>: 0.0000")
  616. self.position_label.setMinimumWidth(110)
  617. self.position_label.setToolTip("Absolute neasurement.\nReference is (X=0, Y= 0) position")
  618. self.infobar.addWidget(self.position_label)
  619. self.units_label = QtWidgets.QLabel("[in]")
  620. self.units_label.setMargin(2)
  621. self.infobar.addWidget(self.units_label)
  622. # disabled
  623. self.progress_bar = QtWidgets.QProgressBar()
  624. self.progress_bar.setMinimum(0)
  625. self.progress_bar.setMaximum(100)
  626. # infobar.addWidget(self.progress_bar)
  627. self.activity_view = FlatCAMActivityView()
  628. self.infobar.addWidget(self.activity_view)
  629. self.app_icon = QtGui.QIcon()
  630. self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16))
  631. self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24))
  632. self.app_icon.addFile('share/flatcam_icon32.png', QtCore.QSize(32, 32))
  633. self.app_icon.addFile('share/flatcam_icon48.png', QtCore.QSize(48, 48))
  634. self.app_icon.addFile('share/flatcam_icon128.png', QtCore.QSize(128, 128))
  635. self.app_icon.addFile('share/flatcam_icon256.png', QtCore.QSize(256, 256))
  636. self.setWindowIcon(self.app_icon)
  637. self.setGeometry(100, 100, 1024, 650)
  638. self.setWindowTitle('FlatCAM %s %s - %s' % (version, ('BETA' if beta else ''), platform.architecture()[0]))
  639. self.show()
  640. self.filename = ""
  641. self.setAcceptDrops(True)
  642. def dragEnterEvent(self, event):
  643. if event.mimeData().hasUrls:
  644. event.accept()
  645. else:
  646. event.ignore()
  647. def dragMoveEvent(self, event):
  648. if event.mimeData().hasUrls:
  649. event.accept()
  650. else:
  651. event.ignore()
  652. def dropEvent(self, event):
  653. if event.mimeData().hasUrls:
  654. event.setDropAction(QtCore.Qt.CopyAction)
  655. event.accept()
  656. for url in event.mimeData().urls():
  657. self.filename = str(url.toLocalFile())
  658. if self.filename == "":
  659. self.app.inform.emit("Open cancelled.")
  660. else:
  661. if self.filename.lower().rpartition('.')[-1] in self.app.grb_list:
  662. self.app.worker_task.emit({'fcn': self.app.open_gerber,
  663. 'params': [self.filename]})
  664. else:
  665. event.ignore()
  666. if self.filename.lower().rpartition('.')[-1] in self.app.exc_list:
  667. self.app.worker_task.emit({'fcn': self.app.open_excellon,
  668. 'params': [self.filename]})
  669. else:
  670. event.ignore()
  671. if self.filename.lower().rpartition('.')[-1] in self.app.gcode_list:
  672. self.app.worker_task.emit({'fcn': self.app.open_gcode,
  673. 'params': [self.filename]})
  674. else:
  675. event.ignore()
  676. if self.filename.lower().rpartition('.')[-1] in self.app.svg_list:
  677. object_type = 'geometry'
  678. self.app.worker_task.emit({'fcn': self.app.import_svg,
  679. 'params': [self.filename, object_type, None]})
  680. if self.filename.lower().rpartition('.')[-1] in self.app.dxf_list:
  681. object_type = 'geometry'
  682. self.app.worker_task.emit({'fcn': self.app.import_dxf,
  683. 'params': [self.filename, object_type, None]})
  684. if self.filename.lower().rpartition('.')[-1] in self.app.prj_list:
  685. # self.app.open_project() is not Thread Safe
  686. self.app.open_project(self.filename)
  687. else:
  688. event.ignore()
  689. else:
  690. event.ignore()
  691. def closeEvent(self, event):
  692. grect = self.geometry()
  693. # self.splitter.sizes()[0] is actually the size of the "notebook"
  694. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
  695. self.final_save.emit()
  696. QtWidgets.qApp.quit()
  697. class GeneralPreferencesUI(QtWidgets.QWidget):
  698. def __init__(self, parent=None):
  699. QtWidgets.QWidget.__init__(self, parent=parent)
  700. self.layout = QtWidgets.QVBoxLayout()
  701. self.setLayout(self.layout)
  702. self.general_group = GeneralPrefGroupUI()
  703. self.general_group.setFixedWidth(260)
  704. self.layout.addWidget(self.general_group)
  705. class GerberPreferencesUI(QtWidgets.QWidget):
  706. def __init__(self, parent=None):
  707. QtWidgets.QWidget.__init__(self, parent=parent)
  708. self.layout = QtWidgets.QVBoxLayout()
  709. self.setLayout(self.layout)
  710. self.gerber_group = GerberPrefGroupUI()
  711. self.gerber_group.setFixedWidth(260)
  712. self.layout.addWidget(self.gerber_group)
  713. class ExcellonPreferencesUI(QtWidgets.QWidget):
  714. def __init__(self, parent=None):
  715. QtWidgets.QWidget.__init__(self, parent=parent)
  716. self.layout = QtWidgets.QVBoxLayout()
  717. self.setLayout(self.layout)
  718. self.excellon_group = ExcellonPrefGroupUI()
  719. self.excellon_group.setFixedWidth(260)
  720. self.layout.addWidget(self.excellon_group)
  721. class GeometryPreferencesUI(QtWidgets.QWidget):
  722. def __init__(self, parent=None):
  723. QtWidgets.QWidget.__init__(self, parent=parent)
  724. self.layout = QtWidgets.QVBoxLayout()
  725. self.setLayout(self.layout)
  726. self.geometry_group = GeometryPrefGroupUI()
  727. self.geometry_group.setFixedWidth(260)
  728. self.layout.addWidget(self.geometry_group)
  729. class CNCJobPreferencesUI(QtWidgets.QWidget):
  730. def __init__(self, parent=None):
  731. QtWidgets.QWidget.__init__(self, parent=parent)
  732. self.layout = QtWidgets.QVBoxLayout()
  733. self.setLayout(self.layout)
  734. self.cncjob_group = CNCJobPrefGroupUI()
  735. self.cncjob_group.setFixedWidth(260)
  736. self.layout.addWidget(self.cncjob_group)
  737. class OptionsGroupUI(QtWidgets.QGroupBox):
  738. def __init__(self, title, parent=None):
  739. # QtGui.QGroupBox.__init__(self, title, parent=parent)
  740. super(OptionsGroupUI, self).__init__()
  741. self.setStyleSheet("""
  742. QGroupBox
  743. {
  744. font-size: 16px;
  745. font-weight: bold;
  746. }
  747. """)
  748. self.layout = QtWidgets.QVBoxLayout()
  749. self.setLayout(self.layout)
  750. class GeneralPrefGroupUI(OptionsGroupUI):
  751. def __init__(self, parent=None):
  752. super(GeneralPrefGroupUI, self).__init__(self)
  753. self.setTitle(str("Global Preferences"))
  754. # Create a form layout for the Application general settings
  755. self.form_box = QtWidgets.QFormLayout()
  756. # Units for FlatCAM
  757. self.unitslabel = QtWidgets.QLabel('<b>Units:</b>')
  758. self.unitslabel.setToolTip("Those are units in which FlatCAM works.")
  759. self.units_radio = RadioSet([{'label': 'IN', 'value': 'IN'},
  760. {'label': 'MM', 'value': 'MM'}])
  761. # Shell StartUp CB
  762. self.shell_startup_label = QtWidgets.QLabel('Shell at StartUp:')
  763. self.shell_startup_label.setToolTip(
  764. "Check this box if you want the shell to\n"
  765. "start automatically at startup."
  766. )
  767. self.shell_startup_cb = FCCheckBox(label='')
  768. self.shell_startup_cb.setToolTip(
  769. "Check this box if you want the shell to\n"
  770. "start automatically at startup."
  771. )
  772. # Version Check CB
  773. self.version_check_label = QtWidgets.QLabel('Version Check:')
  774. self.version_check_label.setToolTip(
  775. "Check this box if you want to check\n"
  776. "for a new version automatically at startup."
  777. )
  778. self.version_check_cb = FCCheckBox(label='')
  779. self.version_check_cb.setToolTip(
  780. "Check this box if you want to check\n"
  781. "for a new version automatically at startup."
  782. )
  783. # Send Stats CB
  784. self.send_stats_label = QtWidgets.QLabel('Send Stats:')
  785. self.send_stats_label.setToolTip(
  786. "Check this box if you agree to send anonymous\n"
  787. "stats automatically at startup, to help improve FlatCAM."
  788. )
  789. self.send_stats_cb= FCCheckBox(label='')
  790. self.send_stats_cb.setToolTip(
  791. "Check this box if you agree to send anonymous\n"
  792. "stats automatically at startup, to help improve FlatCAM."
  793. )
  794. self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
  795. # Grid X Entry
  796. self.gridx_label = QtWidgets.QLabel('Grid X value:')
  797. self.gridx_label.setToolTip(
  798. "This is the Grid value on X axis\n"
  799. )
  800. self.gridx_entry = LengthEntry()
  801. # Grid Y Entry
  802. self.gridy_label = QtWidgets.QLabel('Grid Y value:')
  803. self.gridy_label.setToolTip(
  804. "This is the Grid value on Y axis\n"
  805. )
  806. self.gridy_entry = LengthEntry()
  807. # Select mouse pan button
  808. self.panbuttonlabel = QtWidgets.QLabel('<b>Pan Button:</b>')
  809. self.panbuttonlabel.setToolTip("Select the mouse button to use for panning.")
  810. self.pan_button_radio = RadioSet([{'label': 'Middle But.', 'value': '3'},
  811. {'label': 'Right But.', 'value': '2'}])
  812. # Multiple Selection Modifier Key
  813. self.mselectlabel = QtWidgets.QLabel('<b>Multiple Sel:</b>')
  814. self.mselectlabel.setToolTip("Select the key used for multiple selection.")
  815. self.mselect_radio = RadioSet([{'label': 'CTRL', 'value': 'Control'},
  816. {'label': 'SHIFT', 'value': 'Shift'}])
  817. # # Mouse panning with "Space" key, CB
  818. # self.pan_with_space_label = QtWidgets.QLabel('Pan w/ Space:')
  819. # self.pan_with_space_label.setToolTip(
  820. # "Check this box if you want to pan when mouse is moved,\n"
  821. # "and key 'Space' is pressed."
  822. # )
  823. # self.pan_with_space_cb = FCCheckBox(label='')
  824. # self.pan_with_space_cb.setToolTip(
  825. # "Check this box if you want to pan when mouse is moved,\n"
  826. # "and key 'Space' is pressed."
  827. # )
  828. # Workspace
  829. self.workspace_lbl = QtWidgets.QLabel('Workspace:')
  830. self.workspace_lbl.setToolTip(
  831. "Draw a delimiting rectangle on canvas.\n"
  832. "The purpose is to illustrate the limits for our work."
  833. )
  834. self.workspace_type_lbl = QtWidgets.QLabel('Wk. format:')
  835. self.workspace_type_lbl.setToolTip(
  836. "Select the type of rectangle to be used on canvas,\n"
  837. "as valid workspace."
  838. )
  839. self.workspace_cb = FCCheckBox()
  840. self.wk_cb = FCComboBox()
  841. self.wk_cb.addItem('A4P')
  842. self.wk_cb.addItem('A4L')
  843. self.wk_cb.addItem('A3P')
  844. self.wk_cb.addItem('A3L')
  845. self.wks = OptionalInputSection(self.workspace_cb, [self.workspace_type_lbl, self.wk_cb])
  846. # Plot Fill Color
  847. self.pf_color_label = QtWidgets.QLabel('Plot Fill:')
  848. self.pf_color_label.setToolTip(
  849. "Set the fill color for plotted objects.\n"
  850. "First 6 digits are the color and the last 2\n"
  851. "digits are for alpha (transparency) level."
  852. )
  853. self.pf_color_entry = FCEntry()
  854. self.pf_color_button = QtWidgets.QPushButton()
  855. self.pf_color_button.setFixedSize(15, 15)
  856. self.form_box_child_1 = QtWidgets.QHBoxLayout()
  857. self.form_box_child_1.addWidget(self.pf_color_entry)
  858. self.form_box_child_1.addWidget(self.pf_color_button)
  859. self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  860. # Plot Fill Transparency Level
  861. self.pf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  862. self.pf_alpha_label.setToolTip(
  863. "Set the fill transparency for plotted objects."
  864. )
  865. self.pf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  866. self.pf_color_alpha_slider.setMinimum(0)
  867. self.pf_color_alpha_slider.setMaximum(255)
  868. self.pf_color_alpha_slider.setSingleStep(1)
  869. self.pf_color_alpha_spinner = FCSpinner()
  870. self.pf_color_alpha_spinner.setFixedWidth(70)
  871. self.pf_color_alpha_spinner.setMinimum(0)
  872. self.pf_color_alpha_spinner.setMaximum(255)
  873. self.form_box_child_2 = QtWidgets.QHBoxLayout()
  874. self.form_box_child_2.addWidget(self.pf_color_alpha_slider)
  875. self.form_box_child_2.addWidget(self.pf_color_alpha_spinner)
  876. # Plot Line Color
  877. self.pl_color_label = QtWidgets.QLabel('Plot Line:')
  878. self.pl_color_label.setToolTip(
  879. "Set the line color for plotted objects."
  880. )
  881. self.pl_color_entry = FCEntry()
  882. self.pl_color_button = QtWidgets.QPushButton()
  883. self.pl_color_button.setFixedSize(15, 15)
  884. self.form_box_child_3 = QtWidgets.QHBoxLayout()
  885. self.form_box_child_3.addWidget(self.pl_color_entry)
  886. self.form_box_child_3.addWidget(self.pl_color_button)
  887. self.form_box_child_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  888. # Plot Selection (left - right) Fill Color
  889. self.sf_color_label = QtWidgets.QLabel('Sel. Fill:')
  890. self.sf_color_label.setToolTip(
  891. "Set the fill color for the selection box\n"
  892. "in case that the selection is done from left to right.\n"
  893. "First 6 digits are the color and the last 2\n"
  894. "digits are for alpha (transparency) level."
  895. )
  896. self.sf_color_entry = FCEntry()
  897. self.sf_color_button = QtWidgets.QPushButton()
  898. self.sf_color_button.setFixedSize(15, 15)
  899. self.form_box_child_4 = QtWidgets.QHBoxLayout()
  900. self.form_box_child_4.addWidget(self.sf_color_entry)
  901. self.form_box_child_4.addWidget(self.sf_color_button)
  902. self.form_box_child_4.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  903. # Plot Selection (left - right) Fill Transparency Level
  904. self.sf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  905. self.sf_alpha_label.setToolTip(
  906. "Set the fill transparency for the 'left to right' selection box."
  907. )
  908. self.sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  909. self.sf_color_alpha_slider.setMinimum(0)
  910. self.sf_color_alpha_slider.setMaximum(255)
  911. self.sf_color_alpha_slider.setSingleStep(1)
  912. self.sf_color_alpha_spinner = FCSpinner()
  913. self.sf_color_alpha_spinner.setFixedWidth(70)
  914. self.sf_color_alpha_spinner.setMinimum(0)
  915. self.sf_color_alpha_spinner.setMaximum(255)
  916. self.form_box_child_5 = QtWidgets.QHBoxLayout()
  917. self.form_box_child_5.addWidget(self.sf_color_alpha_slider)
  918. self.form_box_child_5.addWidget(self.sf_color_alpha_spinner)
  919. # Plot Selection (left - right) Line Color
  920. self.sl_color_label = QtWidgets.QLabel('Sel. Line:')
  921. self.sl_color_label.setToolTip(
  922. "Set the line color for the 'left to right' selection box."
  923. )
  924. self.sl_color_entry = FCEntry()
  925. self.sl_color_button = QtWidgets.QPushButton()
  926. self.sl_color_button.setFixedSize(15, 15)
  927. self.form_box_child_6 = QtWidgets.QHBoxLayout()
  928. self.form_box_child_6.addWidget(self.sl_color_entry)
  929. self.form_box_child_6.addWidget(self.sl_color_button)
  930. self.form_box_child_6.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  931. # Plot Selection (right - left) Fill Color
  932. self.alt_sf_color_label = QtWidgets.QLabel('Sel2. Fill:')
  933. self.alt_sf_color_label.setToolTip(
  934. "Set the fill color for the selection box\n"
  935. "in case that the selection is done from right to left.\n"
  936. "First 6 digits are the color and the last 2\n"
  937. "digits are for alpha (transparency) level."
  938. )
  939. self.alt_sf_color_entry = FCEntry()
  940. self.alt_sf_color_button = QtWidgets.QPushButton()
  941. self.alt_sf_color_button.setFixedSize(15, 15)
  942. self.form_box_child_7 = QtWidgets.QHBoxLayout()
  943. self.form_box_child_7.addWidget(self.alt_sf_color_entry)
  944. self.form_box_child_7.addWidget(self.alt_sf_color_button)
  945. self.form_box_child_7.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  946. # Plot Selection (right - left) Fill Transparency Level
  947. self.alt_sf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  948. self.alt_sf_alpha_label.setToolTip(
  949. "Set the fill transparency for selection 'right to left' box."
  950. )
  951. self.alt_sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  952. self.alt_sf_color_alpha_slider.setMinimum(0)
  953. self.alt_sf_color_alpha_slider.setMaximum(255)
  954. self.alt_sf_color_alpha_slider.setSingleStep(1)
  955. self.alt_sf_color_alpha_spinner = FCSpinner()
  956. self.alt_sf_color_alpha_spinner.setFixedWidth(70)
  957. self.alt_sf_color_alpha_spinner.setMinimum(0)
  958. self.alt_sf_color_alpha_spinner.setMaximum(255)
  959. self.form_box_child_8 = QtWidgets.QHBoxLayout()
  960. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_slider)
  961. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_spinner)
  962. # Plot Selection (right - left) Line Color
  963. self.alt_sl_color_label = QtWidgets.QLabel('Sel2. Line:')
  964. self.alt_sl_color_label.setToolTip(
  965. "Set the line color for the 'right to left' selection box."
  966. )
  967. self.alt_sl_color_entry = FCEntry()
  968. self.alt_sl_color_button = QtWidgets.QPushButton()
  969. self.alt_sl_color_button.setFixedSize(15, 15)
  970. self.form_box_child_9 = QtWidgets.QHBoxLayout()
  971. self.form_box_child_9.addWidget(self.alt_sl_color_entry)
  972. self.form_box_child_9.addWidget(self.alt_sl_color_button)
  973. self.form_box_child_9.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  974. # Editor Draw Color
  975. self.draw_color_label = QtWidgets.QLabel('Editor Draw:')
  976. self.alt_sf_color_label.setToolTip(
  977. "Set the color for the shape."
  978. )
  979. self.draw_color_entry = FCEntry()
  980. self.draw_color_button = QtWidgets.QPushButton()
  981. self.draw_color_button.setFixedSize(15, 15)
  982. self.form_box_child_10 = QtWidgets.QHBoxLayout()
  983. self.form_box_child_10.addWidget(self.draw_color_entry)
  984. self.form_box_child_10.addWidget(self.draw_color_button)
  985. self.form_box_child_10.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  986. # Editor Draw Selection Color
  987. self.sel_draw_color_label = QtWidgets.QLabel('Editor Draw Sel.:')
  988. self.sel_draw_color_label.setToolTip(
  989. "Set the color of the shape when selected."
  990. )
  991. self.sel_draw_color_entry = FCEntry()
  992. self.sel_draw_color_button = QtWidgets.QPushButton()
  993. self.sel_draw_color_button.setFixedSize(15, 15)
  994. self.form_box_child_11 = QtWidgets.QHBoxLayout()
  995. self.form_box_child_11.addWidget(self.sel_draw_color_entry)
  996. self.form_box_child_11.addWidget(self.sel_draw_color_button)
  997. self.form_box_child_11.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  998. # Just to add empty rows
  999. self.spacelabel = QtWidgets.QLabel('')
  1000. # Add (label - input field) pair to the QFormLayout
  1001. self.form_box.addRow(self.unitslabel, self.units_radio)
  1002. self.form_box.addRow(self.spacelabel, self.spacelabel)
  1003. self.form_box.addRow(self.shell_startup_label, self.shell_startup_cb)
  1004. self.form_box.addRow(self.version_check_label, self.version_check_cb)
  1005. self.form_box.addRow(self.send_stats_label, self.send_stats_cb)
  1006. self.form_box.addRow(self.gridx_label, self.gridx_entry)
  1007. self.form_box.addRow(self.gridy_label, self.gridy_entry)
  1008. self.form_box.addRow(self.panbuttonlabel, self.pan_button_radio)
  1009. self.form_box.addRow(self.mselectlabel, self.mselect_radio)
  1010. # self.form_box.addRow(self.pan_with_space_label, self.pan_with_space_cb)
  1011. self.form_box.addRow(self.workspace_lbl, self.workspace_cb)
  1012. self.form_box.addRow(self.workspace_type_lbl, self.wk_cb)
  1013. self.form_box.addRow(self.spacelabel, self.spacelabel)
  1014. self.form_box.addRow(self.pf_color_label, self.form_box_child_1)
  1015. self.form_box.addRow(self.pf_alpha_label, self.form_box_child_2)
  1016. self.form_box.addRow(self.pl_color_label, self.form_box_child_3)
  1017. self.form_box.addRow(self.sf_color_label, self.form_box_child_4)
  1018. self.form_box.addRow(self.sf_alpha_label, self.form_box_child_5)
  1019. self.form_box.addRow(self.sl_color_label, self.form_box_child_6)
  1020. self.form_box.addRow(self.alt_sf_color_label, self.form_box_child_7)
  1021. self.form_box.addRow(self.alt_sf_alpha_label, self.form_box_child_8)
  1022. self.form_box.addRow(self.alt_sl_color_label, self.form_box_child_9)
  1023. self.form_box.addRow(self.draw_color_label, self.form_box_child_10)
  1024. self.form_box.addRow(self.sel_draw_color_label, self.form_box_child_11)
  1025. # Add the QFormLayout that holds the Application general defaults
  1026. # to the main layout of this TAB
  1027. self.layout.addLayout(self.form_box)
  1028. class GerberPrefGroupUI(OptionsGroupUI):
  1029. def __init__(self, parent=None):
  1030. # OptionsGroupUI.__init__(self, "Gerber Options", parent=parent)
  1031. super(GerberPrefGroupUI, self).__init__(self)
  1032. self.setTitle(str("Gerber Options"))
  1033. ## Plot options
  1034. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1035. self.layout.addWidget(self.plot_options_label)
  1036. grid0 = QtWidgets.QGridLayout()
  1037. self.layout.addLayout(grid0)
  1038. # Plot CB
  1039. self.plot_cb = FCCheckBox(label='Plot')
  1040. self.plot_options_label.setToolTip(
  1041. "Plot (show) this object."
  1042. )
  1043. grid0.addWidget(self.plot_cb, 0, 0)
  1044. # Solid CB
  1045. self.solid_cb = FCCheckBox(label='Solid')
  1046. self.solid_cb.setToolTip(
  1047. "Solid color polygons."
  1048. )
  1049. grid0.addWidget(self.solid_cb, 0, 1)
  1050. # Multicolored CB
  1051. self.multicolored_cb = FCCheckBox(label='Multicolored')
  1052. self.multicolored_cb.setToolTip(
  1053. "Draw polygons in different colors."
  1054. )
  1055. grid0.addWidget(self.multicolored_cb, 0, 2)
  1056. # Number of circle steps for circular aperture linear approximation
  1057. self.circle_steps_label = QtWidgets.QLabel("Circle Steps:")
  1058. self.circle_steps_label.setToolTip(
  1059. "The number of circle steps for Gerber \n"
  1060. "circular aperture linear approximation."
  1061. )
  1062. grid0.addWidget(self.circle_steps_label, 1, 0)
  1063. self.circle_steps_entry = IntEntry()
  1064. grid0.addWidget(self.circle_steps_entry, 1, 1)
  1065. ## Isolation Routing
  1066. self.isolation_routing_label = QtWidgets.QLabel("<b>Isolation Routing:</b>")
  1067. self.isolation_routing_label.setToolTip(
  1068. "Create a Geometry object with\n"
  1069. "toolpaths to cut outside polygons."
  1070. )
  1071. self.layout.addWidget(self.isolation_routing_label)
  1072. # Cutting Tool Diameter
  1073. grid1 = QtWidgets.QGridLayout()
  1074. self.layout.addLayout(grid1)
  1075. tdlabel = QtWidgets.QLabel('Tool dia:')
  1076. tdlabel.setToolTip(
  1077. "Diameter of the cutting tool."
  1078. )
  1079. grid1.addWidget(tdlabel, 0, 0)
  1080. self.iso_tool_dia_entry = LengthEntry()
  1081. grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
  1082. # Nr of passes
  1083. passlabel = QtWidgets.QLabel('Width (# passes):')
  1084. passlabel.setToolTip(
  1085. "Width of the isolation gap in\n"
  1086. "number (integer) of tool widths."
  1087. )
  1088. grid1.addWidget(passlabel, 1, 0)
  1089. self.iso_width_entry = IntEntry()
  1090. grid1.addWidget(self.iso_width_entry, 1, 1)
  1091. # Pass overlap
  1092. overlabel = QtWidgets.QLabel('Pass overlap:')
  1093. overlabel.setToolTip(
  1094. "How much (fraction) of the tool width to overlap each tool pass.\n"
  1095. "Example:\n"
  1096. "A value here of 0.25 means an overlap of 25% from the tool diameter found above."
  1097. )
  1098. grid1.addWidget(overlabel, 2, 0)
  1099. self.iso_overlap_entry = FloatEntry()
  1100. grid1.addWidget(self.iso_overlap_entry, 2, 1)
  1101. milling_type_label = QtWidgets.QLabel('Milling Type:')
  1102. milling_type_label.setToolTip(
  1103. "Milling type:\n"
  1104. "- climb / best for precision milling and to reduce tool usage\n"
  1105. "- conventional / useful when there is no backlash compensation"
  1106. )
  1107. grid1.addWidget(milling_type_label, 3, 0)
  1108. self.milling_type_radio = RadioSet([{'label': 'Climb', 'value': 'cl'},
  1109. {'label': 'Conv.', 'value': 'cv'}])
  1110. grid1.addWidget(self.milling_type_radio, 3, 1)
  1111. # Combine passes
  1112. self.combine_passes_cb = FCCheckBox(label='Combine Passes')
  1113. self.combine_passes_cb.setToolTip(
  1114. "Combine all passes into one object"
  1115. )
  1116. grid1.addWidget(self.combine_passes_cb, 4, 0)
  1117. ## Clear non-copper regions
  1118. self.clearcopper_label = QtWidgets.QLabel("<b>Clear non-copper:</b>")
  1119. self.clearcopper_label.setToolTip(
  1120. "Create a Geometry object with\n"
  1121. "toolpaths to cut all non-copper regions."
  1122. )
  1123. self.layout.addWidget(self.clearcopper_label)
  1124. grid5 = QtWidgets.QGridLayout()
  1125. self.layout.addLayout(grid5)
  1126. ncctdlabel = QtWidgets.QLabel('Tools dia:')
  1127. ncctdlabel.setToolTip(
  1128. "Diameters of the cutting tools, separated by ','"
  1129. )
  1130. grid5.addWidget(ncctdlabel, 0, 0)
  1131. self.ncc_tool_dia_entry = FCEntry()
  1132. grid5.addWidget(self.ncc_tool_dia_entry, 0, 1)
  1133. nccoverlabel = QtWidgets.QLabel('Overlap:')
  1134. nccoverlabel.setToolTip(
  1135. "How much (fraction) of the tool width to overlap each tool pass.\n"
  1136. "Example:\n"
  1137. "A value here of 0.25 means 25% from the tool diameter found above.\n\n"
  1138. "Adjust the value starting with lower values\n"
  1139. "and increasing it if areas that should be cleared are still \n"
  1140. "not cleared.\n"
  1141. "Lower values = faster processing, faster execution on PCB.\n"
  1142. "Higher values = slow processing and slow execution on CNC\n"
  1143. "due of too many paths."
  1144. )
  1145. grid5.addWidget(nccoverlabel, 1, 0)
  1146. self.ncc_overlap_entry = FloatEntry()
  1147. grid5.addWidget(self.ncc_overlap_entry, 1, 1)
  1148. nccmarginlabel = QtWidgets.QLabel('Margin:')
  1149. nccmarginlabel.setToolTip(
  1150. "Bounding box margin."
  1151. )
  1152. grid5.addWidget(nccmarginlabel, 2, 0)
  1153. self.ncc_margin_entry = FloatEntry()
  1154. grid5.addWidget(self.ncc_margin_entry, 2, 1)
  1155. # Method
  1156. methodlabel = QtWidgets.QLabel('Method:')
  1157. methodlabel.setToolTip(
  1158. "Algorithm for non-copper clearing:<BR>"
  1159. "<B>Standard</B>: Fixed step inwards.<BR>"
  1160. "<B>Seed-based</B>: Outwards from seed.<BR>"
  1161. "<B>Line-based</B>: Parallel lines."
  1162. )
  1163. grid5.addWidget(methodlabel, 3, 0)
  1164. self.ncc_method_radio = RadioSet([
  1165. {"label": "Standard", "value": "standard"},
  1166. {"label": "Seed-based", "value": "seed"},
  1167. {"label": "Straight lines", "value": "lines"}
  1168. ], orientation='vertical', stretch=False)
  1169. grid5.addWidget(self.ncc_method_radio, 3, 1)
  1170. # Connect lines
  1171. pathconnectlabel = QtWidgets.QLabel("Connect:")
  1172. pathconnectlabel.setToolTip(
  1173. "Draw lines between resulting\n"
  1174. "segments to minimize tool lifts."
  1175. )
  1176. grid5.addWidget(pathconnectlabel, 4, 0)
  1177. self.ncc_connect_cb = FCCheckBox()
  1178. grid5.addWidget(self.ncc_connect_cb, 4, 1)
  1179. contourlabel = QtWidgets.QLabel("Contour:")
  1180. contourlabel.setToolTip(
  1181. "Cut around the perimeter of the polygon\n"
  1182. "to trim rough edges."
  1183. )
  1184. grid5.addWidget(contourlabel, 5, 0)
  1185. self.ncc_contour_cb = FCCheckBox()
  1186. grid5.addWidget(self.ncc_contour_cb, 5, 1)
  1187. restlabel = QtWidgets.QLabel("Rest M.:")
  1188. restlabel.setToolTip(
  1189. "If checked, use 'rest machining'.\n"
  1190. "Basically it will clear copper outside PCB features,\n"
  1191. "using the biggest tool and continue with the next tools,\n"
  1192. "from bigger to smaller, to clear areas of copper that\n"
  1193. "could not be cleared by previous tool.\n"
  1194. "If not checked, use the standard algorithm."
  1195. )
  1196. grid5.addWidget(restlabel, 6, 0)
  1197. self.ncc_rest_cb = FCCheckBox()
  1198. grid5.addWidget(self.ncc_rest_cb, 6, 1)
  1199. ## Board cuttout
  1200. self.board_cutout_label = QtWidgets.QLabel("<b>Board cutout:</b>")
  1201. self.board_cutout_label.setToolTip(
  1202. "Create toolpaths to cut around\n"
  1203. "the PCB and separate it from\n"
  1204. "the original board."
  1205. )
  1206. self.layout.addWidget(self.board_cutout_label)
  1207. grid2 = QtWidgets.QGridLayout()
  1208. self.layout.addLayout(grid2)
  1209. tdclabel = QtWidgets.QLabel('Tool dia:')
  1210. tdclabel.setToolTip(
  1211. "Diameter of the cutting tool."
  1212. )
  1213. grid2.addWidget(tdclabel, 0, 0)
  1214. self.cutout_tooldia_entry = LengthEntry()
  1215. grid2.addWidget(self.cutout_tooldia_entry, 0, 1)
  1216. marginlabel = QtWidgets.QLabel('Margin:')
  1217. marginlabel.setToolTip(
  1218. "Distance from objects at which\n"
  1219. "to draw the cutout."
  1220. )
  1221. grid2.addWidget(marginlabel, 1, 0)
  1222. self.cutout_margin_entry = LengthEntry()
  1223. grid2.addWidget(self.cutout_margin_entry, 1, 1)
  1224. gaplabel = QtWidgets.QLabel('Gap size:')
  1225. gaplabel.setToolTip(
  1226. "Size of the gaps in the toolpath\n"
  1227. "that will remain to hold the\n"
  1228. "board in place."
  1229. )
  1230. grid2.addWidget(gaplabel, 2, 0)
  1231. self.cutout_gap_entry = LengthEntry()
  1232. grid2.addWidget(self.cutout_gap_entry, 2, 1)
  1233. gapslabel = QtWidgets.QLabel('Gaps:')
  1234. gapslabel.setToolTip(
  1235. "Where to place the gaps, Top/Bottom\n"
  1236. "Left/Rigt, or on all 4 sides."
  1237. )
  1238. grid2.addWidget(gapslabel, 3, 0)
  1239. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  1240. {'label': '2 (L/R)', 'value': 'lr'},
  1241. {'label': '4', 'value': '4'}])
  1242. grid2.addWidget(self.gaps_radio, 3, 1)
  1243. ## Non-copper regions
  1244. self.noncopper_label = QtWidgets.QLabel("<b>Non-copper regions:</b>")
  1245. self.noncopper_label.setToolTip(
  1246. "Create polygons covering the\n"
  1247. "areas without copper on the PCB.\n"
  1248. "Equivalent to the inverse of this\n"
  1249. "object. Can be used to remove all\n"
  1250. "copper from a specified region."
  1251. )
  1252. self.layout.addWidget(self.noncopper_label)
  1253. grid3 = QtWidgets.QGridLayout()
  1254. self.layout.addLayout(grid3)
  1255. # Margin
  1256. bmlabel = QtWidgets.QLabel('Boundary Margin:')
  1257. bmlabel.setToolTip(
  1258. "Specify the edge of the PCB\n"
  1259. "by drawing a box around all\n"
  1260. "objects with this minimum\n"
  1261. "distance."
  1262. )
  1263. grid3.addWidget(bmlabel, 0, 0)
  1264. self.noncopper_margin_entry = LengthEntry()
  1265. grid3.addWidget(self.noncopper_margin_entry, 0, 1)
  1266. # Rounded corners
  1267. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  1268. self.noncopper_rounded_cb.setToolTip(
  1269. "Creates a Geometry objects with polygons\n"
  1270. "covering the copper-free areas of the PCB."
  1271. )
  1272. grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  1273. ## Bounding box
  1274. self.boundingbox_label = QtWidgets.QLabel('<b>Bounding Box:</b>')
  1275. self.layout.addWidget(self.boundingbox_label)
  1276. grid4 = QtWidgets.QGridLayout()
  1277. self.layout.addLayout(grid4)
  1278. bbmargin = QtWidgets.QLabel('Boundary Margin:')
  1279. bbmargin.setToolTip(
  1280. "Distance of the edges of the box\n"
  1281. "to the nearest polygon."
  1282. )
  1283. grid4.addWidget(bbmargin, 0, 0)
  1284. self.bbmargin_entry = LengthEntry()
  1285. grid4.addWidget(self.bbmargin_entry, 0, 1)
  1286. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  1287. self.bbrounded_cb.setToolTip(
  1288. "If the bounding box is \n"
  1289. "to have rounded corners\n"
  1290. "their radius is equal to\n"
  1291. "the margin."
  1292. )
  1293. grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  1294. self.layout.addStretch()
  1295. class ExcellonPrefGroupUI(OptionsGroupUI):
  1296. def __init__(self, parent=None):
  1297. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  1298. super(ExcellonPrefGroupUI, self).__init__(self)
  1299. self.setTitle(str("Excellon Options"))
  1300. # Plot options
  1301. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1302. self.layout.addWidget(self.plot_options_label)
  1303. grid1 = QtWidgets.QGridLayout()
  1304. self.layout.addLayout(grid1)
  1305. self.plot_cb = FCCheckBox(label='Plot')
  1306. self.plot_cb.setToolTip(
  1307. "Plot (show) this object."
  1308. )
  1309. grid1.addWidget(self.plot_cb, 0, 0)
  1310. self.solid_cb = FCCheckBox(label='Solid')
  1311. self.solid_cb.setToolTip(
  1312. "Plot as solid circles."
  1313. )
  1314. grid1.addWidget(self.solid_cb, 0, 1)
  1315. # Excellon format
  1316. self.excellon_format_label = QtWidgets.QLabel("<b>Excellon Format:</b>")
  1317. self.excellon_format_label.setToolTip(
  1318. "The NC drill files, usually named Excellon files\n"
  1319. "are files that can be found in different formats.\n"
  1320. "Here we set the format used when the provided\n"
  1321. "coordinates are not using period.\n"
  1322. "\n"
  1323. "Possible presets:\n"
  1324. "\n"
  1325. "PROTEUS 3:3 MM LZ\n"
  1326. "DipTrace 5:2 MM TZ\n"
  1327. "DipTrace 4:3 MM LZ\n"
  1328. "\n"
  1329. "EAGLE 3:3 MM TZ\n"
  1330. "EAGLE 4:3 MM TZ\n"
  1331. "EAGLE 2:5 INCH TZ\n"
  1332. "EAGLE 3:5 INCH TZ\n"
  1333. "\n"
  1334. "ALTIUM 2:4 INCH LZ\n"
  1335. "Sprint Layout 2:4 INCH LZ"
  1336. "\n"
  1337. "KiCAD 3:5 INCH TZ"
  1338. )
  1339. self.layout.addWidget(self.excellon_format_label)
  1340. hlay1 = QtWidgets.QHBoxLayout()
  1341. self.layout.addLayout(hlay1)
  1342. self.excellon_format_in_label = QtWidgets.QLabel("INCH:")
  1343. self.excellon_format_in_label.setAlignment(QtCore.Qt.AlignLeft)
  1344. self.excellon_format_in_label.setToolTip(
  1345. "Default values for INCH are 2:4")
  1346. hlay1.addWidget(self.excellon_format_in_label, QtCore.Qt.AlignLeft)
  1347. self.excellon_format_upper_in_entry = IntEntry()
  1348. self.excellon_format_upper_in_entry.setMaxLength(1)
  1349. self.excellon_format_upper_in_entry.setAlignment(QtCore.Qt.AlignRight)
  1350. self.excellon_format_upper_in_entry.setFixedWidth(30)
  1351. self.excellon_format_upper_in_entry.setToolTip(
  1352. "This numbers signify the number of digits in\n"
  1353. "the whole part of Excellon coordinates."
  1354. )
  1355. hlay1.addWidget(self.excellon_format_upper_in_entry, QtCore.Qt.AlignLeft)
  1356. excellon_separator_in_label= QtWidgets.QLabel(':')
  1357. excellon_separator_in_label.setFixedWidth(5)
  1358. hlay1.addWidget(excellon_separator_in_label, QtCore.Qt.AlignLeft)
  1359. self.excellon_format_lower_in_entry = IntEntry()
  1360. self.excellon_format_lower_in_entry.setMaxLength(1)
  1361. self.excellon_format_lower_in_entry.setAlignment(QtCore.Qt.AlignRight)
  1362. self.excellon_format_lower_in_entry.setFixedWidth(30)
  1363. self.excellon_format_lower_in_entry.setToolTip(
  1364. "This numbers signify the number of digits in\n"
  1365. "the decimal part of Excellon coordinates."
  1366. )
  1367. hlay1.addWidget(self.excellon_format_lower_in_entry, QtCore.Qt.AlignLeft)
  1368. hlay1.addStretch()
  1369. hlay2 = QtWidgets.QHBoxLayout()
  1370. self.layout.addLayout(hlay2)
  1371. self.excellon_format_mm_label = QtWidgets.QLabel("METRIC:")
  1372. self.excellon_format_mm_label.setAlignment(QtCore.Qt.AlignLeft)
  1373. self.excellon_format_mm_label.setToolTip(
  1374. "Default values for METRIC are 3:3")
  1375. hlay2.addWidget(self.excellon_format_mm_label, QtCore.Qt.AlignLeft)
  1376. self.excellon_format_upper_mm_entry = IntEntry()
  1377. self.excellon_format_upper_mm_entry.setMaxLength(1)
  1378. self.excellon_format_upper_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  1379. self.excellon_format_upper_mm_entry.setFixedWidth(30)
  1380. self.excellon_format_upper_mm_entry.setToolTip(
  1381. "This numbers signify the number of digits in\n"
  1382. "the whole part of Excellon coordinates."
  1383. )
  1384. hlay2.addWidget(self.excellon_format_upper_mm_entry, QtCore.Qt.AlignLeft)
  1385. excellon_separator_mm_label= QtWidgets.QLabel(':')
  1386. excellon_separator_mm_label.setFixedWidth(5)
  1387. hlay2.addWidget(excellon_separator_mm_label, QtCore.Qt.AlignLeft)
  1388. self.excellon_format_lower_mm_entry = IntEntry()
  1389. self.excellon_format_lower_mm_entry.setMaxLength(1)
  1390. self.excellon_format_lower_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  1391. self.excellon_format_lower_mm_entry.setFixedWidth(30)
  1392. self.excellon_format_lower_mm_entry.setToolTip(
  1393. "This numbers signify the number of digits in\n"
  1394. "the decimal part of Excellon coordinates."
  1395. )
  1396. hlay2.addWidget(self.excellon_format_lower_mm_entry, QtCore.Qt.AlignLeft)
  1397. hlay2.addStretch()
  1398. hlay3 = QtWidgets.QHBoxLayout()
  1399. self.layout.addLayout(hlay3)
  1400. self.excellon_zeros_label = QtWidgets.QLabel('Default <b>Zeros</b> Type:')
  1401. self.excellon_zeros_label.setAlignment(QtCore.Qt.AlignLeft)
  1402. self.excellon_zeros_label.setToolTip(
  1403. "This sets the type of Excellon zeros.\n"
  1404. "If LZ then Leading Zeros are kept and\n"
  1405. "Trailing Zeros are removed.\n"
  1406. "If TZ is checked then Trailing Zeros are kept\n"
  1407. "and Leading Zeros are removed."
  1408. )
  1409. hlay3.addWidget(self.excellon_zeros_label)
  1410. self.excellon_zeros_radio = RadioSet([{'label': 'LZ', 'value': 'L'},
  1411. {'label': 'TZ', 'value': 'T'}])
  1412. self.excellon_zeros_radio.setToolTip(
  1413. "This sets the default type of Excellon zeros.\n"
  1414. "If it is not detected in the parsed file the value here\n"
  1415. "will be used."
  1416. "If LZ then Leading Zeros are kept and\n"
  1417. "Trailing Zeros are removed.\n"
  1418. "If TZ is checked then Trailing Zeros are kept\n"
  1419. "and Leading Zeros are removed."
  1420. )
  1421. hlay3.addStretch()
  1422. hlay3.addWidget(self.excellon_zeros_radio, QtCore.Qt.AlignRight)
  1423. hlay4 = QtWidgets.QHBoxLayout()
  1424. self.layout.addLayout(hlay4)
  1425. self.excellon_units_label = QtWidgets.QLabel('Default <b>Units</b> Type:')
  1426. self.excellon_units_label.setAlignment(QtCore.Qt.AlignLeft)
  1427. self.excellon_units_label.setToolTip(
  1428. "This sets the default units of Excellon files.\n"
  1429. "If it is not detected in the parsed file the value here\n"
  1430. "will be used."
  1431. "Some Excellon files don't have an header\n"
  1432. "therefore this parameter will be used.\n"
  1433. )
  1434. hlay4.addWidget(self.excellon_units_label)
  1435. self.excellon_units_radio = RadioSet([{'label': 'INCH', 'value': 'INCH'},
  1436. {'label': 'MM', 'value': 'METRIC'}])
  1437. self.excellon_units_radio.setToolTip(
  1438. "This sets the units of Excellon files.\n"
  1439. "Some Excellon files don't have an header\n"
  1440. "therefore this parameter will be used.\n"
  1441. )
  1442. hlay4.addStretch()
  1443. hlay4.addWidget(self.excellon_units_radio, QtCore.Qt.AlignRight)
  1444. hlay5 = QtWidgets.QVBoxLayout()
  1445. self.layout.addLayout(hlay5)
  1446. self.empty_label = QtWidgets.QLabel("")
  1447. hlay5.addWidget(self.empty_label)
  1448. hlay6 = QtWidgets.QVBoxLayout()
  1449. self.layout.addLayout(hlay6)
  1450. self.excellon_general_label = QtWidgets.QLabel("<b>Excellon Optimization:</b>")
  1451. hlay6.addWidget(self.excellon_general_label)
  1452. # Create a form layout for the Excellon general settings
  1453. form_box_excellon = QtWidgets.QFormLayout()
  1454. hlay6.addLayout(form_box_excellon)
  1455. self.excellon_optimization_label = QtWidgets.QLabel('Path Optimization: ')
  1456. self.excellon_optimization_label.setAlignment(QtCore.Qt.AlignLeft)
  1457. self.excellon_optimization_label.setToolTip(
  1458. "This sets the optimization type for the Excellon drill path.\n"
  1459. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  1460. "Guided Local Path is used. Default search time is 3sec.\n"
  1461. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  1462. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  1463. "\n"
  1464. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  1465. "Travelling Salesman algorithm for path optimization."
  1466. )
  1467. self.excellon_optimization_radio = RadioSet([{'label': 'MH', 'value': 'M'},
  1468. {'label': 'Basic', 'value': 'B'}])
  1469. self.excellon_optimization_radio.setToolTip(
  1470. "This sets the optimization type for the Excellon drill path.\n"
  1471. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  1472. "Guided Local Path is used. Default search time is 3sec.\n"
  1473. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  1474. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  1475. "\n"
  1476. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  1477. "Travelling Salesman algorithm for path optimization."
  1478. )
  1479. form_box_excellon.addRow(self.excellon_optimization_label, self.excellon_optimization_radio)
  1480. current_platform = platform.architecture()[0]
  1481. if current_platform == '64bit':
  1482. self.excellon_optimization_label.setDisabled(False)
  1483. self.excellon_optimization_radio.setDisabled(False)
  1484. else:
  1485. self.excellon_optimization_label.setDisabled(True)
  1486. self.excellon_optimization_radio.setDisabled(True)
  1487. ## Create CNC Job
  1488. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job</b>')
  1489. self.cncjob_label.setToolTip(
  1490. "Create a CNC Job object\n"
  1491. "for this drill object."
  1492. )
  1493. self.layout.addWidget(self.cncjob_label)
  1494. grid2 = QtWidgets.QGridLayout()
  1495. self.layout.addLayout(grid2)
  1496. cutzlabel = QtWidgets.QLabel('Cut Z:')
  1497. cutzlabel.setToolTip(
  1498. "Drill depth (negative)\n"
  1499. "below the copper surface."
  1500. )
  1501. grid2.addWidget(cutzlabel, 0, 0)
  1502. self.cutz_entry = LengthEntry()
  1503. grid2.addWidget(self.cutz_entry, 0, 1)
  1504. travelzlabel = QtWidgets.QLabel('Travel Z:')
  1505. travelzlabel.setToolTip(
  1506. "Tool height when travelling\n"
  1507. "across the XY plane."
  1508. )
  1509. grid2.addWidget(travelzlabel, 1, 0)
  1510. self.travelz_entry = LengthEntry()
  1511. grid2.addWidget(self.travelz_entry, 1, 1)
  1512. # Tool change:
  1513. toolchlabel = QtWidgets.QLabel("Tool change:")
  1514. toolchlabel.setToolTip(
  1515. "Include tool-change sequence\n"
  1516. "in G-Code (Pause for tool change)."
  1517. )
  1518. self.toolchange_cb = FCCheckBox()
  1519. grid2.addWidget(toolchlabel, 2, 0)
  1520. grid2.addWidget(self.toolchange_cb, 2, 1)
  1521. toolchangezlabel = QtWidgets.QLabel('Toolchange Z:')
  1522. toolchangezlabel.setToolTip(
  1523. "Toolchange Z position."
  1524. )
  1525. grid2.addWidget(toolchangezlabel, 3, 0)
  1526. self.toolchangez_entry = LengthEntry()
  1527. grid2.addWidget(self.toolchangez_entry, 3, 1)
  1528. toolchange_xy_label = QtWidgets.QLabel('Toolchange X,Y:')
  1529. toolchange_xy_label.setToolTip(
  1530. "Toolchange X,Y position."
  1531. )
  1532. grid2.addWidget(toolchange_xy_label, 4, 0)
  1533. self.toolchangexy_entry = FCEntry()
  1534. grid2.addWidget(self.toolchangexy_entry, 4, 1)
  1535. startzlabel = QtWidgets.QLabel('Start move Z:')
  1536. startzlabel.setToolTip(
  1537. "Height of the tool just after start.\n"
  1538. "Delete the value if you don't need this feature."
  1539. )
  1540. grid2.addWidget(startzlabel, 5, 0)
  1541. self.estartz_entry = FloatEntry()
  1542. grid2.addWidget(self.estartz_entry, 5, 1)
  1543. endzlabel = QtWidgets.QLabel('End move Z:')
  1544. endzlabel.setToolTip(
  1545. "Height of the tool after\n"
  1546. "the last move at the end of the job."
  1547. )
  1548. grid2.addWidget(endzlabel, 6, 0)
  1549. self.eendz_entry = LengthEntry()
  1550. grid2.addWidget(self.eendz_entry, 6, 1)
  1551. frlabel = QtWidgets.QLabel('Feedrate:')
  1552. frlabel.setToolTip(
  1553. "Tool speed while drilling\n"
  1554. "(in units per minute)."
  1555. )
  1556. grid2.addWidget(frlabel, 7, 0)
  1557. self.feedrate_entry = LengthEntry()
  1558. grid2.addWidget(self.feedrate_entry, 7, 1)
  1559. fr_rapid_label = QtWidgets.QLabel('Feedrate Rapids:')
  1560. fr_rapid_label.setToolTip(
  1561. "Tool speed while drilling\n"
  1562. "with rapid move\n"
  1563. "(in units per minute)."
  1564. )
  1565. grid2.addWidget(fr_rapid_label, 8, 0)
  1566. self.feedrate_rapid_entry = LengthEntry()
  1567. grid2.addWidget(self.feedrate_rapid_entry, 8, 1)
  1568. # Spindle speed
  1569. spdlabel = QtWidgets.QLabel('Spindle speed:')
  1570. spdlabel.setToolTip(
  1571. "Speed of the spindle\n"
  1572. "in RPM (optional)"
  1573. )
  1574. grid2.addWidget(spdlabel, 9, 0)
  1575. self.spindlespeed_entry = IntEntry(allow_empty=True)
  1576. grid2.addWidget(self.spindlespeed_entry, 9, 1)
  1577. # Dwell
  1578. dwelllabel = QtWidgets.QLabel('Dwell:')
  1579. dwelllabel.setToolTip(
  1580. "Pause to allow the spindle to reach its\n"
  1581. "speed before cutting."
  1582. )
  1583. dwelltime = QtWidgets.QLabel('Duration [m-sec.]:')
  1584. dwelltime.setToolTip(
  1585. "Number of milliseconds for spindle to dwell."
  1586. )
  1587. self.dwell_cb = FCCheckBox()
  1588. self.dwelltime_entry = FCEntry()
  1589. grid2.addWidget(dwelllabel, 10, 0)
  1590. grid2.addWidget(self.dwell_cb, 10, 1)
  1591. grid2.addWidget(dwelltime, 11, 0)
  1592. grid2.addWidget(self.dwelltime_entry, 11, 1)
  1593. self.ois_dwell_exc = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  1594. # postprocessor selection
  1595. pp_excellon_label = QtWidgets.QLabel("Postprocessor:")
  1596. pp_excellon_label.setToolTip(
  1597. "The postprocessor file that dictates\n"
  1598. "gcode output."
  1599. )
  1600. grid2.addWidget(pp_excellon_label, 12, 0)
  1601. self.pp_excellon_name_cb = FCComboBox()
  1602. self.pp_excellon_name_cb.setFocusPolicy(Qt.StrongFocus)
  1603. grid2.addWidget(self.pp_excellon_name_cb, 12, 1)
  1604. #### Choose what to use for Gcode creation: Drills, Slots or Both
  1605. excellon_gcode_type_label = QtWidgets.QLabel('<b>Gcode: </b>')
  1606. excellon_gcode_type_label.setToolTip(
  1607. "Choose what to use for GCode generation:\n"
  1608. "'Drills', 'Slots' or 'Both'.\n"
  1609. "When choosing 'Slots' or 'Both', slots will be\n"
  1610. "converted to drills."
  1611. )
  1612. self.excellon_gcode_type_radio = RadioSet([{'label': 'Drills', 'value': 'drills'},
  1613. {'label': 'Slots', 'value': 'slots'},
  1614. {'label': 'Both', 'value': 'both'}])
  1615. grid2.addWidget(excellon_gcode_type_label, 13, 0)
  1616. grid2.addWidget(self.excellon_gcode_type_radio, 13, 1)
  1617. # until I decide to implement this feature those remain disabled
  1618. excellon_gcode_type_label.setDisabled(True)
  1619. self.excellon_gcode_type_radio.setDisabled(True)
  1620. #### Milling Holes ####
  1621. self.mill_hole_label = QtWidgets.QLabel('<b>Mill Holes</b>')
  1622. self.mill_hole_label.setToolTip(
  1623. "Create Geometry for milling holes."
  1624. )
  1625. self.layout.addWidget(self.mill_hole_label)
  1626. grid3 = QtWidgets.QGridLayout()
  1627. self.layout.addLayout(grid3)
  1628. tdlabel = QtWidgets.QLabel('Drill Tool dia:')
  1629. tdlabel.setToolTip(
  1630. "Diameter of the cutting tool."
  1631. )
  1632. grid3.addWidget(tdlabel, 0, 0)
  1633. self.tooldia_entry = LengthEntry()
  1634. grid3.addWidget(self.tooldia_entry, 0, 1)
  1635. stdlabel = QtWidgets.QLabel('Slot Tool dia:')
  1636. stdlabel.setToolTip(
  1637. "Diameter of the cutting tool\n"
  1638. "when milling slots."
  1639. )
  1640. grid3.addWidget(stdlabel, 1, 0)
  1641. self.slot_tooldia_entry = LengthEntry()
  1642. grid3.addWidget(self.slot_tooldia_entry, 1, 1)
  1643. grid4 = QtWidgets.QGridLayout()
  1644. self.layout.addLayout(grid4)
  1645. # Adding the Excellon Format Defaults Button
  1646. self.excellon_defaults_button = QtWidgets.QPushButton()
  1647. self.excellon_defaults_button.setText(str("Defaults"))
  1648. self.excellon_defaults_button.setFixedWidth(80)
  1649. grid4.addWidget(self.excellon_defaults_button, 0, 0, QtCore.Qt.AlignRight)
  1650. self.layout.addStretch()
  1651. class GeometryPrefGroupUI(OptionsGroupUI):
  1652. def __init__(self, parent=None):
  1653. # OptionsGroupUI.__init__(self, "Geometry Options", parent=parent)
  1654. super(GeometryPrefGroupUI, self).__init__(self)
  1655. self.setTitle(str("Geometry Options"))
  1656. ## Plot options
  1657. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1658. self.layout.addWidget(self.plot_options_label)
  1659. # Plot CB
  1660. self.plot_cb = FCCheckBox(label='Plot')
  1661. self.plot_cb.setToolTip(
  1662. "Plot (show) this object."
  1663. )
  1664. self.layout.addWidget(self.plot_cb)
  1665. grid0 = QtWidgets.QGridLayout()
  1666. self.layout.addLayout(grid0)
  1667. # Number of circle steps for circular aperture linear approximation
  1668. self.circle_steps_label = QtWidgets.QLabel("Circle Steps:")
  1669. self.circle_steps_label.setToolTip(
  1670. "The number of circle steps for <b>Geometry</b> \n"
  1671. "circle and arc shapes linear approximation."
  1672. )
  1673. grid0.addWidget(self.circle_steps_label, 1, 0)
  1674. self.circle_steps_entry = IntEntry()
  1675. grid0.addWidget(self.circle_steps_entry, 1, 1)
  1676. # Tools
  1677. self.tools_label = QtWidgets.QLabel("<b>Tools</b>")
  1678. self.layout.addWidget(self.tools_label)
  1679. grid1 = QtWidgets.QGridLayout()
  1680. self.layout.addLayout(grid1)
  1681. # Tooldia
  1682. tdlabel = QtWidgets.QLabel('Tool dia: ')
  1683. tdlabel.setToolTip(
  1684. "The diameter of the cutting\n"
  1685. "tool (just for display)."
  1686. )
  1687. grid1.addWidget(tdlabel, 0, 0)
  1688. self.cnctooldia_entry = LengthEntry()
  1689. grid1.addWidget(self.cnctooldia_entry, 0, 1)
  1690. # ------------------------------
  1691. ## Create CNC Job
  1692. # ------------------------------
  1693. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job:</b>')
  1694. self.cncjob_label.setToolTip(
  1695. "Create a CNC Job object\n"
  1696. "tracing the contours of this\n"
  1697. "Geometry object."
  1698. )
  1699. self.layout.addWidget(self.cncjob_label)
  1700. grid2 = QtWidgets.QGridLayout()
  1701. self.layout.addLayout(grid2)
  1702. # Cut Z
  1703. cutzlabel = QtWidgets.QLabel('Cut Z:')
  1704. cutzlabel.setToolTip(
  1705. "Cutting depth (negative)\n"
  1706. "below the copper surface."
  1707. )
  1708. grid2.addWidget(cutzlabel, 0, 0)
  1709. self.cutz_entry = LengthEntry()
  1710. grid2.addWidget(self.cutz_entry, 0, 1)
  1711. # Multidepth CheckBox
  1712. self.multidepth_cb = FCCheckBox(label='Multidepth')
  1713. self.multidepth_cb.setToolTip(
  1714. "Multidepth usage: True or False."
  1715. )
  1716. grid2.addWidget(self.multidepth_cb, 1, 0)
  1717. # Depth/pass
  1718. dplabel = QtWidgets.QLabel('Depth/Pass:')
  1719. dplabel.setToolTip(
  1720. "The depth to cut on each pass,\n"
  1721. "when multidepth is enabled.\n"
  1722. "It has positive value although\n"
  1723. "it is a fraction from the depth\n"
  1724. "which has negative value."
  1725. )
  1726. grid2.addWidget(dplabel, 2, 0)
  1727. self.depthperpass_entry = LengthEntry()
  1728. grid2.addWidget(self.depthperpass_entry, 2, 1)
  1729. self.ois_multidepth = OptionalInputSection(self.multidepth_cb, [self.depthperpass_entry])
  1730. # Travel Z
  1731. travelzlabel = QtWidgets.QLabel('Travel Z:')
  1732. travelzlabel.setToolTip(
  1733. "Height of the tool when\n"
  1734. "moving without cutting."
  1735. )
  1736. grid2.addWidget(travelzlabel, 3, 0)
  1737. self.travelz_entry = LengthEntry()
  1738. grid2.addWidget(self.travelz_entry, 3, 1)
  1739. # Tool change:
  1740. toolchlabel = QtWidgets.QLabel("Tool change:")
  1741. toolchlabel.setToolTip(
  1742. "Include tool-change sequence\n"
  1743. "in G-Code (Pause for tool change)."
  1744. )
  1745. self.toolchange_cb = FCCheckBox()
  1746. grid2.addWidget(toolchlabel, 4, 0)
  1747. grid2.addWidget(self.toolchange_cb, 4, 1)
  1748. # Toolchange Z
  1749. toolchangezlabel = QtWidgets.QLabel('Toolchange Z:')
  1750. toolchangezlabel.setToolTip(
  1751. "Toolchange Z position."
  1752. )
  1753. grid2.addWidget(toolchangezlabel, 5, 0)
  1754. self.toolchangez_entry = LengthEntry()
  1755. grid2.addWidget(self.toolchangez_entry, 5, 1)
  1756. # Toolchange X,Y
  1757. toolchange_xy_label = QtWidgets.QLabel('Toolchange X,Y:')
  1758. toolchange_xy_label.setToolTip(
  1759. "Toolchange X,Y position."
  1760. )
  1761. grid2.addWidget(toolchange_xy_label, 6, 0)
  1762. self.toolchangexy_entry = FCEntry()
  1763. grid2.addWidget(self.toolchangexy_entry, 6, 1)
  1764. # Start move Z
  1765. startzlabel = QtWidgets.QLabel('Start move Z:')
  1766. startzlabel.setToolTip(
  1767. "Height of the tool just after starting the work.\n"
  1768. "Delete the value if you don't need this feature."
  1769. )
  1770. grid2.addWidget(startzlabel, 7, 0)
  1771. self.gstartz_entry = FloatEntry()
  1772. grid2.addWidget(self.gstartz_entry, 7, 1)
  1773. # End move Z
  1774. endzlabel = QtWidgets.QLabel('End move Z:')
  1775. endzlabel.setToolTip(
  1776. "Height of the tool after\n"
  1777. "the last move at the end of the job."
  1778. )
  1779. grid2.addWidget(endzlabel, 8, 0)
  1780. self.gendz_entry = LengthEntry()
  1781. grid2.addWidget(self.gendz_entry, 8, 1)
  1782. # Feedrate X-Y
  1783. frlabel = QtWidgets.QLabel('Feed Rate X-Y:')
  1784. frlabel.setToolTip(
  1785. "Cutting speed in the XY\n"
  1786. "plane in units per minute"
  1787. )
  1788. grid2.addWidget(frlabel, 9, 0)
  1789. self.cncfeedrate_entry = LengthEntry()
  1790. grid2.addWidget(self.cncfeedrate_entry, 9, 1)
  1791. # Feedrate Z (Plunge)
  1792. frz_label = QtWidgets.QLabel('Feed Rate Z:')
  1793. frz_label.setToolTip(
  1794. "Cutting speed in the XY\n"
  1795. "plane in units per minute.\n"
  1796. "It is called also Plunge."
  1797. )
  1798. grid2.addWidget(frz_label, 10, 0)
  1799. self.cncplunge_entry = LengthEntry()
  1800. grid2.addWidget(self.cncplunge_entry, 10, 1)
  1801. # Feedrate rapids
  1802. fr_rapid_label = QtWidgets.QLabel('Feed Rate Rapids:')
  1803. fr_rapid_label.setToolTip(
  1804. "Cutting speed in the XY\n"
  1805. "plane in units per minute"
  1806. )
  1807. grid2.addWidget(fr_rapid_label, 11, 0)
  1808. self.cncfeedrate_rapid_entry = LengthEntry()
  1809. grid2.addWidget(self.cncfeedrate_rapid_entry, 11, 1)
  1810. # End move extra cut
  1811. self.extracut_cb = FCCheckBox(label='Cut over 1st pt.')
  1812. self.extracut_cb.setToolTip(
  1813. "In order to remove possible\n"
  1814. "copper leftovers where first cut\n"
  1815. "meet with last cut, we generate an\n"
  1816. "extended cut over the first cut section."
  1817. )
  1818. grid2.addWidget(self.extracut_cb, 12, 0)
  1819. # Spindle Speed
  1820. spdlabel = QtWidgets.QLabel('Spindle speed:')
  1821. spdlabel.setToolTip(
  1822. "Speed of the spindle\n"
  1823. "in RPM (optional)"
  1824. )
  1825. grid2.addWidget(spdlabel, 13, 0)
  1826. self.cncspindlespeed_entry = IntEntry(allow_empty=True)
  1827. grid2.addWidget(self.cncspindlespeed_entry, 13, 1)
  1828. # Dwell
  1829. self.dwell_cb = FCCheckBox(label='Dwell:')
  1830. self.dwell_cb.setToolTip(
  1831. "Pause to allow the spindle to reach its\n"
  1832. "speed before cutting."
  1833. )
  1834. dwelltime = QtWidgets.QLabel('Duration [m-sec.]:')
  1835. dwelltime.setToolTip(
  1836. "Number of milliseconds for spindle to dwell."
  1837. )
  1838. self.dwelltime_entry = FCEntry()
  1839. grid2.addWidget(self.dwell_cb, 14, 0)
  1840. grid2.addWidget(dwelltime, 15, 0)
  1841. grid2.addWidget(self.dwelltime_entry, 15, 1)
  1842. self.ois_dwell = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  1843. # postprocessor selection
  1844. pp_label = QtWidgets.QLabel("Postprocessor:")
  1845. pp_label.setToolTip(
  1846. "The postprocessor file that dictates\n"
  1847. "Machine Code output."
  1848. )
  1849. grid2.addWidget(pp_label, 16, 0)
  1850. self.pp_geometry_name_cb = FCComboBox()
  1851. self.pp_geometry_name_cb.setFocusPolicy(Qt.StrongFocus)
  1852. grid2.addWidget(self.pp_geometry_name_cb, 16, 1)
  1853. # ------------------------------
  1854. ## Paint area
  1855. # ------------------------------
  1856. self.paint_label = QtWidgets.QLabel('<b>Paint Area:</b>')
  1857. self.paint_label.setToolTip(
  1858. "Creates tool paths to cover the\n"
  1859. "whole area of a polygon (remove\n"
  1860. "all copper). You will be asked\n"
  1861. "to click on the desired polygon."
  1862. )
  1863. self.layout.addWidget(self.paint_label)
  1864. grid4 = QtWidgets.QGridLayout()
  1865. self.layout.addLayout(grid4)
  1866. # Tool dia
  1867. ptdlabel = QtWidgets.QLabel('Tool dia:')
  1868. ptdlabel.setToolTip(
  1869. "Diameter of the tool to\n"
  1870. "be used in the operation."
  1871. )
  1872. grid4.addWidget(ptdlabel, 0, 0)
  1873. self.painttooldia_entry = LengthEntry()
  1874. grid4.addWidget(self.painttooldia_entry, 0, 1)
  1875. # Overlap
  1876. ovlabel = QtWidgets.QLabel('Overlap:')
  1877. ovlabel.setToolTip(
  1878. "How much (fraction) of the tool\n"
  1879. "width to overlap each tool pass."
  1880. )
  1881. grid4.addWidget(ovlabel, 1, 0)
  1882. self.paintoverlap_entry = LengthEntry()
  1883. grid4.addWidget(self.paintoverlap_entry, 1, 1)
  1884. # Margin
  1885. marginlabel = QtWidgets.QLabel('Margin:')
  1886. marginlabel.setToolTip(
  1887. "Distance by which to avoid\n"
  1888. "the edges of the polygon to\n"
  1889. "be painted."
  1890. )
  1891. grid4.addWidget(marginlabel, 2, 0)
  1892. self.paintmargin_entry = LengthEntry()
  1893. grid4.addWidget(self.paintmargin_entry, 2, 1)
  1894. # Method
  1895. methodlabel = QtWidgets.QLabel('Method:')
  1896. methodlabel.setToolTip(
  1897. "Algorithm to paint the polygon:<BR>"
  1898. "<B>Standard</B>: Fixed step inwards.<BR>"
  1899. "<B>Seed-based</B>: Outwards from seed."
  1900. )
  1901. grid4.addWidget(methodlabel, 3, 0)
  1902. self.paintmethod_combo = RadioSet([
  1903. {"label": "Standard", "value": "standard"},
  1904. {"label": "Seed-based", "value": "seed"},
  1905. {"label": "Straight lines", "value": "lines"}
  1906. ], orientation='vertical', stretch=False)
  1907. grid4.addWidget(self.paintmethod_combo, 3, 1)
  1908. # Connect lines
  1909. pathconnectlabel = QtWidgets.QLabel("Connect:")
  1910. pathconnectlabel.setToolTip(
  1911. "Draw lines between resulting\n"
  1912. "segments to minimize tool lifts."
  1913. )
  1914. grid4.addWidget(pathconnectlabel, 4, 0)
  1915. self.pathconnect_cb = FCCheckBox()
  1916. grid4.addWidget(self.pathconnect_cb, 4, 1)
  1917. # Paint contour
  1918. contourlabel = QtWidgets.QLabel("Contour:")
  1919. contourlabel.setToolTip(
  1920. "Cut around the perimeter of the polygon\n"
  1921. "to trim rough edges."
  1922. )
  1923. grid4.addWidget(contourlabel, 5, 0)
  1924. self.contour_cb = FCCheckBox()
  1925. grid4.addWidget(self.contour_cb, 5, 1)
  1926. # Polygon selection
  1927. selectlabel = QtWidgets.QLabel('Selection:')
  1928. selectlabel.setToolTip(
  1929. "How to select the polygons to paint."
  1930. )
  1931. grid4.addWidget(selectlabel, 6, 0)
  1932. self.selectmethod_combo = RadioSet([
  1933. {"label": "Single", "value": "single"},
  1934. {"label": "All", "value": "all"},
  1935. # {"label": "Rectangle", "value": "rectangle"}
  1936. ])
  1937. grid4.addWidget(self.selectmethod_combo, 6, 1)
  1938. self.layout.addStretch()
  1939. class CNCJobPrefGroupUI(OptionsGroupUI):
  1940. def __init__(self, parent=None):
  1941. # OptionsGroupUI.__init__(self, "CNC Job Options", parent=None)
  1942. super(CNCJobPrefGroupUI, self).__init__(self)
  1943. self.setTitle(str("CNC Job Options"))
  1944. ## Plot options
  1945. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1946. self.layout.addWidget(self.plot_options_label)
  1947. grid0 = QtWidgets.QGridLayout()
  1948. self.layout.addLayout(grid0)
  1949. # Plot CB
  1950. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  1951. self.plot_cb = FCCheckBox('Plot')
  1952. self.plot_cb.setToolTip(
  1953. "Plot (show) this object."
  1954. )
  1955. grid0.addWidget(self.plot_cb, 0, 0)
  1956. # Number of circle steps for circular aperture linear approximation
  1957. self.steps_per_circle_label = QtWidgets.QLabel("Circle Steps:")
  1958. self.steps_per_circle_label.setToolTip(
  1959. "The number of circle steps for <b>GCode</b> \n"
  1960. "circle and arc shapes linear approximation."
  1961. )
  1962. grid0.addWidget(self.steps_per_circle_label, 1, 0)
  1963. self.steps_per_circle_entry = IntEntry()
  1964. grid0.addWidget(self.steps_per_circle_entry, 1, 1)
  1965. # Tool dia for plot
  1966. tdlabel = QtWidgets.QLabel('Tool dia:')
  1967. tdlabel.setToolTip(
  1968. "Diameter of the tool to be\n"
  1969. "rendered in the plot."
  1970. )
  1971. grid0.addWidget(tdlabel, 2, 0)
  1972. self.tooldia_entry = LengthEntry()
  1973. grid0.addWidget(self.tooldia_entry, 2, 1)
  1974. # Number of decimals to use in GCODE coordinates
  1975. cdeclabel = QtWidgets.QLabel('Coords decimals:')
  1976. cdeclabel.setToolTip(
  1977. "The number of decimals to be used for \n"
  1978. "the X, Y, Z coordinates in CNC code (GCODE, etc.)"
  1979. )
  1980. grid0.addWidget(cdeclabel, 3, 0)
  1981. self.coords_dec_entry = IntEntry()
  1982. grid0.addWidget(self.coords_dec_entry, 3, 1)
  1983. # Number of decimals to use in GCODE feedrate
  1984. frdeclabel = QtWidgets.QLabel('Feedrate decimals:')
  1985. frdeclabel.setToolTip(
  1986. "The number of decimals to be used for \n"
  1987. "the feedrate in CNC code (GCODE, etc.)"
  1988. )
  1989. grid0.addWidget(frdeclabel, 4, 0)
  1990. self.fr_dec_entry = IntEntry()
  1991. grid0.addWidget(self.fr_dec_entry, 4, 1)
  1992. ## Export G-Code
  1993. self.export_gcode_label = QtWidgets.QLabel("<b>Export G-Code:</b>")
  1994. self.export_gcode_label.setToolTip(
  1995. "Export and save G-Code to\n"
  1996. "make this object to a file."
  1997. )
  1998. self.layout.addWidget(self.export_gcode_label)
  1999. # Prepend to G-Code
  2000. prependlabel = QtWidgets.QLabel('Prepend to G-Code:')
  2001. prependlabel.setToolTip(
  2002. "Type here any G-Code commands you would\n"
  2003. "like to add at the beginning of the G-Code file."
  2004. )
  2005. self.layout.addWidget(prependlabel)
  2006. self.prepend_text = FCTextArea()
  2007. self.layout.addWidget(self.prepend_text)
  2008. # Append text to G-Code
  2009. appendlabel = QtWidgets.QLabel('Append to G-Code:')
  2010. appendlabel.setToolTip(
  2011. "Type here any G-Code commands you would\n"
  2012. "like to append to the generated file.\n"
  2013. "I.e.: M2 (End of program)"
  2014. )
  2015. self.layout.addWidget(appendlabel)
  2016. self.append_text = FCTextArea()
  2017. self.layout.addWidget(self.append_text)
  2018. grid0 = QtWidgets.QGridLayout()
  2019. self.layout.addLayout(grid0)
  2020. class FlatCAMActivityView(QtWidgets.QWidget):
  2021. def __init__(self, parent=None):
  2022. super().__init__(parent=parent)
  2023. self.setMinimumWidth(200)
  2024. self.icon = QtWidgets.QLabel(self)
  2025. self.icon.setGeometry(0, 0, 16, 12)
  2026. self.movie = QtGui.QMovie("share/active.gif")
  2027. self.icon.setMovie(self.movie)
  2028. # self.movie.start()
  2029. layout = QtWidgets.QHBoxLayout()
  2030. layout.setContentsMargins(5, 0, 5, 0)
  2031. layout.setAlignment(QtCore.Qt.AlignLeft)
  2032. self.setLayout(layout)
  2033. layout.addWidget(self.icon)
  2034. self.text = QtWidgets.QLabel(self)
  2035. self.text.setText("Idle.")
  2036. layout.addWidget(self.text)
  2037. def set_idle(self):
  2038. self.movie.stop()
  2039. self.text.setText("Idle.")
  2040. def set_busy(self, msg):
  2041. self.movie.start()
  2042. self.text.setText(msg)
  2043. class FlatCAMInfoBar(QtWidgets.QWidget):
  2044. def __init__(self, parent=None):
  2045. super(FlatCAMInfoBar, self).__init__(parent=parent)
  2046. self.icon = QtWidgets.QLabel(self)
  2047. self.icon.setGeometry(0, 0, 12, 12)
  2048. self.pmap = QtGui.QPixmap('share/graylight12.png')
  2049. self.icon.setPixmap(self.pmap)
  2050. layout = QtWidgets.QHBoxLayout()
  2051. layout.setContentsMargins(5, 0, 5, 0)
  2052. self.setLayout(layout)
  2053. layout.addWidget(self.icon)
  2054. self.text = QtWidgets.QLabel(self)
  2055. self.text.setText("Hello!")
  2056. self.text.setToolTip("Hello!")
  2057. layout.addWidget(self.text)
  2058. layout.addStretch()
  2059. def set_text_(self, text):
  2060. self.text.setText(text)
  2061. self.text.setToolTip(text)
  2062. def set_status(self, text, level="info"):
  2063. level = str(level)
  2064. self.pmap.fill()
  2065. if level == "error" or level == "error_notcl":
  2066. self.pmap = QtGui.QPixmap('share/redlight12.png')
  2067. elif level == "success":
  2068. self.pmap = QtGui.QPixmap('share/greenlight12.png')
  2069. elif level == "warning" or level == "warning_notcl":
  2070. self.pmap = QtGui.QPixmap('share/yellowlight12.png')
  2071. else:
  2072. self.pmap = QtGui.QPixmap('share/graylight12.png')
  2073. self.icon.setPixmap(self.pmap)
  2074. self.set_text_(text)
  2075. # end of file