FlatCAMGUI.py 214 KB

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