MainGUI.py 209 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448
  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.hud_label = FCLabel("H")
  1288. self.hud_label.setToolTip(_("HUD (Heads up display)"))
  1289. self.hud_label.setMargin(2)
  1290. self.infobar.addWidget(self.hud_label)
  1291. self.wplace_label = FCLabel("A4")
  1292. self.wplace_label.setMargin(2)
  1293. self.infobar.addWidget(self.wplace_label)
  1294. self.units_label = QtWidgets.QLabel("[mm]")
  1295. self.units_label.setMargin(2)
  1296. self.infobar.addWidget(self.units_label)
  1297. # disabled
  1298. # self.progress_bar = QtWidgets.QProgressBar()
  1299. # self.progress_bar.setMinimum(0)
  1300. # self.progress_bar.setMaximum(100)
  1301. # infobar.addWidget(self.progress_bar)
  1302. # ########################################################################
  1303. # ########################## SET GUI Elements # ##########################
  1304. # ########################################################################
  1305. self.app_icon = QtGui.QIcon()
  1306. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon16.png', QtCore.QSize(16, 16))
  1307. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon24.png', QtCore.QSize(24, 24))
  1308. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon32.png', QtCore.QSize(32, 32))
  1309. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon48.png', QtCore.QSize(48, 48))
  1310. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon128.png', QtCore.QSize(128, 128))
  1311. self.app_icon.addFile(self.app.resource_location + '/flatcam_icon256.png', QtCore.QSize(256, 256))
  1312. self.setWindowIcon(self.app_icon)
  1313. self.setGeometry(100, 100, 1024, 650)
  1314. self.setWindowTitle('FlatCAM %s %s - %s' %
  1315. (self.app.version,
  1316. ('BETA' if self.app.beta else ''),
  1317. platform.architecture()[0])
  1318. )
  1319. self.filename = ""
  1320. self.units = ""
  1321. self.setAcceptDrops(True)
  1322. # ########################################################################
  1323. # ########################## Build GUI # #################################
  1324. # ########################################################################
  1325. self.grid_snap_btn.setCheckable(True)
  1326. self.corner_snap_btn.setCheckable(True)
  1327. self.update_obj_btn.setEnabled(False)
  1328. # start with GRID activated
  1329. self.grid_snap_btn.trigger()
  1330. self.g_editor_cmenu.menuAction().setVisible(False)
  1331. self.grb_editor_cmenu.menuAction().setVisible(False)
  1332. self.e_editor_cmenu.menuAction().setVisible(False)
  1333. # ########################################################################
  1334. # ######################## BUILD PREFERENCES #############################
  1335. # ########################################################################
  1336. self.general_defaults_form = GeneralPreferencesUI(decimals=self.decimals)
  1337. self.gerber_defaults_form = GerberPreferencesUI(decimals=self.decimals)
  1338. self.excellon_defaults_form = ExcellonPreferencesUI(decimals=self.decimals)
  1339. self.geometry_defaults_form = GeometryPreferencesUI(decimals=self.decimals)
  1340. self.cncjob_defaults_form = CNCJobPreferencesUI(decimals=self.decimals)
  1341. self.tools_defaults_form = ToolsPreferencesUI(decimals=self.decimals)
  1342. self.tools2_defaults_form = Tools2PreferencesUI(decimals=self.decimals)
  1343. self.util_defaults_form = UtilPreferencesUI(decimals=self.decimals)
  1344. QtWidgets.qApp.installEventFilter(self)
  1345. # ########################################################################
  1346. # ################## RESTORE THE TOOLBAR STATE from file #################
  1347. # ########################################################################
  1348. flat_settings = QSettings("Open Source", "FlatCAM")
  1349. if flat_settings.contains("saved_gui_state"):
  1350. saved_gui_state = flat_settings.value('saved_gui_state')
  1351. self.restoreState(saved_gui_state)
  1352. log.debug("MainGUI.__init__() --> UI state restored from QSettings.")
  1353. self.corner_snap_btn.setVisible(False)
  1354. self.snap_magnet.setVisible(False)
  1355. if flat_settings.contains("layout"):
  1356. layout = flat_settings.value('layout', type=str)
  1357. self.exc_edit_toolbar.setDisabled(True)
  1358. self.geo_edit_toolbar.setDisabled(True)
  1359. self.grb_edit_toolbar.setDisabled(True)
  1360. log.debug("MainGUI.__init__() --> UI layout restored from QSettings. Layout = %s" % str(layout))
  1361. else:
  1362. self.exc_edit_toolbar.setDisabled(True)
  1363. self.geo_edit_toolbar.setDisabled(True)
  1364. self.grb_edit_toolbar.setDisabled(True)
  1365. flat_settings.setValue('layout', "standard")
  1366. # This will write the setting to the platform specific storage.
  1367. del flat_settings
  1368. log.debug("MainGUI.__init__() --> UI layout restored from defaults. QSettings set to 'standard'")
  1369. # construct the Toolbar Lock menu entry to the context menu of the QMainWindow
  1370. self.lock_action = QtWidgets.QAction()
  1371. self.lock_action.setText(_("Lock Toolbars"))
  1372. self.lock_action.setCheckable(True)
  1373. qsettings = QSettings("Open Source", "FlatCAM")
  1374. if qsettings.contains("toolbar_lock"):
  1375. lock_val = settings.value('toolbar_lock')
  1376. if lock_val == 'true':
  1377. lock_state = True
  1378. self.lock_action.setChecked(True)
  1379. else:
  1380. lock_state = False
  1381. self.lock_action.setChecked(False)
  1382. else:
  1383. lock_state = False
  1384. qsettings.setValue('toolbar_lock', lock_state)
  1385. # This will write the setting to the platform specific storage.
  1386. del qsettings
  1387. self.lock_toolbar(lock=lock_state)
  1388. self.lock_action.triggered[bool].connect(self.lock_toolbar)
  1389. self.pref_open_button.clicked.connect(self.on_preferences_open_folder)
  1390. self.clear_btn.clicked.connect(self.on_gui_clear)
  1391. self.wplace_label.clicked.connect(self.app.on_workspace_toggle)
  1392. self.hud_label.clicked.connect(self.app.on_toggle_hud)
  1393. # to be used in the future
  1394. # self.plot_tab_area.tab_attached.connect(lambda x: print(x))
  1395. # self.plot_tab_area.tab_detached.connect(lambda x: print(x))
  1396. # restore the toolbar view
  1397. self.restore_toolbar_view()
  1398. # restore the GUI geometry
  1399. self.restore_main_win_geom()
  1400. # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1401. # %%%%%%%%%%%%%%%%% GUI Building FINISHED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1402. # %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  1403. # Variable to store the status of the fullscreen event
  1404. self.toggle_fscreen = False
  1405. self.x_pos = None
  1406. self.y_pos = None
  1407. self.width = None
  1408. self.height = None
  1409. self.geom_update[int, int, int, int, int].connect(self.save_geometry)
  1410. self.final_save.connect(self.app.final_save)
  1411. def save_geometry(self, x, y, width, height, notebook_width):
  1412. """
  1413. Will save the application geometry and positions in the defaults dicitionary to be restored at the next
  1414. launch of the application.
  1415. :param x: X position of the main window
  1416. :param y: Y position of the main window
  1417. :param width: width of the main window
  1418. :param height: height of the main window
  1419. :param notebook_width: the notebook width is adjustable so it get saved here, too.
  1420. :return: None
  1421. """
  1422. self.app.defaults["global_def_win_x"] = x
  1423. self.app.defaults["global_def_win_y"] = y
  1424. self.app.defaults["global_def_win_w"] = width
  1425. self.app.defaults["global_def_win_h"] = height
  1426. self.app.defaults["global_def_notebook_width"] = notebook_width
  1427. self.app.preferencesUiManager.save_defaults()
  1428. def restore_main_win_geom(self):
  1429. try:
  1430. self.setGeometry(self.app.defaults["global_def_win_x"],
  1431. self.app.defaults["global_def_win_y"],
  1432. self.app.defaults["global_def_win_w"],
  1433. self.app.defaults["global_def_win_h"])
  1434. self.splitter.setSizes([self.app.defaults["global_def_notebook_width"], 0])
  1435. except KeyError as e:
  1436. log.debug("AppGUI.MainGUI.restore_main_win_geom() --> %s" % str(e))
  1437. def restore_toolbar_view(self):
  1438. """
  1439. Some toolbars may be hidden by user and here we restore the state of the toolbars visibility that
  1440. was saved in the defaults dictionary.
  1441. :return: None
  1442. """
  1443. tb = self.app.defaults["global_toolbar_view"]
  1444. if tb & 1:
  1445. self.toolbarfile.setVisible(True)
  1446. else:
  1447. self.toolbarfile.setVisible(False)
  1448. if tb & 2:
  1449. self.toolbaredit.setVisible(True)
  1450. else:
  1451. self.toolbaredit.setVisible(False)
  1452. if tb & 4:
  1453. self.toolbarview.setVisible(True)
  1454. else:
  1455. self.toolbarview.setVisible(False)
  1456. if tb & 8:
  1457. self.toolbartools.setVisible(True)
  1458. else:
  1459. self.toolbartools.setVisible(False)
  1460. if tb & 16:
  1461. self.exc_edit_toolbar.setVisible(True)
  1462. else:
  1463. self.exc_edit_toolbar.setVisible(False)
  1464. if tb & 32:
  1465. self.geo_edit_toolbar.setVisible(True)
  1466. else:
  1467. self.geo_edit_toolbar.setVisible(False)
  1468. if tb & 64:
  1469. self.grb_edit_toolbar.setVisible(True)
  1470. else:
  1471. self.grb_edit_toolbar.setVisible(False)
  1472. # if tb & 128:
  1473. # self.ui.snap_toolbar.setVisible(True)
  1474. # else:
  1475. # self.ui.snap_toolbar.setVisible(False)
  1476. # Grid Toolbar is always active now
  1477. self.snap_toolbar.setVisible(True)
  1478. if tb & 256:
  1479. self.toolbarshell.setVisible(True)
  1480. else:
  1481. self.toolbarshell.setVisible(False)
  1482. def eventFilter(self, obj, event):
  1483. """
  1484. Filter the ToolTips display based on a Preferences setting
  1485. :param obj:
  1486. :param event: QT event to filter
  1487. :return:
  1488. """
  1489. if self.app.defaults["global_toggle_tooltips"] is False:
  1490. if event.type() == QtCore.QEvent.ToolTip:
  1491. return True
  1492. else:
  1493. return False
  1494. return False
  1495. def on_preferences_open_folder(self):
  1496. """
  1497. Will open an Explorer window set to the folder path where the FlatCAM preferences files are usually saved.
  1498. :return: None
  1499. """
  1500. if sys.platform == 'win32':
  1501. subprocess.Popen('explorer %s' % self.app.data_path)
  1502. elif sys.platform == 'darwin':
  1503. os.system('open "%s"' % self.app.data_path)
  1504. else:
  1505. subprocess.Popen(['xdg-open', self.app.data_path])
  1506. self.app.inform.emit('[success] %s' % _("FlatCAM Preferences Folder opened."))
  1507. def on_gui_clear(self):
  1508. theme_settings = QtCore.QSettings("Open Source", "FlatCAM")
  1509. theme_settings.setValue('theme', 'white')
  1510. del theme_settings
  1511. resource_loc = self.app.resource_location
  1512. msgbox = QtWidgets.QMessageBox()
  1513. msgbox.setText(_("Are you sure you want to delete the GUI Settings? \n"))
  1514. msgbox.setWindowTitle(_("Clear GUI Settings"))
  1515. msgbox.setWindowIcon(QtGui.QIcon(resource_loc + '/trash32.png'))
  1516. bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
  1517. bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
  1518. msgbox.setDefaultButton(bt_no)
  1519. msgbox.exec_()
  1520. response = msgbox.clickedButton()
  1521. if response == bt_yes:
  1522. qsettings = QSettings("Open Source", "FlatCAM")
  1523. for key in qsettings.allKeys():
  1524. qsettings.remove(key)
  1525. # This will write the setting to the platform specific storage.
  1526. del qsettings
  1527. def populate_toolbars(self):
  1528. """
  1529. Will populate the App Toolbars with their actions
  1530. :return: None
  1531. """
  1532. # ########################################################################
  1533. # ## File Toolbar # ##
  1534. # ########################################################################
  1535. self.file_open_gerber_btn = self.toolbarfile.addAction(
  1536. QtGui.QIcon(self.app.resource_location + '/flatcam_icon32.png'), _("Open Gerber"))
  1537. self.file_open_excellon_btn = self.toolbarfile.addAction(
  1538. QtGui.QIcon(self.app.resource_location + '/drill32.png'), _("Open Excellon"))
  1539. self.toolbarfile.addSeparator()
  1540. self.file_open_btn = self.toolbarfile.addAction(
  1541. QtGui.QIcon(self.app.resource_location + '/folder32.png'), _("Open project"))
  1542. self.file_save_btn = self.toolbarfile.addAction(
  1543. QtGui.QIcon(self.app.resource_location + '/project_save32.png'), _("Save project"))
  1544. # ########################################################################
  1545. # ## Edit Toolbar # ##
  1546. # ########################################################################
  1547. self.editgeo_btn = self.toolbaredit.addAction(
  1548. QtGui.QIcon(self.app.resource_location + '/edit32.png'), _("Editor"))
  1549. self.update_obj_btn = self.toolbaredit.addAction(
  1550. QtGui.QIcon(self.app.resource_location + '/close_edit_file32.png'),
  1551. _("Save Object and close the Editor")
  1552. )
  1553. self.toolbaredit.addSeparator()
  1554. self.copy_btn = self.toolbaredit.addAction(
  1555. QtGui.QIcon(self.app.resource_location + '/copy_file32.png'), _("Copy"))
  1556. self.delete_btn = self.toolbaredit.addAction(
  1557. QtGui.QIcon(self.app.resource_location + '/delete_file32.png'), _("&Delete"))
  1558. self.toolbaredit.addSeparator()
  1559. self.distance_btn = self.toolbaredit.addAction(
  1560. QtGui.QIcon(self.app.resource_location + '/distance32.png'), _("Distance Tool"))
  1561. self.distance_min_btn = self.toolbaredit.addAction(
  1562. QtGui.QIcon(self.app.resource_location + '/distance_min32.png'), _("Distance Min Tool"))
  1563. self.origin_btn = self.toolbaredit.addAction(
  1564. QtGui.QIcon(self.app.resource_location + '/origin32.png'), _('Set Origin'))
  1565. self.move2origin_btn = self.toolbaredit.addAction(
  1566. QtGui.QIcon(self.app.resource_location + '/origin2_32.png'), _('Move to Origin'))
  1567. self.jmp_btn = self.toolbaredit.addAction(
  1568. QtGui.QIcon(self.app.resource_location + '/jump_to16.png'), _('Jump to Location'))
  1569. self.locate_btn = self.toolbaredit.addAction(
  1570. QtGui.QIcon(self.app.resource_location + '/locate32.png'), _('Locate in Object'))
  1571. # ########################################################################
  1572. # ########################## View Toolbar# ###############################
  1573. # ########################################################################
  1574. self.replot_btn = self.toolbarview.addAction(
  1575. QtGui.QIcon(self.app.resource_location + '/replot32.png'), _("&Replot"))
  1576. self.clear_plot_btn = self.toolbarview.addAction(
  1577. QtGui.QIcon(self.app.resource_location + '/clear_plot32.png'), _("&Clear plot"))
  1578. self.zoom_in_btn = self.toolbarview.addAction(
  1579. QtGui.QIcon(self.app.resource_location + '/zoom_in32.png'), _("Zoom In"))
  1580. self.zoom_out_btn = self.toolbarview.addAction(
  1581. QtGui.QIcon(self.app.resource_location + '/zoom_out32.png'), _("Zoom Out"))
  1582. self.zoom_fit_btn = self.toolbarview.addAction(
  1583. QtGui.QIcon(self.app.resource_location + '/zoom_fit32.png'), _("Zoom Fit"))
  1584. # ########################################################################
  1585. # ########################## Shell Toolbar# ##############################
  1586. # ########################################################################
  1587. self.shell_btn = self.toolbarshell.addAction(
  1588. QtGui.QIcon(self.app.resource_location + '/shell32.png'), _("&Command Line"))
  1589. self.new_script_btn = self.toolbarshell.addAction(
  1590. QtGui.QIcon(self.app.resource_location + '/script_new24.png'), _('New Script ...'))
  1591. self.open_script_btn = self.toolbarshell.addAction(
  1592. QtGui.QIcon(self.app.resource_location + '/open_script32.png'), _('Open Script ...'))
  1593. self.run_script_btn = self.toolbarshell.addAction(
  1594. QtGui.QIcon(self.app.resource_location + '/script16.png'), _('Run Script ...'))
  1595. # #########################################################################
  1596. # ######################### Tools Toolbar #################################
  1597. # #########################################################################
  1598. self.dblsided_btn = self.toolbartools.addAction(
  1599. QtGui.QIcon(self.app.resource_location + '/doubleside32.png'), _("2Sided Tool"))
  1600. self.align_btn = self.toolbartools.addAction(
  1601. QtGui.QIcon(self.app.resource_location + '/align32.png'), _("Align Objects Tool"))
  1602. self.extract_btn = self.toolbartools.addAction(
  1603. QtGui.QIcon(self.app.resource_location + '/extract_drill32.png'), _("Extract Drills Tool"))
  1604. self.cutout_btn = self.toolbartools.addAction(
  1605. QtGui.QIcon(self.app.resource_location + '/cut16_bis.png'), _("&Cutout Tool"))
  1606. self.ncc_btn = self.toolbartools.addAction(
  1607. QtGui.QIcon(self.app.resource_location + '/ncc16.png'), _("NCC Tool"))
  1608. self.paint_btn = self.toolbartools.addAction(
  1609. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _("Paint Tool"))
  1610. self.toolbartools.addSeparator()
  1611. self.panelize_btn = self.toolbartools.addAction(
  1612. QtGui.QIcon(self.app.resource_location + '/panelize32.png'), _("Panel Tool"))
  1613. self.film_btn = self.toolbartools.addAction(
  1614. QtGui.QIcon(self.app.resource_location + '/film16.png'), _("Film Tool"))
  1615. self.solder_btn = self.toolbartools.addAction(
  1616. QtGui.QIcon(self.app.resource_location + '/solderpastebis32.png'), _("SolderPaste Tool"))
  1617. self.sub_btn = self.toolbartools.addAction(
  1618. QtGui.QIcon(self.app.resource_location + '/sub32.png'), _("Subtract Tool"))
  1619. self.rules_btn = self.toolbartools.addAction(
  1620. QtGui.QIcon(self.app.resource_location + '/rules32.png'), _("Rules Tool"))
  1621. self.optimal_btn = self.toolbartools.addAction(
  1622. QtGui.QIcon(self.app.resource_location + '/open_excellon32.png'), _("Optimal Tool"))
  1623. self.toolbartools.addSeparator()
  1624. self.calculators_btn = self.toolbartools.addAction(
  1625. QtGui.QIcon(self.app.resource_location + '/calculator24.png'), _("Calculators Tool"))
  1626. self.transform_btn = self.toolbartools.addAction(
  1627. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transform Tool"))
  1628. self.qrcode_btn = self.toolbartools.addAction(
  1629. QtGui.QIcon(self.app.resource_location + '/qrcode32.png'), _("QRCode Tool"))
  1630. self.copperfill_btn = self.toolbartools.addAction(
  1631. QtGui.QIcon(self.app.resource_location + '/copperfill32.png'), _("Copper Thieving Tool"))
  1632. self.fiducials_btn = self.toolbartools.addAction(
  1633. QtGui.QIcon(self.app.resource_location + '/fiducials_32.png'), _("Fiducials Tool"))
  1634. self.cal_btn = self.toolbartools.addAction(
  1635. QtGui.QIcon(self.app.resource_location + '/calibrate_32.png'), _("Calibration Tool"))
  1636. self.punch_btn = self.toolbartools.addAction(
  1637. QtGui.QIcon(self.app.resource_location + '/punch32.png'), _("Punch Gerber Tool"))
  1638. self.invert_btn = self.toolbartools.addAction(
  1639. QtGui.QIcon(self.app.resource_location + '/invert32.png'), _("Invert Gerber Tool"))
  1640. self.corners_tool_btn = self.toolbartools.addAction(
  1641. QtGui.QIcon(self.app.resource_location + '/corners_32.png'), _("Corner Markers Tool"))
  1642. self.etch_btn = self.toolbartools.addAction(
  1643. QtGui.QIcon(self.app.resource_location + '/etch_32.png'), _("Etch Compensation Tool"))
  1644. # ########################################################################
  1645. # ## Excellon Editor Toolbar # ##
  1646. # ########################################################################
  1647. self.select_drill_btn = self.exc_edit_toolbar.addAction(
  1648. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  1649. self.add_drill_btn = self.exc_edit_toolbar.addAction(
  1650. QtGui.QIcon(self.app.resource_location + '/plus16.png'), _('Add Drill Hole'))
  1651. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  1652. QtGui.QIcon(self.app.resource_location + '/addarray16.png'), _('Add Drill Hole Array'))
  1653. self.resize_drill_btn = self.exc_edit_toolbar.addAction(
  1654. QtGui.QIcon(self.app.resource_location + '/resize16.png'), _('Resize Drill'))
  1655. self.add_slot_btn = self.exc_edit_toolbar.addAction(
  1656. QtGui.QIcon(self.app.resource_location + '/slot26.png'), _('Add Slot'))
  1657. self.add_slot_array_btn = self.exc_edit_toolbar.addAction(
  1658. QtGui.QIcon(self.app.resource_location + '/slot_array26.png'), _('Add Slot Array'))
  1659. self.exc_edit_toolbar.addSeparator()
  1660. self.copy_drill_btn = self.exc_edit_toolbar.addAction(
  1661. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _('Copy Drill'))
  1662. self.delete_drill_btn = self.exc_edit_toolbar.addAction(
  1663. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Drill"))
  1664. self.exc_edit_toolbar.addSeparator()
  1665. self.move_drill_btn = self.exc_edit_toolbar.addAction(
  1666. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Drill"))
  1667. # ########################################################################
  1668. # ## Geometry Editor Toolbar # ##
  1669. # ########################################################################
  1670. self.geo_select_btn = self.geo_edit_toolbar.addAction(
  1671. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select 'Esc'"))
  1672. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(
  1673. QtGui.QIcon(self.app.resource_location + '/circle32.png'), _('Add Circle'))
  1674. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(
  1675. QtGui.QIcon(self.app.resource_location + '/arc32.png'), _('Add Arc'))
  1676. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(
  1677. QtGui.QIcon(self.app.resource_location + '/rectangle32.png'), _('Add Rectangle'))
  1678. self.geo_edit_toolbar.addSeparator()
  1679. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(
  1680. QtGui.QIcon(self.app.resource_location + '/path32.png'), _('Add Path'))
  1681. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(
  1682. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _('Add Polygon'))
  1683. self.geo_edit_toolbar.addSeparator()
  1684. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(
  1685. QtGui.QIcon(self.app.resource_location + '/text32.png'), _('Add Text'))
  1686. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(
  1687. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Add Buffer'))
  1688. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(
  1689. QtGui.QIcon(self.app.resource_location + '/paint20_1.png'), _('Paint Shape'))
  1690. self.geo_eraser_btn = self.geo_edit_toolbar.addAction(
  1691. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  1692. self.geo_edit_toolbar.addSeparator()
  1693. self.geo_union_btn = self.geo_edit_toolbar.addAction(
  1694. QtGui.QIcon(self.app.resource_location + '/union32.png'), _('Polygon Union'))
  1695. self.geo_explode_btn = self.geo_edit_toolbar.addAction(
  1696. QtGui.QIcon(self.app.resource_location + '/explode32.png'), _('Polygon Explode'))
  1697. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(
  1698. QtGui.QIcon(self.app.resource_location + '/intersection32.png'), _('Polygon Intersection'))
  1699. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(
  1700. QtGui.QIcon(self.app.resource_location + '/subtract32.png'), _('Polygon Subtraction'))
  1701. self.geo_edit_toolbar.addSeparator()
  1702. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(
  1703. QtGui.QIcon(self.app.resource_location + '/cutpath32.png'), _('Cut Path'))
  1704. self.geo_copy_btn = self.geo_edit_toolbar.addAction(
  1705. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy Objects"))
  1706. self.geo_delete_btn = self.geo_edit_toolbar.addAction(
  1707. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete Shape"))
  1708. self.geo_transform_btn = self.geo_edit_toolbar.addAction(
  1709. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  1710. self.geo_edit_toolbar.addSeparator()
  1711. self.geo_move_btn = self.geo_edit_toolbar.addAction(
  1712. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move Objects"))
  1713. # ########################################################################
  1714. # ## Gerber Editor Toolbar # ##
  1715. # ########################################################################
  1716. self.grb_select_btn = self.grb_edit_toolbar.addAction(
  1717. QtGui.QIcon(self.app.resource_location + '/pointer32.png'), _("Select"))
  1718. self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(
  1719. QtGui.QIcon(self.app.resource_location + '/aperture32.png'), _("Add Pad"))
  1720. self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(
  1721. QtGui.QIcon(self.app.resource_location + '/padarray32.png'), _('Add Pad Array'))
  1722. self.grb_add_track_btn = self.grb_edit_toolbar.addAction(
  1723. QtGui.QIcon(self.app.resource_location + '/track32.png'), _("Add Track"))
  1724. self.grb_add_region_btn = self.grb_edit_toolbar.addAction(
  1725. QtGui.QIcon(self.app.resource_location + '/polygon32.png'), _("Add Region"))
  1726. self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(
  1727. QtGui.QIcon(self.app.resource_location + '/poligonize32.png'), _("Poligonize"))
  1728. self.grb_add_semidisc_btn = self.grb_edit_toolbar.addAction(
  1729. QtGui.QIcon(self.app.resource_location + '/semidisc32.png'), _("SemiDisc"))
  1730. self.grb_add_disc_btn = self.grb_edit_toolbar.addAction(
  1731. QtGui.QIcon(self.app.resource_location + '/disc32.png'), _("Disc"))
  1732. self.grb_edit_toolbar.addSeparator()
  1733. self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(
  1734. QtGui.QIcon(self.app.resource_location + '/buffer16-2.png'), _('Buffer'))
  1735. self.aperture_scale_btn = self.grb_edit_toolbar.addAction(
  1736. QtGui.QIcon(self.app.resource_location + '/scale32.png'), _('Scale'))
  1737. self.aperture_markarea_btn = self.grb_edit_toolbar.addAction(
  1738. QtGui.QIcon(self.app.resource_location + '/markarea32.png'), _('Mark Area'))
  1739. self.aperture_eraser_btn = self.grb_edit_toolbar.addAction(
  1740. QtGui.QIcon(self.app.resource_location + '/eraser26.png'), _('Eraser'))
  1741. self.grb_edit_toolbar.addSeparator()
  1742. self.aperture_copy_btn = self.grb_edit_toolbar.addAction(
  1743. QtGui.QIcon(self.app.resource_location + '/copy32.png'), _("Copy"))
  1744. self.aperture_delete_btn = self.grb_edit_toolbar.addAction(
  1745. QtGui.QIcon(self.app.resource_location + '/trash32.png'), _("Delete"))
  1746. self.grb_transform_btn = self.grb_edit_toolbar.addAction(
  1747. QtGui.QIcon(self.app.resource_location + '/transform.png'), _("Transformations"))
  1748. self.grb_edit_toolbar.addSeparator()
  1749. self.aperture_move_btn = self.grb_edit_toolbar.addAction(
  1750. QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
  1751. self.corner_snap_btn.setVisible(False)
  1752. self.snap_magnet.setVisible(False)
  1753. qsettings = QSettings("Open Source", "FlatCAM")
  1754. if qsettings.contains("layout"):
  1755. layout = qsettings.value('layout', type=str)
  1756. # on 'minimal' layout only some toolbars are active
  1757. if layout != 'minimal':
  1758. self.exc_edit_toolbar.setVisible(True)
  1759. self.exc_edit_toolbar.setDisabled(True)
  1760. self.geo_edit_toolbar.setVisible(True)
  1761. self.geo_edit_toolbar.setDisabled(True)
  1762. self.grb_edit_toolbar.setVisible(True)
  1763. self.grb_edit_toolbar.setDisabled(True)
  1764. def keyPressEvent(self, event):
  1765. """
  1766. Key event handler for the entire app.
  1767. Some of the key events are also treated locally in the FlatCAM editors
  1768. :param event: QT event
  1769. :return:
  1770. """
  1771. modifiers = QtWidgets.QApplication.keyboardModifiers()
  1772. active = self.app.collection.get_active()
  1773. selected = self.app.collection.get_selected()
  1774. names_list = self.app.collection.get_names()
  1775. matplotlib_key_flag = False
  1776. # events out of the self.app.collection view (it's about Project Tab) are of type int
  1777. if type(event) is int:
  1778. key = event
  1779. # events from the GUI are of type QKeyEvent
  1780. elif type(event) == QtGui.QKeyEvent:
  1781. key = event.key()
  1782. elif isinstance(event, mpl_key_event): # MatPlotLib key events are trickier to interpret than the rest
  1783. matplotlib_key_flag = True
  1784. key = event.key
  1785. key = QtGui.QKeySequence(key)
  1786. # check for modifiers
  1787. key_string = key.toString().lower()
  1788. if '+' in key_string:
  1789. mod, __, key_text = key_string.rpartition('+')
  1790. if mod.lower() == 'ctrl':
  1791. modifiers = QtCore.Qt.ControlModifier
  1792. elif mod.lower() == 'alt':
  1793. modifiers = QtCore.Qt.AltModifier
  1794. elif mod.lower() == 'shift':
  1795. modifiers = QtCore.Qt.ShiftModifier
  1796. else:
  1797. modifiers = QtCore.Qt.NoModifier
  1798. key = QtGui.QKeySequence(key_text)
  1799. # events from Vispy are of type KeyEvent
  1800. else:
  1801. key = event.key
  1802. if self.app.call_source == 'app':
  1803. # CTRL + ALT
  1804. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  1805. if key == QtCore.Qt.Key_X:
  1806. self.app.abort_all_tasks()
  1807. return
  1808. # CTRL + SHIFT
  1809. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.ShiftModifier:
  1810. if key == QtCore.Qt.Key_S:
  1811. self.app.on_file_saveprojectas()
  1812. return
  1813. # CTRL
  1814. elif modifiers == QtCore.Qt.ControlModifier:
  1815. # Select All
  1816. if key == QtCore.Qt.Key_A:
  1817. self.app.on_selectall()
  1818. # Copy an FlatCAM object
  1819. if key == QtCore.Qt.Key_C:
  1820. widget_name = self.plot_tab_area.currentWidget().objectName()
  1821. if widget_name == 'database_tab':
  1822. # Tools DB saved, update flag
  1823. self.app.tools_db_changed_flag = True
  1824. self.app.tools_db_tab.on_tool_copy()
  1825. return
  1826. self.app.on_copy_command()
  1827. # Copy an FlatCAM object
  1828. if key == QtCore.Qt.Key_D:
  1829. self.app.on_tools_database()
  1830. # Open Excellon file
  1831. if key == QtCore.Qt.Key_E:
  1832. self.app.on_fileopenexcellon(signal=None)
  1833. # Open Gerber file
  1834. if key == QtCore.Qt.Key_G:
  1835. widget_name = self.plot_tab_area.currentWidget().objectName()
  1836. if 'editor' in widget_name.lower():
  1837. self.app.goto_text_line()
  1838. else:
  1839. self.app.on_fileopengerber(signal=None)
  1840. # Distance Tool
  1841. if key == QtCore.Qt.Key_M:
  1842. self.app.distance_tool.run()
  1843. # Create New Project
  1844. if key == QtCore.Qt.Key_N:
  1845. self.app.on_file_new_click()
  1846. # Open Project
  1847. if key == QtCore.Qt.Key_O:
  1848. self.app.on_file_openproject(signal=None)
  1849. # Open Project
  1850. if key == QtCore.Qt.Key_P:
  1851. self.app.on_file_save_objects_pdf(use_thread=True)
  1852. # PDF Import
  1853. if key == QtCore.Qt.Key_Q:
  1854. self.app.pdf_tool.run()
  1855. # Save Project
  1856. if key == QtCore.Qt.Key_S:
  1857. widget_name = self.plot_tab_area.currentWidget().objectName()
  1858. if widget_name == 'preferences_tab':
  1859. self.app.preferencesUiManager.on_save_button(save_to_file=False)
  1860. return
  1861. if widget_name == 'database_tab':
  1862. # Tools DB saved, update flag
  1863. self.app.tools_db_changed_flag = False
  1864. self.app.tools_db_tab.on_save_tools_db()
  1865. return
  1866. self.app.on_file_saveproject()
  1867. # Toggle Plot Area
  1868. if key == QtCore.Qt.Key_F10 or key == 'F10':
  1869. self.on_toggle_plotarea()
  1870. return
  1871. # SHIFT
  1872. elif modifiers == QtCore.Qt.ShiftModifier:
  1873. # Copy Object Name
  1874. if key == QtCore.Qt.Key_C:
  1875. self.app.on_copy_name()
  1876. # Toggle Code Editor
  1877. if key == QtCore.Qt.Key_E:
  1878. self.app.on_toggle_code_editor()
  1879. # Toggle axis
  1880. if key == QtCore.Qt.Key_G:
  1881. self.app.on_toggle_axis()
  1882. # Toggle HUD (Heads-Up Display)
  1883. if key == QtCore.Qt.Key_H:
  1884. self.app.on_toggle_hud()
  1885. # Locate in Object
  1886. if key == QtCore.Qt.Key_J:
  1887. self.app.on_locate(obj=self.app.collection.get_active())
  1888. # Run Distance Minimum Tool
  1889. if key == QtCore.Qt.Key_M:
  1890. self.app.distance_min_tool.run()
  1891. return
  1892. # Open Preferences Window
  1893. if key == QtCore.Qt.Key_P:
  1894. self.app.on_preferences()
  1895. return
  1896. # Rotate Object by 90 degree CCW
  1897. if key == QtCore.Qt.Key_R:
  1898. self.app.on_rotate(silent=True, preset=-float(self.app.defaults['tools_transform_rotate']))
  1899. return
  1900. # Run a Script
  1901. if key == QtCore.Qt.Key_S:
  1902. self.app.on_filerunscript()
  1903. return
  1904. # Toggle Workspace
  1905. if key == QtCore.Qt.Key_W:
  1906. self.app.on_workspace_toggle()
  1907. return
  1908. # Skew on X axis
  1909. if key == QtCore.Qt.Key_X:
  1910. self.app.on_skewx()
  1911. return
  1912. # Skew on Y axis
  1913. if key == QtCore.Qt.Key_Y:
  1914. self.app.on_skewy()
  1915. return
  1916. # ALT
  1917. elif modifiers == QtCore.Qt.AltModifier:
  1918. # Eanble all plots
  1919. if key == Qt.Key_1:
  1920. self.app.enable_all_plots()
  1921. # Disable all plots
  1922. if key == Qt.Key_2:
  1923. self.app.disable_all_plots()
  1924. # Disable all other plots
  1925. if key == Qt.Key_3:
  1926. self.app.disable_other_plots()
  1927. # Align in Object Tool
  1928. if key == QtCore.Qt.Key_A:
  1929. self.app.align_objects_tool.run(toggle=True)
  1930. # Calculator Tool
  1931. if key == QtCore.Qt.Key_C:
  1932. self.app.calculator_tool.run(toggle=True)
  1933. # 2-Sided PCB Tool
  1934. if key == QtCore.Qt.Key_D:
  1935. self.app.dblsidedtool.run(toggle=True)
  1936. return
  1937. # Calibration Tool
  1938. if key == QtCore.Qt.Key_E:
  1939. self.app.cal_exc_tool.run(toggle=True)
  1940. return
  1941. # Copper Thieving Tool
  1942. if key == QtCore.Qt.Key_F:
  1943. self.app.copper_thieving_tool.run(toggle=True)
  1944. return
  1945. # Toggle Grid lines
  1946. if key == QtCore.Qt.Key_G:
  1947. self.app.on_toggle_grid_lines()
  1948. return
  1949. # Align in Object Tool
  1950. if key == QtCore.Qt.Key_H:
  1951. self.app.punch_tool.run(toggle=True)
  1952. # Extract Drills Tool
  1953. if key == QtCore.Qt.Key_I:
  1954. self.app.edrills_tool.run(toggle=True)
  1955. # Fiducials Tool
  1956. if key == QtCore.Qt.Key_J:
  1957. self.app.fiducial_tool.run(toggle=True)
  1958. return
  1959. # Solder Paste Dispensing Tool
  1960. if key == QtCore.Qt.Key_K:
  1961. self.app.paste_tool.run(toggle=True)
  1962. return
  1963. # Film Tool
  1964. if key == QtCore.Qt.Key_L:
  1965. self.app.film_tool.run(toggle=True)
  1966. return
  1967. # Corner Markers Tool
  1968. if key == QtCore.Qt.Key_M:
  1969. self.app.corners_tool.run(toggle=True)
  1970. return
  1971. # Non-Copper Clear Tool
  1972. if key == QtCore.Qt.Key_N:
  1973. self.app.ncclear_tool.run(toggle=True)
  1974. return
  1975. # Optimal Tool
  1976. if key == QtCore.Qt.Key_O:
  1977. self.app.optimal_tool.run(toggle=True)
  1978. return
  1979. # Paint Tool
  1980. if key == QtCore.Qt.Key_P:
  1981. self.app.paint_tool.run(toggle=True)
  1982. return
  1983. # QRCode Tool
  1984. if key == QtCore.Qt.Key_Q:
  1985. self.app.qrcode_tool.run()
  1986. return
  1987. # Rules Tool
  1988. if key == QtCore.Qt.Key_R:
  1989. self.app.rules_tool.run(toggle=True)
  1990. return
  1991. # View Source Object Content
  1992. if key == QtCore.Qt.Key_S:
  1993. self.app.on_view_source()
  1994. return
  1995. # Transformation Tool
  1996. if key == QtCore.Qt.Key_T:
  1997. self.app.transform_tool.run(toggle=True)
  1998. return
  1999. # Substract Tool
  2000. if key == QtCore.Qt.Key_W:
  2001. self.app.sub_tool.run(toggle=True)
  2002. return
  2003. # Cutout Tool
  2004. if key == QtCore.Qt.Key_X:
  2005. self.app.cutout_tool.run(toggle=True)
  2006. return
  2007. # Panelize Tool
  2008. if key == QtCore.Qt.Key_Z:
  2009. self.app.panelize_tool.run(toggle=True)
  2010. return
  2011. # Toggle Fullscreen
  2012. if key == QtCore.Qt.Key_F10 or key == 'F10':
  2013. self.on_fullscreen()
  2014. return
  2015. # NO MODIFIER
  2016. elif modifiers == QtCore.Qt.NoModifier:
  2017. # Open Manual
  2018. if key == QtCore.Qt.Key_F1 or key == 'F1':
  2019. webbrowser.open(self.app.manual_url)
  2020. # Show shortcut list
  2021. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2022. self.app.on_shortcut_list()
  2023. # Open Video Help
  2024. if key == QtCore.Qt.Key_F4 or key == 'F4':
  2025. webbrowser.open(self.app.video_url)
  2026. # Open Video Help
  2027. if key == QtCore.Qt.Key_F5 or key == 'F5':
  2028. self.app.plot_all()
  2029. # Switch to Project Tab
  2030. if key == QtCore.Qt.Key_1:
  2031. self.app.on_select_tab('project')
  2032. # Switch to Selected Tab
  2033. if key == QtCore.Qt.Key_2:
  2034. self.app.on_select_tab('selected')
  2035. # Switch to Tool Tab
  2036. if key == QtCore.Qt.Key_3:
  2037. self.app.on_select_tab('tool')
  2038. # Delete from PyQt
  2039. # It's meant to make a difference between delete objects and delete tools in
  2040. # Geometry Selected tool table
  2041. if key == QtCore.Qt.Key_Delete and matplotlib_key_flag is False:
  2042. widget_name = self.plot_tab_area.currentWidget().objectName()
  2043. if widget_name == 'database_tab':
  2044. # Tools DB saved, update flag
  2045. self.app.tools_db_changed_flag = True
  2046. self.app.tools_db_tab.on_tool_delete()
  2047. return
  2048. self.app.on_delete_keypress()
  2049. # Delete from canvas
  2050. if key == 'Delete':
  2051. # Delete via the application to
  2052. # ensure cleanup of the AppGUI
  2053. if active:
  2054. active.app.on_delete()
  2055. # Escape = Deselect All
  2056. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2057. self.app.on_deselect_all()
  2058. # if in full screen, exit to normal view
  2059. if self.toggle_fscreen is True:
  2060. self.on_fullscreen(disable=True)
  2061. # try to disconnect the slot from Set Origin
  2062. try:
  2063. self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_set_zero_click)
  2064. except TypeError:
  2065. pass
  2066. self.app.inform.emit("")
  2067. # Space = Toggle Active/Inactive
  2068. if key == QtCore.Qt.Key_Space:
  2069. for select in selected:
  2070. select.ui.plot_cb.toggle()
  2071. self.app.collection.update_view()
  2072. self.app.delete_selection_shape()
  2073. # Select the object in the Tree above the current one
  2074. if key == QtCore.Qt.Key_Up:
  2075. # make sure it works only for the Project Tab who is an instance of KeySensitiveListView
  2076. focused_wdg = QtWidgets.QApplication.focusWidget()
  2077. if isinstance(focused_wdg, KeySensitiveListView):
  2078. self.app.collection.set_all_inactive()
  2079. if active is None:
  2080. return
  2081. active_name = active.options['name']
  2082. active_index = names_list.index(active_name)
  2083. if active_index == 0:
  2084. self.app.collection.set_active(names_list[-1])
  2085. else:
  2086. self.app.collection.set_active(names_list[active_index-1])
  2087. # Select the object in the Tree below the current one
  2088. if key == QtCore.Qt.Key_Down:
  2089. # make sure it works only for the Project Tab who is an instance of KeySensitiveListView
  2090. focused_wdg = QtWidgets.QApplication.focusWidget()
  2091. if isinstance(focused_wdg, KeySensitiveListView):
  2092. self.app.collection.set_all_inactive()
  2093. if active is None:
  2094. return
  2095. active_name = active.options['name']
  2096. active_index = names_list.index(active_name)
  2097. if active_index == len(names_list) - 1:
  2098. self.app.collection.set_active(names_list[0])
  2099. else:
  2100. self.app.collection.set_active(names_list[active_index+1])
  2101. # New Geometry
  2102. if key == QtCore.Qt.Key_B:
  2103. self.app.app_obj.new_gerber_object()
  2104. # New Geometry
  2105. if key == QtCore.Qt.Key_D:
  2106. self.app.new_document_object()
  2107. # Copy Object Name
  2108. if key == QtCore.Qt.Key_E:
  2109. self.app.object2editor()
  2110. # Grid toggle
  2111. if key == QtCore.Qt.Key_G:
  2112. self.app.ui.grid_snap_btn.trigger()
  2113. # Jump to coords
  2114. if key == QtCore.Qt.Key_J:
  2115. self.app.on_jump_to()
  2116. # New Excellon
  2117. if key == QtCore.Qt.Key_L:
  2118. self.app.app_obj.new_excellon_object()
  2119. # Move tool toggle
  2120. if key == QtCore.Qt.Key_M:
  2121. self.app.move_tool.toggle()
  2122. # New Geometry
  2123. if key == QtCore.Qt.Key_N:
  2124. self.app.app_obj.new_geometry_object()
  2125. # Set Origin
  2126. if key == QtCore.Qt.Key_O:
  2127. self.app.on_set_origin()
  2128. return
  2129. # Properties Tool
  2130. if key == QtCore.Qt.Key_P:
  2131. self.app.properties_tool.run()
  2132. return
  2133. # Change Units
  2134. if key == QtCore.Qt.Key_Q:
  2135. # if self.app.defaults["units"] == 'MM':
  2136. # self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("IN")
  2137. # else:
  2138. # self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("MM")
  2139. # self.app.on_toggle_units(no_pref=True)
  2140. self.app.on_toggle_units_click()
  2141. # Rotate Object by 90 degree CW
  2142. if key == QtCore.Qt.Key_R:
  2143. self.app.on_rotate(silent=True, preset=self.app.defaults['tools_transform_rotate'])
  2144. # Shell toggle
  2145. if key == QtCore.Qt.Key_S:
  2146. self.toggle_shell_ui()
  2147. # Add a Tool from shortcut
  2148. if key == QtCore.Qt.Key_T:
  2149. widget_name = self.plot_tab_area.currentWidget().objectName()
  2150. if widget_name == 'database_tab':
  2151. # Tools DB saved, update flag
  2152. self.app.tools_db_changed_flag = True
  2153. self.app.tools_db_tab.on_tool_add()
  2154. return
  2155. self.app.on_tool_add_keypress()
  2156. # Zoom Fit
  2157. if key == QtCore.Qt.Key_V:
  2158. self.app.on_zoom_fit()
  2159. # Mirror on X the selected object(s)
  2160. if key == QtCore.Qt.Key_X:
  2161. self.app.on_flipx()
  2162. # Mirror on Y the selected object(s)
  2163. if key == QtCore.Qt.Key_Y:
  2164. self.app.on_flipy()
  2165. # Zoom In
  2166. if key == QtCore.Qt.Key_Equal:
  2167. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'], self.app.mouse)
  2168. # Zoom Out
  2169. if key == QtCore.Qt.Key_Minus:
  2170. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'], self.app.mouse)
  2171. # toggle display of Notebook area
  2172. if key == QtCore.Qt.Key_QuoteLeft:
  2173. self.on_toggle_notebook()
  2174. return
  2175. elif self.app.call_source == 'geo_editor':
  2176. # CTRL
  2177. if modifiers == QtCore.Qt.ControlModifier:
  2178. # save (update) the current geometry and return to the App
  2179. if key == QtCore.Qt.Key_S or key == 'S':
  2180. self.app.editor2object()
  2181. return
  2182. # toggle the measurement tool
  2183. if key == QtCore.Qt.Key_M or key == 'M':
  2184. self.app.distance_tool.run()
  2185. return
  2186. # Cut Action Tool
  2187. if key == QtCore.Qt.Key_X or key == 'X':
  2188. if self.app.geo_editor.get_selected() is not None:
  2189. self.app.geo_editor.cutpath()
  2190. else:
  2191. msg = _('Please first select a geometry item to be cutted\n'
  2192. 'then select the geometry item that will be cutted\n'
  2193. 'out of the first item. In the end press ~X~ key or\n'
  2194. 'the toolbar button.')
  2195. messagebox = QtWidgets.QMessageBox()
  2196. messagebox.setText(msg)
  2197. messagebox.setWindowTitle(_("Warning"))
  2198. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2199. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2200. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2201. messagebox.exec_()
  2202. return
  2203. # SHIFT
  2204. elif modifiers == QtCore.Qt.ShiftModifier:
  2205. # Run Distance Minimum Tool
  2206. if key == QtCore.Qt.Key_M or key == 'M':
  2207. self.app.distance_min_tool.run()
  2208. return
  2209. # Skew on X axis
  2210. if key == QtCore.Qt.Key_X or key == 'X':
  2211. self.app.geo_editor.transform_tool.on_skewx_key()
  2212. return
  2213. # Skew on Y axis
  2214. if key == QtCore.Qt.Key_Y or key == 'Y':
  2215. self.app.geo_editor.transform_tool.on_skewy_key()
  2216. return
  2217. # ALT
  2218. elif modifiers == QtCore.Qt.AltModifier:
  2219. # Transformation Tool
  2220. if key == QtCore.Qt.Key_R or key == 'R':
  2221. self.app.geo_editor.select_tool('transform')
  2222. return
  2223. # Offset on X axis
  2224. if key == QtCore.Qt.Key_X or key == 'X':
  2225. self.app.geo_editor.transform_tool.on_offx_key()
  2226. return
  2227. # Offset on Y axis
  2228. if key == QtCore.Qt.Key_Y or key == 'Y':
  2229. self.app.geo_editor.transform_tool.on_offy_key()
  2230. return
  2231. # NO MODIFIER
  2232. elif modifiers == QtCore.Qt.NoModifier:
  2233. # toggle display of Notebook area
  2234. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2235. self.on_toggle_notebook()
  2236. # Finish the current action. Use with tools that do not
  2237. # complete automatically, like a polygon or path.
  2238. if key == QtCore.Qt.Key_Enter or key == 'Enter':
  2239. if isinstance(self.app.geo_editor.active_tool, FCShapeTool):
  2240. if self.app.geo_editor.active_tool.name == 'rotate':
  2241. self.app.geo_editor.active_tool.make()
  2242. if self.app.geo_editor.active_tool.complete:
  2243. self.app.geo_editor.on_shape_complete()
  2244. self.app.inform.emit('[success] %s' % _("Done."))
  2245. # automatically make the selection tool active after completing current action
  2246. self.app.geo_editor.select_tool('select')
  2247. return
  2248. else:
  2249. self.app.geo_editor.active_tool.click(
  2250. self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
  2251. self.app.geo_editor.active_tool.make()
  2252. if self.app.geo_editor.active_tool.complete:
  2253. self.app.geo_editor.on_shape_complete()
  2254. self.app.inform.emit('[success] %s' % _("Done."))
  2255. # automatically make the selection tool active after completing current action
  2256. self.app.geo_editor.select_tool('select')
  2257. # Abort the current action
  2258. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2259. # self.on_tool_select("select")
  2260. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  2261. self.app.geo_editor.delete_utility_geometry()
  2262. self.app.geo_editor.active_tool.clean_up()
  2263. self.app.geo_editor.select_tool('select')
  2264. # hide the notebook
  2265. self.app.ui.splitter.setSizes([0, 1])
  2266. return
  2267. # Delete selected object
  2268. if key == QtCore.Qt.Key_Delete or key == 'Delete':
  2269. self.app.geo_editor.delete_selected()
  2270. self.app.geo_editor.replot()
  2271. # Rotate
  2272. if key == QtCore.Qt.Key_Space or key == 'Space':
  2273. self.app.geo_editor.transform_tool.on_rotate_key()
  2274. # Zoom Out
  2275. if key == QtCore.Qt.Key_Minus or key == '-':
  2276. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  2277. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2278. # Zoom In
  2279. if key == QtCore.Qt.Key_Equal or key == '=':
  2280. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  2281. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2282. # Switch to Project Tab
  2283. if key == QtCore.Qt.Key_1 or key == '1':
  2284. self.app.on_select_tab('project')
  2285. # Switch to Selected Tab
  2286. if key == QtCore.Qt.Key_2 or key == '2':
  2287. self.app.on_select_tab('selected')
  2288. # Switch to Tool Tab
  2289. if key == QtCore.Qt.Key_3 or key == '3':
  2290. self.app.on_select_tab('tool')
  2291. # Grid Snap
  2292. if key == QtCore.Qt.Key_G or key == 'G':
  2293. self.app.ui.grid_snap_btn.trigger()
  2294. # make sure that the cursor shape is enabled/disabled, too
  2295. if self.app.geo_editor.options['grid_snap'] is True:
  2296. self.app.app_cursor.enabled = True
  2297. else:
  2298. self.app.app_cursor.enabled = False
  2299. # Corner Snap
  2300. if key == QtCore.Qt.Key_K or key == 'K':
  2301. self.app.geo_editor.on_corner_snap()
  2302. if key == QtCore.Qt.Key_V or key == 'V':
  2303. self.app.on_zoom_fit()
  2304. # we do this so we can reuse the following keys while inside a Tool
  2305. # the above keys are general enough so were left outside
  2306. if self.app.geo_editor.active_tool is not None and self.geo_select_btn.isChecked() is False:
  2307. response = self.app.geo_editor.active_tool.on_key(key=key)
  2308. if response is not None:
  2309. self.app.inform.emit(response)
  2310. else:
  2311. # Arc Tool
  2312. if key == QtCore.Qt.Key_A or key == 'A':
  2313. self.app.geo_editor.select_tool('arc')
  2314. # Buffer
  2315. if key == QtCore.Qt.Key_B or key == 'B':
  2316. self.app.geo_editor.select_tool('buffer')
  2317. # Copy
  2318. if key == QtCore.Qt.Key_C or key == 'C':
  2319. self.app.geo_editor.on_copy_click()
  2320. # Substract Tool
  2321. if key == QtCore.Qt.Key_E or key == 'E':
  2322. if self.app.geo_editor.get_selected() is not None:
  2323. self.app.geo_editor.intersection()
  2324. else:
  2325. msg = _("Please select geometry items \n"
  2326. "on which to perform Intersection Tool.")
  2327. messagebox = QtWidgets.QMessageBox()
  2328. messagebox.setText(msg)
  2329. messagebox.setWindowTitle(_("Warning"))
  2330. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2331. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2332. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2333. messagebox.exec_()
  2334. # Paint
  2335. if key == QtCore.Qt.Key_I or key == 'I':
  2336. self.app.geo_editor.select_tool('paint')
  2337. # Jump to coords
  2338. if key == QtCore.Qt.Key_J or key == 'J':
  2339. self.app.on_jump_to()
  2340. # Move
  2341. if key == QtCore.Qt.Key_M or key == 'M':
  2342. self.app.geo_editor.on_move_click()
  2343. # Polygon Tool
  2344. if key == QtCore.Qt.Key_N or key == 'N':
  2345. self.app.geo_editor.select_tool('polygon')
  2346. # Circle Tool
  2347. if key == QtCore.Qt.Key_O or key == 'O':
  2348. self.app.geo_editor.select_tool('circle')
  2349. # Path Tool
  2350. if key == QtCore.Qt.Key_P or key == 'P':
  2351. self.app.geo_editor.select_tool('path')
  2352. # Rectangle Tool
  2353. if key == QtCore.Qt.Key_R or key == 'R':
  2354. self.app.geo_editor.select_tool('rectangle')
  2355. # Substract Tool
  2356. if key == QtCore.Qt.Key_S or key == 'S':
  2357. if self.app.geo_editor.get_selected() is not None:
  2358. self.app.geo_editor.subtract()
  2359. else:
  2360. msg = _(
  2361. "Please select geometry items \n"
  2362. "on which to perform Substraction Tool.")
  2363. messagebox = QtWidgets.QMessageBox()
  2364. messagebox.setText(msg)
  2365. messagebox.setWindowTitle(_("Warning"))
  2366. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2367. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2368. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2369. messagebox.exec_()
  2370. # Add Text Tool
  2371. if key == QtCore.Qt.Key_T or key == 'T':
  2372. self.app.geo_editor.select_tool('text')
  2373. # Substract Tool
  2374. if key == QtCore.Qt.Key_U or key == 'U':
  2375. if self.app.geo_editor.get_selected() is not None:
  2376. self.app.geo_editor.union()
  2377. else:
  2378. msg = _("Please select geometry items \n"
  2379. "on which to perform union.")
  2380. messagebox = QtWidgets.QMessageBox()
  2381. messagebox.setText(msg)
  2382. messagebox.setWindowTitle(_("Warning"))
  2383. messagebox.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/warning.png'))
  2384. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2385. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2386. messagebox.exec_()
  2387. # Flip on X axis
  2388. if key == QtCore.Qt.Key_X or key == 'X':
  2389. self.app.geo_editor.transform_tool.on_flipx()
  2390. return
  2391. # Flip on Y axis
  2392. if key == QtCore.Qt.Key_Y or key == 'Y':
  2393. self.app.geo_editor.transform_tool.on_flipy()
  2394. return
  2395. # Show Shortcut list
  2396. if key == 'F3':
  2397. self.app.on_shortcut_list()
  2398. elif self.app.call_source == 'grb_editor':
  2399. # CTRL
  2400. if modifiers == QtCore.Qt.ControlModifier:
  2401. # Eraser Tool
  2402. if key == QtCore.Qt.Key_E or key == 'E':
  2403. self.app.grb_editor.on_eraser()
  2404. return
  2405. # save (update) the current geometry and return to the App
  2406. if key == QtCore.Qt.Key_S or key == 'S':
  2407. self.app.editor2object()
  2408. return
  2409. # toggle the measurement tool
  2410. if key == QtCore.Qt.Key_M or key == 'M':
  2411. self.app.distance_tool.run()
  2412. return
  2413. # SHIFT
  2414. elif modifiers == QtCore.Qt.ShiftModifier:
  2415. # Run Distance Minimum Tool
  2416. if key == QtCore.Qt.Key_M or key == 'M':
  2417. self.app.distance_min_tool.run()
  2418. return
  2419. # ALT
  2420. elif modifiers == QtCore.Qt.AltModifier:
  2421. # Mark Area Tool
  2422. if key == QtCore.Qt.Key_A or key == 'A':
  2423. self.app.grb_editor.on_markarea()
  2424. return
  2425. # Poligonize Tool
  2426. if key == QtCore.Qt.Key_N or key == 'N':
  2427. self.app.grb_editor.on_poligonize()
  2428. return
  2429. # Transformation Tool
  2430. if key == QtCore.Qt.Key_R or key == 'R':
  2431. self.app.grb_editor.on_transform()
  2432. return
  2433. # NO MODIFIER
  2434. elif modifiers == QtCore.Qt.NoModifier:
  2435. # Abort the current action
  2436. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2437. # self.on_tool_select("select")
  2438. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  2439. self.app.grb_editor.delete_utility_geometry()
  2440. # self.app.grb_editor.plot_all()
  2441. self.app.grb_editor.active_tool.clean_up()
  2442. self.app.grb_editor.select_tool('select')
  2443. return
  2444. # Delete selected object if delete key event comes out of canvas
  2445. if key == 'Delete':
  2446. self.app.grb_editor.launched_from_shortcuts = True
  2447. if self.app.grb_editor.selected:
  2448. self.app.grb_editor.delete_selected()
  2449. self.app.grb_editor.plot_all()
  2450. else:
  2451. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to delete."))
  2452. return
  2453. # Delete aperture in apertures table if delete key event comes from the Selected Tab
  2454. if key == QtCore.Qt.Key_Delete:
  2455. self.app.grb_editor.launched_from_shortcuts = True
  2456. self.app.grb_editor.on_aperture_delete()
  2457. return
  2458. if key == QtCore.Qt.Key_Minus or key == '-':
  2459. self.app.grb_editor.launched_from_shortcuts = True
  2460. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  2461. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2462. return
  2463. if key == QtCore.Qt.Key_Equal or key == '=':
  2464. self.app.grb_editor.launched_from_shortcuts = True
  2465. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  2466. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2467. return
  2468. # toggle display of Notebook area
  2469. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2470. self.app.grb_editor.launched_from_shortcuts = True
  2471. self.on_toggle_notebook()
  2472. return
  2473. # Rotate
  2474. if key == QtCore.Qt.Key_Space or key == 'Space':
  2475. self.app.grb_editor.transform_tool.on_rotate_key()
  2476. # Switch to Project Tab
  2477. if key == QtCore.Qt.Key_1 or key == '1':
  2478. self.app.grb_editor.launched_from_shortcuts = True
  2479. self.app.on_select_tab('project')
  2480. return
  2481. # Switch to Selected Tab
  2482. if key == QtCore.Qt.Key_2 or key == '2':
  2483. self.app.grb_editor.launched_from_shortcuts = True
  2484. self.app.on_select_tab('selected')
  2485. return
  2486. # Switch to Tool Tab
  2487. if key == QtCore.Qt.Key_3 or key == '3':
  2488. self.app.grb_editor.launched_from_shortcuts = True
  2489. self.app.on_select_tab('tool')
  2490. return
  2491. # we do this so we can reuse the following keys while inside a Tool
  2492. # the above keys are general enough so were left outside
  2493. if self.app.grb_editor.active_tool is not None and self.grb_select_btn.isChecked() is False:
  2494. response = self.app.grb_editor.active_tool.on_key(key=key)
  2495. if response is not None:
  2496. self.app.inform.emit(response)
  2497. else:
  2498. # Add Array of pads
  2499. if key == QtCore.Qt.Key_A or key == 'A':
  2500. self.app.grb_editor.launched_from_shortcuts = True
  2501. self.app.inform.emit("Click on target point.")
  2502. self.app.ui.add_pad_ar_btn.setChecked(True)
  2503. self.app.grb_editor.x = self.app.mouse[0]
  2504. self.app.grb_editor.y = self.app.mouse[1]
  2505. self.app.grb_editor.select_tool('array')
  2506. return
  2507. # Scale Tool
  2508. if key == QtCore.Qt.Key_B or key == 'B':
  2509. self.app.grb_editor.launched_from_shortcuts = True
  2510. self.app.grb_editor.select_tool('buffer')
  2511. return
  2512. # Copy
  2513. if key == QtCore.Qt.Key_C or key == 'C':
  2514. self.app.grb_editor.launched_from_shortcuts = True
  2515. if self.app.grb_editor.selected:
  2516. self.app.inform.emit(_("Click on target point."))
  2517. self.app.ui.aperture_copy_btn.setChecked(True)
  2518. self.app.grb_editor.on_tool_select('copy')
  2519. self.app.grb_editor.active_tool.set_origin(
  2520. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  2521. else:
  2522. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to copy."))
  2523. return
  2524. # Add Disc Tool
  2525. if key == QtCore.Qt.Key_D or key == 'D':
  2526. self.app.grb_editor.launched_from_shortcuts = True
  2527. self.app.grb_editor.select_tool('disc')
  2528. return
  2529. # Add SemiDisc Tool
  2530. if key == QtCore.Qt.Key_E or key == 'E':
  2531. self.app.grb_editor.launched_from_shortcuts = True
  2532. self.app.grb_editor.select_tool('semidisc')
  2533. return
  2534. # Grid Snap
  2535. if key == QtCore.Qt.Key_G or key == 'G':
  2536. self.app.grb_editor.launched_from_shortcuts = True
  2537. # make sure that the cursor shape is enabled/disabled, too
  2538. if self.app.grb_editor.options['grid_snap'] is True:
  2539. self.app.app_cursor.enabled = False
  2540. else:
  2541. self.app.app_cursor.enabled = True
  2542. self.app.ui.grid_snap_btn.trigger()
  2543. return
  2544. # Jump to coords
  2545. if key == QtCore.Qt.Key_J or key == 'J':
  2546. self.app.on_jump_to()
  2547. # Corner Snap
  2548. if key == QtCore.Qt.Key_K or key == 'K':
  2549. self.app.grb_editor.launched_from_shortcuts = True
  2550. self.app.ui.corner_snap_btn.trigger()
  2551. return
  2552. # Move
  2553. if key == QtCore.Qt.Key_M or key == 'M':
  2554. self.app.grb_editor.launched_from_shortcuts = True
  2555. if self.app.grb_editor.selected:
  2556. self.app.inform.emit(_("Click on target point."))
  2557. self.app.ui.aperture_move_btn.setChecked(True)
  2558. self.app.grb_editor.on_tool_select('move')
  2559. self.app.grb_editor.active_tool.set_origin(
  2560. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  2561. else:
  2562. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to move."))
  2563. return
  2564. # Add Region Tool
  2565. if key == QtCore.Qt.Key_N or key == 'N':
  2566. self.app.grb_editor.launched_from_shortcuts = True
  2567. self.app.grb_editor.select_tool('region')
  2568. return
  2569. # Add Pad Tool
  2570. if key == QtCore.Qt.Key_P or key == 'P':
  2571. self.app.grb_editor.launched_from_shortcuts = True
  2572. self.app.inform.emit(_("Click on target point."))
  2573. self.app.ui.add_pad_ar_btn.setChecked(True)
  2574. self.app.grb_editor.x = self.app.mouse[0]
  2575. self.app.grb_editor.y = self.app.mouse[1]
  2576. self.app.grb_editor.select_tool('pad')
  2577. return
  2578. # Scale Tool
  2579. if key == QtCore.Qt.Key_S or key == 'S':
  2580. self.app.grb_editor.launched_from_shortcuts = True
  2581. self.app.grb_editor.select_tool('scale')
  2582. return
  2583. # Add Track
  2584. if key == QtCore.Qt.Key_T or key == 'T':
  2585. self.app.grb_editor.launched_from_shortcuts = True
  2586. # ## Current application units in Upper Case
  2587. self.app.grb_editor.select_tool('track')
  2588. return
  2589. # Zoom fit
  2590. if key == QtCore.Qt.Key_V or key == 'V':
  2591. self.app.grb_editor.launched_from_shortcuts = True
  2592. self.app.grb_editor.on_zoom_fit()
  2593. return
  2594. # Show Shortcut list
  2595. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2596. self.app.on_shortcut_list()
  2597. return
  2598. elif self.app.call_source == 'exc_editor':
  2599. # CTRL
  2600. if modifiers == QtCore.Qt.ControlModifier:
  2601. # save (update) the current geometry and return to the App
  2602. if key == QtCore.Qt.Key_S or key == 'S':
  2603. self.app.editor2object()
  2604. return
  2605. # toggle the measurement tool
  2606. if key == QtCore.Qt.Key_M or key == 'M':
  2607. self.app.distance_tool.run()
  2608. return
  2609. # SHIFT
  2610. elif modifiers == QtCore.Qt.ShiftModifier:
  2611. # Run Distance Minimum Tool
  2612. if key == QtCore.Qt.Key_M or key == 'M':
  2613. self.app.distance_min_tool.run()
  2614. return
  2615. # ALT
  2616. elif modifiers == QtCore.Qt.AltModifier:
  2617. pass
  2618. # NO MODIFIER
  2619. elif modifiers == QtCore.Qt.NoModifier:
  2620. # Abort the current action
  2621. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2622. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled."))
  2623. self.app.exc_editor.delete_utility_geometry()
  2624. self.app.exc_editor.active_tool.clean_up()
  2625. self.app.exc_editor.select_tool('drill_select')
  2626. return
  2627. # Delete selected object if delete key event comes out of canvas
  2628. if key == 'Delete':
  2629. self.app.exc_editor.launched_from_shortcuts = True
  2630. if self.app.exc_editor.selected:
  2631. self.app.exc_editor.delete_selected()
  2632. self.app.exc_editor.replot()
  2633. else:
  2634. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to delete."))
  2635. return
  2636. # Delete tools in tools table if delete key event comes from the Selected Tab
  2637. if key == QtCore.Qt.Key_Delete:
  2638. self.app.exc_editor.launched_from_shortcuts = True
  2639. self.app.exc_editor.on_tool_delete()
  2640. return
  2641. if key == QtCore.Qt.Key_Minus or key == '-':
  2642. self.app.exc_editor.launched_from_shortcuts = True
  2643. self.app.plotcanvas.zoom(1 / self.app.defaults['global_zoom_ratio'],
  2644. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  2645. return
  2646. if key == QtCore.Qt.Key_Equal or key == '=':
  2647. self.app.exc_editor.launched_from_shortcuts = True
  2648. self.app.plotcanvas.zoom(self.app.defaults['global_zoom_ratio'],
  2649. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  2650. return
  2651. # toggle display of Notebook area
  2652. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2653. self.app.exc_editor.launched_from_shortcuts = True
  2654. self.on_toggle_notebook()
  2655. return
  2656. # Switch to Project Tab
  2657. if key == QtCore.Qt.Key_1 or key == '1':
  2658. self.app.exc_editor.launched_from_shortcuts = True
  2659. self.app.on_select_tab('project')
  2660. return
  2661. # Switch to Selected Tab
  2662. if key == QtCore.Qt.Key_2 or key == '2':
  2663. self.app.exc_editor.launched_from_shortcuts = True
  2664. self.app.on_select_tab('selected')
  2665. return
  2666. # Switch to Tool Tab
  2667. if key == QtCore.Qt.Key_3 or key == '3':
  2668. self.app.exc_editor.launched_from_shortcuts = True
  2669. self.app.on_select_tab('tool')
  2670. return
  2671. # Grid Snap
  2672. if key == QtCore.Qt.Key_G or key == 'G':
  2673. self.app.exc_editor.launched_from_shortcuts = True
  2674. # make sure that the cursor shape is enabled/disabled, too
  2675. if self.app.exc_editor.options['grid_snap'] is True:
  2676. self.app.app_cursor.enabled = False
  2677. else:
  2678. self.app.app_cursor.enabled = True
  2679. self.app.ui.grid_snap_btn.trigger()
  2680. return
  2681. # Corner Snap
  2682. if key == QtCore.Qt.Key_K or key == 'K':
  2683. self.app.exc_editor.launched_from_shortcuts = True
  2684. self.app.ui.corner_snap_btn.trigger()
  2685. return
  2686. # Zoom Fit
  2687. if key == QtCore.Qt.Key_V or key == 'V':
  2688. self.app.exc_editor.launched_from_shortcuts = True
  2689. self.app.on_zoom_fit()
  2690. return
  2691. # Add Slot Hole Tool
  2692. if key == QtCore.Qt.Key_W or key == 'W':
  2693. self.app.exc_editor.launched_from_shortcuts = True
  2694. self.app.inform.emit(_("Click on target point."))
  2695. self.app.ui.add_slot_btn.setChecked(True)
  2696. self.app.exc_editor.x = self.app.mouse[0]
  2697. self.app.exc_editor.y = self.app.mouse[1]
  2698. self.app.exc_editor.select_tool('slot_add')
  2699. return
  2700. # Propagate to tool
  2701. # Show Shortcut list
  2702. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2703. self.app.on_shortcut_list()
  2704. return
  2705. # we do this so we can reuse the following keys while inside a Tool
  2706. # the above keys are general enough so were left outside
  2707. if self.app.exc_editor.active_tool is not None and self.select_drill_btn.isChecked() is False:
  2708. response = self.app.exc_editor.active_tool.on_key(key=key)
  2709. if response is not None:
  2710. self.app.inform.emit(response)
  2711. else:
  2712. # Add Array of Drill Hole Tool
  2713. if key == QtCore.Qt.Key_A or key == 'A':
  2714. self.app.exc_editor.launched_from_shortcuts = True
  2715. self.app.inform.emit("Click on target point.")
  2716. self.app.ui.add_drill_array_btn.setChecked(True)
  2717. self.app.exc_editor.x = self.app.mouse[0]
  2718. self.app.exc_editor.y = self.app.mouse[1]
  2719. self.app.exc_editor.select_tool('drill_array')
  2720. return
  2721. # Copy
  2722. if key == QtCore.Qt.Key_C or key == 'C':
  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.copy_drill_btn.setChecked(True)
  2727. self.app.exc_editor.on_tool_select('drill_copy')
  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 copy."))
  2732. return
  2733. # Add Drill Hole Tool
  2734. if key == QtCore.Qt.Key_D or key == 'D':
  2735. self.app.exc_editor.launched_from_shortcuts = True
  2736. self.app.inform.emit(_("Click on target point."))
  2737. self.app.ui.add_drill_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('drill_add')
  2741. return
  2742. # Jump to coords
  2743. if key == QtCore.Qt.Key_J or key == 'J':
  2744. self.app.on_jump_to()
  2745. # Move
  2746. if key == QtCore.Qt.Key_M or key == 'M':
  2747. self.app.exc_editor.launched_from_shortcuts = True
  2748. if self.app.exc_editor.selected:
  2749. self.app.inform.emit(_("Click on target point."))
  2750. self.app.ui.move_drill_btn.setChecked(True)
  2751. self.app.exc_editor.on_tool_select('drill_move')
  2752. self.app.exc_editor.active_tool.set_origin(
  2753. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  2754. else:
  2755. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Cancelled. Nothing selected to move."))
  2756. return
  2757. # Add Array of Slots Hole Tool
  2758. if key == QtCore.Qt.Key_Q or key == 'Q':
  2759. self.app.exc_editor.launched_from_shortcuts = True
  2760. self.app.inform.emit("Click on target point.")
  2761. self.app.ui.add_slot_array_btn.setChecked(True)
  2762. self.app.exc_editor.x = self.app.mouse[0]
  2763. self.app.exc_editor.y = self.app.mouse[1]
  2764. self.app.exc_editor.select_tool('slot_array')
  2765. return
  2766. # Resize Tool
  2767. if key == QtCore.Qt.Key_R or key == 'R':
  2768. self.app.exc_editor.launched_from_shortcuts = True
  2769. self.app.exc_editor.select_tool('drill_resize')
  2770. return
  2771. # Add Tool
  2772. if key == QtCore.Qt.Key_T or key == 'T':
  2773. self.app.exc_editor.launched_from_shortcuts = True
  2774. # ## Current application units in Upper Case
  2775. self.units = self.general_defaults_form.general_app_group.units_radio.get_value().upper()
  2776. tool_add_popup = FCInputDialog(title=_("New Tool ..."),
  2777. text='%s:' % _('Enter a Tool Diameter'),
  2778. min=0.0000, max=99.9999, decimals=4)
  2779. tool_add_popup.setWindowIcon(QtGui.QIcon(self.app.resource_location + '/letter_t_32.png'))
  2780. val, ok = tool_add_popup.get_value()
  2781. if ok:
  2782. self.app.exc_editor.on_tool_add(tooldia=val)
  2783. formated_val = '%.*f' % (self.decimals, float(val))
  2784. self.app.inform.emit(
  2785. '[success] %s: %s %s' % (_("Added new tool with dia"), formated_val, str(self.units))
  2786. )
  2787. else:
  2788. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Adding Tool cancelled ..."))
  2789. return
  2790. elif self.app.call_source == 'measurement':
  2791. if modifiers == QtCore.Qt.ControlModifier:
  2792. pass
  2793. elif modifiers == QtCore.Qt.AltModifier:
  2794. pass
  2795. elif modifiers == QtCore.Qt.ShiftModifier:
  2796. pass
  2797. # NO MODIFIER
  2798. elif modifiers == QtCore.Qt.NoModifier:
  2799. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2800. # abort the measurement action
  2801. self.app.distance_tool.deactivate_measure_tool()
  2802. self.app.inform.emit(_("Distance Tool exit..."))
  2803. return
  2804. if key == QtCore.Qt.Key_G or key == 'G':
  2805. self.app.ui.grid_snap_btn.trigger()
  2806. return
  2807. # Jump to coords
  2808. if key == QtCore.Qt.Key_J or key == 'J':
  2809. self.app.on_jump_to()
  2810. elif self.app.call_source == 'qrcode_tool':
  2811. # CTRL + ALT
  2812. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  2813. if key == QtCore.Qt.Key_X:
  2814. self.app.abort_all_tasks()
  2815. return
  2816. elif modifiers == QtCore.Qt.ControlModifier:
  2817. pass
  2818. elif modifiers == QtCore.Qt.ShiftModifier:
  2819. pass
  2820. elif modifiers == QtCore.Qt.AltModifier:
  2821. pass
  2822. # NO MODIFIER
  2823. elif modifiers == QtCore.Qt.NoModifier:
  2824. # Escape = Deselect All
  2825. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2826. self.app.qrcode_tool.on_exit()
  2827. # Grid toggle
  2828. if key == QtCore.Qt.Key_G:
  2829. self.app.ui.grid_snap_btn.trigger()
  2830. # Jump to coords
  2831. if key == QtCore.Qt.Key_J:
  2832. self.app.on_jump_to()
  2833. elif self.app.call_source == 'copper_thieving_tool':
  2834. # CTRL + ALT
  2835. if modifiers == QtCore.Qt.ControlModifier | QtCore.Qt.AltModifier:
  2836. if key == QtCore.Qt.Key_X:
  2837. self.app.abort_all_tasks()
  2838. return
  2839. elif modifiers == QtCore.Qt.ControlModifier:
  2840. pass
  2841. elif modifiers == QtCore.Qt.ShiftModifier:
  2842. pass
  2843. elif modifiers == QtCore.Qt.AltModifier:
  2844. pass
  2845. # NO MODIFIER
  2846. elif modifiers == QtCore.Qt.NoModifier:
  2847. # Escape = Deselect All
  2848. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2849. self.app.copperfill_tool.on_exit()
  2850. # Grid toggle
  2851. if key == QtCore.Qt.Key_G:
  2852. self.app.ui.grid_snap_btn.trigger()
  2853. # Jump to coords
  2854. if key == QtCore.Qt.Key_J:
  2855. self.app.on_jump_to()
  2856. elif self.app.call_source == 'geometry':
  2857. if modifiers == QtCore.Qt.ControlModifier:
  2858. pass
  2859. elif modifiers == QtCore.Qt.AltModifier:
  2860. pass
  2861. elif modifiers == QtCore.Qt.ShiftModifier:
  2862. pass
  2863. # NO MODIFIER
  2864. elif modifiers == QtCore.Qt.NoModifier:
  2865. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2866. sel_obj = self.app.collection.get_active()
  2867. assert sel_obj.kind == 'geometry' or sel_obj.kind == 'excellon', \
  2868. "Expected a Geometry or Excellon Object, got %s" % type(sel_obj)
  2869. sel_obj.area_disconnect()
  2870. return
  2871. if key == QtCore.Qt.Key_G or key == 'G':
  2872. self.app.ui.grid_snap_btn.trigger()
  2873. return
  2874. # Jump to coords
  2875. if key == QtCore.Qt.Key_J or key == 'J':
  2876. self.app.on_jump_to()
  2877. def createPopupMenu(self):
  2878. menu = super().createPopupMenu()
  2879. menu.addSeparator()
  2880. menu.addAction(self.lock_action)
  2881. return menu
  2882. def lock_toolbar(self, lock=False):
  2883. """
  2884. Used to (un)lock the toolbars of the app.
  2885. :param lock: boolean, will lock all toolbars in place when set True
  2886. :return: None
  2887. """
  2888. if lock:
  2889. for widget in self.children():
  2890. if isinstance(widget, QtWidgets.QToolBar):
  2891. widget.setMovable(False)
  2892. else:
  2893. for widget in self.children():
  2894. if isinstance(widget, QtWidgets.QToolBar):
  2895. widget.setMovable(True)
  2896. def dragEnterEvent(self, event):
  2897. if event.mimeData().hasUrls:
  2898. event.accept()
  2899. else:
  2900. event.ignore()
  2901. def dragMoveEvent(self, event):
  2902. if event.mimeData().hasUrls:
  2903. event.accept()
  2904. else:
  2905. event.ignore()
  2906. def dropEvent(self, event):
  2907. if event.mimeData().hasUrls:
  2908. event.setDropAction(QtCore.Qt.CopyAction)
  2909. event.accept()
  2910. for url in event.mimeData().urls():
  2911. self.filename = str(url.toLocalFile())
  2912. if self.filename == "":
  2913. self.app.inform.emit("Cancelled.")
  2914. else:
  2915. extension = self.filename.lower().rpartition('.')[-1]
  2916. if extension in self.app.grb_list:
  2917. self.app.worker_task.emit({'fcn': self.app.open_gerber,
  2918. 'params': [self.filename]})
  2919. else:
  2920. event.ignore()
  2921. if extension in self.app.exc_list:
  2922. self.app.worker_task.emit({'fcn': self.app.open_excellon,
  2923. 'params': [self.filename]})
  2924. else:
  2925. event.ignore()
  2926. if extension in self.app.gcode_list:
  2927. self.app.worker_task.emit({'fcn': self.app.open_gcode,
  2928. 'params': [self.filename]})
  2929. else:
  2930. event.ignore()
  2931. if extension in self.app.svg_list:
  2932. object_type = 'geometry'
  2933. self.app.worker_task.emit({'fcn': self.app.import_svg,
  2934. 'params': [self.filename, object_type, None]})
  2935. if extension in self.app.dxf_list:
  2936. object_type = 'geometry'
  2937. self.app.worker_task.emit({'fcn': self.app.import_dxf,
  2938. 'params': [self.filename, object_type, None]})
  2939. if extension in self.app.pdf_list:
  2940. self.app.pdf_tool.periodic_check(1000)
  2941. self.app.worker_task.emit({'fcn': self.app.pdf_tool.open_pdf,
  2942. 'params': [self.filename]})
  2943. if extension in self.app.prj_list:
  2944. # self.app.open_project() is not Thread Safe
  2945. self.app.open_project(self.filename)
  2946. if extension in self.app.conf_list:
  2947. self.app.open_config_file(self.filename)
  2948. else:
  2949. event.ignore()
  2950. else:
  2951. event.ignore()
  2952. def closeEvent(self, event):
  2953. if self.app.save_in_progress:
  2954. self.app.inform.emit('[WARNING_NOTCL] %s' % _("Application is saving the project. Please wait ..."))
  2955. else:
  2956. grect = self.geometry()
  2957. # self.splitter.sizes()[0] is actually the size of the "notebook"
  2958. if not self.isMaximized():
  2959. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
  2960. self.final_save.emit()
  2961. event.ignore()
  2962. def on_fullscreen(self, disable=False):
  2963. """
  2964. :param disable:
  2965. :return:
  2966. """
  2967. flags = self.windowFlags()
  2968. if self.toggle_fscreen is False and disable is False:
  2969. # self.ui.showFullScreen()
  2970. self.setWindowFlags(flags | Qt.FramelessWindowHint)
  2971. a = self.geometry()
  2972. self.x_pos = a.x()
  2973. self.y_pos = a.y()
  2974. self.width = a.width()
  2975. self.height = a.height()
  2976. # set new geometry to full desktop rect
  2977. # Subtracting and adding the pixels below it's hack to bypass a bug in Qt5 and OpenGL that made that a
  2978. # window drawn with OpenGL in fullscreen will not show any other windows on top which means that menus and
  2979. # everything else will not work without this hack. This happen in Windows.
  2980. # https://bugreports.qt.io/browse/QTBUG-41309
  2981. desktop = QtWidgets.QApplication.desktop()
  2982. screen = desktop.screenNumber(QtGui.QCursor.pos())
  2983. rec = desktop.screenGeometry(screen)
  2984. x = rec.x() - 1
  2985. y = rec.y() - 1
  2986. h = rec.height() + 2
  2987. w = rec.width() + 2
  2988. self.setGeometry(x, y, w, h)
  2989. self.show()
  2990. # hide all Toolbars
  2991. for tb in self.findChildren(QtWidgets.QToolBar):
  2992. tb.setVisible(False)
  2993. self.snap_toolbar.setVisible(True) # This Toolbar is always visible so restore it
  2994. self.splitter.setSizes([0, 1])
  2995. self.toggle_fscreen = True
  2996. elif self.toggle_fscreen is True or disable is True:
  2997. self.setWindowFlags(flags & ~Qt.FramelessWindowHint)
  2998. self.setGeometry(self.x_pos, self.y_pos, self.width, self.height)
  2999. self.showNormal()
  3000. self.restore_toolbar_view()
  3001. self.toggle_fscreen = False
  3002. def on_toggle_plotarea(self):
  3003. """
  3004. :return:
  3005. """
  3006. try:
  3007. name = self.plot_tab_area.widget(0).objectName()
  3008. except AttributeError:
  3009. self.plot_tab_area.addTab(self.plot_tab, "Plot Area")
  3010. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  3011. self.plot_tab_area.protectTab(0)
  3012. return
  3013. if name != 'plotarea_tab':
  3014. self.plot_tab_area.insertTab(0, self.plot_tab, "Plot Area")
  3015. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  3016. self.plot_tab_area.protectTab(0)
  3017. else:
  3018. self.plot_tab_area.closeTab(0)
  3019. def on_toggle_notebook(self):
  3020. """
  3021. :return:
  3022. """
  3023. if self.splitter.sizes()[0] == 0:
  3024. self.splitter.setSizes([1, 1])
  3025. self.menu_toggle_nb.setChecked(True)
  3026. else:
  3027. self.splitter.setSizes([0, 1])
  3028. self.menu_toggle_nb.setChecked(False)
  3029. def on_toggle_grid(self):
  3030. """
  3031. :return:
  3032. """
  3033. self.grid_snap_btn.trigger()
  3034. def toggle_shell_ui(self):
  3035. """
  3036. Toggle shell dock: if is visible close it, if it is closed then open it
  3037. :return: None
  3038. """
  3039. if self.shell_dock.isVisible():
  3040. self.shell_dock.hide()
  3041. self.app.plotcanvas.native.setFocus()
  3042. else:
  3043. self.shell_dock.show()
  3044. # I want to take the focus and give it to the Tcl Shell when the Tcl Shell is run
  3045. # self.shell._edit.setFocus()
  3046. QtCore.QTimer.singleShot(0, lambda: self.shell_dock.widget()._edit.setFocus())
  3047. # HACK - simulate a mouse click - alternative
  3048. # no_km = QtCore.Qt.KeyboardModifier(QtCore.Qt.NoModifier) # no KB modifier
  3049. # pos = QtCore.QPoint((self.shell._edit.width() - 40), (self.shell._edit.height() - 2))
  3050. # e = QtGui.QMouseEvent(QtCore.QEvent.MouseButtonPress, pos, QtCore.Qt.LeftButton, QtCore.Qt.LeftButton,
  3051. # no_km)
  3052. # QtWidgets.qApp.sendEvent(self.shell._edit, e)
  3053. # f = QtGui.QMouseEvent(QtCore.QEvent.MouseButtonRelease, pos, QtCore.Qt.LeftButton, QtCore.Qt.LeftButton,
  3054. # no_km)
  3055. # QtWidgets.qApp.sendEvent(self.shell._edit, f)
  3056. class ShortcutsTab(QtWidgets.QWidget):
  3057. def __init__(self):
  3058. super(ShortcutsTab, self).__init__()
  3059. self.sh_tab_layout = QtWidgets.QVBoxLayout()
  3060. self.sh_tab_layout.setContentsMargins(2, 2, 2, 2)
  3061. self.setLayout(self.sh_tab_layout)
  3062. self.sh_hlay = QtWidgets.QHBoxLayout()
  3063. self.sh_title = QtWidgets.QTextEdit(_('<b>Shortcut Key List</b>'))
  3064. self.sh_title.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  3065. self.sh_title.setFrameStyle(QtWidgets.QFrame.NoFrame)
  3066. self.sh_title.setMaximumHeight(30)
  3067. font = self.sh_title.font()
  3068. font.setPointSize(12)
  3069. self.sh_title.setFont(font)
  3070. self.sh_tab_layout.addWidget(self.sh_title)
  3071. self.sh_tab_layout.addLayout(self.sh_hlay)
  3072. self.app_sh_msg = (
  3073. '''<b>%s</b><br>
  3074. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  3075. <tbody>
  3076. <tr height="20">
  3077. <td height="20" width="89"><strong>F3</strong></td>
  3078. <td width="194"><span style="color:#006400"><strong>&nbsp;%s</strong></span></td>
  3079. </tr>
  3080. <tr height="20">
  3081. <td height="20">&nbsp;</td>
  3082. <td>&nbsp;</td>
  3083. </tr>
  3084. <tr height="20">
  3085. <td height="20"><strong>1</strong></td>
  3086. <td>&nbsp;%s</td>
  3087. </tr>
  3088. <tr height="20">
  3089. <td height="20"><strong>2</strong></td>
  3090. <td>&nbsp;%s</td>
  3091. </tr>
  3092. <tr height="20">
  3093. <td height="20"><strong>3</strong></td>
  3094. <td>&nbsp;%s</td>
  3095. </tr>
  3096. <tr height="20">
  3097. <td height="20">&nbsp;</td>
  3098. <td>&nbsp;</td>
  3099. </tr>
  3100. <tr height="20">
  3101. <td height="20"><strong>B</strong></td>
  3102. <td>&nbsp;%s</td>
  3103. </tr>
  3104. <tr height="20">
  3105. <td height="20"><strong>E</strong></td>
  3106. <td>&nbsp;%s</td>
  3107. </tr>
  3108. <tr height="20">
  3109. <td height="20"><strong>G</strong></td>
  3110. <td>&nbsp;%s</td>
  3111. </tr>
  3112. <tr height="20">
  3113. <td height="20"><strong>J</strong></td>
  3114. <td>&nbsp;%s</td>
  3115. </tr>
  3116. <tr height="20">
  3117. <td height="20"><strong>L</strong></td>
  3118. <td>&nbsp;%s</td>
  3119. </tr>
  3120. <tr height="20">
  3121. <td height="20"><strong>M</strong></td>
  3122. <td>&nbsp;%s</td>
  3123. </tr>
  3124. <tr height="20">
  3125. <td height="20"><strong>N</strong></td>
  3126. <td>&nbsp;%s</td>
  3127. </tr>
  3128. <tr height="20">
  3129. <td height="20"><strong>O</strong></td>
  3130. <td>&nbsp;%s</td>
  3131. </tr>
  3132. <tr height="20">
  3133. <td height="20"><strong>Q</strong></td>
  3134. <td>&nbsp;%s</td>
  3135. </tr>
  3136. <tr height="20">
  3137. <td height="20"><strong>P</strong></td>
  3138. <td>&nbsp;%s</td>
  3139. </tr>
  3140. <tr height="20">
  3141. <td height="20"><strong>R</strong></td>
  3142. <td>&nbsp;%s</td>
  3143. </tr>
  3144. <tr height="20">
  3145. <td height="20"><strong>S</strong></td>
  3146. <td>&nbsp;%s</td>
  3147. </tr>
  3148. <tr height="20">
  3149. <td height="20"><strong>T</strong></td>
  3150. <td>&nbsp;%s</td>
  3151. </tr>
  3152. <tr height="20">
  3153. <td height="20"><strong>V</strong></td>
  3154. <td>&nbsp;%s</td>
  3155. </tr>
  3156. <tr height="20">
  3157. <td height="20"><strong>X</strong></td>
  3158. <td>&nbsp;%s</td>
  3159. </tr>
  3160. <tr height="20">
  3161. <td height="20"><strong>Y</strong></td>
  3162. <td>&nbsp;%s</td>
  3163. </tr>
  3164. <tr height="20">
  3165. <td height="20"><strong>&#39;-&#39;</strong></td>
  3166. <td>&nbsp;%s</td>
  3167. </tr>
  3168. <tr height="20">
  3169. <td height="20"><strong>&#39;=&#39;</strong></td>
  3170. <td>&nbsp;%s</td>
  3171. </tr>
  3172. <tr height="20">
  3173. <td height="20">&nbsp;</td>
  3174. <td>&nbsp;</td>
  3175. </tr>
  3176. <tr height="20">
  3177. <td height="20"><strong>Ctrl+A</strong></td>
  3178. <td>&nbsp;%s</td>
  3179. </tr>
  3180. <tr height="20">
  3181. <td height="20"><strong>Ctrl+C</strong></td>
  3182. <td>&nbsp;%s</td>
  3183. </tr>
  3184. <tr height="20">
  3185. <td height="20"><strong>Ctrl+D</strong></td>
  3186. <td>&nbsp;%s</td>
  3187. </tr>
  3188. <tr height="20">
  3189. <td height="20"><strong>Ctrl+E</strong></td>
  3190. <td>&nbsp;%s</td>
  3191. </tr>
  3192. <tr height="20">
  3193. <td height="20"><strong>Ctrl+G</strong></td>
  3194. <td>&nbsp;%s</td>
  3195. </tr>
  3196. <tr height="20">
  3197. <td height="20"><strong>Ctrl+M</strong></td>
  3198. <td>&nbsp;%s</td>
  3199. </tr>
  3200. <tr height="20">
  3201. <td height="20"><strong>Ctrl+N</strong></td>
  3202. <td>&nbsp;%s</td>
  3203. </tr>
  3204. <tr height="20">
  3205. <td height="20"><strong>Ctrl+O</strong></td>
  3206. <td>&nbsp;%s</td>
  3207. </tr>
  3208. <tr height="20">
  3209. <td height="20"><strong>Ctrl+P</strong></td>
  3210. <td>&nbsp;%s</td>
  3211. </tr>
  3212. <tr height="20">
  3213. <td height="20"><strong>Ctrl+Q</strong></td>
  3214. <td>&nbsp;%s</td>
  3215. </tr>
  3216. <tr height="20">
  3217. <td height="20"><strong>Ctrl+S</strong></td>
  3218. <td>&nbsp;%s</td>
  3219. </tr>
  3220. <tr height="20">
  3221. <td height="20"><strong>Ctrl+F10</strong></td>
  3222. <td>&nbsp;%s</td>
  3223. </tr>
  3224. <tr height="20">
  3225. <td height="20">&nbsp;</td>
  3226. <td>&nbsp;</td>
  3227. </tr>
  3228. <tr height="20">
  3229. <td height="20"><strong>Shift+C</strong></td>
  3230. <td>&nbsp;%s</td>
  3231. </tr>
  3232. <tr height="20">
  3233. <td height="20"><strong>Shift+E</strong></td>
  3234. <td>&nbsp;%s</td>
  3235. </tr>
  3236. <tr height="20">
  3237. <td height="20"><strong>Shift+G</strong></td>
  3238. <td>&nbsp;%s</td>
  3239. </tr>
  3240. <tr height="20">
  3241. <td height="20"><strong>Shift+J</strong></td>
  3242. <td>&nbsp;%s</td>
  3243. </tr>
  3244. <tr height="20">
  3245. <td height="20"><strong>Shift+M</strong></td>
  3246. <td>&nbsp;%s</td>
  3247. </tr>
  3248. <tr height="20">
  3249. <td height="20"><strong>Shift+P</strong></td>
  3250. <td>&nbsp;%s</td>
  3251. </tr>
  3252. <tr height="20">
  3253. <td height="20"><strong>Shift+R</strong></td>
  3254. <td>&nbsp;%s</td>
  3255. </tr>
  3256. <tr height="20">
  3257. <td height="20"><strong>Shift+S</strong></td>
  3258. <td>&nbsp;%s</td>
  3259. </tr>
  3260. <tr height="20">
  3261. <td height="20"><strong>Shift+W</strong></td>
  3262. <td>&nbsp;%s</td>
  3263. </tr>
  3264. <tr height="20">
  3265. <td height="20"><strong>Shift+X</strong></td>
  3266. <td>&nbsp;%s</td>
  3267. </tr>
  3268. <tr height="20">
  3269. <td height="20"><strong>Shift+Y</strong></td>
  3270. <td>&nbsp;%s</td>
  3271. </tr>
  3272. <tr height="20">
  3273. <td height="20">&nbsp;</td>
  3274. <td>&nbsp;</td>
  3275. </tr>
  3276. <tr height="20">
  3277. <td height="20"><strong>Alt+A</strong></td>
  3278. <td>&nbsp;%s</td>
  3279. </tr>
  3280. <tr height="20">
  3281. <td height="20"><strong>Alt+C</strong></td>
  3282. <td>&nbsp;%s</td>
  3283. </tr>
  3284. <tr height="20">
  3285. <td height="20"><strong>Alt+D</strong></td>
  3286. <td>&nbsp;%s</td>
  3287. </tr>
  3288. <tr height="20">
  3289. <td height="20"><strong>Alt+E</strong></td>
  3290. <td>&nbsp;%s</td>
  3291. </tr>
  3292. <tr height="20">
  3293. <td height="20"><strong>Alt+H</strong></td>
  3294. <td>&nbsp;%s</td>
  3295. </tr>
  3296. <tr height="20">
  3297. <td height="20"><strong>Alt+I</strong></td>
  3298. <td>&nbsp;%s</td>
  3299. </tr>
  3300. <tr height="20">
  3301. <td height="20"><strong>Alt+J</strong></td>
  3302. <td>&nbsp;%s</td>
  3303. </tr>
  3304. <tr height="20">
  3305. <td height="20"><strong>Alt+K</strong></td>
  3306. <td>&nbsp;%s</td>
  3307. </tr>
  3308. <tr height="20">
  3309. <td height="20"><strong>Alt+L</strong></td>
  3310. <td>&nbsp;%s</td>
  3311. </tr>
  3312. <tr height="20">
  3313. <td height="20"><strong>Alt+M</strong></td>
  3314. <td>&nbsp;%s</td>
  3315. </tr>
  3316. <tr height="20">
  3317. <td height="20"><strong>Alt+N</strong></td>
  3318. <td>&nbsp;%s</td>
  3319. </tr>
  3320. <tr height="20">
  3321. <td height="20"><strong>Alt+O</strong></td>
  3322. <td>&nbsp;%s</td>
  3323. </tr>
  3324. <tr height="20">
  3325. <td height="20"><strong>Alt+P</strong></td>
  3326. <td>&nbsp;%s</td>
  3327. </tr>
  3328. <tr height="20">
  3329. <td height="20"><strong>Alt+Q</strong></td>
  3330. <td>&nbsp;%s</td>
  3331. </tr>
  3332. <tr height="20">
  3333. <td height="20"><strong>Alt+R</strong></td>
  3334. <td>&nbsp;%s</td>
  3335. </tr>
  3336. <tr height="20">
  3337. <td height="20"><strong>Alt+S</strong></td>
  3338. <td>&nbsp;%s</td>
  3339. </tr>
  3340. <tr height="20">
  3341. <td height="20"><strong>Alt+U</strong></td>
  3342. <td>&nbsp;%s</td>
  3343. </tr>
  3344. <tr height="20">
  3345. <td height="20"><strong>Alt+1</strong></td>
  3346. <td>&nbsp;%s</td>
  3347. </tr>
  3348. <tr height="20">
  3349. <td height="20"><strong>Alt+2</strong></td>
  3350. <td>&nbsp;%s</td>
  3351. </tr>
  3352. <tr height="20">
  3353. <td height="20"><strong>Alt+3</strong></td>
  3354. <td>&nbsp;%s</td>
  3355. </tr>
  3356. <tr height="20">
  3357. <td height="20"><strong>Alt+F10</strong></td>
  3358. <td>&nbsp;%s</td>
  3359. </tr>
  3360. <tr height="20">
  3361. <td height="20">&nbsp;</td>
  3362. <td>&nbsp;</td>
  3363. </tr>
  3364. <tr height="20">
  3365. <td height="20"><strong>Ctrl+Alt+X</strong></td>
  3366. <td>&nbsp;%s</td>
  3367. </tr>
  3368. <tr height="20">
  3369. <td height="20">&nbsp;</td>
  3370. <td>&nbsp;</td>
  3371. </tr>
  3372. <tr height="20">
  3373. <td height="20"><strong>Ctrl+Shift+S</strong></td>
  3374. <td>&nbsp;%s</td>
  3375. </tr>
  3376. </tr>
  3377. <tr height="20">
  3378. <td height="20"><strong>Ctrl+Shift+V</strong></td>
  3379. <td>&nbsp;%s</td>
  3380. </tr>
  3381. <tr height="20">
  3382. <td height="20">&nbsp;</td>
  3383. <td>&nbsp;</td>
  3384. </tr>
  3385. <tr height="20">
  3386. <td height="20"><strong>F1</strong></td>
  3387. <td>&nbsp;%s</td>
  3388. </tr>
  3389. <tr height="20">
  3390. <td height="20"><strong>F4</strong></td>
  3391. <td>&nbsp;%s</td>
  3392. </tr>
  3393. <tr height="20">
  3394. <td height="20"><strong>F5</strong></td>
  3395. <td>&nbsp;%s</td>
  3396. </tr>
  3397. <tr height="20">
  3398. <td height="20"><strong>Del</strong></td>
  3399. <td>&nbsp;%s</td>
  3400. </tr>
  3401. <tr height="20">
  3402. <td height="20"><strong>Del</strong></td>
  3403. <td>&nbsp;%s</td>
  3404. </tr>
  3405. <tr height="20">
  3406. <td height="20"><strong>'`'</strong></td>
  3407. <td>&nbsp;%s</td>
  3408. </tr>
  3409. <tr height="20">
  3410. <td height="20"><strong>SPACE</strong></td>
  3411. <td>&nbsp;%s</td>
  3412. </tr>
  3413. <tr height="20">
  3414. <td height="20"><strong>Escape</strong></td>
  3415. <td>&nbsp;%s</td>
  3416. </tr>
  3417. </tbody>
  3418. </table>
  3419. ''' %
  3420. (
  3421. _("General Shortcut list"),
  3422. _("SHOW SHORTCUT LIST"), _("Switch to Project Tab"), _("Switch to Selected Tab"),
  3423. _("Switch to Tool Tab"),
  3424. _("New Gerber"), _("Edit Object (if selected)"), _("Grid On/Off"), _("Jump to Coordinates"),
  3425. _("New Excellon"), _("Move Obj"), _("New Geometry"), _("Set Origin"), _("Change Units"),
  3426. _("Open Properties Tool"), _("Rotate by 90 degree CW"), _("Shell Toggle"),
  3427. _("Add a Tool (when in Geometry Selected Tab or in Tools NCC or Tools Paint)"), _("Zoom Fit"),
  3428. _("Flip on X_axis"), _("Flip on Y_axis"), _("Zoom Out"), _("Zoom In"),
  3429. # CTRL section
  3430. _("Select All"), _("Copy Obj"), _("Open Tools Database"),
  3431. _("Open Excellon File"), _("Open Gerber File"), _("Distance Tool"), _("New Project"),
  3432. _("Open Project"), _("Print (PDF)"), _("PDF Import Tool"), _("Save Project"), _("Toggle Plot Area"),
  3433. # SHIFT section
  3434. _("Copy Obj_Name"),
  3435. _("Toggle Code Editor"), _("Toggle the axis"), _("Locate in Object"), _("Distance Minimum Tool"),
  3436. _("Open Preferences Window"),
  3437. _("Rotate by 90 degree CCW"), _("Run a Script"), _("Toggle the workspace"), _("Skew on X axis"),
  3438. _("Skew on Y axis"),
  3439. # ALT section
  3440. _("Align Objects Tool"), _("Calculators Tool"), _("2-Sided PCB Tool"), _("Transformations Tool"),
  3441. _("Punch Gerber Tool"), _("Extract Drills Tool"), _("Fiducials Tool"),
  3442. _("Solder Paste Dispensing Tool"),
  3443. _("Film PCB Tool"), _("Corner Markers Tool"), _("Non-Copper Clearing Tool"), _("Optimal Tool"),
  3444. _("Paint Area Tool"), _("QRCode Tool"), _("Rules Check Tool"),
  3445. _("View File Source"),
  3446. _("Cutout PCB Tool"), _("Enable all Plots"), _("Disable all Plots"), _("Disable Non-selected Plots"),
  3447. _("Toggle Full Screen"),
  3448. # CTRL + ALT section
  3449. _("Abort current task (gracefully)"),
  3450. # CTRL + SHIFT section
  3451. _("Save Project As"),
  3452. _("Paste Special. Will convert a Windows path style to the one required in Tcl Shell"),
  3453. # F keys section
  3454. _("Open Online Manual"),
  3455. _("Open Online Tutorials"), _("Refresh Plots"), _("Delete Object"), _("Alternate: Delete Tool"),
  3456. _("(left to Key_1)Toggle Notebook Area (Left Side)"), _("En(Dis)able Obj Plot"),
  3457. _("Deselects all objects")
  3458. )
  3459. )
  3460. self.sh_app = QtWidgets.QTextEdit()
  3461. self.sh_app.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  3462. self.sh_app.setText(self.app_sh_msg)
  3463. self.sh_app.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  3464. self.sh_hlay.addWidget(self.sh_app)
  3465. editor_title = """
  3466. <b>%s</b><br>
  3467. <br>
  3468. """ % _("Editor Shortcut list")
  3469. geo_sh_messages = """
  3470. <strong><span style="color:#0000ff">%s</span></strong><br>
  3471. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  3472. <tbody>
  3473. <tr height="20">
  3474. <td height="20" width="89"><strong>A</strong></td>
  3475. <td width="194">&nbsp;%s</td>
  3476. </tr>
  3477. <tr height="20">
  3478. <td height="20"><strong>B</strong></td>
  3479. <td>&nbsp;%s</td>
  3480. </tr>
  3481. <tr height="20">
  3482. <td height="20"><strong>C</strong></td>
  3483. <td>&nbsp;%s</td>
  3484. </tr>
  3485. <tr height="20">
  3486. <td height="20"><strong>D</strong></td>
  3487. <td>&nbsp;%s</td>
  3488. </tr>
  3489. <tr height="20">
  3490. <td height="20"><strong>E</strong></td>
  3491. <td>&nbsp;%s</td>
  3492. </tr>
  3493. <tr height="20">
  3494. <td height="20"><strong>I</strong></td>
  3495. <td>&nbsp;%s</td>
  3496. </tr>
  3497. <tr height="20">
  3498. <td height="20"><strong>J</strong></td>
  3499. <td>&nbsp;%s</td>
  3500. </tr>
  3501. <tr height="20">
  3502. <td height="20"><strong>K</strong></td>
  3503. <td>&nbsp;%s</td>
  3504. </tr>
  3505. <tr height="20">
  3506. <td height="20"><strong>M</strong></td>
  3507. <td>&nbsp;%s</td>
  3508. </tr>
  3509. <tr height="20">
  3510. <td height="20"><strong>M</strong></td>
  3511. <td>&nbsp;%s</td>
  3512. </tr>
  3513. <tr height="20">
  3514. <td height="20"><strong>N</strong></td>
  3515. <td>&nbsp;%s</td>
  3516. </tr>
  3517. <tr height="20">
  3518. <td height="20"><strong>O</strong></td>
  3519. <td>&nbsp;%s</td>
  3520. </tr>
  3521. <tr height="20">
  3522. <td height="20"><strong>P</strong></td>
  3523. <td>&nbsp;%s</td>
  3524. </tr>
  3525. <tr height="20">
  3526. <td height="20"><strong>R</strong></td>
  3527. <td>&nbsp;%s</td>
  3528. </tr>
  3529. <tr height="20">
  3530. <td height="20"><strong>S</strong></td>
  3531. <td>&nbsp;%s</td>
  3532. </tr>
  3533. <tr height="20">
  3534. <td height="20"><strong>T</strong></td>
  3535. <td>&nbsp;%s</td>
  3536. </tr>
  3537. <tr height="20">
  3538. <td height="20"><strong>U</strong></td>
  3539. <td>&nbsp;%s</td>
  3540. </tr>
  3541. <tr height="20">
  3542. <td height="20"><strong>X</strong></td>
  3543. <td>&nbsp;%s</td>
  3544. </tr>
  3545. <tr height="20">
  3546. <td height="20"><strong>Y</strong></td>
  3547. <td>&nbsp;%s</td>
  3548. </tr>
  3549. <tr height="20">
  3550. <td height="20">&nbsp;</td>
  3551. <td>&nbsp;</td>
  3552. </tr>
  3553. <tr height="20">
  3554. <td height="20"><strong>Shift+M</strong></td>
  3555. <td>&nbsp;%s</td>
  3556. </tr>
  3557. <tr height="20">
  3558. <td height="20"><strong>Shift+X</strong></td>
  3559. <td>&nbsp;%s</td>
  3560. </tr>
  3561. <tr height="20">
  3562. <td height="20"><strong>Shift+Y</strong></td>
  3563. <td>&nbsp;%s</td>
  3564. </tr>
  3565. <tr height="20">
  3566. <td height="20">&nbsp;</td>
  3567. <td>&nbsp;</td>
  3568. </tr>
  3569. <tr height="20">
  3570. <td height="20"><strong>Alt+R</strong></td>
  3571. <td>&nbsp;%s</td>
  3572. </tr>
  3573. <tr height="20">
  3574. <td height="20"><strong>Alt+X</strong></td>
  3575. <td>&nbsp;%s</td>
  3576. </tr>
  3577. <tr height="20">
  3578. <td height="20"><strong>Alt+Y</strong></td>
  3579. <td>&nbsp;%s</td>
  3580. </tr>
  3581. <tr height="20">
  3582. <td height="20">&nbsp;</td>
  3583. <td>&nbsp;</td>
  3584. </tr>
  3585. <tr height="20">
  3586. <td height="20"><strong>Ctrl+M</strong></td>
  3587. <td>&nbsp;%s</td>
  3588. </tr>
  3589. <tr height="20">
  3590. <td height="20"><strong>Ctrl+S</strong></td>
  3591. <td>&nbsp;%s</td>
  3592. </tr>
  3593. <tr height="20">
  3594. <td height="20"><strong>Ctrl+X</strong></td>
  3595. <td>&nbsp;%s</td>
  3596. </tr>
  3597. <tr height="20">
  3598. <td height="20">&nbsp;</td>
  3599. <td>&nbsp;</td>
  3600. </tr>
  3601. <tr height="20">
  3602. <td height="20"><strong>Space</strong></td>
  3603. <td>&nbsp;%s</td>
  3604. </tr>
  3605. <tr height="20">
  3606. <td height="20"><strong>ENTER</strong></td>
  3607. <td>&nbsp;%s</td>
  3608. </tr>
  3609. <tr height="20">
  3610. <td height="20"><strong>ESC</strong></td>
  3611. <td>&nbsp;%s</td>
  3612. </tr>
  3613. <tr height="20">
  3614. <td height="20"><strong>Del</strong></td>
  3615. <td>&nbsp;%s</td>
  3616. </tr>
  3617. </tbody>
  3618. </table>
  3619. <br>
  3620. """ % (
  3621. _("GEOMETRY EDITOR"), _("Draw an Arc"), _("Buffer Tool"), _("Copy Geo Item"),
  3622. _("Within Add Arc will toogle the ARC direction: CW or CCW"), _("Polygon Intersection Tool"),
  3623. _("Geo Paint Tool"), _("Jump to Location (x, y)"), _("Toggle Corner Snap"), _("Move Geo Item"),
  3624. _("Within Add Arc will cycle through the ARC modes"), _("Draw a Polygon"), _("Draw a Circle"),
  3625. _("Draw a Path"), _("Draw Rectangle"), _("Polygon Subtraction Tool"), _("Add Text Tool"),
  3626. _("Polygon Union Tool"), _("Flip shape on X axis"), _("Flip shape on Y axis"), _("Distance Minimum Tool"),
  3627. _("Skew shape on X axis"), _("Skew shape on Y axis"), _("Editor Transformation Tool"),
  3628. _("Offset shape on X axis"), _("Offset shape on Y axis"), _("Distance Tool"),
  3629. _("Save Object and Exit Editor"), _("Polygon Cut Tool"),
  3630. _("Rotate Geometry"), _("Finish drawing for certain tools"), _("Abort and return to Select"),
  3631. _("Delete Shape")
  3632. )
  3633. exc_sh_messages = """
  3634. <br>
  3635. <strong><span style="color:#ff0000">%s</span></strong><br>
  3636. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  3637. <tbody>
  3638. <tr height="20">
  3639. <td height="20" width="89"><strong>A</strong></td>
  3640. <td width="194">&nbsp;%s</td>
  3641. </tr>
  3642. <tr height="20">
  3643. <td height="20"><strong>C</strong></td>
  3644. <td>&nbsp;%s</td>
  3645. </tr>
  3646. <tr height="20">
  3647. <td height="20"><strong>D</strong></td>
  3648. <td>&nbsp;%s</td>
  3649. </tr>
  3650. <tr height="20">
  3651. <td height="20"><strong>J</strong></td>
  3652. <td>&nbsp;%s</td>
  3653. </tr>
  3654. <tr height="20">
  3655. <td height="20"><strong>M</strong></td>
  3656. <td>&nbsp;%s</td>
  3657. </tr>
  3658. <tr height="20">
  3659. <td height="20" width="89"><strong>Q</strong></td>
  3660. <td width="194">&nbsp;%s</td>
  3661. </tr>
  3662. <tr height="20">
  3663. <td height="20"><strong>R</strong></td>
  3664. <td>&nbsp;%s</td>
  3665. </tr>
  3666. <tr height="20">
  3667. <td height="20"><strong>T</strong></td>
  3668. <td>&nbsp;%s</td>
  3669. </tr>
  3670. <tr height="20">
  3671. <td height="20" width="89"><strong>W</strong></td>
  3672. <td width="194">&nbsp;%s</td>
  3673. </tr>
  3674. <tr height="20">
  3675. <td height="20">&nbsp;</td>
  3676. <td>&nbsp;</td>
  3677. </tr>
  3678. <tr height="20">
  3679. <td height="20"><strong>Shift+M</strong></td>
  3680. <td>&nbsp;%s</td>
  3681. </tr>
  3682. <tr height="20">
  3683. <td height="20">&nbsp;</td>
  3684. <td>&nbsp;</td>
  3685. </tr>
  3686. <tr height="20">
  3687. <td height="20"><strong>Del</strong></td>
  3688. <td>&nbsp;%s</td>
  3689. </tr>
  3690. <tr height="20">
  3691. <td height="20"><strong>Del</strong></td>
  3692. <td>&nbsp;%s</td>
  3693. </tr>
  3694. <tr height="20">
  3695. <td height="20">&nbsp;</td>
  3696. <td>&nbsp;</td>
  3697. </tr>
  3698. <tr height="20">
  3699. <td height="20"><strong>ESC</strong></td>
  3700. <td>&nbsp;%s</td>
  3701. </tr>
  3702. <tr height="20">
  3703. <td height="20"><strong>Ctrl+S</strong></td>
  3704. <td>&nbsp;%s</td>
  3705. </tr>
  3706. </tbody>
  3707. </table>
  3708. <br>
  3709. """ % (
  3710. _("EXCELLON EDITOR"), _("Add Drill Array"), _("Copy Drill(s)"), _("Add Drill"),
  3711. _("Jump to Location (x, y)"), _("Move Drill(s)"), _("Add Slot Array"), _("Resize Drill(s)"),
  3712. _("Add a new Tool"), _("Add Slot"), _("Distance Minimum Tool"),
  3713. _("Delete Drill(s)"), _("Alternate: Delete Tool(s)"),
  3714. _("Abort and return to Select"), _("Save Object and Exit Editor")
  3715. )
  3716. grb_sh_messages = """
  3717. <br>
  3718. <strong><span style="color:#00ff00">%s</span></strong><br>
  3719. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  3720. <tbody>
  3721. <tr height="20">
  3722. <td height="20" width="89"><strong>A</strong></td>
  3723. <td width="194">&nbsp;%s</td>
  3724. </tr>
  3725. <tr height="20">
  3726. <td height="20"><strong>B</strong></td>
  3727. <td>&nbsp;%s</td>
  3728. </tr>
  3729. <tr height="20">
  3730. <td height="20"><strong>C</strong></td>
  3731. <td>&nbsp;%s</td>
  3732. </tr>
  3733. <tr height="20">
  3734. <td height="20"><strong>D</strong></td>
  3735. <td>&nbsp;%s</td>
  3736. </tr>
  3737. <tr height="20">
  3738. <td height="20"><strong>E</strong></td>
  3739. <td>&nbsp;%s</td>
  3740. </tr>
  3741. <tr height="20">
  3742. <td height="20"><strong>J</strong></td>
  3743. <td>&nbsp;%s</td>
  3744. </tr>
  3745. <tr height="20">
  3746. <td height="20"><strong>M</strong></td>
  3747. <td>&nbsp;%s</td>
  3748. </tr>
  3749. <tr height="20">
  3750. <td height="20"><strong>N</strong></td>
  3751. <td>&nbsp;%s</td>
  3752. </tr>
  3753. <tr height="20">
  3754. <td height="20"><strong>P</strong></td>
  3755. <td>&nbsp;%s</td>
  3756. </tr>
  3757. <tr height="20">
  3758. <td height="20"><strong>R</strong></td>
  3759. <td>&nbsp;%s</td>
  3760. </tr>
  3761. <tr height="20">
  3762. <td height="20"><strong>S</strong></td>
  3763. <td>&nbsp;%s</td>
  3764. </tr>
  3765. <tr height="20">
  3766. <td height="20"><strong>T</strong></td>
  3767. <td>&nbsp;%s</td>
  3768. </tr>
  3769. <tr height="20">
  3770. <td height="20"><strong>T</strong></td>
  3771. <td>&nbsp;%s</td>
  3772. </tr>
  3773. <tr height="20">
  3774. <td height="20">&nbsp;</td>
  3775. <td>&nbsp;</td>
  3776. </tr>
  3777. <tr height="20">
  3778. <td height="20"><strong>Del</strong></td>
  3779. <td>&nbsp;%s</td>
  3780. </tr>
  3781. <tr height="20">
  3782. <td height="20"><strong>Del</strong></td>
  3783. <td>&nbsp;%s</td>
  3784. </tr>
  3785. <tr height="20">
  3786. <td height="20"><strong>ESC</strong></td>
  3787. <td>&nbsp;%s</td>
  3788. </tr>
  3789. <tr height="20">
  3790. <td height="20">&nbsp;</td>
  3791. <td>&nbsp;</td>
  3792. </tr>
  3793. <tr height="20">
  3794. <td height="20"><strong>Shift+M</strong></td>
  3795. <td>&nbsp;%s</td>
  3796. </tr>
  3797. <tr height="20">
  3798. <td height="20">&nbsp;</td>
  3799. <td>&nbsp;</td>
  3800. </tr>
  3801. <tr height="20">
  3802. <td height="20"><strong>Ctrl+E</strong></td>
  3803. <td>&nbsp;%s</td>
  3804. </tr>
  3805. <tr height="20">
  3806. <td height="20"><strong>Ctrl+S</strong></td>
  3807. <td>&nbsp;%s</td>
  3808. </tr>
  3809. <tr height="20">
  3810. <td height="20">&nbsp;</td>
  3811. <td>&nbsp;</td>
  3812. </tr>
  3813. <tr height="20">
  3814. <td height="20"><strong>Alt+A</strong></td>
  3815. <td>&nbsp;%s</td>
  3816. </tr>
  3817. <tr height="20">
  3818. <td height="20"><strong>Alt+N</strong></td>
  3819. <td>&nbsp;%s</td>
  3820. </tr>
  3821. <tr height="20">
  3822. <td height="20"><strong>Alt+R</strong></td>
  3823. <td>&nbsp;%s</td>
  3824. </tr>
  3825. </tbody>
  3826. </table>
  3827. <br>
  3828. """ % (
  3829. _("GERBER EDITOR"), _("Add Pad Array"), _("Buffer"), _("Copy"), _("Add Disc"), _("Add SemiDisc"),
  3830. _("Jump to Location (x, y)"), _("Move"), _("Add Region"), _("Add Pad"),
  3831. _("Within Track & Region Tools will cycle in REVERSE the bend modes"), _("Scale"), _("Add Track"),
  3832. _("Within Track & Region Tools will cycle FORWARD the bend modes"), _("Delete"),
  3833. _("Alternate: Delete Apertures"), _("Abort and return to Select"), _("Distance Minimum Tool"),
  3834. _("Eraser Tool"),
  3835. _("Save Object and Exit Editor"), _("Mark Area Tool"), _("Poligonize Tool"), _("Transformation Tool")
  3836. )
  3837. self.editor_sh_msg = editor_title + geo_sh_messages + grb_sh_messages + exc_sh_messages
  3838. self.sh_editor = QtWidgets.QTextEdit()
  3839. self.sh_editor.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  3840. self.sh_editor.setText(self.editor_sh_msg)
  3841. self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  3842. self.sh_hlay.addWidget(self.sh_editor)
  3843. # end of file