MainGUI.py 212 KB

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