FlatCAMGUI.py 204 KB

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