FlatCAMGUI.py 203 KB

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