MainGUI.py 211 KB

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