MainGUI.py 213 KB

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