FlatCAMGUI.py 199 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853
  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. from PyQt5 import QtGui, QtCore, QtWidgets
  9. from PyQt5.QtCore import Qt, QSettings
  10. from GUIElements import *
  11. import platform
  12. import webbrowser
  13. from FlatCAMEditor import FCShapeTool
  14. class FlatCAMGUI(QtWidgets.QMainWindow):
  15. # Emitted when persistent window geometry needs to be retained
  16. geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate')
  17. final_save = QtCore.pyqtSignal(name='saveBeforeExit')
  18. def __init__(self, version, beta, app):
  19. super(FlatCAMGUI, self).__init__()
  20. self.app = app
  21. # Divine icon pack by Ipapun @ finicons.com
  22. #####################################
  23. ### BUILDING THE GUI IS DONE HERE ###
  24. #####################################
  25. ############
  26. ### Menu ###
  27. ############
  28. self.menu = self.menuBar()
  29. ### File ###
  30. self.menufile = self.menu.addMenu('&File')
  31. self.menufile.setToolTipsVisible(True)
  32. # New Project
  33. self.menufilenewproject = QtWidgets.QAction(QtGui.QIcon('share/file16.png'), '&New Project ...\tCTRL+N', self)
  34. self.menufilenewproject.setToolTip(
  35. "Will create a new, blank project"
  36. )
  37. self.menufile.addAction(self.menufilenewproject)
  38. # New Category (Excellon, Geometry)
  39. self.menufilenew = self.menufile.addMenu(QtGui.QIcon('share/file16.png'), '&New')
  40. self.menufilenew.setToolTipsVisible(True)
  41. self.menufilenewgeo = self.menufilenew.addAction(QtGui.QIcon('share/new_geo16.png'), '&New Geometry\tN')
  42. self.menufilenewgeo.setToolTip(
  43. "Will create a new, empty Geometry Object."
  44. )
  45. self.menufilenewexc = self.menufilenew.addAction(QtGui.QIcon('share/new_geo16.png'), 'New Excellon\tL')
  46. self.menufilenewexc.setToolTip(
  47. "Will create a new, empty Excellon Object."
  48. )
  49. self.menufile_open = self.menufile.addMenu(QtGui.QIcon('share/folder32_bis.png'), 'Open')
  50. self.menufile_open.setToolTipsVisible(True)
  51. # Open gerber ...
  52. self.menufileopengerber = QtWidgets.QAction(QtGui.QIcon('share/flatcam_icon24.png'),
  53. 'Open &Gerber ...\tCTRL+G', self)
  54. self.menufile_open.addAction(self.menufileopengerber)
  55. # Open gerber with follow...
  56. self.menufileopengerber_follow = QtWidgets.QAction(QtGui.QIcon('share/flatcam_icon24.png'),
  57. 'Open &Gerber (w/ Follow) ...', self)
  58. self.menufileopengerber_follow.setToolTip(
  59. "Will open a Gerber file with the 'follow' attribute.\n"
  60. "This will actually 'trace' the features of a Gerber file and\n"
  61. "the resulting Gerber geometry will have no volume, it will be\n"
  62. "made out of lines."
  63. )
  64. self.menufile_open.addAction(self.menufileopengerber_follow)
  65. self.menufile_open.addSeparator()
  66. # Open Excellon ...
  67. self.menufileopenexcellon = QtWidgets.QAction(QtGui.QIcon('share/open_excellon32.png'),
  68. 'Open &Excellon ...\tCTRL+E',
  69. self)
  70. self.menufile_open.addAction(self.menufileopenexcellon)
  71. # Open G-Code ...
  72. self.menufileopengcode = QtWidgets.QAction(QtGui.QIcon('share/code.png'), 'Open G-&Code ...', self)
  73. self.menufile_open.addAction(self.menufileopengcode)
  74. # Open Project ...
  75. self.menufileopenproject = QtWidgets.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Project ...', self)
  76. self.menufile_open.addAction(self.menufileopenproject)
  77. # Recent
  78. self.recent = self.menufile.addMenu(QtGui.QIcon('share/recent_files.png'), "Recent files")
  79. # Separator
  80. self.menufile.addSeparator()
  81. # Run Scripts
  82. self.menufilerunscript = QtWidgets.QAction(QtGui.QIcon('share/script16.png'), 'Run Script ...\tSHIFT+S', self)
  83. self.menufilerunscript.setToolTip(
  84. "Will run the opened Tcl Script thus\n"
  85. "enabling the automation of certain\n"
  86. "functions of FlatCAM."
  87. )
  88. self.menufile.addAction(self.menufilerunscript)
  89. # Separator
  90. self.menufile.addSeparator()
  91. # Import ...
  92. self.menufileimport = self.menufile.addMenu(QtGui.QIcon('share/import.png'), 'Import')
  93. self.menufileimportsvg = QtWidgets.QAction(QtGui.QIcon('share/svg16.png'),
  94. '&SVG as Geometry Object ...', self)
  95. self.menufileimport.addAction(self.menufileimportsvg)
  96. self.menufileimportsvg_as_gerber = QtWidgets.QAction(QtGui.QIcon('share/svg16.png'),
  97. '&SVG as Gerber Object ...', self)
  98. self.menufileimport.addAction(self.menufileimportsvg_as_gerber)
  99. self.menufileimport.addSeparator()
  100. self.menufileimportdxf = QtWidgets.QAction(QtGui.QIcon('share/dxf16.png'),
  101. '&DXF as Geometry Object ...', self)
  102. self.menufileimport.addAction(self.menufileimportdxf)
  103. self.menufileimportdxf_as_gerber = QtWidgets.QAction(QtGui.QIcon('share/dxf16.png'),
  104. '&DXF as Gerber Object ...', self)
  105. self.menufileimport.addAction(self.menufileimportdxf_as_gerber)
  106. self.menufileimport.addSeparator()
  107. # Export ...
  108. self.menufileexport = self.menufile.addMenu(QtGui.QIcon('share/export.png'), 'Export')
  109. self.menufileexport.setToolTipsVisible(True)
  110. self.menufileexportsvg = QtWidgets.QAction(QtGui.QIcon('share/export.png'), 'Export &SVG ...', self)
  111. self.menufileexport.addAction(self.menufileexportsvg)
  112. self.menufileexportdxf = QtWidgets.QAction(QtGui.QIcon('share/export.png'), 'Export DXF ...', self)
  113. self.menufileexport.addAction(self.menufileexportdxf)
  114. self.menufileexport.addSeparator()
  115. self.menufileexportpng = QtWidgets.QAction(QtGui.QIcon('share/export_png32.png'), 'Export &PNG ...', self)
  116. self.menufileexportpng.setToolTip(
  117. "Will export an image in PNG format,\n"
  118. "the saved image will contain the visual \n"
  119. "information currently in FlatCAM Plot Area."
  120. )
  121. self.menufileexport.addAction(self.menufileexportpng)
  122. self.menufileexport.addSeparator()
  123. self.menufileexportexcellon = QtWidgets.QAction(QtGui.QIcon('share/drill32.png'), 'Export &Excellon ...', self)
  124. self.menufileexportexcellon.setToolTip(
  125. "Will export an Excellon Object as Excellon file,\n"
  126. "the coordinates format, the file units and zeros\n"
  127. "are set in Preferences -> Excellon Export."
  128. )
  129. self.menufileexport.addAction(self.menufileexportexcellon)
  130. # Separator
  131. self.menufile.addSeparator()
  132. # Save Defaults
  133. self.menufilesavedefaults = QtWidgets.QAction(QtGui.QIcon('share/defaults.png'), 'Save &Defaults', self)
  134. self.menufile.addAction(self.menufilesavedefaults)
  135. # Separator
  136. self.menufile.addSeparator()
  137. self.menufile_save = self.menufile.addMenu(QtGui.QIcon('share/save_as.png'), 'Save')
  138. # Save Project
  139. self.menufilesaveproject = QtWidgets.QAction(QtGui.QIcon('share/floppy16.png'), '&Save Project ...', self)
  140. self.menufile_save.addAction(self.menufilesaveproject)
  141. # Save Project As ...
  142. self.menufilesaveprojectas = QtWidgets.QAction(QtGui.QIcon('share/save_as.png'),
  143. 'Save Project &As ...\tCTRL+S', self)
  144. self.menufile_save.addAction(self.menufilesaveprojectas)
  145. # Save Project Copy ...
  146. self.menufilesaveprojectcopy = QtWidgets.QAction(QtGui.QIcon('share/floppy16.png'), 'Save Project C&opy ...',
  147. self)
  148. self.menufile_save.addAction(self.menufilesaveprojectcopy)
  149. # Separator
  150. self.menufile.addSeparator()
  151. # Quit
  152. self.menufile_exit = QtWidgets.QAction(QtGui.QIcon('share/power16.png'), 'E&xit', self)
  153. # exitAction.setShortcut('Ctrl+Q')
  154. # exitAction.setStatusTip('Exit application')
  155. self.menufile.addAction(self.menufile_exit)
  156. ### Edit ###
  157. self.menuedit = self.menu.addMenu('&Edit')
  158. # Separator
  159. self.menuedit.addSeparator()
  160. self.menueditedit = self.menuedit.addAction(QtGui.QIcon('share/edit16.png'), 'Edit Object\tE')
  161. self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), 'Save && Close Editor\tCTRL+S')
  162. # Separator
  163. self.menuedit.addSeparator()
  164. self.menuedit_convert = self.menuedit.addMenu(QtGui.QIcon('share/convert24.png'), 'Conversion')
  165. self.menuedit_convertjoin = self.menuedit_convert.addAction(
  166. QtGui.QIcon('share/join16.png'), '&Join Geo/Gerber/Exc -> Geo')
  167. self.menuedit_convertjoin.setToolTip(
  168. "Merge a selection of objects, which can be of type:\n"
  169. "- Gerber\n"
  170. "- Excellon\n"
  171. "- Geometry\n"
  172. "into a new combo Geometry object.")
  173. self.menuedit_convertjoinexc = self.menuedit_convert.addAction(
  174. QtGui.QIcon('share/join16.png'), 'Join Excellon(s) -> Excellon')
  175. self.menuedit_convertjoinexc.setToolTip(
  176. "Merge a selection of Excellon objects into a new combo Excellon object.")
  177. self.menuedit_convertjoingrb = self.menuedit_convert.addAction(
  178. QtGui.QIcon('share/join16.png'), 'Join Gerber(s) -> Gerber')
  179. self.menuedit_convertjoingrb.setToolTip(
  180. "Merge a selection of Gerber objects into a new combo Gerber object.")
  181. # Separator
  182. self.menuedit_convert.addSeparator()
  183. self.menuedit_convert_sg2mg = self.menuedit_convert.addAction(
  184. QtGui.QIcon('share/convert24.png'), 'Convert Single to MultiGeo')
  185. self.menuedit_convert_sg2mg.setToolTip(
  186. "Will convert a Geometry object from single_geometry type\n"
  187. "to a multi_geometry type.")
  188. self.menuedit_convert_mg2sg = self.menuedit_convert.addAction(
  189. QtGui.QIcon('share/convert24.png'), 'Convert Multi to SingleGeo')
  190. self.menuedit_convert_mg2sg.setToolTip(
  191. "Will convert a Geometry object from multi_geometry type\n"
  192. "to a single_geometry type.")
  193. self.menuedit_convert.setToolTipsVisible(True)
  194. # Separator
  195. self.menuedit.addSeparator()
  196. self.menueditcopyobject = self.menuedit.addAction(QtGui.QIcon('share/copy.png'), '&Copy Object\tCTRL+C')
  197. self.menueditcopyobjectasgeom = self.menuedit.addAction(QtGui.QIcon('share/copy_geo.png'),
  198. 'Copy as &Geom')
  199. # Separator
  200. self.menuedit.addSeparator()
  201. self.menueditdelete = self.menuedit.addAction(QtGui.QIcon('share/trash16.png'), '&Delete\tDEL')
  202. # Separator
  203. self.menuedit.addSeparator()
  204. self.menueditorigin = self.menuedit.addAction(QtGui.QIcon('share/origin.png'), 'Se&t Origin\tO')
  205. self.menueditjump = self.menuedit.addAction(QtGui.QIcon('share/jump_to16.png'), 'Jump to Location\tJ')
  206. # Separator
  207. self.menuedit.addSeparator()
  208. self.menuedittoggleunits= self.menuedit.addAction(QtGui.QIcon('share/toggle_units16.png'),
  209. 'Toggle Units\tQ')
  210. self.menueditselectall = self.menuedit.addAction(QtGui.QIcon('share/select_all.png'),
  211. '&Select All\tCTRL+A')
  212. # Separator
  213. self.menuedit.addSeparator()
  214. self.menueditpreferences = self.menuedit.addAction(QtGui.QIcon('share/pref.png'), '&Preferences\tSHIFT+P')
  215. ### Options ###
  216. self.menuoptions = self.menu.addMenu('&Options')
  217. # self.menuoptions_transfer = self.menuoptions.addMenu(QtGui.QIcon('share/transfer.png'), 'Transfer options')
  218. # self.menuoptions_transfer_a2p = self.menuoptions_transfer.addAction("Application to Project")
  219. # self.menuoptions_transfer_p2a = self.menuoptions_transfer.addAction("Project to Application")
  220. # self.menuoptions_transfer_p2o = self.menuoptions_transfer.addAction("Project to Object")
  221. # self.menuoptions_transfer_o2p = self.menuoptions_transfer.addAction("Object to Project")
  222. # self.menuoptions_transfer_a2o = self.menuoptions_transfer.addAction("Application to Object")
  223. # self.menuoptions_transfer_o2a = self.menuoptions_transfer.addAction("Object to Application")
  224. # Separator
  225. # self.menuoptions.addSeparator()
  226. # self.menuoptions_transform = self.menuoptions.addMenu(QtGui.QIcon('share/transform.png'),
  227. # '&Transform Object')
  228. self.menuoptions_transform_rotate = self.menuoptions.addAction(QtGui.QIcon('share/rotate.png'),
  229. "&Rotate Selection\tSHIFT+(R)")
  230. # Separator
  231. self.menuoptions.addSeparator()
  232. self.menuoptions_transform_skewx = self.menuoptions.addAction(QtGui.QIcon('share/skewX.png'),
  233. "&Skew on X axis\tSHIFT+X")
  234. self.menuoptions_transform_skewy = self.menuoptions.addAction(QtGui.QIcon('share/skewY.png'),
  235. "S&kew on Y axis\tSHIFT+Y")
  236. # Separator
  237. self.menuoptions.addSeparator()
  238. self.menuoptions_transform_flipx = self.menuoptions.addAction(QtGui.QIcon('share/flipx.png'),
  239. "Flip on &X axis\tX")
  240. self.menuoptions_transform_flipy = self.menuoptions.addAction(QtGui.QIcon('share/flipy.png'),
  241. "Flip on &Y axis\tY")
  242. # Separator
  243. self.menuoptions.addSeparator()
  244. self.menuoptions_view_source = self.menuoptions.addAction(QtGui.QIcon('share/source32.png'),
  245. "View source\tALT+S")
  246. # Separator
  247. self.menuoptions.addSeparator()
  248. ### View ###
  249. self.menuview = self.menu.addMenu('&View')
  250. self.menuviewenable = self.menuview.addAction(QtGui.QIcon('share/replot16.png'), 'Enable all plots\tALT+1')
  251. self.menuviewdisableall = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  252. 'Disable all plots\tALT+2')
  253. self.menuviewdisableother = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  254. 'Disable non-selected\tALT+3')
  255. # Separator
  256. self.menuview.addSeparator()
  257. self.menuview_zoom_fit = self.menuview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "&Zoom Fit\tV")
  258. self.menuview_zoom_in = self.menuview.addAction(QtGui.QIcon('share/zoom_in32.png'), "&Zoom In\t-")
  259. self.menuview_zoom_out = self.menuview.addAction(QtGui.QIcon('share/zoom_out32.png'), "&Zoom Out\t=")
  260. self.menuview.addSeparator()
  261. self.menuview_toggle_fscreen = self.menuview.addAction(
  262. QtGui.QIcon('share/fscreen32.png'), "&Toggle FullScreen\tALT+F10")
  263. self.menuview_toggle_parea = self.menuview.addAction(
  264. QtGui.QIcon('share/plot32.png'), "&Toggle Plot Area\tCTRL+F10")
  265. self.menuview_toggle_notebook = self.menuview.addAction(
  266. QtGui.QIcon('share/notebook32.png'), "&Toggle Project/Sel/Tool\t`")
  267. self.menuview.addSeparator()
  268. self.menuview_toggle_grid = self.menuview.addAction(QtGui.QIcon('share/grid32.png'), "&Toggle Grid Snap\tG")
  269. self.menuview_toggle_axis = self.menuview.addAction(QtGui.QIcon('share/axis32.png'), "&Toggle Axis\tSHIFT+G")
  270. self.menuview_toggle_workspace = self.menuview.addAction(QtGui.QIcon('share/workspace24.png'),
  271. "Toggle Workspace\tSHIFT+W")
  272. ### Tool ###
  273. # self.menutool = self.menu.addMenu('&Tool')
  274. self.menutool = QtWidgets.QMenu('&Tool')
  275. self.menutoolaction = self.menu.addMenu(self.menutool)
  276. self.menutoolshell = self.menutool.addAction(QtGui.QIcon('share/shell16.png'), '&Command Line\tS')
  277. ### Help ###
  278. self.menuhelp = self.menu.addMenu('&Help')
  279. self.menuhelp_manual = self.menuhelp.addAction(QtGui.QIcon('share/globe16.png'), 'Help\tF1')
  280. self.menuhelp_home = self.menuhelp.addAction(QtGui.QIcon('share/home16.png'), 'FlatCAM.org')
  281. self.menuhelp.addSeparator()
  282. self.menuhelp_videohelp = self.menuhelp.addAction(QtGui.QIcon('share/youtube32.png'), 'YouTube Channel\tF2')
  283. self.menuhelp_shortcut_list = self.menuhelp.addAction(QtGui.QIcon('share/shortcuts24.png'), 'Shortcuts List\tF3')
  284. self.menuhelp_about = self.menuhelp.addAction(QtGui.QIcon('share/about32.png'), 'About')
  285. ### FlatCAM Editor menu ###
  286. # self.editor_menu = QtWidgets.QMenu("Editor")
  287. # self.menu.addMenu(self.editor_menu)
  288. self.geo_editor_menu = QtWidgets.QMenu(">Geo Editor<")
  289. self.menu.addMenu(self.geo_editor_menu)
  290. # self.select_menuitem = self.menu.addAction(QtGui.QIcon('share/pointer16.png'), "Select 'Esc'")
  291. self.geo_add_circle_menuitem = self.geo_editor_menu.addAction(
  292. QtGui.QIcon('share/circle32.png'), 'Add Circle\tO'
  293. )
  294. self.geo_add_arc_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/arc16.png'), 'Add Arc\tA')
  295. self.geo_editor_menu.addSeparator()
  296. self.geo_add_rectangle_menuitem = self.geo_editor_menu.addAction(
  297. QtGui.QIcon('share/rectangle32.png'), 'Add Rectangle\tR'
  298. )
  299. self.geo_add_polygon_menuitem = self.geo_editor_menu.addAction(
  300. QtGui.QIcon('share/polygon32.png'), 'Add Polygon\tN'
  301. )
  302. self.geo_add_path_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/path32.png'), 'Add Path\tP')
  303. self.geo_editor_menu.addSeparator()
  304. self.geo_add_text_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/text32.png'), 'Add Text\tT')
  305. self.geo_editor_menu.addSeparator()
  306. self.geo_union_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/union16.png'), 'Polygon Union\tU')
  307. self.geo_intersection_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/intersection16.png'),
  308. 'Polygon Intersection\tE')
  309. self.geo_subtract_menuitem = self.geo_editor_menu.addAction(
  310. QtGui.QIcon('share/subtract16.png'), 'Polygon Subtraction\tS'
  311. )
  312. self.geo_editor_menu.addSeparator()
  313. self.geo_cutpath_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/cutpath16.png'), 'Cut Path\tX')
  314. # self.move_menuitem = self.menu.addAction(QtGui.QIcon('share/move16.png'), "Move Objects 'm'")
  315. self.geo_copy_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/copy16.png'), "Copy Geom\tC")
  316. self.geo_delete_menuitem = self.geo_editor_menu.addAction(
  317. QtGui.QIcon('share/deleteshape16.png'), "Delete Shape\tDEL"
  318. )
  319. self.geo_editor_menu.addSeparator()
  320. self.geo_move_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/move32.png'), "Move\tM")
  321. self.geo_buffer_menuitem = self.geo_editor_menu.addAction(
  322. QtGui.QIcon('share/buffer16.png'), "Buffer Selection\tB"
  323. )
  324. self.geo_paint_menuitem = self.geo_editor_menu.addAction(
  325. QtGui.QIcon('share/paint16.png'), "Paint Selection\tI"
  326. )
  327. self.geo_editor_menu.addSeparator()
  328. self.geo_cornersnap_menuitem = self.geo_editor_menu.addAction(
  329. QtGui.QIcon('share/corner32.png'), "Toggle Corner Snap\tK"
  330. )
  331. self.exc_editor_menu = QtWidgets.QMenu(">Excellon Editor<")
  332. self.menu.addMenu(self.exc_editor_menu)
  333. self.exc_add_array_drill_menuitem = self.exc_editor_menu.addAction(
  334. QtGui.QIcon('share/rectangle32.png'), 'Add Drill Array\tA')
  335. self.exc_add_drill_menuitem = self.exc_editor_menu.addAction(QtGui.QIcon('share/plus16.png'), 'Add Drill\tD')
  336. self.exc_editor_menu.addSeparator()
  337. self.exc_resize_drill_menuitem = self.exc_editor_menu.addAction(
  338. QtGui.QIcon('share/resize16.png'), 'Resize Drill(S)\tR'
  339. )
  340. self.exc_copy_drill_menuitem = self.exc_editor_menu.addAction(QtGui.QIcon('share/copy32.png'), 'Copy\tC')
  341. self.exc_delete_drill_menuitem = self.exc_editor_menu.addAction(
  342. QtGui.QIcon('share/deleteshape32.png'), 'Delete\tDEL'
  343. )
  344. self.exc_editor_menu.addSeparator()
  345. self.exc_move_drill_menuitem = self.exc_editor_menu.addAction(
  346. QtGui.QIcon('share/move32.png'), 'Move Drill(s)\tM')
  347. self.geo_editor_menu.menuAction().setVisible(False)
  348. self.geo_editor_menu.setDisabled(True)
  349. self.exc_editor_menu.menuAction().setVisible(False)
  350. self.exc_editor_menu.setDisabled(True)
  351. ################################
  352. ### Project Tab Context menu ###
  353. ################################
  354. self.menuproject = QtWidgets.QMenu()
  355. self.menuprojectenable = self.menuproject.addAction(QtGui.QIcon('share/replot32.png'), 'Enable Plot')
  356. self.menuprojectdisable = self.menuproject.addAction(QtGui.QIcon('share/clear_plot32.png'), 'Disable Plot')
  357. self.menuproject.addSeparator()
  358. self.menuprojectgeneratecnc = self.menuproject.addAction(QtGui.QIcon('share/cnc32.png'), 'Generate CNC')
  359. self.menuprojectviewsource = self.menuproject.addAction(QtGui.QIcon('share/source32.png'), 'View Source')
  360. self.menuprojectedit = self.menuproject.addAction(QtGui.QIcon('share/edit_ok32.png'), 'Edit')
  361. self.menuprojectcopy = self.menuproject.addAction(QtGui.QIcon('share/copy32.png'), 'Copy')
  362. self.menuprojectdelete = self.menuproject.addAction(QtGui.QIcon('share/delete32.png'), 'Delete')
  363. self.menuprojectsave= self.menuproject.addAction(QtGui.QIcon('share/save_as.png'), 'Save')
  364. self.menuproject.addSeparator()
  365. self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), 'Properties')
  366. ################
  367. ### Splitter ###
  368. ################
  369. # IMPORTANT #
  370. # The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
  371. # desired.
  372. self.splitter = QtWidgets.QSplitter()
  373. self.setCentralWidget(self.splitter)
  374. # self.notebook = QtWidgets.QTabWidget()
  375. self.notebook = FCDetachableTab(protect=True)
  376. self.notebook.setTabsClosable(False)
  377. self.notebook.useOldIndex(True)
  378. self.splitter.addWidget(self.notebook)
  379. self.splitter_left = QtWidgets.QSplitter(Qt.Vertical)
  380. self.splitter.addWidget(self.splitter_left)
  381. self.splitter_left.addWidget(self.notebook)
  382. self.splitter_left.setHandleWidth(0)
  383. ###############
  384. ### Toolbar ###
  385. ###############
  386. ### TOOLBAR INSTALLATION ###
  387. self.toolbarfile = QtWidgets.QToolBar('File Toolbar')
  388. self.toolbarfile.setObjectName('File_TB')
  389. self.addToolBar(self.toolbarfile)
  390. self.toolbargeo = QtWidgets.QToolBar('Edit Toolbar')
  391. self.toolbargeo.setObjectName('Edit_TB')
  392. self.addToolBar(self.toolbargeo)
  393. self.toolbarview = QtWidgets.QToolBar('View Toolbar')
  394. self.toolbarview.setObjectName('View_TB')
  395. self.addToolBar(self.toolbarview)
  396. self.toolbartools = QtWidgets.QToolBar('Tools Toolbar')
  397. self.toolbartools.setObjectName('Tools_TB')
  398. self.addToolBar(self.toolbartools)
  399. self.exc_edit_toolbar = QtWidgets.QToolBar('Excellon Editor Toolbar')
  400. self.exc_edit_toolbar.setObjectName('ExcEditor_TB')
  401. self.addToolBar(self.exc_edit_toolbar)
  402. self.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
  403. self.geo_edit_toolbar.setObjectName('GeoEditor_TB')
  404. self.addToolBar(self.geo_edit_toolbar)
  405. self.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
  406. self.snap_toolbar.setObjectName('Snap_TB')
  407. settings = QSettings("Open Source", "FlatCAM")
  408. if settings.contains("layout"):
  409. layout = settings.value('layout', type=str)
  410. if layout == 'standard':
  411. self.addToolBar(self.snap_toolbar)
  412. elif layout == 'compact':
  413. self.snap_toolbar.setMaximumHeight(30)
  414. self.splitter_left.addWidget(self.snap_toolbar)
  415. else:
  416. self.addToolBar(self.snap_toolbar)
  417. ### File Toolbar ###
  418. self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
  419. "Open GERBER")
  420. self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), "Open EXCELLON")
  421. self.toolbarfile.addSeparator()
  422. self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), "Open project")
  423. self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), "Save project")
  424. ### Edit Toolbar ###
  425. self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "New Blank Geometry")
  426. self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), "New Blank Excellon")
  427. self.toolbargeo.addSeparator()
  428. self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), "Editor")
  429. self.update_obj_btn = self.toolbargeo.addAction(
  430. QtGui.QIcon('share/edit_ok32_bis.png'), "Save Object and close the Editor"
  431. )
  432. self.toolbargeo.addSeparator()
  433. self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), "&Delete")
  434. ### View Toolbar ###
  435. self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), "&Replot")
  436. self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), "&Clear plot")
  437. self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), "Zoom In")
  438. self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), "Zoom Out")
  439. self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
  440. # self.toolbarview.setVisible(False)
  441. ### Tools Toolbar ###
  442. self.shell_btn = self.toolbartools.addAction(QtGui.QIcon('share/shell32.png'), "&Command Line")
  443. ### Drill Editor Toolbar ###
  444. self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
  445. self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), 'Add Drill Hole')
  446. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  447. QtGui.QIcon('share/addarray16.png'), 'Add Drill Hole Array')
  448. self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), 'Resize Drill')
  449. self.exc_edit_toolbar.addSeparator()
  450. self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), 'Copy Drill')
  451. self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Drill")
  452. self.exc_edit_toolbar.addSeparator()
  453. self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Drill")
  454. ### Geometry Editor Toolbar ###
  455. self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
  456. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), 'Add Circle')
  457. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), 'Add Arc')
  458. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'),
  459. 'Add Rectangle')
  460. self.geo_edit_toolbar.addSeparator()
  461. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), 'Add Path')
  462. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), 'Add Polygon')
  463. self.geo_edit_toolbar.addSeparator()
  464. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), 'Add Text')
  465. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), 'Add Buffer')
  466. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), 'Paint Shape')
  467. self.geo_edit_toolbar.addSeparator()
  468. self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), 'Polygon Union')
  469. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
  470. 'Polygon Intersection')
  471. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'),
  472. 'Polygon Subtraction')
  473. self.geo_edit_toolbar.addSeparator()
  474. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), 'Cut Path')
  475. self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), "Copy Objects 'c'")
  476. self.geo_rotate_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rotate.png'), "Rotate Objects 'Space'")
  477. self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'),
  478. "Delete Shape '-'")
  479. self.geo_edit_toolbar.addSeparator()
  480. self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Objects 'm'")
  481. ### Snap Toolbar ###
  482. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  483. # self.addToolBar(self.snap_toolbar)
  484. self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), 'Snap to grid')
  485. self.grid_gap_x_entry = FCEntry2()
  486. self.grid_gap_x_entry.setMaximumWidth(70)
  487. self.grid_gap_x_entry.setToolTip("Grid X distance")
  488. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  489. self.grid_gap_y_entry = FCEntry2()
  490. self.grid_gap_y_entry.setMaximumWidth(70)
  491. self.grid_gap_y_entry.setToolTip("Grid Y distance")
  492. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  493. self.grid_space_label = QtWidgets.QLabel(" ")
  494. self.snap_toolbar.addWidget(self.grid_space_label)
  495. self.grid_gap_link_cb = FCCheckBox()
  496. self.grid_gap_link_cb.setToolTip("When active, value on Grid_X\n"
  497. "is copied to the Grid_Y value.")
  498. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  499. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  500. self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), 'Snap to corner')
  501. self.snap_max_dist_entry = FCEntry()
  502. self.snap_max_dist_entry.setMaximumWidth(70)
  503. self.snap_max_dist_entry.setToolTip("Max. magnet distance")
  504. self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  505. ################
  506. ### Notebook ###
  507. ################
  508. ### Project ###
  509. self.project_tab = QtWidgets.QWidget()
  510. self.project_tab.setObjectName("project_tab")
  511. # project_tab.setMinimumWidth(250) # Hack
  512. self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_tab)
  513. self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
  514. self.notebook.addTab(self.project_tab, "Project")
  515. ### Selected ###
  516. self.selected_tab = QtWidgets.QWidget()
  517. self.selected_tab.setObjectName("selected_tab")
  518. self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab)
  519. self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
  520. self.selected_scroll_area = VerticalScrollArea()
  521. self.selected_tab_layout.addWidget(self.selected_scroll_area)
  522. self.notebook.addTab(self.selected_tab, "Selected")
  523. ### Tool ###
  524. self.tool_tab = QtWidgets.QWidget()
  525. self.tool_tab.setObjectName("tool_tab")
  526. self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab)
  527. self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
  528. self.notebook.addTab(self.tool_tab, "Tool")
  529. self.tool_scroll_area = VerticalScrollArea()
  530. self.tool_tab_layout.addWidget(self.tool_scroll_area)
  531. self.right_widget = QtWidgets.QWidget()
  532. self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
  533. self.splitter.addWidget(self.right_widget)
  534. self.right_lay = QtWidgets.QVBoxLayout()
  535. self.right_lay.setContentsMargins(0, 0, 0, 0)
  536. self.right_widget.setLayout(self.right_lay)
  537. # self.plot_tab_area = FCTab()
  538. self.plot_tab_area = FCDetachableTab(protect=False, protect_by_name=['Plot Area'])
  539. self.plot_tab_area.useOldIndex(True)
  540. self.right_lay.addWidget(self.plot_tab_area)
  541. self.plot_tab_area.setTabsClosable(True)
  542. self.plot_tab = QtWidgets.QWidget()
  543. self.plot_tab.setObjectName("plotarea")
  544. self.plot_tab_area.addTab(self.plot_tab, "Plot Area")
  545. self.right_layout = QtWidgets.QVBoxLayout()
  546. self.right_layout.setContentsMargins(2, 2, 2, 2)
  547. self.plot_tab.setLayout(self.right_layout)
  548. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  549. self.plot_tab_area.protectTab(0)
  550. ########################################
  551. ### HERE WE BUILD THE PREF. TAB AREA ###
  552. ########################################
  553. self.preferences_tab = QtWidgets.QWidget()
  554. self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
  555. self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
  556. self.pref_tab_area = FCTab()
  557. self.pref_tab_area.setTabsClosable(False)
  558. self.pref_tab_area_tabBar = self.pref_tab_area.tabBar()
  559. self.pref_tab_area_tabBar.setStyleSheet("QTabBar::tab{width:90px;}")
  560. self.pref_tab_area_tabBar.setExpanding(True)
  561. self.pref_tab_layout.addWidget(self.pref_tab_area)
  562. self.general_tab = QtWidgets.QWidget()
  563. self.pref_tab_area.addTab(self.general_tab, "General")
  564. self.general_tab_lay = QtWidgets.QVBoxLayout()
  565. self.general_tab_lay.setContentsMargins(2, 2, 2, 2)
  566. self.general_tab.setLayout(self.general_tab_lay)
  567. self.hlay1 = QtWidgets.QHBoxLayout()
  568. self.general_tab_lay.addLayout(self.hlay1)
  569. self.options_combo = QtWidgets.QComboBox()
  570. self.options_combo.addItem("APP. DEFAULTS")
  571. self.options_combo.addItem("PROJ. OPTIONS ")
  572. self.hlay1.addWidget(self.options_combo)
  573. # disable this button as it may no longer be useful
  574. self.options_combo.setVisible(False)
  575. self.hlay1.addStretch()
  576. self.general_scroll_area = QtWidgets.QScrollArea()
  577. self.general_tab_lay.addWidget(self.general_scroll_area)
  578. self.gerber_tab = QtWidgets.QWidget()
  579. self.pref_tab_area.addTab(self.gerber_tab, "GERBER")
  580. self.gerber_tab_lay = QtWidgets.QVBoxLayout()
  581. self.gerber_tab_lay.setContentsMargins(2, 2, 2, 2)
  582. self.gerber_tab.setLayout(self.gerber_tab_lay)
  583. self.gerber_scroll_area = QtWidgets.QScrollArea()
  584. self.gerber_tab_lay.addWidget(self.gerber_scroll_area)
  585. self.excellon_tab = QtWidgets.QWidget()
  586. self.pref_tab_area.addTab(self.excellon_tab, "EXCELLON")
  587. self.excellon_tab_lay = QtWidgets.QVBoxLayout()
  588. self.excellon_tab_lay.setContentsMargins(2, 2, 2, 2)
  589. self.excellon_tab.setLayout(self.excellon_tab_lay)
  590. self.excellon_scroll_area = QtWidgets.QScrollArea()
  591. self.excellon_tab_lay.addWidget(self.excellon_scroll_area)
  592. self.geometry_tab = QtWidgets.QWidget()
  593. self.pref_tab_area.addTab(self.geometry_tab, "GEOMETRY")
  594. self.geometry_tab_lay = QtWidgets.QVBoxLayout()
  595. self.geometry_tab_lay.setContentsMargins(2, 2, 2, 2)
  596. self.geometry_tab.setLayout(self.geometry_tab_lay)
  597. self.geometry_scroll_area = QtWidgets.QScrollArea()
  598. self.geometry_tab_lay.addWidget(self.geometry_scroll_area)
  599. self.cncjob_tab = QtWidgets.QWidget()
  600. self.pref_tab_area.addTab(self.cncjob_tab, "CNC-JOB")
  601. self.cncjob_tab_lay = QtWidgets.QVBoxLayout()
  602. self.cncjob_tab_lay.setContentsMargins(2, 2, 2, 2)
  603. self.cncjob_tab.setLayout(self.cncjob_tab_lay)
  604. self.cncjob_scroll_area = QtWidgets.QScrollArea()
  605. self.cncjob_tab_lay.addWidget(self.cncjob_scroll_area)
  606. self.tools_tab = QtWidgets.QWidget()
  607. self.pref_tab_area.addTab(self.tools_tab, "TOOLS")
  608. self.tools_tab_lay = QtWidgets.QVBoxLayout()
  609. self.tools_tab_lay.setContentsMargins(2, 2, 2, 2)
  610. self.tools_tab.setLayout(self.tools_tab_lay)
  611. self.tools_scroll_area = QtWidgets.QScrollArea()
  612. self.tools_tab_lay.addWidget(self.tools_scroll_area)
  613. self.pref_tab_bottom_layout = QtWidgets.QHBoxLayout()
  614. self.pref_tab_bottom_layout.setAlignment(QtCore.Qt.AlignVCenter)
  615. self.pref_tab_layout.addLayout(self.pref_tab_bottom_layout)
  616. self.pref_tab_bottom_layout_1 = QtWidgets.QHBoxLayout()
  617. self.pref_tab_bottom_layout_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  618. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_1)
  619. self.pref_import_button = QtWidgets.QPushButton()
  620. self.pref_import_button.setText("Import Preferences")
  621. self.pref_import_button.setFixedWidth(130)
  622. self.pref_import_button.setToolTip(
  623. "Import a full set of FlatCAM settings from a file\n"
  624. "previously saved on HDD.\n\n"
  625. "FlatCAM automatically save a 'factory_defaults' file\n"
  626. "on the first start. Do not delete that file.")
  627. self.pref_tab_bottom_layout_1.addWidget(self.pref_import_button)
  628. self.pref_export_button = QtWidgets.QPushButton()
  629. self.pref_export_button.setText("Export Preferences")
  630. self.pref_export_button.setFixedWidth(130)
  631. self.pref_export_button.setToolTip(
  632. "Export a full set of FlatCAM settings in a file\n"
  633. "that is saved on HDD.")
  634. self.pref_tab_bottom_layout_1.addWidget(self.pref_export_button)
  635. self.pref_open_button = QtWidgets.QPushButton()
  636. self.pref_open_button.setText("Open Pref Folder")
  637. self.pref_open_button.setFixedWidth(130)
  638. self.pref_open_button.setToolTip(
  639. "Open the folder where FlatCAM save the preferences files.")
  640. self.pref_tab_bottom_layout_1.addWidget(self.pref_open_button)
  641. self.pref_tab_bottom_layout_2 = QtWidgets.QHBoxLayout()
  642. self.pref_tab_bottom_layout_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  643. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_2)
  644. self.pref_save_button = QtWidgets.QPushButton()
  645. self.pref_save_button.setText("Save Preferences")
  646. self.pref_save_button.setFixedWidth(130)
  647. self.pref_save_button.setToolTip(
  648. "Save the current settings in the 'current_defaults' file\n"
  649. "which is the file storing the working default preferences.")
  650. self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
  651. ########################################
  652. ### HERE WE BUILD THE SHORTCUTS LIST. TAB AREA ###
  653. ########################################
  654. self.shortcuts_tab = QtWidgets.QWidget()
  655. self.sh_tab_layout = QtWidgets.QVBoxLayout()
  656. self.sh_tab_layout.setContentsMargins(2, 2, 2, 2)
  657. self.shortcuts_tab.setLayout(self.sh_tab_layout)
  658. self.sh_hlay = QtWidgets.QHBoxLayout()
  659. self.sh_title = QtWidgets.QTextEdit(
  660. '<b>Shortcut Key List</b>')
  661. self.sh_title.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  662. self.sh_title.setFrameStyle(QtWidgets.QFrame.NoFrame)
  663. self.sh_title.setMaximumHeight(30)
  664. font = self.sh_title.font()
  665. font.setPointSize(12)
  666. self.sh_title.setFont(font)
  667. self.sh_tab_layout.addWidget(self.sh_title)
  668. self.sh_tab_layout.addLayout(self.sh_hlay)
  669. self.app_sh_msg = '''<b>General Shortcut list</b><br>
  670. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  671. <tbody>
  672. <tr height="20">
  673. <td height="20" width="89"><strong>F3</strong></td>
  674. <td width="194"><span style="color:#006400"><strong>&nbsp;SHOW SHORTCUT LIST</strong></span></td>
  675. </tr>
  676. <tr height="20">
  677. <td height="20">&nbsp;</td>
  678. <td>&nbsp;</td>
  679. </tr>
  680. <tr height="20">
  681. <td height="20"><strong>1</strong></td>
  682. <td>&nbsp;Switch to Project Tab</td>
  683. </tr>
  684. <tr height="20">
  685. <td height="20"><strong>2</strong></td>
  686. <td>&nbsp;Switch to Selected Tab</td>
  687. </tr>
  688. <tr height="20">
  689. <td height="20"><strong>3</strong></td>
  690. <td>&nbsp;Switch to Tool Tab</td>
  691. </tr>
  692. <tr height="20">
  693. <td height="20">&nbsp;</td>
  694. <td>&nbsp;</td>
  695. </tr>
  696. <tr height="20">
  697. <td height="20"><strong>E</strong></td>
  698. <td>&nbsp;Edit Object (if selected)</td>
  699. </tr>
  700. <tr height="20">
  701. <td height="20"><strong>G</strong></td>
  702. <td>&nbsp;Grid On/Off</td>
  703. </tr>
  704. <tr height="20">
  705. <td height="20"><strong>J</strong></td>
  706. <td>&nbsp;Jump to Coordinates</td>
  707. </tr>
  708. <tr height="20">
  709. <td height="20"><strong>L</strong></td>
  710. <td>&nbsp;New Excellon</td>
  711. </tr>
  712. <tr height="20">
  713. <td height="20"><strong>M</strong></td>
  714. <td>&nbsp;Move Obj</td>
  715. </tr>
  716. <tr height="20">
  717. <td height="20"><strong>N</strong></td>
  718. <td>&nbsp;New Geometry</td>
  719. </tr>
  720. <tr height="20">
  721. <td height="20"><strong>O</strong></td>
  722. <td>&nbsp;Set Origin</td>
  723. </tr>
  724. <tr height="20">
  725. <td height="20"><strong>Q</strong></td>
  726. <td>&nbsp;Change Units</td>
  727. </tr>
  728. <tr height="20">
  729. <td height="20"><strong>P</strong></td>
  730. <td>&nbsp;Open Properties Tool</td>
  731. </tr>
  732. <tr height="20">
  733. <td height="20"><strong>R</strong></td>
  734. <td>&nbsp;Rotate by 90 degree CW</td>
  735. </tr>
  736. <tr height="20">
  737. <td height="20"><strong>S</strong></td>
  738. <td>&nbsp;Shell Toggle</td>
  739. </tr>
  740. <tr height="20">
  741. <td height="20"><strong>T</strong></td>
  742. <td>&nbsp;Add a Tool (when in Geometry Selected Tab or in Tools NCC or Tools Paint)</td>
  743. </tr>
  744. <tr height="20">
  745. <td height="20"><strong>V</strong></td>
  746. <td>&nbsp;Zoom Fit</td>
  747. </tr>
  748. <tr height="20">
  749. <td height="20"><strong>X</strong></td>
  750. <td>&nbsp;Flip on X_axis</td>
  751. </tr>
  752. <tr height="20">
  753. <td height="20"><strong>Y</strong></td>
  754. <td>&nbsp;Flip on Y_axis</td>
  755. </tr>
  756. <tr height="20">
  757. <td height="20"><strong>&#39;=&#39;</strong></td>
  758. <td>&nbsp;Zoom Out</td>
  759. </tr>
  760. <tr height="20">
  761. <td height="20"><strong>&#39;-&#39;</strong></td>
  762. <td>&nbsp;Zoom In</td>
  763. </tr>
  764. <tr height="20">
  765. <td height="20">&nbsp;</td>
  766. <td>&nbsp;</td>
  767. </tr>
  768. <tr height="20">
  769. <td height="20"><strong>CTRL+A</strong></td>
  770. <td>&nbsp;Select All</td>
  771. </tr>
  772. <tr height="20">
  773. <td height="20"><strong>CTRL+C</strong></td>
  774. <td>&nbsp;Copy Obj</td>
  775. </tr>
  776. <tr height="20">
  777. <td height="20"><strong>CTRL+E</strong></td>
  778. <td>&nbsp;Open Excellon File</td>
  779. </tr>
  780. <tr height="20">
  781. <td height="20"><strong>CTRL+G</strong></td>
  782. <td>&nbsp;Open Gerber File</td>
  783. </tr>
  784. <tr height="20">
  785. <td height="20"><strong>CTRL+N</strong></td>
  786. <td>&nbsp;New Project</td>
  787. </tr>
  788. <tr height="20">
  789. <td height="20"><strong>CTRL+M</strong></td>
  790. <td>&nbsp;Measurement Tool</td>
  791. </tr>
  792. <tr height="20">
  793. <td height="20"><strong>CTRL+O</strong></td>
  794. <td>&nbsp;Open Project</td>
  795. </tr>
  796. <tr height="20">
  797. <td height="20"><strong>CTRL+S</strong></td>
  798. <td>&nbsp;Save Project As</td>
  799. </tr>
  800. <tr height="20">
  801. <td height="20"><strong>CTRL+F10</strong></td>
  802. <td>&nbsp;Toggle Plot Area</td>
  803. </tr>
  804. <tr height="20">
  805. <td height="20">&nbsp;</td>
  806. <td>&nbsp;</td>
  807. </tr>
  808. <tr height="20">
  809. <td height="20"><strong>SHIFT+C</strong></td>
  810. <td>&nbsp;Copy Obj_Name</td>
  811. </tr>
  812. <tr height="20">
  813. <td height="20"><strong>SHIFT+G</strong></td>
  814. <td>&nbsp;Toggle the axis</td>
  815. </tr>
  816. <tr height="20">
  817. <td height="20"><strong>SHIFT+P</strong></td>
  818. <td>&nbsp;Open Preferences Window</td>
  819. </tr>
  820. <tr height="20">
  821. <td height="20"><strong>SHIFT+R</strong></td>
  822. <td>&nbsp;Rotate by 90 degree CCW</td>
  823. </tr>
  824. <tr height="20">
  825. <td height="20"><strong>SHIFT+S</strong></td>
  826. <td>&nbsp;Run a Script</td>
  827. </tr>
  828. <tr height="20">
  829. <td height="20"><strong>SHIFT+W</strong></td>
  830. <td>&nbsp;Toggle the workspace</td>
  831. </tr>
  832. <tr height="20">
  833. <td height="20"><strong>SHIFT+X</strong></td>
  834. <td>&nbsp;Skew on X axis</td>
  835. </tr>
  836. <tr height="20">
  837. <td height="20"><strong>SHIFT+Y</strong></td>
  838. <td>&nbsp;Skew on Y axis</td>
  839. </tr>
  840. <tr height="20">
  841. <td height="20">&nbsp;</td>
  842. <td>&nbsp;</td>
  843. </tr>
  844. <tr height="20">
  845. <td height="20"><strong>ALT+C</strong></td>
  846. <td>&nbsp;Calculators Tool</td>
  847. </tr>
  848. <tr height="20">
  849. <td height="20"><strong>ALT+D</strong></td>
  850. <td>&nbsp;2-Sided PCB Tool</td>
  851. </tr>
  852. <tr height="20">
  853. <td height="20"><strong>ALT+L</strong></td>
  854. <td>&nbsp;Film PCB Tool</td>
  855. </tr>
  856. <tr height="20">
  857. <td height="20"><strong>ALT+N</strong></td>
  858. <td>&nbsp;Non-Copper Clearing Tool</td>
  859. </tr>
  860. <tr height="20">
  861. <td height="20"><strong>ALT+P</strong></td>
  862. <td>&nbsp;Paint Area Tool</td>
  863. </tr>
  864. <tr height="20">
  865. <td height="20"><strong>ALT+R</strong></td>
  866. <td>&nbsp;Transformations Tool</td>
  867. </tr>
  868. <tr height="20">
  869. <td height="20"><strong>ALT+S</strong></td>
  870. <td>&nbsp;View File Source</td>
  871. </tr>
  872. <tr height="20">
  873. <td height="20"><strong>ALT+U</strong></td>
  874. <td>&nbsp;Cutout PCB Tool</td>
  875. </tr>
  876. <tr height="20">
  877. <td height="20"><strong>ALT+1</strong></td>
  878. <td>&nbsp;Enable all Plots</td>
  879. </tr>
  880. <tr height="20">
  881. <td height="20"><strong>ALT+2</strong></td>
  882. <td>&nbsp;Disable all Plots</td>
  883. </tr>
  884. <tr height="20">
  885. <td height="20"><strong>ALT+3</strong></td>
  886. <td>&nbsp;Disable Non-selected Plots</td>
  887. </tr>
  888. <tr height="20">
  889. <td height="20"><strong>ALT+F10</strong></td>
  890. <td>&nbsp;Toggle Full Screen</td>
  891. </tr>
  892. <tr height="20">
  893. <td height="20">&nbsp;</td>
  894. <td>&nbsp;</td>
  895. </tr>
  896. <tr height="20">
  897. <td height="20"><strong>F1</strong></td>
  898. <td>&nbsp;Open Online Manual</td>
  899. </tr>
  900. <tr height="20">
  901. <td height="20"><strong>F2</strong></td>
  902. <td>&nbsp;Open Online Tutorials</td>
  903. </tr>
  904. <tr height="20">
  905. <td height="20"><strong>Del</strong></td>
  906. <td>&nbsp;Delete Object</td>
  907. </tr>
  908. <tr height="20">
  909. <td height="20"><strong>Del</strong></td>
  910. <td>&nbsp;Alternate: Delete Tool</td>
  911. </tr>
  912. <tr height="20">
  913. <td height="20"><strong>'`'</strong></td>
  914. <td>&nbsp;(left to Key_1)Toogle Notebook Area (Left Side)</td>
  915. </tr>
  916. <tr height="20">
  917. <td height="20"><strong>SPACE</strong></td>
  918. <td>&nbsp;En(Dis)able Obj Plot</td>
  919. </tr>
  920. <tr height="20">
  921. <td height="20"><strong>Escape</strong></td>
  922. <td>&nbsp;Deselects all objects</td>
  923. </tr>
  924. </tbody>
  925. </table>
  926. '''
  927. self.sh_app = QtWidgets.QTextEdit()
  928. self.sh_app.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  929. self.sh_app.setText(self.app_sh_msg)
  930. self.sh_app.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  931. self.sh_hlay.addWidget(self.sh_app)
  932. self.editor_sh_msg = '''<b>Editor Shortcut list</b><br>
  933. <br>
  934. <strong><span style="color:#0000ff">GEOMETRY EDITOR</span></strong><br>
  935. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  936. <tbody>
  937. <tr height="20">
  938. <td height="20" width="89"><strong>A</strong></td>
  939. <td width="194">&nbsp;Draw an Arc</td>
  940. </tr>
  941. <tr height="20">
  942. <td height="20"><strong>B</strong></td>
  943. <td>&nbsp;Buffer Tool</td>
  944. </tr>
  945. <tr height="20">
  946. <td height="20"><strong>C</strong></td>
  947. <td>&nbsp;Copy Geo Item</td>
  948. </tr>
  949. <tr height="20">
  950. <td height="20"><strong>E</strong></td>
  951. <td>&nbsp;Polygon Intersection Tool</td>
  952. </tr>
  953. <tr height="20">
  954. <td height="20"><strong>I</strong></td>
  955. <td>&nbsp;Paint Tool</td>
  956. </tr>
  957. <tr height="20">
  958. <td height="20"><strong>J</strong></td>
  959. <td>&nbsp;Jump to Location (x, y)</td>
  960. </tr>
  961. <tr height="20">
  962. <td height="20"><strong>K</strong></td>
  963. <td>&nbsp;Toggle Corner Snap</td>
  964. </tr>
  965. <tr height="20">
  966. <td height="20"><strong>M</strong></td>
  967. <td>&nbsp;Move Geo Item</td>
  968. </tr>
  969. <tr height="20">
  970. <td height="20"><strong>N</strong></td>
  971. <td>&nbsp;Draw a Polygon</td>
  972. </tr>
  973. <tr height="20">
  974. <td height="20"><strong>O</strong></td>
  975. <td>&nbsp;Draw a Circle</td>
  976. </tr>
  977. <tr height="20">
  978. <td height="20"><strong>P</strong></td>
  979. <td>&nbsp;Draw a Path</td>
  980. </tr>
  981. <tr height="20">
  982. <td height="20"><strong>R</strong></td>
  983. <td>&nbsp;Draw Rectangle</td>
  984. </tr>
  985. <tr height="20">
  986. <td height="20"><strong>S</strong></td>
  987. <td>&nbsp;Polygon Substraction Tool</td>
  988. </tr>
  989. <tr height="20">
  990. <td height="20"><strong>T</strong></td>
  991. <td>&nbsp;Add Text Tool</td>
  992. </tr>
  993. <tr height="20">
  994. <td height="20"><strong>U</strong></td>
  995. <td>&nbsp;Polygon Union Tool</td>
  996. </tr>
  997. <tr height="20">
  998. <td height="20"><strong>X</strong></td>
  999. <td>&nbsp;Polygon Cut Tool</td>
  1000. </tr>
  1001. <tr height="20">
  1002. <td height="20">&nbsp;</td>
  1003. <td>&nbsp;</td>
  1004. </tr>
  1005. <tr height="20">
  1006. <td height="20"><strong>CTRL+S</strong></td>
  1007. <td>&nbsp;Save Object and Exit Editor</td>
  1008. </tr>
  1009. <tr height="20">
  1010. <td height="20">&nbsp;</td>
  1011. <td>&nbsp;</td>
  1012. </tr>
  1013. <tr height="20">
  1014. <td height="20"><strong>Space</strong></td>
  1015. <td>&nbsp;Rotate Geometry</td>
  1016. </tr>
  1017. <tr height="20">
  1018. <td height="20"><strong>ENTER</strong></td>
  1019. <td>&nbsp;Finish drawing for certain tools</td>
  1020. </tr>
  1021. <tr height="20">
  1022. <td height="20"><strong>ESC</strong></td>
  1023. <td>&nbsp;Abort and return to Select</td>
  1024. </tr>
  1025. <tr height="20">
  1026. <td height="20"><strong>Del</strong></td>
  1027. <td>&nbsp;Delete Shape</td>
  1028. </tr>
  1029. </tbody>
  1030. </table>
  1031. <br>
  1032. <br>
  1033. <strong><span style="color:#ff0000">EXCELLON EDITOR</span></strong><br>
  1034. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1035. <tbody>
  1036. <tr height="20">
  1037. <td height="20" width="89"><strong>A</strong></td>
  1038. <td width="194">&nbsp;Add Drill Array</td>
  1039. </tr>
  1040. <tr height="20">
  1041. <td height="20"><strong>C</strong></td>
  1042. <td>&nbsp;Copy Drill(s)</td>
  1043. </tr>
  1044. <tr height="20">
  1045. <td height="20"><strong>D</strong></td>
  1046. <td>&nbsp;Add Drill</td>
  1047. </tr>
  1048. <tr height="20">
  1049. <td height="20"><strong>J</strong></td>
  1050. <td>&nbsp;Jump to Location (x, y)</td>
  1051. </tr>
  1052. <tr height="20">
  1053. <td height="20"><strong>M</strong></td>
  1054. <td>&nbsp;Move Drill(s)</td>
  1055. </tr>
  1056. <tr height="20">
  1057. <td height="20"><strong>R</strong></td>
  1058. <td>&nbsp;Resize Drill(s)</td>
  1059. </tr>
  1060. <tr height="20">
  1061. <td height="20"><strong>T</strong></td>
  1062. <td>&nbsp;Add a new Tool</td>
  1063. </tr>
  1064. <tr height="20">
  1065. <td height="20">&nbsp;</td>
  1066. <td>&nbsp;</td>
  1067. </tr>
  1068. <tr height="20">
  1069. <td height="20"><strong>Del</strong></td>
  1070. <td>&nbsp;Delete Drill(s)</td>
  1071. </tr>
  1072. <tr height="20">
  1073. <td height="20"><strong>Del</strong></td>
  1074. <td>&nbsp;Alternate: Delete Tool(s)</td>
  1075. </tr>
  1076. <tr height="20">
  1077. <td height="20">&nbsp;</td>
  1078. <td>&nbsp;</td>
  1079. </tr>
  1080. <tr height="20">
  1081. <td height="20"><strong>ESC</strong></td>
  1082. <td>&nbsp;Abort and return to Select</td>
  1083. </tr>
  1084. <tr height="20">
  1085. <td height="20"><strong>CTRL+S</strong></td>
  1086. <td>&nbsp;Save Object and Exit Editor</td>
  1087. </tr>
  1088. </tbody>
  1089. </table>
  1090. '''
  1091. self.sh_editor = QtWidgets.QTextEdit()
  1092. self.sh_editor.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1093. self.sh_editor.setText(self.editor_sh_msg)
  1094. self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  1095. self.sh_hlay.addWidget(self.sh_editor)
  1096. ##############################################################
  1097. ### HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS ###
  1098. ##############################################################
  1099. self.popMenu = QtWidgets.QMenu()
  1100. self.popmenu_disable = self.popMenu.addAction(QtGui.QIcon('share/clear_plot32.png'), "Disable")
  1101. self.popMenu.addSeparator()
  1102. self.cmenu_newmenu = self.popMenu.addMenu(QtGui.QIcon('share/file32.png'), "New")
  1103. self.popmenu_new_geo = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "Geometry")
  1104. self.popmenu_new_exc = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_exc32.png'), "Excellon")
  1105. self.cmenu_newmenu.addSeparator()
  1106. self.popmenu_new_prj = self.cmenu_newmenu.addAction(QtGui.QIcon('share/file16.png'), "Project")
  1107. self.popMenu.addSeparator()
  1108. self.cmenu_gridmenu = self.popMenu.addMenu(QtGui.QIcon('share/grid32_menu.png'), "Grids")
  1109. self.cmenu_viewmenu = self.popMenu.addMenu(QtGui.QIcon('share/view64.png'), "View")
  1110. self.zoomfit = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
  1111. self.clearplot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/clear_plot32.png'), "Clear Plot")
  1112. self.replot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/replot32.png'), "Replot")
  1113. self.popMenu.addSeparator()
  1114. self.g_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/draw32.png'), "Geo Editor")
  1115. self.draw_line = self.g_editor_cmenu.addAction(QtGui.QIcon('share/path32.png'), "Line")
  1116. self.draw_rect = self.g_editor_cmenu.addAction(QtGui.QIcon('share/rectangle32.png'), "Rectangle")
  1117. self.draw_cut = self.g_editor_cmenu.addAction(QtGui.QIcon('share/cutpath32.png'), "Cut")
  1118. self.g_editor_cmenu.addSeparator()
  1119. self.draw_move = self.g_editor_cmenu.addAction(QtGui.QIcon('share/move32.png'), "Move")
  1120. self.e_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/drill32.png'), "Exc Editor")
  1121. self.drill = self.e_editor_cmenu.addAction(QtGui.QIcon('share/drill32.png'), "Add Drill")
  1122. self.drill_array = self.e_editor_cmenu.addAction(QtGui.QIcon('share/addarray32.png'), "Add Drill Array")
  1123. self.drill_copy = self.e_editor_cmenu.addAction(QtGui.QIcon('share/copy32.png'), "Copy Drill(s)")
  1124. self.popMenu.addSeparator()
  1125. self.popmenu_copy = self.popMenu.addAction(QtGui.QIcon('share/copy32.png'), "Copy")
  1126. self.popmenu_delete = self.popMenu.addAction(QtGui.QIcon('share/delete32.png'), "Delete")
  1127. self.popmenu_edit = self.popMenu.addAction(QtGui.QIcon('share/edit32.png'), "Edit")
  1128. self.popmenu_save = self.popMenu.addAction(QtGui.QIcon('share/floppy32.png'), "Save && Close Edit")
  1129. self.popmenu_save.setVisible(False)
  1130. self.popMenu.addSeparator()
  1131. self.popmenu_move = self.popMenu.addAction(QtGui.QIcon('share/move32.png'), "Move")
  1132. self.popmenu_properties = self.popMenu.addAction(QtGui.QIcon('share/properties32.png'), "Properties")
  1133. ####################################
  1134. ### Here we build the CNCJob Tab ###
  1135. ####################################
  1136. self.cncjob_tab = QtWidgets.QWidget()
  1137. self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_tab)
  1138. self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
  1139. self.cncjob_tab.setLayout(self.cncjob_tab_layout)
  1140. self.code_editor = QtWidgets.QTextEdit()
  1141. stylesheet = """
  1142. QTextEdit { selection-background-color:yellow;
  1143. selection-color:black;
  1144. }
  1145. """
  1146. self.code_editor.setStyleSheet(stylesheet)
  1147. self.buttonPreview = QtWidgets.QPushButton('Print Preview')
  1148. self.buttonPrint = QtWidgets.QPushButton('Print Code')
  1149. self.buttonFind = QtWidgets.QPushButton('Find in Code')
  1150. self.buttonFind.setFixedWidth(100)
  1151. self.buttonPreview.setFixedWidth(100)
  1152. self.entryFind = FCEntry()
  1153. self.entryFind.setMaximumWidth(200)
  1154. self.buttonReplace = QtWidgets.QPushButton('Replace With')
  1155. self.buttonReplace.setFixedWidth(100)
  1156. self.entryReplace = FCEntry()
  1157. self.entryReplace.setMaximumWidth(200)
  1158. self.sel_all_cb = QtWidgets.QCheckBox('All')
  1159. self.sel_all_cb.setToolTip(
  1160. "When checked it will replace all instances in the 'Find' box\n"
  1161. "with the text in the 'Replace' box.."
  1162. )
  1163. self.buttonOpen = QtWidgets.QPushButton('Open Code')
  1164. self.buttonSave = QtWidgets.QPushButton('Save Code')
  1165. self.cncjob_tab_layout.addWidget(self.code_editor, 0, 0, 1, 5)
  1166. cnc_tab_lay_1 = QtWidgets.QHBoxLayout()
  1167. cnc_tab_lay_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1168. cnc_tab_lay_1.addWidget(self.buttonFind)
  1169. cnc_tab_lay_1.addWidget(self.entryFind)
  1170. cnc_tab_lay_1.addWidget(self.buttonReplace)
  1171. cnc_tab_lay_1.addWidget(self.entryReplace)
  1172. cnc_tab_lay_1.addWidget(self.sel_all_cb)
  1173. self.cncjob_tab_layout.addLayout(cnc_tab_lay_1, 1, 0, 1, 1, QtCore.Qt.AlignLeft)
  1174. cnc_tab_lay_3 = QtWidgets.QHBoxLayout()
  1175. cnc_tab_lay_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1176. cnc_tab_lay_3.addWidget(self.buttonPreview)
  1177. cnc_tab_lay_3.addWidget(self.buttonPrint)
  1178. self.cncjob_tab_layout.addLayout(cnc_tab_lay_3, 2, 0, 1, 1, QtCore.Qt.AlignLeft)
  1179. cnc_tab_lay_4 = QtWidgets.QHBoxLayout()
  1180. cnc_tab_lay_4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  1181. cnc_tab_lay_4.addWidget(self.buttonOpen)
  1182. cnc_tab_lay_4.addWidget(self.buttonSave)
  1183. self.cncjob_tab_layout.addLayout(cnc_tab_lay_4, 2, 4, 1, 1)
  1184. ##################################
  1185. ### Build InfoBar is done here ###
  1186. ##################################
  1187. self.infobar = self.statusBar()
  1188. self.fcinfo = FlatCAMInfoBar()
  1189. self.infobar.addWidget(self.fcinfo, stretch=1)
  1190. self.rel_position_label = QtWidgets.QLabel(
  1191. "<b>Dx</b>: 0.0000&nbsp;&nbsp; <b>Dy</b>: 0.0000&nbsp;&nbsp;&nbsp;&nbsp;")
  1192. self.rel_position_label.setMinimumWidth(110)
  1193. self.rel_position_label.setToolTip("Relative neasurement.\nReference is last click position")
  1194. self.infobar.addWidget(self.rel_position_label)
  1195. self.position_label = QtWidgets.QLabel(
  1196. "&nbsp;&nbsp;&nbsp;&nbsp;<b>X</b>: 0.0000&nbsp;&nbsp; <b>Y</b>: 0.0000")
  1197. self.position_label.setMinimumWidth(110)
  1198. self.position_label.setToolTip("Absolute neasurement.\nReference is (X=0, Y= 0) position")
  1199. self.infobar.addWidget(self.position_label)
  1200. self.units_label = QtWidgets.QLabel("[in]")
  1201. self.units_label.setMargin(2)
  1202. self.infobar.addWidget(self.units_label)
  1203. # disabled
  1204. self.progress_bar = QtWidgets.QProgressBar()
  1205. self.progress_bar.setMinimum(0)
  1206. self.progress_bar.setMaximum(100)
  1207. # infobar.addWidget(self.progress_bar)
  1208. self.activity_view = FlatCAMActivityView()
  1209. self.infobar.addWidget(self.activity_view)
  1210. self.app_icon = QtGui.QIcon()
  1211. self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16))
  1212. self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24))
  1213. self.app_icon.addFile('share/flatcam_icon32.png', QtCore.QSize(32, 32))
  1214. self.app_icon.addFile('share/flatcam_icon48.png', QtCore.QSize(48, 48))
  1215. self.app_icon.addFile('share/flatcam_icon128.png', QtCore.QSize(128, 128))
  1216. self.app_icon.addFile('share/flatcam_icon256.png', QtCore.QSize(256, 256))
  1217. self.setWindowIcon(self.app_icon)
  1218. self.setGeometry(100, 100, 1024, 650)
  1219. self.setWindowTitle('FlatCAM %s %s - %s' % (version, ('BETA' if beta else ''), platform.architecture()[0]))
  1220. self.show()
  1221. self.filename = ""
  1222. self.setAcceptDrops(True)
  1223. # # restore the Toolbar State from file
  1224. # try:
  1225. # with open(self.app.data_path + '\gui_state.config', 'rb') as stream:
  1226. # self.restoreState(QtCore.QByteArray(stream.read()))
  1227. # log.debug("FlatCAMGUI.__init__() --> UI state restored.")
  1228. # except IOError:
  1229. # log.debug("FlatCAMGUI.__init__() --> UI state not restored. IOError")
  1230. # pass
  1231. ######################
  1232. ### INITIALIZE GUI ###
  1233. ######################
  1234. self.grid_snap_btn.setCheckable(True)
  1235. self.corner_snap_btn.setCheckable(True)
  1236. self.update_obj_btn.setEnabled(False)
  1237. # start with GRID activated
  1238. self.grid_snap_btn.trigger()
  1239. self.g_editor_cmenu.setEnabled(False)
  1240. self.e_editor_cmenu.setEnabled(False)
  1241. # restore the Toolbar State from file
  1242. settings = QSettings("Open Source", "FlatCAM")
  1243. if settings.contains("saved_gui_state"):
  1244. saved_gui_state = settings.value('saved_gui_state')
  1245. self.restoreState(saved_gui_state)
  1246. log.debug("FlatCAMGUI.__init__() --> UI state restored.")
  1247. if settings.contains("layout"):
  1248. layout = settings.value('layout', type=str)
  1249. if layout == 'standard':
  1250. self.exc_edit_toolbar.setVisible(False)
  1251. self.exc_edit_toolbar.setDisabled(True)
  1252. self.geo_edit_toolbar.setVisible(False)
  1253. self.geo_edit_toolbar.setDisabled(True)
  1254. self.corner_snap_btn.setVisible(False)
  1255. self.snap_magnet.setVisible(False)
  1256. elif layout == 'compact':
  1257. self.exc_edit_toolbar.setDisabled(True)
  1258. self.geo_edit_toolbar.setDisabled(True)
  1259. self.snap_magnet.setVisible(True)
  1260. self.corner_snap_btn.setVisible(True)
  1261. self.snap_magnet.setDisabled(True)
  1262. self.corner_snap_btn.setDisabled(True)
  1263. else:
  1264. self.exc_edit_toolbar.setVisible(False)
  1265. self.exc_edit_toolbar.setDisabled(True)
  1266. self.geo_edit_toolbar.setVisible(False)
  1267. self.geo_edit_toolbar.setDisabled(True)
  1268. self.corner_snap_btn.setVisible(False)
  1269. self.snap_magnet.setVisible(False)
  1270. def populate_toolbars(self):
  1271. ### File Toolbar ###
  1272. self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
  1273. "Open GERBER")
  1274. self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), "Open EXCELLON")
  1275. self.toolbarfile.addSeparator()
  1276. self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), "Open project")
  1277. self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), "Save project")
  1278. ### Edit Toolbar ###
  1279. self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "New Blank Geometry")
  1280. self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), "New Blank Excellon")
  1281. self.toolbargeo.addSeparator()
  1282. self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), "Editor")
  1283. self.update_obj_btn = self.toolbargeo.addAction(
  1284. QtGui.QIcon('share/edit_ok32_bis.png'), "Save Object and close the Editor"
  1285. )
  1286. self.toolbargeo.addSeparator()
  1287. self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), "&Delete")
  1288. ### View Toolbar ###
  1289. self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), "&Replot")
  1290. self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), "&Clear plot")
  1291. self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), "Zoom In")
  1292. self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), "Zoom Out")
  1293. self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
  1294. # self.toolbarview.setVisible(False)
  1295. ### Tools Toolbar ###
  1296. self.shell_btn = self.toolbartools.addAction(QtGui.QIcon('share/shell32.png'), "&Command Line")
  1297. ### Drill Editor Toolbar ###
  1298. self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
  1299. self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), 'Add Drill Hole')
  1300. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  1301. QtGui.QIcon('share/addarray16.png'), 'Add Drill Hole Array')
  1302. self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), 'Resize Drill')
  1303. self.exc_edit_toolbar.addSeparator()
  1304. self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), 'Copy Drill')
  1305. self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Drill")
  1306. self.exc_edit_toolbar.addSeparator()
  1307. self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Drill")
  1308. ### Geometry Editor Toolbar ###
  1309. self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
  1310. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), 'Add Circle')
  1311. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), 'Add Arc')
  1312. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'), 'Add Rectangle')
  1313. self.geo_edit_toolbar.addSeparator()
  1314. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), 'Add Path')
  1315. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), 'Add Polygon')
  1316. self.geo_edit_toolbar.addSeparator()
  1317. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), 'Add Text')
  1318. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), 'Add Buffer')
  1319. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), 'Paint Shape')
  1320. self.geo_edit_toolbar.addSeparator()
  1321. self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), 'Polygon Union')
  1322. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
  1323. 'Polygon Intersection')
  1324. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'), 'Polygon Subtraction')
  1325. self.geo_edit_toolbar.addSeparator()
  1326. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), 'Cut Path')
  1327. self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), "Copy Objects 'c'")
  1328. self.geo_rotate_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rotate.png'), "Rotate Objects 'Space'")
  1329. self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Shape '-'")
  1330. self.geo_edit_toolbar.addSeparator()
  1331. self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Objects 'm'")
  1332. ### Snap Toolbar ###
  1333. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  1334. # self.addToolBar(self.snap_toolbar)
  1335. self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), 'Snap to grid')
  1336. self.grid_gap_x_entry = FCEntry2()
  1337. self.grid_gap_x_entry.setMaximumWidth(70)
  1338. self.grid_gap_x_entry.setToolTip("Grid X distance")
  1339. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  1340. self.grid_gap_y_entry = FCEntry2()
  1341. self.grid_gap_y_entry.setMaximumWidth(70)
  1342. self.grid_gap_y_entry.setToolTip("Grid Y distance")
  1343. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  1344. self.grid_space_label = QtWidgets.QLabel(" ")
  1345. self.snap_toolbar.addWidget(self.grid_space_label)
  1346. self.grid_gap_link_cb = FCCheckBox()
  1347. self.grid_gap_link_cb.setToolTip("When active, value on Grid_X\n"
  1348. "is copied to the Grid_Y value.")
  1349. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  1350. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  1351. self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), 'Snap to corner')
  1352. self.snap_max_dist_entry = FCEntry()
  1353. self.snap_max_dist_entry.setMaximumWidth(70)
  1354. self.snap_max_dist_entry.setToolTip("Max. magnet distance")
  1355. self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  1356. self.grid_snap_btn.setCheckable(True)
  1357. self.corner_snap_btn.setCheckable(True)
  1358. self.update_obj_btn.setEnabled(False)
  1359. # start with GRID activated
  1360. self.grid_snap_btn.trigger()
  1361. settings = QSettings("Open Source", "FlatCAM")
  1362. if settings.contains("layout"):
  1363. layout = settings.value('layout', type=str)
  1364. if layout == 'standard':
  1365. self.exc_edit_toolbar.setVisible(False)
  1366. self.exc_edit_toolbar.setDisabled(True)
  1367. self.geo_edit_toolbar.setVisible(False)
  1368. self.geo_edit_toolbar.setDisabled(True)
  1369. self.corner_snap_btn.setVisible(False)
  1370. self.snap_magnet.setVisible(False)
  1371. elif layout == 'compact':
  1372. self.exc_edit_toolbar.setVisible(True)
  1373. self.exc_edit_toolbar.setDisabled(True)
  1374. self.geo_edit_toolbar.setVisible(True)
  1375. self.geo_edit_toolbar.setDisabled(True)
  1376. self.corner_snap_btn.setVisible(True)
  1377. self.snap_magnet.setVisible(True)
  1378. self.corner_snap_btn.setDisabled(True)
  1379. self.snap_magnet.setDisabled(True)
  1380. def keyPressEvent(self, event):
  1381. modifiers = QtWidgets.QApplication.keyboardModifiers()
  1382. active = self.app.collection.get_active()
  1383. selected = self.app.collection.get_selected()
  1384. # events out of the self.app.collection view (it's about Project Tab) are of type int
  1385. if type(event) is int:
  1386. key = event
  1387. # events from the GUI are of type QKeyEvent
  1388. elif type(event) == QtGui.QKeyEvent:
  1389. key = event.key()
  1390. # events from Vispy are of type KeyEvent
  1391. else:
  1392. key = event.key
  1393. if self.app.call_source == 'app':
  1394. if modifiers == QtCore.Qt.ControlModifier:
  1395. if key == QtCore.Qt.Key_A:
  1396. self.app.on_selectall()
  1397. if key == QtCore.Qt.Key_C:
  1398. self.app.on_copy_object()
  1399. if key == QtCore.Qt.Key_E:
  1400. self.app.on_fileopenexcellon()
  1401. if key == QtCore.Qt.Key_G:
  1402. self.app.on_fileopengerber()
  1403. if key == QtCore.Qt.Key_N:
  1404. self.app.on_file_new_click()
  1405. if key == QtCore.Qt.Key_M:
  1406. self.app.measurement_tool.run()
  1407. if key == QtCore.Qt.Key_O:
  1408. self.app.on_file_openproject()
  1409. if key == QtCore.Qt.Key_S:
  1410. self.app.on_file_saveproject()
  1411. # Toggle Plot Area
  1412. if key == QtCore.Qt.Key_F10 or key == 'F10':
  1413. self.app.on_toggle_plotarea()
  1414. return
  1415. elif modifiers == QtCore.Qt.ShiftModifier:
  1416. # Copy Object Name
  1417. # Copy Object Name
  1418. if key == QtCore.Qt.Key_C:
  1419. self.app.on_copy_name()
  1420. # Toggle axis
  1421. if key == QtCore.Qt.Key_G:
  1422. if self.app.toggle_axis is False:
  1423. self.app.plotcanvas.v_line.set_data(color=(0.70, 0.3, 0.3, 1.0))
  1424. self.app.plotcanvas.h_line.set_data(color=(0.70, 0.3, 0.3, 1.0))
  1425. self.app.plotcanvas.redraw()
  1426. self.app.toggle_axis = True
  1427. else:
  1428. self.app.plotcanvas.v_line.set_data(color=(0.0, 0.0, 0.0, 0.0))
  1429. self.app.plotcanvas.h_line.set_data(color=(0.0, 0.0, 0.0, 0.0))
  1430. self.app.plotcanvas.redraw()
  1431. self.app.toggle_axis = False
  1432. # Open Preferences Window
  1433. if key == QtCore.Qt.Key_P:
  1434. self.app.on_preferences()
  1435. return
  1436. # Rotate Object by 90 degree CCW
  1437. if key == QtCore.Qt.Key_R:
  1438. self.app.on_rotate(silent=True, preset=-90)
  1439. return
  1440. # Run a Script
  1441. if key == QtCore.Qt.Key_S:
  1442. self.app.on_filerunscript()
  1443. return
  1444. # Toggle Workspace
  1445. if key == QtCore.Qt.Key_W:
  1446. self.app.on_workspace_menu()
  1447. return
  1448. # Skew on X axis
  1449. if key == QtCore.Qt.Key_X:
  1450. self.app.on_skewx()
  1451. return
  1452. # Skew on Y axis
  1453. if key == QtCore.Qt.Key_Y:
  1454. self.app.on_skewy()
  1455. return
  1456. elif modifiers == QtCore.Qt.AltModifier:
  1457. # Eanble all plots
  1458. if key == Qt.Key_1:
  1459. self.app.enable_all_plots()
  1460. # Disable all plots
  1461. if key == Qt.Key_2:
  1462. self.app.disable_all_plots()
  1463. # Disable all other plots
  1464. if key == Qt.Key_3:
  1465. self.app.disable_other_plots()
  1466. # Calculator Tool
  1467. if key == QtCore.Qt.Key_C:
  1468. self.app.calculator_tool.run()
  1469. # 2-Sided PCB Tool
  1470. if key == QtCore.Qt.Key_D:
  1471. self.app.dblsidedtool.run()
  1472. return
  1473. # Film Tool
  1474. if key == QtCore.Qt.Key_L:
  1475. self.app.film_tool.run()
  1476. return
  1477. # Non-Copper Clear Tool
  1478. if key == QtCore.Qt.Key_N:
  1479. self.app.ncclear_tool.run()
  1480. return
  1481. # Paint Tool
  1482. if key == QtCore.Qt.Key_P:
  1483. self.app.paint_tool.run()
  1484. return
  1485. # Transformation Tool
  1486. if key == QtCore.Qt.Key_R:
  1487. self.app.transform_tool.run()
  1488. return
  1489. # Transformation Tool
  1490. if key == QtCore.Qt.Key_S:
  1491. self.app.on_view_source()
  1492. return
  1493. # Cutout Tool
  1494. if key == QtCore.Qt.Key_U:
  1495. self.app.cutout_tool.run()
  1496. return
  1497. # Panelize Tool
  1498. if key == QtCore.Qt.Key_Z:
  1499. self.app.panelize_tool.run()
  1500. return
  1501. # Toggle Fullscreen
  1502. if key == QtCore.Qt.Key_F10 or key == 'F10':
  1503. self.app.on_fullscreen()
  1504. return
  1505. elif modifiers == QtCore.Qt.NoModifier:
  1506. # Open Manual
  1507. if key == QtCore.Qt.Key_F1 or key == 'F1':
  1508. webbrowser.open(self.app.manual_url)
  1509. # Open Video Help
  1510. if key == QtCore.Qt.Key_F2 or key == 'F2':
  1511. webbrowser.open(self.app.video_url)
  1512. # Show shortcut list
  1513. if key == QtCore.Qt.Key_F3 or key == 'F3':
  1514. self.app.on_shortcut_list()
  1515. # Switch to Project Tab
  1516. if key == QtCore.Qt.Key_1:
  1517. self.app.on_select_tab('project')
  1518. # Switch to Selected Tab
  1519. if key == QtCore.Qt.Key_2:
  1520. self.app.on_select_tab('selected')
  1521. # Switch to Tool Tab
  1522. if key == QtCore.Qt.Key_3:
  1523. self.app.on_select_tab('tool')
  1524. # Delete from PyQt
  1525. # It's meant to make a difference between delete objects and delete tools in
  1526. # Geometry Selected tool table
  1527. if key == QtCore.Qt.Key_Delete:
  1528. self.app.on_delete_keypress()
  1529. # Delete from canvas
  1530. if key == 'Delete':
  1531. # Delete via the application to
  1532. # ensure cleanup of the GUI
  1533. if active:
  1534. active.app.on_delete()
  1535. # Escape = Deselect All
  1536. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  1537. self.app.on_deselect_all()
  1538. self.app.inform.emit("")
  1539. # Space = Toggle Active/Inactive
  1540. if key == QtCore.Qt.Key_Space:
  1541. for select in selected:
  1542. select.ui.plot_cb.toggle()
  1543. self.app.delete_selection_shape()
  1544. # Copy Object Name
  1545. if key == QtCore.Qt.Key_E:
  1546. self.app.object2editor()
  1547. # Grid toggle
  1548. if key == QtCore.Qt.Key_G:
  1549. self.app.ui.grid_snap_btn.trigger()
  1550. # Jump to coords
  1551. if key == QtCore.Qt.Key_J:
  1552. self.app.on_jump_to()
  1553. # New Excellon
  1554. if key == QtCore.Qt.Key_L:
  1555. self.app.new_excellon_object()
  1556. # Move tool toggle
  1557. if key == QtCore.Qt.Key_M:
  1558. self.app.move_tool.toggle()
  1559. # New Geometry
  1560. if key == QtCore.Qt.Key_N:
  1561. self.app.new_geometry_object()
  1562. # Set Origin
  1563. if key == QtCore.Qt.Key_O:
  1564. self.app.on_set_origin()
  1565. return
  1566. # Set Origin
  1567. if key == QtCore.Qt.Key_P:
  1568. self.app.properties_tool.run()
  1569. return
  1570. # Change Units
  1571. if key == QtCore.Qt.Key_Q:
  1572. if self.app.options["units"] == 'MM':
  1573. self.app.general_options_form.general_app_group.units_radio.set_value("IN")
  1574. else:
  1575. self.app.general_options_form.general_app_group.units_radio.set_value("MM")
  1576. self.app.on_toggle_units()
  1577. # Rotate Object by 90 degree CW
  1578. if key == QtCore.Qt.Key_R:
  1579. self.app.on_rotate(silent=True, preset=90)
  1580. # Shell toggle
  1581. if key == QtCore.Qt.Key_S:
  1582. self.app.on_toggle_shell()
  1583. # Add a Tool from shortcut
  1584. if key == QtCore.Qt.Key_T:
  1585. self.app.on_tool_add_keypress()
  1586. # Zoom Fit
  1587. if key == QtCore.Qt.Key_V:
  1588. self.app.on_zoom_fit(None)
  1589. # Mirror on X the selected object(s)
  1590. if key == QtCore.Qt.Key_X:
  1591. self.app.on_flipx()
  1592. # Mirror on Y the selected object(s)
  1593. if key == QtCore.Qt.Key_Y:
  1594. self.app.on_flipy()
  1595. # Zoom In
  1596. if key == QtCore.Qt.Key_Equal:
  1597. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'], self.app.mouse)
  1598. # Zoom Out
  1599. if key == QtCore.Qt.Key_Minus:
  1600. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'], self.app.mouse)
  1601. # toggle display of Notebook area
  1602. if key == QtCore.Qt.Key_QuoteLeft:
  1603. self.app.on_toggle_notebook()
  1604. return
  1605. elif self.app.call_source == 'geo_editor':
  1606. if modifiers == QtCore.Qt.ControlModifier:
  1607. # save (update) the current geometry and return to the App
  1608. if key == QtCore.Qt.Key_S or key == 'S':
  1609. self.app.editor2object()
  1610. return
  1611. # toggle the measurement tool
  1612. if key == QtCore.Qt.Key_M or key == 'M':
  1613. self.app.measurement_tool.run()
  1614. return
  1615. elif modifiers == QtCore.Qt.ShiftModifier:
  1616. pass
  1617. elif modifiers == QtCore.Qt.AltModifier:
  1618. pass
  1619. elif modifiers == QtCore.Qt.NoModifier:
  1620. # toggle display of Notebook area
  1621. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  1622. self.app.on_toggle_notebook()
  1623. # Finish the current action. Use with tools that do not
  1624. # complete automatically, like a polygon or path.
  1625. if key == QtCore.Qt.Key_Enter or key == 'Enter':
  1626. if isinstance(self.app.geo_editor.active_tool, FCShapeTool):
  1627. if self.app.geo_editor.active_tool.name == 'fc_rotate':
  1628. self.app.geo_editor.active_tool.make()
  1629. if self.app.geo_editor.active_tool.complete:
  1630. self.app.geo_editor.on_shape_complete()
  1631. self.app.inform.emit("[success]Done.")
  1632. # automatically make the selection tool active after completing current action
  1633. self.app.geo_editor.select_tool('select')
  1634. return
  1635. else:
  1636. self.app.geo_editor.active_tool.click(
  1637. self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
  1638. self.app.geo_editor.active_tool.make()
  1639. if self.app.geo_editor.active_tool.complete:
  1640. self.app.geo_editor.on_shape_complete()
  1641. self.app.inform.emit("[success]Done.")
  1642. # automatically make the selection tool active after completing current action
  1643. self.app.geo_editor.select_tool('select')
  1644. # Abort the current action
  1645. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  1646. # TODO: ...?
  1647. # self.on_tool_select("select")
  1648. self.app.inform.emit("[WARNING_NOTCL]Cancelled.")
  1649. self.app.geo_editor.delete_utility_geometry()
  1650. self.app.geo_editor.replot()
  1651. # self.select_btn.setChecked(True)
  1652. # self.on_tool_select('select')
  1653. self.app.geo_editor.select_tool('select')
  1654. return
  1655. # Delete selected object
  1656. if key == QtCore.Qt.Key_Delete or key == 'Delete':
  1657. self.app.geo_editor.delete_selected()
  1658. self.app.geo_editor.replot()
  1659. # Move
  1660. if key == QtCore.Qt.Key_Space or key == 'Space':
  1661. self.app.ui.geo_rotate_btn.setChecked(True)
  1662. self.app.geo_editor.on_tool_select('rotate')
  1663. self.app.geo_editor.active_tool.set_origin(
  1664. self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
  1665. if key == QtCore.Qt.Key_Minus or key == '-':
  1666. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'],
  1667. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  1668. if key == QtCore.Qt.Key_Equal or key == '=':
  1669. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'],
  1670. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  1671. # Switch to Project Tab
  1672. if key == QtCore.Qt.Key_1 or key == '1':
  1673. self.app.on_select_tab('project')
  1674. # Switch to Selected Tab
  1675. if key == QtCore.Qt.Key_2 or key == '2':
  1676. self.app.on_select_tab('selected')
  1677. # Switch to Tool Tab
  1678. if key == QtCore.Qt.Key_3 or key == '3':
  1679. self.app.on_select_tab('tool')
  1680. # Arc Tool
  1681. if key == QtCore.Qt.Key_A or key == 'A':
  1682. self.app.geo_editor.select_tool('arc')
  1683. # Buffer
  1684. if key == QtCore.Qt.Key_B or key == 'B':
  1685. self.app.geo_editor.select_tool('buffer')
  1686. # Copy
  1687. if key == QtCore.Qt.Key_C or key == 'C':
  1688. self.app.ui.geo_copy_btn.setChecked(True)
  1689. self.app.geo_editor.on_tool_select('copy')
  1690. self.app.geo_editor.active_tool.set_origin(self.app.geo_editor.snap(
  1691. self.app.geo_editor.x, self.app.geo_editor.y))
  1692. self.app.inform.emit("Click on target point.")
  1693. # Substract Tool
  1694. if key == QtCore.Qt.Key_E or key == 'E':
  1695. if self.app.geo_editor.get_selected() is not None:
  1696. self.app.geo_editor.intersection()
  1697. else:
  1698. msg = "Please select geometry items \n" \
  1699. "on which to perform Intersection Tool."
  1700. messagebox = QtWidgets.QMessageBox()
  1701. messagebox.setText(msg)
  1702. messagebox.setWindowTitle("Warning")
  1703. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  1704. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  1705. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  1706. messagebox.exec_()
  1707. # Grid Snap
  1708. if key == QtCore.Qt.Key_G or key == 'G':
  1709. self.app.ui.grid_snap_btn.trigger()
  1710. # make sure that the cursor shape is enabled/disabled, too
  1711. if self.app.geo_editor.options['grid_snap'] is True:
  1712. self.app.app_cursor.enabled = True
  1713. else:
  1714. self.app.app_cursor.enabled = False
  1715. # Paint
  1716. if key == QtCore.Qt.Key_I or key == 'I':
  1717. self.app.geo_editor.select_tool('paint')
  1718. # Jump to coords
  1719. if key == QtCore.Qt.Key_J or key == 'J':
  1720. self.app.on_jump_to()
  1721. # Corner Snap
  1722. if key == QtCore.Qt.Key_K or key == 'K':
  1723. self.app.geo_editor.on_corner_snap()
  1724. # Move
  1725. if key == QtCore.Qt.Key_M or key == 'M':
  1726. self.app.geo_editor.on_move_click()
  1727. # Polygon Tool
  1728. if key == QtCore.Qt.Key_N or key == 'N':
  1729. self.app.geo_editor.select_tool('polygon')
  1730. # Circle Tool
  1731. if key == QtCore.Qt.Key_O or key == 'O':
  1732. self.app.geo_editor.select_tool('circle')
  1733. # Path Tool
  1734. if key == QtCore.Qt.Key_P or key == 'P':
  1735. self.app.geo_editor.select_tool('path')
  1736. # Rectangle Tool
  1737. if key == QtCore.Qt.Key_R or key == 'R':
  1738. self.app.geo_editor.select_tool('rectangle')
  1739. # Substract Tool
  1740. if key == QtCore.Qt.Key_S or key == 'S':
  1741. if self.app.geo_editor.get_selected() is not None:
  1742. self.app.geo_editor.subtract()
  1743. else:
  1744. msg = "Please select geometry items \n" \
  1745. "on which to perform Substraction Tool."
  1746. messagebox = QtWidgets.QMessageBox()
  1747. messagebox.setText(msg)
  1748. messagebox.setWindowTitle("Warning")
  1749. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  1750. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  1751. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  1752. messagebox.exec_()
  1753. # Add Text Tool
  1754. if key == QtCore.Qt.Key_T or key == 'T':
  1755. self.app.geo_editor.select_tool('text')
  1756. # Substract Tool
  1757. if key == QtCore.Qt.Key_U or key == 'U':
  1758. if self.app.geo_editor.get_selected() is not None:
  1759. self.app.geo_editor.union()
  1760. else:
  1761. msg = "Please select geometry items \n" \
  1762. "on which to perform union."
  1763. messagebox = QtWidgets.QMessageBox()
  1764. messagebox.setText(msg)
  1765. messagebox.setWindowTitle("Warning")
  1766. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  1767. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  1768. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  1769. messagebox.exec_()
  1770. if key == QtCore.Qt.Key_V or key == 'V':
  1771. self.app.on_zoom_fit(None)
  1772. # Cut Action Tool
  1773. if key == QtCore.Qt.Key_X or key == 'X':
  1774. if self.app.geo_editor.get_selected() is not None:
  1775. self.app.geo_editor.cutpath()
  1776. else:
  1777. msg = 'Please first select a geometry item to be cutted\n' \
  1778. 'then select the geometry item that will be cutted\n' \
  1779. 'out of the first item. In the end press ~X~ key or\n' \
  1780. 'the toolbar button.' \
  1781. messagebox = QtWidgets.QMessageBox()
  1782. messagebox.setText(msg)
  1783. messagebox.setWindowTitle("Warning")
  1784. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  1785. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  1786. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  1787. messagebox.exec_()
  1788. # Propagate to tool
  1789. response = None
  1790. if self.app.geo_editor.active_tool is not None:
  1791. response = self.app.geo_editor.active_tool.on_key(key=key)
  1792. if response is not None:
  1793. self.app.inform.emit(response)
  1794. # Show Shortcut list
  1795. if key == 'F3':
  1796. self.app.on_shortcut_list()
  1797. elif self.app.call_source == 'exc_editor':
  1798. if modifiers == QtCore.Qt.ControlModifier:
  1799. # save (update) the current geometry and return to the App
  1800. if key == QtCore.Qt.Key_S or key == 'S':
  1801. self.app.editor2object()
  1802. return
  1803. # toggle the measurement tool
  1804. if key == QtCore.Qt.Key_M or key == 'M':
  1805. self.app.measurement_tool.run()
  1806. return
  1807. elif modifiers == QtCore.Qt.ShiftModifier:
  1808. pass
  1809. elif modifiers == QtCore.Qt.AltModifier:
  1810. pass
  1811. elif modifiers == QtCore.Qt.NoModifier:
  1812. # Abort the current action
  1813. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  1814. # TODO: ...?
  1815. # self.on_tool_select("select")
  1816. self.app.inform.emit("[WARNING_NOTCL]Cancelled.")
  1817. self.app.exc_editor.delete_utility_geometry()
  1818. self.app.exc_editor.replot()
  1819. # self.select_btn.setChecked(True)
  1820. # self.on_tool_select('select')
  1821. self.app.exc_editor.select_tool('select')
  1822. return
  1823. # Delete selected object if delete key event comes out of canvas
  1824. if key == 'Delete':
  1825. self.app.exc_editor.launched_from_shortcuts = True
  1826. if self.app.exc_editor.selected:
  1827. self.app.exc_editor.delete_selected()
  1828. self.app.exc_editor.replot()
  1829. else:
  1830. self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to delete.")
  1831. return
  1832. # Delete tools in tools table if delete key event comes from the Selected Tab
  1833. if key == QtCore.Qt.Key_Delete:
  1834. self.app.exc_editor.launched_from_shortcuts = True
  1835. self.app.exc_editor.on_tool_delete()
  1836. return
  1837. if key == QtCore.Qt.Key_Minus or key == '-':
  1838. self.app.exc_editor.launched_from_shortcuts = True
  1839. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'],
  1840. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  1841. return
  1842. if key == QtCore.Qt.Key_Equal or key == '=':
  1843. self.app.exc_editor.launched_from_shortcuts = True
  1844. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'],
  1845. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  1846. return
  1847. # toggle display of Notebook area
  1848. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  1849. self.app.exc_editor.launched_from_shortcuts = True
  1850. self.app.on_toggle_notebook()
  1851. return
  1852. # Switch to Project Tab
  1853. if key == QtCore.Qt.Key_1 or key == '1':
  1854. self.app.exc_editor.launched_from_shortcuts = True
  1855. self.app.on_select_tab('project')
  1856. return
  1857. # Switch to Selected Tab
  1858. if key == QtCore.Qt.Key_2 or key == '2':
  1859. self.app.exc_editor.launched_from_shortcuts = True
  1860. self.app.on_select_tab('selected')
  1861. return
  1862. # Switch to Tool Tab
  1863. if key == QtCore.Qt.Key_3 or key == '3':
  1864. self.app.exc_editor.launched_from_shortcuts = True
  1865. self.app.on_select_tab('tool')
  1866. return
  1867. # Add Array of Drill Hole Tool
  1868. if key == QtCore.Qt.Key_A or key == 'A':
  1869. self.app.exc_editor.launched_from_shortcuts = True
  1870. self.app.inform.emit("Click on target point.")
  1871. self.app.ui.add_drill_array_btn.setChecked(True)
  1872. self.app.exc_editor.x = self.app.mouse[0]
  1873. self.app.exc_editor.y = self.app.mouse[1]
  1874. self.app.exc_editor.select_tool('add_array')
  1875. return
  1876. # Copy
  1877. if key == QtCore.Qt.Key_C or key == 'C':
  1878. self.app.exc_editor.launched_from_shortcuts = True
  1879. if self.app.exc_editor.selected:
  1880. self.app.inform.emit("Click on target point.")
  1881. self.app.ui.copy_drill_btn.setChecked(True)
  1882. self.app.exc_editor.on_tool_select('copy')
  1883. self.app.exc_editor.active_tool.set_origin(
  1884. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  1885. else:
  1886. self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to copy.")
  1887. return
  1888. # Add Drill Hole Tool
  1889. if key == QtCore.Qt.Key_D or key == 'D':
  1890. self.app.exc_editor.launched_from_shortcuts = True
  1891. self.app.inform.emit("Click on target point.")
  1892. self.app.ui.add_drill_btn.setChecked(True)
  1893. self.app.exc_editor.x = self.app.mouse[0]
  1894. self.app.exc_editor.y = self.app.mouse[1]
  1895. self.app.exc_editor.select_tool('add')
  1896. return
  1897. # Grid Snap
  1898. if key == QtCore.Qt.Key_G or key == 'G':
  1899. self.app.exc_editor.launched_from_shortcuts = True
  1900. # make sure that the cursor shape is enabled/disabled, too
  1901. if self.app.exc_editor.options['grid_snap'] is True:
  1902. self.app.app_cursor.enabled = False
  1903. else:
  1904. self.app.app_cursor.enabled = True
  1905. self.app.ui.grid_snap_btn.trigger()
  1906. return
  1907. # Jump to coords
  1908. if key == QtCore.Qt.Key_J or key == 'J':
  1909. self.app.on_jump_to()
  1910. # Corner Snap
  1911. if key == QtCore.Qt.Key_K or key == 'K':
  1912. self.app.exc_editor.launched_from_shortcuts = True
  1913. self.app.ui.corner_snap_btn.trigger()
  1914. return
  1915. # Move
  1916. if key == QtCore.Qt.Key_M or key == 'M':
  1917. self.app.exc_editor.launched_from_shortcuts = True
  1918. if self.app.exc_editor.selected:
  1919. self.app.inform.emit("Click on target point.")
  1920. self.app.ui.move_drill_btn.setChecked(True)
  1921. self.app.exc_editor.on_tool_select('move')
  1922. self.app.exc_editor.active_tool.set_origin(
  1923. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  1924. else:
  1925. self.app.inform.emit("[WARNING_NOTCL]Cancelled. Nothing selected to move.")
  1926. return
  1927. # Resize Tool
  1928. if key == QtCore.Qt.Key_R or key == 'R':
  1929. self.app.exc_editor.launched_from_shortcuts = True
  1930. self.app.exc_editor.select_tool('resize')
  1931. return
  1932. # Add Tool
  1933. if key == QtCore.Qt.Key_T or key == 'T':
  1934. self.app.exc_editor.launched_from_shortcuts = True
  1935. ## Current application units in Upper Case
  1936. self.units = self.app.general_options_form.general_app_group.units_radio.get_value().upper()
  1937. tool_add_popup = FCInputDialog(title="New Tool ...",
  1938. text='Enter a Tool Diameter:',
  1939. min=0.0000, max=99.9999, decimals=4)
  1940. tool_add_popup.setWindowIcon(QtGui.QIcon('share/letter_t_32.png'))
  1941. val, ok = tool_add_popup.get_value()
  1942. if ok:
  1943. self.app.exc_editor.on_tool_add(tooldia=val)
  1944. self.app.inform.emit(
  1945. "[success]Added new tool with dia: %s %s" % ('%.4f' % float(val), str(self.units)))
  1946. else:
  1947. self.app.inform.emit(
  1948. "[WARNING_NOTCL] Adding Tool cancelled ...")
  1949. return
  1950. # Zoom Fit
  1951. if key == QtCore.Qt.Key_V or key == 'V':
  1952. self.app.exc_editor.launched_from_shortcuts = True
  1953. self.app.on_zoom_fit(None)
  1954. return
  1955. # Propagate to tool
  1956. response = None
  1957. if self.app.exc_editor.active_tool is not None:
  1958. response = self.app.exc_editor.active_tool.on_key(key=key)
  1959. if response is not None:
  1960. self.app.inform.emit(response)
  1961. # Show Shortcut list
  1962. if key == QtCore.Qt.Key_F3 or key == 'F3':
  1963. self.app.on_shortcut_list()
  1964. return
  1965. def dragEnterEvent(self, event):
  1966. if event.mimeData().hasUrls:
  1967. event.accept()
  1968. else:
  1969. event.ignore()
  1970. def dragMoveEvent(self, event):
  1971. if event.mimeData().hasUrls:
  1972. event.accept()
  1973. else:
  1974. event.ignore()
  1975. def dropEvent(self, event):
  1976. if event.mimeData().hasUrls:
  1977. event.setDropAction(QtCore.Qt.CopyAction)
  1978. event.accept()
  1979. for url in event.mimeData().urls():
  1980. self.filename = str(url.toLocalFile())
  1981. if self.filename == "":
  1982. self.app.inform.emit("Open cancelled.")
  1983. else:
  1984. if self.filename.lower().rpartition('.')[-1] in self.app.grb_list:
  1985. self.app.worker_task.emit({'fcn': self.app.open_gerber,
  1986. 'params': [self.filename]})
  1987. else:
  1988. event.ignore()
  1989. if self.filename.lower().rpartition('.')[-1] in self.app.exc_list:
  1990. self.app.worker_task.emit({'fcn': self.app.open_excellon,
  1991. 'params': [self.filename]})
  1992. else:
  1993. event.ignore()
  1994. if self.filename.lower().rpartition('.')[-1] in self.app.gcode_list:
  1995. self.app.worker_task.emit({'fcn': self.app.open_gcode,
  1996. 'params': [self.filename]})
  1997. else:
  1998. event.ignore()
  1999. if self.filename.lower().rpartition('.')[-1] in self.app.svg_list:
  2000. object_type = 'geometry'
  2001. self.app.worker_task.emit({'fcn': self.app.import_svg,
  2002. 'params': [self.filename, object_type, None]})
  2003. if self.filename.lower().rpartition('.')[-1] in self.app.dxf_list:
  2004. object_type = 'geometry'
  2005. self.app.worker_task.emit({'fcn': self.app.import_dxf,
  2006. 'params': [self.filename, object_type, None]})
  2007. if self.filename.lower().rpartition('.')[-1] in self.app.prj_list:
  2008. # self.app.open_project() is not Thread Safe
  2009. self.app.open_project(self.filename)
  2010. else:
  2011. event.ignore()
  2012. else:
  2013. event.ignore()
  2014. def closeEvent(self, event):
  2015. grect = self.geometry()
  2016. # self.splitter.sizes()[0] is actually the size of the "notebook"
  2017. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
  2018. self.final_save.emit()
  2019. if self.app.should_we_quit is True:
  2020. # # save toolbar state to file
  2021. # with open(self.app.data_path + '\gui_state.config', 'wb') as stream:
  2022. # stream.write(self.saveState().data())
  2023. # log.debug("FlatCAMGUI.__init__() --> UI state saved.")
  2024. # QtWidgets.qApp.quit()
  2025. # save toolbar state to file
  2026. settings = QSettings("Open Source", "FlatCAM")
  2027. settings.setValue('saved_gui_state', self.saveState())
  2028. # This will write the setting to the platform specific storage.
  2029. del settings
  2030. log.debug("FlatCAMGUI.__init__() --> UI state saved.")
  2031. QtWidgets.qApp.quit()
  2032. else:
  2033. self.app.should_we_quit = True
  2034. event.ignore()
  2035. class GeneralPreferencesUI(QtWidgets.QWidget):
  2036. def __init__(self, parent=None):
  2037. QtWidgets.QWidget.__init__(self, parent=parent)
  2038. self.layout = QtWidgets.QHBoxLayout()
  2039. self.setLayout(self.layout)
  2040. self.general_app_group = GeneralAppPrefGroupUI()
  2041. self.general_app_group.setFixedWidth(250)
  2042. self.general_gui_group = GeneralGUIPrefGroupUI()
  2043. self.general_gui_group.setFixedWidth(250)
  2044. self.layout.addWidget(self.general_app_group)
  2045. self.layout.addWidget(self.general_gui_group)
  2046. self.layout.addStretch()
  2047. class GerberPreferencesUI(QtWidgets.QWidget):
  2048. def __init__(self, parent=None):
  2049. QtWidgets.QWidget.__init__(self, parent=parent)
  2050. self.layout = QtWidgets.QHBoxLayout()
  2051. self.setLayout(self.layout)
  2052. self.gerber_gen_group = GerberGenPrefGroupUI()
  2053. self.gerber_gen_group.setFixedWidth(250)
  2054. self.gerber_opt_group = GerberOptPrefGroupUI()
  2055. self.gerber_opt_group.setFixedWidth(250)
  2056. self.layout.addWidget(self.gerber_gen_group)
  2057. self.layout.addWidget(self.gerber_opt_group)
  2058. self.layout.addStretch()
  2059. class ExcellonPreferencesUI(QtWidgets.QWidget):
  2060. def __init__(self, parent=None):
  2061. QtWidgets.QWidget.__init__(self, parent=parent)
  2062. self.layout = QtWidgets.QHBoxLayout()
  2063. self.setLayout(self.layout)
  2064. self.excellon_gen_group = ExcellonGenPrefGroupUI()
  2065. self.excellon_gen_group.setFixedWidth(220)
  2066. self.excellon_opt_group = ExcellonOptPrefGroupUI()
  2067. self.excellon_opt_group.setFixedWidth(250)
  2068. self.excellon_exp_group = ExcellonExpPrefGroupUI()
  2069. self.excellon_exp_group.setFixedWidth(250)
  2070. self.layout.addWidget(self.excellon_gen_group)
  2071. self.layout.addWidget(self.excellon_opt_group)
  2072. self.layout.addWidget(self.excellon_exp_group)
  2073. self.layout.addStretch()
  2074. class GeometryPreferencesUI(QtWidgets.QWidget):
  2075. def __init__(self, parent=None):
  2076. QtWidgets.QWidget.__init__(self, parent=parent)
  2077. self.layout = QtWidgets.QHBoxLayout()
  2078. self.setLayout(self.layout)
  2079. self.geometry_gen_group = GeometryGenPrefGroupUI()
  2080. self.geometry_gen_group.setFixedWidth(220)
  2081. self.geometry_opt_group = GeometryOptPrefGroupUI()
  2082. self.geometry_opt_group.setFixedWidth(250)
  2083. self.layout.addWidget(self.geometry_gen_group)
  2084. self.layout.addWidget(self.geometry_opt_group)
  2085. self.layout.addStretch()
  2086. class ToolsPreferencesUI(QtWidgets.QWidget):
  2087. def __init__(self, parent=None):
  2088. QtWidgets.QWidget.__init__(self, parent=parent)
  2089. self.layout = QtWidgets.QHBoxLayout()
  2090. self.setLayout(self.layout)
  2091. self.tools_ncc_group = ToolsNCCPrefGroupUI()
  2092. self.tools_ncc_group.setMinimumWidth(200)
  2093. self.tools_paint_group = ToolsPaintPrefGroupUI()
  2094. self.tools_paint_group.setMinimumWidth(200)
  2095. self.tools_cutout_group = ToolsCutoutPrefGroupUI()
  2096. self.tools_cutout_group.setMinimumWidth(220)
  2097. self.tools_2sided_group = Tools2sidedPrefGroupUI()
  2098. self.tools_2sided_group.setMinimumWidth(220)
  2099. self.tools_film_group = ToolsFilmPrefGroupUI()
  2100. self.tools_film_group.setMinimumWidth(220)
  2101. self.tools_panelize_group = ToolsPanelizePrefGroupUI()
  2102. self.tools_panelize_group.setMinimumWidth(220)
  2103. self.tools_calculators_group = ToolsCalculatorsPrefGroupUI()
  2104. self.tools_calculators_group.setMinimumWidth(220)
  2105. self.vlay = QtWidgets.QVBoxLayout()
  2106. self.vlay.addWidget(self.tools_ncc_group)
  2107. self.vlay.addWidget(self.tools_paint_group)
  2108. self.vlay1 = QtWidgets.QVBoxLayout()
  2109. self.vlay1.addWidget(self.tools_cutout_group)
  2110. self.vlay1.addWidget(self.tools_2sided_group)
  2111. self.vlay1.addWidget(self.tools_film_group)
  2112. self.vlay2 = QtWidgets.QVBoxLayout()
  2113. self.vlay2.addWidget(self.tools_panelize_group)
  2114. self.vlay2.addWidget(self.tools_calculators_group)
  2115. self.layout.addLayout(self.vlay)
  2116. self.layout.addLayout(self.vlay1)
  2117. self.layout.addLayout(self.vlay2)
  2118. self.layout.addStretch()
  2119. class CNCJobPreferencesUI(QtWidgets.QWidget):
  2120. def __init__(self, parent=None):
  2121. QtWidgets.QWidget.__init__(self, parent=parent)
  2122. self.layout = QtWidgets.QHBoxLayout()
  2123. self.setLayout(self.layout)
  2124. self.cncjob_gen_group = CNCJobGenPrefGroupUI()
  2125. self.cncjob_gen_group.setFixedWidth(270)
  2126. self.cncjob_opt_group = CNCJobOptPrefGroupUI()
  2127. self.cncjob_opt_group.setFixedWidth(260)
  2128. self.layout.addWidget(self.cncjob_gen_group)
  2129. self.layout.addWidget(self.cncjob_opt_group)
  2130. self.layout.addStretch()
  2131. class OptionsGroupUI(QtWidgets.QGroupBox):
  2132. def __init__(self, title, parent=None):
  2133. # QtGui.QGroupBox.__init__(self, title, parent=parent)
  2134. super(OptionsGroupUI, self).__init__()
  2135. self.setStyleSheet("""
  2136. QGroupBox
  2137. {
  2138. font-size: 16px;
  2139. font-weight: bold;
  2140. }
  2141. """)
  2142. self.layout = QtWidgets.QVBoxLayout()
  2143. self.setLayout(self.layout)
  2144. class GeneralGUIPrefGroupUI(OptionsGroupUI):
  2145. def __init__(self, parent=None):
  2146. super(GeneralGUIPrefGroupUI, self).__init__(self)
  2147. self.setTitle(str("GUI Preferences"))
  2148. # Create a form layout for the Application general settings
  2149. self.form_box = QtWidgets.QFormLayout()
  2150. # Grid X Entry
  2151. self.gridx_label = QtWidgets.QLabel('Grid X value:')
  2152. self.gridx_label.setToolTip(
  2153. "This is the Grid value on X axis\n"
  2154. )
  2155. self.gridx_entry = LengthEntry()
  2156. # Grid Y Entry
  2157. self.gridy_label = QtWidgets.QLabel('Grid Y value:')
  2158. self.gridy_label.setToolTip(
  2159. "This is the Grid value on Y axis\n"
  2160. )
  2161. self.gridy_entry = LengthEntry()
  2162. # Snap Max Entry
  2163. self.snap_max_label = QtWidgets.QLabel('Snap Max:')
  2164. self.snap_max_label.setToolTip("Max. magnet distance")
  2165. self.snap_max_dist_entry = FCEntry()
  2166. # Workspace
  2167. self.workspace_lbl = QtWidgets.QLabel('Workspace:')
  2168. self.workspace_lbl.setToolTip(
  2169. "Draw a delimiting rectangle on canvas.\n"
  2170. "The purpose is to illustrate the limits for our work."
  2171. )
  2172. self.workspace_type_lbl = QtWidgets.QLabel('Wk. format:')
  2173. self.workspace_type_lbl.setToolTip(
  2174. "Select the type of rectangle to be used on canvas,\n"
  2175. "as valid workspace."
  2176. )
  2177. self.workspace_cb = FCCheckBox()
  2178. self.wk_cb = FCComboBox()
  2179. self.wk_cb.addItem('A4P')
  2180. self.wk_cb.addItem('A4L')
  2181. self.wk_cb.addItem('A3P')
  2182. self.wk_cb.addItem('A3L')
  2183. self.wks = OptionalInputSection(self.workspace_cb, [self.workspace_type_lbl, self.wk_cb])
  2184. # Plot Fill Color
  2185. self.pf_color_label = QtWidgets.QLabel('Plot Fill:')
  2186. self.pf_color_label.setToolTip(
  2187. "Set the fill color for plotted objects.\n"
  2188. "First 6 digits are the color and the last 2\n"
  2189. "digits are for alpha (transparency) level."
  2190. )
  2191. self.pf_color_entry = FCEntry()
  2192. self.pf_color_button = QtWidgets.QPushButton()
  2193. self.pf_color_button.setFixedSize(15, 15)
  2194. self.form_box_child_1 = QtWidgets.QHBoxLayout()
  2195. self.form_box_child_1.addWidget(self.pf_color_entry)
  2196. self.form_box_child_1.addWidget(self.pf_color_button)
  2197. self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2198. # Plot Fill Transparency Level
  2199. self.pf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  2200. self.pf_alpha_label.setToolTip(
  2201. "Set the fill transparency for plotted objects."
  2202. )
  2203. self.pf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  2204. self.pf_color_alpha_slider.setMinimum(0)
  2205. self.pf_color_alpha_slider.setMaximum(255)
  2206. self.pf_color_alpha_slider.setSingleStep(1)
  2207. self.pf_color_alpha_spinner = FCSpinner()
  2208. self.pf_color_alpha_spinner.setFixedWidth(70)
  2209. self.pf_color_alpha_spinner.setMinimum(0)
  2210. self.pf_color_alpha_spinner.setMaximum(255)
  2211. self.form_box_child_2 = QtWidgets.QHBoxLayout()
  2212. self.form_box_child_2.addWidget(self.pf_color_alpha_slider)
  2213. self.form_box_child_2.addWidget(self.pf_color_alpha_spinner)
  2214. # Plot Line Color
  2215. self.pl_color_label = QtWidgets.QLabel('Plot Line:')
  2216. self.pl_color_label.setToolTip(
  2217. "Set the line color for plotted objects."
  2218. )
  2219. self.pl_color_entry = FCEntry()
  2220. self.pl_color_button = QtWidgets.QPushButton()
  2221. self.pl_color_button.setFixedSize(15, 15)
  2222. self.form_box_child_3 = QtWidgets.QHBoxLayout()
  2223. self.form_box_child_3.addWidget(self.pl_color_entry)
  2224. self.form_box_child_3.addWidget(self.pl_color_button)
  2225. self.form_box_child_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2226. # Plot Selection (left - right) Fill Color
  2227. self.sf_color_label = QtWidgets.QLabel('Sel. Fill:')
  2228. self.sf_color_label.setToolTip(
  2229. "Set the fill color for the selection box\n"
  2230. "in case that the selection is done from left to right.\n"
  2231. "First 6 digits are the color and the last 2\n"
  2232. "digits are for alpha (transparency) level."
  2233. )
  2234. self.sf_color_entry = FCEntry()
  2235. self.sf_color_button = QtWidgets.QPushButton()
  2236. self.sf_color_button.setFixedSize(15, 15)
  2237. self.form_box_child_4 = QtWidgets.QHBoxLayout()
  2238. self.form_box_child_4.addWidget(self.sf_color_entry)
  2239. self.form_box_child_4.addWidget(self.sf_color_button)
  2240. self.form_box_child_4.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2241. # Plot Selection (left - right) Fill Transparency Level
  2242. self.sf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  2243. self.sf_alpha_label.setToolTip(
  2244. "Set the fill transparency for the 'left to right' selection box."
  2245. )
  2246. self.sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  2247. self.sf_color_alpha_slider.setMinimum(0)
  2248. self.sf_color_alpha_slider.setMaximum(255)
  2249. self.sf_color_alpha_slider.setSingleStep(1)
  2250. self.sf_color_alpha_spinner = FCSpinner()
  2251. self.sf_color_alpha_spinner.setFixedWidth(70)
  2252. self.sf_color_alpha_spinner.setMinimum(0)
  2253. self.sf_color_alpha_spinner.setMaximum(255)
  2254. self.form_box_child_5 = QtWidgets.QHBoxLayout()
  2255. self.form_box_child_5.addWidget(self.sf_color_alpha_slider)
  2256. self.form_box_child_5.addWidget(self.sf_color_alpha_spinner)
  2257. # Plot Selection (left - right) Line Color
  2258. self.sl_color_label = QtWidgets.QLabel('Sel. Line:')
  2259. self.sl_color_label.setToolTip(
  2260. "Set the line color for the 'left to right' selection box."
  2261. )
  2262. self.sl_color_entry = FCEntry()
  2263. self.sl_color_button = QtWidgets.QPushButton()
  2264. self.sl_color_button.setFixedSize(15, 15)
  2265. self.form_box_child_6 = QtWidgets.QHBoxLayout()
  2266. self.form_box_child_6.addWidget(self.sl_color_entry)
  2267. self.form_box_child_6.addWidget(self.sl_color_button)
  2268. self.form_box_child_6.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2269. # Plot Selection (right - left) Fill Color
  2270. self.alt_sf_color_label = QtWidgets.QLabel('Sel2. Fill:')
  2271. self.alt_sf_color_label.setToolTip(
  2272. "Set the fill color for the selection box\n"
  2273. "in case that the selection is done from right to left.\n"
  2274. "First 6 digits are the color and the last 2\n"
  2275. "digits are for alpha (transparency) level."
  2276. )
  2277. self.alt_sf_color_entry = FCEntry()
  2278. self.alt_sf_color_button = QtWidgets.QPushButton()
  2279. self.alt_sf_color_button.setFixedSize(15, 15)
  2280. self.form_box_child_7 = QtWidgets.QHBoxLayout()
  2281. self.form_box_child_7.addWidget(self.alt_sf_color_entry)
  2282. self.form_box_child_7.addWidget(self.alt_sf_color_button)
  2283. self.form_box_child_7.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2284. # Plot Selection (right - left) Fill Transparency Level
  2285. self.alt_sf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  2286. self.alt_sf_alpha_label.setToolTip(
  2287. "Set the fill transparency for selection 'right to left' box."
  2288. )
  2289. self.alt_sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  2290. self.alt_sf_color_alpha_slider.setMinimum(0)
  2291. self.alt_sf_color_alpha_slider.setMaximum(255)
  2292. self.alt_sf_color_alpha_slider.setSingleStep(1)
  2293. self.alt_sf_color_alpha_spinner = FCSpinner()
  2294. self.alt_sf_color_alpha_spinner.setFixedWidth(70)
  2295. self.alt_sf_color_alpha_spinner.setMinimum(0)
  2296. self.alt_sf_color_alpha_spinner.setMaximum(255)
  2297. self.form_box_child_8 = QtWidgets.QHBoxLayout()
  2298. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_slider)
  2299. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_spinner)
  2300. # Plot Selection (right - left) Line Color
  2301. self.alt_sl_color_label = QtWidgets.QLabel('Sel2. Line:')
  2302. self.alt_sl_color_label.setToolTip(
  2303. "Set the line color for the 'right to left' selection box."
  2304. )
  2305. self.alt_sl_color_entry = FCEntry()
  2306. self.alt_sl_color_button = QtWidgets.QPushButton()
  2307. self.alt_sl_color_button.setFixedSize(15, 15)
  2308. self.form_box_child_9 = QtWidgets.QHBoxLayout()
  2309. self.form_box_child_9.addWidget(self.alt_sl_color_entry)
  2310. self.form_box_child_9.addWidget(self.alt_sl_color_button)
  2311. self.form_box_child_9.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2312. # Editor Draw Color
  2313. self.draw_color_label = QtWidgets.QLabel('Editor Draw:')
  2314. self.alt_sf_color_label.setToolTip(
  2315. "Set the color for the shape."
  2316. )
  2317. self.draw_color_entry = FCEntry()
  2318. self.draw_color_button = QtWidgets.QPushButton()
  2319. self.draw_color_button.setFixedSize(15, 15)
  2320. self.form_box_child_10 = QtWidgets.QHBoxLayout()
  2321. self.form_box_child_10.addWidget(self.draw_color_entry)
  2322. self.form_box_child_10.addWidget(self.draw_color_button)
  2323. self.form_box_child_10.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2324. # Editor Draw Selection Color
  2325. self.sel_draw_color_label = QtWidgets.QLabel('Editor Draw Sel.:')
  2326. self.sel_draw_color_label.setToolTip(
  2327. "Set the color of the shape when selected."
  2328. )
  2329. self.sel_draw_color_entry = FCEntry()
  2330. self.sel_draw_color_button = QtWidgets.QPushButton()
  2331. self.sel_draw_color_button.setFixedSize(15, 15)
  2332. self.form_box_child_11 = QtWidgets.QHBoxLayout()
  2333. self.form_box_child_11.addWidget(self.sel_draw_color_entry)
  2334. self.form_box_child_11.addWidget(self.sel_draw_color_button)
  2335. self.form_box_child_11.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2336. # Theme selection
  2337. self.layout_label = QtWidgets.QLabel('Layout:')
  2338. self.alt_sf_color_label.setToolTip(
  2339. "Select an layout for FlatCAM."
  2340. )
  2341. self.layout_combo = FCComboBox()
  2342. self.layout_combo.addItem("Choose ...")
  2343. self.layout_combo.addItem("Standard")
  2344. self.layout_combo.addItem("Compact")
  2345. self.layout_combo.setCurrentIndex(0)
  2346. # Just to add empty rows
  2347. self.spacelabel = QtWidgets.QLabel('')
  2348. # Add (label - input field) pair to the QFormLayout
  2349. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2350. self.form_box.addRow(self.gridx_label, self.gridx_entry)
  2351. self.form_box.addRow(self.gridy_label, self.gridy_entry)
  2352. self.form_box.addRow(self.snap_max_label, self.snap_max_dist_entry)
  2353. self.form_box.addRow(self.workspace_lbl, self.workspace_cb)
  2354. self.form_box.addRow(self.workspace_type_lbl, self.wk_cb)
  2355. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2356. self.form_box.addRow(self.pf_color_label, self.form_box_child_1)
  2357. self.form_box.addRow(self.pf_alpha_label, self.form_box_child_2)
  2358. self.form_box.addRow(self.pl_color_label, self.form_box_child_3)
  2359. self.form_box.addRow(self.sf_color_label, self.form_box_child_4)
  2360. self.form_box.addRow(self.sf_alpha_label, self.form_box_child_5)
  2361. self.form_box.addRow(self.sl_color_label, self.form_box_child_6)
  2362. self.form_box.addRow(self.alt_sf_color_label, self.form_box_child_7)
  2363. self.form_box.addRow(self.alt_sf_alpha_label, self.form_box_child_8)
  2364. self.form_box.addRow(self.alt_sl_color_label, self.form_box_child_9)
  2365. self.form_box.addRow(self.draw_color_label, self.form_box_child_10)
  2366. self.form_box.addRow(self.sel_draw_color_label, self.form_box_child_11)
  2367. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2368. self.form_box.addRow(self.layout_label, self.layout_combo)
  2369. # Add the QFormLayout that holds the Application general defaults
  2370. # to the main layout of this TAB
  2371. self.layout.addLayout(self.form_box)
  2372. class GeneralAppPrefGroupUI(OptionsGroupUI):
  2373. def __init__(self, parent=None):
  2374. super(GeneralAppPrefGroupUI, self).__init__(self)
  2375. self.setTitle(str("App Preferences"))
  2376. # Create a form layout for the Application general settings
  2377. self.form_box = QtWidgets.QFormLayout()
  2378. # Units for FlatCAM
  2379. self.unitslabel = QtWidgets.QLabel('<b>Units:</b>')
  2380. self.unitslabel.setToolTip("The default value for FlatCAM units.\n"
  2381. "Whatever is selected here is set every time\n"
  2382. "FLatCAM is started.")
  2383. self.units_radio = RadioSet([{'label': 'IN', 'value': 'IN'},
  2384. {'label': 'MM', 'value': 'MM'}])
  2385. # Languages for FlatCAM
  2386. self.languagelabel = QtWidgets.QLabel('<b>Languages:</b>')
  2387. self.languagelabel.setToolTip("Set the language used throughout FlatCAM.")
  2388. self.language_cb = FCComboBox()
  2389. self.languagespace = QtWidgets.QLabel('')
  2390. self.language_apply_btn = FCButton("Apply Language")
  2391. # Shell StartUp CB
  2392. self.shell_startup_label = QtWidgets.QLabel('Shell at StartUp:')
  2393. self.shell_startup_label.setToolTip(
  2394. "Check this box if you want the shell to\n"
  2395. "start automatically at startup."
  2396. )
  2397. self.shell_startup_cb = FCCheckBox(label='')
  2398. self.shell_startup_cb.setToolTip(
  2399. "Check this box if you want the shell to\n"
  2400. "start automatically at startup."
  2401. )
  2402. # Version Check CB
  2403. self.version_check_label = QtWidgets.QLabel('Version Check:')
  2404. self.version_check_label.setToolTip(
  2405. "Check this box if you want to check\n"
  2406. "for a new version automatically at startup."
  2407. )
  2408. self.version_check_cb = FCCheckBox(label='')
  2409. self.version_check_cb.setToolTip(
  2410. "Check this box if you want to check\n"
  2411. "for a new version automatically at startup."
  2412. )
  2413. # Send Stats CB
  2414. self.send_stats_label = QtWidgets.QLabel('Send Stats:')
  2415. self.send_stats_label.setToolTip(
  2416. "Check this box if you agree to send anonymous\n"
  2417. "stats automatically at startup, to help improve FlatCAM."
  2418. )
  2419. self.send_stats_cb= FCCheckBox(label='')
  2420. self.send_stats_cb.setToolTip(
  2421. "Check this box if you agree to send anonymous\n"
  2422. "stats automatically at startup, to help improve FlatCAM."
  2423. )
  2424. self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
  2425. # Select mouse pan button
  2426. self.panbuttonlabel = QtWidgets.QLabel('<b>Pan Button:</b>')
  2427. self.panbuttonlabel.setToolTip("Select the mouse button to use for panning:\n"
  2428. "- MMB --> Middle Mouse Button\n"
  2429. "- RMB --> Right Mouse Button")
  2430. self.pan_button_radio = RadioSet([{'label': 'MMB', 'value': '3'},
  2431. {'label': 'RMB', 'value': '2'}])
  2432. # Multiple Selection Modifier Key
  2433. self.mselectlabel = QtWidgets.QLabel('<b>Multiple Sel:</b>')
  2434. self.mselectlabel.setToolTip("Select the key used for multiple selection.")
  2435. self.mselect_radio = RadioSet([{'label': 'CTRL', 'value': 'Control'},
  2436. {'label': 'SHIFT', 'value': 'Shift'}])
  2437. # Project at StartUp CB
  2438. self.project_startup_label = QtWidgets.QLabel('Project at StartUp:')
  2439. self.project_startup_label.setToolTip(
  2440. "Check this box if you want the project/selected/tool tab area to\n"
  2441. "to be shown automatically at startup."
  2442. )
  2443. self.project_startup_cb = FCCheckBox(label='')
  2444. self.project_startup_cb.setToolTip(
  2445. "Check this box if you want the project/selected/tool tab area to\n"
  2446. "to be shown automatically at startup."
  2447. )
  2448. # Project autohide CB
  2449. self.project_autohide_label = QtWidgets.QLabel('Project AutoHide:')
  2450. self.project_autohide_label.setToolTip(
  2451. "Check this box if you want the project/selected/tool tab area to\n"
  2452. "hide automatically when there are no objects loaded and\n"
  2453. "to show whenever a new object is created."
  2454. )
  2455. self.project_autohide_cb = FCCheckBox(label='')
  2456. self.project_autohide_cb.setToolTip(
  2457. "Check this box if you want the project/selected/tool tab area to\n"
  2458. "hide automatically when there are no objects loaded and\n"
  2459. "to show whenever a new object is created."
  2460. )
  2461. # Just to add empty rows
  2462. self.spacelabel = QtWidgets.QLabel('')
  2463. # Add (label - input field) pair to the QFormLayout
  2464. self.form_box.addRow(self.unitslabel, self.units_radio)
  2465. self.form_box.addRow(self.languagelabel, self.language_cb)
  2466. self.form_box.addRow(self.languagespace, self.language_apply_btn)
  2467. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2468. self.form_box.addRow(self.shell_startup_label, self.shell_startup_cb)
  2469. self.form_box.addRow(self.version_check_label, self.version_check_cb)
  2470. self.form_box.addRow(self.send_stats_label, self.send_stats_cb)
  2471. self.form_box.addRow(self.panbuttonlabel, self.pan_button_radio)
  2472. self.form_box.addRow(self.mselectlabel, self.mselect_radio)
  2473. self.form_box.addRow(self.project_startup_label, self.project_startup_cb)
  2474. self.form_box.addRow(self.project_autohide_label, self.project_autohide_cb)
  2475. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2476. # Add the QFormLayout that holds the Application general defaults
  2477. # to the main layout of this TAB
  2478. self.layout.addLayout(self.form_box)
  2479. class GerberGenPrefGroupUI(OptionsGroupUI):
  2480. def __init__(self, parent=None):
  2481. # OptionsGroupUI.__init__(self, "Gerber General Preferences", parent=parent)
  2482. super(GerberGenPrefGroupUI, self).__init__(self)
  2483. self.setTitle(str("Gerber General"))
  2484. ## Plot options
  2485. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  2486. self.layout.addWidget(self.plot_options_label)
  2487. grid0 = QtWidgets.QGridLayout()
  2488. self.layout.addLayout(grid0)
  2489. # Plot CB
  2490. self.plot_cb = FCCheckBox(label='Plot')
  2491. self.plot_options_label.setToolTip(
  2492. "Plot (show) this object."
  2493. )
  2494. grid0.addWidget(self.plot_cb, 0, 0)
  2495. # Solid CB
  2496. self.solid_cb = FCCheckBox(label='Solid')
  2497. self.solid_cb.setToolTip(
  2498. "Solid color polygons."
  2499. )
  2500. grid0.addWidget(self.solid_cb, 0, 1)
  2501. # Multicolored CB
  2502. self.multicolored_cb = FCCheckBox(label='M-Color')
  2503. self.multicolored_cb.setToolTip(
  2504. "Draw polygons in different colors."
  2505. )
  2506. grid0.addWidget(self.multicolored_cb, 0, 2)
  2507. # Number of circle steps for circular aperture linear approximation
  2508. self.circle_steps_label = QtWidgets.QLabel("Circle Steps:")
  2509. self.circle_steps_label.setToolTip(
  2510. "The number of circle steps for Gerber \n"
  2511. "circular aperture linear approximation."
  2512. )
  2513. grid0.addWidget(self.circle_steps_label, 1, 0)
  2514. self.circle_steps_entry = IntEntry()
  2515. grid0.addWidget(self.circle_steps_entry, 1, 1)
  2516. self.layout.addStretch()
  2517. class GerberOptPrefGroupUI(OptionsGroupUI):
  2518. def __init__(self, parent=None):
  2519. # OptionsGroupUI.__init__(self, "Gerber Options Preferences", parent=parent)
  2520. super(GerberOptPrefGroupUI, self).__init__(self)
  2521. self.setTitle(str("Gerber Options"))
  2522. ## Isolation Routing
  2523. self.isolation_routing_label = QtWidgets.QLabel("<b>Isolation Routing:</b>")
  2524. self.isolation_routing_label.setToolTip(
  2525. "Create a Geometry object with\n"
  2526. "toolpaths to cut outside polygons."
  2527. )
  2528. self.layout.addWidget(self.isolation_routing_label)
  2529. # Cutting Tool Diameter
  2530. grid0 = QtWidgets.QGridLayout()
  2531. self.layout.addLayout(grid0)
  2532. tdlabel = QtWidgets.QLabel('Tool dia:')
  2533. tdlabel.setToolTip(
  2534. "Diameter of the cutting tool."
  2535. )
  2536. grid0.addWidget(tdlabel, 0, 0)
  2537. self.iso_tool_dia_entry = LengthEntry()
  2538. grid0.addWidget(self.iso_tool_dia_entry, 0, 1)
  2539. # Nr of passes
  2540. passlabel = QtWidgets.QLabel('Width (# passes):')
  2541. passlabel.setToolTip(
  2542. "Width of the isolation gap in\n"
  2543. "number (integer) of tool widths."
  2544. )
  2545. grid0.addWidget(passlabel, 1, 0)
  2546. self.iso_width_entry = IntEntry()
  2547. grid0.addWidget(self.iso_width_entry, 1, 1)
  2548. # Pass overlap
  2549. overlabel = QtWidgets.QLabel('Pass overlap:')
  2550. overlabel.setToolTip(
  2551. "How much (fraction) of the tool width to overlap each tool pass.\n"
  2552. "Example:\n"
  2553. "A value here of 0.25 means an overlap of 25% from the tool diameter found above."
  2554. )
  2555. grid0.addWidget(overlabel, 2, 0)
  2556. self.iso_overlap_entry = FloatEntry()
  2557. grid0.addWidget(self.iso_overlap_entry, 2, 1)
  2558. milling_type_label = QtWidgets.QLabel('Milling Type:')
  2559. milling_type_label.setToolTip(
  2560. "Milling type:\n"
  2561. "- climb / best for precision milling and to reduce tool usage\n"
  2562. "- conventional / useful when there is no backlash compensation"
  2563. )
  2564. grid0.addWidget(milling_type_label, 3, 0)
  2565. self.milling_type_radio = RadioSet([{'label': 'Climb', 'value': 'cl'},
  2566. {'label': 'Conv.', 'value': 'cv'}])
  2567. grid0.addWidget(self.milling_type_radio, 3, 1)
  2568. # Combine passes
  2569. self.combine_passes_cb = FCCheckBox(label='Combine Passes')
  2570. self.combine_passes_cb.setToolTip(
  2571. "Combine all passes into one object"
  2572. )
  2573. grid0.addWidget(self.combine_passes_cb, 4, 0)
  2574. ## Clear non-copper regions
  2575. self.clearcopper_label = QtWidgets.QLabel("<b>Clear non-copper:</b>")
  2576. self.clearcopper_label.setToolTip(
  2577. "Create a Geometry object with\n"
  2578. "toolpaths to cut all non-copper regions."
  2579. )
  2580. self.layout.addWidget(self.clearcopper_label)
  2581. grid1 = QtWidgets.QGridLayout()
  2582. self.layout.addLayout(grid1)
  2583. # Margin
  2584. bmlabel = QtWidgets.QLabel('Boundary Margin:')
  2585. bmlabel.setToolTip(
  2586. "Specify the edge of the PCB\n"
  2587. "by drawing a box around all\n"
  2588. "objects with this minimum\n"
  2589. "distance."
  2590. )
  2591. grid1.addWidget(bmlabel, 0, 0)
  2592. self.noncopper_margin_entry = LengthEntry()
  2593. grid1.addWidget(self.noncopper_margin_entry, 0, 1)
  2594. # Rounded corners
  2595. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  2596. self.noncopper_rounded_cb.setToolTip(
  2597. "Creates a Geometry objects with polygons\n"
  2598. "covering the copper-free areas of the PCB."
  2599. )
  2600. grid1.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  2601. ## Bounding box
  2602. self.boundingbox_label = QtWidgets.QLabel('<b>Bounding Box:</b>')
  2603. self.layout.addWidget(self.boundingbox_label)
  2604. grid2 = QtWidgets.QGridLayout()
  2605. self.layout.addLayout(grid2)
  2606. bbmargin = QtWidgets.QLabel('Boundary Margin:')
  2607. bbmargin.setToolTip(
  2608. "Distance of the edges of the box\n"
  2609. "to the nearest polygon."
  2610. )
  2611. grid2.addWidget(bbmargin, 0, 0)
  2612. self.bbmargin_entry = LengthEntry()
  2613. grid2.addWidget(self.bbmargin_entry, 0, 1)
  2614. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  2615. self.bbrounded_cb.setToolTip(
  2616. "If the bounding box is \n"
  2617. "to have rounded corners\n"
  2618. "their radius is equal to\n"
  2619. "the margin."
  2620. )
  2621. grid2.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  2622. self.layout.addStretch()
  2623. class ExcellonGenPrefGroupUI(OptionsGroupUI):
  2624. def __init__(self, parent=None):
  2625. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  2626. super(ExcellonGenPrefGroupUI, self).__init__(self)
  2627. self.setTitle(str("Excellon General"))
  2628. # Plot options
  2629. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  2630. self.layout.addWidget(self.plot_options_label)
  2631. grid1 = QtWidgets.QGridLayout()
  2632. self.layout.addLayout(grid1)
  2633. self.plot_cb = FCCheckBox(label='Plot')
  2634. self.plot_cb.setToolTip(
  2635. "Plot (show) this object."
  2636. )
  2637. grid1.addWidget(self.plot_cb, 0, 0)
  2638. self.solid_cb = FCCheckBox(label='Solid')
  2639. self.solid_cb.setToolTip(
  2640. "Plot as solid circles."
  2641. )
  2642. grid1.addWidget(self.solid_cb, 0, 1)
  2643. # Excellon format
  2644. self.excellon_format_label = QtWidgets.QLabel("<b>Excellon Format:</b>")
  2645. self.excellon_format_label.setToolTip(
  2646. "The NC drill files, usually named Excellon files\n"
  2647. "are files that can be found in different formats.\n"
  2648. "Here we set the format used when the provided\n"
  2649. "coordinates are not using period.\n"
  2650. "\n"
  2651. "Possible presets:\n"
  2652. "\n"
  2653. "PROTEUS 3:3 MM LZ\n"
  2654. "DipTrace 5:2 MM TZ\n"
  2655. "DipTrace 4:3 MM LZ\n"
  2656. "\n"
  2657. "EAGLE 3:3 MM TZ\n"
  2658. "EAGLE 4:3 MM TZ\n"
  2659. "EAGLE 2:5 INCH TZ\n"
  2660. "EAGLE 3:5 INCH TZ\n"
  2661. "\n"
  2662. "ALTIUM 2:4 INCH LZ\n"
  2663. "Sprint Layout 2:4 INCH LZ"
  2664. "\n"
  2665. "KiCAD 3:5 INCH TZ"
  2666. )
  2667. self.layout.addWidget(self.excellon_format_label)
  2668. hlay1 = QtWidgets.QHBoxLayout()
  2669. self.layout.addLayout(hlay1)
  2670. self.excellon_format_in_label = QtWidgets.QLabel("INCH:")
  2671. self.excellon_format_in_label.setAlignment(QtCore.Qt.AlignLeft)
  2672. self.excellon_format_in_label.setToolTip(
  2673. "Default values for INCH are 2:4")
  2674. hlay1.addWidget(self.excellon_format_in_label, QtCore.Qt.AlignLeft)
  2675. self.excellon_format_upper_in_entry = IntEntry()
  2676. self.excellon_format_upper_in_entry.setMaxLength(1)
  2677. self.excellon_format_upper_in_entry.setAlignment(QtCore.Qt.AlignRight)
  2678. self.excellon_format_upper_in_entry.setFixedWidth(30)
  2679. self.excellon_format_upper_in_entry.setToolTip(
  2680. "This numbers signify the number of digits in\n"
  2681. "the whole part of Excellon coordinates."
  2682. )
  2683. hlay1.addWidget(self.excellon_format_upper_in_entry, QtCore.Qt.AlignLeft)
  2684. excellon_separator_in_label= QtWidgets.QLabel(':')
  2685. excellon_separator_in_label.setFixedWidth(5)
  2686. hlay1.addWidget(excellon_separator_in_label, QtCore.Qt.AlignLeft)
  2687. self.excellon_format_lower_in_entry = IntEntry()
  2688. self.excellon_format_lower_in_entry.setMaxLength(1)
  2689. self.excellon_format_lower_in_entry.setAlignment(QtCore.Qt.AlignRight)
  2690. self.excellon_format_lower_in_entry.setFixedWidth(30)
  2691. self.excellon_format_lower_in_entry.setToolTip(
  2692. "This numbers signify the number of digits in\n"
  2693. "the decimal part of Excellon coordinates."
  2694. )
  2695. hlay1.addWidget(self.excellon_format_lower_in_entry, QtCore.Qt.AlignLeft)
  2696. hlay1.addStretch()
  2697. hlay2 = QtWidgets.QHBoxLayout()
  2698. self.layout.addLayout(hlay2)
  2699. self.excellon_format_mm_label = QtWidgets.QLabel("METRIC:")
  2700. self.excellon_format_mm_label.setAlignment(QtCore.Qt.AlignLeft)
  2701. self.excellon_format_mm_label.setToolTip(
  2702. "Default values for METRIC are 3:3")
  2703. hlay2.addWidget(self.excellon_format_mm_label, QtCore.Qt.AlignLeft)
  2704. self.excellon_format_upper_mm_entry = IntEntry()
  2705. self.excellon_format_upper_mm_entry.setMaxLength(1)
  2706. self.excellon_format_upper_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  2707. self.excellon_format_upper_mm_entry.setFixedWidth(30)
  2708. self.excellon_format_upper_mm_entry.setToolTip(
  2709. "This numbers signify the number of digits in\n"
  2710. "the whole part of Excellon coordinates."
  2711. )
  2712. hlay2.addWidget(self.excellon_format_upper_mm_entry, QtCore.Qt.AlignLeft)
  2713. excellon_separator_mm_label= QtWidgets.QLabel(':')
  2714. excellon_separator_mm_label.setFixedWidth(5)
  2715. hlay2.addWidget(excellon_separator_mm_label, QtCore.Qt.AlignLeft)
  2716. self.excellon_format_lower_mm_entry = IntEntry()
  2717. self.excellon_format_lower_mm_entry.setMaxLength(1)
  2718. self.excellon_format_lower_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  2719. self.excellon_format_lower_mm_entry.setFixedWidth(30)
  2720. self.excellon_format_lower_mm_entry.setToolTip(
  2721. "This numbers signify the number of digits in\n"
  2722. "the decimal part of Excellon coordinates."
  2723. )
  2724. hlay2.addWidget(self.excellon_format_lower_mm_entry, QtCore.Qt.AlignLeft)
  2725. hlay2.addStretch()
  2726. hlay3 = QtWidgets.QHBoxLayout()
  2727. self.layout.addLayout(hlay3)
  2728. self.excellon_zeros_label = QtWidgets.QLabel('Default <b>Zeros</b>:')
  2729. self.excellon_zeros_label.setAlignment(QtCore.Qt.AlignLeft)
  2730. self.excellon_zeros_label.setToolTip(
  2731. "This sets the type of Excellon zeros.\n"
  2732. "If LZ then Leading Zeros are kept and\n"
  2733. "Trailing Zeros are removed.\n"
  2734. "If TZ is checked then Trailing Zeros are kept\n"
  2735. "and Leading Zeros are removed."
  2736. )
  2737. hlay3.addWidget(self.excellon_zeros_label)
  2738. self.excellon_zeros_radio = RadioSet([{'label': 'LZ', 'value': 'L'},
  2739. {'label': 'TZ', 'value': 'T'}])
  2740. self.excellon_zeros_radio.setToolTip(
  2741. "This sets the default type of Excellon zeros.\n"
  2742. "If it is not detected in the parsed file the value here\n"
  2743. "will be used."
  2744. "If LZ then Leading Zeros are kept and\n"
  2745. "Trailing Zeros are removed.\n"
  2746. "If TZ is checked then Trailing Zeros are kept\n"
  2747. "and Leading Zeros are removed."
  2748. )
  2749. hlay3.addStretch()
  2750. hlay3.addWidget(self.excellon_zeros_radio, QtCore.Qt.AlignRight)
  2751. hlay4 = QtWidgets.QHBoxLayout()
  2752. self.layout.addLayout(hlay4)
  2753. self.excellon_units_label = QtWidgets.QLabel('Default <b>Units</b>:')
  2754. self.excellon_units_label.setAlignment(QtCore.Qt.AlignLeft)
  2755. self.excellon_units_label.setToolTip(
  2756. "This sets the default units of Excellon files.\n"
  2757. "If it is not detected in the parsed file the value here\n"
  2758. "will be used."
  2759. "Some Excellon files don't have an header\n"
  2760. "therefore this parameter will be used.\n"
  2761. )
  2762. hlay4.addWidget(self.excellon_units_label)
  2763. self.excellon_units_radio = RadioSet([{'label': 'INCH', 'value': 'INCH'},
  2764. {'label': 'MM', 'value': 'METRIC'}])
  2765. self.excellon_units_radio.setToolTip(
  2766. "This sets the units of Excellon files.\n"
  2767. "Some Excellon files don't have an header\n"
  2768. "therefore this parameter will be used.\n"
  2769. )
  2770. hlay4.addStretch()
  2771. hlay4.addWidget(self.excellon_units_radio, QtCore.Qt.AlignRight)
  2772. hlay5 = QtWidgets.QVBoxLayout()
  2773. self.layout.addLayout(hlay5)
  2774. self.empty_label = QtWidgets.QLabel("")
  2775. hlay5.addWidget(self.empty_label)
  2776. hlay6 = QtWidgets.QVBoxLayout()
  2777. self.layout.addLayout(hlay6)
  2778. self.excellon_general_label = QtWidgets.QLabel("<b>Excellon Optimization:</b>")
  2779. hlay6.addWidget(self.excellon_general_label)
  2780. # Create a form layout for the Excellon general settings
  2781. form_box_excellon = QtWidgets.QFormLayout()
  2782. hlay6.addLayout(form_box_excellon)
  2783. self.excellon_optimization_label = QtWidgets.QLabel('Algorithm: ')
  2784. self.excellon_optimization_label.setAlignment(QtCore.Qt.AlignLeft)
  2785. self.excellon_optimization_label.setToolTip(
  2786. "This sets the optimization type for the Excellon drill path.\n"
  2787. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  2788. "Guided Local Path is used. Default search time is 3sec.\n"
  2789. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  2790. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  2791. "\n"
  2792. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  2793. "Travelling Salesman algorithm for path optimization."
  2794. )
  2795. self.excellon_optimization_radio = RadioSet([{'label': 'MH', 'value': 'M'},
  2796. {'label': 'Basic', 'value': 'B'}])
  2797. self.excellon_optimization_radio.setToolTip(
  2798. "This sets the optimization type for the Excellon drill path.\n"
  2799. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  2800. "Guided Local Path is used. Default search time is 3sec.\n"
  2801. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  2802. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  2803. "\n"
  2804. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  2805. "Travelling Salesman algorithm for path optimization."
  2806. )
  2807. form_box_excellon.addRow(self.excellon_optimization_label, self.excellon_optimization_radio)
  2808. self.optimization_time_label = QtWidgets.QLabel('Optimization Time: ')
  2809. self.optimization_time_label.setAlignment(QtCore.Qt.AlignLeft)
  2810. self.optimization_time_label.setToolTip(
  2811. "When OR-Tools Metaheuristic (MH) is enabled there is a\n"
  2812. "maximum threshold for how much time is spent doing the\n"
  2813. "path optimization. This max duration is set here.\n"
  2814. "In seconds."
  2815. )
  2816. self.optimization_time_entry = LengthEntry()
  2817. form_box_excellon.addRow(self.optimization_time_label, self.optimization_time_entry)
  2818. current_platform = platform.architecture()[0]
  2819. if current_platform == '64bit':
  2820. self.excellon_optimization_label.setDisabled(False)
  2821. self.excellon_optimization_radio.setDisabled(False)
  2822. self.optimization_time_label.setDisabled(False)
  2823. self.optimization_time_entry.setDisabled(False)
  2824. self.excellon_optimization_radio.activated_custom.connect(self.optimization_selection)
  2825. else:
  2826. self.excellon_optimization_label.setDisabled(True)
  2827. self.excellon_optimization_radio.setDisabled(True)
  2828. self.optimization_time_label.setDisabled(True)
  2829. self.optimization_time_entry.setDisabled(True)
  2830. ## Create CNC Job
  2831. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job</b>')
  2832. self.cncjob_label.setToolTip(
  2833. "Parameters used to create a CNC Job object\n"
  2834. "for this drill object that are not changed very often."
  2835. )
  2836. self.layout.addWidget(self.cncjob_label)
  2837. grid1 = QtWidgets.QGridLayout()
  2838. self.layout.addLayout(grid1)
  2839. offsetlabel = QtWidgets.QLabel('Offset Z:')
  2840. offsetlabel.setToolTip(
  2841. "Some drill bits (the larger ones) need to drill deeper\n"
  2842. "to create the desired exit hole diameter due of the tip shape.\n"
  2843. "The value here can compensate the Cut Z parameter.")
  2844. grid1.addWidget(offsetlabel, 0, 0)
  2845. self.offset_entry = LengthEntry()
  2846. grid1.addWidget(self.offset_entry, 0, 1)
  2847. toolchange_xy_label = QtWidgets.QLabel('Toolchange X,Y:')
  2848. toolchange_xy_label.setToolTip(
  2849. "Toolchange X,Y position."
  2850. )
  2851. grid1.addWidget(toolchange_xy_label, 1, 0)
  2852. self.toolchangexy_entry = FCEntry()
  2853. grid1.addWidget(self.toolchangexy_entry, 1, 1)
  2854. startzlabel = QtWidgets.QLabel('Start move Z:')
  2855. startzlabel.setToolTip(
  2856. "Height of the tool just after start.\n"
  2857. "Delete the value if you don't need this feature."
  2858. )
  2859. grid1.addWidget(startzlabel, 2, 0)
  2860. self.estartz_entry = FloatEntry()
  2861. grid1.addWidget(self.estartz_entry, 2, 1)
  2862. endzlabel = QtWidgets.QLabel('End move Z:')
  2863. endzlabel.setToolTip(
  2864. "Height of the tool after\n"
  2865. "the last move at the end of the job."
  2866. )
  2867. grid1.addWidget(endzlabel, 3, 0)
  2868. self.eendz_entry = LengthEntry()
  2869. grid1.addWidget(self.eendz_entry, 3, 1)
  2870. fr_rapid_label = QtWidgets.QLabel('Feedrate Rapids:')
  2871. fr_rapid_label.setToolTip(
  2872. "Tool speed while drilling\n"
  2873. "with rapid move\n"
  2874. "(in units per minute)."
  2875. )
  2876. grid1.addWidget(fr_rapid_label, 4, 0)
  2877. self.feedrate_rapid_entry = LengthEntry()
  2878. grid1.addWidget(self.feedrate_rapid_entry, 4, 1)
  2879. # Probe depth
  2880. self.pdepth_label = QtWidgets.QLabel("Probe Z depth:")
  2881. self.pdepth_label.setToolTip(
  2882. "The maximum depth that the probe is allowed\n"
  2883. "to probe. Negative value, in current units."
  2884. )
  2885. grid1.addWidget(self.pdepth_label, 5, 0)
  2886. self.pdepth_entry = FCEntry()
  2887. grid1.addWidget(self.pdepth_entry, 5, 1)
  2888. # Probe feedrate
  2889. self.feedrate_probe_label = QtWidgets.QLabel("Feedrate Probe:")
  2890. self.feedrate_probe_label.setToolTip(
  2891. "The feedrate used while the probe is probing."
  2892. )
  2893. grid1.addWidget(self.feedrate_probe_label, 6, 0)
  2894. self.feedrate_probe_entry = FCEntry()
  2895. grid1.addWidget(self.feedrate_probe_entry, 6, 1)
  2896. fplungelabel = QtWidgets.QLabel('Fast Plunge:')
  2897. fplungelabel.setToolTip(
  2898. "By checking this, the vertical move from\n"
  2899. "Z_Toolchange to Z_move is done with G0,\n"
  2900. "meaning the fastest speed available.\n"
  2901. "WARNING: the move is done at Toolchange X,Y coords."
  2902. )
  2903. self.fplunge_cb = FCCheckBox()
  2904. grid1.addWidget(fplungelabel, 7, 0)
  2905. grid1.addWidget(self.fplunge_cb, 7, 1)
  2906. fretractlabel = QtWidgets.QLabel('Fast Retract:')
  2907. fretractlabel.setToolTip(
  2908. "Exit hole strategy.\n"
  2909. " - When uncheked, while exiting the drilled hole the drill bit\n"
  2910. "will travel slow, with set feedrate (G1), up to zero depth and then\n"
  2911. "travel as fast as possible (G0) to the Z Move (travel height).\n"
  2912. " - When checked the travel from Z cut (cut depth) to Z_move\n"
  2913. "(travel height) is done as fast as possible (G0) in one move."
  2914. )
  2915. self.fretract_cb = FCCheckBox()
  2916. grid1.addWidget(fretractlabel, 8, 0)
  2917. grid1.addWidget(self.fretract_cb, 8, 1)
  2918. self.layout.addStretch()
  2919. def optimization_selection(self):
  2920. if self.excellon_optimization_radio.get_value() == 'M':
  2921. self.optimization_time_label.setDisabled(False)
  2922. self.optimization_time_entry.setDisabled(False)
  2923. else:
  2924. self.optimization_time_label.setDisabled(True)
  2925. self.optimization_time_entry.setDisabled(True)
  2926. class ExcellonOptPrefGroupUI(OptionsGroupUI):
  2927. def __init__(self, parent=None):
  2928. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  2929. super(ExcellonOptPrefGroupUI, self).__init__(self)
  2930. self.setTitle(str("Excellon Options"))
  2931. ## Create CNC Job
  2932. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job</b>')
  2933. self.cncjob_label.setToolTip(
  2934. "Parameters used to create a CNC Job object\n"
  2935. "for this drill object."
  2936. )
  2937. self.layout.addWidget(self.cncjob_label)
  2938. grid2 = QtWidgets.QGridLayout()
  2939. self.layout.addLayout(grid2)
  2940. cutzlabel = QtWidgets.QLabel('Cut Z:')
  2941. cutzlabel.setToolTip(
  2942. "Drill depth (negative)\n"
  2943. "below the copper surface."
  2944. )
  2945. grid2.addWidget(cutzlabel, 0, 0)
  2946. self.cutz_entry = LengthEntry()
  2947. grid2.addWidget(self.cutz_entry, 0, 1)
  2948. travelzlabel = QtWidgets.QLabel('Travel Z:')
  2949. travelzlabel.setToolTip(
  2950. "Tool height when travelling\n"
  2951. "across the XY plane."
  2952. )
  2953. grid2.addWidget(travelzlabel, 1, 0)
  2954. self.travelz_entry = LengthEntry()
  2955. grid2.addWidget(self.travelz_entry, 1, 1)
  2956. # Tool change:
  2957. toolchlabel = QtWidgets.QLabel("Tool change:")
  2958. toolchlabel.setToolTip(
  2959. "Include tool-change sequence\n"
  2960. "in G-Code (Pause for tool change)."
  2961. )
  2962. self.toolchange_cb = FCCheckBox()
  2963. grid2.addWidget(toolchlabel, 2, 0)
  2964. grid2.addWidget(self.toolchange_cb, 2, 1)
  2965. toolchangezlabel = QtWidgets.QLabel('Toolchange Z:')
  2966. toolchangezlabel.setToolTip(
  2967. "Toolchange Z position."
  2968. )
  2969. grid2.addWidget(toolchangezlabel, 3, 0)
  2970. self.toolchangez_entry = LengthEntry()
  2971. grid2.addWidget(self.toolchangez_entry, 3, 1)
  2972. frlabel = QtWidgets.QLabel('Feedrate:')
  2973. frlabel.setToolTip(
  2974. "Tool speed while drilling\n"
  2975. "(in units per minute)."
  2976. )
  2977. grid2.addWidget(frlabel, 4, 0)
  2978. self.feedrate_entry = LengthEntry()
  2979. grid2.addWidget(self.feedrate_entry, 4, 1)
  2980. # Spindle speed
  2981. spdlabel = QtWidgets.QLabel('Spindle Speed:')
  2982. spdlabel.setToolTip(
  2983. "Speed of the spindle\n"
  2984. "in RPM (optional)"
  2985. )
  2986. grid2.addWidget(spdlabel, 5, 0)
  2987. self.spindlespeed_entry = IntEntry(allow_empty=True)
  2988. grid2.addWidget(self.spindlespeed_entry, 5, 1)
  2989. # Dwell
  2990. dwelllabel = QtWidgets.QLabel('Dwell:')
  2991. dwelllabel.setToolTip(
  2992. "Pause to allow the spindle to reach its\n"
  2993. "speed before cutting."
  2994. )
  2995. dwelltime = QtWidgets.QLabel('Duration:')
  2996. dwelltime.setToolTip(
  2997. "Number of milliseconds for spindle to dwell."
  2998. )
  2999. self.dwell_cb = FCCheckBox()
  3000. self.dwelltime_entry = FCEntry()
  3001. grid2.addWidget(dwelllabel, 6, 0)
  3002. grid2.addWidget(self.dwell_cb, 6, 1)
  3003. grid2.addWidget(dwelltime, 7, 0)
  3004. grid2.addWidget(self.dwelltime_entry, 7, 1)
  3005. self.ois_dwell_exc = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  3006. # postprocessor selection
  3007. pp_excellon_label = QtWidgets.QLabel("Postprocessor:")
  3008. pp_excellon_label.setToolTip(
  3009. "The postprocessor file that dictates\n"
  3010. "gcode output."
  3011. )
  3012. grid2.addWidget(pp_excellon_label, 8, 0)
  3013. self.pp_excellon_name_cb = FCComboBox()
  3014. self.pp_excellon_name_cb.setFocusPolicy(Qt.StrongFocus)
  3015. grid2.addWidget(self.pp_excellon_name_cb, 8, 1)
  3016. #### Choose what to use for Gcode creation: Drills, Slots or Both
  3017. excellon_gcode_type_label = QtWidgets.QLabel('<b>Gcode: </b>')
  3018. excellon_gcode_type_label.setToolTip(
  3019. "Choose what to use for GCode generation:\n"
  3020. "'Drills', 'Slots' or 'Both'.\n"
  3021. "When choosing 'Slots' or 'Both', slots will be\n"
  3022. "converted to drills."
  3023. )
  3024. self.excellon_gcode_type_radio = RadioSet([{'label': 'Drills', 'value': 'drills'},
  3025. {'label': 'Slots', 'value': 'slots'},
  3026. {'label': 'Both', 'value': 'both'}])
  3027. grid2.addWidget(excellon_gcode_type_label, 9, 0)
  3028. grid2.addWidget(self.excellon_gcode_type_radio, 9, 1)
  3029. # until I decide to implement this feature those remain disabled
  3030. excellon_gcode_type_label.hide()
  3031. self.excellon_gcode_type_radio.setVisible(False)
  3032. #### Milling Holes ####
  3033. self.mill_hole_label = QtWidgets.QLabel('<b>Mill Holes</b>')
  3034. self.mill_hole_label.setToolTip(
  3035. "Create Geometry for milling holes."
  3036. )
  3037. self.layout.addWidget(self.mill_hole_label)
  3038. grid3 = QtWidgets.QGridLayout()
  3039. self.layout.addLayout(grid3)
  3040. tdlabel = QtWidgets.QLabel('Drill Tool dia:')
  3041. tdlabel.setToolTip(
  3042. "Diameter of the cutting tool."
  3043. )
  3044. grid3.addWidget(tdlabel, 0, 0)
  3045. self.tooldia_entry = LengthEntry()
  3046. grid3.addWidget(self.tooldia_entry, 0, 1)
  3047. stdlabel = QtWidgets.QLabel('Slot Tool dia:')
  3048. stdlabel.setToolTip(
  3049. "Diameter of the cutting tool\n"
  3050. "when milling slots."
  3051. )
  3052. grid3.addWidget(stdlabel, 1, 0)
  3053. self.slot_tooldia_entry = LengthEntry()
  3054. grid3.addWidget(self.slot_tooldia_entry, 1, 1)
  3055. grid4 = QtWidgets.QGridLayout()
  3056. self.layout.addLayout(grid4)
  3057. # Adding the Excellon Format Defaults Button
  3058. self.excellon_defaults_button = QtWidgets.QPushButton()
  3059. self.excellon_defaults_button.setText(str("Defaults"))
  3060. self.excellon_defaults_button.setFixedWidth(80)
  3061. grid4.addWidget(self.excellon_defaults_button, 0, 0, QtCore.Qt.AlignRight)
  3062. self.layout.addStretch()
  3063. class ExcellonExpPrefGroupUI(OptionsGroupUI):
  3064. def __init__(self, parent=None):
  3065. super(ExcellonExpPrefGroupUI, self).__init__(self)
  3066. self.setTitle(str("Excellon Export"))
  3067. # Plot options
  3068. self.export_options_label = QtWidgets.QLabel("<b>Export Options:</b>")
  3069. self.export_options_label.setToolTip(
  3070. "The parameters set here are used in the file exported<cr>"
  3071. "when using the <b>File -> Export -> Export Excellon</b> menu entry."
  3072. )
  3073. self.layout.addWidget(self.export_options_label)
  3074. form = QtWidgets.QFormLayout()
  3075. self.layout.addLayout(form)
  3076. # Excellon Units
  3077. self.excellon_units_label = QtWidgets.QLabel('<b>Units</b>:')
  3078. self.excellon_units_label.setToolTip(
  3079. "The units used in the Excellon file."
  3080. )
  3081. self.excellon_units_radio = RadioSet([{'label': 'INCH', 'value': 'INCH'}, {'label': 'MM', 'value': 'METRIC'}])
  3082. self.excellon_units_radio.setToolTip(
  3083. "The units used in the Excellon file."
  3084. )
  3085. form.addRow(self.excellon_units_label, self.excellon_units_radio)
  3086. # Excellon non-decimal format
  3087. self.digits_label = QtWidgets.QLabel("<b>Int/Decimals:</b>")
  3088. self.digits_label.setToolTip(
  3089. "The NC drill files, usually named Excellon files\n"
  3090. "are files that can be found in different formats.\n"
  3091. "Here we set the format used when the provided\n"
  3092. "coordinates are not using period."
  3093. )
  3094. hlay1 = QtWidgets.QHBoxLayout()
  3095. self.format_whole_entry = IntEntry()
  3096. self.format_whole_entry.setMaxLength(1)
  3097. self.format_whole_entry.setAlignment(QtCore.Qt.AlignRight)
  3098. self.format_whole_entry.setFixedWidth(30)
  3099. self.format_whole_entry.setToolTip(
  3100. "This numbers signify the number of digits in\n"
  3101. "the whole part of Excellon coordinates."
  3102. )
  3103. hlay1.addWidget(self.format_whole_entry, QtCore.Qt.AlignLeft)
  3104. excellon_separator_label= QtWidgets.QLabel(':')
  3105. excellon_separator_label.setFixedWidth(5)
  3106. hlay1.addWidget(excellon_separator_label, QtCore.Qt.AlignLeft)
  3107. self.format_dec_entry = IntEntry()
  3108. self.format_dec_entry.setMaxLength(1)
  3109. self.format_dec_entry.setAlignment(QtCore.Qt.AlignRight)
  3110. self.format_dec_entry.setFixedWidth(30)
  3111. self.format_dec_entry.setToolTip(
  3112. "This numbers signify the number of digits in\n"
  3113. "the decimal part of Excellon coordinates."
  3114. )
  3115. hlay1.addWidget(self.format_dec_entry, QtCore.Qt.AlignLeft)
  3116. hlay1.addStretch()
  3117. form.addRow(self.digits_label, hlay1)
  3118. # Select the Excellon Format
  3119. self.format_label = QtWidgets.QLabel("<b>Format:</b>")
  3120. self.format_label.setToolTip(
  3121. "Select the kind of coordinates format used.\n"
  3122. "Coordinates can be saved with decimal point or without.\n"
  3123. "When there is no decimal point, it is required to specify\n"
  3124. "the number of digits for integer part and the number of decimals.\n"
  3125. "Also it will have to be specified if LZ = leading zeros are kept\n"
  3126. "or TZ = trailing zeros are kept."
  3127. )
  3128. self.format_radio = RadioSet([{'label': 'Decimal', 'value': 'dec'}, {'label': 'No-Decimal', 'value': 'ndec'}])
  3129. self.format_radio.setToolTip(
  3130. "Select the kind of coordinates format used.\n"
  3131. "Coordinates can be saved with decimal point or without.\n"
  3132. "When there is no decimal point, it is required to specify\n"
  3133. "the number of digits for integer part and the number of decimals.\n"
  3134. "Also it will have to be specified if LZ = leading zeros are kept\n"
  3135. "or TZ = trailing zeros are kept."
  3136. )
  3137. form.addRow(self.format_label, self.format_radio)
  3138. # Excellon Zeros
  3139. self.zeros_label = QtWidgets.QLabel('<b>Zeros</b>:')
  3140. self.zeros_label.setAlignment(QtCore.Qt.AlignLeft)
  3141. self.zeros_label.setToolTip(
  3142. "This sets the type of Excellon zeros.\n"
  3143. "If LZ then Leading Zeros are kept and\n"
  3144. "Trailing Zeros are removed.\n"
  3145. "If TZ is checked then Trailing Zeros are kept\n"
  3146. "and Leading Zeros are removed."
  3147. )
  3148. self.zeros_radio = RadioSet([{'label': 'LZ', 'value': 'LZ'},
  3149. {'label': 'TZ', 'value': 'TZ'}])
  3150. self.zeros_radio.setToolTip(
  3151. "This sets the default type of Excellon zeros.\n"
  3152. "If LZ then Leading Zeros are kept and\n"
  3153. "Trailing Zeros are removed.\n"
  3154. "If TZ is checked then Trailing Zeros are kept\n"
  3155. "and Leading Zeros are removed."
  3156. )
  3157. form.addRow(self.zeros_label, self.zeros_radio)
  3158. self.layout.addStretch()
  3159. self.format_radio.activated_custom.connect(self.optimization_selection)
  3160. def optimization_selection(self):
  3161. if self.format_radio.get_value() == 'dec':
  3162. self.zeros_label.setDisabled(True)
  3163. self.zeros_radio.setDisabled(True)
  3164. else:
  3165. self.zeros_label.setDisabled(False)
  3166. self.zeros_radio.setDisabled(False)
  3167. class GeometryGenPrefGroupUI(OptionsGroupUI):
  3168. def __init__(self, parent=None):
  3169. # OptionsGroupUI.__init__(self, "Geometry General Preferences", parent=parent)
  3170. super(GeometryGenPrefGroupUI, self).__init__(self)
  3171. self.setTitle(str("Geometry General"))
  3172. ## Plot options
  3173. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  3174. self.layout.addWidget(self.plot_options_label)
  3175. # Plot CB
  3176. self.plot_cb = FCCheckBox(label='Plot')
  3177. self.plot_cb.setToolTip(
  3178. "Plot (show) this object."
  3179. )
  3180. self.layout.addWidget(self.plot_cb)
  3181. grid0 = QtWidgets.QGridLayout()
  3182. self.layout.addLayout(grid0)
  3183. # Number of circle steps for circular aperture linear approximation
  3184. self.circle_steps_label = QtWidgets.QLabel("Circle Steps:")
  3185. self.circle_steps_label.setToolTip(
  3186. "The number of circle steps for <b>Geometry</b> \n"
  3187. "circle and arc shapes linear approximation."
  3188. )
  3189. grid0.addWidget(self.circle_steps_label, 1, 0)
  3190. self.circle_steps_entry = IntEntry()
  3191. grid0.addWidget(self.circle_steps_entry, 1, 1)
  3192. # Tools
  3193. self.tools_label = QtWidgets.QLabel("<b>Tools</b>")
  3194. self.layout.addWidget(self.tools_label)
  3195. grid0_b = QtWidgets.QGridLayout()
  3196. self.layout.addLayout(grid0_b)
  3197. # Tooldia
  3198. tdlabel = QtWidgets.QLabel('Tool dia: ')
  3199. tdlabel.setToolTip(
  3200. "The diameter of the cutting\n"
  3201. "tool.."
  3202. )
  3203. grid0_b.addWidget(tdlabel, 0, 0)
  3204. self.cnctooldia_entry = LengthEntry()
  3205. grid0_b.addWidget(self.cnctooldia_entry, 0, 1)
  3206. # ------------------------------
  3207. ## Create CNC Job
  3208. # ------------------------------
  3209. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job:</b>')
  3210. self.cncjob_label.setToolTip(
  3211. "Parameters to create a CNC Job object\n"
  3212. "tracing the contours of a Geometry object."
  3213. )
  3214. self.layout.addWidget(self.cncjob_label)
  3215. grid1 = QtWidgets.QGridLayout()
  3216. self.layout.addLayout(grid1)
  3217. # Toolchange X,Y
  3218. toolchange_xy_label = QtWidgets.QLabel('Toolchange X,Y:')
  3219. toolchange_xy_label.setToolTip(
  3220. "Toolchange X,Y position."
  3221. )
  3222. grid1.addWidget(toolchange_xy_label, 1, 0)
  3223. self.toolchangexy_entry = FCEntry()
  3224. grid1.addWidget(self.toolchangexy_entry, 1, 1)
  3225. # Start move Z
  3226. startzlabel = QtWidgets.QLabel('Start move Z:')
  3227. startzlabel.setToolTip(
  3228. "Height of the tool just after starting the work.\n"
  3229. "Delete the value if you don't need this feature."
  3230. )
  3231. grid1.addWidget(startzlabel, 2, 0)
  3232. self.gstartz_entry = FloatEntry()
  3233. grid1.addWidget(self.gstartz_entry, 2, 1)
  3234. # End move Z
  3235. endzlabel = QtWidgets.QLabel('End move Z:')
  3236. endzlabel.setToolTip(
  3237. "Height of the tool after\n"
  3238. "the last move at the end of the job."
  3239. )
  3240. grid1.addWidget(endzlabel, 3, 0)
  3241. self.gendz_entry = LengthEntry()
  3242. grid1.addWidget(self.gendz_entry, 3, 1)
  3243. # Feedrate rapids
  3244. fr_rapid_label = QtWidgets.QLabel('Feedrate Rapids:')
  3245. fr_rapid_label.setToolTip(
  3246. "Cutting speed in the XY\n"
  3247. "plane in units per minute"
  3248. )
  3249. grid1.addWidget(fr_rapid_label, 4, 0)
  3250. self.cncfeedrate_rapid_entry = LengthEntry()
  3251. grid1.addWidget(self.cncfeedrate_rapid_entry, 4, 1)
  3252. # End move extra cut
  3253. self.extracut_cb = FCCheckBox(label='Re-cut 1st pt.')
  3254. self.extracut_cb.setToolTip(
  3255. "In order to remove possible\n"
  3256. "copper leftovers where first cut\n"
  3257. "meet with last cut, we generate an\n"
  3258. "extended cut over the first cut section."
  3259. )
  3260. grid1.addWidget(self.extracut_cb, 5, 0)
  3261. # Probe depth
  3262. self.pdepth_label = QtWidgets.QLabel("Probe Z depth:")
  3263. self.pdepth_label.setToolTip(
  3264. "The maximum depth that the probe is allowed\n"
  3265. "to probe. Negative value, in current units."
  3266. )
  3267. grid1.addWidget(self.pdepth_label, 6, 0)
  3268. self.pdepth_entry = FCEntry()
  3269. grid1.addWidget(self.pdepth_entry, 6, 1)
  3270. # Probe feedrate
  3271. self.feedrate_probe_label = QtWidgets.QLabel("Feedrate Probe:")
  3272. self.feedrate_probe_label.setToolTip(
  3273. "The feedrate used while the probe is probing."
  3274. )
  3275. grid1.addWidget(self.feedrate_probe_label, 7, 0)
  3276. self.feedrate_probe_entry = FCEntry()
  3277. grid1.addWidget(self.feedrate_probe_entry, 7, 1)
  3278. # Fast Move from Z Toolchange
  3279. fplungelabel = QtWidgets.QLabel('Fast Plunge:')
  3280. fplungelabel.setToolTip(
  3281. "By checking this, the vertical move from\n"
  3282. "Z_Toolchange to Z_move is done with G0,\n"
  3283. "meaning the fastest speed available.\n"
  3284. "WARNING: the move is done at Toolchange X,Y coords."
  3285. )
  3286. self.fplunge_cb = FCCheckBox()
  3287. grid1.addWidget(fplungelabel, 8, 0)
  3288. grid1.addWidget(self.fplunge_cb, 8, 1)
  3289. # Size of trace segment on X axis
  3290. segx_label = QtWidgets.QLabel("Seg. X size:")
  3291. segx_label.setToolTip(
  3292. "The size of the trace segment on the X axis.\n"
  3293. "Useful for auto-leveling.\n"
  3294. "A value of 0 means no segmentation on the X axis."
  3295. )
  3296. grid1.addWidget(segx_label, 9, 0)
  3297. self.segx_entry = FCEntry()
  3298. grid1.addWidget(self.segx_entry, 9, 1)
  3299. # Size of trace segment on Y axis
  3300. segy_label = QtWidgets.QLabel("Seg. Y size:")
  3301. segy_label.setToolTip(
  3302. "The size of the trace segment on the Y axis.\n"
  3303. "Useful for auto-leveling.\n"
  3304. "A value of 0 means no segmentation on the Y axis."
  3305. )
  3306. grid1.addWidget(segy_label, 10, 0)
  3307. self.segy_entry = FCEntry()
  3308. grid1.addWidget(self.segy_entry, 10, 1)
  3309. self.layout.addStretch()
  3310. class GeometryOptPrefGroupUI(OptionsGroupUI):
  3311. def __init__(self, parent=None):
  3312. # OptionsGroupUI.__init__(self, "Geometry Options Preferences", parent=parent)
  3313. super(GeometryOptPrefGroupUI, self).__init__(self)
  3314. self.setTitle(str("Geometry Options"))
  3315. # ------------------------------
  3316. ## Create CNC Job
  3317. # ------------------------------
  3318. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job:</b>')
  3319. self.cncjob_label.setToolTip(
  3320. "Create a CNC Job object\n"
  3321. "tracing the contours of this\n"
  3322. "Geometry object."
  3323. )
  3324. self.layout.addWidget(self.cncjob_label)
  3325. grid1 = QtWidgets.QGridLayout()
  3326. self.layout.addLayout(grid1)
  3327. # Cut Z
  3328. cutzlabel = QtWidgets.QLabel('Cut Z:')
  3329. cutzlabel.setToolTip(
  3330. "Cutting depth (negative)\n"
  3331. "below the copper surface."
  3332. )
  3333. grid1.addWidget(cutzlabel, 0, 0)
  3334. self.cutz_entry = LengthEntry()
  3335. grid1.addWidget(self.cutz_entry, 0, 1)
  3336. # Multidepth CheckBox
  3337. self.multidepth_cb = FCCheckBox(label='Multidepth')
  3338. self.multidepth_cb.setToolTip(
  3339. "Multidepth usage: True or False."
  3340. )
  3341. grid1.addWidget(self.multidepth_cb, 1, 0)
  3342. # Depth/pass
  3343. dplabel = QtWidgets.QLabel('Depth/Pass:')
  3344. dplabel.setToolTip(
  3345. "The depth to cut on each pass,\n"
  3346. "when multidepth is enabled.\n"
  3347. "It has positive value although\n"
  3348. "it is a fraction from the depth\n"
  3349. "which has negative value."
  3350. )
  3351. grid1.addWidget(dplabel, 2, 0)
  3352. self.depthperpass_entry = LengthEntry()
  3353. grid1.addWidget(self.depthperpass_entry, 2, 1)
  3354. self.ois_multidepth = OptionalInputSection(self.multidepth_cb, [self.depthperpass_entry])
  3355. # Travel Z
  3356. travelzlabel = QtWidgets.QLabel('Travel Z:')
  3357. travelzlabel.setToolTip(
  3358. "Height of the tool when\n"
  3359. "moving without cutting."
  3360. )
  3361. grid1.addWidget(travelzlabel, 3, 0)
  3362. self.travelz_entry = LengthEntry()
  3363. grid1.addWidget(self.travelz_entry, 3, 1)
  3364. # Tool change:
  3365. toolchlabel = QtWidgets.QLabel("Tool change:")
  3366. toolchlabel.setToolTip(
  3367. "Include tool-change sequence\n"
  3368. "in G-Code (Pause for tool change)."
  3369. )
  3370. self.toolchange_cb = FCCheckBox()
  3371. grid1.addWidget(toolchlabel, 4, 0)
  3372. grid1.addWidget(self.toolchange_cb, 4, 1)
  3373. # Toolchange Z
  3374. toolchangezlabel = QtWidgets.QLabel('Toolchange Z:')
  3375. toolchangezlabel.setToolTip(
  3376. "Toolchange Z position."
  3377. )
  3378. grid1.addWidget(toolchangezlabel, 5, 0)
  3379. self.toolchangez_entry = LengthEntry()
  3380. grid1.addWidget(self.toolchangez_entry, 5, 1)
  3381. # Feedrate X-Y
  3382. frlabel = QtWidgets.QLabel('Feed Rate X-Y:')
  3383. frlabel.setToolTip(
  3384. "Cutting speed in the XY\n"
  3385. "plane in units per minute"
  3386. )
  3387. grid1.addWidget(frlabel, 6, 0)
  3388. self.cncfeedrate_entry = LengthEntry()
  3389. grid1.addWidget(self.cncfeedrate_entry, 6, 1)
  3390. # Feedrate Z (Plunge)
  3391. frz_label = QtWidgets.QLabel('Feed Rate Z:')
  3392. frz_label.setToolTip(
  3393. "Cutting speed in the XY\n"
  3394. "plane in units per minute.\n"
  3395. "It is called also Plunge."
  3396. )
  3397. grid1.addWidget(frz_label, 7, 0)
  3398. self.cncplunge_entry = LengthEntry()
  3399. grid1.addWidget(self.cncplunge_entry, 7, 1)
  3400. # Spindle Speed
  3401. spdlabel = QtWidgets.QLabel('Spindle speed:')
  3402. spdlabel.setToolTip(
  3403. "Speed of the spindle\n"
  3404. "in RPM (optional)"
  3405. )
  3406. grid1.addWidget(spdlabel, 8, 0)
  3407. self.cncspindlespeed_entry = IntEntry(allow_empty=True)
  3408. grid1.addWidget(self.cncspindlespeed_entry, 8, 1)
  3409. # Dwell
  3410. self.dwell_cb = FCCheckBox(label='Dwell:')
  3411. self.dwell_cb.setToolTip(
  3412. "Pause to allow the spindle to reach its\n"
  3413. "speed before cutting."
  3414. )
  3415. dwelltime = QtWidgets.QLabel('Duration:')
  3416. dwelltime.setToolTip(
  3417. "Number of milliseconds for spindle to dwell."
  3418. )
  3419. self.dwelltime_entry = FCEntry()
  3420. grid1.addWidget(self.dwell_cb, 9, 0)
  3421. grid1.addWidget(dwelltime, 10, 0)
  3422. grid1.addWidget(self.dwelltime_entry, 10, 1)
  3423. self.ois_dwell = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  3424. # postprocessor selection
  3425. pp_label = QtWidgets.QLabel("Postprocessor:")
  3426. pp_label.setToolTip(
  3427. "The postprocessor file that dictates\n"
  3428. "Machine Code output."
  3429. )
  3430. grid1.addWidget(pp_label, 11, 0)
  3431. self.pp_geometry_name_cb = FCComboBox()
  3432. self.pp_geometry_name_cb.setFocusPolicy(Qt.StrongFocus)
  3433. grid1.addWidget(self.pp_geometry_name_cb, 11, 1)
  3434. self.layout.addStretch()
  3435. class CNCJobGenPrefGroupUI(OptionsGroupUI):
  3436. def __init__(self, parent=None):
  3437. # OptionsGroupUI.__init__(self, "CNC Job General Preferences", parent=None)
  3438. super(CNCJobGenPrefGroupUI, self).__init__(self)
  3439. self.setTitle(str("CNC Job General"))
  3440. ## Plot options
  3441. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  3442. self.layout.addWidget(self.plot_options_label)
  3443. grid0 = QtWidgets.QGridLayout()
  3444. self.layout.addLayout(grid0)
  3445. grid0.setColumnStretch(1, 1)
  3446. grid0.setColumnStretch(2, 1)
  3447. # Plot CB
  3448. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  3449. self.plot_cb = FCCheckBox('Plot Object')
  3450. self.plot_cb.setToolTip(
  3451. "Plot (show) this object."
  3452. )
  3453. grid0.addWidget(self.plot_cb, 0, 0)
  3454. # Plot Kind
  3455. self.cncplot_method_label = QtWidgets.QLabel("Plot kind:")
  3456. self.cncplot_method_label.setToolTip(
  3457. "This selects the kind of geometries on the canvas to plot.\n"
  3458. "Those can be either of type 'Travel' which means the moves\n"
  3459. "above the work piece or it can be of type 'Cut',\n"
  3460. "which means the moves that cut into the material."
  3461. )
  3462. self.cncplot_method_radio = RadioSet([
  3463. {"label": "All", "value": "all"},
  3464. {"label": "Travel", "value": "travel"},
  3465. {"label": "Cut", "value": "cut"}
  3466. ], stretch=False)
  3467. grid0.addWidget(self.cncplot_method_label, 1, 0)
  3468. grid0.addWidget(self.cncplot_method_radio, 1, 1)
  3469. grid0.addWidget(QtWidgets.QLabel(''), 1, 2)
  3470. # Number of circle steps for circular aperture linear approximation
  3471. self.steps_per_circle_label = QtWidgets.QLabel("Circle Steps:")
  3472. self.steps_per_circle_label.setToolTip(
  3473. "The number of circle steps for <b>GCode</b> \n"
  3474. "circle and arc shapes linear approximation."
  3475. )
  3476. grid0.addWidget(self.steps_per_circle_label, 2, 0)
  3477. self.steps_per_circle_entry = IntEntry()
  3478. grid0.addWidget(self.steps_per_circle_entry, 2, 1)
  3479. # Tool dia for plot
  3480. tdlabel = QtWidgets.QLabel('Tool dia:')
  3481. tdlabel.setToolTip(
  3482. "Diameter of the tool to be\n"
  3483. "rendered in the plot."
  3484. )
  3485. grid0.addWidget(tdlabel, 3, 0)
  3486. self.tooldia_entry = LengthEntry()
  3487. grid0.addWidget(self.tooldia_entry, 3, 1)
  3488. # Number of decimals to use in GCODE coordinates
  3489. cdeclabel = QtWidgets.QLabel('Coords dec.:')
  3490. cdeclabel.setToolTip(
  3491. "The number of decimals to be used for \n"
  3492. "the X, Y, Z coordinates in CNC code (GCODE, etc.)"
  3493. )
  3494. grid0.addWidget(cdeclabel, 4, 0)
  3495. self.coords_dec_entry = IntEntry()
  3496. grid0.addWidget(self.coords_dec_entry, 4, 1)
  3497. # Number of decimals to use in GCODE feedrate
  3498. frdeclabel = QtWidgets.QLabel('Feedrate dec.:')
  3499. frdeclabel.setToolTip(
  3500. "The number of decimals to be used for \n"
  3501. "the Feedrate parameter in CNC code (GCODE, etc.)"
  3502. )
  3503. grid0.addWidget(frdeclabel, 5, 0)
  3504. self.fr_dec_entry = IntEntry()
  3505. grid0.addWidget(self.fr_dec_entry, 5, 1)
  3506. self.layout.addStretch()
  3507. class CNCJobOptPrefGroupUI(OptionsGroupUI):
  3508. def __init__(self, parent=None):
  3509. # OptionsGroupUI.__init__(self, "CNC Job Options Preferences", parent=None)
  3510. super(CNCJobOptPrefGroupUI, self).__init__(self)
  3511. self.setTitle(str("CNC Job Options"))
  3512. ## Export G-Code
  3513. self.export_gcode_label = QtWidgets.QLabel("<b>Export G-Code:</b>")
  3514. self.export_gcode_label.setToolTip(
  3515. "Export and save G-Code to\n"
  3516. "make this object to a file."
  3517. )
  3518. self.layout.addWidget(self.export_gcode_label)
  3519. # Prepend to G-Code
  3520. prependlabel = QtWidgets.QLabel('Prepend to G-Code:')
  3521. prependlabel.setToolTip(
  3522. "Type here any G-Code commands you would\n"
  3523. "like to add at the beginning of the G-Code file."
  3524. )
  3525. self.layout.addWidget(prependlabel)
  3526. self.prepend_text = FCTextArea()
  3527. self.layout.addWidget(self.prepend_text)
  3528. # Append text to G-Code
  3529. appendlabel = QtWidgets.QLabel('Append to G-Code:')
  3530. appendlabel.setToolTip(
  3531. "Type here any G-Code commands you would\n"
  3532. "like to append to the generated file.\n"
  3533. "I.e.: M2 (End of program)"
  3534. )
  3535. self.layout.addWidget(appendlabel)
  3536. self.append_text = FCTextArea()
  3537. self.layout.addWidget(self.append_text)
  3538. self.layout.addStretch()
  3539. class ToolsNCCPrefGroupUI(OptionsGroupUI):
  3540. def __init__(self, parent=None):
  3541. # OptionsGroupUI.__init__(self, "NCC Tool Options", parent=parent)
  3542. super(ToolsNCCPrefGroupUI, self).__init__(self)
  3543. self.setTitle(str("NCC Tool Options"))
  3544. ## Clear non-copper regions
  3545. self.clearcopper_label = QtWidgets.QLabel("<b>Parameters:</b>")
  3546. self.clearcopper_label.setToolTip(
  3547. "Create a Geometry object with\n"
  3548. "toolpaths to cut all non-copper regions."
  3549. )
  3550. self.layout.addWidget(self.clearcopper_label)
  3551. grid0 = QtWidgets.QGridLayout()
  3552. self.layout.addLayout(grid0)
  3553. ncctdlabel = QtWidgets.QLabel('Tools dia:')
  3554. ncctdlabel.setToolTip(
  3555. "Diameters of the cutting tools, separated by ','"
  3556. )
  3557. grid0.addWidget(ncctdlabel, 0, 0)
  3558. self.ncc_tool_dia_entry = FCEntry()
  3559. grid0.addWidget(self.ncc_tool_dia_entry, 0, 1)
  3560. nccoverlabel = QtWidgets.QLabel('Overlap:')
  3561. nccoverlabel.setToolTip(
  3562. "How much (fraction) of the tool width to overlap each tool pass.\n"
  3563. "Example:\n"
  3564. "A value here of 0.25 means 25% from the tool diameter found above.\n\n"
  3565. "Adjust the value starting with lower values\n"
  3566. "and increasing it if areas that should be cleared are still \n"
  3567. "not cleared.\n"
  3568. "Lower values = faster processing, faster execution on PCB.\n"
  3569. "Higher values = slow processing and slow execution on CNC\n"
  3570. "due of too many paths."
  3571. )
  3572. grid0.addWidget(nccoverlabel, 1, 0)
  3573. self.ncc_overlap_entry = FloatEntry()
  3574. grid0.addWidget(self.ncc_overlap_entry, 1, 1)
  3575. nccmarginlabel = QtWidgets.QLabel('Margin:')
  3576. nccmarginlabel.setToolTip(
  3577. "Bounding box margin."
  3578. )
  3579. grid0.addWidget(nccmarginlabel, 2, 0)
  3580. self.ncc_margin_entry = FloatEntry()
  3581. grid0.addWidget(self.ncc_margin_entry, 2, 1)
  3582. # Method
  3583. methodlabel = QtWidgets.QLabel('Method:')
  3584. methodlabel.setToolTip(
  3585. "Algorithm for non-copper clearing:<BR>"
  3586. "<B>Standard</B>: Fixed step inwards.<BR>"
  3587. "<B>Seed-based</B>: Outwards from seed.<BR>"
  3588. "<B>Line-based</B>: Parallel lines."
  3589. )
  3590. grid0.addWidget(methodlabel, 3, 0)
  3591. self.ncc_method_radio = RadioSet([
  3592. {"label": "Standard", "value": "standard"},
  3593. {"label": "Seed-based", "value": "seed"},
  3594. {"label": "Straight lines", "value": "lines"}
  3595. ], orientation='vertical', stretch=False)
  3596. grid0.addWidget(self.ncc_method_radio, 3, 1)
  3597. # Connect lines
  3598. pathconnectlabel = QtWidgets.QLabel("Connect:")
  3599. pathconnectlabel.setToolTip(
  3600. "Draw lines between resulting\n"
  3601. "segments to minimize tool lifts."
  3602. )
  3603. grid0.addWidget(pathconnectlabel, 4, 0)
  3604. self.ncc_connect_cb = FCCheckBox()
  3605. grid0.addWidget(self.ncc_connect_cb, 4, 1)
  3606. contourlabel = QtWidgets.QLabel("Contour:")
  3607. contourlabel.setToolTip(
  3608. "Cut around the perimeter of the polygon\n"
  3609. "to trim rough edges."
  3610. )
  3611. grid0.addWidget(contourlabel, 5, 0)
  3612. self.ncc_contour_cb = FCCheckBox()
  3613. grid0.addWidget(self.ncc_contour_cb, 5, 1)
  3614. restlabel = QtWidgets.QLabel("Rest M.:")
  3615. restlabel.setToolTip(
  3616. "If checked, use 'rest machining'.\n"
  3617. "Basically it will clear copper outside PCB features,\n"
  3618. "using the biggest tool and continue with the next tools,\n"
  3619. "from bigger to smaller, to clear areas of copper that\n"
  3620. "could not be cleared by previous tool.\n"
  3621. "If not checked, use the standard algorithm."
  3622. )
  3623. grid0.addWidget(restlabel, 6, 0)
  3624. self.ncc_rest_cb = FCCheckBox()
  3625. grid0.addWidget(self.ncc_rest_cb, 6, 1)
  3626. self.layout.addStretch()
  3627. class ToolsCutoutPrefGroupUI(OptionsGroupUI):
  3628. def __init__(self, parent=None):
  3629. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  3630. super(ToolsCutoutPrefGroupUI, self).__init__(self)
  3631. self.setTitle(str("Cutout Tool Options"))
  3632. ## Board cuttout
  3633. self.board_cutout_label = QtWidgets.QLabel("<b>Parameters:</b>")
  3634. self.board_cutout_label.setToolTip(
  3635. "Create toolpaths to cut around\n"
  3636. "the PCB and separate it from\n"
  3637. "the original board."
  3638. )
  3639. self.layout.addWidget(self.board_cutout_label)
  3640. grid0 = QtWidgets.QGridLayout()
  3641. self.layout.addLayout(grid0)
  3642. tdclabel = QtWidgets.QLabel('Tool dia:')
  3643. tdclabel.setToolTip(
  3644. "Diameter of the cutting tool."
  3645. )
  3646. grid0.addWidget(tdclabel, 0, 0)
  3647. self.cutout_tooldia_entry = LengthEntry()
  3648. grid0.addWidget(self.cutout_tooldia_entry, 0, 1)
  3649. marginlabel = QtWidgets.QLabel('Margin:')
  3650. marginlabel.setToolTip(
  3651. "Distance from objects at which\n"
  3652. "to draw the cutout."
  3653. )
  3654. grid0.addWidget(marginlabel, 1, 0)
  3655. self.cutout_margin_entry = LengthEntry()
  3656. grid0.addWidget(self.cutout_margin_entry, 1, 1)
  3657. gaplabel = QtWidgets.QLabel('Gap size:')
  3658. gaplabel.setToolTip(
  3659. "Size of the gaps in the toolpath\n"
  3660. "that will remain to hold the\n"
  3661. "board in place."
  3662. )
  3663. grid0.addWidget(gaplabel, 2, 0)
  3664. self.cutout_gap_entry = LengthEntry()
  3665. grid0.addWidget(self.cutout_gap_entry, 2, 1)
  3666. gapslabel = QtWidgets.QLabel('Gaps Rect:')
  3667. gapslabel.setToolTip(
  3668. "Where to place the gaps when doing a Rectangular Cutout:\n"
  3669. " - 2 (T/B) --> Top/Bottom\n"
  3670. " - 2 (L/R) --> Left/Rigt\n"
  3671. " - 4 --> on each of all 4 sides."
  3672. )
  3673. grid0.addWidget(gapslabel, 3, 0)
  3674. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  3675. {'label': '2 (L/R)', 'value': 'lr'},
  3676. {'label': '4', 'value': '4'}])
  3677. grid0.addWidget(self.gaps_radio, 3, 1)
  3678. gaps_ff_label = QtWidgets.QLabel('Gaps FF:')
  3679. gaps_ff_label.setToolTip(
  3680. "Number of gaps used for the FreeForm cutout.\n"
  3681. "There can be maximum 8 bridges/gaps.\n"
  3682. "The choices are:\n"
  3683. "- lr - left + right\n"
  3684. "- tb - top + bottom\n"
  3685. "- 4 - left + right +top + bottom\n"
  3686. "- 2lr - 2*left + 2*right\n"
  3687. "- 2tb - 2*top + 2*bottom\n"
  3688. "- 8 - 2*left + 2*right +2*top + 2*bottom"
  3689. )
  3690. grid0.addWidget(gaps_ff_label, 4, 0)
  3691. self.gaps_combo = FCComboBox()
  3692. grid0.addWidget(self.gaps_combo, 4, 1)
  3693. gaps_items = ['LR', 'TB', '4', '2LR', '2TB', '8']
  3694. for it in gaps_items:
  3695. self.gaps_combo.addItem(it)
  3696. self.gaps_combo.setStyleSheet('background-color: rgb(255,255,255)')
  3697. self.layout.addStretch()
  3698. class Tools2sidedPrefGroupUI(OptionsGroupUI):
  3699. def __init__(self, parent=None):
  3700. # OptionsGroupUI.__init__(self, "2sided Tool Options", parent=parent)
  3701. super(Tools2sidedPrefGroupUI, self).__init__(self)
  3702. self.setTitle(str("2Sided Tool Options"))
  3703. ## Board cuttout
  3704. self.dblsided_label = QtWidgets.QLabel("<b>Parameters:</b>")
  3705. self.dblsided_label.setToolTip(
  3706. "A tool to help in creating a double sided\n"
  3707. "PCB using alignment holes."
  3708. )
  3709. self.layout.addWidget(self.dblsided_label)
  3710. grid0 = QtWidgets.QGridLayout()
  3711. self.layout.addLayout(grid0)
  3712. ## Drill diameter for alignment holes
  3713. self.drill_dia_entry = LengthEntry()
  3714. self.dd_label = QtWidgets.QLabel("Drill diam.:")
  3715. self.dd_label.setToolTip(
  3716. "Diameter of the drill for the "
  3717. "alignment holes."
  3718. )
  3719. grid0.addWidget(self.dd_label, 0, 0)
  3720. grid0.addWidget(self.drill_dia_entry, 0, 1)
  3721. ## Axis
  3722. self.mirror_axis_radio = RadioSet([{'label': 'X', 'value': 'X'},
  3723. {'label': 'Y', 'value': 'Y'}])
  3724. self.mirax_label = QtWidgets.QLabel("Mirror Axis:")
  3725. self.mirax_label.setToolTip(
  3726. "Mirror vertically (X) or horizontally (Y)."
  3727. )
  3728. # grid_lay.addRow("Mirror Axis:", self.mirror_axis)
  3729. self.empty_lb1 = QtWidgets.QLabel("")
  3730. grid0.addWidget(self.empty_lb1, 1, 0)
  3731. grid0.addWidget(self.mirax_label, 2, 0)
  3732. grid0.addWidget(self.mirror_axis_radio, 2, 1)
  3733. ## Axis Location
  3734. self.axis_location_radio = RadioSet([{'label': 'Point', 'value': 'point'},
  3735. {'label': 'Box', 'value': 'box'}])
  3736. self.axloc_label = QtWidgets.QLabel("Axis Ref:")
  3737. self.axloc_label.setToolTip(
  3738. "The axis should pass through a <b>point</b> or cut\n "
  3739. "a specified <b>box</b> (in a Geometry object) in \n"
  3740. "the middle."
  3741. )
  3742. # grid_lay.addRow("Axis Location:", self.axis_location)
  3743. grid0.addWidget(self.axloc_label, 3, 0)
  3744. grid0.addWidget(self.axis_location_radio, 3, 1)
  3745. self.layout.addStretch()
  3746. class ToolsPaintPrefGroupUI(OptionsGroupUI):
  3747. def __init__(self, parent=None):
  3748. # OptionsGroupUI.__init__(self, "Paint Area Tool Options", parent=parent)
  3749. super(ToolsPaintPrefGroupUI, self).__init__(self)
  3750. self.setTitle(str("Paint Tool Options"))
  3751. # ------------------------------
  3752. ## Paint area
  3753. # ------------------------------
  3754. self.paint_label = QtWidgets.QLabel('<b>Parameters:</b>')
  3755. self.paint_label.setToolTip(
  3756. "Creates tool paths to cover the\n"
  3757. "whole area of a polygon (remove\n"
  3758. "all copper). You will be asked\n"
  3759. "to click on the desired polygon."
  3760. )
  3761. self.layout.addWidget(self.paint_label)
  3762. grid0 = QtWidgets.QGridLayout()
  3763. self.layout.addLayout(grid0)
  3764. # Tool dia
  3765. ptdlabel = QtWidgets.QLabel('Tool dia:')
  3766. ptdlabel.setToolTip(
  3767. "Diameter of the tool to\n"
  3768. "be used in the operation."
  3769. )
  3770. grid0.addWidget(ptdlabel, 0, 0)
  3771. self.painttooldia_entry = LengthEntry()
  3772. grid0.addWidget(self.painttooldia_entry, 0, 1)
  3773. # Overlap
  3774. ovlabel = QtWidgets.QLabel('Overlap:')
  3775. ovlabel.setToolTip(
  3776. "How much (fraction) of the tool\n"
  3777. "width to overlap each tool pass."
  3778. )
  3779. grid0.addWidget(ovlabel, 1, 0)
  3780. self.paintoverlap_entry = LengthEntry()
  3781. grid0.addWidget(self.paintoverlap_entry, 1, 1)
  3782. # Margin
  3783. marginlabel = QtWidgets.QLabel('Margin:')
  3784. marginlabel.setToolTip(
  3785. "Distance by which to avoid\n"
  3786. "the edges of the polygon to\n"
  3787. "be painted."
  3788. )
  3789. grid0.addWidget(marginlabel, 2, 0)
  3790. self.paintmargin_entry = LengthEntry()
  3791. grid0.addWidget(self.paintmargin_entry, 2, 1)
  3792. # Method
  3793. methodlabel = QtWidgets.QLabel('Method:')
  3794. methodlabel.setToolTip(
  3795. "Algorithm to paint the polygon:<BR>"
  3796. "<B>Standard</B>: Fixed step inwards.<BR>"
  3797. "<B>Seed-based</B>: Outwards from seed."
  3798. )
  3799. grid0.addWidget(methodlabel, 3, 0)
  3800. self.paintmethod_combo = RadioSet([
  3801. {"label": "Standard", "value": "standard"},
  3802. {"label": "Seed-based", "value": "seed"},
  3803. {"label": "Straight lines", "value": "lines"}
  3804. ], orientation='vertical', stretch=False)
  3805. grid0.addWidget(self.paintmethod_combo, 3, 1)
  3806. # Connect lines
  3807. pathconnectlabel = QtWidgets.QLabel("Connect:")
  3808. pathconnectlabel.setToolTip(
  3809. "Draw lines between resulting\n"
  3810. "segments to minimize tool lifts."
  3811. )
  3812. grid0.addWidget(pathconnectlabel, 4, 0)
  3813. self.pathconnect_cb = FCCheckBox()
  3814. grid0.addWidget(self.pathconnect_cb, 4, 1)
  3815. # Paint contour
  3816. contourlabel = QtWidgets.QLabel("Contour:")
  3817. contourlabel.setToolTip(
  3818. "Cut around the perimeter of the polygon\n"
  3819. "to trim rough edges."
  3820. )
  3821. grid0.addWidget(contourlabel, 5, 0)
  3822. self.contour_cb = FCCheckBox()
  3823. grid0.addWidget(self.contour_cb, 5, 1)
  3824. # Polygon selection
  3825. selectlabel = QtWidgets.QLabel('Selection:')
  3826. selectlabel.setToolTip(
  3827. "How to select the polygons to paint."
  3828. )
  3829. grid0.addWidget(selectlabel, 6, 0)
  3830. self.selectmethod_combo = RadioSet([
  3831. {"label": "Single", "value": "single"},
  3832. {"label": "All", "value": "all"},
  3833. # {"label": "Rectangle", "value": "rectangle"}
  3834. ])
  3835. grid0.addWidget(self.selectmethod_combo, 6, 1)
  3836. self.layout.addStretch()
  3837. class ToolsFilmPrefGroupUI(OptionsGroupUI):
  3838. def __init__(self, parent=None):
  3839. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  3840. super(ToolsFilmPrefGroupUI, self).__init__(self)
  3841. self.setTitle(str("Film Tool Options"))
  3842. ## Board cuttout
  3843. self.film_label = QtWidgets.QLabel("<b>Parameters:</b>")
  3844. self.film_label.setToolTip(
  3845. "Create a PCB film from a Gerber or Geometry\n"
  3846. "FlatCAM object.\n"
  3847. "The file is saved in SVG format."
  3848. )
  3849. self.layout.addWidget(self.film_label)
  3850. grid0 = QtWidgets.QGridLayout()
  3851. self.layout.addLayout(grid0)
  3852. self.film_type_radio = RadioSet([{'label': 'Pos', 'value': 'pos'}, {'label': 'Neg', 'value': 'neg'}])
  3853. ftypelbl = QtWidgets.QLabel('Film Type:')
  3854. ftypelbl.setToolTip(
  3855. "Generate a Positive black film or a Negative film.\n"
  3856. "Positive means that it will print the features\n"
  3857. "with black on a white canvas.\n"
  3858. "Negative means that it will print the features\n"
  3859. "with white on a black canvas.\n"
  3860. "The Film format is SVG."
  3861. )
  3862. grid0.addWidget(ftypelbl, 0, 0)
  3863. grid0.addWidget(self.film_type_radio, 0, 1)
  3864. self.film_boundary_entry = FCEntry()
  3865. self.film_boundary_label = QtWidgets.QLabel("Border:")
  3866. self.film_boundary_label.setToolTip(
  3867. "Specify a border around the object.\n"
  3868. "Only for negative film.\n"
  3869. "It helps if we use as a Box Object the same \n"
  3870. "object as in Film Object. It will create a thick\n"
  3871. "black bar around the actual print allowing for a\n"
  3872. "better delimitation of the outline features which are of\n"
  3873. "white color like the rest and which may confound with the\n"
  3874. "surroundings if not for this border."
  3875. )
  3876. grid0.addWidget(self.film_boundary_label, 1, 0)
  3877. grid0.addWidget(self.film_boundary_entry, 1, 1)
  3878. self.film_scale_entry = FCEntry()
  3879. self.film_scale_label = QtWidgets.QLabel("Scale Stroke:")
  3880. self.film_scale_label.setToolTip(
  3881. "Scale the line stroke thickness of each feature in the SVG file.\n"
  3882. "It means that the line that envelope each SVG feature will be thicker or thinner,\n"
  3883. "therefore the fine features may be more affected by this parameter."
  3884. )
  3885. grid0.addWidget(self.film_scale_label, 2, 0)
  3886. grid0.addWidget(self.film_scale_entry, 2, 1)
  3887. self.layout.addStretch()
  3888. class ToolsPanelizePrefGroupUI(OptionsGroupUI):
  3889. def __init__(self, parent=None):
  3890. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  3891. super(ToolsPanelizePrefGroupUI, self).__init__(self)
  3892. self.setTitle(str("Panelize Tool Options"))
  3893. ## Board cuttout
  3894. self.panelize_label = QtWidgets.QLabel("<b>Parameters:</b>")
  3895. self.panelize_label.setToolTip(
  3896. "Create an object that contains an array of (x, y) elements,\n"
  3897. "each element is a copy of the source object spaced\n"
  3898. "at a X distance, Y distance of each other."
  3899. )
  3900. self.layout.addWidget(self.panelize_label)
  3901. grid0 = QtWidgets.QGridLayout()
  3902. self.layout.addLayout(grid0)
  3903. ## Spacing Columns
  3904. self.pspacing_columns = FCEntry()
  3905. self.spacing_columns_label = QtWidgets.QLabel("Spacing cols:")
  3906. self.spacing_columns_label.setToolTip(
  3907. "Spacing between columns of the desired panel.\n"
  3908. "In current units."
  3909. )
  3910. grid0.addWidget(self.spacing_columns_label, 0, 0)
  3911. grid0.addWidget(self.pspacing_columns, 0, 1)
  3912. ## Spacing Rows
  3913. self.pspacing_rows = FCEntry()
  3914. self.spacing_rows_label = QtWidgets.QLabel("Spacing rows:")
  3915. self.spacing_rows_label.setToolTip(
  3916. "Spacing between rows of the desired panel.\n"
  3917. "In current units."
  3918. )
  3919. grid0.addWidget(self.spacing_rows_label, 1, 0)
  3920. grid0.addWidget(self.pspacing_rows, 1, 1)
  3921. ## Columns
  3922. self.pcolumns = FCEntry()
  3923. self.columns_label = QtWidgets.QLabel("Columns:")
  3924. self.columns_label.setToolTip(
  3925. "Number of columns of the desired panel"
  3926. )
  3927. grid0.addWidget(self.columns_label, 2, 0)
  3928. grid0.addWidget(self.pcolumns, 2, 1)
  3929. ## Rows
  3930. self.prows = FCEntry()
  3931. self.rows_label = QtWidgets.QLabel("Rows:")
  3932. self.rows_label.setToolTip(
  3933. "Number of rows of the desired panel"
  3934. )
  3935. grid0.addWidget(self.rows_label, 3, 0)
  3936. grid0.addWidget(self.prows, 3, 1)
  3937. ## Constrains
  3938. self.pconstrain_cb = FCCheckBox("Constrain within:")
  3939. self.pconstrain_cb.setToolTip(
  3940. "Area define by DX and DY within to constrain the panel.\n"
  3941. "DX and DY values are in current units.\n"
  3942. "Regardless of how many columns and rows are desired,\n"
  3943. "the final panel will have as many columns and rows as\n"
  3944. "they fit completely within selected area."
  3945. )
  3946. grid0.addWidget(self.pconstrain_cb, 4, 0)
  3947. self.px_width_entry = FCEntry()
  3948. self.x_width_lbl = QtWidgets.QLabel("Width (DX):")
  3949. self.x_width_lbl.setToolTip(
  3950. "The width (DX) within which the panel must fit.\n"
  3951. "In current units."
  3952. )
  3953. grid0.addWidget(self.x_width_lbl, 5, 0)
  3954. grid0.addWidget(self.px_width_entry, 5, 1)
  3955. self.py_height_entry = FCEntry()
  3956. self.y_height_lbl = QtWidgets.QLabel("Height (DY):")
  3957. self.y_height_lbl.setToolTip(
  3958. "The height (DY)within which the panel must fit.\n"
  3959. "In current units."
  3960. )
  3961. grid0.addWidget(self.y_height_lbl, 6, 0)
  3962. grid0.addWidget(self.py_height_entry, 6, 1)
  3963. self.layout.addStretch()
  3964. class ToolsCalculatorsPrefGroupUI(OptionsGroupUI):
  3965. def __init__(self, parent=None):
  3966. # OptionsGroupUI.__init__(self, "Calculators Tool Options", parent=parent)
  3967. super(ToolsCalculatorsPrefGroupUI, self).__init__(self)
  3968. self.setTitle(str("Calculators Tool Options"))
  3969. ## V-shape Calculator Tool
  3970. self.vshape_tool_label = QtWidgets.QLabel("<b>V-Shape Tool Calculator:</b>")
  3971. self.vshape_tool_label.setToolTip(
  3972. "Calculate the tool diameter for a given V-shape tool,\n"
  3973. "having the tip diameter, tip angle and\n"
  3974. "depth-of-cut as parameters."
  3975. )
  3976. self.layout.addWidget(self.vshape_tool_label)
  3977. grid0 = QtWidgets.QGridLayout()
  3978. self.layout.addLayout(grid0)
  3979. ## Tip Diameter
  3980. self.tip_dia_entry = FCEntry()
  3981. self.tip_dia_label = QtWidgets.QLabel("Tip Diameter:")
  3982. self.tip_dia_label.setToolTip(
  3983. "This is the tool tip diameter.\n"
  3984. "It is specified by manufacturer."
  3985. )
  3986. grid0.addWidget(self.tip_dia_label, 0, 0)
  3987. grid0.addWidget(self.tip_dia_entry, 0, 1)
  3988. ## Tip angle
  3989. self.tip_angle_entry = FCEntry()
  3990. self.tip_angle_label = QtWidgets.QLabel("Tip angle:")
  3991. self.tip_angle_label.setToolTip(
  3992. "This is the angle on the tip of the tool.\n"
  3993. "It is specified by manufacturer."
  3994. )
  3995. grid0.addWidget(self.tip_angle_label, 1, 0)
  3996. grid0.addWidget(self.tip_angle_entry, 1, 1)
  3997. ## Depth-of-cut Cut Z
  3998. self.cut_z_entry = FCEntry()
  3999. self.cut_z_label = QtWidgets.QLabel("Cut Z:")
  4000. self.cut_z_label.setToolTip(
  4001. "This is depth to cut into material.\n"
  4002. "In the CNCJob object it is the CutZ parameter."
  4003. )
  4004. grid0.addWidget(self.cut_z_label, 2, 0)
  4005. grid0.addWidget(self.cut_z_entry, 2, 1)
  4006. ## Electroplating Calculator Tool
  4007. self.plate_title_label = QtWidgets.QLabel("<b>ElectroPlating Calculator:</b>")
  4008. self.plate_title_label.setToolTip(
  4009. "This calculator is useful for those who plate the via/pad/drill holes,\n"
  4010. "using a method like grahite ink or calcium hypophosphite ink or palladium chloride."
  4011. )
  4012. self.layout.addWidget(self.plate_title_label)
  4013. grid1 = QtWidgets.QGridLayout()
  4014. self.layout.addLayout(grid1)
  4015. ## PCB Length
  4016. self.pcblength_entry = FCEntry()
  4017. self.pcblengthlabel = QtWidgets.QLabel("Board Length:")
  4018. self.pcblengthlabel.setToolTip('This is the board length. In centimeters.')
  4019. grid1.addWidget(self.pcblengthlabel, 0, 0)
  4020. grid1.addWidget(self.pcblength_entry, 0, 1)
  4021. ## PCB Width
  4022. self.pcbwidth_entry = FCEntry()
  4023. self.pcbwidthlabel = QtWidgets.QLabel("Board Width:")
  4024. self.pcbwidthlabel.setToolTip('This is the board width.In centimeters.')
  4025. grid1.addWidget(self.pcbwidthlabel, 1, 0)
  4026. grid1.addWidget(self.pcbwidth_entry, 1, 1)
  4027. ## Current Density
  4028. self.cdensity_label = QtWidgets.QLabel("Current Density:")
  4029. self.cdensity_entry = FCEntry()
  4030. self.cdensity_label.setToolTip("Current density to pass through the board. \n"
  4031. "In Amps per Square Feet ASF.")
  4032. grid1.addWidget(self.cdensity_label, 2, 0)
  4033. grid1.addWidget(self.cdensity_entry, 2, 1)
  4034. ## PCB Copper Growth
  4035. self.growth_label = QtWidgets.QLabel("Copper Growth:")
  4036. self.growth_entry = FCEntry()
  4037. self.growth_label.setToolTip("How thick the copper growth is intended to be.\n"
  4038. "In microns.")
  4039. grid1.addWidget(self.growth_label, 3, 0)
  4040. grid1.addWidget(self.growth_entry, 3, 1)
  4041. self.layout.addStretch()
  4042. class FlatCAMActivityView(QtWidgets.QWidget):
  4043. def __init__(self, parent=None):
  4044. super().__init__(parent=parent)
  4045. self.setMinimumWidth(200)
  4046. self.icon = QtWidgets.QLabel(self)
  4047. self.icon.setGeometry(0, 0, 16, 12)
  4048. self.movie = QtGui.QMovie("share/active.gif")
  4049. self.icon.setMovie(self.movie)
  4050. # self.movie.start()
  4051. layout = QtWidgets.QHBoxLayout()
  4052. layout.setContentsMargins(5, 0, 5, 0)
  4053. layout.setAlignment(QtCore.Qt.AlignLeft)
  4054. self.setLayout(layout)
  4055. layout.addWidget(self.icon)
  4056. self.text = QtWidgets.QLabel(self)
  4057. self.text.setText("Idle.")
  4058. layout.addWidget(self.text)
  4059. def set_idle(self):
  4060. self.movie.stop()
  4061. self.text.setText("Idle.")
  4062. def set_busy(self, msg):
  4063. self.movie.start()
  4064. self.text.setText(msg)
  4065. class FlatCAMInfoBar(QtWidgets.QWidget):
  4066. def __init__(self, parent=None):
  4067. super(FlatCAMInfoBar, self).__init__(parent=parent)
  4068. self.icon = QtWidgets.QLabel(self)
  4069. self.icon.setGeometry(0, 0, 12, 12)
  4070. self.pmap = QtGui.QPixmap('share/graylight12.png')
  4071. self.icon.setPixmap(self.pmap)
  4072. layout = QtWidgets.QHBoxLayout()
  4073. layout.setContentsMargins(5, 0, 5, 0)
  4074. self.setLayout(layout)
  4075. layout.addWidget(self.icon)
  4076. self.text = QtWidgets.QLabel(self)
  4077. self.text.setText("Application started ...")
  4078. self.text.setToolTip("Hello!")
  4079. layout.addWidget(self.text)
  4080. layout.addStretch()
  4081. def set_text_(self, text, color=None):
  4082. self.text.setText(text)
  4083. self.text.setToolTip(text)
  4084. if color:
  4085. self.text.setStyleSheet('color: %s' % str(color))
  4086. def set_status(self, text, level="info"):
  4087. level = str(level)
  4088. self.pmap.fill()
  4089. if level == "ERROR" or level == "ERROR_NOTCL":
  4090. self.pmap = QtGui.QPixmap('share/redlight12.png')
  4091. elif level == "success" or level == "SUCCESS":
  4092. self.pmap = QtGui.QPixmap('share/greenlight12.png')
  4093. elif level == "WARNING" or level == "WARNING_NOTCL":
  4094. self.pmap = QtGui.QPixmap('share/yellowlight12.png')
  4095. elif level == "selected" or level == "SELECTED":
  4096. self.pmap = QtGui.QPixmap('share/bluelight12.png')
  4097. else:
  4098. self.pmap = QtGui.QPixmap('share/graylight12.png')
  4099. self.set_text_(text)
  4100. self.icon.setPixmap(self.pmap)
  4101. # end of file