MainGUI.py 210 KB

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