MainGUI.py 230 KB

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