MainGUI.py 213 KB

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