FlatCAMGUI.py 207 KB

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