FlatCAMGUI.py 208 KB

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