MainGUI.py 222 KB

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