FlatCAMGUI.py 208 KB

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