MainGUI.py 207 KB

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