FlatCAMGUI.py 209 KB

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