FlatCAMGUI.py 197 KB

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