MainGUI.py 219 KB

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