MainGUI.py 214 KB

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