FlatCAMGUI.py 203 KB

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