FlatCAMGUI.py 207 KB

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