FlatCAMGUI.py 197 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150
  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. # ##########################################################
  9. # File Modified (major mod): Marius Adrian Stanciu #
  10. # Date: 3/10/2019 #
  11. # ##########################################################
  12. from flatcamGUI.PreferencesUI import *
  13. from flatcamEditors.FlatCAMGeoEditor import FCShapeTool
  14. from matplotlib.backend_bases import KeyEvent as mpl_key_event
  15. import webbrowser
  16. from copy import deepcopy
  17. from datetime import datetime
  18. import gettext
  19. import FlatCAMTranslation as fcTranslate
  20. import builtins
  21. fcTranslate.apply_language('strings')
  22. if '_' not in builtins.__dict__:
  23. _ = gettext.gettext
  24. class FlatCAMGUI(QtWidgets.QMainWindow):
  25. # Emitted when persistent window geometry needs to be retained
  26. geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate')
  27. final_save = QtCore.pyqtSignal(name='saveBeforeExit')
  28. def __init__(self, app):
  29. super(FlatCAMGUI, self).__init__()
  30. self.app = app
  31. self.decimals = self.app.decimals
  32. # Divine icon pack by Ipapun @ finicons.com
  33. # ################################## ##
  34. # ## BUILDING THE GUI IS DONE HERE # ##
  35. # ################################## ##
  36. # ######### ##
  37. # ## Menu # ##
  38. # ######### ##
  39. self.menu = self.menuBar()
  40. self.menu_toggle_nb = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/notebook32.png'), _("Toggle Panel"))
  41. self.menu_toggle_nb.setToolTip(
  42. _("Toggle Panel")
  43. )
  44. # self.menu_toggle_nb = QtWidgets.QAction("NB")
  45. self.menu_toggle_nb.setCheckable(True)
  46. self.menu.addAction(self.menu_toggle_nb)
  47. # ########################################################################
  48. # ########################## File # ######################################
  49. # ########################################################################
  50. self.menufile = self.menu.addMenu(_('File'))
  51. self.menufile.setToolTipsVisible(True)
  52. # New Project
  53. self.menufilenewproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/file16.png'),
  54. _('&New Project ...\tCTRL+N'), self)
  55. self.menufilenewproject.setToolTip(
  56. _("Will create a new, blank project")
  57. )
  58. self.menufile.addAction(self.menufilenewproject)
  59. # New Category (Excellon, Geometry)
  60. self.menufilenew = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/file16.png'), _('&New'))
  61. self.menufilenew.setToolTipsVisible(True)
  62. self.menufilenewgeo = self.menufilenew.addAction(
  63. QtGui.QIcon(self.app.resource_location + '/new_file_geo16.png'), _('Geometry\tN'))
  64. self.menufilenewgeo.setToolTip(
  65. _("Will create a new, empty Geometry Object.")
  66. )
  67. self.menufilenewgrb = self.menufilenew.addAction(QtGui.QIcon(self.app.resource_location + '/new_file_grb16.png'), _('Gerber\tB'))
  68. self.menufilenewgrb.setToolTip(
  69. _("Will create a new, empty Gerber Object.")
  70. )
  71. self.menufilenewexc = self.menufilenew.addAction(QtGui.QIcon(self.app.resource_location + '/new_file_exc16.png'), _('Excellon\tL'))
  72. self.menufilenewexc.setToolTip(
  73. _("Will create a new, empty Excellon Object.")
  74. )
  75. self.menufilenew.addSeparator()
  76. self.menufilenewdoc = self.menufilenew.addAction(QtGui.QIcon(self.app.resource_location + '/notes16_1.png'), _('Document\tD'))
  77. self.menufilenewdoc.setToolTip(
  78. _("Will create a new, empty Document Object.")
  79. )
  80. self.menufile_open = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/folder32_bis.png'), _('Open'))
  81. self.menufile_open.setToolTipsVisible(True)
  82. # Open Project ...
  83. self.menufileopenproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/folder16.png'), _('Open &Project ...'), self)
  84. self.menufile_open.addAction(self.menufileopenproject)
  85. self.menufile_open.addSeparator()
  86. # Open Gerber ...
  87. self.menufileopengerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/flatcam_icon24.png'),
  88. _('Open &Gerber ...\tCTRL+G'), self)
  89. self.menufile_open.addAction(self.menufileopengerber)
  90. # Open Excellon ...
  91. self.menufileopenexcellon = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'),
  92. _('Open &Excellon ...\tCTRL+E'), self)
  93. self.menufile_open.addAction(self.menufileopenexcellon)
  94. # Open G-Code ...
  95. self.menufileopengcode = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/code.png'), _('Open G-&Code ...'), self)
  96. self.menufile_open.addAction(self.menufileopengcode)
  97. self.menufile_open.addSeparator()
  98. # Open Config File...
  99. self.menufileopenconfig = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/folder16.png'), _('Open Config ...'), self)
  100. self.menufile_open.addAction(self.menufileopenconfig)
  101. # Recent
  102. self.recent_projects = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/recent_files.png'), _("Recent projects"))
  103. self.recent = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/recent_files.png'), _("Recent files"))
  104. # Separator
  105. self.menufile.addSeparator()
  106. # Scripting
  107. self.menufile_scripting = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Scripting'))
  108. self.menufile_scripting.setToolTipsVisible(True)
  109. self.menufilenewscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/script_new16.png'), _('New Script ...'), self)
  110. self.menufileopenscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'), self)
  111. self.menufilerunscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/script16.png'),
  112. '%s\tSHIFT+S' % _('Run Script ...'), self)
  113. self.menufilerunscript.setToolTip(
  114. _("Will run the opened Tcl Script thus\n"
  115. "enabling the automation of certain\n"
  116. "functions of FlatCAM.")
  117. )
  118. self.menufile_scripting.addAction(self.menufilenewscript)
  119. self.menufile_scripting.addAction(self.menufileopenscript)
  120. self.menufile_scripting.addSeparator()
  121. self.menufile_scripting.addAction(self.menufilerunscript)
  122. # Separator
  123. self.menufile.addSeparator()
  124. # Import ...
  125. self.menufileimport = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/import.png'), _('Import'))
  126. self.menufileimportsvg = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/svg16.png'),
  127. _('&SVG as Geometry Object ...'), self)
  128. self.menufileimport.addAction(self.menufileimportsvg)
  129. self.menufileimportsvg_as_gerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/svg16.png'),
  130. _('&SVG as Gerber Object ...'), self)
  131. self.menufileimport.addAction(self.menufileimportsvg_as_gerber)
  132. self.menufileimport.addSeparator()
  133. self.menufileimportdxf = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/dxf16.png'),
  134. _('&DXF as Geometry Object ...'), self)
  135. self.menufileimport.addAction(self.menufileimportdxf)
  136. self.menufileimportdxf_as_gerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/dxf16.png'),
  137. _('&DXF as Gerber Object ...'), self)
  138. self.menufileimport.addAction(self.menufileimportdxf_as_gerber)
  139. self.menufileimport.addSeparator()
  140. self.menufileimport_hpgl2_as_geo = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/dxf16.png'),
  141. _('HPGL2 as Geometry Object ...'), self)
  142. self.menufileimport.addAction(self.menufileimport_hpgl2_as_geo)
  143. self.menufileimport.addSeparator()
  144. # Export ...
  145. self.menufileexport = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export'))
  146. self.menufileexport.setToolTipsVisible(True)
  147. self.menufileexportsvg = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export &SVG ...'), self)
  148. self.menufileexport.addAction(self.menufileexportsvg)
  149. self.menufileexportdxf = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/export.png'), _('Export DXF ...'), self)
  150. self.menufileexport.addAction(self.menufileexportdxf)
  151. self.menufileexport.addSeparator()
  152. self.menufileexportpng = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/export_png32.png'), _('Export &PNG ...'), self)
  153. self.menufileexportpng.setToolTip(
  154. _("Will export an image in PNG format,\n"
  155. "the saved image will contain the visual \n"
  156. "information currently in FlatCAM Plot Area.")
  157. )
  158. self.menufileexport.addAction(self.menufileexportpng)
  159. self.menufileexport.addSeparator()
  160. self.menufileexportexcellon = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/drill32.png'),
  161. _('Export &Excellon ...'), self)
  162. self.menufileexportexcellon.setToolTip(
  163. _("Will export an Excellon Object as Excellon file,\n"
  164. "the coordinates format, the file units and zeros\n"
  165. "are set in Preferences -> Excellon Export.")
  166. )
  167. self.menufileexport.addAction(self.menufileexportexcellon)
  168. self.menufileexportgerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'),
  169. _('Export &Gerber ...'), self)
  170. self.menufileexportgerber.setToolTip(
  171. _("Will export an Gerber Object as Gerber file,\n"
  172. "the coordinates format, the file units and zeros\n"
  173. "are set in Preferences -> Gerber Export.")
  174. )
  175. self.menufileexport.addAction(self.menufileexportgerber)
  176. # Separator
  177. self.menufile.addSeparator()
  178. # Save Defaults
  179. self.menufilesavedefaults = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/defaults.png'),
  180. _('Save Preferences'), self)
  181. self.menufile.addAction(self.menufilesavedefaults)
  182. # Separator
  183. self.menufile.addSeparator()
  184. self.menufile_backup = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/backup24.png'),
  185. _('Backup'))
  186. # Import Preferences
  187. self.menufileimportpref = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/backup_import24.png'),
  188. _('Import Preferences from file ...'), self)
  189. self.menufile_backup.addAction(self.menufileimportpref)
  190. # Export Preferences
  191. self.menufileexportpref = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/backup_export24.png'),
  192. _('Export Preferences to file ...'), self)
  193. self.menufile_backup.addAction(self.menufileexportpref)
  194. # Separator
  195. self.menufile.addSeparator()
  196. self.menufile_print = QtWidgets.QAction(
  197. QtGui.QIcon(self.app.resource_location + '/printer32.png'), '%s\tCTRL+P' % _('Print (PDF)'))
  198. self.menufile.addAction(self.menufile_print)
  199. self.menufile_save = self.menufile.addMenu(QtGui.QIcon(self.app.resource_location + '/save_as.png'), _('Save'))
  200. # Save Project
  201. self.menufilesaveproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/floppy16.png'),
  202. _('&Save Project ...'), self)
  203. self.menufile_save.addAction(self.menufilesaveproject)
  204. # Save Project As ...
  205. self.menufilesaveprojectas = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/save_as.png'),
  206. _('Save Project &As ...\tCTRL+S'), self)
  207. self.menufile_save.addAction(self.menufilesaveprojectas)
  208. # Save Project Copy ...
  209. self.menufilesaveprojectcopy = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/floppy16.png'),
  210. _('Save Project C&opy ...'), self)
  211. self.menufile_save.addAction(self.menufilesaveprojectcopy)
  212. self.menufile_save.addSeparator()
  213. # Separator
  214. self.menufile.addSeparator()
  215. # Quit
  216. self.menufile_exit = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/power16.png'),
  217. _('E&xit'), self)
  218. # exitAction.setShortcut('Ctrl+Q')
  219. # exitAction.setStatusTip('Exit application')
  220. self.menufile.addAction(self.menufile_exit)
  221. # ########################################################################
  222. # ########################## Edit # ######################################
  223. # ########################################################################
  224. self.menuedit = self.menu.addMenu(_('Edit'))
  225. # Separator
  226. self.menuedit.addSeparator()
  227. self.menueditedit = self.menuedit.addAction(QtGui.QIcon(self.app.resource_location + '/edit16.png'),
  228. _('Edit Object\tE'))
  229. self.menueditok = self.menuedit.addAction(QtGui.QIcon(self.app.resource_location + '/edit_ok16.png'),
  230. _('Close Editor\tCTRL+S'))
  231. # adjust the initial state of the menu entries related to the editor
  232. self.menueditedit.setDisabled(False)
  233. self.menueditok.setDisabled(True)
  234. # Separator
  235. self.menuedit.addSeparator()
  236. self.menuedit_convert = self.menuedit.addMenu(QtGui.QIcon(self.app.resource_location + '/convert24.png'),
  237. _('Conversion'))
  238. self.menuedit_convertjoin = self.menuedit_convert.addAction(
  239. QtGui.QIcon(self.app.resource_location + '/join16.png'), _('&Join Geo/Gerber/Exc -> Geo'))
  240. self.menuedit_convertjoin.setToolTip(
  241. _("Merge a selection of objects, which can be of type:\n"
  242. "- Gerber\n"
  243. "- Excellon\n"
  244. "- Geometry\n"
  245. "into a new combo Geometry object.")
  246. )
  247. self.menuedit_convertjoinexc = self.menuedit_convert.addAction(
  248. QtGui.QIcon(self.app.resource_location + '/join16.png'), _('Join Excellon(s) -> Excellon'))
  249. self.menuedit_convertjoinexc.setToolTip(
  250. _("Merge a selection of Excellon objects into a new combo Excellon object.")
  251. )
  252. self.menuedit_convertjoingrb = self.menuedit_convert.addAction(
  253. QtGui.QIcon(self.app.resource_location + '/join16.png'), _('Join Gerber(s) -> Gerber'))
  254. self.menuedit_convertjoingrb.setToolTip(
  255. _("Merge a selection of Gerber objects into a new combo Gerber object.")
  256. )
  257. # Separator
  258. self.menuedit_convert.addSeparator()
  259. self.menuedit_convert_sg2mg = self.menuedit_convert.addAction(
  260. QtGui.QIcon(self.app.resource_location + '/convert24.png'), _('Convert Single to MultiGeo'))
  261. self.menuedit_convert_sg2mg.setToolTip(
  262. _("Will convert a Geometry object from single_geometry type\n"
  263. "to a multi_geometry type.")
  264. )
  265. self.menuedit_convert_mg2sg = self.menuedit_convert.addAction(
  266. QtGui.QIcon(self.app.resource_location + '/convert24.png'), _('Convert Multi to SingleGeo'))
  267. self.menuedit_convert_mg2sg.setToolTip(
  268. _("Will convert a Geometry object from multi_geometry type\n"
  269. "to a single_geometry type.")
  270. )
  271. # Separator
  272. self.menuedit_convert.addSeparator()
  273. self.menueditconvert_any2geo = self.menuedit_convert.addAction(
  274. QtGui.QIcon(self.app.resource_location + '/copy_geo.png'),
  275. _('Convert Any to Geo'))
  276. self.menueditconvert_any2gerber = self.menuedit_convert.addAction(
  277. QtGui.QIcon(self.app.resource_location + '/copy_geo.png'),
  278. _('Convert Any to Gerber'))
  279. self.menuedit_convert.setToolTipsVisible(True)
  280. # Separator
  281. self.menuedit.addSeparator()
  282. self.menueditcopyobject = self.menuedit.addAction(
  283. QtGui.QIcon(self.app.resource_location + '/copy.png'), _('&Copy\tCTRL+C'))
  284. # Separator
  285. self.menuedit.addSeparator()
  286. self.menueditdelete = self.menuedit.addAction(
  287. QtGui.QIcon(self.app.resource_location + '/trash16.png'), _('&Delete\tDEL'))
  288. # Separator
  289. self.menuedit.addSeparator()
  290. self.menueditorigin = self.menuedit.addAction(
  291. QtGui.QIcon(self.app.resource_location + '/origin16.png'), _('Se&t Origin\tO'))
  292. self.menueditjump = self.menuedit.addAction(
  293. QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location\tJ'))
  294. # Separator
  295. self.menuedit.addSeparator()
  296. self.menuedittoggleunits = self.menuedit.addAction(
  297. QtGui.QIcon(self.app.resource_location + '/toggle_units16.png'), _('Toggle Units\tQ'))
  298. self.menueditselectall = self.menuedit.addAction(
  299. QtGui.QIcon(self.app.resource_location + '/select_all.png'), _('&Select All\tCTRL+A'))
  300. # Separator
  301. self.menuedit.addSeparator()
  302. self.menueditpreferences = self.menuedit.addAction(
  303. QtGui.QIcon(self.app.resource_location + '/pref.png'), _('&Preferences\tSHIFT+P'))
  304. # ########################################################################
  305. # ########################## OPTIONS # ###################################
  306. # ########################################################################
  307. self.menuoptions = self.menu.addMenu(_('Options'))
  308. self.menuoptions_transform_rotate = self.menuoptions.addAction(
  309. QtGui.QIcon(self.app.resource_location + '/rotate.png'), _("&Rotate Selection\tSHIFT+(R)"))
  310. # Separator
  311. self.menuoptions.addSeparator()
  312. self.menuoptions_transform_skewx = self.menuoptions.addAction(
  313. QtGui.QIcon(self.app.resource_location + '/skewX.png'), _("&Skew on X axis\tSHIFT+X"))
  314. self.menuoptions_transform_skewy = self.menuoptions.addAction(
  315. QtGui.QIcon(self.app.resource_location + '/skewY.png'), _("S&kew on Y axis\tSHIFT+Y"))
  316. # Separator
  317. self.menuoptions.addSeparator()
  318. self.menuoptions_transform_flipx = self.menuoptions.addAction(
  319. QtGui.QIcon(self.app.resource_location + '/flipx.png'), _("Flip on &X axis\tX"))
  320. self.menuoptions_transform_flipy = self.menuoptions.addAction(
  321. QtGui.QIcon(self.app.resource_location + '/flipy.png'), _("Flip on &Y axis\tY"))
  322. # Separator
  323. self.menuoptions.addSeparator()
  324. self.menuoptions_view_source = self.menuoptions.addAction(
  325. QtGui.QIcon(self.app.resource_location + '/source32.png'), _("View source\tALT+S"))
  326. self.menuoptions_tools_db = self.menuoptions.addAction(
  327. QtGui.QIcon(self.app.resource_location + '/database32.png'), _("Tools DataBase\tCTRL+D"))
  328. # Separator
  329. self.menuoptions.addSeparator()
  330. # ########################################################################
  331. # ########################## View # ######################################
  332. # ########################################################################
  333. self.menuview = self.menu.addMenu(_('View'))
  334. self.menuviewenable = self.menuview.addAction(
  335. QtGui.QIcon(self.app.resource_location + '/replot16.png'), _('Enable all plots\tALT+1'))
  336. self.menuviewdisableall = self.menuview.addAction(
  337. QtGui.QIcon(self.app.resource_location + '/clear_plot16.png'), _('Disable all plots\tALT+2'))
  338. self.menuviewdisableother = self.menuview.addAction(
  339. QtGui.QIcon(self.app.resource_location + '/clear_plot16.png'), _('Disable non-selected\tALT+3'))
  340. # Separator
  341. self.menuview.addSeparator()
  342. self.menuview_zoom_fit = self.menuview.addAction(
  343. QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("&Zoom Fit\tV"))
  344. self.menuview_zoom_in = self.menuview.addAction(
  345. QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("&Zoom In\t="))
  346. self.menuview_zoom_out = self.menuview.addAction(
  347. QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("&Zoom Out\t-"))
  348. self.menuview.addSeparator()
  349. # Replot all
  350. self.menuview_replot = self.menuview.addAction(
  351. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("Redraw All\tF5"))
  352. self.menuview.addSeparator()
  353. self.menuview_toggle_code_editor = self.menuview.addAction(
  354. QtGui.QIcon(self.app.resource_location + '/code_editor32.png'), _('Toggle Code Editor\tSHIFT+E'))
  355. self.menuview.addSeparator()
  356. self.menuview_toggle_fscreen = self.menuview.addAction(
  357. QtGui.QIcon(self.app.resource_location + '/fscreen32.png'), _("&Toggle FullScreen\tALT+F10"))
  358. self.menuview_toggle_parea = self.menuview.addAction(
  359. QtGui.QIcon(self.app.resource_location + '/plot32.png'), _("&Toggle Plot Area\tCTRL+F10"))
  360. self.menuview_toggle_notebook = self.menuview.addAction(
  361. QtGui.QIcon(self.app.resource_location + '/notebook32.png'), _("&Toggle Project/Sel/Tool\t`"))
  362. self.menuview.addSeparator()
  363. self.menuview_toggle_grid = self.menuview.addAction(
  364. QtGui.QIcon(self.app.resource_location + '/grid32.png'), _("&Toggle Grid Snap\tG"))
  365. self.menuview_toggle_grid_lines = self.menuview.addAction(
  366. QtGui.QIcon(self.app.resource_location + '/grid32.png'), _("&Toggle Grid Lines\tALT+G"))
  367. self.menuview_toggle_axis = self.menuview.addAction(
  368. QtGui.QIcon(self.app.resource_location + '/axis32.png'), _("&Toggle Axis\tSHIFT+G"))
  369. self.menuview_toggle_workspace = self.menuview.addAction(
  370. QtGui.QIcon(self.app.resource_location + '/workspace24.png'), _("Toggle Workspace\tSHIFT+W"))
  371. # ########################################################################
  372. # ########################## Objects # ###################################
  373. # ########################################################################
  374. self.menuobjects = self.menu.addMenu(_('Objects'))
  375. self.menuobjects.addSeparator()
  376. self.menuobjects_selall = self.menuobjects.addAction(
  377. QtGui.QIcon(self.app.resource_location + '/select_all.png'), _('Select All'))
  378. self.menuobjects_unselall = self.menuobjects.addAction(
  379. QtGui.QIcon(self.app.resource_location + '/deselect_all32.png'), _('Deselect All')
  380. )
  381. # ########################################################################
  382. # ########################## Tool # ######################################
  383. # ########################################################################
  384. self.menutool = QtWidgets.QMenu(_('Tool'))
  385. self.menutoolaction = self.menu.addMenu(self.menutool)
  386. self.menutoolshell = self.menutool.addAction(
  387. QtGui.QIcon(self.app.resource_location + '/shell16.png'), _('&Command Line\tS'))
  388. # ########################################################################
  389. # ########################## Help # ######################################
  390. # ########################################################################
  391. self.menuhelp = self.menu.addMenu(_('Help'))
  392. self.menuhelp_manual = self.menuhelp.addAction(
  393. QtGui.QIcon(self.app.resource_location + '/globe16.png'), _('Online Help\tF1'))
  394. self.menuhelp_bookmarks = self.menuhelp.addMenu(
  395. QtGui.QIcon(self.app.resource_location + '/bookmarks16.png'), _('Bookmarks'))
  396. self.menuhelp_bookmarks.addSeparator()
  397. self.menuhelp_bookmarks_manager = self.menuhelp_bookmarks.addAction(
  398. QtGui.QIcon(self.app.resource_location + '/bookmarks16.png'), _('Bookmarks Manager'))
  399. self.menuhelp.addSeparator()
  400. self.menuhelp_report_bug = self.menuhelp.addAction(
  401. QtGui.QIcon(self.app.resource_location + '/bug16.png'), _('Report a bug'))
  402. self.menuhelp.addSeparator()
  403. self.menuhelp_exc_spec = self.menuhelp.addAction(
  404. QtGui.QIcon(self.app.resource_location + '/pdf_link16.png'), _('Excellon Specification'))
  405. self.menuhelp_gerber_spec = self.menuhelp.addAction(
  406. QtGui.QIcon(self.app.resource_location + '/pdf_link16.png'), _('Gerber Specification'))
  407. self.menuhelp.addSeparator()
  408. self.menuhelp_shortcut_list = self.menuhelp.addAction(
  409. QtGui.QIcon(self.app.resource_location + '/shortcuts24.png'), _('Shortcuts List\tF3'))
  410. self.menuhelp_videohelp = self.menuhelp.addAction(
  411. QtGui.QIcon(self.app.resource_location + '/youtube32.png'), _('YouTube Channel\tF4'))
  412. self.menuhelp_about = self.menuhelp.addAction(
  413. QtGui.QIcon(self.app.resource_location + '/about32.png'), _('About FlatCAM'))
  414. # ########################################################################
  415. # ########################## GEOMETRY EDITOR # ###########################
  416. # ########################################################################
  417. self.geo_editor_menu = QtWidgets.QMenu(">Geo Editor<")
  418. self.menu.addMenu(self.geo_editor_menu)
  419. self.geo_add_circle_menuitem = self.geo_editor_menu.addAction(
  420. QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle\tO')
  421. )
  422. self.geo_add_arc_menuitem = self.geo_editor_menu.addAction(
  423. QtGui.QIcon(self.app.resource_location + '/arc16.png'), _('Add Arc\tA'))
  424. self.geo_editor_menu.addSeparator()
  425. self.geo_add_rectangle_menuitem = self.geo_editor_menu.addAction(
  426. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle\tR')
  427. )
  428. self.geo_add_polygon_menuitem = self.geo_editor_menu.addAction(
  429. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon\tN')
  430. )
  431. self.geo_add_path_menuitem = self.geo_editor_menu.addAction(
  432. QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path\tP'))
  433. self.geo_editor_menu.addSeparator()
  434. self.geo_add_text_menuitem = self.geo_editor_menu.addAction(
  435. QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text\tT'))
  436. self.geo_editor_menu.addSeparator()
  437. self.geo_union_menuitem = self.geo_editor_menu.addAction(
  438. QtGui.QIcon(self.app.resource_location + '/union16.png'),_('Polygon Union\tU'))
  439. self.geo_intersection_menuitem = self.geo_editor_menu.addAction(
  440. QtGui.QIcon(self.app.resource_location + '/intersection16.png'), _('Polygon Intersection\tE'))
  441. self.geo_subtract_menuitem = self.geo_editor_menu.addAction(
  442. QtGui.QIcon(self.app.resource_location + '/subtract16.png'), _('Polygon Subtraction\tS')
  443. )
  444. self.geo_editor_menu.addSeparator()
  445. self.geo_cutpath_menuitem = self.geo_editor_menu.addAction(
  446. QtGui.QIcon(self.app.resource_location + '/cutpath16.png'), _('Cut Path\tX'))
  447. # self.move_menuitem = self.menu.addAction(QtGui.QIcon(self.app.resource_location + '/move16.png'), "Move Objects 'm'")
  448. self.geo_copy_menuitem = self.geo_editor_menu.addAction(
  449. QtGui.QIcon(self.app.resource_location + '/copy16.png'), _("Copy Geom\tC"))
  450. self.geo_delete_menuitem = self.geo_editor_menu.addAction(
  451. QtGui.QIcon(self.app.resource_location + '/deleteshape16.png'), _("Delete Shape\tDEL")
  452. )
  453. self.geo_editor_menu.addSeparator()
  454. self.geo_move_menuitem = self.geo_editor_menu.addAction(
  455. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move\tM"))
  456. self.geo_buffer_menuitem = self.geo_editor_menu.addAction(
  457. QtGui.QIcon(self.app.resource_location + '/buffer16.png'), _("Buffer Tool\tB")
  458. )
  459. self.geo_paint_menuitem = self.geo_editor_menu.addAction(
  460. QtGui.QIcon(self.app.resource_location + '/paint16.png'), _("Paint Tool\tI")
  461. )
  462. self.geo_transform_menuitem = self.geo_editor_menu.addAction(
  463. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool\tALT+R")
  464. )
  465. self.geo_editor_menu.addSeparator()
  466. self.geo_cornersnap_menuitem = self.geo_editor_menu.addAction(
  467. QtGui.QIcon(self.app.resource_location + '/corner32.png'), _("Toggle Corner Snap\tK")
  468. )
  469. # ########################################################################
  470. # ########################## EXCELLON Editor # ###########################
  471. # ########################################################################
  472. self.exc_editor_menu = QtWidgets.QMenu(_(">Excellon Editor<"))
  473. self.menu.addMenu(self.exc_editor_menu)
  474. self.exc_add_array_drill_menuitem = self.exc_editor_menu.addAction(
  475. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Drill Array\tA'))
  476. self.exc_add_drill_menuitem = self.exc_editor_menu.addAction(
  477. QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill\tD'))
  478. self.exc_editor_menu.addSeparator()
  479. self.exc_add_array_slot_menuitem = self.exc_editor_menu.addAction(
  480. QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array\tQ'))
  481. self.exc_add_slot_menuitem = self.exc_editor_menu.addAction(
  482. QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot\tW'))
  483. self.exc_editor_menu.addSeparator()
  484. self.exc_resize_drill_menuitem = self.exc_editor_menu.addAction(
  485. QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill(S)\tR')
  486. )
  487. self.exc_copy_drill_menuitem = self.exc_editor_menu.addAction(
  488. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy\tC'))
  489. self.exc_delete_drill_menuitem = self.exc_editor_menu.addAction(
  490. QtGui.QIcon(self.app.resource_location + '/deleteshape32.png'), _('Delete\tDEL')
  491. )
  492. self.exc_editor_menu.addSeparator()
  493. self.exc_move_drill_menuitem = self.exc_editor_menu.addAction(
  494. QtGui.QIcon(self.app.resource_location + '/move32.png'), _('Move Drill(s)\tM'))
  495. # ########################################################################
  496. # ########################## GERBER Editor # #############################
  497. # ########################################################################
  498. self.grb_editor_menu = QtWidgets.QMenu(_(">Gerber Editor<"))
  499. self.menu.addMenu(self.grb_editor_menu)
  500. self.grb_add_pad_menuitem = self.grb_editor_menu.addAction(
  501. QtGui.QIcon(self.app.resource_location + '/aperture16.png'), _('Add Pad\tP'))
  502. self.grb_add_pad_array_menuitem = self.grb_editor_menu.addAction(
  503. QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array\tA'))
  504. self.grb_add_track_menuitem = self.grb_editor_menu.addAction(
  505. QtGui.QIcon(self.app.resource_location + '/track32.png'), _('Add Track\tT'))
  506. self.grb_add_region_menuitem = self.grb_editor_menu.addAction(
  507. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Region\tN'))
  508. self.grb_editor_menu.addSeparator()
  509. self.grb_convert_poly_menuitem = self.grb_editor_menu.addAction(
  510. QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize\tALT+N"))
  511. self.grb_add_semidisc_menuitem = self.grb_editor_menu.addAction(
  512. QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("Add SemiDisc\tE"))
  513. self.grb_add_disc_menuitem = self.grb_editor_menu.addAction(
  514. QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Add Disc\tD"))
  515. self.grb_add_buffer_menuitem = self.grb_editor_menu.addAction(
  516. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer\tB'))
  517. self.grb_add_scale_menuitem = self.grb_editor_menu.addAction(
  518. QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale\tS'))
  519. self.grb_add_markarea_menuitem = self.grb_editor_menu.addAction(
  520. QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area\tALT+A'))
  521. self.grb_add_eraser_menuitem = self.grb_editor_menu.addAction(
  522. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser\tCTRL+E'))
  523. self.grb_transform_menuitem = self.grb_editor_menu.addAction(
  524. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform\tALT+R"))
  525. self.grb_editor_menu.addSeparator()
  526. self.grb_copy_menuitem = self.grb_editor_menu.addAction(
  527. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy\tC'))
  528. self.grb_delete_menuitem = self.grb_editor_menu.addAction(
  529. QtGui.QIcon(self.app.resource_location + '/deleteshape32.png'), _('Delete\tDEL'))
  530. self.grb_editor_menu.addSeparator()
  531. self.grb_move_menuitem = self.grb_editor_menu.addAction(
  532. QtGui.QIcon(self.app.resource_location + '/move32.png'), _('Move\tM'))
  533. self.grb_editor_menu.menuAction().setVisible(False)
  534. self.grb_editor_menu.setDisabled(True)
  535. self.geo_editor_menu.menuAction().setVisible(False)
  536. self.geo_editor_menu.setDisabled(True)
  537. self.exc_editor_menu.menuAction().setVisible(False)
  538. self.exc_editor_menu.setDisabled(True)
  539. # ########################################################################
  540. # ########################## Project Tab Context Menu # ##################
  541. # ########################################################################
  542. self.menuproject = QtWidgets.QMenu()
  543. self.menuprojectenable = self.menuproject.addAction(
  544. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _('Enable Plot'))
  545. self.menuprojectdisable = self.menuproject.addAction(
  546. QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _('Disable Plot'))
  547. self.menuproject.addSeparator()
  548. self.menuprojectcolor = self.menuproject.addMenu(
  549. QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Set Color'))
  550. self.menuproject_red = self.menuprojectcolor.addAction(
  551. QtGui.QIcon(self.app.resource_location + '/red32.png'), _('Red'))
  552. self.menuproject_blue = self.menuprojectcolor.addAction(
  553. QtGui.QIcon(self.app.resource_location + '/blue32.png'), _('Blue'))
  554. self.menuproject_yellow = self.menuprojectcolor.addAction(
  555. QtGui.QIcon(self.app.resource_location + '/yellow32.png'), _('Yellow'))
  556. self.menuproject_green = self.menuprojectcolor.addAction(
  557. QtGui.QIcon(self.app.resource_location + '/green32.png'), _('Green'))
  558. self.menuproject_purple = self.menuprojectcolor.addAction(
  559. QtGui.QIcon(self.app.resource_location + '/violet32.png'), _('Purple'))
  560. self.menuproject_brown = self.menuprojectcolor.addAction(
  561. QtGui.QIcon(self.app.resource_location + '/brown32.png'), _('Brown'))
  562. self.menuproject_custom = self.menuprojectcolor.addAction(
  563. QtGui.QIcon(self.app.resource_location + '/set_color32.png'), _('Custom'))
  564. self.menuproject.addSeparator()
  565. self.menuprojectgeneratecnc = self.menuproject.addAction(
  566. QtGui.QIcon(self.app.resource_location + '/cnc32.png'), _('Generate CNC'))
  567. self.menuprojectviewsource = self.menuproject.addAction(
  568. QtGui.QIcon(self.app.resource_location + '/source32.png'), _('View Source'))
  569. self.menuprojectedit = self.menuproject.addAction(
  570. QtGui.QIcon(self.app.resource_location + '/edit_ok32.png'), _('Edit'))
  571. self.menuprojectcopy = self.menuproject.addAction(
  572. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy'))
  573. self.menuprojectdelete = self.menuproject.addAction(
  574. QtGui.QIcon(self.app.resource_location + '/delete32.png'), _('Delete'))
  575. self.menuprojectsave = self.menuproject.addAction(
  576. QtGui.QIcon(self.app.resource_location + '/save_as.png'), _('Save'))
  577. self.menuproject.addSeparator()
  578. self.menuprojectproperties = self.menuproject.addAction(
  579. QtGui.QIcon(self.app.resource_location + '/properties32.png'), _('Properties'))
  580. # ########################################################################
  581. # ####################### Central Widget -> Splitter # ##################
  582. # ########################################################################
  583. # IMPORTANT #
  584. # The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
  585. # desired.
  586. self.splitter = QtWidgets.QSplitter()
  587. self.setCentralWidget(self.splitter)
  588. # self.notebook = QtWidgets.QTabWidget()
  589. self.notebook = FCDetachableTab(protect=True)
  590. self.notebook.setTabsClosable(False)
  591. self.notebook.useOldIndex(True)
  592. self.splitter.addWidget(self.notebook)
  593. self.splitter_left = QtWidgets.QSplitter(Qt.Vertical)
  594. self.splitter.addWidget(self.splitter_left)
  595. self.splitter_left.addWidget(self.notebook)
  596. self.splitter_left.setHandleWidth(0)
  597. # ########################################################################
  598. # ########################## ToolBAR # ###################################
  599. # ########################################################################
  600. # ## TOOLBAR INSTALLATION ###
  601. self.toolbarfile = QtWidgets.QToolBar(_('File Toolbar'))
  602. self.toolbarfile.setObjectName('File_TB')
  603. self.addToolBar(self.toolbarfile)
  604. self.toolbargeo = QtWidgets.QToolBar(_('Edit Toolbar'))
  605. self.toolbargeo.setObjectName('Edit_TB')
  606. self.addToolBar(self.toolbargeo)
  607. self.toolbarview = QtWidgets.QToolBar(_('View Toolbar'))
  608. self.toolbarview.setObjectName('View_TB')
  609. self.addToolBar(self.toolbarview)
  610. self.toolbarshell = QtWidgets.QToolBar(_('Shell Toolbar'))
  611. self.toolbarshell.setObjectName('Shell_TB')
  612. self.addToolBar(self.toolbarshell)
  613. self.toolbartools = QtWidgets.QToolBar(_('Tools Toolbar'))
  614. self.toolbartools.setObjectName('Tools_TB')
  615. self.addToolBar(self.toolbartools)
  616. self.exc_edit_toolbar = QtWidgets.QToolBar(_('Excellon Editor Toolbar'))
  617. self.exc_edit_toolbar.setObjectName('ExcEditor_TB')
  618. self.addToolBar(self.exc_edit_toolbar)
  619. self.addToolBarBreak()
  620. self.geo_edit_toolbar = QtWidgets.QToolBar(_('Geometry Editor Toolbar'))
  621. self.geo_edit_toolbar.setObjectName('GeoEditor_TB')
  622. self.addToolBar(self.geo_edit_toolbar)
  623. self.grb_edit_toolbar = QtWidgets.QToolBar(_('Gerber Editor Toolbar'))
  624. self.grb_edit_toolbar.setObjectName('GrbEditor_TB')
  625. self.addToolBar(self.grb_edit_toolbar)
  626. self.snap_toolbar = QtWidgets.QToolBar(_('Grid Toolbar'))
  627. self.snap_toolbar.setObjectName('Snap_TB')
  628. self.addToolBar(self.snap_toolbar)
  629. settings = QSettings("Open Source", "FlatCAM")
  630. if settings.contains("layout"):
  631. layout = settings.value('layout', type=str)
  632. if layout == 'standard':
  633. pass
  634. elif layout == 'compact':
  635. self.removeToolBar(self.snap_toolbar)
  636. self.snap_toolbar.setMaximumHeight(30)
  637. self.splitter_left.addWidget(self.snap_toolbar)
  638. # ########################################################################
  639. # ########################## File Toolbar# ###############################
  640. # ########################################################################
  641. self.file_open_gerber_btn = self.toolbarfile.addAction(
  642. QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _("Open Gerber"))
  643. self.file_open_excellon_btn = self.toolbarfile.addAction(
  644. QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Open Excellon"))
  645. self.toolbarfile.addSeparator()
  646. self.file_open_btn = self.toolbarfile.addAction(
  647. QtGui.QIcon(self.app.resource_location + '/folder32.png'), _("Open project"))
  648. self.file_save_btn = self.toolbarfile.addAction(
  649. QtGui.QIcon(self.app.resource_location + '/project_save32.png'), _("Save project"))
  650. # ########################################################################
  651. # ########################## Edit Toolbar# ###############################
  652. # ########################################################################
  653. self.newgeo_btn = self.toolbargeo.addAction(
  654. QtGui.QIcon(self.app.resource_location + '/new_file_geo32.png'), _("New Blank Geometry"))
  655. self.newgrb_btn = self.toolbargeo.addAction(
  656. QtGui.QIcon(self.app.resource_location + '/new_file_grb32.png'), _("New Blank Gerber"))
  657. self.newexc_btn = self.toolbargeo.addAction(
  658. QtGui.QIcon(self.app.resource_location + '/new_file_exc32.png'), _("New Blank Excellon"))
  659. self.toolbargeo.addSeparator()
  660. self.editgeo_btn = self.toolbargeo.addAction(
  661. QtGui.QIcon(self.app.resource_location + '/edit_file32.png'), _("Editor"))
  662. self.update_obj_btn = self.toolbargeo.addAction(
  663. QtGui.QIcon(self.app.resource_location + '/close_edit_file32.png'), _("Save Object and close the Editor")
  664. )
  665. self.toolbargeo.addSeparator()
  666. self.copy_btn = self.toolbargeo.addAction(
  667. QtGui.QIcon(self.app.resource_location + '/copy_file32.png'), _("Copy"))
  668. self.delete_btn = self.toolbargeo.addAction(
  669. QtGui.QIcon(self.app.resource_location + '/delete_file32.png'), _("&Delete"))
  670. self.toolbargeo.addSeparator()
  671. self.distance_btn = self.toolbargeo.addAction(
  672. QtGui.QIcon(self.app.resource_location + '/distance32.png'), _("Distance Tool"))
  673. self.distance_min_btn = self.toolbargeo.addAction(
  674. QtGui.QIcon(self.app.resource_location + '/distance_min32.png'), _("Distance Min Tool"))
  675. self.origin_btn = self.toolbargeo.addAction(
  676. QtGui.QIcon(self.app.resource_location + '/origin32.png'), _('Set Origin'))
  677. self.jmp_btn = self.toolbargeo.addAction(
  678. QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location'))
  679. # ########################################################################
  680. # ########################## View Toolbar# ###############################
  681. # ########################################################################
  682. self.replot_btn = self.toolbarview.addAction(
  683. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("&Replot"))
  684. self.clear_plot_btn = self.toolbarview.addAction(
  685. QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("&Clear plot"))
  686. self.zoom_in_btn = self.toolbarview.addAction(
  687. QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("Zoom In"))
  688. self.zoom_out_btn = self.toolbarview.addAction(
  689. QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("Zoom Out"))
  690. self.zoom_fit_btn = self.toolbarview.addAction(
  691. QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
  692. # self.toolbarview.setVisible(False)
  693. # ########################################################################
  694. # ########################## Shell Toolbar# ##############################
  695. # ########################################################################
  696. self.shell_btn = self.toolbarshell.addAction(
  697. QtGui.QIcon(self.app.resource_location + '/shell32.png'), _("&Command Line"))
  698. self.new_script_btn = self.toolbarshell.addAction(
  699. QtGui.QIcon(self.app.resource_location + '/script_new24.png'), _('New Script ...'))
  700. self.open_script_btn = self.toolbarshell.addAction(
  701. QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'))
  702. self.run_script_btn = self.toolbarshell.addAction(
  703. QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Run Script ...'))
  704. # ########################################################################
  705. # ########################## Tools Toolbar# ##############################
  706. # ########################################################################
  707. self.dblsided_btn = self.toolbartools.addAction(
  708. QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2Sided Tool"))
  709. self.cutout_btn = self.toolbartools.addAction(
  710. QtGui.QIcon(self.app.resource_location + '/cut16_bis.png'), _("Cutout Tool"))
  711. self.ncc_btn = self.toolbartools.addAction(
  712. QtGui.QIcon(self.app.resource_location + '/ncc16.png'), _("NCC Tool"))
  713. self.paint_btn = self.toolbartools.addAction(
  714. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint Tool"))
  715. self.toolbartools.addSeparator()
  716. self.panelize_btn = self.toolbartools.addAction(
  717. QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel Tool"))
  718. self.film_btn = self.toolbartools.addAction(
  719. QtGui.QIcon(self.app.resource_location + '/film16.png'), _("Film Tool"))
  720. self.solder_btn = self.toolbartools.addAction(
  721. QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'), _("SolderPaste Tool"))
  722. self.sub_btn = self.toolbartools.addAction(
  723. QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool"))
  724. self.rules_btn = self.toolbartools.addAction(
  725. QtGui.QIcon(self.app.resource_location + '/rules32.png'), _("Rules Tool"))
  726. self.optimal_btn = self.toolbartools.addAction(
  727. QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'), _("Optimal Tool"))
  728. self.toolbartools.addSeparator()
  729. self.calculators_btn = self.toolbartools.addAction(
  730. QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators Tool"))
  731. self.transform_btn = self.toolbartools.addAction(
  732. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool"))
  733. self.qrcode_btn = self.toolbartools.addAction(
  734. QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode Tool"))
  735. self.copperfill_btn = self.toolbartools.addAction(
  736. QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving Tool"))
  737. self.fiducials_btn = self.toolbartools.addAction(
  738. QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials Tool"))
  739. self.cal_btn = self.toolbartools.addAction(
  740. QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool"))
  741. # ########################################################################
  742. # ########################## Excellon Editor Toolbar# ####################
  743. # ########################################################################
  744. self.select_drill_btn = self.exc_edit_toolbar.addAction(
  745. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  746. self.add_drill_btn = self.exc_edit_toolbar.addAction(
  747. QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill Hole'))
  748. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  749. QtGui.QIcon(self.app.resource_location + '/addarray16.png'), _('Add Drill Hole Array'))
  750. self.add_slot_btn = self.exc_edit_toolbar.addAction(
  751. QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot'))
  752. self.add_slot_array_btn = self.exc_edit_toolbar.addAction(
  753. QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array'))
  754. self.resize_drill_btn = self.exc_edit_toolbar.addAction(
  755. QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill'))
  756. self.exc_edit_toolbar.addSeparator()
  757. self.copy_drill_btn = self.exc_edit_toolbar.addAction(
  758. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy Drill'))
  759. self.delete_drill_btn = self.exc_edit_toolbar.addAction(
  760. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Drill"))
  761. self.exc_edit_toolbar.addSeparator()
  762. self.move_drill_btn = self.exc_edit_toolbar.addAction(
  763. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Drill"))
  764. # ########################################################################
  765. # ########################## Geometry Editor Toolbar# ####################
  766. # ########################################################################
  767. self.geo_select_btn = self.geo_edit_toolbar.addAction(
  768. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  769. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(
  770. QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle'))
  771. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(
  772. QtGui.QIcon(self.app.resource_location + '/arc32.png'), _('Add Arc'))
  773. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(
  774. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle'))
  775. self.geo_edit_toolbar.addSeparator()
  776. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(
  777. QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path'))
  778. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(
  779. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon'))
  780. self.geo_edit_toolbar.addSeparator()
  781. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(
  782. QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text'))
  783. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(
  784. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Add Buffer'))
  785. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(
  786. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _('Paint Shape'))
  787. self.geo_eraser_btn = self.geo_edit_toolbar.addAction(
  788. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  789. self.geo_edit_toolbar.addSeparator()
  790. self.geo_union_btn = self.geo_edit_toolbar.addAction(
  791. QtGui.QIcon(self.app.resource_location + '/union32.png'), _('Polygon Union'))
  792. self.geo_explode_btn = self.geo_edit_toolbar.addAction(
  793. QtGui.QIcon(self.app.resource_location + '/explode32.png'), _('Polygon Explode'))
  794. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(
  795. QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _('Polygon Intersection'))
  796. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(
  797. QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _('Polygon Subtraction'))
  798. self.geo_edit_toolbar.addSeparator()
  799. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(
  800. QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _('Cut Path'))
  801. self.geo_copy_btn = self.geo_edit_toolbar.addAction(
  802. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy Shape(s)"))
  803. self.geo_delete_btn = self.geo_edit_toolbar.addAction(
  804. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Shape '-'"))
  805. self.geo_transform_btn = self.geo_edit_toolbar.addAction(
  806. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  807. self.geo_edit_toolbar.addSeparator()
  808. self.geo_move_btn = self.geo_edit_toolbar.addAction(
  809. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Objects "))
  810. # ########################################################################
  811. # ########################## Gerber Editor Toolbar# ######################
  812. # ########################################################################
  813. self.grb_select_btn = self.grb_edit_toolbar.addAction(
  814. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  815. self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(
  816. QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Add Pad"))
  817. self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(
  818. QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array'))
  819. self.grb_add_track_btn = self.grb_edit_toolbar.addAction(
  820. QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Add Track"))
  821. self.grb_add_region_btn = self.grb_edit_toolbar.addAction(
  822. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Add Region"))
  823. self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(
  824. QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
  825. self.grb_add_semidisc_btn = self.grb_edit_toolbar.addAction(
  826. QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
  827. self.grb_add_disc_btn = self.grb_edit_toolbar.addAction(
  828. QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
  829. self.grb_edit_toolbar.addSeparator()
  830. self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(
  831. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer'))
  832. self.aperture_scale_btn = self.grb_edit_toolbar.addAction(
  833. QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale'))
  834. self.aperture_markarea_btn = self.grb_edit_toolbar.addAction(
  835. QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area'))
  836. self.aperture_eraser_btn = self.grb_edit_toolbar.addAction(
  837. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  838. self.grb_edit_toolbar.addSeparator()
  839. self.aperture_copy_btn = self.grb_edit_toolbar.addAction(
  840. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
  841. self.aperture_delete_btn = self.grb_edit_toolbar.addAction(
  842. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete"))
  843. self.grb_transform_btn = self.grb_edit_toolbar.addAction(
  844. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  845. self.grb_edit_toolbar.addSeparator()
  846. self.aperture_move_btn = self.grb_edit_toolbar.addAction(
  847. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
  848. # ########################################################################
  849. # ########################## Snap Toolbar# ###############################
  850. # ########################################################################
  851. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  852. self.grid_snap_btn = self.snap_toolbar.addAction(
  853. QtGui.QIcon(self.app.resource_location + '/grid32.png'), _('Snap to grid'))
  854. self.grid_gap_x_entry = FCEntry2()
  855. self.grid_gap_x_entry.setMaximumWidth(70)
  856. self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
  857. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  858. self.grid_gap_y_entry = FCEntry2()
  859. self.grid_gap_y_entry.setMaximumWidth(70)
  860. self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
  861. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  862. self.grid_space_label = QtWidgets.QLabel(" ")
  863. self.snap_toolbar.addWidget(self.grid_space_label)
  864. self.grid_gap_link_cb = FCCheckBox()
  865. self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
  866. "is copied to the Grid_Y value."))
  867. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  868. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  869. self.corner_snap_btn = self.snap_toolbar.addAction(
  870. QtGui.QIcon(self.app.resource_location + '/corner32.png'), _('Snap to corner'))
  871. self.snap_max_dist_entry = FCEntry()
  872. self.snap_max_dist_entry.setMaximumWidth(70)
  873. self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
  874. self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  875. # ########################################################################
  876. # ########################## Notebook # ##################################
  877. # ########################################################################
  878. # ########################################################################
  879. # ########################## PROJECT Tab # ###############################
  880. # ########################################################################
  881. self.project_tab = QtWidgets.QWidget()
  882. self.project_tab.setObjectName("project_tab")
  883. self.project_frame_lay = QtWidgets.QVBoxLayout(self.project_tab)
  884. self.project_frame_lay.setContentsMargins(0, 0, 0, 0)
  885. self.project_frame = QtWidgets.QFrame()
  886. self.project_frame.setContentsMargins(0, 0, 0, 0)
  887. self.project_frame_lay.addWidget(self.project_frame)
  888. self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_frame)
  889. self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
  890. self.notebook.addTab(self.project_tab, _("Project"))
  891. self.project_frame.setDisabled(False)
  892. # ########################################################################
  893. # ########################## SELECTED Tab # ##############################
  894. # ########################################################################
  895. self.selected_tab = QtWidgets.QWidget()
  896. self.selected_tab.setObjectName("selected_tab")
  897. self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab)
  898. self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
  899. self.selected_scroll_area = VerticalScrollArea()
  900. self.selected_tab_layout.addWidget(self.selected_scroll_area)
  901. self.notebook.addTab(self.selected_tab, _("Selected"))
  902. # ########################################################################
  903. # ########################## TOOL Tab # ##################################
  904. # ########################################################################
  905. self.tool_tab = QtWidgets.QWidget()
  906. self.tool_tab.setObjectName("tool_tab")
  907. self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab)
  908. self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
  909. self.notebook.addTab(self.tool_tab, _("Tool"))
  910. self.tool_scroll_area = VerticalScrollArea()
  911. self.tool_tab_layout.addWidget(self.tool_scroll_area)
  912. # ########################################################################
  913. # ########################## RIGHT Widget # ##############################
  914. # ########################################################################
  915. self.right_widget = QtWidgets.QWidget()
  916. self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
  917. self.splitter.addWidget(self.right_widget)
  918. self.right_lay = QtWidgets.QVBoxLayout()
  919. self.right_lay.setContentsMargins(0, 0, 0, 0)
  920. self.right_widget.setLayout(self.right_lay)
  921. # ########################################################################
  922. # ########################## PLOT AREA Tab # #############################
  923. # ########################################################################
  924. self.plot_tab_area = FCDetachableTab2(protect=False, protect_by_name=[_('Plot Area')])
  925. self.plot_tab_area.useOldIndex(True)
  926. self.right_lay.addWidget(self.plot_tab_area)
  927. self.plot_tab_area.setTabsClosable(True)
  928. self.plot_tab = QtWidgets.QWidget()
  929. self.plot_tab.setObjectName("plotarea")
  930. self.plot_tab_area.addTab(self.plot_tab, _("Plot Area"))
  931. self.right_layout = QtWidgets.QVBoxLayout()
  932. self.right_layout.setObjectName("right_layout")
  933. self.right_layout.setContentsMargins(2, 2, 2, 2)
  934. self.plot_tab.setLayout(self.right_layout)
  935. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  936. self.plot_tab_area.protectTab(0)
  937. # ########################################################################
  938. # ########################## PREFERENCES AREA Tab # ######################
  939. # ########################################################################
  940. self.preferences_tab = QtWidgets.QWidget()
  941. self.preferences_tab.setObjectName("preferences_tab")
  942. self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
  943. self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
  944. self.pref_tab_area = FCTab()
  945. self.pref_tab_area.setTabsClosable(False)
  946. self.pref_tab_area_tabBar = self.pref_tab_area.tabBar()
  947. self.pref_tab_area_tabBar.setStyleSheet("QTabBar::tab{min-width:90px;}")
  948. self.pref_tab_area_tabBar.setExpanding(True)
  949. self.pref_tab_layout.addWidget(self.pref_tab_area)
  950. self.general_tab = QtWidgets.QWidget()
  951. self.general_tab.setObjectName("general_tab")
  952. self.pref_tab_area.addTab(self.general_tab, _("General"))
  953. self.general_tab_lay = QtWidgets.QVBoxLayout()
  954. self.general_tab_lay.setContentsMargins(2, 2, 2, 2)
  955. self.general_tab.setLayout(self.general_tab_lay)
  956. self.hlay1 = QtWidgets.QHBoxLayout()
  957. self.general_tab_lay.addLayout(self.hlay1)
  958. self.hlay1.addStretch()
  959. self.general_scroll_area = QtWidgets.QScrollArea()
  960. self.general_tab_lay.addWidget(self.general_scroll_area)
  961. self.gerber_tab = QtWidgets.QWidget()
  962. self.gerber_tab.setObjectName("gerber_tab")
  963. self.pref_tab_area.addTab(self.gerber_tab, _("GERBER"))
  964. self.gerber_tab_lay = QtWidgets.QVBoxLayout()
  965. self.gerber_tab_lay.setContentsMargins(2, 2, 2, 2)
  966. self.gerber_tab.setLayout(self.gerber_tab_lay)
  967. self.gerber_scroll_area = QtWidgets.QScrollArea()
  968. self.gerber_tab_lay.addWidget(self.gerber_scroll_area)
  969. self.excellon_tab = QtWidgets.QWidget()
  970. self.excellon_tab.setObjectName("excellon_tab")
  971. self.pref_tab_area.addTab(self.excellon_tab, _("EXCELLON"))
  972. self.excellon_tab_lay = QtWidgets.QVBoxLayout()
  973. self.excellon_tab_lay.setContentsMargins(2, 2, 2, 2)
  974. self.excellon_tab.setLayout(self.excellon_tab_lay)
  975. self.excellon_scroll_area = QtWidgets.QScrollArea()
  976. self.excellon_tab_lay.addWidget(self.excellon_scroll_area)
  977. self.geometry_tab = QtWidgets.QWidget()
  978. self.geometry_tab.setObjectName("geometry_tab")
  979. self.pref_tab_area.addTab(self.geometry_tab, _("GEOMETRY"))
  980. self.geometry_tab_lay = QtWidgets.QVBoxLayout()
  981. self.geometry_tab_lay.setContentsMargins(2, 2, 2, 2)
  982. self.geometry_tab.setLayout(self.geometry_tab_lay)
  983. self.geometry_scroll_area = QtWidgets.QScrollArea()
  984. self.geometry_tab_lay.addWidget(self.geometry_scroll_area)
  985. self.text_editor_tab = QtWidgets.QWidget()
  986. self.text_editor_tab.setObjectName("text_editor_tab")
  987. self.pref_tab_area.addTab(self.text_editor_tab, _("CNC-JOB"))
  988. self.cncjob_tab_lay = QtWidgets.QVBoxLayout()
  989. self.cncjob_tab_lay.setContentsMargins(2, 2, 2, 2)
  990. self.text_editor_tab.setLayout(self.cncjob_tab_lay)
  991. self.cncjob_scroll_area = QtWidgets.QScrollArea()
  992. self.cncjob_tab_lay.addWidget(self.cncjob_scroll_area)
  993. self.tools_tab = QtWidgets.QWidget()
  994. self.pref_tab_area.addTab(self.tools_tab, _("TOOLS"))
  995. self.tools_tab_lay = QtWidgets.QVBoxLayout()
  996. self.tools_tab_lay.setContentsMargins(2, 2, 2, 2)
  997. self.tools_tab.setLayout(self.tools_tab_lay)
  998. self.tools_scroll_area = QtWidgets.QScrollArea()
  999. self.tools_tab_lay.addWidget(self.tools_scroll_area)
  1000. self.tools2_tab = QtWidgets.QWidget()
  1001. self.pref_tab_area.addTab(self.tools2_tab, _("TOOLS 2"))
  1002. self.tools2_tab_lay = QtWidgets.QVBoxLayout()
  1003. self.tools2_tab_lay.setContentsMargins(2, 2, 2, 2)
  1004. self.tools2_tab.setLayout(self.tools2_tab_lay)
  1005. self.tools2_scroll_area = QtWidgets.QScrollArea()
  1006. self.tools2_tab_lay.addWidget(self.tools2_scroll_area)
  1007. self.fa_tab = QtWidgets.QWidget()
  1008. self.fa_tab.setObjectName("fa_tab")
  1009. self.pref_tab_area.addTab(self.fa_tab, _("UTILITIES"))
  1010. self.fa_tab_lay = QtWidgets.QVBoxLayout()
  1011. self.fa_tab_lay.setContentsMargins(2, 2, 2, 2)
  1012. self.fa_tab.setLayout(self.fa_tab_lay)
  1013. self.fa_scroll_area = QtWidgets.QScrollArea()
  1014. self.fa_tab_lay.addWidget(self.fa_scroll_area)
  1015. self.pref_tab_bottom_layout = QtWidgets.QHBoxLayout()
  1016. self.pref_tab_bottom_layout.setAlignment(QtCore.Qt.AlignVCenter)
  1017. self.pref_tab_layout.addLayout(self.pref_tab_bottom_layout)
  1018. self.pref_tab_bottom_layout_1 = QtWidgets.QHBoxLayout()
  1019. self.pref_tab_bottom_layout_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1020. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_1)
  1021. self.pref_defaults_button = QtWidgets.QPushButton()
  1022. self.pref_defaults_button.setText(_("Restore Defaults"))
  1023. self.pref_defaults_button.setMinimumWidth(130)
  1024. self.pref_defaults_button.setToolTip(
  1025. _("Restore the entire set of default valaues\n"
  1026. "to the initial values loaded after first launch."))
  1027. self.pref_tab_bottom_layout_1.addWidget(self.pref_defaults_button)
  1028. self.pref_open_button = QtWidgets.QPushButton()
  1029. self.pref_open_button.setText(_("Open Pref Folder"))
  1030. self.pref_open_button.setMinimumWidth(130)
  1031. self.pref_open_button.setToolTip(
  1032. _("Open the folder where FlatCAM save the preferences files."))
  1033. self.pref_tab_bottom_layout_1.addWidget(self.pref_open_button)
  1034. # Clear Settings
  1035. self.clear_btn = FCButton('%s' % _('Clear GUI Settings'))
  1036. self.clear_btn.setMinimumWidth(130)
  1037. self.clear_btn.setToolTip(
  1038. _("Clear the GUI settings for FlatCAM,\n"
  1039. "such as: layout, gui state, style, hdpi support etc.")
  1040. )
  1041. self.pref_tab_bottom_layout_1.addWidget(self.clear_btn)
  1042. self.pref_tab_bottom_layout_2 = QtWidgets.QHBoxLayout()
  1043. self.pref_tab_bottom_layout_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  1044. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_2)
  1045. self.pref_apply_button = FCButton()
  1046. self.pref_apply_button.setText(_("Apply"))
  1047. self.pref_apply_button.setMinimumWidth(130)
  1048. self.pref_apply_button.setToolTip(
  1049. _("Apply the current preferences without saving to a file."))
  1050. self.pref_tab_bottom_layout_2.addWidget(self.pref_apply_button)
  1051. self.pref_save_button = QtWidgets.QPushButton()
  1052. self.pref_save_button.setText(_("Save"))
  1053. self.pref_save_button.setMinimumWidth(130)
  1054. self.pref_save_button.setToolTip(
  1055. _("Save the current settings in the 'current_defaults' file\n"
  1056. "which is the file storing the working default preferences."))
  1057. self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
  1058. self.pref_close_button = QtWidgets.QPushButton()
  1059. self.pref_close_button.setText(_("Cancel"))
  1060. self.pref_close_button.setMinimumWidth(130)
  1061. self.pref_close_button.setToolTip(
  1062. _("Will not save the changes and will close the preferences window."))
  1063. self.pref_tab_bottom_layout_2.addWidget(self.pref_close_button)
  1064. # ########################################################################
  1065. # #################### SHORTCUT LIST AREA Tab # ##########################
  1066. # ########################################################################
  1067. self.shortcuts_tab = QtWidgets.QWidget()
  1068. self.sh_tab_layout = QtWidgets.QVBoxLayout()
  1069. self.sh_tab_layout.setContentsMargins(2, 2, 2, 2)
  1070. self.shortcuts_tab.setLayout(self.sh_tab_layout)
  1071. self.sh_hlay = QtWidgets.QHBoxLayout()
  1072. self.sh_title = QtWidgets.QTextEdit(
  1073. _('<b>Shortcut Key List</b>'))
  1074. self.sh_title.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1075. self.sh_title.setFrameStyle(QtWidgets.QFrame.NoFrame)
  1076. self.sh_title.setMaximumHeight(30)
  1077. font = self.sh_title.font()
  1078. font.setPointSize(12)
  1079. self.sh_title.setFont(font)
  1080. self.sh_tab_layout.addWidget(self.sh_title)
  1081. self.sh_tab_layout.addLayout(self.sh_hlay)
  1082. self.app_sh_msg = (
  1083. '''<b>General Shortcut list</b><br>
  1084. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1085. <tbody>
  1086. <tr height="20">
  1087. <td height="20" width="89"><strong>F3</strong></td>
  1088. <td width="194"><span style="color:#006400"><strong>&nbsp;%s</strong></span></td>
  1089. </tr>
  1090. <tr height="20">
  1091. <td height="20">&nbsp;</td>
  1092. <td>&nbsp;</td>
  1093. </tr>
  1094. <tr height="20">
  1095. <td height="20"><strong>1</strong></td>
  1096. <td>&nbsp;%s</td>
  1097. </tr>
  1098. <tr height="20">
  1099. <td height="20"><strong>2</strong></td>
  1100. <td>&nbsp;%s</td>
  1101. </tr>
  1102. <tr height="20">
  1103. <td height="20"><strong>3</strong></td>
  1104. <td>&nbsp;%s</td>
  1105. </tr>
  1106. <tr height="20">
  1107. <td height="20">&nbsp;</td>
  1108. <td>&nbsp;</td>
  1109. </tr>
  1110. <tr height="20">
  1111. <td height="20"><strong>B</strong></td>
  1112. <td>&nbsp;%s</td>
  1113. </tr>
  1114. <tr height="20">
  1115. <td height="20"><strong>E</strong></td>
  1116. <td>&nbsp;%s</td>
  1117. </tr>
  1118. <tr height="20">
  1119. <td height="20"><strong>G</strong></td>
  1120. <td>&nbsp;%s</td>
  1121. </tr>
  1122. <tr height="20">
  1123. <td height="20"><strong>J</strong></td>
  1124. <td>&nbsp;%s</td>
  1125. </tr>
  1126. <tr height="20">
  1127. <td height="20"><strong>L</strong></td>
  1128. <td>&nbsp;%s</td>
  1129. </tr>
  1130. <tr height="20">
  1131. <td height="20"><strong>M</strong></td>
  1132. <td>&nbsp;%s</td>
  1133. </tr>
  1134. <tr height="20">
  1135. <td height="20"><strong>N</strong></td>
  1136. <td>&nbsp;%s</td>
  1137. </tr>
  1138. <tr height="20">
  1139. <td height="20"><strong>O</strong></td>
  1140. <td>&nbsp;%s</td>
  1141. </tr>
  1142. <tr height="20">
  1143. <td height="20"><strong>Q</strong></td>
  1144. <td>&nbsp;%s</td>
  1145. </tr>
  1146. <tr height="20">
  1147. <td height="20"><strong>P</strong></td>
  1148. <td>&nbsp;%s</td>
  1149. </tr>
  1150. <tr height="20">
  1151. <td height="20"><strong>R</strong></td>
  1152. <td>&nbsp;%s</td>
  1153. </tr>
  1154. <tr height="20">
  1155. <td height="20"><strong>S</strong></td>
  1156. <td>&nbsp;%s</td>
  1157. </tr>
  1158. <tr height="20">
  1159. <td height="20"><strong>T</strong></td>
  1160. <td>&nbsp;%s</td>
  1161. </tr>
  1162. <tr height="20">
  1163. <td height="20"><strong>V</strong></td>
  1164. <td>&nbsp;%s</td>
  1165. </tr>
  1166. <tr height="20">
  1167. <td height="20"><strong>X</strong></td>
  1168. <td>&nbsp;%s</td>
  1169. </tr>
  1170. <tr height="20">
  1171. <td height="20"><strong>Y</strong></td>
  1172. <td>&nbsp;%s</td>
  1173. </tr>
  1174. <tr height="20">
  1175. <td height="20"><strong>&#39;-&#39;</strong></td>
  1176. <td>&nbsp;%s</td>
  1177. </tr>
  1178. <tr height="20">
  1179. <td height="20"><strong>&#39;=&#39;</strong></td>
  1180. <td>&nbsp;%s</td>
  1181. </tr>
  1182. <tr height="20">
  1183. <td height="20">&nbsp;</td>
  1184. <td>&nbsp;</td>
  1185. </tr>
  1186. <tr height="20">
  1187. <td height="20"><strong>CTRL+A</strong></td>
  1188. <td>&nbsp;%s</td>
  1189. </tr>
  1190. <tr height="20">
  1191. <td height="20"><strong>CTRL+C</strong></td>
  1192. <td>&nbsp;%s</td>
  1193. </tr>
  1194. <tr height="20">
  1195. <td height="20"><strong>CTRL+D</strong></td>
  1196. <td>&nbsp;%s</td>
  1197. </tr>
  1198. <tr height="20">
  1199. <td height="20"><strong>CTRL+E</strong></td>
  1200. <td>&nbsp;%s</td>
  1201. </tr>
  1202. <tr height="20">
  1203. <td height="20"><strong>CTRL+G</strong></td>
  1204. <td>&nbsp;%s</td>
  1205. </tr>
  1206. <tr height="20">
  1207. <td height="20"><strong>CTRL+M</strong></td>
  1208. <td>&nbsp;%s</td>
  1209. </tr>
  1210. <tr height="20">
  1211. <td height="20"><strong>CTRL+N</strong></td>
  1212. <td>&nbsp;%s</td>
  1213. </tr>
  1214. <tr height="20">
  1215. <td height="20"><strong>CTRL+O</strong></td>
  1216. <td>&nbsp;%s</td>
  1217. </tr>
  1218. <tr height="20">
  1219. <td height="20"><strong>CTRL+P</strong></td>
  1220. <td>&nbsp;%s</td>
  1221. </tr>
  1222. <tr height="20">
  1223. <td height="20"><strong>CTRL+Q</strong></td>
  1224. <td>&nbsp;%s</td>
  1225. </tr>
  1226. <tr height="20">
  1227. <td height="20"><strong>CTRL+S</strong></td>
  1228. <td>&nbsp;%s</td>
  1229. </tr>
  1230. <tr height="20">
  1231. <td height="20"><strong>CTRL+F10</strong></td>
  1232. <td>&nbsp;%s</td>
  1233. </tr>
  1234. <tr height="20">
  1235. <td height="20">&nbsp;</td>
  1236. <td>&nbsp;</td>
  1237. </tr>
  1238. <tr height="20">
  1239. <td height="20"><strong>SHIFT+C</strong></td>
  1240. <td>&nbsp;%s</td>
  1241. </tr>
  1242. <tr height="20">
  1243. <td height="20"><strong>SHIFT+E</strong></td>
  1244. <td>&nbsp;%s</td>
  1245. </tr>
  1246. <tr height="20">
  1247. <td height="20"><strong>SHIFT+G</strong></td>
  1248. <td>&nbsp;%s</td>
  1249. </tr>
  1250. <tr height="20">
  1251. <td height="20"><strong>SHIFT+M</strong></td>
  1252. <td>&nbsp;%s</td>
  1253. </tr>
  1254. <tr height="20">
  1255. <td height="20"><strong>SHIFT+P</strong></td>
  1256. <td>&nbsp;%s</td>
  1257. </tr>
  1258. <tr height="20">
  1259. <td height="20"><strong>SHIFT+R</strong></td>
  1260. <td>&nbsp;%s</td>
  1261. </tr>
  1262. <tr height="20">
  1263. <td height="20"><strong>SHIFT+S</strong></td>
  1264. <td>&nbsp;%s</td>
  1265. </tr>
  1266. <tr height="20">
  1267. <td height="20"><strong>SHIFT+W</strong></td>
  1268. <td>&nbsp;%s</td>
  1269. </tr>
  1270. <tr height="20">
  1271. <td height="20"><strong>SHIFT+X</strong></td>
  1272. <td>&nbsp;%s</td>
  1273. </tr>
  1274. <tr height="20">
  1275. <td height="20"><strong>SHIFT+Y</strong></td>
  1276. <td>&nbsp;%s</td>
  1277. </tr>
  1278. <tr height="20">
  1279. <td height="20">&nbsp;</td>
  1280. <td>&nbsp;</td>
  1281. </tr>
  1282. <tr height="20">
  1283. <td height="20"><strong>ALT+C</strong></td>
  1284. <td>&nbsp;%s</td>
  1285. </tr>
  1286. <tr height="20">
  1287. <td height="20"><strong>ALT+D</strong></td>
  1288. <td>&nbsp;%s</td>
  1289. </tr>
  1290. <tr height="20">
  1291. <td height="20"><strong>ALT+E</strong></td>
  1292. <td>&nbsp;%s</td>
  1293. </tr>
  1294. <tr height="20">
  1295. <td height="20"><strong>ALT+J</strong></td>
  1296. <td>&nbsp;%s</td>
  1297. </tr>
  1298. <tr height="20">
  1299. <td height="20"><strong>ALT+K</strong></td>
  1300. <td>&nbsp;%s</td>
  1301. </tr>
  1302. <tr height="20">
  1303. <td height="20"><strong>ALT+L</strong></td>
  1304. <td>&nbsp;%s</td>
  1305. </tr>
  1306. <tr height="20">
  1307. <td height="20"><strong>ALT+N</strong></td>
  1308. <td>&nbsp;%s</td>
  1309. </tr>
  1310. <tr height="20">
  1311. <td height="20"><strong>ALT+O</strong></td>
  1312. <td>&nbsp;%s</td>
  1313. </tr>
  1314. <tr height="20">
  1315. <td height="20"><strong>ALT+P</strong></td>
  1316. <td>&nbsp;%s</td>
  1317. </tr>
  1318. <tr height="20">
  1319. <td height="20"><strong>ALT+Q</strong></td>
  1320. <td>&nbsp;%s</td>
  1321. </tr>
  1322. <tr height="20">
  1323. <td height="20"><strong>ALT+R</strong></td>
  1324. <td>&nbsp;%s</td>
  1325. </tr>
  1326. <tr height="20">
  1327. <td height="20"><strong>ALT+S</strong></td>
  1328. <td>&nbsp;%s</td>
  1329. </tr>
  1330. <tr height="20">
  1331. <td height="20"><strong>ALT+U</strong></td>
  1332. <td>&nbsp;%s</td>
  1333. </tr>
  1334. <tr height="20">
  1335. <td height="20"><strong>ALT+1</strong></td>
  1336. <td>&nbsp;%s</td>
  1337. </tr>
  1338. <tr height="20">
  1339. <td height="20"><strong>ALT+2</strong></td>
  1340. <td>&nbsp;%s</td>
  1341. </tr>
  1342. <tr height="20">
  1343. <td height="20"><strong>ALT+3</strong></td>
  1344. <td>&nbsp;%s</td>
  1345. </tr>
  1346. <tr height="20">
  1347. <td height="20"><strong>ALT+F10</strong></td>
  1348. <td>&nbsp;%s</td>
  1349. </tr>
  1350. <tr height="20">
  1351. <td height="20">&nbsp;</td>
  1352. <td>&nbsp;</td>
  1353. </tr>
  1354. <tr height="20">
  1355. <td height="20"><strong>CTRL+ALT+X</strong></td>
  1356. <td>&nbsp;%s</td>
  1357. </tr>
  1358. <tr height="20">
  1359. <td height="20">&nbsp;</td>
  1360. <td>&nbsp;</td>
  1361. </tr>
  1362. <tr height="20">
  1363. <td height="20"><strong>F1</strong></td>
  1364. <td>&nbsp;%s</td>
  1365. </tr>
  1366. <tr height="20">
  1367. <td height="20"><strong>F4</strong></td>
  1368. <td>&nbsp;%s</td>
  1369. </tr>
  1370. <tr height="20">
  1371. <td height="20"><strong>F5</strong></td>
  1372. <td>&nbsp;%s</td>
  1373. </tr>
  1374. <tr height="20">
  1375. <td height="20"><strong>Del</strong></td>
  1376. <td>&nbsp;%s</td>
  1377. </tr>
  1378. <tr height="20">
  1379. <td height="20"><strong>Del</strong></td>
  1380. <td>&nbsp;%s</td>
  1381. </tr>
  1382. <tr height="20">
  1383. <td height="20"><strong>'`'</strong></td>
  1384. <td>&nbsp;%s</td>
  1385. </tr>
  1386. <tr height="20">
  1387. <td height="20"><strong>SPACE</strong></td>
  1388. <td>&nbsp;%s</td>
  1389. </tr>
  1390. <tr height="20">
  1391. <td height="20"><strong>Escape</strong></td>
  1392. <td>&nbsp;%s</td>
  1393. </tr>
  1394. </tbody>
  1395. </table>
  1396. ''' %
  1397. (
  1398. _("SHOW SHORTCUT LIST"), _("Switch to Project Tab"), _("Switch to Selected Tab"),
  1399. _("Switch to Tool Tab"),
  1400. _("New Gerber"), _("Edit Object (if selected)"), _("Grid On/Off"), _("Jump to Coordinates"),
  1401. _("New Excellon"), _("Move Obj"), _("New Geometry"), _("Set Origin"), _("Change Units"),
  1402. _("Open Properties Tool"), _("Rotate by 90 degree CW"), _("Shell Toggle"),
  1403. _("Add a Tool (when in Geometry Selected Tab or in Tools NCC or Tools Paint)"), _("Zoom Fit"),
  1404. _("Flip on X_axis"), _("Flip on Y_axis"), _("Zoom Out"), _("Zoom In"),
  1405. # CTRL section
  1406. _("Select All"), _("Copy Obj"), _("Open Tools Database"),
  1407. _("Open Excellon File"), _("Open Gerber File"), _("Distance Tool"), _("New Project"),
  1408. _("Open Project"), _("Print (PDF)"), _("PDF Import Tool"), _("Save Project As"), _("Toggle Plot Area"),
  1409. # SHIFT section
  1410. _("Copy Obj_Name"),
  1411. _("Toggle Code Editor"), _("Toggle the axis"), _("Distance Minimum Tool"), _("Open Preferences Window"),
  1412. _("Rotate by 90 degree CCW"), _("Run a Script"), _("Toggle the workspace"), _("Skew on X axis"),
  1413. _("Skew on Y axis"),
  1414. # ALT section
  1415. _("Calculators Tool"), _("2-Sided PCB Tool"), _("Transformations Tool"), _("Fiducials Tool"),
  1416. _("Solder Paste Dispensing Tool"),
  1417. _("Film PCB Tool"), _("Non-Copper Clearing Tool"), _("Optimal Tool"),
  1418. _("Paint Area Tool"), _("QRCode Tool"), _("Rules Check Tool"),
  1419. _("View File Source"),
  1420. _("Cutout PCB Tool"), _("Enable all Plots"), _("Disable all Plots"), _("Disable Non-selected Plots"),
  1421. _("Toggle Full Screen"),
  1422. # CTRL + ALT section
  1423. _("Abort current task (gracefully)"),
  1424. # F keys section
  1425. _("Open Online Manual"),
  1426. _("Open Online Tutorials"), _("Refresh Plots"), _("Delete Object"), _("Alternate: Delete Tool"),
  1427. _("(left to Key_1)Toogle Notebook Area (Left Side)"), _("En(Dis)able Obj Plot"),
  1428. _("Deselects all objects")
  1429. )
  1430. )
  1431. self.sh_app = QtWidgets.QTextEdit()
  1432. self.sh_app.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1433. self.sh_app.setText(self.app_sh_msg)
  1434. self.sh_app.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  1435. self.sh_hlay.addWidget(self.sh_app)
  1436. editor_title = """
  1437. <b>%s</b><br>
  1438. <br>
  1439. """ % _("Editor Shortcut list")
  1440. geo_sh_messages = """
  1441. <strong><span style="color:#0000ff">%s</span></strong><br>
  1442. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1443. <tbody>
  1444. <tr height="20">
  1445. <td height="20" width="89"><strong>A</strong></td>
  1446. <td width="194">&nbsp;%s</td>
  1447. </tr>
  1448. <tr height="20">
  1449. <td height="20"><strong>B</strong></td>
  1450. <td>&nbsp;%s</td>
  1451. </tr>
  1452. <tr height="20">
  1453. <td height="20"><strong>C</strong></td>
  1454. <td>&nbsp;%s</td>
  1455. </tr>
  1456. <tr height="20">
  1457. <td height="20"><strong>D</strong></td>
  1458. <td>&nbsp;%s</td>
  1459. </tr>
  1460. <tr height="20">
  1461. <td height="20"><strong>E</strong></td>
  1462. <td>&nbsp;%s</td>
  1463. </tr>
  1464. <tr height="20">
  1465. <td height="20"><strong>I</strong></td>
  1466. <td>&nbsp;%s</td>
  1467. </tr>
  1468. <tr height="20">
  1469. <td height="20"><strong>J</strong></td>
  1470. <td>&nbsp;%s</td>
  1471. </tr>
  1472. <tr height="20">
  1473. <td height="20"><strong>K</strong></td>
  1474. <td>&nbsp;%s</td>
  1475. </tr>
  1476. <tr height="20">
  1477. <td height="20"><strong>M</strong></td>
  1478. <td>&nbsp;%s</td>
  1479. </tr>
  1480. <tr height="20">
  1481. <td height="20"><strong>M</strong></td>
  1482. <td>&nbsp;%s</td>
  1483. </tr>
  1484. <tr height="20">
  1485. <td height="20"><strong>N</strong></td>
  1486. <td>&nbsp;%s</td>
  1487. </tr>
  1488. <tr height="20">
  1489. <td height="20"><strong>O</strong></td>
  1490. <td>&nbsp;%s</td>
  1491. </tr>
  1492. <tr height="20">
  1493. <td height="20"><strong>P</strong></td>
  1494. <td>&nbsp;%s</td>
  1495. </tr>
  1496. <tr height="20">
  1497. <td height="20"><strong>R</strong></td>
  1498. <td>&nbsp;%s</td>
  1499. </tr>
  1500. <tr height="20">
  1501. <td height="20"><strong>S</strong></td>
  1502. <td>&nbsp;%s</td>
  1503. </tr>
  1504. <tr height="20">
  1505. <td height="20"><strong>T</strong></td>
  1506. <td>&nbsp;%s</td>
  1507. </tr>
  1508. <tr height="20">
  1509. <td height="20"><strong>U</strong></td>
  1510. <td>&nbsp;%s</td>
  1511. </tr>
  1512. <tr height="20">
  1513. <td height="20"><strong>X</strong></td>
  1514. <td>&nbsp;%s</td>
  1515. </tr>
  1516. <tr height="20">
  1517. <td height="20"><strong>Y</strong></td>
  1518. <td>&nbsp;%s</td>
  1519. </tr>
  1520. <tr height="20">
  1521. <td height="20">&nbsp;</td>
  1522. <td>&nbsp;</td>
  1523. </tr>
  1524. <tr height="20">
  1525. <td height="20"><strong>SHIFT+M</strong></td>
  1526. <td>&nbsp;%s</td>
  1527. </tr>
  1528. <tr height="20">
  1529. <td height="20"><strong>SHIFT+X</strong></td>
  1530. <td>&nbsp;%s</td>
  1531. </tr>
  1532. <tr height="20">
  1533. <td height="20"><strong>SHIFT+Y</strong></td>
  1534. <td>&nbsp;%s</td>
  1535. </tr>
  1536. <tr height="20">
  1537. <td height="20">&nbsp;</td>
  1538. <td>&nbsp;</td>
  1539. </tr>
  1540. <tr height="20">
  1541. <td height="20"><strong>ALT+R</strong></td>
  1542. <td>&nbsp;%s</td>
  1543. </tr>
  1544. <tr height="20">
  1545. <td height="20"><strong>ALT+X</strong></td>
  1546. <td>&nbsp;%s</td>
  1547. </tr>
  1548. <tr height="20">
  1549. <td height="20"><strong>ALT+Y</strong></td>
  1550. <td>&nbsp;%s</td>
  1551. </tr>
  1552. <tr height="20">
  1553. <td height="20">&nbsp;</td>
  1554. <td>&nbsp;</td>
  1555. </tr>
  1556. <tr height="20">
  1557. <td height="20"><strong>CTRL+M</strong></td>
  1558. <td>&nbsp;%s</td>
  1559. </tr>
  1560. <tr height="20">
  1561. <td height="20"><strong>CTRL+S</strong></td>
  1562. <td>&nbsp;%s</td>
  1563. </tr>
  1564. <tr height="20">
  1565. <td height="20"><strong>CTRL+X</strong></td>
  1566. <td>&nbsp;%s</td>
  1567. </tr>
  1568. <tr height="20">
  1569. <td height="20">&nbsp;</td>
  1570. <td>&nbsp;</td>
  1571. </tr>
  1572. <tr height="20">
  1573. <td height="20"><strong>Space</strong></td>
  1574. <td>&nbsp;%s</td>
  1575. </tr>
  1576. <tr height="20">
  1577. <td height="20"><strong>ENTER</strong></td>
  1578. <td>&nbsp;%s</td>
  1579. </tr>
  1580. <tr height="20">
  1581. <td height="20"><strong>ESC</strong></td>
  1582. <td>&nbsp;%s</td>
  1583. </tr>
  1584. <tr height="20">
  1585. <td height="20"><strong>Del</strong></td>
  1586. <td>&nbsp;%s</td>
  1587. </tr>
  1588. </tbody>
  1589. </table>
  1590. <br>
  1591. """ % (
  1592. _("GEOMETRY EDITOR"), _("Draw an Arc"), _("Buffer Tool"), _("Copy Geo Item"),
  1593. _("Within Add Arc will toogle the ARC direction: CW or CCW"), _("Polygon Intersection Tool"),
  1594. _("Geo Paint Tool"), _("Jump to Location (x, y)"), _("Toggle Corner Snap"), _("Move Geo Item"),
  1595. _("Within Add Arc will cycle through the ARC modes"), _("Draw a Polygon"), _("Draw a Circle"),
  1596. _("Draw a Path"), _("Draw Rectangle"), _("Polygon Subtraction Tool"), _("Add Text Tool"),
  1597. _("Polygon Union Tool"), _("Flip shape on X axis"), _("Flip shape on Y axis"), _("Distance Minimum Tool"),
  1598. _("Skew shape on X axis"), _("Skew shape on Y axis"), _("Editor Transformation Tool"),
  1599. _("Offset shape on X axis"), _("Offset shape on Y axis"), _("Distance Tool"),
  1600. _("Save Object and Exit Editor"), _("Polygon Cut Tool"),
  1601. _("Rotate Geometry"), _("Finish drawing for certain tools"), _("Abort and return to Select"),
  1602. _("Delete Shape")
  1603. )
  1604. exc_sh_messages = """
  1605. <br>
  1606. <strong><span style="color:#ff0000">%s</span></strong><br>
  1607. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1608. <tbody>
  1609. <tr height="20">
  1610. <td height="20" width="89"><strong>A</strong></td>
  1611. <td width="194">&nbsp;%s</td>
  1612. </tr>
  1613. <tr height="20">
  1614. <td height="20"><strong>C</strong></td>
  1615. <td>&nbsp;%s</td>
  1616. </tr>
  1617. <tr height="20">
  1618. <td height="20"><strong>D</strong></td>
  1619. <td>&nbsp;%s</td>
  1620. </tr>
  1621. <tr height="20">
  1622. <td height="20"><strong>J</strong></td>
  1623. <td>&nbsp;%s</td>
  1624. </tr>
  1625. <tr height="20">
  1626. <td height="20"><strong>M</strong></td>
  1627. <td>&nbsp;%s</td>
  1628. </tr>
  1629. <tr height="20">
  1630. <td height="20" width="89"><strong>Q</strong></td>
  1631. <td width="194">&nbsp;%s</td>
  1632. </tr>
  1633. <tr height="20">
  1634. <td height="20"><strong>R</strong></td>
  1635. <td>&nbsp;%s</td>
  1636. </tr>
  1637. <tr height="20">
  1638. <td height="20"><strong>T</strong></td>
  1639. <td>&nbsp;%s</td>
  1640. </tr>
  1641. <tr height="20">
  1642. <td height="20" width="89"><strong>W</strong></td>
  1643. <td width="194">&nbsp;%s</td>
  1644. </tr>
  1645. <tr height="20">
  1646. <td height="20">&nbsp;</td>
  1647. <td>&nbsp;</td>
  1648. </tr>
  1649. <tr height="20">
  1650. <td height="20"><strong>SHIFT+M</strong></td>
  1651. <td>&nbsp;%s</td>
  1652. </tr>
  1653. <tr height="20">
  1654. <td height="20">&nbsp;</td>
  1655. <td>&nbsp;</td>
  1656. </tr>
  1657. <tr height="20">
  1658. <td height="20"><strong>Del</strong></td>
  1659. <td>&nbsp;%s</td>
  1660. </tr>
  1661. <tr height="20">
  1662. <td height="20"><strong>Del</strong></td>
  1663. <td>&nbsp;%s</td>
  1664. </tr>
  1665. <tr height="20">
  1666. <td height="20">&nbsp;</td>
  1667. <td>&nbsp;</td>
  1668. </tr>
  1669. <tr height="20">
  1670. <td height="20"><strong>ESC</strong></td>
  1671. <td>&nbsp;%s</td>
  1672. </tr>
  1673. <tr height="20">
  1674. <td height="20"><strong>CTRL+S</strong></td>
  1675. <td>&nbsp;%s</td>
  1676. </tr>
  1677. </tbody>
  1678. </table>
  1679. <br>
  1680. """ % (
  1681. _("EXCELLON EDITOR"), _("Add Drill Array"), _("Copy Drill(s)"), _("Add Drill"),
  1682. _("Jump to Location (x, y)"), _("Move Drill(s)"), _("Add Slot Array"), _("Resize Drill(s)"),
  1683. _("Add a new Tool"), _("Add Slot"), _("Distance Minimum Tool"),
  1684. _("Delete Drill(s)"), _("Alternate: Delete Tool(s)"),
  1685. _("Abort and return to Select"), _("Save Object and Exit Editor")
  1686. )
  1687. grb_sh_messages = """
  1688. <br>
  1689. <strong><span style="color:#00ff00">%s</span></strong><br>
  1690. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1691. <tbody>
  1692. <tr height="20">
  1693. <td height="20" width="89"><strong>A</strong></td>
  1694. <td width="194">&nbsp;%s</td>
  1695. </tr>
  1696. <tr height="20">
  1697. <td height="20"><strong>B</strong></td>
  1698. <td>&nbsp;%s</td>
  1699. </tr>
  1700. <tr height="20">
  1701. <td height="20"><strong>C</strong></td>
  1702. <td>&nbsp;%s</td>
  1703. </tr>
  1704. <tr height="20">
  1705. <td height="20"><strong>D</strong></td>
  1706. <td>&nbsp;%s</td>
  1707. </tr>
  1708. <tr height="20">
  1709. <td height="20"><strong>E</strong></td>
  1710. <td>&nbsp;%s</td>
  1711. </tr>
  1712. <tr height="20">
  1713. <td height="20"><strong>J</strong></td>
  1714. <td>&nbsp;%s</td>
  1715. </tr>
  1716. <tr height="20">
  1717. <td height="20"><strong>M</strong></td>
  1718. <td>&nbsp;%s</td>
  1719. </tr>
  1720. <tr height="20">
  1721. <td height="20"><strong>N</strong></td>
  1722. <td>&nbsp;%s</td>
  1723. </tr>
  1724. <tr height="20">
  1725. <td height="20"><strong>P</strong></td>
  1726. <td>&nbsp;%s</td>
  1727. </tr>
  1728. <tr height="20">
  1729. <td height="20"><strong>R</strong></td>
  1730. <td>&nbsp;%s</td>
  1731. </tr>
  1732. <tr height="20">
  1733. <td height="20"><strong>S</strong></td>
  1734. <td>&nbsp;%s</td>
  1735. </tr>
  1736. <tr height="20">
  1737. <td height="20"><strong>T</strong></td>
  1738. <td>&nbsp;%s</td>
  1739. </tr>
  1740. <tr height="20">
  1741. <td height="20"><strong>T</strong></td>
  1742. <td>&nbsp;%s</td>
  1743. </tr>
  1744. <tr height="20">
  1745. <td height="20">&nbsp;</td>
  1746. <td>&nbsp;</td>
  1747. </tr>
  1748. <tr height="20">
  1749. <td height="20"><strong>Del</strong></td>
  1750. <td>&nbsp;%s</td>
  1751. </tr>
  1752. <tr height="20">
  1753. <td height="20"><strong>Del</strong></td>
  1754. <td>&nbsp;%s</td>
  1755. </tr>
  1756. <tr height="20">
  1757. <td height="20"><strong>ESC</strong></td>
  1758. <td>&nbsp;%s</td>
  1759. </tr>
  1760. <tr height="20">
  1761. <td height="20">&nbsp;</td>
  1762. <td>&nbsp;</td>
  1763. </tr>
  1764. <tr height="20">
  1765. <td height="20"><strong>SHIFT+M</strong></td>
  1766. <td>&nbsp;%s</td>
  1767. </tr>
  1768. <tr height="20">
  1769. <td height="20">&nbsp;</td>
  1770. <td>&nbsp;</td>
  1771. </tr>
  1772. <tr height="20">
  1773. <td height="20"><strong>CTRL+E</strong></td>
  1774. <td>&nbsp;%s</td>
  1775. </tr>
  1776. <tr height="20">
  1777. <td height="20"><strong>CTRL+S</strong></td>
  1778. <td>&nbsp;%s</td>
  1779. </tr>
  1780. <tr height="20">
  1781. <td height="20">&nbsp;</td>
  1782. <td>&nbsp;</td>
  1783. </tr>
  1784. <tr height="20">
  1785. <td height="20"><strong>ALT+A</strong></td>
  1786. <td>&nbsp;%s</td>
  1787. </tr>
  1788. <tr height="20">
  1789. <td height="20"><strong>ALT+N</strong></td>
  1790. <td>&nbsp;%s</td>
  1791. </tr>
  1792. <tr height="20">
  1793. <td height="20"><strong>ALT+R</strong></td>
  1794. <td>&nbsp;%s</td>
  1795. </tr>
  1796. </tbody>
  1797. </table>
  1798. <br>
  1799. """ % (
  1800. _("GERBER EDITOR"), _("Add Pad Array"), _("Buffer"), _("Copy"), _("Add Disc"), _("Add SemiDisc"),
  1801. _("Jump to Location (x, y)"), _("Move"), _("Add Region"), _("Add Pad"),
  1802. _("Within Track & Region Tools will cycle in REVERSE the bend modes"), _("Scale"), _("Add Track"),
  1803. _("Within Track & Region Tools will cycle FORWARD the bend modes"), _("Delete"),
  1804. _("Alternate: Delete Apertures"), _("Abort and return to Select"), _("Distance Minimum Tool"),
  1805. _("Eraser Tool"),
  1806. _("Save Object and Exit Editor"), _("Mark Area Tool"), _("Poligonize Tool"), _("Transformation Tool")
  1807. )
  1808. self.editor_sh_msg = editor_title + geo_sh_messages + grb_sh_messages + exc_sh_messages
  1809. self.sh_editor = QtWidgets.QTextEdit()
  1810. self.sh_editor.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1811. self.sh_editor.setText(self.editor_sh_msg)
  1812. self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  1813. self.sh_hlay.addWidget(self.sh_editor)
  1814. # ########################################################################
  1815. # ########################## PLOT AREA CONTEXT MENU # ###################
  1816. # ########################################################################
  1817. self.popMenu = FCMenu()
  1818. self.popmenu_disable = self.popMenu.addAction(
  1819. QtGui.QIcon(self.app.resource_location + '/disable32.png'), _("Toggle Visibility"))
  1820. self.popmenu_panel_toggle = self.popMenu.addAction(
  1821. QtGui.QIcon(self.app.resource_location + '/notebook16.png'), _("Toggle Panel"))
  1822. self.popMenu.addSeparator()
  1823. self.cmenu_newmenu = self.popMenu.addMenu(
  1824. QtGui.QIcon(self.app.resource_location + '/file32.png'), _("New"))
  1825. self.popmenu_new_geo = self.cmenu_newmenu.addAction(
  1826. QtGui.QIcon(self.app.resource_location + '/new_geo32_bis.png'), _("Geometry"))
  1827. self.popmenu_new_grb = self.cmenu_newmenu.addAction(
  1828. QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), "Gerber")
  1829. self.popmenu_new_exc = self.cmenu_newmenu.addAction(
  1830. QtGui.QIcon(self.app.resource_location + '/new_exc32.png'), _("Excellon"))
  1831. self.cmenu_newmenu.addSeparator()
  1832. self.popmenu_new_prj = self.cmenu_newmenu.addAction(
  1833. QtGui.QIcon(self.app.resource_location + '/file16.png'), _("Project"))
  1834. self.popMenu.addSeparator()
  1835. self.cmenu_gridmenu = self.popMenu.addMenu(
  1836. QtGui.QIcon(self.app.resource_location + '/grid32_menu.png'), _("Grids"))
  1837. self.cmenu_viewmenu = self.popMenu.addMenu(
  1838. QtGui.QIcon(self.app.resource_location + '/view64.png'), _("View"))
  1839. self.zoomfit = self.cmenu_viewmenu.addAction(
  1840. QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
  1841. self.clearplot = self.cmenu_viewmenu.addAction(
  1842. QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("Clear Plot"))
  1843. self.replot = self.cmenu_viewmenu.addAction(
  1844. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("Replot"))
  1845. self.popMenu.addSeparator()
  1846. self.g_editor_cmenu = self.popMenu.addMenu(
  1847. QtGui.QIcon(self.app.resource_location + '/draw32.png'), _("Geo Editor"))
  1848. self.draw_line = self.g_editor_cmenu.addAction(
  1849. QtGui.QIcon(self.app.resource_location + '/path32.png'), _("Path"))
  1850. self.draw_rect = self.g_editor_cmenu.addAction(
  1851. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _("Rectangle"))
  1852. self.g_editor_cmenu.addSeparator()
  1853. self.draw_circle = self.g_editor_cmenu.addAction(
  1854. QtGui.QIcon(self.app.resource_location + '/circle32.png'), _("Circle"))
  1855. self.draw_poly = self.g_editor_cmenu.addAction(
  1856. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Polygon"))
  1857. self.draw_arc = self.g_editor_cmenu.addAction(
  1858. QtGui.QIcon(self.app.resource_location + '/arc32.png'), _("Arc"))
  1859. self.g_editor_cmenu.addSeparator()
  1860. self.draw_text = self.g_editor_cmenu.addAction(
  1861. QtGui.QIcon(self.app.resource_location + '/text32.png'), _("Text"))
  1862. self.draw_buffer = self.g_editor_cmenu.addAction(
  1863. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _("Buffer"))
  1864. self.draw_paint = self.g_editor_cmenu.addAction(
  1865. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint"))
  1866. self.draw_eraser = self.g_editor_cmenu.addAction(
  1867. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _("Eraser"))
  1868. self.g_editor_cmenu.addSeparator()
  1869. self.draw_union = self.g_editor_cmenu.addAction(
  1870. QtGui.QIcon(self.app.resource_location + '/union32.png'), _("Union"))
  1871. self.draw_intersect = self.g_editor_cmenu.addAction(
  1872. QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _("Intersection"))
  1873. self.draw_substract = self.g_editor_cmenu.addAction(
  1874. QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _("Subtraction"))
  1875. self.draw_cut = self.g_editor_cmenu.addAction(
  1876. QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _("Cut"))
  1877. self.draw_transform = self.g_editor_cmenu.addAction(
  1878. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  1879. self.g_editor_cmenu.addSeparator()
  1880. self.draw_move = self.g_editor_cmenu.addAction(
  1881. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
  1882. self.grb_editor_cmenu = self.popMenu.addMenu(
  1883. QtGui.QIcon(self.app.resource_location + '/draw32.png'), _("Gerber Editor"))
  1884. self.grb_draw_pad = self.grb_editor_cmenu.addAction(
  1885. QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Pad"))
  1886. self.grb_draw_pad_array = self.grb_editor_cmenu.addAction(
  1887. QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _("Pad Array"))
  1888. self.grb_editor_cmenu.addSeparator()
  1889. self.grb_draw_track = self.grb_editor_cmenu.addAction(
  1890. QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Track"))
  1891. self.grb_draw_region = self.grb_editor_cmenu.addAction(
  1892. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Region"))
  1893. self.grb_draw_poligonize = self.grb_editor_cmenu.addAction(
  1894. QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
  1895. self.grb_draw_semidisc = self.grb_editor_cmenu.addAction(
  1896. QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
  1897. self.grb_draw_disc = self.grb_editor_cmenu.addAction(
  1898. QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
  1899. self.grb_editor_cmenu.addSeparator()
  1900. self.grb_draw_buffer = self.grb_editor_cmenu.addAction(
  1901. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _("Buffer"))
  1902. self.grb_draw_scale = self.grb_editor_cmenu.addAction(
  1903. QtGui.QIcon(self.app.resource_location + '/scale32.png'), _("Scale"))
  1904. self.grb_draw_markarea = self.grb_editor_cmenu.addAction(
  1905. QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _("Mark Area"))
  1906. self.grb_draw_eraser = self.grb_editor_cmenu.addAction(
  1907. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _("Eraser"))
  1908. self.grb_editor_cmenu.addSeparator()
  1909. self.grb_draw_transformations = self.grb_editor_cmenu.addAction(
  1910. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  1911. self.e_editor_cmenu = self.popMenu.addMenu(
  1912. QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Exc Editor"))
  1913. self.drill = self.e_editor_cmenu.addAction(
  1914. QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Add Drill"))
  1915. self.drill_array = self.e_editor_cmenu.addAction(
  1916. QtGui.QIcon(self.app.resource_location + '/addarray32.png'), _("Add Drill Array"))
  1917. self.e_editor_cmenu.addSeparator()
  1918. self.slot = self.e_editor_cmenu.addAction(
  1919. QtGui.QIcon(self.app.resource_location + '/slot26.png'), _("Add Slot"))
  1920. self.slot_array = self.e_editor_cmenu.addAction(
  1921. QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _("Add Slot Array"))
  1922. self.e_editor_cmenu.addSeparator()
  1923. self.drill_resize = self.e_editor_cmenu.addAction(
  1924. QtGui.QIcon(self.app.resource_location + '/resize16.png'), _("Resize Drill"))
  1925. self.popMenu.addSeparator()
  1926. self.popmenu_copy = self.popMenu.addAction(
  1927. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
  1928. self.popmenu_delete = self.popMenu.addAction(
  1929. QtGui.QIcon(self.app.resource_location + '/delete32.png'), _("Delete"))
  1930. self.popmenu_edit = self.popMenu.addAction(
  1931. QtGui.QIcon(self.app.resource_location + '/edit32.png'), _("Edit"))
  1932. self.popmenu_save = self.popMenu.addAction(
  1933. QtGui.QIcon(self.app.resource_location + '/floppy32.png'), _("Close Editor"))
  1934. self.popmenu_save.setVisible(False)
  1935. self.popMenu.addSeparator()
  1936. self.popmenu_move = self.popMenu.addAction(
  1937. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
  1938. self.popmenu_properties = self.popMenu.addAction(
  1939. QtGui.QIcon(self.app.resource_location + '/properties32.png'), _("Properties"))
  1940. # ########################################################################
  1941. # ########################## INFO BAR # ##################################
  1942. # ########################################################################
  1943. self.infobar = self.statusBar()
  1944. self.fcinfo = FlatCAMInfoBar(app=self.app)
  1945. self.infobar.addWidget(self.fcinfo, stretch=1)
  1946. self.snap_infobar_label = QtWidgets.QLabel()
  1947. self.snap_infobar_label.setPixmap(QtGui.QPixmap(self.app.resource_location + '/snap_16.png'))
  1948. self.infobar.addWidget(self.snap_infobar_label)
  1949. self.rel_position_label = QtWidgets.QLabel(
  1950. "<b>Dx</b>: 0.0000&nbsp;&nbsp; <b>Dy</b>: 0.0000&nbsp;&nbsp;&nbsp;&nbsp;")
  1951. self.rel_position_label.setMinimumWidth(110)
  1952. self.rel_position_label.setToolTip(_("Relative neasurement.\nReference is last click position"))
  1953. self.infobar.addWidget(self.rel_position_label)
  1954. self.position_label = QtWidgets.QLabel(
  1955. "&nbsp;&nbsp;&nbsp;&nbsp;<b>X</b>: 0.0000&nbsp;&nbsp; <b>Y</b>: 0.0000")
  1956. self.position_label.setMinimumWidth(110)
  1957. self.position_label.setToolTip(_("Absolute neasurement.\nReference is (X=0, Y= 0) position"))
  1958. self.infobar.addWidget(self.position_label)
  1959. self.units_label = QtWidgets.QLabel("[in]")
  1960. self.units_label.setMargin(2)
  1961. self.infobar.addWidget(self.units_label)
  1962. # disabled
  1963. self.progress_bar = QtWidgets.QProgressBar()
  1964. self.progress_bar.setMinimum(0)
  1965. self.progress_bar.setMaximum(100)
  1966. # infobar.addWidget(self.progress_bar)
  1967. # ########################################################################
  1968. # ########################## SET GUI Elements # ##########################
  1969. # ########################################################################
  1970. self.app_icon = QtGui.QIcon()
  1971. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon16.png', QtCore.QSize(16, 16))
  1972. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon24.png', QtCore.QSize(24, 24))
  1973. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon32.png', QtCore.QSize(32, 32))
  1974. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon48.png', QtCore.QSize(48, 48))
  1975. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon128.png', QtCore.QSize(128, 128))
  1976. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon256.png', QtCore.QSize(256, 256))
  1977. self.setWindowIcon(self.app_icon)
  1978. self.setGeometry(100, 100, 1024, 650)
  1979. self.setWindowTitle('FlatCAM %s %s - %s' %
  1980. (self.app.version,
  1981. ('BETA' if self.app.beta else ''),
  1982. platform.architecture()[0])
  1983. )
  1984. self.filename = ""
  1985. self.units = ""
  1986. self.setAcceptDrops(True)
  1987. # ########################################################################
  1988. # ########################## Build GUI # #################################
  1989. # ########################################################################
  1990. self.grid_snap_btn.setCheckable(True)
  1991. self.corner_snap_btn.setCheckable(True)
  1992. self.update_obj_btn.setEnabled(False)
  1993. # start with GRID activated
  1994. self.grid_snap_btn.trigger()
  1995. self.g_editor_cmenu.menuAction().setVisible(False)
  1996. self.grb_editor_cmenu.menuAction().setVisible(False)
  1997. self.e_editor_cmenu.menuAction().setVisible(False)
  1998. self.general_defaults_form = GeneralPreferencesUI(decimals=self.decimals)
  1999. self.gerber_defaults_form = GerberPreferencesUI(decimals=self.decimals)
  2000. self.excellon_defaults_form = ExcellonPreferencesUI(decimals=self.decimals)
  2001. self.geometry_defaults_form = GeometryPreferencesUI(decimals=self.decimals)
  2002. self.cncjob_defaults_form = CNCJobPreferencesUI(decimals=self.decimals)
  2003. self.tools_defaults_form = ToolsPreferencesUI(decimals=self.decimals)
  2004. self.tools2_defaults_form = Tools2PreferencesUI(decimals=self.decimals)
  2005. self.util_defaults_form = UtilPreferencesUI(decimals=self.decimals)
  2006. QtWidgets.qApp.installEventFilter(self)
  2007. # restore the Toolbar State from file
  2008. settings = QSettings("Open Source", "FlatCAM")
  2009. if settings.contains("saved_gui_state"):
  2010. saved_gui_state = settings.value('saved_gui_state')
  2011. self.restoreState(saved_gui_state)
  2012. log.debug("FlatCAMGUI.__init__() --> UI state restored.")
  2013. if settings.contains("layout"):
  2014. layout = settings.value('layout', type=str)
  2015. if layout == 'standard':
  2016. # self.exc_edit_toolbar.setVisible(False)
  2017. self.exc_edit_toolbar.setDisabled(True)
  2018. # self.geo_edit_toolbar.setVisible(False)
  2019. self.geo_edit_toolbar.setDisabled(True)
  2020. # self.grb_edit_toolbar.setVisible(False)
  2021. self.grb_edit_toolbar.setDisabled(True)
  2022. self.corner_snap_btn.setVisible(False)
  2023. self.snap_magnet.setVisible(False)
  2024. elif layout == 'compact':
  2025. self.exc_edit_toolbar.setDisabled(True)
  2026. self.geo_edit_toolbar.setDisabled(True)
  2027. self.grb_edit_toolbar.setDisabled(True)
  2028. self.snap_magnet.setVisible(True)
  2029. self.corner_snap_btn.setVisible(True)
  2030. self.snap_magnet.setDisabled(True)
  2031. self.corner_snap_btn.setDisabled(True)
  2032. log.debug("FlatCAMGUI.__init__() --> UI layout restored from QSettings.")
  2033. else:
  2034. # self.exc_edit_toolbar.setVisible(False)
  2035. self.exc_edit_toolbar.setDisabled(True)
  2036. # self.geo_edit_toolbar.setVisible(False)
  2037. self.geo_edit_toolbar.setDisabled(True)
  2038. # self.grb_edit_toolbar.setVisible(False)
  2039. self.grb_edit_toolbar.setDisabled(True)
  2040. self.corner_snap_btn.setVisible(False)
  2041. self.snap_magnet.setVisible(False)
  2042. settings.setValue('layout', "standard")
  2043. # This will write the setting to the platform specific storage.
  2044. del settings
  2045. log.debug("FlatCAMGUI.__init__() --> UI layout restored from defaults. QSettings set to 'standard'")
  2046. # construct the Toolbar Lock menu entry to the context menu of the QMainWindow
  2047. self.lock_action = QtWidgets.QAction()
  2048. self.lock_action.setText(_("Lock Toolbars"))
  2049. self.lock_action.setCheckable(True)
  2050. settings = QSettings("Open Source", "FlatCAM")
  2051. if settings.contains("toolbar_lock"):
  2052. lock_val = settings.value('toolbar_lock')
  2053. if lock_val == 'true':
  2054. lock_state = True
  2055. self.lock_action.setChecked(True)
  2056. else:
  2057. lock_state = False
  2058. self.lock_action.setChecked(False)
  2059. else:
  2060. lock_state = False
  2061. settings.setValue('toolbar_lock', lock_state)
  2062. # This will write the setting to the platform specific storage.
  2063. del settings
  2064. self.lock_toolbar(lock=lock_state)
  2065. self.lock_action.triggered[bool].connect(self.lock_toolbar)
  2066. # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2067. # %%%%%%%%%%%%%%%%% GUI Building FINISHED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2068. # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2069. def eventFilter(self, obj, event):
  2070. """
  2071. Filter the ToolTips display based on a Preferences setting
  2072. :param obj:
  2073. :param event: QT event to filter
  2074. :return:
  2075. """
  2076. if self.general_defaults_form.general_app_set_group.toggle_tooltips_cb.get_value() is False:
  2077. if event.type() == QtCore.QEvent.ToolTip:
  2078. return True
  2079. else:
  2080. return False
  2081. return False
  2082. def populate_toolbars(self):
  2083. """
  2084. Will populate the App Toolbars with theie actions
  2085. :return: None
  2086. """
  2087. # ## File Toolbar # ##
  2088. self.file_open_gerber_btn = self.toolbarfile.addAction(
  2089. QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _("Open Gerber"))
  2090. self.file_open_excellon_btn = self.toolbarfile.addAction(
  2091. QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Open Excellon"))
  2092. self.toolbarfile.addSeparator()
  2093. self.file_open_btn = self.toolbarfile.addAction(
  2094. QtGui.QIcon(self.app.resource_location + '/folder32.png'), _("Open project"))
  2095. self.file_save_btn = self.toolbarfile.addAction(
  2096. QtGui.QIcon(self.app.resource_location + '/project_save32.png'), _("Save project"))
  2097. # ## Edit Toolbar # ##
  2098. self.newgeo_btn = self.toolbargeo.addAction(
  2099. QtGui.QIcon(self.app.resource_location + '/new_file_geo32.png'), _("New Blank Geometry"))
  2100. self.newgrb_btn = self.toolbargeo.addAction(
  2101. QtGui.QIcon(self.app.resource_location + '/new_file_grb32.png'), _("New Blank Gerber"))
  2102. self.newexc_btn = self.toolbargeo.addAction(
  2103. QtGui.QIcon(self.app.resource_location + '/new_file_exc32.png'), _("New Blank Excellon"))
  2104. self.toolbargeo.addSeparator()
  2105. self.editgeo_btn = self.toolbargeo.addAction(
  2106. QtGui.QIcon(self.app.resource_location + '/edit32.png'), _("Editor"))
  2107. self.update_obj_btn = self.toolbargeo.addAction(
  2108. QtGui.QIcon(self.app.resource_location + '/close_edit_file32.png'),
  2109. _("Save Object and close the Editor")
  2110. )
  2111. self.toolbargeo.addSeparator()
  2112. self.copy_btn = self.toolbargeo.addAction(
  2113. QtGui.QIcon(self.app.resource_location + '/copy_file32.png'), _("Copy"))
  2114. self.delete_btn = self.toolbargeo.addAction(
  2115. QtGui.QIcon(self.app.resource_location + '/delete_file32.png'), _("&Delete"))
  2116. self.toolbargeo.addSeparator()
  2117. self.distance_btn = self.toolbargeo.addAction(
  2118. QtGui.QIcon(self.app.resource_location + '/distance32.png'), _("Distance Tool"))
  2119. self.distance_min_btn = self.toolbargeo.addAction(
  2120. QtGui.QIcon(self.app.resource_location + '/distance_min32.png'), _("Distance Min Tool"))
  2121. self.origin_btn = self.toolbargeo.addAction(
  2122. QtGui.QIcon(self.app.resource_location + '/origin32.png'), _('Set Origin'))
  2123. self.jmp_btn = self.toolbargeo.addAction(
  2124. QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location'))
  2125. # ## View Toolbar # ##
  2126. self.replot_btn = self.toolbarview.addAction(
  2127. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("&Replot"))
  2128. self.clear_plot_btn = self.toolbarview.addAction(
  2129. QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("&Clear plot"))
  2130. self.zoom_in_btn = self.toolbarview.addAction(
  2131. QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("Zoom In"))
  2132. self.zoom_out_btn = self.toolbarview.addAction(
  2133. QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("Zoom Out"))
  2134. self.zoom_fit_btn = self.toolbarview.addAction(
  2135. QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
  2136. # self.toolbarview.setVisible(False)
  2137. # ## Shell Toolbar # ##
  2138. self.shell_btn = self.toolbarshell.addAction(
  2139. QtGui.QIcon(self.app.resource_location + '/shell32.png'), _("&Command Line"))
  2140. self.new_script_btn = self.toolbarshell.addAction(
  2141. QtGui.QIcon(self.app.resource_location + '/script_new24.png'), _('New Script ...'))
  2142. self.open_script_btn = self.toolbarshell.addAction(
  2143. QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'))
  2144. self.run_script_btn = self.toolbarshell.addAction(
  2145. QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Run Script ...'))
  2146. # ## Tools Toolbar # ##
  2147. self.dblsided_btn = self.toolbartools.addAction(
  2148. QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2Sided Tool"))
  2149. self.cutout_btn = self.toolbartools.addAction(
  2150. QtGui.QIcon(self.app.resource_location + '/cut16_bis.png'), _("&Cutout Tool"))
  2151. self.ncc_btn = self.toolbartools.addAction(
  2152. QtGui.QIcon(self.app.resource_location + '/ncc16.png'), _("NCC Tool"))
  2153. self.paint_btn = self.toolbartools.addAction(
  2154. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint Tool"))
  2155. self.toolbartools.addSeparator()
  2156. self.panelize_btn = self.toolbartools.addAction(
  2157. QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel Tool"))
  2158. self.film_btn = self.toolbartools.addAction(
  2159. QtGui.QIcon(self.app.resource_location + '/film16.png'), _("Film Tool"))
  2160. self.solder_btn = self.toolbartools.addAction(
  2161. QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'),
  2162. _("SolderPaste Tool"))
  2163. self.sub_btn = self.toolbartools.addAction(
  2164. QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool"))
  2165. self.toolbartools.addSeparator()
  2166. self.calculators_btn = self.toolbartools.addAction(
  2167. QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators Tool"))
  2168. self.transform_btn = self.toolbartools.addAction(
  2169. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool"))
  2170. self.qrcode_btn = self.toolbartools.addAction(
  2171. QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode Tool"))
  2172. self.copperfill_btn = self.toolbartools.addAction(
  2173. QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving Tool"))
  2174. self.fiducials_btn = self.toolbartools.addAction(
  2175. QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials Tool"))
  2176. self.cal_btn = self.toolbartools.addAction(
  2177. QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool"))
  2178. # ## Excellon Editor Toolbar # ##
  2179. self.select_drill_btn = self.exc_edit_toolbar.addAction(
  2180. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  2181. self.add_drill_btn = self.exc_edit_toolbar.addAction(
  2182. QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill Hole'))
  2183. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  2184. QtGui.QIcon(self.app.resource_location + '/addarray16.png'), _('Add Drill Hole Array'))
  2185. self.resize_drill_btn = self.exc_edit_toolbar.addAction(
  2186. QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill'))
  2187. self.add_slot_btn = self.exc_edit_toolbar.addAction(
  2188. QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot'))
  2189. self.add_slot_array_btn = self.exc_edit_toolbar.addAction(
  2190. QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array'))
  2191. self.exc_edit_toolbar.addSeparator()
  2192. self.copy_drill_btn = self.exc_edit_toolbar.addAction(
  2193. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy Drill'))
  2194. self.delete_drill_btn = self.exc_edit_toolbar.addAction(
  2195. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Drill"))
  2196. self.exc_edit_toolbar.addSeparator()
  2197. self.move_drill_btn = self.exc_edit_toolbar.addAction(
  2198. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Drill"))
  2199. # ## Geometry Editor Toolbar # ##
  2200. self.geo_select_btn = self.geo_edit_toolbar.addAction(
  2201. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select 'Esc'"))
  2202. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(
  2203. QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle'))
  2204. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(
  2205. QtGui.QIcon(self.app.resource_location + '/arc32.png'), _('Add Arc'))
  2206. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(
  2207. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle'))
  2208. self.geo_edit_toolbar.addSeparator()
  2209. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(
  2210. QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path'))
  2211. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(
  2212. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon'))
  2213. self.geo_edit_toolbar.addSeparator()
  2214. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(
  2215. QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text'))
  2216. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(
  2217. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Add Buffer'))
  2218. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(
  2219. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _('Paint Shape'))
  2220. self.geo_eraser_btn = self.geo_edit_toolbar.addAction(
  2221. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  2222. self.geo_edit_toolbar.addSeparator()
  2223. self.geo_union_btn = self.geo_edit_toolbar.addAction(
  2224. QtGui.QIcon(self.app.resource_location + '/union32.png'), _('Polygon Union'))
  2225. self.geo_explode_btn = self.geo_edit_toolbar.addAction(
  2226. QtGui.QIcon(self.app.resource_location + '/explode32.png'), _('Polygon Explode'))
  2227. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(
  2228. QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _('Polygon Intersection'))
  2229. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(
  2230. QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _('Polygon Subtraction'))
  2231. self.geo_edit_toolbar.addSeparator()
  2232. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(
  2233. QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _('Cut Path'))
  2234. self.geo_copy_btn = self.geo_edit_toolbar.addAction(
  2235. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy Objects"))
  2236. self.geo_delete_btn = self.geo_edit_toolbar.addAction(
  2237. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Shape"))
  2238. self.geo_transform_btn = self.geo_edit_toolbar.addAction(
  2239. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  2240. self.geo_edit_toolbar.addSeparator()
  2241. self.geo_move_btn = self.geo_edit_toolbar.addAction(
  2242. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Objects"))
  2243. # ## Gerber Editor Toolbar # ##
  2244. self.grb_select_btn = self.grb_edit_toolbar.addAction(
  2245. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  2246. self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(
  2247. QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Add Pad"))
  2248. self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(
  2249. QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array'))
  2250. self.grb_add_track_btn = self.grb_edit_toolbar.addAction(
  2251. QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Add Track"))
  2252. self.grb_add_region_btn = self.grb_edit_toolbar.addAction(
  2253. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Add Region"))
  2254. self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(
  2255. QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
  2256. self.grb_add_semidisc_btn = self.grb_edit_toolbar.addAction(
  2257. QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
  2258. self.grb_add_disc_btn = self.grb_edit_toolbar.addAction(
  2259. QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
  2260. self.grb_edit_toolbar.addSeparator()
  2261. self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(
  2262. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer'))
  2263. self.aperture_scale_btn = self.grb_edit_toolbar.addAction(
  2264. QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale'))
  2265. self.aperture_markarea_btn = self.grb_edit_toolbar.addAction(
  2266. QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area'))
  2267. self.aperture_eraser_btn = self.grb_edit_toolbar.addAction(
  2268. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  2269. self.grb_edit_toolbar.addSeparator()
  2270. self.aperture_copy_btn = self.grb_edit_toolbar.addAction(
  2271. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
  2272. self.aperture_delete_btn = self.grb_edit_toolbar.addAction(
  2273. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete"))
  2274. self.grb_transform_btn = self.grb_edit_toolbar.addAction(
  2275. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  2276. self.grb_edit_toolbar.addSeparator()
  2277. self.aperture_move_btn = self.grb_edit_toolbar.addAction(
  2278. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
  2279. # ## Snap Toolbar # ##
  2280. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  2281. # self.addToolBar(self.snap_toolbar)
  2282. self.grid_snap_btn = self.snap_toolbar.addAction(
  2283. QtGui.QIcon(self.app.resource_location + '/grid32.png'), _('Snap to grid'))
  2284. self.grid_gap_x_entry = FCEntry2()
  2285. self.grid_gap_x_entry.setMaximumWidth(70)
  2286. self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
  2287. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  2288. self.grid_gap_y_entry = FCEntry2()
  2289. self.grid_gap_y_entry.setMaximumWidth(70)
  2290. self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
  2291. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  2292. self.grid_space_label = QtWidgets.QLabel(" ")
  2293. self.snap_toolbar.addWidget(self.grid_space_label)
  2294. self.grid_gap_link_cb = FCCheckBox()
  2295. self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
  2296. "is copied to the Grid_Y value."))
  2297. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  2298. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  2299. self.corner_snap_btn = self.snap_toolbar.addAction(
  2300. QtGui.QIcon(self.app.resource_location + '/corner32.png'), _('Snap to corner'))
  2301. self.snap_max_dist_entry = FCEntry()
  2302. self.snap_max_dist_entry.setMaximumWidth(70)
  2303. self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
  2304. self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  2305. self.grid_snap_btn.setCheckable(True)
  2306. self.corner_snap_btn.setCheckable(True)
  2307. self.update_obj_btn.setEnabled(False)
  2308. # start with GRID activated
  2309. self.grid_snap_btn.trigger()
  2310. settings = QSettings("Open Source", "FlatCAM")
  2311. if settings.contains("layout"):
  2312. layout = settings.value('layout', type=str)
  2313. if layout == 'standard':
  2314. self.exc_edit_toolbar.setVisible(True)
  2315. self.exc_edit_toolbar.setDisabled(True)
  2316. self.geo_edit_toolbar.setVisible(True)
  2317. self.geo_edit_toolbar.setDisabled(True)
  2318. self.grb_edit_toolbar.setVisible(True)
  2319. self.grb_edit_toolbar.setDisabled(True)
  2320. self.corner_snap_btn.setVisible(False)
  2321. self.snap_magnet.setVisible(False)
  2322. elif layout == 'compact':
  2323. self.exc_edit_toolbar.setVisible(True)
  2324. self.exc_edit_toolbar.setDisabled(True)
  2325. self.geo_edit_toolbar.setVisible(True)
  2326. self.geo_edit_toolbar.setDisabled(True)
  2327. self.grb_edit_toolbar.setVisible(True)
  2328. self.grb_edit_toolbar.setDisabled(True)
  2329. self.corner_snap_btn.setVisible(True)
  2330. self.snap_magnet.setVisible(True)
  2331. self.corner_snap_btn.setDisabled(True)
  2332. self.snap_magnet.setDisabled(True)
  2333. def keyPressEvent(self, event):
  2334. """
  2335. Key event handler for the entire app.
  2336. Some of the key events are also treated locally in the FlatCAM editors
  2337. :param event: QT event
  2338. :return:
  2339. """
  2340. modifiers = QtWidgets.QApplication.keyboardModifiers()
  2341. active = self.app.collection.get_active()
  2342. selected = self.app.collection.get_selected()
  2343. matplotlib_key_flag = False
  2344. # events out of the self.app.collection view (it's about Project Tab) are of type int
  2345. if type(event) is int:
  2346. key = event
  2347. # events from the GUI are of type QKeyEvent
  2348. elif type(event) == QtGui.QKeyEvent:
  2349. key = event.key()
  2350. elif isinstance(event, mpl_key_event): # MatPlotLib key events are trickier to interpret than the rest
  2351. matplotlib_key_flag = True
  2352. key = event.key
  2353. key = QtGui.QKeySequence(key)
  2354. # check for modifiers
  2355. key_string = key.toString().lower()
  2356. if '+' in key_string:
  2357. mod, __, key_text = key_string.rpartition('+')
  2358. if mod.lower() == 'ctrl':
  2359. modifiers = QtCore.Qt.ControlModifier
  2360. elif mod.lower() == 'alt':
  2361. modifiers = QtCore.Qt.AltModifier
  2362. elif mod.lower() == 'shift':
  2363. modifiers = QtCore.Qt.ShiftModifier
  2364. else:
  2365. modifiers = QtCore.Qt.NoModifier
  2366. key = QtGui.QKeySequence(key_text)
  2367. # events from Vispy are of type KeyEvent
  2368. else:
  2369. key = event.key
  2370. if self.app.call_source == 'app':
  2371. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  2372. if key == QtCore.Qt.Key_X:
  2373. self.app.abort_all_tasks()
  2374. return
  2375. elif modifiers == QtCore.Qt.ControlModifier:
  2376. # Select All
  2377. if key == QtCore.Qt.Key_A:
  2378. self.app.on_selectall()
  2379. # Copy an FlatCAM object
  2380. if key == QtCore.Qt.Key_C:
  2381. widget_name = self.plot_tab_area.currentWidget().objectName()
  2382. if widget_name == 'database_tab':
  2383. # Tools DB saved, update flag
  2384. self.app.tools_db_changed_flag = True
  2385. self.app.tools_db_tab.on_tool_copy()
  2386. return
  2387. self.app.on_copy_object()
  2388. # Copy an FlatCAM object
  2389. if key == QtCore.Qt.Key_D:
  2390. self.app.on_tools_database()
  2391. # Open Excellon file
  2392. if key == QtCore.Qt.Key_E:
  2393. self.app.on_fileopenexcellon()
  2394. # Open Gerber file
  2395. if key == QtCore.Qt.Key_G:
  2396. self.app.on_fileopengerber()
  2397. # Distance Tool
  2398. if key == QtCore.Qt.Key_M:
  2399. self.app.distance_tool.run()
  2400. # Create New Project
  2401. if key == QtCore.Qt.Key_N:
  2402. self.app.on_file_new_click()
  2403. # Open Project
  2404. if key == QtCore.Qt.Key_O:
  2405. self.app.on_file_openproject()
  2406. # Open Project
  2407. if key == QtCore.Qt.Key_P:
  2408. self.app.on_file_save_objects_pdf(use_thread=True)
  2409. # PDF Import
  2410. if key == QtCore.Qt.Key_Q:
  2411. self.app.pdf_tool.run()
  2412. # Save Project
  2413. if key == QtCore.Qt.Key_S:
  2414. widget_name = self.plot_tab_area.currentWidget().objectName()
  2415. if widget_name == 'preferences_tab':
  2416. self.app.on_save_button(save_to_file=False)
  2417. return
  2418. if widget_name == 'database_tab':
  2419. # Tools DB saved, update flag
  2420. self.app.tools_db_changed_flag = False
  2421. self.app.tools_db_tab.on_save_tools_db()
  2422. return
  2423. self.app.on_file_saveproject()
  2424. # Toggle Plot Area
  2425. if key == QtCore.Qt.Key_F10 or key == 'F10':
  2426. self.app.on_toggle_plotarea()
  2427. return
  2428. elif modifiers == QtCore.Qt.ShiftModifier:
  2429. # Copy Object Name
  2430. if key == QtCore.Qt.Key_C:
  2431. self.app.on_copy_name()
  2432. # Toggle Code Editor
  2433. if key == QtCore.Qt.Key_E:
  2434. self.app.on_toggle_code_editor()
  2435. # Toggle axis
  2436. if key == QtCore.Qt.Key_G:
  2437. self.app.on_toggle_axis()
  2438. # Run Distance Minimum Tool
  2439. if key == QtCore.Qt.Key_M:
  2440. self.app.distance_min_tool.run()
  2441. return
  2442. # Open Preferences Window
  2443. if key == QtCore.Qt.Key_P:
  2444. self.app.on_preferences()
  2445. return
  2446. # Rotate Object by 90 degree CCW
  2447. if key == QtCore.Qt.Key_R:
  2448. self.app.on_rotate(silent=True, preset=-float(self.app.defaults['tools_transform_rotate']))
  2449. return
  2450. # Run a Script
  2451. if key == QtCore.Qt.Key_S:
  2452. self.app.on_filerunscript()
  2453. return
  2454. # Toggle Workspace
  2455. if key == QtCore.Qt.Key_W:
  2456. self.app.on_workspace_toggle()
  2457. return
  2458. # Skew on X axis
  2459. if key == QtCore.Qt.Key_X:
  2460. self.app.on_skewx()
  2461. return
  2462. # Skew on Y axis
  2463. if key == QtCore.Qt.Key_Y:
  2464. self.app.on_skewy()
  2465. return
  2466. elif modifiers == QtCore.Qt.AltModifier:
  2467. # Eanble all plots
  2468. if key == Qt.Key_1:
  2469. self.app.enable_all_plots()
  2470. # Disable all plots
  2471. if key == Qt.Key_2:
  2472. self.app.disable_all_plots()
  2473. # Disable all other plots
  2474. if key == Qt.Key_3:
  2475. self.app.disable_other_plots()
  2476. # Calculator Tool
  2477. if key == QtCore.Qt.Key_C:
  2478. self.app.calculator_tool.run(toggle=True)
  2479. # 2-Sided PCB Tool
  2480. if key == QtCore.Qt.Key_D:
  2481. self.app.dblsidedtool.run(toggle=True)
  2482. return
  2483. # Calibration Tool
  2484. if key == QtCore.Qt.Key_E:
  2485. self.app.cal_exc_tool.run(toggle=True)
  2486. return
  2487. # Copper Thieving Tool
  2488. if key == QtCore.Qt.Key_F:
  2489. self.app.copper_thieving_tool.run(toggle=True)
  2490. return
  2491. # Toggle Grid lines
  2492. if key == QtCore.Qt.Key_G:
  2493. self.app.on_toggle_grid_lines()
  2494. return
  2495. # Fiducials Tool
  2496. if key == QtCore.Qt.Key_J:
  2497. self.app.fiducial_tool.run(toggle=True)
  2498. return
  2499. # Solder Paste Dispensing Tool
  2500. if key == QtCore.Qt.Key_K:
  2501. self.app.paste_tool.run(toggle=True)
  2502. return
  2503. # Film Tool
  2504. if key == QtCore.Qt.Key_L:
  2505. self.app.film_tool.run(toggle=True)
  2506. return
  2507. # Non-Copper Clear Tool
  2508. if key == QtCore.Qt.Key_N:
  2509. self.app.ncclear_tool.run(toggle=True)
  2510. return
  2511. # Optimal Tool
  2512. if key == QtCore.Qt.Key_O:
  2513. self.app.optimal_tool.run(toggle=True)
  2514. return
  2515. # Paint Tool
  2516. if key == QtCore.Qt.Key_P:
  2517. self.app.paint_tool.run(toggle=True)
  2518. return
  2519. # QRCode Tool
  2520. if key == QtCore.Qt.Key_Q:
  2521. self.app.qrcode_tool.run()
  2522. return
  2523. # Rules Tool
  2524. if key == QtCore.Qt.Key_R:
  2525. self.app.rules_tool.run(toggle=True)
  2526. return
  2527. # View Source Object Content
  2528. if key == QtCore.Qt.Key_S:
  2529. self.app.on_view_source()
  2530. return
  2531. # Transformation Tool
  2532. if key == QtCore.Qt.Key_T:
  2533. self.app.transform_tool.run(toggle=True)
  2534. return
  2535. # Substract Tool
  2536. if key == QtCore.Qt.Key_W:
  2537. self.app.sub_tool.run(toggle=True)
  2538. return
  2539. # Cutout Tool
  2540. if key == QtCore.Qt.Key_X:
  2541. self.app.cutout_tool.run(toggle=True)
  2542. return
  2543. # Panelize Tool
  2544. if key == QtCore.Qt.Key_Z:
  2545. self.app.panelize_tool.run(toggle=True)
  2546. return
  2547. # Toggle Fullscreen
  2548. if key == QtCore.Qt.Key_F10 or key == 'F10':
  2549. self.app.on_fullscreen()
  2550. return
  2551. elif modifiers == QtCore.Qt.NoModifier:
  2552. # Open Manual
  2553. if key == QtCore.Qt.Key_F1 or key == 'F1':
  2554. webbrowser.open(self.app.manual_url)
  2555. # Show shortcut list
  2556. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2557. self.app.on_shortcut_list()
  2558. # Open Video Help
  2559. if key == QtCore.Qt.Key_F4 or key == 'F4':
  2560. webbrowser.open(self.app.video_url)
  2561. # Open Video Help
  2562. if key == QtCore.Qt.Key_F5 or key == 'F5':
  2563. self.app.plot_all()
  2564. # Switch to Project Tab
  2565. if key == QtCore.Qt.Key_1:
  2566. self.app.on_select_tab('project')
  2567. # Switch to Selected Tab
  2568. if key == QtCore.Qt.Key_2:
  2569. self.app.on_select_tab('selected')
  2570. # Switch to Tool Tab
  2571. if key == QtCore.Qt.Key_3:
  2572. self.app.on_select_tab('tool')
  2573. # Delete from PyQt
  2574. # It's meant to make a difference between delete objects and delete tools in
  2575. # Geometry Selected tool table
  2576. if key == QtCore.Qt.Key_Delete and matplotlib_key_flag is False:
  2577. widget_name = self.plot_tab_area.currentWidget().objectName()
  2578. if widget_name == 'database_tab':
  2579. # Tools DB saved, update flag
  2580. self.app.tools_db_changed_flag = True
  2581. self.app.tools_db_tab.on_tool_delete()
  2582. return
  2583. self.app.on_delete_keypress()
  2584. # Delete from canvas
  2585. if key == 'Delete':
  2586. # Delete via the application to
  2587. # ensure cleanup of the GUI
  2588. if active:
  2589. active.app.on_delete()
  2590. # Escape = Deselect All
  2591. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2592. self.app.on_deselect_all()
  2593. # if in full screen, exit to normal view
  2594. if self.app.toggle_fscreen is True:
  2595. self.app.on_fullscreen(disable=True)
  2596. # try to disconnect the slot from Set Origin
  2597. try:
  2598. self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_set_zero_click)
  2599. except TypeError:
  2600. pass
  2601. self.app.inform.emit("")
  2602. # Space = Toggle Active/Inactive
  2603. if key == QtCore.Qt.Key_Space:
  2604. for select in selected:
  2605. select.ui.plot_cb.toggle()
  2606. self.app.collection.update_view()
  2607. self.app.delete_selection_shape()
  2608. # New Geometry
  2609. if key == QtCore.Qt.Key_B:
  2610. self.app.new_gerber_object()
  2611. # New Geometry
  2612. if key == QtCore.Qt.Key_D:
  2613. self.app.new_document_object()
  2614. # Copy Object Name
  2615. if key == QtCore.Qt.Key_E:
  2616. self.app.object2editor()
  2617. # Grid toggle
  2618. if key == QtCore.Qt.Key_G:
  2619. self.app.ui.grid_snap_btn.trigger()
  2620. # Jump to coords
  2621. if key == QtCore.Qt.Key_J:
  2622. self.app.on_jump_to()
  2623. # New Excellon
  2624. if key == QtCore.Qt.Key_L:
  2625. self.app.new_excellon_object()
  2626. # Move tool toggle
  2627. if key == QtCore.Qt.Key_M:
  2628. self.app.move_tool.toggle()
  2629. # New Geometry
  2630. if key == QtCore.Qt.Key_N:
  2631. self.app.new_geometry_object()
  2632. # Set Origin
  2633. if key == QtCore.Qt.Key_O:
  2634. self.app.on_set_origin()
  2635. return
  2636. # Properties Tool
  2637. if key == QtCore.Qt.Key_P:
  2638. self.app.properties_tool.run()
  2639. return
  2640. # Change Units
  2641. if key == QtCore.Qt.Key_Q:
  2642. # if self.app.defaults["units"] == 'MM':
  2643. # self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("IN")
  2644. # else:
  2645. # self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("MM")
  2646. # self.app.on_toggle_units(no_pref=True)
  2647. self.app.on_toggle_units_click()
  2648. # Rotate Object by 90 degree CW
  2649. if key == QtCore.Qt.Key_R:
  2650. self.app.on_rotate(silent=True, preset=self.app.defaults['tools_transform_rotate'])
  2651. # Shell toggle
  2652. if key == QtCore.Qt.Key_S:
  2653. self.app.on_toggle_shell()
  2654. # Add a Tool from shortcut
  2655. if key == QtCore.Qt.Key_T:
  2656. widget_name = self.plot_tab_area.currentWidget().objectName()
  2657. if widget_name == 'database_tab':
  2658. # Tools DB saved, update flag
  2659. self.app.tools_db_changed_flag = True
  2660. self.app.tools_db_tab.on_tool_add()
  2661. return
  2662. self.app.on_tool_add_keypress()
  2663. # Zoom Fit
  2664. if key == QtCore.Qt.Key_V:
  2665. self.app.on_zoom_fit(None)
  2666. # Mirror on X the selected object(s)
  2667. if key == QtCore.Qt.Key_X:
  2668. self.app.on_flipx()
  2669. # Mirror on Y the selected object(s)
  2670. if key == QtCore.Qt.Key_Y:
  2671. self.app.on_flipy()
  2672. # Zoom In
  2673. if key == QtCore.Qt.Key_Equal:
  2674. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], self.app.mouse)
  2675. # Zoom Out
  2676. if key == QtCore.Qt.Key_Minus:
  2677. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], self.app.mouse)
  2678. # toggle display of Notebook area
  2679. if key == QtCore.Qt.Key_QuoteLeft:
  2680. self.app.on_toggle_notebook()
  2681. return
  2682. elif self.app.call_source == 'geo_editor':
  2683. if modifiers == QtCore.Qt.ControlModifier:
  2684. # save (update) the current geometry and return to the App
  2685. if key == QtCore.Qt.Key_S or key == 'S':
  2686. self.app.editor2object()
  2687. return
  2688. # toggle the measurement tool
  2689. if key == QtCore.Qt.Key_M or key == 'M':
  2690. self.app.distance_tool.run()
  2691. return
  2692. # Cut Action Tool
  2693. if key == QtCore.Qt.Key_X or key == 'X':
  2694. if self.app.geo_editor.get_selected() is not None:
  2695. self.app.geo_editor.cutpath()
  2696. else:
  2697. msg = _('Please first select a geometry item to be cutted\n'
  2698. 'then select the geometry item that will be cutted\n'
  2699. 'out of the first item. In the end press ~X~ key or\n'
  2700. 'the toolbar button.')
  2701. messagebox = QtWidgets.QMessageBox()
  2702. messagebox.setText(msg)
  2703. messagebox.setWindowTitle(_("Warning"))
  2704. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2705. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2706. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2707. messagebox.exec_()
  2708. return
  2709. elif modifiers == QtCore.Qt.ShiftModifier:
  2710. # Run Distance Minimum Tool
  2711. if key == QtCore.Qt.Key_M or key == 'M':
  2712. self.app.distance_min_tool.run()
  2713. return
  2714. # Skew on X axis
  2715. if key == QtCore.Qt.Key_X or key == 'X':
  2716. self.app.geo_editor.transform_tool.on_skewx_key()
  2717. return
  2718. # Skew on Y axis
  2719. if key == QtCore.Qt.Key_Y or key == 'Y':
  2720. self.app.geo_editor.transform_tool.on_skewy_key()
  2721. return
  2722. elif modifiers == QtCore.Qt.AltModifier:
  2723. # Transformation Tool
  2724. if key == QtCore.Qt.Key_R or key == 'R':
  2725. self.app.geo_editor.select_tool('transform')
  2726. return
  2727. # Offset on X axis
  2728. if key == QtCore.Qt.Key_X or key == 'X':
  2729. self.app.geo_editor.transform_tool.on_offx_key()
  2730. return
  2731. # Offset on Y axis
  2732. if key == QtCore.Qt.Key_Y or key == 'Y':
  2733. self.app.geo_editor.transform_tool.on_offy_key()
  2734. return
  2735. elif modifiers == QtCore.Qt.NoModifier:
  2736. # toggle display of Notebook area
  2737. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2738. self.app.on_toggle_notebook()
  2739. # Finish the current action. Use with tools that do not
  2740. # complete automatically, like a polygon or path.
  2741. if key == QtCore.Qt.Key_Enter or key == 'Enter':
  2742. if isinstance(self.app.geo_editor.active_tool, FCShapeTool):
  2743. if self.app.geo_editor.active_tool.name == 'rotate':
  2744. self.app.geo_editor.active_tool.make()
  2745. if self.app.geo_editor.active_tool.complete:
  2746. self.app.geo_editor.on_shape_complete()
  2747. self.app.inform.emit('[success] %s' % _("Done."))
  2748. # automatically make the selection tool active after completing current action
  2749. self.app.geo_editor.select_tool('select')
  2750. return
  2751. else:
  2752. self.app.geo_editor.active_tool.click(
  2753. self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
  2754. self.app.geo_editor.active_tool.make()
  2755. if self.app.geo_editor.active_tool.complete:
  2756. self.app.geo_editor.on_shape_complete()
  2757. self.app.inform.emit('[success] %s' % _("Done."))
  2758. # automatically make the selection tool active after completing current action
  2759. self.app.geo_editor.select_tool('select')
  2760. # Abort the current action
  2761. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2762. # TODO: ...?
  2763. # self.on_tool_select("select")
  2764. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  2765. self.app.geo_editor.delete_utility_geometry()
  2766. self.app.geo_editor.active_tool.clean_up()
  2767. self.app.geo_editor.select_tool('select')
  2768. # hide the notebook
  2769. self.app.ui.splitter.setSizes([0, 1])
  2770. return
  2771. # Delete selected object
  2772. if key == QtCore.Qt.Key_Delete or key == 'Delete':
  2773. self.app.geo_editor.delete_selected()
  2774. self.app.geo_editor.replot()
  2775. # Rotate
  2776. if key == QtCore.Qt.Key_Space or key == 'Space':
  2777. self.app.geo_editor.transform_tool.on_rotate_key()
  2778. # Zoom Out
  2779. if key == QtCore.Qt.Key_Minus or key == '-':
  2780. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  2781. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2782. # Zoom In
  2783. if key == QtCore.Qt.Key_Equal or key == '=':
  2784. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  2785. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2786. # Switch to Project Tab
  2787. if key == QtCore.Qt.Key_1 or key == '1':
  2788. self.app.on_select_tab('project')
  2789. # Switch to Selected Tab
  2790. if key == QtCore.Qt.Key_2 or key == '2':
  2791. self.app.on_select_tab('selected')
  2792. # Switch to Tool Tab
  2793. if key == QtCore.Qt.Key_3 or key == '3':
  2794. self.app.on_select_tab('tool')
  2795. # Grid Snap
  2796. if key == QtCore.Qt.Key_G or key == 'G':
  2797. self.app.ui.grid_snap_btn.trigger()
  2798. # make sure that the cursor shape is enabled/disabled, too
  2799. if self.app.geo_editor.options['grid_snap'] is True:
  2800. self.app.app_cursor.enabled = True
  2801. else:
  2802. self.app.app_cursor.enabled = False
  2803. # Corner Snap
  2804. if key == QtCore.Qt.Key_K or key == 'K':
  2805. self.app.geo_editor.on_corner_snap()
  2806. if key == QtCore.Qt.Key_V or key == 'V':
  2807. self.app.on_zoom_fit(None)
  2808. # we do this so we can reuse the following keys while inside a Tool
  2809. # the above keys are general enough so were left outside
  2810. if self.app.geo_editor.active_tool is not None and self.geo_select_btn.isChecked() is False:
  2811. response = self.app.geo_editor.active_tool.on_key(key=key)
  2812. if response is not None:
  2813. self.app.inform.emit(response)
  2814. else:
  2815. # Arc Tool
  2816. if key == QtCore.Qt.Key_A or key == 'A':
  2817. self.app.geo_editor.select_tool('arc')
  2818. # Buffer
  2819. if key == QtCore.Qt.Key_B or key == 'B':
  2820. self.app.geo_editor.select_tool('buffer')
  2821. # Copy
  2822. if key == QtCore.Qt.Key_C or key == 'C':
  2823. self.app.geo_editor.on_copy_click()
  2824. # Substract Tool
  2825. if key == QtCore.Qt.Key_E or key == 'E':
  2826. if self.app.geo_editor.get_selected() is not None:
  2827. self.app.geo_editor.intersection()
  2828. else:
  2829. msg = _("Please select geometry items \n"
  2830. "on which to perform Intersection Tool.")
  2831. messagebox = QtWidgets.QMessageBox()
  2832. messagebox.setText(msg)
  2833. messagebox.setWindowTitle(_("Warning"))
  2834. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2835. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2836. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2837. messagebox.exec_()
  2838. # Paint
  2839. if key == QtCore.Qt.Key_I or key == 'I':
  2840. self.app.geo_editor.select_tool('paint')
  2841. # Jump to coords
  2842. if key == QtCore.Qt.Key_J or key == 'J':
  2843. self.app.on_jump_to()
  2844. # Move
  2845. if key == QtCore.Qt.Key_M or key == 'M':
  2846. self.app.geo_editor.on_move_click()
  2847. # Polygon Tool
  2848. if key == QtCore.Qt.Key_N or key == 'N':
  2849. self.app.geo_editor.select_tool('polygon')
  2850. # Circle Tool
  2851. if key == QtCore.Qt.Key_O or key == 'O':
  2852. self.app.geo_editor.select_tool('circle')
  2853. # Path Tool
  2854. if key == QtCore.Qt.Key_P or key == 'P':
  2855. self.app.geo_editor.select_tool('path')
  2856. # Rectangle Tool
  2857. if key == QtCore.Qt.Key_R or key == 'R':
  2858. self.app.geo_editor.select_tool('rectangle')
  2859. # Substract Tool
  2860. if key == QtCore.Qt.Key_S or key == 'S':
  2861. if self.app.geo_editor.get_selected() is not None:
  2862. self.app.geo_editor.subtract()
  2863. else:
  2864. msg = _(
  2865. "Please select geometry items \n"
  2866. "on which to perform Substraction Tool.")
  2867. messagebox = QtWidgets.QMessageBox()
  2868. messagebox.setText(msg)
  2869. messagebox.setWindowTitle(_("Warning"))
  2870. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2871. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2872. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2873. messagebox.exec_()
  2874. # Add Text Tool
  2875. if key == QtCore.Qt.Key_T or key == 'T':
  2876. self.app.geo_editor.select_tool('text')
  2877. # Substract Tool
  2878. if key == QtCore.Qt.Key_U or key == 'U':
  2879. if self.app.geo_editor.get_selected() is not None:
  2880. self.app.geo_editor.union()
  2881. else:
  2882. msg = _("Please select geometry items \n"
  2883. "on which to perform union.")
  2884. messagebox = QtWidgets.QMessageBox()
  2885. messagebox.setText(msg)
  2886. messagebox.setWindowTitle(_("Warning"))
  2887. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2888. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2889. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2890. messagebox.exec_()
  2891. # Flip on X axis
  2892. if key == QtCore.Qt.Key_X or key == 'X':
  2893. self.app.geo_editor.transform_tool.on_flipx()
  2894. return
  2895. # Flip on Y axis
  2896. if key == QtCore.Qt.Key_Y or key == 'Y':
  2897. self.app.geo_editor.transform_tool.on_flipy()
  2898. return
  2899. # Show Shortcut list
  2900. if key == 'F3':
  2901. self.app.on_shortcut_list()
  2902. elif self.app.call_source == 'grb_editor':
  2903. if modifiers == QtCore.Qt.ControlModifier:
  2904. # Eraser Tool
  2905. if key == QtCore.Qt.Key_E or key == 'E':
  2906. self.app.grb_editor.on_eraser()
  2907. return
  2908. # save (update) the current geometry and return to the App
  2909. if key == QtCore.Qt.Key_S or key == 'S':
  2910. self.app.editor2object()
  2911. return
  2912. # toggle the measurement tool
  2913. if key == QtCore.Qt.Key_M or key == 'M':
  2914. self.app.distance_tool.run()
  2915. return
  2916. elif modifiers == QtCore.Qt.ShiftModifier:
  2917. # Run Distance Minimum Tool
  2918. if key == QtCore.Qt.Key_M or key == 'M':
  2919. self.app.distance_min_tool.run()
  2920. return
  2921. elif modifiers == QtCore.Qt.AltModifier:
  2922. # Mark Area Tool
  2923. if key == QtCore.Qt.Key_A or key == 'A':
  2924. self.app.grb_editor.on_markarea()
  2925. return
  2926. # Poligonize Tool
  2927. if key == QtCore.Qt.Key_N or key == 'N':
  2928. self.app.grb_editor.on_poligonize()
  2929. return
  2930. # Transformation Tool
  2931. if key == QtCore.Qt.Key_R or key == 'R':
  2932. self.app.grb_editor.on_transform()
  2933. return
  2934. elif modifiers == QtCore.Qt.NoModifier:
  2935. # Abort the current action
  2936. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2937. # self.on_tool_select("select")
  2938. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  2939. self.app.grb_editor.delete_utility_geometry()
  2940. # self.app.grb_editor.plot_all()
  2941. self.app.grb_editor.active_tool.clean_up()
  2942. self.app.grb_editor.select_tool('select')
  2943. return
  2944. # Delete selected object if delete key event comes out of canvas
  2945. if key == 'Delete':
  2946. self.app.grb_editor.launched_from_shortcuts = True
  2947. if self.app.grb_editor.selected:
  2948. self.app.grb_editor.delete_selected()
  2949. self.app.grb_editor.plot_all()
  2950. else:
  2951. self.app.inform.emit('[WARNING_NOTCL] %s' %
  2952. _("Cancelled. Nothing selected to delete."))
  2953. return
  2954. # Delete aperture in apertures table if delete key event comes from the Selected Tab
  2955. if key == QtCore.Qt.Key_Delete:
  2956. self.app.grb_editor.launched_from_shortcuts = True
  2957. self.app.grb_editor.on_aperture_delete()
  2958. return
  2959. if key == QtCore.Qt.Key_Minus or key == '-':
  2960. self.app.grb_editor.launched_from_shortcuts = True
  2961. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  2962. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2963. return
  2964. if key == QtCore.Qt.Key_Equal or key == '=':
  2965. self.app.grb_editor.launched_from_shortcuts = True
  2966. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  2967. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2968. return
  2969. # toggle display of Notebook area
  2970. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2971. self.app.grb_editor.launched_from_shortcuts = True
  2972. self.app.on_toggle_notebook()
  2973. return
  2974. # Rotate
  2975. if key == QtCore.Qt.Key_Space or key == 'Space':
  2976. self.app.grb_editor.transform_tool.on_rotate_key()
  2977. # Switch to Project Tab
  2978. if key == QtCore.Qt.Key_1 or key == '1':
  2979. self.app.grb_editor.launched_from_shortcuts = True
  2980. self.app.on_select_tab('project')
  2981. return
  2982. # Switch to Selected Tab
  2983. if key == QtCore.Qt.Key_2 or key == '2':
  2984. self.app.grb_editor.launched_from_shortcuts = True
  2985. self.app.on_select_tab('selected')
  2986. return
  2987. # Switch to Tool Tab
  2988. if key == QtCore.Qt.Key_3 or key == '3':
  2989. self.app.grb_editor.launched_from_shortcuts = True
  2990. self.app.on_select_tab('tool')
  2991. return
  2992. # we do this so we can reuse the following keys while inside a Tool
  2993. # the above keys are general enough so were left outside
  2994. if self.app.grb_editor.active_tool is not None and self.grb_select_btn.isChecked() is False:
  2995. response = self.app.grb_editor.active_tool.on_key(key=key)
  2996. if response is not None:
  2997. self.app.inform.emit(response)
  2998. else:
  2999. # Add Array of pads
  3000. if key == QtCore.Qt.Key_A or key == 'A':
  3001. self.app.grb_editor.launched_from_shortcuts = True
  3002. self.app.inform.emit("Click on target point.")
  3003. self.app.ui.add_pad_ar_btn.setChecked(True)
  3004. self.app.grb_editor.x = self.app.mouse[0]
  3005. self.app.grb_editor.y = self.app.mouse[1]
  3006. self.app.grb_editor.select_tool('array')
  3007. return
  3008. # Scale Tool
  3009. if key == QtCore.Qt.Key_B or key == 'B':
  3010. self.app.grb_editor.launched_from_shortcuts = True
  3011. self.app.grb_editor.select_tool('buffer')
  3012. return
  3013. # Copy
  3014. if key == QtCore.Qt.Key_C or key == 'C':
  3015. self.app.grb_editor.launched_from_shortcuts = True
  3016. if self.app.grb_editor.selected:
  3017. self.app.inform.emit(_("Click on target point."))
  3018. self.app.ui.aperture_copy_btn.setChecked(True)
  3019. self.app.grb_editor.on_tool_select('copy')
  3020. self.app.grb_editor.active_tool.set_origin(
  3021. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  3022. else:
  3023. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3024. _("Cancelled. Nothing selected to copy."))
  3025. return
  3026. # Add Disc Tool
  3027. if key == QtCore.Qt.Key_D or key == 'D':
  3028. self.app.grb_editor.launched_from_shortcuts = True
  3029. self.app.grb_editor.select_tool('disc')
  3030. return
  3031. # Add SemiDisc Tool
  3032. if key == QtCore.Qt.Key_E or key == 'E':
  3033. self.app.grb_editor.launched_from_shortcuts = True
  3034. self.app.grb_editor.select_tool('semidisc')
  3035. return
  3036. # Grid Snap
  3037. if key == QtCore.Qt.Key_G or key == 'G':
  3038. self.app.grb_editor.launched_from_shortcuts = True
  3039. # make sure that the cursor shape is enabled/disabled, too
  3040. if self.app.grb_editor.options['grid_snap'] is True:
  3041. self.app.app_cursor.enabled = False
  3042. else:
  3043. self.app.app_cursor.enabled = True
  3044. self.app.ui.grid_snap_btn.trigger()
  3045. return
  3046. # Jump to coords
  3047. if key == QtCore.Qt.Key_J or key == 'J':
  3048. self.app.on_jump_to()
  3049. # Corner Snap
  3050. if key == QtCore.Qt.Key_K or key == 'K':
  3051. self.app.grb_editor.launched_from_shortcuts = True
  3052. self.app.ui.corner_snap_btn.trigger()
  3053. return
  3054. # Move
  3055. if key == QtCore.Qt.Key_M or key == 'M':
  3056. self.app.grb_editor.launched_from_shortcuts = True
  3057. if self.app.grb_editor.selected:
  3058. self.app.inform.emit(_("Click on target point."))
  3059. self.app.ui.aperture_move_btn.setChecked(True)
  3060. self.app.grb_editor.on_tool_select('move')
  3061. self.app.grb_editor.active_tool.set_origin(
  3062. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  3063. else:
  3064. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3065. _("Cancelled. Nothing selected to move."))
  3066. return
  3067. # Add Region Tool
  3068. if key == QtCore.Qt.Key_N or key == 'N':
  3069. self.app.grb_editor.launched_from_shortcuts = True
  3070. self.app.grb_editor.select_tool('region')
  3071. return
  3072. # Add Pad Tool
  3073. if key == QtCore.Qt.Key_P or key == 'P':
  3074. self.app.grb_editor.launched_from_shortcuts = True
  3075. self.app.inform.emit(_("Click on target point."))
  3076. self.app.ui.add_pad_ar_btn.setChecked(True)
  3077. self.app.grb_editor.x = self.app.mouse[0]
  3078. self.app.grb_editor.y = self.app.mouse[1]
  3079. self.app.grb_editor.select_tool('pad')
  3080. return
  3081. # Scale Tool
  3082. if key == QtCore.Qt.Key_S or key == 'S':
  3083. self.app.grb_editor.launched_from_shortcuts = True
  3084. self.app.grb_editor.select_tool('scale')
  3085. return
  3086. # Add Track
  3087. if key == QtCore.Qt.Key_T or key == 'T':
  3088. self.app.grb_editor.launched_from_shortcuts = True
  3089. # ## Current application units in Upper Case
  3090. self.app.grb_editor.select_tool('track')
  3091. return
  3092. # Zoom Fit
  3093. if key == QtCore.Qt.Key_V or key == 'V':
  3094. self.app.grb_editor.launched_from_shortcuts = True
  3095. self.app.on_zoom_fit(None)
  3096. return
  3097. # Show Shortcut list
  3098. if key == QtCore.Qt.Key_F3 or key == 'F3':
  3099. self.app.on_shortcut_list()
  3100. return
  3101. elif self.app.call_source == 'exc_editor':
  3102. if modifiers == QtCore.Qt.ControlModifier:
  3103. # save (update) the current geometry and return to the App
  3104. if key == QtCore.Qt.Key_S or key == 'S':
  3105. self.app.editor2object()
  3106. return
  3107. # toggle the measurement tool
  3108. if key == QtCore.Qt.Key_M or key == 'M':
  3109. self.app.distance_tool.run()
  3110. return
  3111. elif modifiers == QtCore.Qt.ShiftModifier:
  3112. # Run Distance Minimum Tool
  3113. if key == QtCore.Qt.Key_M or key == 'M':
  3114. self.app.distance_min_tool.run()
  3115. return
  3116. elif modifiers == QtCore.Qt.AltModifier:
  3117. pass
  3118. elif modifiers == QtCore.Qt.NoModifier:
  3119. # Abort the current action
  3120. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3121. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  3122. self.app.exc_editor.delete_utility_geometry()
  3123. self.app.exc_editor.active_tool.clean_up()
  3124. self.app.exc_editor.select_tool('drill_select')
  3125. return
  3126. # Delete selected object if delete key event comes out of canvas
  3127. if key == 'Delete':
  3128. self.app.exc_editor.launched_from_shortcuts = True
  3129. if self.app.exc_editor.selected:
  3130. self.app.exc_editor.delete_selected()
  3131. self.app.exc_editor.replot()
  3132. else:
  3133. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3134. _("Cancelled. Nothing selected to delete."))
  3135. return
  3136. # Delete tools in tools table if delete key event comes from the Selected Tab
  3137. if key == QtCore.Qt.Key_Delete:
  3138. self.app.exc_editor.launched_from_shortcuts = True
  3139. self.app.exc_editor.on_tool_delete()
  3140. return
  3141. if key == QtCore.Qt.Key_Minus or key == '-':
  3142. self.app.exc_editor.launched_from_shortcuts = True
  3143. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  3144. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  3145. return
  3146. if key == QtCore.Qt.Key_Equal or key == '=':
  3147. self.app.exc_editor.launched_from_shortcuts = True
  3148. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  3149. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  3150. return
  3151. # toggle display of Notebook area
  3152. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  3153. self.app.exc_editor.launched_from_shortcuts = True
  3154. self.app.on_toggle_notebook()
  3155. return
  3156. # Switch to Project Tab
  3157. if key == QtCore.Qt.Key_1 or key == '1':
  3158. self.app.exc_editor.launched_from_shortcuts = True
  3159. self.app.on_select_tab('project')
  3160. return
  3161. # Switch to Selected Tab
  3162. if key == QtCore.Qt.Key_2 or key == '2':
  3163. self.app.exc_editor.launched_from_shortcuts = True
  3164. self.app.on_select_tab('selected')
  3165. return
  3166. # Switch to Tool Tab
  3167. if key == QtCore.Qt.Key_3 or key == '3':
  3168. self.app.exc_editor.launched_from_shortcuts = True
  3169. self.app.on_select_tab('tool')
  3170. return
  3171. # Grid Snap
  3172. if key == QtCore.Qt.Key_G or key == 'G':
  3173. self.app.exc_editor.launched_from_shortcuts = True
  3174. # make sure that the cursor shape is enabled/disabled, too
  3175. if self.app.exc_editor.options['grid_snap'] is True:
  3176. self.app.app_cursor.enabled = False
  3177. else:
  3178. self.app.app_cursor.enabled = True
  3179. self.app.ui.grid_snap_btn.trigger()
  3180. return
  3181. # Corner Snap
  3182. if key == QtCore.Qt.Key_K or key == 'K':
  3183. self.app.exc_editor.launched_from_shortcuts = True
  3184. self.app.ui.corner_snap_btn.trigger()
  3185. return
  3186. # Zoom Fit
  3187. if key == QtCore.Qt.Key_V or key == 'V':
  3188. self.app.exc_editor.launched_from_shortcuts = True
  3189. self.app.on_zoom_fit(None)
  3190. return
  3191. # Add Slot Hole Tool
  3192. if key == QtCore.Qt.Key_W or key == 'W':
  3193. self.app.exc_editor.launched_from_shortcuts = True
  3194. self.app.inform.emit(_("Click on target point."))
  3195. self.app.ui.add_slot_btn.setChecked(True)
  3196. self.app.exc_editor.x = self.app.mouse[0]
  3197. self.app.exc_editor.y = self.app.mouse[1]
  3198. self.app.exc_editor.select_tool('slot_add')
  3199. return
  3200. # Propagate to tool
  3201. response = None
  3202. # Show Shortcut list
  3203. if key == QtCore.Qt.Key_F3 or key == 'F3':
  3204. self.app.on_shortcut_list()
  3205. return
  3206. # we do this so we can reuse the following keys while inside a Tool
  3207. # the above keys are general enough so were left outside
  3208. if self.app.exc_editor.active_tool is not None and self.select_drill_btn.isChecked() is False:
  3209. response = self.app.exc_editor.active_tool.on_key(key=key)
  3210. if response is not None:
  3211. self.app.inform.emit(response)
  3212. else:
  3213. # Add Array of Drill Hole Tool
  3214. if key == QtCore.Qt.Key_A or key == 'A':
  3215. self.app.exc_editor.launched_from_shortcuts = True
  3216. self.app.inform.emit("Click on target point.")
  3217. self.app.ui.add_drill_array_btn.setChecked(True)
  3218. self.app.exc_editor.x = self.app.mouse[0]
  3219. self.app.exc_editor.y = self.app.mouse[1]
  3220. self.app.exc_editor.select_tool('drill_array')
  3221. return
  3222. # Copy
  3223. if key == QtCore.Qt.Key_C or key == 'C':
  3224. self.app.exc_editor.launched_from_shortcuts = True
  3225. if self.app.exc_editor.selected:
  3226. self.app.inform.emit(_("Click on target point."))
  3227. self.app.ui.copy_drill_btn.setChecked(True)
  3228. self.app.exc_editor.on_tool_select('drill_copy')
  3229. self.app.exc_editor.active_tool.set_origin(
  3230. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  3231. else:
  3232. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3233. _("Cancelled. Nothing selected to copy."))
  3234. return
  3235. # Add Drill Hole Tool
  3236. if key == QtCore.Qt.Key_D or key == 'D':
  3237. self.app.exc_editor.launched_from_shortcuts = True
  3238. self.app.inform.emit(_("Click on target point."))
  3239. self.app.ui.add_drill_btn.setChecked(True)
  3240. self.app.exc_editor.x = self.app.mouse[0]
  3241. self.app.exc_editor.y = self.app.mouse[1]
  3242. self.app.exc_editor.select_tool('drill_add')
  3243. return
  3244. # Jump to coords
  3245. if key == QtCore.Qt.Key_J or key == 'J':
  3246. self.app.on_jump_to()
  3247. # Move
  3248. if key == QtCore.Qt.Key_M or key == 'M':
  3249. self.app.exc_editor.launched_from_shortcuts = True
  3250. if self.app.exc_editor.selected:
  3251. self.app.inform.emit(_("Click on target point."))
  3252. self.app.ui.move_drill_btn.setChecked(True)
  3253. self.app.exc_editor.on_tool_select('drill_move')
  3254. self.app.exc_editor.active_tool.set_origin(
  3255. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  3256. else:
  3257. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3258. _("Cancelled. Nothing selected to move."))
  3259. return
  3260. # Add Array of Slots Hole Tool
  3261. if key == QtCore.Qt.Key_Q or key == 'Q':
  3262. self.app.exc_editor.launched_from_shortcuts = True
  3263. self.app.inform.emit("Click on target point.")
  3264. self.app.ui.add_slot_array_btn.setChecked(True)
  3265. self.app.exc_editor.x = self.app.mouse[0]
  3266. self.app.exc_editor.y = self.app.mouse[1]
  3267. self.app.exc_editor.select_tool('slot_array')
  3268. return
  3269. # Resize Tool
  3270. if key == QtCore.Qt.Key_R or key == 'R':
  3271. self.app.exc_editor.launched_from_shortcuts = True
  3272. self.app.exc_editor.select_tool('drill_resize')
  3273. return
  3274. # Add Tool
  3275. if key == QtCore.Qt.Key_T or key == 'T':
  3276. self.app.exc_editor.launched_from_shortcuts = True
  3277. # ## Current application units in Upper Case
  3278. self.units = self.general_defaults_form.general_app_group.units_radio.get_value().upper()
  3279. tool_add_popup = FCInputDialog(title=_("New Tool ..."),
  3280. text='%s:' % _('Enter a Tool Diameter'),
  3281. min=0.0000, max=99.9999, decimals=4)
  3282. tool_add_popup.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/letter_t_32.png'))
  3283. val, ok = tool_add_popup.get_value()
  3284. if ok:
  3285. self.app.exc_editor.on_tool_add(tooldia=val)
  3286. formated_val = '%.*f' % (self.decimals, float(val))
  3287. self.app.inform.emit(
  3288. '[success] %s: %s %s' % (_("Added new tool with dia"), formated_val, str(self.units))
  3289. )
  3290. else:
  3291. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Adding Tool cancelled ..."))
  3292. return
  3293. elif self.app.call_source == 'measurement':
  3294. if modifiers == QtCore.Qt.ControlModifier:
  3295. pass
  3296. elif modifiers == QtCore.Qt.AltModifier:
  3297. pass
  3298. elif modifiers == QtCore.Qt.ShiftModifier:
  3299. pass
  3300. elif modifiers == QtCore.Qt.NoModifier:
  3301. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3302. # abort the measurement action
  3303. self.app.distance_tool.deactivate_measure_tool()
  3304. self.app.inform.emit(_("Distance Tool exit..."))
  3305. return
  3306. if key == QtCore.Qt.Key_G or key == 'G':
  3307. self.app.ui.grid_snap_btn.trigger()
  3308. return
  3309. # Jump to coords
  3310. if key == QtCore.Qt.Key_J or key == 'J':
  3311. self.app.on_jump_to()
  3312. elif self.app.call_source == 'qrcode_tool':
  3313. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  3314. if key == QtCore.Qt.Key_X:
  3315. self.app.abort_all_tasks()
  3316. return
  3317. elif modifiers == QtCore.Qt.ControlModifier:
  3318. pass
  3319. elif modifiers == QtCore.Qt.ShiftModifier:
  3320. pass
  3321. elif modifiers == QtCore.Qt.AltModifier:
  3322. pass
  3323. elif modifiers == QtCore.Qt.NoModifier:
  3324. # Escape = Deselect All
  3325. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3326. self.app.qrcode_tool.on_exit()
  3327. # Grid toggle
  3328. if key == QtCore.Qt.Key_G:
  3329. self.app.ui.grid_snap_btn.trigger()
  3330. # Jump to coords
  3331. if key == QtCore.Qt.Key_J:
  3332. self.app.on_jump_to()
  3333. elif self.app.call_source == 'copper_thieving_tool':
  3334. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  3335. if key == QtCore.Qt.Key_X:
  3336. self.app.abort_all_tasks()
  3337. return
  3338. elif modifiers == QtCore.Qt.ControlModifier:
  3339. pass
  3340. elif modifiers == QtCore.Qt.ShiftModifier:
  3341. pass
  3342. elif modifiers == QtCore.Qt.AltModifier:
  3343. pass
  3344. elif modifiers == QtCore.Qt.NoModifier:
  3345. # Escape = Deselect All
  3346. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3347. self.app.copperfill_tool.on_exit()
  3348. # Grid toggle
  3349. if key == QtCore.Qt.Key_G:
  3350. self.app.ui.grid_snap_btn.trigger()
  3351. # Jump to coords
  3352. if key == QtCore.Qt.Key_J:
  3353. self.app.on_jump_to()
  3354. def createPopupMenu(self):
  3355. menu = super().createPopupMenu()
  3356. menu.addSeparator()
  3357. menu.addAction(self.lock_action)
  3358. return menu
  3359. def lock_toolbar(self, lock=False):
  3360. """
  3361. Used to (un)lock the toolbars of the app.
  3362. :param lock: boolean, will lock all toolbars in place when set True
  3363. :return: None
  3364. """
  3365. if lock:
  3366. for widget in self.children():
  3367. if isinstance(widget, QtWidgets.QToolBar):
  3368. widget.setMovable(False)
  3369. else:
  3370. for widget in self.children():
  3371. if isinstance(widget, QtWidgets.QToolBar):
  3372. widget.setMovable(True)
  3373. def dragEnterEvent(self, event):
  3374. if event.mimeData().hasUrls:
  3375. event.accept()
  3376. else:
  3377. event.ignore()
  3378. def dragMoveEvent(self, event):
  3379. if event.mimeData().hasUrls:
  3380. event.accept()
  3381. else:
  3382. event.ignore()
  3383. def dropEvent(self, event):
  3384. if event.mimeData().hasUrls:
  3385. event.setDropAction(QtCore.Qt.CopyAction)
  3386. event.accept()
  3387. for url in event.mimeData().urls():
  3388. self.filename = str(url.toLocalFile())
  3389. if self.filename == "":
  3390. self.app.inform.emit("Open cancelled.")
  3391. else:
  3392. extension = self.filename.lower().rpartition('.')[-1]
  3393. if extension in self.app.grb_list:
  3394. self.app.worker_task.emit({'fcn': self.app.open_gerber,
  3395. 'params': [self.filename]})
  3396. else:
  3397. event.ignore()
  3398. if extension in self.app.exc_list:
  3399. self.app.worker_task.emit({'fcn': self.app.open_excellon,
  3400. 'params': [self.filename]})
  3401. else:
  3402. event.ignore()
  3403. if extension in self.app.gcode_list:
  3404. self.app.worker_task.emit({'fcn': self.app.open_gcode,
  3405. 'params': [self.filename]})
  3406. else:
  3407. event.ignore()
  3408. if extension in self.app.svg_list:
  3409. object_type = 'geometry'
  3410. self.app.worker_task.emit({'fcn': self.app.import_svg,
  3411. 'params': [self.filename, object_type, None]})
  3412. if extension in self.app.dxf_list:
  3413. object_type = 'geometry'
  3414. self.app.worker_task.emit({'fcn': self.app.import_dxf,
  3415. 'params': [self.filename, object_type, None]})
  3416. if extension in self.app.pdf_list:
  3417. self.app.pdf_tool.periodic_check(1000)
  3418. self.app.worker_task.emit({'fcn': self.app.pdf_tool.open_pdf,
  3419. 'params': [self.filename]})
  3420. if extension in self.app.prj_list:
  3421. # self.app.open_project() is not Thread Safe
  3422. self.app.open_project(self.filename)
  3423. if extension in self.app.conf_list:
  3424. self.app.open_config_file(self.filename)
  3425. else:
  3426. event.ignore()
  3427. else:
  3428. event.ignore()
  3429. def closeEvent(self, event):
  3430. if self.app.save_in_progress:
  3431. self.app.inform.emit('[WARNING_NOTCL] %s' %
  3432. _("Application is saving the project. Please wait ..."))
  3433. else:
  3434. grect = self.geometry()
  3435. # self.splitter.sizes()[0] is actually the size of the "notebook"
  3436. if not self.isMaximized():
  3437. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
  3438. self.final_save.emit()
  3439. event.ignore()
  3440. class FlatCAMActivityView(QtWidgets.QWidget):
  3441. """
  3442. This class create and control the activity icon displayed in the App status bar
  3443. """
  3444. def __init__(self, app, parent=None):
  3445. super().__init__(parent=parent)
  3446. self.app = app
  3447. if self.app.defaults["global_activity_icon"] == "Ball green":
  3448. icon = self.app.resource_location + '/active_2_static.png'
  3449. movie = self.app.resource_location + "/active_2.gif"
  3450. elif self.app.defaults["global_activity_icon"] == "Ball black":
  3451. icon = self.app.resource_location + '/active_static.png'
  3452. movie = self.app.resource_location + "/active.gif"
  3453. elif self.app.defaults["global_activity_icon"] == "Arrow green":
  3454. icon = self.app.resource_location + '/active_3_static.png'
  3455. movie = self.app.resource_location + "/active_3.gif"
  3456. elif self.app.defaults["global_activity_icon"] == "Eclipse green":
  3457. icon = self.app.resource_location + '/active_4_static.png'
  3458. movie = self.app.resource_location + "/active_4.gif"
  3459. else:
  3460. icon = self.app.resource_location + '/active_static.png'
  3461. movie = self.app.resource_location + "/active.gif"
  3462. self.setMinimumWidth(200)
  3463. self.movie_path = movie
  3464. self.icon_path = icon
  3465. self.icon = QtWidgets.QLabel(self)
  3466. self.icon.setGeometry(0, 0, 16, 12)
  3467. self.movie = QtGui.QMovie(self.movie_path)
  3468. self.icon.setMovie(self.movie)
  3469. # self.movie.start()
  3470. layout = QtWidgets.QHBoxLayout()
  3471. layout.setContentsMargins(5, 0, 5, 0)
  3472. layout.setAlignment(QtCore.Qt.AlignLeft)
  3473. self.setLayout(layout)
  3474. layout.addWidget(self.icon)
  3475. self.text = QtWidgets.QLabel(self)
  3476. self.text.setText(_("Idle."))
  3477. self.icon.setPixmap(QtGui.QPixmap(self.icon_path))
  3478. layout.addWidget(self.text)
  3479. def set_idle(self):
  3480. self.movie.stop()
  3481. self.text.setText(_("Idle."))
  3482. def set_busy(self, msg, no_movie=None):
  3483. if no_movie is not True:
  3484. self.icon.setMovie(self.movie)
  3485. self.movie.start()
  3486. self.text.setText(msg)
  3487. class FlatCAMInfoBar(QtWidgets.QWidget):
  3488. """
  3489. This class create a place to display the App messages in the Status Bar
  3490. """
  3491. def __init__(self, parent=None, app=None):
  3492. super(FlatCAMInfoBar, self).__init__(parent=parent)
  3493. self.app = app
  3494. self.icon = QtWidgets.QLabel(self)
  3495. self.icon.setGeometry(0, 0, 12, 12)
  3496. self.pmap = QtGui.QPixmap(self.app.resource_location + '/graylight12.png')
  3497. self.icon.setPixmap(self.pmap)
  3498. layout = QtWidgets.QHBoxLayout()
  3499. layout.setContentsMargins(5, 0, 5, 0)
  3500. self.setLayout(layout)
  3501. layout.addWidget(self.icon)
  3502. self.text = QtWidgets.QLabel(self)
  3503. self.text.setText(_("Application started ..."))
  3504. self.text.setToolTip(_("Hello!"))
  3505. layout.addWidget(self.text)
  3506. layout.addStretch()
  3507. def set_text_(self, text, color=None):
  3508. self.text.setText(text)
  3509. self.text.setToolTip(text)
  3510. if color:
  3511. self.text.setStyleSheet('color: %s' % str(color))
  3512. def set_status(self, text, level="info"):
  3513. level = str(level)
  3514. self.pmap.fill()
  3515. if level == "ERROR" or level == "ERROR_NOTCL":
  3516. self.pmap = QtGui.QPixmap(self.app.resource_location + '/redlight12.png')
  3517. elif level == "success" or level == "SUCCESS":
  3518. self.pmap = QtGui.QPixmap(self.app.resource_location + '/greenlight12.png')
  3519. elif level == "WARNING" or level == "WARNING_NOTCL":
  3520. self.pmap = QtGui.QPixmap(self.app.resource_location + '/yellowlight12.png')
  3521. elif level == "selected" or level == "SELECTED":
  3522. self.pmap = QtGui.QPixmap(self.app.resource_location + '/bluelight12.png')
  3523. else:
  3524. self.pmap = QtGui.QPixmap(self.app.resource_location + '/graylight12.png')
  3525. self.set_text_(text)
  3526. self.icon.setPixmap(self.pmap)
  3527. class FlatCAMSystemTray(QtWidgets.QSystemTrayIcon):
  3528. """
  3529. This class create the Sys Tray icon for the app
  3530. """
  3531. def __init__(self, app, icon, headless=None, parent=None):
  3532. # QtWidgets.QSystemTrayIcon.__init__(self, icon, parent)
  3533. super().__init__(icon, parent=parent)
  3534. self.app = app
  3535. menu = QtWidgets.QMenu(parent)
  3536. menu_runscript = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/script14.png'),
  3537. '%s' % _('Run Script ...'), self)
  3538. menu_runscript.setToolTip(
  3539. _("Will run the opened Tcl Script thus\n"
  3540. "enabling the automation of certain\n"
  3541. "functions of FlatCAM.")
  3542. )
  3543. menu.addAction(menu_runscript)
  3544. menu.addSeparator()
  3545. if headless is None:
  3546. self.menu_open = menu.addMenu(QtGui.QIcon(self.app.resource_location + '/folder32_bis.png'), _('Open'))
  3547. # Open Project ...
  3548. menu_openproject = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/folder16.png'),
  3549. _('Open Project ...'), self)
  3550. self.menu_open.addAction(menu_openproject)
  3551. self.menu_open.addSeparator()
  3552. # Open Gerber ...
  3553. menu_opengerber = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/flatcam_icon24.png'),
  3554. _('Open &Gerber ...\tCTRL+G'), self)
  3555. self.menu_open.addAction(menu_opengerber)
  3556. # Open Excellon ...
  3557. menu_openexcellon = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'),
  3558. _('Open &Excellon ...\tCTRL+E'), self)
  3559. self.menu_open.addAction(menu_openexcellon)
  3560. # Open G-Code ...
  3561. menu_opengcode = QtWidgets.QAction(QtGui.QIcon(self.app.resource_location + '/code.png'),
  3562. _('Open G-&Code ...'), self)
  3563. self.menu_open.addAction(menu_opengcode)
  3564. self.menu_open.addSeparator()
  3565. menu_openproject.triggered.connect(self.app.on_file_openproject)
  3566. menu_opengerber.triggered.connect(self.app.on_fileopengerber)
  3567. menu_openexcellon.triggered.connect(self.app.on_fileopenexcellon)
  3568. menu_opengcode.triggered.connect(self.app.on_fileopengcode)
  3569. exitAction = menu.addAction(_("Exit"))
  3570. exitAction.setIcon(QtGui.QIcon(self.app.resource_location + '/power16.png'))
  3571. self.setContextMenu(menu)
  3572. menu_runscript.triggered.connect(lambda: self.app.on_filerunscript(
  3573. silent=True if self.app.cmd_line_headless == 1 else False))
  3574. exitAction.triggered.connect(self.app.final_save)
  3575. # end of file