MainGUI.py 223 KB

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