FlatCAMGUI.py 208 KB

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