MainGUI.py 220 KB

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