MainGUI.py 209 KB

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