FlatCAMGUI.py 208 KB

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