FlatCAMGUI.py 202 KB

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