FlatCAMGUI.py 208 KB

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