FlatCAMGUI.py 199 KB

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