MainGUI.py 211 KB

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