MainGUI.py 220 KB

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