FlatCAMGUI.py 205 KB

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