MainGUI.py 213 KB

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