FlatCAMGUI.py 210 KB

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