FlatCAMGUI.py 206 KB

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