MainGUI.py 219 KB

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