FlatCAMGUI.py 202 KB

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