FlatCAMGUI.py 195 KB

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