MainGUI.py 208 KB

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