FlatCAMGUI.py 209 KB

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