FlatCAMGUI.py 198 KB

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