MainGUI.py 213 KB

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