FlatCAMGUI.py 206 KB

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