MainGUI.py 230 KB

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