FlatCAMGUI.py 211 KB

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