FlatCAMGUI.py 217 KB

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