MainGUI.py 230 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941
  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 save_geometry(self, x, y, width, height, notebook_width):
  1604. """
  1605. Will save the application geometry and positions in the defaults dicitionary to be restored at the next
  1606. launch of the application.
  1607. :param x: X position of the main window
  1608. :param y: Y position of the main window
  1609. :param width: width of the main window
  1610. :param height: height of the main window
  1611. :param notebook_width: the notebook width is adjustable so it get saved here, too.
  1612. :return: None
  1613. """
  1614. self.app.defaults["global_def_win_x"] = x
  1615. self.app.defaults["global_def_win_y"] = y
  1616. self.app.defaults["global_def_win_w"] = width
  1617. self.app.defaults["global_def_win_h"] = height
  1618. self.app.defaults["global_def_notebook_width"] = notebook_width
  1619. self.app.preferencesUiManager.save_defaults()
  1620. def restore_main_win_geom(self):
  1621. try:
  1622. self.setGeometry(self.app.defaults["global_def_win_x"],
  1623. self.app.defaults["global_def_win_y"],
  1624. self.app.defaults["global_def_win_w"],
  1625. self.app.defaults["global_def_win_h"])
  1626. self.splitter.setSizes([self.app.defaults["global_def_notebook_width"], 0])
  1627. except KeyError as e:
  1628. log.debug("appGUI.MainGUI.restore_main_win_geom() --> %s" % str(e))
  1629. def restore_toolbar_view(self):
  1630. """
  1631. Some toolbars may be hidden by user and here we restore the state of the toolbars visibility that
  1632. was saved in the defaults dictionary.
  1633. :return: None
  1634. """
  1635. tb = self.app.defaults["global_toolbar_view"]
  1636. if tb & 1:
  1637. self.toolbarfile.setVisible(True)
  1638. else:
  1639. self.toolbarfile.setVisible(False)
  1640. if tb & 2:
  1641. self.toolbaredit.setVisible(True)
  1642. else:
  1643. self.toolbaredit.setVisible(False)
  1644. if tb & 4:
  1645. self.toolbarview.setVisible(True)
  1646. else:
  1647. self.toolbarview.setVisible(False)
  1648. if tb & 8:
  1649. self.toolbartools.setVisible(True)
  1650. else:
  1651. self.toolbartools.setVisible(False)
  1652. if tb & 16:
  1653. self.exc_edit_toolbar.setVisible(True)
  1654. else:
  1655. self.exc_edit_toolbar.setVisible(False)
  1656. if tb & 32:
  1657. self.geo_edit_toolbar.setVisible(True)
  1658. else:
  1659. self.geo_edit_toolbar.setVisible(False)
  1660. if tb & 64:
  1661. self.grb_edit_toolbar.setVisible(True)
  1662. else:
  1663. self.grb_edit_toolbar.setVisible(False)
  1664. # if tb & 128:
  1665. # self.ui.grid_toolbar.setVisible(True)
  1666. # else:
  1667. # self.ui.grid_toolbar.setVisible(False)
  1668. # Grid Toolbar is controlled by its own setting
  1669. if tb & 256:
  1670. self.toolbarshell.setVisible(True)
  1671. else:
  1672. self.toolbarshell.setVisible(False)
  1673. def on_tab_setup_context_menu(self):
  1674. initial_checked = self.app.defaults["global_tabs_detachable"]
  1675. action_name = str(_("Detachable Tabs"))
  1676. action = QtWidgets.QAction(self)
  1677. action.setCheckable(True)
  1678. action.setText(action_name)
  1679. action.setChecked(initial_checked)
  1680. self.notebook.tabBar.addAction(action)
  1681. self.plot_tab_area.tabBar.addAction(action)
  1682. try:
  1683. action.triggered.disconnect()
  1684. except TypeError:
  1685. pass
  1686. action.triggered.connect(self.on_detachable_tab_rmb_click)
  1687. def on_detachable_tab_rmb_click(self, checked):
  1688. self.notebook.set_detachable(val=checked)
  1689. self.app.defaults["global_tabs_detachable"] = checked
  1690. self.plot_tab_area.set_detachable(val=checked)
  1691. self.app.defaults["global_tabs_detachable"] = checked
  1692. def build_infobar_context_menu(self):
  1693. delta_coords_action_name = str(_("Delta Coordinates Toolbar"))
  1694. delta_coords_action = QtWidgets.QAction(self)
  1695. delta_coords_action.setCheckable(True)
  1696. delta_coords_action.setText(delta_coords_action_name)
  1697. delta_coords_action.setChecked(self.app.defaults["global_delta_coordsbar_show"])
  1698. self.infobar.addAction(delta_coords_action)
  1699. delta_coords_action.triggered.connect(self.toggle_delta_coords)
  1700. coords_action_name = str(_("Coordinates Toolbar"))
  1701. coords_action = QtWidgets.QAction(self)
  1702. coords_action.setCheckable(True)
  1703. coords_action.setText(coords_action_name)
  1704. coords_action.setChecked(self.app.defaults["global_coordsbar_show"])
  1705. self.infobar.addAction(coords_action)
  1706. coords_action.triggered.connect(self.toggle_coords)
  1707. grid_action_name = str(_("Grid Toolbar"))
  1708. grid_action = QtWidgets.QAction(self)
  1709. grid_action.setCheckable(True)
  1710. grid_action.setText(grid_action_name)
  1711. grid_action.setChecked(self.app.defaults["global_gridbar_show"])
  1712. self.infobar.addAction(grid_action)
  1713. grid_action.triggered.connect(self.toggle_gridbar)
  1714. status_action_name = str(_("Status Toolbar"))
  1715. status_action = QtWidgets.QAction(self)
  1716. status_action.setCheckable(True)
  1717. status_action.setText(status_action_name)
  1718. status_action.setChecked(self.app.defaults["global_statusbar_show"])
  1719. self.infobar.addAction(status_action)
  1720. status_action.triggered.connect(self.toggle_statusbar)
  1721. def toggle_coords(self, checked):
  1722. self.app.defaults["global_coordsbar_show"] = checked
  1723. self.coords_toolbar.setVisible(checked)
  1724. def toggle_delta_coords(self, checked):
  1725. self.app.defaults["global_delta_coordsbar_show"] = checked
  1726. self.delta_coords_toolbar.setVisible(checked)
  1727. def toggle_gridbar(self, checked):
  1728. self.app.defaults["global_gridbar_show"] = checked
  1729. self.grid_toolbar.setVisible(checked)
  1730. def toggle_statusbar(self, checked):
  1731. self.app.defaults["global_statusbar_show"] = checked
  1732. self.status_toolbar.setVisible(checked)
  1733. def eventFilter(self, obj, event):
  1734. """
  1735. Filter the ToolTips display based on a Preferences setting
  1736. :param obj:
  1737. :param event: QT event to filter
  1738. :return:
  1739. """
  1740. if self.app.defaults["global_toggle_tooltips"] is False:
  1741. if event.type() == QtCore.QEvent.ToolTip:
  1742. return True
  1743. else:
  1744. return False
  1745. return False
  1746. def on_preferences_open_folder(self):
  1747. """
  1748. Will open an Explorer window set to the folder path where the FlatCAM preferences files are usually saved.
  1749. :return: None
  1750. """
  1751. if sys.platform == 'win32':
  1752. subprocess.Popen('explorer %s' % self.app.data_path)
  1753. elif sys.platform == 'darwin':
  1754. os.system('open "%s"' % self.app.data_path)
  1755. else:
  1756. subprocess.Popen(['xdg-open', self.app.data_path])
  1757. self.app.inform.emit('[success] %s' % _("FlatCAM Preferences Folder opened."))
  1758. def on_gui_clear(self, signal=None, forced_clear=False):
  1759. """
  1760. Will clear the settings that are stored in QSettings.
  1761. """
  1762. log.debug("Clearing the settings in QSettings. GUI settings cleared.")
  1763. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  1764. theme_settings.setValue('theme', 'white')
  1765. del theme_settings
  1766. resource_loc = self.app.resource_location
  1767. response = None
  1768. if forced_clear is False:
  1769. msgbox = QtWidgets.QMessageBox()
  1770. msgbox.setText(_("Are you sure you want to delete the GUI Settings? \n"))
  1771. msgbox.setWindowTitle(_("Clear GUI Settings"))
  1772. msgbox.setWindowIcon(QtGui.QIcon(resource_loc + '/trash32.png'))
  1773. msgbox.setIcon(QtWidgets.QMessageBox.Question)
  1774. bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
  1775. bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
  1776. msgbox.setDefaultButton(bt_no)
  1777. msgbox.exec_()
  1778. response = msgbox.clickedButton()
  1779. if forced_clear is True or response == bt_yes:
  1780. qsettings = QSettings("Open Source", "FlatCAM")
  1781. for key in qsettings.allKeys():
  1782. qsettings.remove(key)
  1783. # This will write the setting to the platform specific storage.
  1784. del qsettings
  1785. def populate_toolbars(self):
  1786. """
  1787. Will populate the App Toolbars with their actions
  1788. :return: None
  1789. """
  1790. # ########################################################################
  1791. # ## File Toolbar # ##
  1792. # ########################################################################
  1793. self.file_open_gerber_btn = self.toolbarfile.addAction(
  1794. QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _("Open Gerber"))
  1795. self.file_open_excellon_btn = self.toolbarfile.addAction(
  1796. QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Open Excellon"))
  1797. self.toolbarfile.addSeparator()
  1798. self.file_open_btn = self.toolbarfile.addAction(
  1799. QtGui.QIcon(self.app.resource_location + '/folder32.png'), _("Open project"))
  1800. self.file_save_btn = self.toolbarfile.addAction(
  1801. QtGui.QIcon(self.app.resource_location + '/project_save32.png'), _("Save project"))
  1802. # ########################################################################
  1803. # ## Edit Toolbar # ##
  1804. # ########################################################################
  1805. self.editgeo_btn = self.toolbaredit.addAction(
  1806. QtGui.QIcon(self.app.resource_location + '/edit32.png'), _("Editor"))
  1807. self.update_obj_btn = self.toolbaredit.addAction(
  1808. QtGui.QIcon(self.app.resource_location + '/close_edit_file32.png'),
  1809. _("Save Object and close the Editor")
  1810. )
  1811. self.toolbaredit.addSeparator()
  1812. self.copy_btn = self.toolbaredit.addAction(
  1813. QtGui.QIcon(self.app.resource_location + '/copy_file32.png'), _("Copy"))
  1814. self.delete_btn = self.toolbaredit.addAction(
  1815. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete"))
  1816. self.toolbaredit.addSeparator()
  1817. self.distance_btn = self.toolbaredit.addAction(
  1818. QtGui.QIcon(self.app.resource_location + '/distance32.png'), _("Distance Tool"))
  1819. self.distance_min_btn = self.toolbaredit.addAction(
  1820. QtGui.QIcon(self.app.resource_location + '/distance_min32.png'), _("Distance Min Tool"))
  1821. self.origin_btn = self.toolbaredit.addAction(
  1822. QtGui.QIcon(self.app.resource_location + '/origin32.png'), _('Set Origin'))
  1823. self.move2origin_btn = self.toolbaredit.addAction(
  1824. QtGui.QIcon(self.app.resource_location + '/origin2_32.png'), _('Move to Origin'))
  1825. self.jmp_btn = self.toolbaredit.addAction(
  1826. QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location'))
  1827. self.locate_btn = self.toolbaredit.addAction(
  1828. QtGui.QIcon(self.app.resource_location + '/locate32.png'), _('Locate in Object'))
  1829. # ########################################################################
  1830. # ########################## View Toolbar# ###############################
  1831. # ########################################################################
  1832. self.replot_btn = self.toolbarview.addAction(
  1833. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("Replot"))
  1834. self.clear_plot_btn = self.toolbarview.addAction(
  1835. QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("Clear plot"))
  1836. self.zoom_in_btn = self.toolbarview.addAction(
  1837. QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("Zoom In"))
  1838. self.zoom_out_btn = self.toolbarview.addAction(
  1839. QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("Zoom Out"))
  1840. self.zoom_fit_btn = self.toolbarview.addAction(
  1841. QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
  1842. # ########################################################################
  1843. # ########################## Shell Toolbar# ##############################
  1844. # ########################################################################
  1845. self.shell_btn = self.toolbarshell.addAction(
  1846. QtGui.QIcon(self.app.resource_location + '/shell32.png'), _("Command Line"))
  1847. self.new_script_btn = self.toolbarshell.addAction(
  1848. QtGui.QIcon(self.app.resource_location + '/script_new24.png'), _('New Script ...'))
  1849. self.open_script_btn = self.toolbarshell.addAction(
  1850. QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'))
  1851. self.run_script_btn = self.toolbarshell.addAction(
  1852. QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Run Script ...'))
  1853. # #########################################################################
  1854. # ######################### Tools Toolbar #################################
  1855. # #########################################################################
  1856. self.dblsided_btn = self.toolbartools.addAction(
  1857. QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2Sided Tool"))
  1858. self.align_btn = self.toolbartools.addAction(
  1859. QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects Tool"))
  1860. self.extract_btn = self.toolbartools.addAction(
  1861. QtGui.QIcon(self.app.resource_location + '/extract_drill32.png'), _("Extract Drills Tool"))
  1862. self.cutout_btn = self.toolbartools.addAction(
  1863. QtGui.QIcon(self.app.resource_location + '/cut16_bis.png'), _("Cutout Tool"))
  1864. self.ncc_btn = self.toolbartools.addAction(
  1865. QtGui.QIcon(self.app.resource_location + '/ncc16.png'), _("NCC Tool"))
  1866. self.paint_btn = self.toolbartools.addAction(
  1867. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint Tool"))
  1868. self.isolation_btn = self.toolbartools.addAction(
  1869. QtGui.QIcon(self.app.resource_location + '/iso_16.png'), _("Isolation Tool"))
  1870. self.drill_btn = self.toolbartools.addAction(
  1871. QtGui.QIcon(self.app.resource_location + '/drilling_tool32.png'), _("Drilling Tool"))
  1872. self.toolbartools.addSeparator()
  1873. self.panelize_btn = self.toolbartools.addAction(
  1874. QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel Tool"))
  1875. self.film_btn = self.toolbartools.addAction(
  1876. QtGui.QIcon(self.app.resource_location + '/film16.png'), _("Film Tool"))
  1877. self.solder_btn = self.toolbartools.addAction(
  1878. QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'), _("SolderPaste Tool"))
  1879. self.sub_btn = self.toolbartools.addAction(
  1880. QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool"))
  1881. self.rules_btn = self.toolbartools.addAction(
  1882. QtGui.QIcon(self.app.resource_location + '/rules32.png'), _("Rules Tool"))
  1883. self.optimal_btn = self.toolbartools.addAction(
  1884. QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'), _("Optimal Tool"))
  1885. self.toolbartools.addSeparator()
  1886. self.calculators_btn = self.toolbartools.addAction(
  1887. QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators Tool"))
  1888. self.transform_btn = self.toolbartools.addAction(
  1889. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool"))
  1890. self.qrcode_btn = self.toolbartools.addAction(
  1891. QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode Tool"))
  1892. self.copperfill_btn = self.toolbartools.addAction(
  1893. QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving Tool"))
  1894. self.fiducials_btn = self.toolbartools.addAction(
  1895. QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials Tool"))
  1896. self.cal_btn = self.toolbartools.addAction(
  1897. QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool"))
  1898. self.punch_btn = self.toolbartools.addAction(
  1899. QtGui.QIcon(self.app.resource_location + '/punch32.png'), _("Punch Gerber Tool"))
  1900. self.invert_btn = self.toolbartools.addAction(
  1901. QtGui.QIcon(self.app.resource_location + '/invert32.png'), _("Invert Gerber Tool"))
  1902. self.corners_tool_btn = self.toolbartools.addAction(
  1903. QtGui.QIcon(self.app.resource_location + '/corners_32.png'), _("Corner Markers Tool"))
  1904. self.etch_btn = self.toolbartools.addAction(
  1905. QtGui.QIcon(self.app.resource_location + '/etch_32.png'), _("Etch Compensation Tool"))
  1906. # ########################################################################
  1907. # ## Excellon Editor Toolbar # ##
  1908. # ########################################################################
  1909. self.select_drill_btn = self.exc_edit_toolbar.addAction(
  1910. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  1911. self.add_drill_btn = self.exc_edit_toolbar.addAction(
  1912. QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill Hole'))
  1913. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  1914. QtGui.QIcon(self.app.resource_location + '/addarray16.png'), _('Add Drill Hole Array'))
  1915. self.resize_drill_btn = self.exc_edit_toolbar.addAction(
  1916. QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill'))
  1917. self.add_slot_btn = self.exc_edit_toolbar.addAction(
  1918. QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot'))
  1919. self.add_slot_array_btn = self.exc_edit_toolbar.addAction(
  1920. QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array'))
  1921. self.exc_edit_toolbar.addSeparator()
  1922. self.copy_drill_btn = self.exc_edit_toolbar.addAction(
  1923. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy Drill'))
  1924. self.delete_drill_btn = self.exc_edit_toolbar.addAction(
  1925. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Drill"))
  1926. self.exc_edit_toolbar.addSeparator()
  1927. self.move_drill_btn = self.exc_edit_toolbar.addAction(
  1928. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Drill"))
  1929. # ########################################################################
  1930. # ## Geometry Editor Toolbar # ##
  1931. # ########################################################################
  1932. self.geo_select_btn = self.geo_edit_toolbar.addAction(
  1933. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select 'Esc'"))
  1934. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(
  1935. QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle'))
  1936. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(
  1937. QtGui.QIcon(self.app.resource_location + '/arc32.png'), _('Add Arc'))
  1938. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(
  1939. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle'))
  1940. self.geo_edit_toolbar.addSeparator()
  1941. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(
  1942. QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path'))
  1943. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(
  1944. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon'))
  1945. self.geo_edit_toolbar.addSeparator()
  1946. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(
  1947. QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text'))
  1948. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(
  1949. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Add Buffer'))
  1950. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(
  1951. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _('Paint Shape'))
  1952. self.geo_eraser_btn = self.geo_edit_toolbar.addAction(
  1953. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  1954. self.geo_edit_toolbar.addSeparator()
  1955. self.geo_union_btn = self.geo_edit_toolbar.addAction(
  1956. QtGui.QIcon(self.app.resource_location + '/union32.png'), _('Polygon Union'))
  1957. self.geo_explode_btn = self.geo_edit_toolbar.addAction(
  1958. QtGui.QIcon(self.app.resource_location + '/explode32.png'), _('Polygon Explode'))
  1959. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(
  1960. QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _('Polygon Intersection'))
  1961. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(
  1962. QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _('Polygon Subtraction'))
  1963. self.geo_edit_toolbar.addSeparator()
  1964. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(
  1965. QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _('Cut Path'))
  1966. self.geo_copy_btn = self.geo_edit_toolbar.addAction(
  1967. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy Objects"))
  1968. self.geo_delete_btn = self.geo_edit_toolbar.addAction(
  1969. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Shape"))
  1970. self.geo_transform_btn = self.geo_edit_toolbar.addAction(
  1971. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  1972. self.geo_edit_toolbar.addSeparator()
  1973. self.geo_move_btn = self.geo_edit_toolbar.addAction(
  1974. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Objects"))
  1975. # ########################################################################
  1976. # ## Gerber Editor Toolbar # ##
  1977. # ########################################################################
  1978. self.grb_select_btn = self.grb_edit_toolbar.addAction(
  1979. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  1980. self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(
  1981. QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Add Pad"))
  1982. self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(
  1983. QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array'))
  1984. self.grb_add_track_btn = self.grb_edit_toolbar.addAction(
  1985. QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Add Track"))
  1986. self.grb_add_region_btn = self.grb_edit_toolbar.addAction(
  1987. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Add Region"))
  1988. self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(
  1989. QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
  1990. self.grb_add_semidisc_btn = self.grb_edit_toolbar.addAction(
  1991. QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
  1992. self.grb_add_disc_btn = self.grb_edit_toolbar.addAction(
  1993. QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
  1994. self.grb_edit_toolbar.addSeparator()
  1995. self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(
  1996. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer'))
  1997. self.aperture_scale_btn = self.grb_edit_toolbar.addAction(
  1998. QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale'))
  1999. self.aperture_markarea_btn = self.grb_edit_toolbar.addAction(
  2000. QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area'))
  2001. self.aperture_eraser_btn = self.grb_edit_toolbar.addAction(
  2002. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  2003. self.grb_edit_toolbar.addSeparator()
  2004. self.aperture_copy_btn = self.grb_edit_toolbar.addAction(
  2005. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
  2006. self.aperture_delete_btn = self.grb_edit_toolbar.addAction(
  2007. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete"))
  2008. self.grb_transform_btn = self.grb_edit_toolbar.addAction(
  2009. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  2010. self.grb_edit_toolbar.addSeparator()
  2011. self.aperture_move_btn = self.grb_edit_toolbar.addAction(
  2012. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
  2013. self.corner_snap_btn.setVisible(False)
  2014. self.snap_magnet.setVisible(False)
  2015. qsettings = QSettings("Open Source", "FlatCAM")
  2016. if qsettings.contains("layout"):
  2017. layout = qsettings.value('layout', type=str)
  2018. # on 'minimal' layout only some toolbars are active
  2019. if layout != 'minimal':
  2020. self.exc_edit_toolbar.setVisible(True)
  2021. self.exc_edit_toolbar.setDisabled(True)
  2022. self.geo_edit_toolbar.setVisible(True)
  2023. self.geo_edit_toolbar.setDisabled(True)
  2024. self.grb_edit_toolbar.setVisible(True)
  2025. self.grb_edit_toolbar.setDisabled(True)
  2026. def keyPressEvent(self, event):
  2027. """
  2028. Key event handler for the entire app.
  2029. Some of the key events are also treated locally in the FlatCAM editors
  2030. :param event: QT event
  2031. :return:
  2032. """
  2033. modifiers = QtWidgets.QApplication.keyboardModifiers()
  2034. active = self.app.collection.get_active()
  2035. selected = self.app.collection.get_selected()
  2036. names_list = self.app.collection.get_names()
  2037. matplotlib_key_flag = False
  2038. # events out of the self.app.collection view (it's about Project Tab) are of type int
  2039. if type(event) is int:
  2040. key = event
  2041. # events from the GUI are of type QKeyEvent
  2042. elif type(event) == QtGui.QKeyEvent:
  2043. key = event.key()
  2044. elif isinstance(event, mpl_key_event): # MatPlotLib key events are trickier to interpret than the rest
  2045. matplotlib_key_flag = True
  2046. key = event.key
  2047. key = QtGui.QKeySequence(key)
  2048. # check for modifiers
  2049. key_string = key.toString().lower()
  2050. if '+' in key_string:
  2051. mod, __, key_text = key_string.rpartition('+')
  2052. if mod.lower() == 'ctrl':
  2053. modifiers = QtCore.Qt.ControlModifier
  2054. elif mod.lower() == 'alt':
  2055. modifiers = QtCore.Qt.AltModifier
  2056. elif mod.lower() == 'shift':
  2057. modifiers = QtCore.Qt.ShiftModifier
  2058. else:
  2059. modifiers = QtCore.Qt.NoModifier
  2060. key = QtGui.QKeySequence(key_text)
  2061. # events from Vispy are of type KeyEvent
  2062. else:
  2063. key = event.key
  2064. if self.app.call_source == 'app':
  2065. # CTRL + ALT
  2066. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  2067. if key == QtCore.Qt.Key_X:
  2068. self.app.abort_all_tasks()
  2069. return
  2070. # CTRL + SHIFT
  2071. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier:
  2072. if key == QtCore.Qt.Key_S:
  2073. self.app.f_handlers.on_file_saveprojectas()
  2074. return
  2075. # CTRL
  2076. elif modifiers == QtCore.Qt.ControlModifier:
  2077. # Select All
  2078. if key == QtCore.Qt.Key_A:
  2079. self.app.on_selectall()
  2080. # Copy an FlatCAM object
  2081. if key == QtCore.Qt.Key_C:
  2082. widget_name = self.plot_tab_area.currentWidget().objectName()
  2083. if widget_name == 'database_tab':
  2084. # Tools DB saved, update flag
  2085. self.app.tools_db_changed_flag = True
  2086. self.app.tools_db_tab.on_tool_copy()
  2087. return
  2088. self.app.on_copy_command()
  2089. # Copy an FlatCAM object
  2090. if key == QtCore.Qt.Key_D:
  2091. self.app.on_tools_database()
  2092. # Open Excellon file
  2093. if key == QtCore.Qt.Key_E:
  2094. self.app.f_handlers.on_fileopenexcellon(signal=None)
  2095. # Open Gerber file
  2096. if key == QtCore.Qt.Key_G:
  2097. widget_name = self.plot_tab_area.currentWidget().objectName()
  2098. if 'editor' in widget_name.lower():
  2099. self.app.goto_text_line()
  2100. else:
  2101. self.app.f_handlers.on_fileopengerber(signal=None)
  2102. # Distance Tool
  2103. if key == QtCore.Qt.Key_M:
  2104. self.app.distance_tool.run()
  2105. # Create New Project
  2106. if key == QtCore.Qt.Key_N:
  2107. self.app.f_handlers.on_file_new_click()
  2108. # Open Project
  2109. if key == QtCore.Qt.Key_O:
  2110. self.app.f_handlers.on_file_openproject(signal=None)
  2111. # Open Project
  2112. if key == QtCore.Qt.Key_P:
  2113. self.app.f_handlers.on_file_save_objects_pdf(use_thread=True)
  2114. # PDF Import
  2115. if key == QtCore.Qt.Key_Q:
  2116. self.app.pdf_tool.run()
  2117. # Save Project
  2118. if key == QtCore.Qt.Key_S:
  2119. widget_name = self.plot_tab_area.currentWidget().objectName()
  2120. if widget_name == 'preferences_tab':
  2121. self.app.preferencesUiManager.on_save_button(save_to_file=False)
  2122. return
  2123. if widget_name == 'database_tab':
  2124. # Tools DB saved, update flag
  2125. self.app.tools_db_changed_flag = False
  2126. self.app.tools_db_tab.on_save_tools_db()
  2127. return
  2128. self.app.f_handlers.on_file_saveproject()
  2129. # Toggle Plot Area
  2130. if key == QtCore.Qt.Key_F10 or key == 'F10':
  2131. self.on_toggle_plotarea()
  2132. return
  2133. # SHIFT
  2134. elif modifiers == QtCore.Qt.ShiftModifier:
  2135. # Toggle axis
  2136. if key == QtCore.Qt.Key_A:
  2137. self.app.plotcanvas.on_toggle_axis()
  2138. # Copy Object Name
  2139. if key == QtCore.Qt.Key_C:
  2140. self.app.on_copy_name()
  2141. # Toggle Code Editor
  2142. if key == QtCore.Qt.Key_E:
  2143. self.app.on_toggle_code_editor()
  2144. # Toggle Grid lines
  2145. if key == QtCore.Qt.Key_G:
  2146. self.app.plotcanvas.on_toggle_grid_lines()
  2147. return
  2148. # Toggle HUD (Heads-Up Display)
  2149. if key == QtCore.Qt.Key_H:
  2150. self.app.plotcanvas.on_toggle_hud()
  2151. # Locate in Object
  2152. if key == QtCore.Qt.Key_J:
  2153. self.app.on_locate(obj=self.app.collection.get_active())
  2154. # Run Distance Minimum Tool
  2155. if key == QtCore.Qt.Key_M:
  2156. self.app.distance_min_tool.run()
  2157. return
  2158. # Open Preferences Window
  2159. if key == QtCore.Qt.Key_P:
  2160. self.app.on_preferences()
  2161. return
  2162. # Rotate Object by 90 degree CCW
  2163. if key == QtCore.Qt.Key_R:
  2164. self.app.on_rotate(silent=True, preset=-float(self.app.defaults['tools_transform_rotate']))
  2165. return
  2166. # Run a Script
  2167. if key == QtCore.Qt.Key_S:
  2168. self.app.f_handlers.on_filerunscript()
  2169. return
  2170. # Toggle Workspace
  2171. if key == QtCore.Qt.Key_W:
  2172. self.app.on_workspace_toggle()
  2173. return
  2174. # Skew on X axis
  2175. if key == QtCore.Qt.Key_X:
  2176. self.app.on_skewx()
  2177. return
  2178. # Skew on Y axis
  2179. if key == QtCore.Qt.Key_Y:
  2180. self.app.on_skewy()
  2181. return
  2182. # ALT
  2183. elif modifiers == QtCore.Qt.AltModifier:
  2184. # Eanble all plots
  2185. if key == Qt.Key_1:
  2186. self.app.enable_all_plots()
  2187. # Disable all plots
  2188. if key == Qt.Key_2:
  2189. self.app.disable_all_plots()
  2190. # Disable all other plots
  2191. if key == Qt.Key_3:
  2192. self.app.enable_other_plots()
  2193. # Disable all other plots
  2194. if key == Qt.Key_4:
  2195. self.app.disable_other_plots()
  2196. # Align in Object Tool
  2197. if key == QtCore.Qt.Key_A:
  2198. self.app.align_objects_tool.run(toggle=True)
  2199. # Calculator Tool
  2200. if key == QtCore.Qt.Key_C:
  2201. self.app.calculator_tool.run(toggle=True)
  2202. # 2-Sided PCB Tool
  2203. if key == QtCore.Qt.Key_D:
  2204. self.app.dblsidedtool.run(toggle=True)
  2205. return
  2206. # Extract Drills Tool
  2207. if key == QtCore.Qt.Key_E:
  2208. # self.app.cal_exc_tool.run(toggle=True)
  2209. self.app.edrills_tool.run(toggle=True)
  2210. return
  2211. # Fiducials Tool
  2212. if key == QtCore.Qt.Key_F:
  2213. self.app.fiducial_tool.run(toggle=True)
  2214. return
  2215. # Punch Gerber Tool
  2216. if key == QtCore.Qt.Key_G:
  2217. self.app.invert_tool.run(toggle=True)
  2218. # Punch Gerber Tool
  2219. if key == QtCore.Qt.Key_H:
  2220. self.app.punch_tool.run(toggle=True)
  2221. # Isolation Tool
  2222. if key == QtCore.Qt.Key_I:
  2223. self.app.isolation_tool.run(toggle=True)
  2224. # Copper Thieving Tool
  2225. if key == QtCore.Qt.Key_J:
  2226. self.app.copper_thieving_tool.run(toggle=True)
  2227. return
  2228. # Solder Paste Dispensing Tool
  2229. if key == QtCore.Qt.Key_K:
  2230. self.app.paste_tool.run(toggle=True)
  2231. return
  2232. # Film Tool
  2233. if key == QtCore.Qt.Key_L:
  2234. self.app.film_tool.run(toggle=True)
  2235. return
  2236. # Corner Markers Tool
  2237. if key == QtCore.Qt.Key_M:
  2238. self.app.corners_tool.run(toggle=True)
  2239. return
  2240. # Non-Copper Clear Tool
  2241. if key == QtCore.Qt.Key_N:
  2242. self.app.ncclear_tool.run(toggle=True)
  2243. return
  2244. # Optimal Tool
  2245. if key == QtCore.Qt.Key_O:
  2246. self.app.optimal_tool.run(toggle=True)
  2247. return
  2248. # Paint Tool
  2249. if key == QtCore.Qt.Key_P:
  2250. self.app.paint_tool.run(toggle=True)
  2251. return
  2252. # QRCode Tool
  2253. if key == QtCore.Qt.Key_Q:
  2254. self.app.qrcode_tool.run()
  2255. return
  2256. # Rules Tool
  2257. if key == QtCore.Qt.Key_R:
  2258. self.app.rules_tool.run(toggle=True)
  2259. return
  2260. # View Source Object Content
  2261. if key == QtCore.Qt.Key_S:
  2262. self.app.on_view_source()
  2263. return
  2264. # Transformation Tool
  2265. if key == QtCore.Qt.Key_T:
  2266. self.app.transform_tool.run(toggle=True)
  2267. return
  2268. # Substract Tool
  2269. if key == QtCore.Qt.Key_W:
  2270. self.app.sub_tool.run(toggle=True)
  2271. return
  2272. # Cutout Tool
  2273. if key == QtCore.Qt.Key_X:
  2274. self.app.cutout_tool.run(toggle=True)
  2275. return
  2276. # Panelize Tool
  2277. if key == QtCore.Qt.Key_Z:
  2278. self.app.panelize_tool.run(toggle=True)
  2279. return
  2280. # Toggle Fullscreen
  2281. if key == QtCore.Qt.Key_F10 or key == 'F10':
  2282. self.on_fullscreen()
  2283. return
  2284. # NO MODIFIER
  2285. elif modifiers == QtCore.Qt.NoModifier:
  2286. # Open Manual
  2287. if key == QtCore.Qt.Key_F1 or key == 'F1':
  2288. webbrowser.open(self.app.manual_url)
  2289. # Show shortcut list
  2290. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2291. self.app.on_shortcut_list()
  2292. # Open Video Help
  2293. if key == QtCore.Qt.Key_F4 or key == 'F4':
  2294. webbrowser.open(self.app.video_url)
  2295. # Open Video Help
  2296. if key == QtCore.Qt.Key_F5 or key == 'F5':
  2297. self.app.plot_all()
  2298. # Switch to Project Tab
  2299. if key == QtCore.Qt.Key_1:
  2300. self.app.on_select_tab('project')
  2301. # Switch to Selected Tab
  2302. if key == QtCore.Qt.Key_2:
  2303. self.app.on_select_tab('properties')
  2304. # Switch to Tool Tab
  2305. if key == QtCore.Qt.Key_3:
  2306. self.app.on_select_tab('tool')
  2307. # Delete from PyQt
  2308. # It's meant to make a difference between delete objects and delete tools in
  2309. # Geometry Selected tool table
  2310. if key == QtCore.Qt.Key_Delete and matplotlib_key_flag is False:
  2311. widget_name = self.plot_tab_area.currentWidget().objectName()
  2312. if widget_name == 'database_tab':
  2313. # Tools DB saved, update flag
  2314. self.app.tools_db_changed_flag = True
  2315. self.app.tools_db_tab.on_tool_delete()
  2316. return
  2317. self.app.on_delete_keypress()
  2318. # Delete from canvas
  2319. if key == 'Delete':
  2320. # Delete via the application to
  2321. # ensure cleanup of the appGUI
  2322. if active:
  2323. active.app.on_delete()
  2324. # Escape = Deselect All
  2325. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2326. self.app.on_deselect_all()
  2327. # if in full screen, exit to normal view
  2328. if self.toggle_fscreen is True:
  2329. self.on_fullscreen(disable=True)
  2330. # try to disconnect the slot from Set Origin
  2331. try:
  2332. self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_set_zero_click)
  2333. except TypeError:
  2334. pass
  2335. self.app.inform.emit("")
  2336. # Space = Toggle Active/Inactive
  2337. if key == QtCore.Qt.Key_Space:
  2338. for select in selected:
  2339. select.ui.plot_cb.toggle()
  2340. QtWidgets.QApplication.processEvents()
  2341. self.app.collection.update_view()
  2342. self.app.delete_selection_shape()
  2343. # Select the object in the Tree above the current one
  2344. if key == QtCore.Qt.Key_Up:
  2345. # make sure it works only for the Project Tab who is an instance of KeySensitiveListView
  2346. focused_wdg = QtWidgets.QApplication.focusWidget()
  2347. if isinstance(focused_wdg, KeySensitiveListView):
  2348. self.app.collection.set_all_inactive()
  2349. if active is None:
  2350. return
  2351. active_name = active.options['name']
  2352. active_index = names_list.index(active_name)
  2353. if active_index == 0:
  2354. self.app.collection.set_active(names_list[-1])
  2355. else:
  2356. self.app.collection.set_active(names_list[active_index - 1])
  2357. # Select the object in the Tree below the current one
  2358. if key == QtCore.Qt.Key_Down:
  2359. # make sure it works only for the Project Tab who is an instance of KeySensitiveListView
  2360. focused_wdg = QtWidgets.QApplication.focusWidget()
  2361. if isinstance(focused_wdg, KeySensitiveListView):
  2362. self.app.collection.set_all_inactive()
  2363. if active is None:
  2364. return
  2365. active_name = active.options['name']
  2366. active_index = names_list.index(active_name)
  2367. if active_index == len(names_list) - 1:
  2368. self.app.collection.set_active(names_list[0])
  2369. else:
  2370. self.app.collection.set_active(names_list[active_index + 1])
  2371. # New Geometry
  2372. if key == QtCore.Qt.Key_B:
  2373. self.app.app_obj.new_gerber_object()
  2374. # New Document Object
  2375. if key == QtCore.Qt.Key_D:
  2376. self.app.app_obj.new_document_object()
  2377. # Copy Object Name
  2378. if key == QtCore.Qt.Key_E:
  2379. self.app.object2editor()
  2380. # Grid toggle
  2381. if key == QtCore.Qt.Key_G:
  2382. self.app.ui.grid_snap_btn.trigger()
  2383. # Jump to coords
  2384. if key == QtCore.Qt.Key_J:
  2385. self.app.on_jump_to()
  2386. # New Excellon
  2387. if key == QtCore.Qt.Key_L:
  2388. self.app.app_obj.new_excellon_object()
  2389. # Move tool toggle
  2390. if key == QtCore.Qt.Key_M:
  2391. self.app.move_tool.toggle()
  2392. # New Geometry
  2393. if key == QtCore.Qt.Key_N:
  2394. self.app.app_obj.new_geometry_object()
  2395. # Set Origin
  2396. if key == QtCore.Qt.Key_O:
  2397. self.app.on_set_origin()
  2398. return
  2399. # Properties Tool
  2400. if key == QtCore.Qt.Key_P:
  2401. self.app.properties_tool.run()
  2402. return
  2403. # Change Units
  2404. if key == QtCore.Qt.Key_Q:
  2405. # if self.app.defaults["units"] == 'MM':
  2406. # self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("IN")
  2407. # else:
  2408. # self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("MM")
  2409. # self.app.on_toggle_units(no_pref=True)
  2410. self.app.on_toggle_units_click()
  2411. # Rotate Object by 90 degree CW
  2412. if key == QtCore.Qt.Key_R:
  2413. self.app.on_rotate(silent=True, preset=self.app.defaults['tools_transform_rotate'])
  2414. # Shell toggle
  2415. if key == QtCore.Qt.Key_S:
  2416. self.toggle_shell_ui()
  2417. # Add a Tool from shortcut
  2418. if key == QtCore.Qt.Key_T:
  2419. widget_name = self.plot_tab_area.currentWidget().objectName()
  2420. if widget_name == 'database_tab':
  2421. # Tools DB saved, update flag
  2422. self.app.tools_db_changed_flag = True
  2423. self.app.tools_db_tab.on_tool_add()
  2424. return
  2425. self.app.on_tool_add_keypress()
  2426. # Zoom Fit
  2427. if key == QtCore.Qt.Key_V:
  2428. self.app.on_zoom_fit()
  2429. # Mirror on X the selected object(s)
  2430. if key == QtCore.Qt.Key_X:
  2431. self.app.on_flipx()
  2432. # Mirror on Y the selected object(s)
  2433. if key == QtCore.Qt.Key_Y:
  2434. self.app.on_flipy()
  2435. # Zoom In
  2436. if key == QtCore.Qt.Key_Equal:
  2437. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], self.app.mouse)
  2438. # Zoom Out
  2439. if key == QtCore.Qt.Key_Minus:
  2440. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], self.app.mouse)
  2441. # toggle display of Notebook area
  2442. if key == QtCore.Qt.Key_QuoteLeft:
  2443. self.on_toggle_notebook()
  2444. return
  2445. elif self.app.call_source == 'geo_editor':
  2446. # CTRL
  2447. if modifiers == QtCore.Qt.ControlModifier:
  2448. # save (update) the current geometry and return to the App
  2449. if key == QtCore.Qt.Key_S or key == 'S':
  2450. self.app.editor2object()
  2451. return
  2452. # toggle the measurement tool
  2453. if key == QtCore.Qt.Key_M or key == 'M':
  2454. self.app.distance_tool.run()
  2455. return
  2456. # Cut Action Tool
  2457. if key == QtCore.Qt.Key_X or key == 'X':
  2458. if self.app.geo_editor.get_selected() is not None:
  2459. self.app.geo_editor.cutpath()
  2460. else:
  2461. msg = _('Please first select a geometry item to be cutted\n'
  2462. 'then select the geometry item that will be cutted\n'
  2463. 'out of the first item. In the end press ~X~ key or\n'
  2464. 'the toolbar button.')
  2465. messagebox = QtWidgets.QMessageBox()
  2466. messagebox.setText(msg)
  2467. messagebox.setWindowTitle(_("Warning"))
  2468. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2469. messagebox.setIcon(QtWidgets.QMessageBox.Question)
  2470. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2471. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2472. messagebox.exec_()
  2473. return
  2474. # SHIFT
  2475. elif modifiers == QtCore.Qt.ShiftModifier:
  2476. # Run Distance Minimum Tool
  2477. if key == QtCore.Qt.Key_M or key == 'M':
  2478. self.app.distance_min_tool.run()
  2479. return
  2480. # Skew on X axis
  2481. if key == QtCore.Qt.Key_X or key == 'X':
  2482. self.app.geo_editor.transform_tool.on_skewx_key()
  2483. return
  2484. # Skew on Y axis
  2485. if key == QtCore.Qt.Key_Y or key == 'Y':
  2486. self.app.geo_editor.transform_tool.on_skewy_key()
  2487. return
  2488. # ALT
  2489. elif modifiers == QtCore.Qt.AltModifier:
  2490. # Transformation Tool
  2491. if key == QtCore.Qt.Key_R or key == 'R':
  2492. self.app.geo_editor.select_tool('transform')
  2493. return
  2494. # Offset on X axis
  2495. if key == QtCore.Qt.Key_X or key == 'X':
  2496. self.app.geo_editor.transform_tool.on_offx_key()
  2497. return
  2498. # Offset on Y axis
  2499. if key == QtCore.Qt.Key_Y or key == 'Y':
  2500. self.app.geo_editor.transform_tool.on_offy_key()
  2501. return
  2502. # NO MODIFIER
  2503. elif modifiers == QtCore.Qt.NoModifier:
  2504. # toggle display of Notebook area
  2505. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2506. self.on_toggle_notebook()
  2507. # Finish the current action. Use with tools that do not
  2508. # complete automatically, like a polygon or path.
  2509. if key == QtCore.Qt.Key_Enter or key == 'Enter':
  2510. if isinstance(self.app.geo_editor.active_tool, FCShapeTool):
  2511. if self.app.geo_editor.active_tool.name == 'rotate':
  2512. self.app.geo_editor.active_tool.make()
  2513. if self.app.geo_editor.active_tool.complete:
  2514. self.app.geo_editor.on_shape_complete()
  2515. self.app.inform.emit('[success] %s' % _("Done."))
  2516. # automatically make the selection tool active after completing current action
  2517. self.app.geo_editor.select_tool('select')
  2518. return
  2519. else:
  2520. self.app.geo_editor.active_tool.click(
  2521. self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
  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. # Abort the current action
  2529. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2530. # self.on_tool_select("select")
  2531. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  2532. self.app.geo_editor.delete_utility_geometry()
  2533. self.app.geo_editor.active_tool.clean_up()
  2534. self.app.geo_editor.select_tool('select')
  2535. # hide the notebook
  2536. self.app.ui.splitter.setSizes([0, 1])
  2537. return
  2538. # Delete selected object
  2539. if key == QtCore.Qt.Key_Delete or key == 'Delete':
  2540. self.app.geo_editor.delete_selected()
  2541. self.app.geo_editor.replot()
  2542. # Rotate
  2543. if key == QtCore.Qt.Key_Space or key == 'Space':
  2544. self.app.geo_editor.transform_tool.on_rotate_key()
  2545. # Zoom Out
  2546. if key == QtCore.Qt.Key_Minus or key == '-':
  2547. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  2548. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2549. # Zoom In
  2550. if key == QtCore.Qt.Key_Equal or key == '=':
  2551. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  2552. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2553. # Switch to Project Tab
  2554. if key == QtCore.Qt.Key_1 or key == '1':
  2555. self.app.on_select_tab('project')
  2556. # Switch to Selected Tab
  2557. if key == QtCore.Qt.Key_2 or key == '2':
  2558. self.app.on_select_tab('selected')
  2559. # Switch to Tool Tab
  2560. if key == QtCore.Qt.Key_3 or key == '3':
  2561. self.app.on_select_tab('tool')
  2562. # Grid Snap
  2563. if key == QtCore.Qt.Key_G or key == 'G':
  2564. self.app.ui.grid_snap_btn.trigger()
  2565. # make sure that the cursor shape is enabled/disabled, too
  2566. if self.app.geo_editor.options['grid_snap'] is True:
  2567. self.app.app_cursor.enabled = True
  2568. else:
  2569. self.app.app_cursor.enabled = False
  2570. # Corner Snap
  2571. if key == QtCore.Qt.Key_K or key == 'K':
  2572. self.app.geo_editor.on_corner_snap()
  2573. if key == QtCore.Qt.Key_V or key == 'V':
  2574. self.app.on_zoom_fit()
  2575. # we do this so we can reuse the following keys while inside a Tool
  2576. # the above keys are general enough so were left outside
  2577. if self.app.geo_editor.active_tool is not None and self.geo_select_btn.isChecked() is False:
  2578. response = self.app.geo_editor.active_tool.on_key(key=key)
  2579. if response is not None:
  2580. self.app.inform.emit(response)
  2581. else:
  2582. # Arc Tool
  2583. if key == QtCore.Qt.Key_A or key == 'A':
  2584. self.app.geo_editor.select_tool('arc')
  2585. # Buffer
  2586. if key == QtCore.Qt.Key_B or key == 'B':
  2587. self.app.geo_editor.select_tool('buffer')
  2588. # Copy
  2589. if key == QtCore.Qt.Key_C or key == 'C':
  2590. self.app.geo_editor.on_copy_click()
  2591. # Substract Tool
  2592. if key == QtCore.Qt.Key_E or key == 'E':
  2593. if self.app.geo_editor.get_selected() is not None:
  2594. self.app.geo_editor.intersection()
  2595. else:
  2596. msg = _("Please select geometry items \n"
  2597. "on which to perform Intersection Tool.")
  2598. messagebox = QtWidgets.QMessageBox()
  2599. messagebox.setText(msg)
  2600. messagebox.setWindowTitle(_("Warning"))
  2601. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2602. messagebox.setIcon(QtWidgets.QMessageBox.Warning)
  2603. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2604. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2605. messagebox.exec_()
  2606. # Paint
  2607. if key == QtCore.Qt.Key_I or key == 'I':
  2608. self.app.geo_editor.select_tool('paint')
  2609. # Jump to coords
  2610. if key == QtCore.Qt.Key_J or key == 'J':
  2611. self.app.on_jump_to()
  2612. # Move
  2613. if key == QtCore.Qt.Key_M or key == 'M':
  2614. self.app.geo_editor.on_move_click()
  2615. # Polygon Tool
  2616. if key == QtCore.Qt.Key_N or key == 'N':
  2617. self.app.geo_editor.select_tool('polygon')
  2618. # Circle Tool
  2619. if key == QtCore.Qt.Key_O or key == 'O':
  2620. self.app.geo_editor.select_tool('circle')
  2621. # Path Tool
  2622. if key == QtCore.Qt.Key_P or key == 'P':
  2623. self.app.geo_editor.select_tool('path')
  2624. # Rectangle Tool
  2625. if key == QtCore.Qt.Key_R or key == 'R':
  2626. self.app.geo_editor.select_tool('rectangle')
  2627. # Substract Tool
  2628. if key == QtCore.Qt.Key_S or key == 'S':
  2629. if self.app.geo_editor.get_selected() is not None:
  2630. self.app.geo_editor.subtract()
  2631. else:
  2632. msg = _(
  2633. "Please select geometry items \n"
  2634. "on which to perform Substraction Tool.")
  2635. messagebox = QtWidgets.QMessageBox()
  2636. messagebox.setText(msg)
  2637. messagebox.setWindowTitle(_("Warning"))
  2638. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2639. messagebox.setIcon(QtWidgets.QMessageBox.Warning)
  2640. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2641. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2642. messagebox.exec_()
  2643. # Add Text Tool
  2644. if key == QtCore.Qt.Key_T or key == 'T':
  2645. self.app.geo_editor.select_tool('text')
  2646. # Substract Tool
  2647. if key == QtCore.Qt.Key_U or key == 'U':
  2648. if self.app.geo_editor.get_selected() is not None:
  2649. self.app.geo_editor.union()
  2650. else:
  2651. msg = _("Please select geometry items \n"
  2652. "on which to perform union.")
  2653. messagebox = QtWidgets.QMessageBox()
  2654. messagebox.setText(msg)
  2655. messagebox.setWindowTitle(_("Warning"))
  2656. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2657. messagebox.setIcon(QtWidgets.QMessageBox.Warning)
  2658. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2659. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2660. messagebox.exec_()
  2661. # Flip on X axis
  2662. if key == QtCore.Qt.Key_X or key == 'X':
  2663. self.app.geo_editor.transform_tool.on_flipx()
  2664. return
  2665. # Flip on Y axis
  2666. if key == QtCore.Qt.Key_Y or key == 'Y':
  2667. self.app.geo_editor.transform_tool.on_flipy()
  2668. return
  2669. # Show Shortcut list
  2670. if key == 'F3':
  2671. self.app.on_shortcut_list()
  2672. elif self.app.call_source == 'grb_editor':
  2673. # CTRL
  2674. if modifiers == QtCore.Qt.ControlModifier:
  2675. # Eraser Tool
  2676. if key == QtCore.Qt.Key_E or key == 'E':
  2677. self.app.grb_editor.on_eraser()
  2678. return
  2679. # save (update) the current geometry and return to the App
  2680. if key == QtCore.Qt.Key_S or key == 'S':
  2681. self.app.editor2object()
  2682. return
  2683. # toggle the measurement tool
  2684. if key == QtCore.Qt.Key_M or key == 'M':
  2685. self.app.distance_tool.run()
  2686. return
  2687. # SHIFT
  2688. elif modifiers == QtCore.Qt.ShiftModifier:
  2689. # Run Distance Minimum Tool
  2690. if key == QtCore.Qt.Key_M or key == 'M':
  2691. self.app.distance_min_tool.run()
  2692. return
  2693. # ALT
  2694. elif modifiers == QtCore.Qt.AltModifier:
  2695. # Mark Area Tool
  2696. if key == QtCore.Qt.Key_A or key == 'A':
  2697. self.app.grb_editor.on_markarea()
  2698. return
  2699. # Poligonize Tool
  2700. if key == QtCore.Qt.Key_N or key == 'N':
  2701. self.app.grb_editor.on_poligonize()
  2702. return
  2703. # Transformation Tool
  2704. if key == QtCore.Qt.Key_R or key == 'R':
  2705. self.app.grb_editor.on_transform()
  2706. return
  2707. # NO MODIFIER
  2708. elif modifiers == QtCore.Qt.NoModifier:
  2709. # Abort the current action
  2710. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2711. # self.on_tool_select("select")
  2712. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  2713. self.app.grb_editor.delete_utility_geometry()
  2714. # self.app.grb_editor.plot_all()
  2715. self.app.grb_editor.active_tool.clean_up()
  2716. self.app.grb_editor.select_tool('select')
  2717. return
  2718. # Delete selected object if delete key event comes out of canvas
  2719. if key == 'Delete':
  2720. self.app.grb_editor.launched_from_shortcuts = True
  2721. if self.app.grb_editor.selected:
  2722. self.app.grb_editor.delete_selected()
  2723. self.app.grb_editor.plot_all()
  2724. else:
  2725. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to delete."))
  2726. return
  2727. # Delete aperture in apertures table if delete key event comes from the Selected Tab
  2728. if key == QtCore.Qt.Key_Delete:
  2729. self.app.grb_editor.launched_from_shortcuts = True
  2730. self.app.grb_editor.on_aperture_delete()
  2731. return
  2732. if key == QtCore.Qt.Key_Minus or key == '-':
  2733. self.app.grb_editor.launched_from_shortcuts = True
  2734. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  2735. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2736. return
  2737. if key == QtCore.Qt.Key_Equal or key == '=':
  2738. self.app.grb_editor.launched_from_shortcuts = True
  2739. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  2740. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2741. return
  2742. # toggle display of Notebook area
  2743. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2744. self.app.grb_editor.launched_from_shortcuts = True
  2745. self.on_toggle_notebook()
  2746. return
  2747. # Rotate
  2748. if key == QtCore.Qt.Key_Space or key == 'Space':
  2749. self.app.grb_editor.transform_tool.on_rotate_key()
  2750. # Switch to Project Tab
  2751. if key == QtCore.Qt.Key_1 or key == '1':
  2752. self.app.grb_editor.launched_from_shortcuts = True
  2753. self.app.on_select_tab('project')
  2754. return
  2755. # Switch to Selected Tab
  2756. if key == QtCore.Qt.Key_2 or key == '2':
  2757. self.app.grb_editor.launched_from_shortcuts = True
  2758. self.app.on_select_tab('selected')
  2759. return
  2760. # Switch to Tool Tab
  2761. if key == QtCore.Qt.Key_3 or key == '3':
  2762. self.app.grb_editor.launched_from_shortcuts = True
  2763. self.app.on_select_tab('tool')
  2764. return
  2765. # we do this so we can reuse the following keys while inside a Tool
  2766. # the above keys are general enough so were left outside
  2767. if self.app.grb_editor.active_tool is not None and self.grb_select_btn.isChecked() is False:
  2768. response = self.app.grb_editor.active_tool.on_key(key=key)
  2769. if response is not None:
  2770. self.app.inform.emit(response)
  2771. else:
  2772. # Add Array of pads
  2773. if key == QtCore.Qt.Key_A or key == 'A':
  2774. self.app.grb_editor.launched_from_shortcuts = True
  2775. self.app.inform.emit("Click on target point.")
  2776. self.app.ui.add_pad_ar_btn.setChecked(True)
  2777. self.app.grb_editor.x = self.app.mouse[0]
  2778. self.app.grb_editor.y = self.app.mouse[1]
  2779. self.app.grb_editor.select_tool('array')
  2780. return
  2781. # Scale Tool
  2782. if key == QtCore.Qt.Key_B or key == 'B':
  2783. self.app.grb_editor.launched_from_shortcuts = True
  2784. self.app.grb_editor.select_tool('buffer')
  2785. return
  2786. # Copy
  2787. if key == QtCore.Qt.Key_C or key == 'C':
  2788. self.app.grb_editor.launched_from_shortcuts = True
  2789. if self.app.grb_editor.selected:
  2790. self.app.inform.emit(_("Click on target point."))
  2791. self.app.ui.aperture_copy_btn.setChecked(True)
  2792. self.app.grb_editor.on_tool_select('copy')
  2793. self.app.grb_editor.active_tool.set_origin(
  2794. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  2795. else:
  2796. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to copy."))
  2797. return
  2798. # Add Disc Tool
  2799. if key == QtCore.Qt.Key_D or key == 'D':
  2800. self.app.grb_editor.launched_from_shortcuts = True
  2801. self.app.grb_editor.select_tool('disc')
  2802. return
  2803. # Add SemiDisc Tool
  2804. if key == QtCore.Qt.Key_E or key == 'E':
  2805. self.app.grb_editor.launched_from_shortcuts = True
  2806. self.app.grb_editor.select_tool('semidisc')
  2807. return
  2808. # Grid Snap
  2809. if key == QtCore.Qt.Key_G or key == 'G':
  2810. self.app.grb_editor.launched_from_shortcuts = True
  2811. # make sure that the cursor shape is enabled/disabled, too
  2812. if self.app.grb_editor.options['grid_snap'] is True:
  2813. self.app.app_cursor.enabled = False
  2814. else:
  2815. self.app.app_cursor.enabled = True
  2816. self.app.ui.grid_snap_btn.trigger()
  2817. return
  2818. # Jump to coords
  2819. if key == QtCore.Qt.Key_J or key == 'J':
  2820. self.app.on_jump_to()
  2821. # Corner Snap
  2822. if key == QtCore.Qt.Key_K or key == 'K':
  2823. self.app.grb_editor.launched_from_shortcuts = True
  2824. self.app.ui.corner_snap_btn.trigger()
  2825. return
  2826. # Move
  2827. if key == QtCore.Qt.Key_M or key == 'M':
  2828. self.app.grb_editor.launched_from_shortcuts = True
  2829. if self.app.grb_editor.selected:
  2830. self.app.inform.emit(_("Click on target point."))
  2831. self.app.ui.aperture_move_btn.setChecked(True)
  2832. self.app.grb_editor.on_tool_select('move')
  2833. self.app.grb_editor.active_tool.set_origin(
  2834. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  2835. else:
  2836. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to move."))
  2837. return
  2838. # Add Region Tool
  2839. if key == QtCore.Qt.Key_N or key == 'N':
  2840. self.app.grb_editor.launched_from_shortcuts = True
  2841. self.app.grb_editor.select_tool('region')
  2842. return
  2843. # Add Pad Tool
  2844. if key == QtCore.Qt.Key_P or key == 'P':
  2845. self.app.grb_editor.launched_from_shortcuts = True
  2846. self.app.inform.emit(_("Click on target point."))
  2847. self.app.ui.add_pad_ar_btn.setChecked(True)
  2848. self.app.grb_editor.x = self.app.mouse[0]
  2849. self.app.grb_editor.y = self.app.mouse[1]
  2850. self.app.grb_editor.select_tool('pad')
  2851. return
  2852. # Scale Tool
  2853. if key == QtCore.Qt.Key_S or key == 'S':
  2854. self.app.grb_editor.launched_from_shortcuts = True
  2855. self.app.grb_editor.select_tool('scale')
  2856. return
  2857. # Add Track
  2858. if key == QtCore.Qt.Key_T or key == 'T':
  2859. self.app.grb_editor.launched_from_shortcuts = True
  2860. # ## Current application units in Upper Case
  2861. self.app.grb_editor.select_tool('track')
  2862. return
  2863. # Zoom fit
  2864. if key == QtCore.Qt.Key_V or key == 'V':
  2865. self.app.grb_editor.launched_from_shortcuts = True
  2866. self.app.grb_editor.on_zoom_fit()
  2867. return
  2868. # Show Shortcut list
  2869. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2870. self.app.on_shortcut_list()
  2871. return
  2872. elif self.app.call_source == 'exc_editor':
  2873. # CTRL
  2874. if modifiers == QtCore.Qt.ControlModifier:
  2875. # save (update) the current geometry and return to the App
  2876. if key == QtCore.Qt.Key_S or key == 'S':
  2877. self.app.editor2object()
  2878. return
  2879. # toggle the measurement tool
  2880. if key == QtCore.Qt.Key_M or key == 'M':
  2881. self.app.distance_tool.run()
  2882. return
  2883. # SHIFT
  2884. elif modifiers == QtCore.Qt.ShiftModifier:
  2885. # Run Distance Minimum Tool
  2886. if key == QtCore.Qt.Key_M or key == 'M':
  2887. self.app.distance_min_tool.run()
  2888. return
  2889. # ALT
  2890. elif modifiers == QtCore.Qt.AltModifier:
  2891. pass
  2892. # NO MODIFIER
  2893. elif modifiers == QtCore.Qt.NoModifier:
  2894. # Abort the current action
  2895. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2896. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  2897. self.app.exc_editor.delete_utility_geometry()
  2898. self.app.exc_editor.active_tool.clean_up()
  2899. self.app.exc_editor.select_tool('drill_select')
  2900. return
  2901. # Delete selected object if delete key event comes out of canvas
  2902. if key == 'Delete':
  2903. self.app.exc_editor.launched_from_shortcuts = True
  2904. if self.app.exc_editor.selected:
  2905. self.app.exc_editor.delete_selected()
  2906. self.app.exc_editor.replot()
  2907. else:
  2908. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to delete."))
  2909. return
  2910. # Delete tools in tools table if delete key event comes from the Selected Tab
  2911. if key == QtCore.Qt.Key_Delete:
  2912. self.app.exc_editor.launched_from_shortcuts = True
  2913. self.app.exc_editor.on_tool_delete()
  2914. return
  2915. if key == QtCore.Qt.Key_Minus or key == '-':
  2916. self.app.exc_editor.launched_from_shortcuts = True
  2917. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  2918. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  2919. return
  2920. if key == QtCore.Qt.Key_Equal or key == '=':
  2921. self.app.exc_editor.launched_from_shortcuts = True
  2922. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  2923. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  2924. return
  2925. # toggle display of Notebook area
  2926. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2927. self.app.exc_editor.launched_from_shortcuts = True
  2928. self.on_toggle_notebook()
  2929. return
  2930. # Switch to Project Tab
  2931. if key == QtCore.Qt.Key_1 or key == '1':
  2932. self.app.exc_editor.launched_from_shortcuts = True
  2933. self.app.on_select_tab('project')
  2934. return
  2935. # Switch to Selected Tab
  2936. if key == QtCore.Qt.Key_2 or key == '2':
  2937. self.app.exc_editor.launched_from_shortcuts = True
  2938. self.app.on_select_tab('selected')
  2939. return
  2940. # Switch to Tool Tab
  2941. if key == QtCore.Qt.Key_3 or key == '3':
  2942. self.app.exc_editor.launched_from_shortcuts = True
  2943. self.app.on_select_tab('tool')
  2944. return
  2945. # Grid Snap
  2946. if key == QtCore.Qt.Key_G or key == 'G':
  2947. self.app.exc_editor.launched_from_shortcuts = True
  2948. # make sure that the cursor shape is enabled/disabled, too
  2949. if self.app.exc_editor.options['grid_snap'] is True:
  2950. self.app.app_cursor.enabled = False
  2951. else:
  2952. self.app.app_cursor.enabled = True
  2953. self.app.ui.grid_snap_btn.trigger()
  2954. return
  2955. # Corner Snap
  2956. if key == QtCore.Qt.Key_K or key == 'K':
  2957. self.app.exc_editor.launched_from_shortcuts = True
  2958. self.app.ui.corner_snap_btn.trigger()
  2959. return
  2960. # Zoom Fit
  2961. if key == QtCore.Qt.Key_V or key == 'V':
  2962. self.app.exc_editor.launched_from_shortcuts = True
  2963. self.app.on_zoom_fit()
  2964. return
  2965. # Add Slot Hole Tool
  2966. if key == QtCore.Qt.Key_W or key == 'W':
  2967. self.app.exc_editor.launched_from_shortcuts = True
  2968. self.app.inform.emit(_("Click on target point."))
  2969. self.app.ui.add_slot_btn.setChecked(True)
  2970. self.app.exc_editor.x = self.app.mouse[0]
  2971. self.app.exc_editor.y = self.app.mouse[1]
  2972. self.app.exc_editor.select_tool('slot_add')
  2973. return
  2974. # Propagate to tool
  2975. # Show Shortcut list
  2976. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2977. self.app.on_shortcut_list()
  2978. return
  2979. # we do this so we can reuse the following keys while inside a Tool
  2980. # the above keys are general enough so were left outside
  2981. if self.app.exc_editor.active_tool is not None and self.select_drill_btn.isChecked() is False:
  2982. response = self.app.exc_editor.active_tool.on_key(key=key)
  2983. if response is not None:
  2984. self.app.inform.emit(response)
  2985. else:
  2986. # Add Array of Drill Hole Tool
  2987. if key == QtCore.Qt.Key_A or key == 'A':
  2988. self.app.exc_editor.launched_from_shortcuts = True
  2989. self.app.inform.emit("Click on target point.")
  2990. self.app.ui.add_drill_array_btn.setChecked(True)
  2991. self.app.exc_editor.x = self.app.mouse[0]
  2992. self.app.exc_editor.y = self.app.mouse[1]
  2993. self.app.exc_editor.select_tool('drill_array')
  2994. return
  2995. # Copy
  2996. if key == QtCore.Qt.Key_C or key == 'C':
  2997. self.app.exc_editor.launched_from_shortcuts = True
  2998. if self.app.exc_editor.selected:
  2999. self.app.inform.emit(_("Click on target point."))
  3000. self.app.ui.copy_drill_btn.setChecked(True)
  3001. self.app.exc_editor.on_tool_select('drill_copy')
  3002. self.app.exc_editor.active_tool.set_origin(
  3003. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  3004. else:
  3005. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to copy."))
  3006. return
  3007. # Add Drill Hole Tool
  3008. if key == QtCore.Qt.Key_D or key == 'D':
  3009. self.app.exc_editor.launched_from_shortcuts = True
  3010. self.app.inform.emit(_("Click on target point."))
  3011. self.app.ui.add_drill_btn.setChecked(True)
  3012. self.app.exc_editor.x = self.app.mouse[0]
  3013. self.app.exc_editor.y = self.app.mouse[1]
  3014. self.app.exc_editor.select_tool('drill_add')
  3015. return
  3016. # Jump to coords
  3017. if key == QtCore.Qt.Key_J or key == 'J':
  3018. self.app.on_jump_to()
  3019. # Move
  3020. if key == QtCore.Qt.Key_M or key == 'M':
  3021. self.app.exc_editor.launched_from_shortcuts = True
  3022. if self.app.exc_editor.selected:
  3023. self.app.inform.emit(_("Click on target point."))
  3024. self.app.ui.move_drill_btn.setChecked(True)
  3025. self.app.exc_editor.on_tool_select('drill_move')
  3026. self.app.exc_editor.active_tool.set_origin(
  3027. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  3028. else:
  3029. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to move."))
  3030. return
  3031. # Add Array of Slots Hole Tool
  3032. if key == QtCore.Qt.Key_Q or key == 'Q':
  3033. self.app.exc_editor.launched_from_shortcuts = True
  3034. self.app.inform.emit("Click on target point.")
  3035. self.app.ui.add_slot_array_btn.setChecked(True)
  3036. self.app.exc_editor.x = self.app.mouse[0]
  3037. self.app.exc_editor.y = self.app.mouse[1]
  3038. self.app.exc_editor.select_tool('slot_array')
  3039. return
  3040. # Resize Tool
  3041. if key == QtCore.Qt.Key_R or key == 'R':
  3042. self.app.exc_editor.launched_from_shortcuts = True
  3043. self.app.exc_editor.select_tool('drill_resize')
  3044. return
  3045. # Add Tool
  3046. if key == QtCore.Qt.Key_T or key == 'T':
  3047. self.app.exc_editor.launched_from_shortcuts = True
  3048. # ## Current application units in Upper Case
  3049. self.units = self.general_defaults_form.general_app_group.units_radio.get_value().upper()
  3050. tool_add_popup = FCInputDialog(title=_("New Tool ..."),
  3051. text='%s:' % _('Enter a Tool Diameter'),
  3052. min=0.0000, max=99.9999, decimals=4)
  3053. tool_add_popup.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/letter_t_32.png'))
  3054. val, ok = tool_add_popup.get_value()
  3055. if ok:
  3056. self.app.exc_editor.on_tool_add(tooldia=val)
  3057. formated_val = '%.*f' % (self.decimals, float(val))
  3058. self.app.inform.emit(
  3059. '[success] %s: %s %s' % (_("Added new tool with dia"), formated_val, str(self.units))
  3060. )
  3061. else:
  3062. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Adding Tool cancelled ..."))
  3063. return
  3064. elif self.app.call_source == 'gcode_editor':
  3065. # CTRL
  3066. if modifiers == QtCore.Qt.ControlModifier:
  3067. # save (update) the current geometry and return to the App
  3068. if key == QtCore.Qt.Key_S or key == 'S':
  3069. self.app.editor2object()
  3070. return
  3071. # SHIFT
  3072. elif modifiers == QtCore.Qt.ShiftModifier:
  3073. pass
  3074. # ALT
  3075. elif modifiers == QtCore.Qt.AltModifier:
  3076. pass
  3077. # NO MODIFIER
  3078. elif modifiers == QtCore.Qt.NoModifier:
  3079. pass
  3080. elif self.app.call_source == 'measurement':
  3081. if modifiers == QtCore.Qt.ControlModifier:
  3082. pass
  3083. elif modifiers == QtCore.Qt.AltModifier:
  3084. pass
  3085. elif modifiers == QtCore.Qt.ShiftModifier:
  3086. pass
  3087. # NO MODIFIER
  3088. elif modifiers == QtCore.Qt.NoModifier:
  3089. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3090. # abort the measurement action
  3091. self.app.distance_tool.deactivate_measure_tool()
  3092. self.app.inform.emit(_("Distance Tool exit..."))
  3093. return
  3094. if key == QtCore.Qt.Key_G or key == 'G':
  3095. self.app.ui.grid_snap_btn.trigger()
  3096. return
  3097. # Jump to coords
  3098. if key == QtCore.Qt.Key_J or key == 'J':
  3099. self.app.on_jump_to()
  3100. elif self.app.call_source == 'qrcode_tool':
  3101. # CTRL + ALT
  3102. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  3103. if key == QtCore.Qt.Key_X:
  3104. self.app.abort_all_tasks()
  3105. return
  3106. elif modifiers == QtCore.Qt.ControlModifier:
  3107. pass
  3108. elif modifiers == QtCore.Qt.ShiftModifier:
  3109. pass
  3110. elif modifiers == QtCore.Qt.AltModifier:
  3111. pass
  3112. # NO MODIFIER
  3113. elif modifiers == QtCore.Qt.NoModifier:
  3114. # Escape = Deselect All
  3115. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3116. self.app.qrcode_tool.on_exit()
  3117. # Grid toggle
  3118. if key == QtCore.Qt.Key_G:
  3119. self.app.ui.grid_snap_btn.trigger()
  3120. # Jump to coords
  3121. if key == QtCore.Qt.Key_J:
  3122. self.app.on_jump_to()
  3123. elif self.app.call_source == 'copper_thieving_tool':
  3124. # CTRL + ALT
  3125. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  3126. if key == QtCore.Qt.Key_X:
  3127. self.app.abort_all_tasks()
  3128. return
  3129. elif modifiers == QtCore.Qt.ControlModifier:
  3130. pass
  3131. elif modifiers == QtCore.Qt.ShiftModifier:
  3132. pass
  3133. elif modifiers == QtCore.Qt.AltModifier:
  3134. pass
  3135. # NO MODIFIER
  3136. elif modifiers == QtCore.Qt.NoModifier:
  3137. # Escape = Deselect All
  3138. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3139. self.app.copperfill_tool.on_exit()
  3140. # Grid toggle
  3141. if key == QtCore.Qt.Key_G:
  3142. self.app.ui.grid_snap_btn.trigger()
  3143. # Jump to coords
  3144. if key == QtCore.Qt.Key_J:
  3145. self.app.on_jump_to()
  3146. elif self.app.call_source == 'geometry':
  3147. if modifiers == QtCore.Qt.ControlModifier:
  3148. pass
  3149. elif modifiers == QtCore.Qt.AltModifier:
  3150. pass
  3151. elif modifiers == QtCore.Qt.ShiftModifier:
  3152. pass
  3153. # NO MODIFIER
  3154. elif modifiers == QtCore.Qt.NoModifier:
  3155. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  3156. sel_obj = self.app.collection.get_active()
  3157. assert sel_obj.kind == 'geometry' or sel_obj.kind == 'excellon', \
  3158. "Expected a Geometry or Excellon Object, got %s" % type(sel_obj)
  3159. sel_obj.area_disconnect()
  3160. return
  3161. if key == QtCore.Qt.Key_G or key == 'G':
  3162. self.app.ui.grid_snap_btn.trigger()
  3163. return
  3164. # Jump to coords
  3165. if key == QtCore.Qt.Key_J or key == 'J':
  3166. self.app.on_jump_to()
  3167. def createPopupMenu(self):
  3168. menu = super().createPopupMenu()
  3169. menu.addSeparator()
  3170. menu.addAction(self.lock_action)
  3171. return menu
  3172. def lock_toolbar(self, lock=False):
  3173. """
  3174. Used to (un)lock the toolbars of the app.
  3175. :param lock: boolean, will lock all toolbars in place when set True
  3176. :return: None
  3177. """
  3178. if lock:
  3179. for widget in self.children():
  3180. if isinstance(widget, QtWidgets.QToolBar):
  3181. widget.setMovable(False)
  3182. else:
  3183. for widget in self.children():
  3184. if isinstance(widget, QtWidgets.QToolBar):
  3185. widget.setMovable(True)
  3186. def dragEnterEvent(self, event):
  3187. if event.mimeData().hasUrls:
  3188. event.accept()
  3189. else:
  3190. event.ignore()
  3191. def dragMoveEvent(self, event):
  3192. if event.mimeData().hasUrls:
  3193. event.accept()
  3194. else:
  3195. event.ignore()
  3196. def dropEvent(self, event):
  3197. if event.mimeData().hasUrls:
  3198. event.setDropAction(QtCore.Qt.CopyAction)
  3199. event.accept()
  3200. for url in event.mimeData().urls():
  3201. self.filename = str(url.toLocalFile())
  3202. if self.filename == "":
  3203. self.app.inform.emit("Cancelled.")
  3204. else:
  3205. extension = self.filename.lower().rpartition('.')[-1]
  3206. if extension in self.app.grb_list:
  3207. self.app.worker_task.emit({'fcn': self.app.f_handlers.open_gerber,
  3208. 'params': [self.filename]})
  3209. else:
  3210. event.ignore()
  3211. if extension in self.app.exc_list:
  3212. self.app.worker_task.emit({'fcn': self.app.f_handlers.open_excellon,
  3213. 'params': [self.filename]})
  3214. else:
  3215. event.ignore()
  3216. if extension in self.app.gcode_list:
  3217. self.app.worker_task.emit({'fcn': self.app.f_handlers.open_gcode,
  3218. 'params': [self.filename]})
  3219. else:
  3220. event.ignore()
  3221. if extension in self.app.svg_list:
  3222. object_type = 'geometry'
  3223. self.app.worker_task.emit({'fcn': self.app.f_handlers.import_svg,
  3224. 'params': [self.filename, object_type, None]})
  3225. if extension in self.app.dxf_list:
  3226. object_type = 'geometry'
  3227. self.app.worker_task.emit({'fcn': self.app.f_handlers.import_dxf,
  3228. 'params': [self.filename, object_type, None]})
  3229. if extension in self.app.pdf_list:
  3230. self.app.pdf_tool.periodic_check(1000)
  3231. self.app.worker_task.emit({'fcn': self.app.pdf_tool.open_pdf,
  3232. 'params': [self.filename]})
  3233. if extension in self.app.prj_list:
  3234. # self.app.open_project() is not Thread Safe
  3235. self.app.f_handlers.open_project(self.filename)
  3236. if extension in self.app.conf_list:
  3237. self.app.f_handlers.open_config_file(self.filename)
  3238. else:
  3239. event.ignore()
  3240. else:
  3241. event.ignore()
  3242. def closeEvent(self, event):
  3243. if self.app.save_in_progress:
  3244. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Application is saving the project. Please wait ..."))
  3245. else:
  3246. grect = self.geometry()
  3247. # self.splitter.sizes()[0] is actually the size of the "notebook"
  3248. if not self.isMaximized():
  3249. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
  3250. self.final_save.emit()
  3251. event.ignore()
  3252. def on_fullscreen(self, disable=False):
  3253. """
  3254. :param disable:
  3255. :return:
  3256. """
  3257. flags = self.windowFlags()
  3258. if self.toggle_fscreen is False and disable is False:
  3259. # self.ui.showFullScreen()
  3260. self.setWindowFlags(flags | Qt.FramelessWindowHint)
  3261. a = self.geometry()
  3262. self.x_pos = a.x()
  3263. self.y_pos = a.y()
  3264. self.width = a.width()
  3265. self.height = a.height()
  3266. self.titlebar_height = self.app.qapp.style().pixelMetric(QtWidgets.QStyle.PM_TitleBarHeight)
  3267. # set new geometry to full desktop rect
  3268. # Subtracting and adding the pixels below it's hack to bypass a bug in Qt5 and OpenGL that made that a
  3269. # window drawn with OpenGL in fullscreen will not show any other windows on top which means that menus and
  3270. # everything else will not work without this hack. This happen in Windows.
  3271. # https://bugreports.qt.io/browse/QTBUG-41309
  3272. desktop = self.app.qapp.desktop()
  3273. screen = desktop.screenNumber(QtGui.QCursor.pos())
  3274. rec = desktop.screenGeometry(screen)
  3275. x = rec.x() - 1
  3276. y = rec.y() - 1
  3277. h = rec.height() + 2
  3278. w = rec.width() + 2
  3279. self.setGeometry(x, y, w, h)
  3280. self.show()
  3281. # hide all Toolbars
  3282. for tb in self.findChildren(QtWidgets.QToolBar):
  3283. tb.setVisible(False)
  3284. self.coords_toolbar.setVisible(self.app.defaults["global_coordsbar_show"])
  3285. self.delta_coords_toolbar.setVisible(self.app.defaults["global_delta_coordsbar_show"])
  3286. self.grid_toolbar.setVisible(self.app.defaults["global_gridbar_show"])
  3287. self.status_toolbar.setVisible(self.app.defaults["global_statusbar_show"])
  3288. self.splitter.setSizes([0, 1])
  3289. self.toggle_fscreen = True
  3290. elif self.toggle_fscreen is True or disable is True:
  3291. self.setWindowFlags(flags & ~Qt.FramelessWindowHint)
  3292. # the additions are made to account for the pixels we subtracted/added above in the (x, y, h, w)
  3293. self.setGeometry(self.x_pos+1, self.y_pos+self.titlebar_height+4, self.width, self.height)
  3294. self.showNormal()
  3295. self.restore_toolbar_view()
  3296. self.toggle_fscreen = False
  3297. def on_toggle_plotarea(self):
  3298. """
  3299. :return:
  3300. """
  3301. try:
  3302. name = self.plot_tab_area.widget(0).objectName()
  3303. except AttributeError:
  3304. self.plot_tab_area.addTab(self.plot_tab, _("Plot Area"))
  3305. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  3306. self.plot_tab_area.protectTab(0)
  3307. return
  3308. if name != 'plotarea_tab':
  3309. self.plot_tab_area.insertTab(0, self.plot_tab, _("Plot Area"))
  3310. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  3311. self.plot_tab_area.protectTab(0)
  3312. else:
  3313. self.plot_tab_area.closeTab(0)
  3314. def on_toggle_notebook(self):
  3315. """
  3316. :return:
  3317. """
  3318. if self.splitter.sizes()[0] == 0:
  3319. self.splitter.setSizes([1, 1])
  3320. self.menu_toggle_nb.setChecked(True)
  3321. else:
  3322. self.splitter.setSizes([0, 1])
  3323. self.menu_toggle_nb.setChecked(False)
  3324. def on_toggle_grid(self):
  3325. """
  3326. :return:
  3327. """
  3328. self.grid_snap_btn.trigger()
  3329. def toggle_shell_ui(self):
  3330. """
  3331. Toggle shell dock: if is visible close it, if it is closed then open it
  3332. :return: None
  3333. """
  3334. if self.shell_dock.isVisible():
  3335. self.shell_dock.hide()
  3336. self.app.plotcanvas.native.setFocus()
  3337. else:
  3338. self.shell_dock.show()
  3339. # I want to take the focus and give it to the Tcl Shell when the Tcl Shell is run
  3340. # self.shell._edit.setFocus()
  3341. QtCore.QTimer.singleShot(0, lambda: self.shell_dock.widget()._edit.setFocus())
  3342. # HACK - simulate a mouse click - alternative
  3343. # no_km = QtCore.Qt.KeyboardModifier(QtCore.Qt.NoModifier) # no KB modifier
  3344. # pos = QtCore.QPoint((self.shell._edit.width() - 40), (self.shell._edit.height() - 2))
  3345. # e = QtGui.QMouseEvent(QtCore.QEvent.MouseButtonPress, pos, QtCore.Qt.LeftButton, QtCore.Qt.LeftButton,
  3346. # no_km)
  3347. # QtWidgets.qApp.sendEvent(self.shell._edit, e)
  3348. # f = QtGui.QMouseEvent(QtCore.QEvent.MouseButtonRelease, pos, QtCore.Qt.LeftButton, QtCore.Qt.LeftButton,
  3349. # no_km)
  3350. # QtWidgets.qApp.sendEvent(self.shell._edit, f)
  3351. def on_shelldock_toggled(self, visibility):
  3352. if visibility is True:
  3353. self.shell_status_label.setStyleSheet("""
  3354. QLabel
  3355. {
  3356. color: black;
  3357. background-color: lightcoral;
  3358. }
  3359. """)
  3360. self.app.inform[str, bool].emit(_("Shell enabled."), False)
  3361. else:
  3362. self.shell_status_label.setStyleSheet("")
  3363. self.app.inform[str, bool].emit(_("Shell disabled."), False)
  3364. class ShortcutsTab(QtWidgets.QWidget):
  3365. def __init__(self):
  3366. super(ShortcutsTab, self).__init__()
  3367. self.sh_tab_layout = QtWidgets.QVBoxLayout()
  3368. self.sh_tab_layout.setContentsMargins(2, 2, 2, 2)
  3369. self.setLayout(self.sh_tab_layout)
  3370. self.sh_hlay = QtWidgets.QHBoxLayout()
  3371. self.sh_title = QtWidgets.QTextEdit(_('<b>Shortcut Key List</b>'))
  3372. self.sh_title.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  3373. self.sh_title.setFrameStyle(QtWidgets.QFrame.NoFrame)
  3374. self.sh_title.setMaximumHeight(30)
  3375. font = self.sh_title.font()
  3376. font.setPointSize(12)
  3377. self.sh_title.setFont(font)
  3378. self.sh_tab_layout.addWidget(self.sh_title)
  3379. self.sh_tab_layout.addLayout(self.sh_hlay)
  3380. self.app_sh_msg = (
  3381. '''<b>%s</b><br>
  3382. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  3383. <tbody>
  3384. <tr height="20">
  3385. <td height="20" width="89"><strong>%s</strong></td>
  3386. <td width="194"><span style="color:#006400"><strong>&nbsp;%s</strong></span></td>
  3387. </tr>
  3388. <tr height="20">
  3389. <td height="20">&nbsp;</td>
  3390. <td>&nbsp;</td>
  3391. </tr>
  3392. <tr height="20">
  3393. <td height="20"><strong>%s</strong></td>
  3394. <td>&nbsp;%s</td>
  3395. </tr>
  3396. <tr height="20">
  3397. <td height="20"><strong>%s</strong></td>
  3398. <td>&nbsp;%s</td>
  3399. </tr>
  3400. <tr height="20">
  3401. <td height="20"><strong>%s</strong></td>
  3402. <td>&nbsp;%s</td>
  3403. </tr>
  3404. <tr height="20">
  3405. <td height="20">&nbsp;</td>
  3406. <td>&nbsp;</td>
  3407. </tr>
  3408. <tr height="20">
  3409. <td height="20"><strong>%s</strong></td>
  3410. <td>&nbsp;%s</td>
  3411. </tr>
  3412. <tr height="20">
  3413. <td height="20"><strong>%s</strong></td>
  3414. <td>&nbsp;%s</td>
  3415. </tr>
  3416. <tr height="20">
  3417. <td height="20"><strong>%s</strong></td>
  3418. <td>&nbsp;%s</td>
  3419. </tr>
  3420. <tr height="20">
  3421. <td height="20"><strong>%s</strong></td>
  3422. <td>&nbsp;%s</td>
  3423. </tr>
  3424. <tr height="20">
  3425. <td height="20"><strong>%s</strong></td>
  3426. <td>&nbsp;%s</td>
  3427. </tr>
  3428. <tr height="20">
  3429. <td height="20"><strong>%s</strong></td>
  3430. <td>&nbsp;%s</td>
  3431. </tr>
  3432. <tr height="20">
  3433. <td height="20"><strong>%s</strong></td>
  3434. <td>&nbsp;%s</td>
  3435. </tr>
  3436. <tr height="20">
  3437. <td height="20"><strong>%s</strong></td>
  3438. <td>&nbsp;%s</td>
  3439. </tr>
  3440. <tr height="20">
  3441. <td height="20"><strong>%s</strong></td>
  3442. <td>&nbsp;%s</td>
  3443. </tr>
  3444. <tr height="20">
  3445. <td height="20"><strong>%s</strong></td>
  3446. <td>&nbsp;%s</td>
  3447. </tr>
  3448. <tr height="20">
  3449. <td height="20"><strong>%s</strong></td>
  3450. <td>&nbsp;%s</td>
  3451. </tr>
  3452. <tr height="20">
  3453. <td height="20"><strong>%s</strong></td>
  3454. <td>&nbsp;%s</td>
  3455. </tr>
  3456. <tr height="20">
  3457. <td height="20"><strong%s>T</strong></td>
  3458. <td>&nbsp;%s</td>
  3459. </tr>
  3460. <tr height="20">
  3461. <td height="20"><strong>%s</strong></td>
  3462. <td>&nbsp;%s</td>
  3463. </tr>
  3464. <tr height="20">
  3465. <td height="20"><strong>%s</strong></td>
  3466. <td>&nbsp;%s</td>
  3467. </tr>
  3468. <tr height="20">
  3469. <td height="20"><strong>%s</strong></td>
  3470. <td>&nbsp;%s</td>
  3471. </tr>
  3472. <tr height="20">
  3473. <td height="20"><strong>&#39;%s&#39;</strong></td>
  3474. <td>&nbsp;%s</td>
  3475. </tr>
  3476. <tr height="20">
  3477. <td height="20"><strong>&#39;%s&#39;</strong></td>
  3478. <td>&nbsp;%s</td>
  3479. </tr>
  3480. <tr height="20">
  3481. <td height="20">&nbsp;</td>
  3482. <td>&nbsp;</td>
  3483. </tr>
  3484. <tr height="20">
  3485. <td height="20"><strong>%s</strong></td>
  3486. <td>&nbsp;%s</td>
  3487. </tr>
  3488. <tr height="20">
  3489. <td height="20"><strong>%s</strong></td>
  3490. <td>&nbsp;%s</td>
  3491. </tr>
  3492. <tr height="20">
  3493. <td height="20"><strong>%s</strong></td>
  3494. <td>&nbsp;%s</td>
  3495. </tr>
  3496. <tr height="20">
  3497. <td height="20"><strong>%s</strong></td>
  3498. <td>&nbsp;%s</td>
  3499. </tr>
  3500. <tr height="20">
  3501. <td height="20"><strong>%s</strong></td>
  3502. <td>&nbsp;%s</td>
  3503. </tr>
  3504. <tr height="20">
  3505. <td height="20"><strong>%s</strong></td>
  3506. <td>&nbsp;%s</td>
  3507. </tr>
  3508. <tr height="20">
  3509. <td height="20"><strong>%s</strong></td>
  3510. <td>&nbsp;%s</td>
  3511. </tr>
  3512. <tr height="20">
  3513. <td height="20"><strong>%s</strong></td>
  3514. <td>&nbsp;%s</td>
  3515. </tr>
  3516. <tr height="20">
  3517. <td height="20"><strong>%s</strong></td>
  3518. <td>&nbsp;%s</td>
  3519. </tr>
  3520. <tr height="20">
  3521. <td height="20"><strong>%s</strong></td>
  3522. <td>&nbsp;%s</td>
  3523. </tr>
  3524. <tr height="20">
  3525. <td height="20"><strong>%s</strong></td>
  3526. <td>&nbsp;%s</td>
  3527. </tr>
  3528. <tr height="20">
  3529. <td height="20"><strong>%s</strong></td>
  3530. <td>&nbsp;%s</td>
  3531. </tr>
  3532. <tr height="20">
  3533. <td height="20">&nbsp;</td>
  3534. <td>&nbsp;</td>
  3535. </tr>
  3536. <tr height="20">
  3537. <td height="20"><strong>%s</strong></td>
  3538. <td>&nbsp;%s</td>
  3539. </tr>
  3540. <tr height="20">
  3541. <td height="20"><strong>%s</strong></td>
  3542. <td>&nbsp;%s</td>
  3543. </tr>
  3544. <tr height="20">
  3545. <td height="20"><strong>%s</strong></td>
  3546. <td>&nbsp;%s</td>
  3547. </tr>
  3548. <tr height="20">
  3549. <td height="20"><strong>%s</strong></td>
  3550. <td>&nbsp;%s</td>
  3551. </tr>
  3552. <tr height="20">
  3553. <td height="20"><strong>%s</strong></td>
  3554. <td>&nbsp;%s</td>
  3555. </tr>
  3556. <tr height="20">
  3557. <td height="20"><strong>%s</strong></td>
  3558. <td>&nbsp;%s</td>
  3559. </tr>
  3560. <tr height="20">
  3561. <td height="20"><strong>%s</strong></td>
  3562. <td>&nbsp;%s</td>
  3563. </tr>
  3564. <tr height="20">
  3565. <td height="20"><strong>%s</strong></td>
  3566. <td>&nbsp;%s</td>
  3567. </tr>
  3568. <tr height="20">
  3569. <td height="20"><strong>%s</strong></td>
  3570. <td>&nbsp;%s</td>
  3571. </tr>
  3572. <tr height="20">
  3573. <td height="20"><strong>%s</strong></td>
  3574. <td>&nbsp;%s</td>
  3575. </tr>
  3576. <tr height="20">
  3577. <td height="20"><strong>%s</strong></td>
  3578. <td>&nbsp;%s</td>
  3579. </tr>
  3580. <tr height="20">
  3581. <td height="20"><strong>%s</strong></td>
  3582. <td>&nbsp;%s</td>
  3583. </tr>
  3584. <tr height="20">
  3585. <td height="20"><strong>%s</strong></td>
  3586. <td>&nbsp;%s</td>
  3587. </tr>
  3588. <tr height="20">
  3589. <td height="20">&nbsp;</td>
  3590. <td>&nbsp;</td>
  3591. </tr>
  3592. <tr height="20">
  3593. <td height="20"><strong>%s</strong></td>
  3594. <td>&nbsp;%s</td>
  3595. </tr>
  3596. <tr height="20">
  3597. <td height="20"><strong>%s</strong></td>
  3598. <td>&nbsp;%s</td>
  3599. </tr>
  3600. <tr height="20">
  3601. <td height="20"><strong>%s</strong></td>
  3602. <td>&nbsp;%s</td>
  3603. </tr>
  3604. <tr height="20">
  3605. <td height="20"><strong>%s</strong></td>
  3606. <td>&nbsp;%s</td>
  3607. </tr>
  3608. </tr>
  3609. <tr height="20">
  3610. <td height="20"><strong>%s</strong></td>
  3611. <td>&nbsp;%s</td>
  3612. </tr>
  3613. </tr>
  3614. <tr height="20">
  3615. <td height="20"><strong>%s</strong></td>
  3616. <td>&nbsp;%s</td>
  3617. </tr>
  3618. <tr height="20">
  3619. <td height="20"><strong>%s</strong></td>
  3620. <td>&nbsp;%s</td>
  3621. </tr>
  3622. <tr height="20">
  3623. <td height="20"><strong>%s</strong></td>
  3624. <td>&nbsp;%s</td>
  3625. </tr>
  3626. <tr height="20">
  3627. <td height="20"><strong>%s</strong></td>
  3628. <td>&nbsp;%s</td>
  3629. </tr>
  3630. <tr height="20">
  3631. <td height="20"><strong>%s</strong></td>
  3632. <td>&nbsp;%s</td>
  3633. </tr>
  3634. <tr height="20">
  3635. <td height="20"><strong>%s</strong></td>
  3636. <td>&nbsp;%s</td>
  3637. </tr>
  3638. <tr height="20">
  3639. <td height="20"><strong>%s</strong></td>
  3640. <td>&nbsp;%s</td>
  3641. </tr>
  3642. <tr height="20">
  3643. <td height="20"><strong>%s</strong></td>
  3644. <td>&nbsp;%s</td>
  3645. </tr>
  3646. <tr height="20">
  3647. <td height="20"><strong>%s</strong></td>
  3648. <td>&nbsp;%s</td>
  3649. </tr>
  3650. <tr height="20">
  3651. <td height="20"><strong>%s</strong></td>
  3652. <td>&nbsp;%s</td>
  3653. </tr>
  3654. <tr height="20">
  3655. <td height="20"><strong>%s</strong></td>
  3656. <td>&nbsp;%s</td>
  3657. </tr>
  3658. <tr height="20">
  3659. <td height="20"><strong>%s</strong></td>
  3660. <td>&nbsp;%s</td>
  3661. </tr>
  3662. <tr height="20">
  3663. <td height="20"><strong>%s</strong></td>
  3664. <td>&nbsp;%s</td>
  3665. </tr>
  3666. <tr height="20">
  3667. <td height="20"><strong>%s</strong></td>
  3668. <td>&nbsp;%s</td>
  3669. </tr>
  3670. <tr height="20">
  3671. <td height="20"><strong>%s</strong></td>
  3672. <td>&nbsp;%s</td>
  3673. </tr>
  3674. <tr height="20">
  3675. <td height="20"><strong>%s</strong></td>
  3676. <td>&nbsp;%s</td>
  3677. </tr>
  3678. <tr height="20">
  3679. <td height="20"><strong>%s</strong></td>
  3680. <td>&nbsp;%s</td>
  3681. </tr>
  3682. <tr height="20">
  3683. <td height="20"><strong>%s</strong></td>
  3684. <td>&nbsp;%s</td>
  3685. </tr>
  3686. <tr height="20">
  3687. <td height="20"><strong>%s</strong></td>
  3688. <td>&nbsp;%s</td>
  3689. </tr>
  3690. <tr height="20">
  3691. <td height="20"><strong%s</strong></td>
  3692. <td>&nbsp;%s</td>
  3693. </tr>
  3694. <tr height="20">
  3695. <td height="20"><strong>%s</strong></td>
  3696. <td>&nbsp;%s</td>
  3697. </tr>
  3698. <tr height="20">
  3699. <td height="20"><strong>%s</strong></td>
  3700. <td>&nbsp;%s</td>
  3701. </tr>
  3702. <tr height="20">
  3703. <td height="20">&nbsp;</td>
  3704. <td>&nbsp;</td>
  3705. </tr>
  3706. <tr height="20">
  3707. <td height="20"><strong>%s</strong></td>
  3708. <td>&nbsp;%s</td>
  3709. </tr>
  3710. <tr height="20">
  3711. <td height="20">&nbsp;</td>
  3712. <td>&nbsp;</td>
  3713. </tr>
  3714. <tr height="20">
  3715. <td height="20"><strong>%s</strong></td>
  3716. <td>&nbsp;%s</td>
  3717. </tr>
  3718. </tr>
  3719. <tr height="20">
  3720. <td height="20"><strong>%s</strong></td>
  3721. <td>&nbsp;%s</td>
  3722. </tr>
  3723. <tr height="20">
  3724. <td height="20">&nbsp;</td>
  3725. <td>&nbsp;</td>
  3726. </tr>
  3727. <tr height="20">
  3728. <td height="20"><strong>%s</strong></td>
  3729. <td>&nbsp;%s</td>
  3730. </tr>
  3731. <tr height="20">
  3732. <td height="20"><strong>%s</strong></td>
  3733. <td>&nbsp;%s</td>
  3734. </tr>
  3735. <tr height="20">
  3736. <td height="20"><strong>%s</strong></td>
  3737. <td>&nbsp;%s</td>
  3738. </tr>
  3739. <tr height="20">
  3740. <td height="20"><strong>%s</strong></td>
  3741. <td>&nbsp;%s</td>
  3742. </tr>
  3743. <tr height="20">
  3744. <td height="20"><strong>%s</strong></td>
  3745. <td>&nbsp;%s</td>
  3746. </tr>
  3747. <tr height="20">
  3748. <td height="20"><strong>'%s'</strong></td>
  3749. <td>&nbsp;%s</td>
  3750. </tr>
  3751. <tr height="20">
  3752. <td height="20"><strong>%s</strong></td>
  3753. <td>&nbsp;%s</td>
  3754. </tr>
  3755. <tr height="20">
  3756. <td height="20"><strong>%s</strong></td>
  3757. <td>&nbsp;%s</td>
  3758. </tr>
  3759. </tbody>
  3760. </table>
  3761. ''' %
  3762. (
  3763. _("General Shortcut list"),
  3764. _('F3'), _("SHOW SHORTCUT LIST"),
  3765. _('1'), _("Switch to Project Tab"),
  3766. _('2'), _("Switch to Selected Tab"),
  3767. _('3'), _("Switch to Tool Tab"),
  3768. _('B'), _("New Gerber"),
  3769. _('E'), _("Edit Object (if selected)"),
  3770. _('G'), _("Grid On/Off"),
  3771. _('J'), _("Jump to Coordinates"),
  3772. _('L'), _("New Excellon"),
  3773. _('M'), _("Move Obj"),
  3774. _('N'), _("New Geometry"),
  3775. _('O'), _("Set Origin"),
  3776. _('Q'), _("Change Units"),
  3777. _('P'), _("Open Properties Tool"),
  3778. _('R'), _("Rotate by 90 degree CW"),
  3779. _('S'), _("Shell Toggle"),
  3780. _('T'), _("Add a Tool (when in Geometry Selected Tab or in Tools NCC or Tools Paint)"),
  3781. _('V'), _("Zoom Fit"),
  3782. _('X'), _("Flip on X_axis"),
  3783. _('Y'), _("Flip on Y_axis"),
  3784. _('-'), _("Zoom Out"),
  3785. _('='), _("Zoom In"),
  3786. # CTRL section
  3787. _('Ctrl+A'), _("Select All"),
  3788. _('Ctrl+C'), _("Copy Obj"),
  3789. _('Ctrl+D'), _("Open Tools Database"),
  3790. _('Ctrl+E'), _("Open Excellon File"),
  3791. _('Ctrl+G'), _("Open Gerber File"),
  3792. _('Ctrl+M'), _("Distance Tool"),
  3793. _('Ctrl+N'), _("New Project"),
  3794. _('Ctrl+O'), _("Open Project"),
  3795. _('Ctrl+P'), _("Print (PDF)"),
  3796. _('Ctrl+Q'), _("PDF Import Tool"),
  3797. _('Ctrl+S'), _("Save Project"),
  3798. _('Ctrl+F10'), _("Toggle Plot Area"),
  3799. # SHIFT section
  3800. _('Shift+A'), _("Toggle the axis"),
  3801. _('Shift+C'), _("Copy Obj_Name"),
  3802. _('Shift+E'), _("Toggle Code Editor"),
  3803. _('Shift+G'), _("Toggle Grid Lines"),
  3804. _('Shift+H'), _("Toggle HUD"),
  3805. _('Shift+J'), _("Locate in Object"),
  3806. _('Shift+M'), _("Distance Minimum Tool"),
  3807. _('Shift+P'), _("Open Preferences Window"),
  3808. _('Shift+R'), _("Rotate by 90 degree CCW"),
  3809. _('Shift+S'), _("Run a Script"),
  3810. _('Shift+W'), _("Toggle the workspace"),
  3811. _('Shift+X'), _("Skew on X axis"),
  3812. _('Shift+Y'), _("Skew on Y axis"),
  3813. # ALT section
  3814. _('Alt+A'), _("Align Objects Tool"),
  3815. _('Alt+C'),_("Calculators Tool"),
  3816. _('Alt+D'),_("2-Sided PCB Tool"),
  3817. _('Alt+E'),_("Extract Drills Tool"),
  3818. _('Alt+F'),_("Fiducials Tool"),
  3819. _('Alt+G'),_("Invert Gerber Tool"),
  3820. _('Alt+H'),_("Punch Gerber Tool"),
  3821. _('Alt+I'),_("Isolation Tool"),
  3822. _('Alt+J'),_("Copper Thieving Tool"),
  3823. _('Alt+K'),_("Solder Paste Dispensing Tool"),
  3824. _('Alt+L'),_("Film PCB Tool"),
  3825. _('Alt+M'),_("Corner Markers Tool"),
  3826. _('Alt+N'),_("Non-Copper Clearing Tool"),
  3827. _('Alt+O'),_("Optimal Tool"),
  3828. _('Alt+P'),_("Paint Area Tool"),
  3829. _('Alt+Q'),_("QRCode Tool"),
  3830. _('Alt+R'),_("Rules Check Tool"),
  3831. _('Alt+S'),_("View File Source"),
  3832. _('Alt+T'),_("Transformations Tool"),
  3833. _('Alt+W'),_("Subtract Tool"),
  3834. _('Alt+X'),_("Cutout PCB Tool"),
  3835. _('Alt+Z'),_("Panelize PCB"),
  3836. _('Alt+1'),_("Enable all"),
  3837. _('Alt+2'),_("Disable all"),
  3838. _('Alt+3'),_("Enable Non-selected Objects"),
  3839. _('Alt+4'),_("Disable Non-selected Objects"),
  3840. _('Alt+F10'),_("Toggle Full Screen"),
  3841. # CTRL + ALT section
  3842. _('Ctrl+Alt+X'), _("Abort current task (gracefully)"),
  3843. # CTRL + SHIFT section
  3844. _('Ctrl+Shift+S'), _("Save Project As"),
  3845. _('Ctrl+Shift+V'), _("Paste Special. "
  3846. "Will convert a Windows path style to the one required in Tcl Shell"),
  3847. # F keys section
  3848. _('F1'), _("Open Online Manual"),
  3849. _('F4'), _("Open Online Tutorials"),
  3850. _('F5'), _("Refresh Plots"),
  3851. _('Del'), _("Delete Object"),
  3852. _('Del'), _("Alternate: Delete Tool"),
  3853. _('`'), _("(left to Key_1)Toggle Notebook Area (Left Side)"),
  3854. _('SPACE'), _("En(Dis)able Obj Plot"),
  3855. _('ESC'), _("Deselects all objects")
  3856. )
  3857. )
  3858. self.sh_app = QtWidgets.QTextEdit()
  3859. self.sh_app.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  3860. self.sh_app.setText(self.app_sh_msg)
  3861. self.sh_app.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  3862. self.sh_hlay.addWidget(self.sh_app)
  3863. editor_title = """
  3864. <b>%s</b><br>
  3865. <br>
  3866. """ % _("Editor Shortcut list")
  3867. # GEOMETRY EDITOR SHORTCUT LIST
  3868. geo_sh_messages = """
  3869. <strong><span style="color:#0000ff">%s</span></strong><br>
  3870. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  3871. <tbody>
  3872. <tr height="20">
  3873. <td height="20" width="89"><strong>%s</strong></td>
  3874. <td width="194">&nbsp;%s</td>
  3875. </tr>
  3876. <tr height="20">
  3877. <td height="20"><strong>%s</strong></td>
  3878. <td>&nbsp;%s</td>
  3879. </tr>
  3880. <tr height="20">
  3881. <td height="20"><strong>%s</strong></td>
  3882. <td>&nbsp;%s</td>
  3883. </tr>
  3884. <tr height="20">
  3885. <td height="20"><strong>%s</strong></td>
  3886. <td>&nbsp;%s</td>
  3887. </tr>
  3888. <tr height="20">
  3889. <td height="20"><strong>%s</strong></td>
  3890. <td>&nbsp;%s</td>
  3891. </tr>
  3892. <tr height="20">
  3893. <td height="20"><strong>%s</strong></td>
  3894. <td>&nbsp;%s</td>
  3895. </tr>
  3896. <tr height="20">
  3897. <td height="20"><strong>%s</strong></td>
  3898. <td>&nbsp;%s</td>
  3899. </tr>
  3900. <tr height="20">
  3901. <td height="20"><strong>%s</strong></td>
  3902. <td>&nbsp;%s</td>
  3903. </tr>
  3904. <tr height="20">
  3905. <td height="20"><strong>%s</strong></td>
  3906. <td>&nbsp;%s</td>
  3907. </tr>
  3908. <tr height="20">
  3909. <td height="20"><strong>%s</strong></td>
  3910. <td>&nbsp;%s</td>
  3911. </tr>
  3912. <tr height="20">
  3913. <td height="20"><strong>%s</strong></td>
  3914. <td>&nbsp;%s</td>
  3915. </tr>
  3916. <tr height="20">
  3917. <td height="20"><strong>%s</strong></td>
  3918. <td>&nbsp;%s</td>
  3919. </tr>
  3920. <tr height="20">
  3921. <td height="20"><strong>%s</strong></td>
  3922. <td>&nbsp;%s</td>
  3923. </tr>
  3924. <tr height="20">
  3925. <td height="20"><strong>%s</strong></td>
  3926. <td>&nbsp;%s</td>
  3927. </tr>
  3928. <tr height="20">
  3929. <td height="20"><strong>%s</strong></td>
  3930. <td>&nbsp;%s</td>
  3931. </tr>
  3932. <tr height="20">
  3933. <td height="20"><strong>%s</strong></td>
  3934. <td>&nbsp;%s</td>
  3935. </tr>
  3936. <tr height="20">
  3937. <td height="20"><strong>%s</strong></td>
  3938. <td>&nbsp;%s</td>
  3939. </tr>
  3940. <tr height="20">
  3941. <td height="20"><strong>%s</strong></td>
  3942. <td>&nbsp;%s</td>
  3943. </tr>
  3944. <tr height="20">
  3945. <td height="20"><strong>%s</strong></td>
  3946. <td>&nbsp;%s</td>
  3947. </tr>
  3948. <tr height="20">
  3949. <td height="20">&nbsp;</td>
  3950. <td>&nbsp;</td>
  3951. </tr>
  3952. <tr height="20">
  3953. <td height="20"><strong>%s</strong></td>
  3954. <td>&nbsp;%s</td>
  3955. </tr>
  3956. <tr height="20">
  3957. <td height="20"><strong>%s</strong></td>
  3958. <td>&nbsp;%s</td>
  3959. </tr>
  3960. <tr height="20">
  3961. <td height="20"><strong>%s</strong></td>
  3962. <td>&nbsp;%s</td>
  3963. </tr>
  3964. <tr height="20">
  3965. <td height="20">&nbsp;</td>
  3966. <td>&nbsp;</td>
  3967. </tr>
  3968. <tr height="20">
  3969. <td height="20"><strong>%s</strong></td>
  3970. <td>&nbsp;%s</td>
  3971. </tr>
  3972. <tr height="20">
  3973. <td height="20"><strong>%s</strong></td>
  3974. <td>&nbsp;%s</td>
  3975. </tr>
  3976. <tr height="20">
  3977. <td height="20"><strong>%s</strong></td>
  3978. <td>&nbsp;%s</td>
  3979. </tr>
  3980. <tr height="20">
  3981. <td height="20">&nbsp;</td>
  3982. <td>&nbsp;</td>
  3983. </tr>
  3984. <tr height="20">
  3985. <td height="20"><strong>%s</strong></td>
  3986. <td>&nbsp;%s</td>
  3987. </tr>
  3988. <tr height="20">
  3989. <td height="20"><strong>%s</strong></td>
  3990. <td>&nbsp;%s</td>
  3991. </tr>
  3992. <tr height="20">
  3993. <td height="20"><strong>%s</strong></td>
  3994. <td>&nbsp;%s</td>
  3995. </tr>
  3996. <tr height="20">
  3997. <td height="20">&nbsp;</td>
  3998. <td>&nbsp;</td>
  3999. </tr>
  4000. <tr height="20">
  4001. <td height="20"><strong>%s</strong></td>
  4002. <td>&nbsp;%s</td>
  4003. </tr>
  4004. <tr height="20">
  4005. <td height="20"><strong>%s</strong></td>
  4006. <td>&nbsp;%s</td>
  4007. </tr>
  4008. <tr height="20">
  4009. <td height="20"><strong>%s</strong></td>
  4010. <td>&nbsp;%s</td>
  4011. </tr>
  4012. <tr height="20">
  4013. <td height="20"><strong>%s</strong></td>
  4014. <td>&nbsp;%s</td>
  4015. </tr>
  4016. </tbody>
  4017. </table>
  4018. <br>
  4019. """ % (
  4020. _("GEOMETRY EDITOR"),
  4021. _('A'), _("Draw an Arc"),
  4022. _('B'), _("Buffer Tool"),
  4023. _('C'), _("Copy Geo Item"),
  4024. _('D'), _("Within Add Arc will toogle the ARC direction: CW or CCW"),
  4025. _('E'), _("Polygon Intersection Tool"),
  4026. _('I'), _("Geo Paint Tool"),
  4027. _('J'), _("Jump to Location (x, y)"),
  4028. _('K'), _("Toggle Corner Snap"),
  4029. _('M'), _("Move Geo Item"),
  4030. _('M'), _("Within Add Arc will cycle through the ARC modes"),
  4031. _('N'), _("Draw a Polygon"),
  4032. _('O'), _("Draw a Circle"),
  4033. _('P'), _("Draw a Path"),
  4034. _('R'), _("Draw Rectangle"),
  4035. _('S'), _("Polygon Subtraction Tool"),
  4036. _('T'), _("Add Text Tool"),
  4037. _('U'), _("Polygon Union Tool"),
  4038. _('X'), _("Flip shape on X axis"),
  4039. _('Y'), _("Flip shape on Y axis"),
  4040. _('Shift+M'), _("Distance Minimum Tool"),
  4041. _('Shift+X'), _("Skew shape on X axis"),
  4042. _('Shift+Y'), _("Skew shape on Y axis"),
  4043. _('Alt+R'), _("Editor Transformation Tool"),
  4044. _('Alt+X'), _("Offset shape on X axis"),
  4045. _('Alt+Y'), _("Offset shape on Y axis"),
  4046. _('Ctrl+M'), _("Distance Tool"),
  4047. _('Ctrl+S'), _("Save Object and Exit Editor"),
  4048. _('Ctrl+X'), _("Polygon Cut Tool"),
  4049. _('Space'), _("Rotate Geometry"),
  4050. _('ENTER'), _("Finish drawing for certain tools"),
  4051. _('ESC'), _("Abort and return to Select"),
  4052. _('Del'), _("Delete Shape")
  4053. )
  4054. # EXCELLON EDITOR SHORTCUT LIST
  4055. exc_sh_messages = """
  4056. <br>
  4057. <strong><span style="color:#ff0000">%s</span></strong><br>
  4058. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  4059. <tbody>
  4060. <tr height="20">
  4061. <td height="20" width="89"><strong>%s</strong></td>
  4062. <td width="194">&nbsp;%s</td>
  4063. </tr>
  4064. <tr height="20">
  4065. <td height="20"><strong>%s</strong></td>
  4066. <td>&nbsp;%s</td>
  4067. </tr>
  4068. <tr height="20">
  4069. <td height="20"><strong>%s</strong></td>
  4070. <td>&nbsp;%s</td>
  4071. </tr>
  4072. <tr height="20">
  4073. <td height="20"><strong>%s</strong></td>
  4074. <td>&nbsp;%s</td>
  4075. </tr>
  4076. <tr height="20">
  4077. <td height="20"><strong>%s</strong></td>
  4078. <td>&nbsp;%s</td>
  4079. </tr>
  4080. <tr height="20">
  4081. <td height="20" width="89"><strong>%s</strong></td>
  4082. <td width="194">&nbsp;%s</td>
  4083. </tr>
  4084. <tr height="20">
  4085. <td height="20"><strong>%s</strong></td>
  4086. <td>&nbsp;%s</td>
  4087. </tr>
  4088. <tr height="20">
  4089. <td height="20"><strong>%s</strong></td>
  4090. <td>&nbsp;%s</td>
  4091. </tr>
  4092. <tr height="20">
  4093. <td height="20" width="89"><strong>%s</strong></td>
  4094. <td width="194">&nbsp;%s</td>
  4095. </tr>
  4096. <tr height="20">
  4097. <td height="20">&nbsp;</td>
  4098. <td>&nbsp;</td>
  4099. </tr>
  4100. <tr height="20">
  4101. <td height="20"><strong>%s</strong></td>
  4102. <td>&nbsp;%s</td>
  4103. </tr>
  4104. <tr height="20">
  4105. <td height="20">&nbsp;</td>
  4106. <td>&nbsp;</td>
  4107. </tr>
  4108. <tr height="20">
  4109. <td height="20"><strong>%s</strong></td>
  4110. <td>&nbsp;%s</td>
  4111. </tr>
  4112. <tr height="20">
  4113. <td height="20"><strong>%s</strong></td>
  4114. <td>&nbsp;%s</td>
  4115. </tr>
  4116. <tr height="20">
  4117. <td height="20">&nbsp;</td>
  4118. <td>&nbsp;</td>
  4119. </tr>
  4120. <tr height="20">
  4121. <td height="20"><strong>%s</strong></td>
  4122. <td>&nbsp;%s</td>
  4123. </tr>
  4124. <tr height="20">
  4125. <td height="20"><strong>%s</strong></td>
  4126. <td>&nbsp;%s</td>
  4127. </tr>
  4128. </tbody>
  4129. </table>
  4130. <br>
  4131. """ % (
  4132. _("EXCELLON EDITOR"),
  4133. _('A'), _("Add Drill Array"),
  4134. _('C'), _("Copy Drill(s)"),
  4135. _('D'), _("Add Drill"),
  4136. _('J'), _("Jump to Location (x, y)"),
  4137. _('M'), _("Move Drill(s)"),
  4138. _('Q'), _("Add Slot Array"),
  4139. _('R'), _("Resize Drill(s)"),
  4140. _('T'), _("Add a new Tool"),
  4141. _('W'), _("Add Slot"),
  4142. _('Shift+M'), _("Distance Minimum Tool"),
  4143. _('Del'), _("Delete Drill(s)"),
  4144. _('Del'), _("Alternate: Delete Tool(s)"),
  4145. _('Esc'), _("Abort and return to Select"),
  4146. _('Ctrl+S'), _("Save Object and Exit Editor")
  4147. )
  4148. # GERBER EDITOR SHORTCUT LIST
  4149. grb_sh_messages = """
  4150. <br>
  4151. <strong><span style="color:#00ff00">%s</span></strong><br>
  4152. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  4153. <tbody>
  4154. <tr height="20">
  4155. <td height="20" width="89"><strong>%s</strong></td>
  4156. <td width="194">&nbsp;%s</td>
  4157. </tr>
  4158. <tr height="20">
  4159. <td height="20"><strong>%s</strong></td>
  4160. <td>&nbsp;%s</td>
  4161. </tr>
  4162. <tr height="20">
  4163. <td height="20"><strong>%s</strong></td>
  4164. <td>&nbsp;%s</td>
  4165. </tr>
  4166. <tr height="20">
  4167. <td height="20"><strong>%s</strong></td>
  4168. <td>&nbsp;%s</td>
  4169. </tr>
  4170. <tr height="20">
  4171. <td height="20"><strong>%s</strong></td>
  4172. <td>&nbsp;%s</td>
  4173. </tr>
  4174. <tr height="20">
  4175. <td height="20"><strong>%s</strong></td>
  4176. <td>&nbsp;%s</td>
  4177. </tr>
  4178. <tr height="20">
  4179. <td height="20"><strong>%s</strong></td>
  4180. <td>&nbsp;%s</td>
  4181. </tr>
  4182. <tr height="20">
  4183. <td height="20"><strong>%s</strong></td>
  4184. <td>&nbsp;%s</td>
  4185. </tr>
  4186. <tr height="20">
  4187. <td height="20"><strong>%s</strong></td>
  4188. <td>&nbsp;%s</td>
  4189. </tr>
  4190. <tr height="20">
  4191. <td height="20"><strong>%s</strong></td>
  4192. <td>&nbsp;%s</td>
  4193. </tr>
  4194. <tr height="20">
  4195. <td height="20"><strong>%s</strong></td>
  4196. <td>&nbsp;%s</td>
  4197. </tr>
  4198. <tr height="20">
  4199. <td height="20"><strong>%s</strong></td>
  4200. <td>&nbsp;%s</td>
  4201. </tr>
  4202. <tr height="20">
  4203. <td height="20"><strong>%s</strong></td>
  4204. <td>&nbsp;%s</td>
  4205. </tr>
  4206. <tr height="20">
  4207. <td height="20">&nbsp;</td>
  4208. <td>&nbsp;</td>
  4209. </tr>
  4210. <tr height="20">
  4211. <td height="20"><strong>%s</strong></td>
  4212. <td>&nbsp;%s</td>
  4213. </tr>
  4214. <tr height="20">
  4215. <td height="20"><strong>%s</strong></td>
  4216. <td>&nbsp;%s</td>
  4217. </tr>
  4218. <tr height="20">
  4219. <td height="20"><strong>%s</strong></td>
  4220. <td>&nbsp;%s</td>
  4221. </tr>
  4222. <tr height="20">
  4223. <td height="20">&nbsp;</td>
  4224. <td>&nbsp;</td>
  4225. </tr>
  4226. <tr height="20">
  4227. <td height="20"><strong>%s</strong></td>
  4228. <td>&nbsp;%s</td>
  4229. </tr>
  4230. <tr height="20">
  4231. <td height="20">&nbsp;</td>
  4232. <td>&nbsp;</td>
  4233. </tr>
  4234. <tr height="20">
  4235. <td height="20"><strong>%s</strong></td>
  4236. <td>&nbsp;%s</td>
  4237. </tr>
  4238. <tr height="20">
  4239. <td height="20"><strong>%s</strong></td>
  4240. <td>&nbsp;%s</td>
  4241. </tr>
  4242. <tr height="20">
  4243. <td height="20">&nbsp;</td>
  4244. <td>&nbsp;</td>
  4245. </tr>
  4246. <tr height="20">
  4247. <td height="20"><strong>%s</strong></td>
  4248. <td>&nbsp;%s</td>
  4249. </tr>
  4250. <tr height="20">
  4251. <td height="20"><strong>%s</strong></td>
  4252. <td>&nbsp;%s</td>
  4253. </tr>
  4254. <tr height="20">
  4255. <td height="20"><strong>%s</strong></td>
  4256. <td>&nbsp;%s</td>
  4257. </tr>
  4258. </tbody>
  4259. </table>
  4260. <br>
  4261. """ % (
  4262. _("GERBER EDITOR"),
  4263. _('A'), _("Add Pad Array"),
  4264. _('B'), _("Buffer"),
  4265. _('C'), _("Copy"),
  4266. _('D'), _("Add Disc"),
  4267. _('E'), _("Add SemiDisc"),
  4268. _('J'), _("Jump to Location (x, y)"),
  4269. _('M'), _("Move"),
  4270. _('N'), _("Add Region"),
  4271. _('P'), _("Add Pad"),
  4272. _('R'), _("Within Track & Region Tools will cycle in REVERSE the bend modes"),
  4273. _('S'), _("Scale"),
  4274. _('T'), _("Add Track"),
  4275. _('T'), _("Within Track & Region Tools will cycle FORWARD the bend modes"),
  4276. _('Del'), _("Delete"),
  4277. _('Del'), _("Alternate: Delete Apertures"),
  4278. _('ESC'), _("Abort and return to Select"),
  4279. _('Shift+M'), _("Distance Minimum Tool"),
  4280. _('Ctrl+E'), _("Eraser Tool"),
  4281. _('Ctrl+S'), _("Save Object and Exit Editor"),
  4282. _('Alt+A'), _("Mark Area Tool"),
  4283. _('Alt+N'), _("Poligonize Tool"),
  4284. _('Alt+R'), _("Transformation Tool")
  4285. )
  4286. self.editor_sh_msg = editor_title + geo_sh_messages + grb_sh_messages + exc_sh_messages
  4287. self.sh_editor = QtWidgets.QTextEdit()
  4288. self.sh_editor.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  4289. self.sh_editor.setText(self.editor_sh_msg)
  4290. self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  4291. self.sh_hlay.addWidget(self.sh_editor)
  4292. # end of file