FlatCAMGUI.py 273 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290
  1. ############################################################
  2. # FlatCAM: 2D Post-processing for Manufacturing #
  3. # http://flatcam.org #
  4. # Author: Juan Pablo Caram (c) #
  5. # Date: 2/5/2014 #
  6. # MIT Licence #
  7. ############################################################
  8. ############################################################
  9. # File Modified (major mod): Marius Adrian Stanciu #
  10. # Date: 3/10/2019 #
  11. ############################################################
  12. from PyQt5.QtCore import QSettings
  13. from flatcamGUI.GUIElements import *
  14. import platform
  15. import webbrowser
  16. from flatcamEditors.FlatCAMGeoEditor import FCShapeTool
  17. import gettext
  18. import FlatCAMTranslation as fcTranslate
  19. fcTranslate.apply_language('strings')
  20. import builtins
  21. if '_' not in builtins.__dict__:
  22. _ = gettext.gettext
  23. class FlatCAMGUI(QtWidgets.QMainWindow):
  24. # Emitted when persistent window geometry needs to be retained
  25. geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate')
  26. final_save = QtCore.pyqtSignal(name='saveBeforeExit')
  27. def __init__(self, version, beta, app):
  28. super(FlatCAMGUI, self).__init__()
  29. self.app = app
  30. # Divine icon pack by Ipapun @ finicons.com
  31. #####################################
  32. ### BUILDING THE GUI IS DONE HERE ###
  33. #####################################
  34. ############
  35. ### Menu ###
  36. ############
  37. self.menu = self.menuBar()
  38. ### File ###
  39. self.menufile = self.menu.addMenu(_('&File'))
  40. self.menufile.setToolTipsVisible(True)
  41. # New Project
  42. self.menufilenewproject = QtWidgets.QAction(QtGui.QIcon('share/file16.png'),
  43. _('&New Project ...\tCTRL+N'), self)
  44. self.menufilenewproject.setToolTip(
  45. _("Will create a new, blank project")
  46. )
  47. self.menufile.addAction(self.menufilenewproject)
  48. # New Category (Excellon, Geometry)
  49. self.menufilenew = self.menufile.addMenu(QtGui.QIcon('share/file16.png'), _('&New'))
  50. self.menufilenew.setToolTipsVisible(True)
  51. self.menufilenewgeo = self.menufilenew.addAction(QtGui.QIcon('share/geometry16.png'), _('Geometry\tN'))
  52. self.menufilenewgeo.setToolTip(
  53. _("Will create a new, empty Geometry Object.")
  54. )
  55. self.menufilenewgrb = self.menufilenew.addAction(QtGui.QIcon('share/flatcam_icon32.png'), _('Gerber\tB'))
  56. self.menufilenewgrb.setToolTip(
  57. _("Will create a new, empty Gerber Object.")
  58. )
  59. self.menufilenewexc = self.menufilenew.addAction(QtGui.QIcon('share/drill16.png'), _('Excellon\tL'))
  60. self.menufilenewexc.setToolTip(
  61. _("Will create a new, empty Excellon Object.")
  62. )
  63. self.menufile_open = self.menufile.addMenu(QtGui.QIcon('share/folder32_bis.png'), _('Open'))
  64. self.menufile_open.setToolTipsVisible(True)
  65. # Open gerber ...
  66. self.menufileopengerber = QtWidgets.QAction(QtGui.QIcon('share/flatcam_icon24.png'),
  67. _('Open &Gerber ...\tCTRL+G'), self)
  68. self.menufile_open.addAction(self.menufileopengerber)
  69. self.menufile_open.addSeparator()
  70. # Open Excellon ...
  71. self.menufileopenexcellon = QtWidgets.QAction(QtGui.QIcon('share/open_excellon32.png'),
  72. _('Open &Excellon ...\tCTRL+E'),
  73. self)
  74. self.menufile_open.addAction(self.menufileopenexcellon)
  75. # Open G-Code ...
  76. self.menufileopengcode = QtWidgets.QAction(QtGui.QIcon('share/code.png'), _('Open G-&Code ...'), self)
  77. self.menufile_open.addAction(self.menufileopengcode)
  78. # Open Project ...
  79. self.menufileopenproject = QtWidgets.QAction(QtGui.QIcon('share/folder16.png'), _('Open &Project ...'), self)
  80. self.menufile_open.addAction(self.menufileopenproject)
  81. self.menufile_open.addSeparator()
  82. # Open Config File...
  83. self.menufileopenconfig = QtWidgets.QAction(QtGui.QIcon('share/folder16.png'), _('Open Config ...'), self)
  84. self.menufile_open.addAction(self.menufileopenconfig)
  85. # Recent
  86. self.recent = self.menufile.addMenu(QtGui.QIcon('share/recent_files.png'), _("Recent files"))
  87. # Separator
  88. self.menufile.addSeparator()
  89. # Scripting
  90. self.menufile_scripting = self.menufile.addMenu(QtGui.QIcon('share/script16.png'), _('Scripting'))
  91. self.menufile_scripting.setToolTipsVisible(True)
  92. self.menufilenewscript = QtWidgets.QAction(QtGui.QIcon('share/script_new16.png'), _('New Script ...'),
  93. self)
  94. self.menufileopenscript = QtWidgets.QAction(QtGui.QIcon('share/script_open16.png'), _('Open Script ...'),
  95. self)
  96. self.menufilerunscript = QtWidgets.QAction(QtGui.QIcon('share/script16.png'), _('Run Script ...\tSHIFT+S'),
  97. self)
  98. self.menufilerunscript.setToolTip(
  99. _( "Will run the opened Tcl Script thus\n"
  100. "enabling the automation of certain\n"
  101. "functions of FlatCAM.")
  102. )
  103. self.menufile_scripting.addAction(self.menufilenewscript)
  104. self.menufile_scripting.addAction(self.menufileopenscript)
  105. self.menufile_scripting.addSeparator()
  106. self.menufile_scripting.addAction(self.menufilerunscript)
  107. # Separator
  108. self.menufile.addSeparator()
  109. # Import ...
  110. self.menufileimport = self.menufile.addMenu(QtGui.QIcon('share/import.png'), _('Import'))
  111. self.menufileimportsvg = QtWidgets.QAction(QtGui.QIcon('share/svg16.png'),
  112. _('&SVG as Geometry Object ...'), self)
  113. self.menufileimport.addAction(self.menufileimportsvg)
  114. self.menufileimportsvg_as_gerber = QtWidgets.QAction(QtGui.QIcon('share/svg16.png'),
  115. _('&SVG as Gerber Object ...'), self)
  116. self.menufileimport.addAction(self.menufileimportsvg_as_gerber)
  117. self.menufileimport.addSeparator()
  118. self.menufileimportdxf = QtWidgets.QAction(QtGui.QIcon('share/dxf16.png'),
  119. _('&DXF as Geometry Object ...'), self)
  120. self.menufileimport.addAction(self.menufileimportdxf)
  121. self.menufileimportdxf_as_gerber = QtWidgets.QAction(QtGui.QIcon('share/dxf16.png'),
  122. _('&DXF as Gerber Object ...'), self)
  123. self.menufileimport.addAction(self.menufileimportdxf_as_gerber)
  124. self.menufileimport.addSeparator()
  125. # Export ...
  126. self.menufileexport = self.menufile.addMenu(QtGui.QIcon('share/export.png'), _('Export'))
  127. self.menufileexport.setToolTipsVisible(True)
  128. self.menufileexportsvg = QtWidgets.QAction(QtGui.QIcon('share/export.png'), _('Export &SVG ...'), self)
  129. self.menufileexport.addAction(self.menufileexportsvg)
  130. self.menufileexportdxf = QtWidgets.QAction(QtGui.QIcon('share/export.png'), _('Export DXF ...'), self)
  131. self.menufileexport.addAction(self.menufileexportdxf)
  132. self.menufileexport.addSeparator()
  133. self.menufileexportpng = QtWidgets.QAction(QtGui.QIcon('share/export_png32.png'), _('Export &PNG ...'), self)
  134. self.menufileexportpng.setToolTip(
  135. _("Will export an image in PNG format,\n"
  136. "the saved image will contain the visual \n"
  137. "information currently in FlatCAM Plot Area.")
  138. )
  139. self.menufileexport.addAction(self.menufileexportpng)
  140. self.menufileexport.addSeparator()
  141. self.menufileexportexcellon = QtWidgets.QAction(QtGui.QIcon('share/drill32.png'), _('Export &Excellon ...'),
  142. self)
  143. self.menufileexportexcellon.setToolTip(
  144. _( "Will export an Excellon Object as Excellon file,\n"
  145. "the coordinates format, the file units and zeros\n"
  146. "are set in Preferences -> Excellon Export.")
  147. )
  148. self.menufileexport.addAction(self.menufileexportexcellon)
  149. # Separator
  150. self.menufile.addSeparator()
  151. # Save Defaults
  152. self.menufilesavedefaults = QtWidgets.QAction(QtGui.QIcon('share/defaults.png'), _('Save &Defaults'), self)
  153. self.menufile.addAction(self.menufilesavedefaults)
  154. # Separator
  155. self.menufile.addSeparator()
  156. self.menufile_save = self.menufile.addMenu(QtGui.QIcon('share/save_as.png'), _('Save'))
  157. # Save Project
  158. self.menufilesaveproject = QtWidgets.QAction(QtGui.QIcon('share/floppy16.png'), _('&Save Project ...'), self)
  159. self.menufile_save.addAction(self.menufilesaveproject)
  160. # Save Project As ...
  161. self.menufilesaveprojectas = QtWidgets.QAction(QtGui.QIcon('share/save_as.png'),
  162. _('Save Project &As ...\tCTRL+S'), self)
  163. self.menufile_save.addAction(self.menufilesaveprojectas)
  164. # Save Project Copy ...
  165. self.menufilesaveprojectcopy = QtWidgets.QAction(QtGui.QIcon('share/floppy16.png'), _('Save Project C&opy ...'),
  166. self)
  167. self.menufile_save.addAction(self.menufilesaveprojectcopy)
  168. # Separator
  169. self.menufile.addSeparator()
  170. # Quit
  171. self.menufile_exit = QtWidgets.QAction(QtGui.QIcon('share/power16.png'), _('E&xit'), self)
  172. # exitAction.setShortcut('Ctrl+Q')
  173. # exitAction.setStatusTip('Exit application')
  174. self.menufile.addAction(self.menufile_exit)
  175. ### Edit ###
  176. self.menuedit = self.menu.addMenu(_('&Edit'))
  177. # Separator
  178. self.menuedit.addSeparator()
  179. self.menueditedit = self.menuedit.addAction(QtGui.QIcon('share/edit16.png'), _('Edit Object\tE'))
  180. self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), _('Close Editor\tCTRL+S'))
  181. # adjust the initial state of the menu entries related to the editor
  182. self.menueditedit.setDisabled(False)
  183. self.menueditok.setDisabled(True)
  184. # Separator
  185. self.menuedit.addSeparator()
  186. self.menuedit_convert = self.menuedit.addMenu(QtGui.QIcon('share/convert24.png'), _('Conversion'))
  187. self.menuedit_convertjoin = self.menuedit_convert.addAction(
  188. QtGui.QIcon('share/join16.png'), _('&Join Geo/Gerber/Exc -> Geo'))
  189. self.menuedit_convertjoin.setToolTip(
  190. _( "Merge a selection of objects, which can be of type:\n"
  191. "- Gerber\n"
  192. "- Excellon\n"
  193. "- Geometry\n"
  194. "into a new combo Geometry object.")
  195. )
  196. self.menuedit_convertjoinexc = self.menuedit_convert.addAction(
  197. QtGui.QIcon('share/join16.png'), _('Join Excellon(s) -> Excellon'))
  198. self.menuedit_convertjoinexc.setToolTip(
  199. _( "Merge a selection of Excellon objects into a new combo Excellon object.")
  200. )
  201. self.menuedit_convertjoingrb = self.menuedit_convert.addAction(
  202. QtGui.QIcon('share/join16.png'), _('Join Gerber(s) -> Gerber'))
  203. self.menuedit_convertjoingrb.setToolTip(
  204. _("Merge a selection of Gerber objects into a new combo Gerber object.")
  205. )
  206. # Separator
  207. self.menuedit_convert.addSeparator()
  208. self.menuedit_convert_sg2mg = self.menuedit_convert.addAction(
  209. QtGui.QIcon('share/convert24.png'), _('Convert Single to MultiGeo'))
  210. self.menuedit_convert_sg2mg.setToolTip(
  211. _( "Will convert a Geometry object from single_geometry type\n"
  212. "to a multi_geometry type.")
  213. )
  214. self.menuedit_convert_mg2sg = self.menuedit_convert.addAction(
  215. QtGui.QIcon('share/convert24.png'), _('Convert Multi to SingleGeo'))
  216. self.menuedit_convert_mg2sg.setToolTip(
  217. _( "Will convert a Geometry object from multi_geometry type\n"
  218. "to a single_geometry type.")
  219. )
  220. self.menuedit_convert.setToolTipsVisible(True)
  221. # Separator
  222. self.menuedit.addSeparator()
  223. self.menueditcopyobject = self.menuedit.addAction(QtGui.QIcon('share/copy.png'), _('&Copy Object\tCTRL+C'))
  224. self.menueditcopyobjectasgeom = self.menuedit.addAction(QtGui.QIcon('share/copy_geo.png'),
  225. _('Copy as &Geom'))
  226. # Separator
  227. self.menuedit.addSeparator()
  228. self.menueditdelete = self.menuedit.addAction(QtGui.QIcon('share/trash16.png'), _('&Delete\tDEL'))
  229. # Separator
  230. self.menuedit.addSeparator()
  231. self.menueditorigin = self.menuedit.addAction(QtGui.QIcon('share/origin.png'), _('Se&t Origin\tO'))
  232. self.menueditjump = self.menuedit.addAction(QtGui.QIcon('share/jump_to16.png'), _('Jump to Location\tJ'))
  233. # Separator
  234. self.menuedit.addSeparator()
  235. self.menuedittoggleunits= self.menuedit.addAction(QtGui.QIcon('share/toggle_units16.png'),
  236. _('Toggle Units\tQ'))
  237. self.menueditselectall = self.menuedit.addAction(QtGui.QIcon('share/select_all.png'),
  238. _('&Select All\tCTRL+A'))
  239. # Separator
  240. self.menuedit.addSeparator()
  241. self.menueditpreferences = self.menuedit.addAction(QtGui.QIcon('share/pref.png'), _('&Preferences\tSHIFT+P'))
  242. ### Options ###
  243. self.menuoptions = self.menu.addMenu(_('&Options'))
  244. # self.menuoptions_transfer = self.menuoptions.addMenu(QtGui.QIcon('share/transfer.png'), 'Transfer options')
  245. # self.menuoptions_transfer_a2p = self.menuoptions_transfer.addAction("Application to Project")
  246. # self.menuoptions_transfer_p2a = self.menuoptions_transfer.addAction("Project to Application")
  247. # self.menuoptions_transfer_p2o = self.menuoptions_transfer.addAction("Project to Object")
  248. # self.menuoptions_transfer_o2p = self.menuoptions_transfer.addAction("Object to Project")
  249. # self.menuoptions_transfer_a2o = self.menuoptions_transfer.addAction("Application to Object")
  250. # self.menuoptions_transfer_o2a = self.menuoptions_transfer.addAction("Object to Application")
  251. # Separator
  252. # self.menuoptions.addSeparator()
  253. # self.menuoptions_transform = self.menuoptions.addMenu(QtGui.QIcon('share/transform.png'),
  254. # '&Transform Object')
  255. self.menuoptions_transform_rotate = self.menuoptions.addAction(QtGui.QIcon('share/rotate.png'),
  256. _("&Rotate Selection\tSHIFT+(R)"))
  257. # Separator
  258. self.menuoptions.addSeparator()
  259. self.menuoptions_transform_skewx = self.menuoptions.addAction(QtGui.QIcon('share/skewX.png'),
  260. _("&Skew on X axis\tSHIFT+X"))
  261. self.menuoptions_transform_skewy = self.menuoptions.addAction(QtGui.QIcon('share/skewY.png'),
  262. _( "S&kew on Y axis\tSHIFT+Y"))
  263. # Separator
  264. self.menuoptions.addSeparator()
  265. self.menuoptions_transform_flipx = self.menuoptions.addAction(QtGui.QIcon('share/flipx.png'),
  266. _("Flip on &X axis\tX"))
  267. self.menuoptions_transform_flipy = self.menuoptions.addAction(QtGui.QIcon('share/flipy.png'),
  268. _("Flip on &Y axis\tY"))
  269. # Separator
  270. self.menuoptions.addSeparator()
  271. self.menuoptions_view_source = self.menuoptions.addAction(QtGui.QIcon('share/source32.png'),
  272. _("View source\tALT+S"))
  273. # Separator
  274. self.menuoptions.addSeparator()
  275. ### View ###
  276. self.menuview = self.menu.addMenu(_('&View'))
  277. self.menuviewenable = self.menuview.addAction(QtGui.QIcon('share/replot16.png'), _('Enable all plots\tALT+1'))
  278. self.menuviewdisableall = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  279. _('Disable all plots\tALT+2'))
  280. self.menuviewdisableother = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  281. _('Disable non-selected\tALT+3'))
  282. # Separator
  283. self.menuview.addSeparator()
  284. self.menuview_zoom_fit = self.menuview.addAction(QtGui.QIcon('share/zoom_fit32.png'), _("&Zoom Fit\tV"))
  285. self.menuview_zoom_in = self.menuview.addAction(QtGui.QIcon('share/zoom_in32.png'), _("&Zoom In\t-"))
  286. self.menuview_zoom_out = self.menuview.addAction(QtGui.QIcon('share/zoom_out32.png'), _("&Zoom Out\t="))
  287. self.menuview.addSeparator()
  288. self.menuview_toggle_code_editor = self.menuview.addAction(QtGui.QIcon('share/code_editor32.png'),
  289. _('Toggle Code Editor\tCTRL+E'))
  290. self.menuview.addSeparator()
  291. self.menuview_toggle_fscreen = self.menuview.addAction(
  292. QtGui.QIcon('share/fscreen32.png'), _("&Toggle FullScreen\tALT+F10"))
  293. self.menuview_toggle_parea = self.menuview.addAction(
  294. QtGui.QIcon('share/plot32.png'), _("&Toggle Plot Area\tCTRL+F10"))
  295. self.menuview_toggle_notebook = self.menuview.addAction(
  296. QtGui.QIcon('share/notebook32.png'), _("&Toggle Project/Sel/Tool\t`"))
  297. self.menuview.addSeparator()
  298. self.menuview_toggle_grid = self.menuview.addAction(QtGui.QIcon('share/grid32.png'), _("&Toggle Grid Snap\tG")
  299. )
  300. self.menuview_toggle_axis = self.menuview.addAction(QtGui.QIcon('share/axis32.png'), _("&Toggle Axis\tSHIFT+G")
  301. )
  302. self.menuview_toggle_workspace = self.menuview.addAction(QtGui.QIcon('share/workspace24.png'),
  303. _("Toggle Workspace\tSHIFT+W"))
  304. ### Tool ###
  305. # self.menutool = self.menu.addMenu('&Tool')
  306. self.menutool = QtWidgets.QMenu(_('&Tool'))
  307. self.menutoolaction = self.menu.addMenu(self.menutool)
  308. self.menutoolshell = self.menutool.addAction(QtGui.QIcon('share/shell16.png'), _('&Command Line\tS'))
  309. ### Help ###
  310. self.menuhelp = self.menu.addMenu(_('&Help'))
  311. self.menuhelp_manual = self.menuhelp.addAction(QtGui.QIcon('share/globe16.png'), _('Help\tF1'))
  312. self.menuhelp_home = self.menuhelp.addAction(QtGui.QIcon('share/home16.png'), _('FlatCAM.org'))
  313. self.menuhelp.addSeparator()
  314. self.menuhelp_shortcut_list = self.menuhelp.addAction(QtGui.QIcon('share/shortcuts24.png'),
  315. _('Shortcuts List\tF3'))
  316. self.menuhelp_videohelp = self.menuhelp.addAction(QtGui.QIcon('share/youtube32.png'), _('YouTube Channel\tF4')
  317. )
  318. self.menuhelp_about = self.menuhelp.addAction(QtGui.QIcon('share/about32.png'), _('About'))
  319. ### FlatCAM Editor menu ###
  320. # self.editor_menu = QtWidgets.QMenu("Editor")
  321. # self.menu.addMenu(self.editor_menu)
  322. self.geo_editor_menu = QtWidgets.QMenu(">Geo Editor<")
  323. self.menu.addMenu(self.geo_editor_menu)
  324. # self.select_menuitem = self.menu.addAction(QtGui.QIcon('share/pointer16.png'), "Select 'Esc'")
  325. self.geo_add_circle_menuitem = self.geo_editor_menu.addAction(
  326. QtGui.QIcon('share/circle32.png'), _('Add Circle\tO')
  327. )
  328. self.geo_add_arc_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/arc16.png'), _('Add Arc\tA'))
  329. self.geo_editor_menu.addSeparator()
  330. self.geo_add_rectangle_menuitem = self.geo_editor_menu.addAction(
  331. QtGui.QIcon('share/rectangle32.png'), _('Add Rectangle\tR')
  332. )
  333. self.geo_add_polygon_menuitem = self.geo_editor_menu.addAction(
  334. QtGui.QIcon('share/polygon32.png'), _('Add Polygon\tN')
  335. )
  336. self.geo_add_path_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/path32.png'), _('Add Path\tP'))
  337. self.geo_editor_menu.addSeparator()
  338. self.geo_add_text_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/text32.png'), _('Add Text\tT'))
  339. self.geo_editor_menu.addSeparator()
  340. self.geo_union_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/union16.png'),
  341. _('Polygon Union\tU'))
  342. self.geo_intersection_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/intersection16.png'),
  343. _('Polygon Intersection\tE'))
  344. self.geo_subtract_menuitem = self.geo_editor_menu.addAction(
  345. QtGui.QIcon('share/subtract16.png'), _('Polygon Subtraction\tS')
  346. )
  347. self.geo_editor_menu.addSeparator()
  348. self.geo_cutpath_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/cutpath16.png'),
  349. _('Cut Path\tX'))
  350. # self.move_menuitem = self.menu.addAction(QtGui.QIcon('share/move16.png'), "Move Objects 'm'")
  351. self.geo_copy_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/copy16.png'), _("Copy Geom\tC"))
  352. self.geo_delete_menuitem = self.geo_editor_menu.addAction(
  353. QtGui.QIcon('share/deleteshape16.png'), _("Delete Shape\tDEL")
  354. )
  355. self.geo_editor_menu.addSeparator()
  356. self.geo_move_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/move32.png'), _("Move\tM"))
  357. self.geo_buffer_menuitem = self.geo_editor_menu.addAction(
  358. QtGui.QIcon('share/buffer16.png'),_( "Buffer Tool\tB")
  359. )
  360. self.geo_paint_menuitem = self.geo_editor_menu.addAction(
  361. QtGui.QIcon('share/paint16.png'), _("Paint Tool\tI")
  362. )
  363. self.geo_transform_menuitem = self.geo_editor_menu.addAction(
  364. QtGui.QIcon('share/transform.png'),_( "Transform Tool\tALT+R")
  365. )
  366. self.geo_editor_menu.addSeparator()
  367. self.geo_cornersnap_menuitem = self.geo_editor_menu.addAction(
  368. QtGui.QIcon('share/corner32.png'), _("Toggle Corner Snap\tK")
  369. )
  370. self.exc_editor_menu = QtWidgets.QMenu(_(">Excellon Editor<"))
  371. self.menu.addMenu(self.exc_editor_menu)
  372. self.exc_add_array_drill_menuitem = self.exc_editor_menu.addAction(
  373. QtGui.QIcon('share/rectangle32.png'), _('Add Drill Array\tA'))
  374. self.exc_add_drill_menuitem = self.exc_editor_menu.addAction(QtGui.QIcon('share/plus16.png'),
  375. _('Add Drill\tD'))
  376. self.exc_editor_menu.addSeparator()
  377. self.exc_resize_drill_menuitem = self.exc_editor_menu.addAction(
  378. QtGui.QIcon('share/resize16.png'), _('Resize Drill(S)\tR')
  379. )
  380. self.exc_copy_drill_menuitem = self.exc_editor_menu.addAction(QtGui.QIcon('share/copy32.png'), _('Copy\tC'))
  381. self.exc_delete_drill_menuitem = self.exc_editor_menu.addAction(
  382. QtGui.QIcon('share/deleteshape32.png'), _('Delete\tDEL')
  383. )
  384. self.exc_editor_menu.addSeparator()
  385. self.exc_move_drill_menuitem = self.exc_editor_menu.addAction(
  386. QtGui.QIcon('share/move32.png'),_( 'Move Drill(s)\tM'))
  387. ### APPLICATION GERBER EDITOR MENU ###
  388. self.grb_editor_menu = QtWidgets.QMenu(_(">Gerber Editor<"))
  389. self.menu.addMenu(self.grb_editor_menu)
  390. self.grb_add_pad_menuitem = self.grb_editor_menu.addAction(
  391. QtGui.QIcon('share/aperture16.png'), _('Add Pad\tP'))
  392. self.grb_add_pad_array_menuitem = self.grb_editor_menu.addAction(
  393. QtGui.QIcon('share/padarray32.png'), _('Add Pad Array\tA'))
  394. self.grb_add_track_menuitem = self.grb_editor_menu.addAction(
  395. QtGui.QIcon('share/track32.png'), _('Add Track\tT'))
  396. self.grb_add_region_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/rectangle32.png'),
  397. _('Add Region\tN'))
  398. self.grb_editor_menu.addSeparator()
  399. self.grb_convert_poly_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/poligonize32.png'),
  400. _("Poligonize\tALT+N"))
  401. self.grb_add_semidisc_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/semidisc32.png'),
  402. _("Add SemiDisc\tE"))
  403. self.grb_add_disc_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/disc32.png'),
  404. _("Add Disc\tD"))
  405. self.grb_add_buffer_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/buffer16-2.png'),
  406. _('Buffer\tB'))
  407. self.grb_add_scale_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/scale32.png'),
  408. _('Scale\tS'))
  409. self.grb_transform_menuitem = self.grb_editor_menu.addAction(
  410. QtGui.QIcon('share/transform.png'),_( "Transform\tALT+R")
  411. )
  412. self.grb_editor_menu.addSeparator()
  413. self.grb_copy_menuitem = self.grb_editor_menu.addAction(QtGui.QIcon('share/copy32.png'), _('Copy\tC'))
  414. self.grb_delete_menuitem = self.grb_editor_menu.addAction(
  415. QtGui.QIcon('share/deleteshape32.png'), _('Delete\tDEL')
  416. )
  417. self.grb_editor_menu.addSeparator()
  418. self.grb_move_menuitem = self.grb_editor_menu.addAction(
  419. QtGui.QIcon('share/move32.png'),_( 'Move\tM'))
  420. self.grb_editor_menu.menuAction().setVisible(False)
  421. self.grb_editor_menu.setDisabled(True)
  422. self.geo_editor_menu.menuAction().setVisible(False)
  423. self.geo_editor_menu.setDisabled(True)
  424. self.exc_editor_menu.menuAction().setVisible(False)
  425. self.exc_editor_menu.setDisabled(True)
  426. ################################
  427. ### Project Tab Context menu ###
  428. ################################
  429. self.menuproject = QtWidgets.QMenu()
  430. self.menuprojectenable = self.menuproject.addAction(QtGui.QIcon('share/replot32.png'), _('Enable Plot'))
  431. self.menuprojectdisable = self.menuproject.addAction(QtGui.QIcon('share/clear_plot32.png'), _('Disable Plot'))
  432. self.menuproject.addSeparator()
  433. self.menuprojectgeneratecnc = self.menuproject.addAction(QtGui.QIcon('share/cnc32.png'), _('Generate CNC'))
  434. self.menuprojectviewsource = self.menuproject.addAction(QtGui.QIcon('share/source32.png'), _('View Source'))
  435. self.menuprojectedit = self.menuproject.addAction(QtGui.QIcon('share/edit_ok32.png'), _('Edit'))
  436. self.menuprojectcopy = self.menuproject.addAction(QtGui.QIcon('share/copy32.png'), _('Copy'))
  437. self.menuprojectdelete = self.menuproject.addAction(QtGui.QIcon('share/delete32.png'), _('Delete'))
  438. self.menuprojectsave= self.menuproject.addAction(QtGui.QIcon('share/save_as.png'), _('Save'))
  439. self.menuproject.addSeparator()
  440. self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), _('Properties'))
  441. ################
  442. ### Splitter ###
  443. ################
  444. # IMPORTANT #
  445. # The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
  446. # desired.
  447. self.splitter = QtWidgets.QSplitter()
  448. self.setCentralWidget(self.splitter)
  449. # self.notebook = QtWidgets.QTabWidget()
  450. self.notebook = FCDetachableTab(protect=True)
  451. self.notebook.setTabsClosable(False)
  452. self.notebook.useOldIndex(True)
  453. self.splitter.addWidget(self.notebook)
  454. self.splitter_left = QtWidgets.QSplitter(Qt.Vertical)
  455. self.splitter.addWidget(self.splitter_left)
  456. self.splitter_left.addWidget(self.notebook)
  457. self.splitter_left.setHandleWidth(0)
  458. ###############
  459. ### Toolbar ###
  460. ###############
  461. ### TOOLBAR INSTALLATION ###
  462. self.toolbarfile = QtWidgets.QToolBar(_('File Toolbar'))
  463. self.toolbarfile.setObjectName('File_TB')
  464. self.addToolBar(self.toolbarfile)
  465. self.toolbargeo = QtWidgets.QToolBar(_('Edit Toolbar'))
  466. self.toolbargeo.setObjectName('Edit_TB')
  467. self.addToolBar(self.toolbargeo)
  468. self.toolbarview = QtWidgets.QToolBar(_('View Toolbar'))
  469. self.toolbarview.setObjectName('View_TB')
  470. self.addToolBar(self.toolbarview)
  471. self.toolbarshell = QtWidgets.QToolBar(_('Shell Toolbar'))
  472. self.toolbarshell.setObjectName('Shell_TB')
  473. self.addToolBar(self.toolbarshell)
  474. self.toolbartools = QtWidgets.QToolBar(_('Tools Toolbar'))
  475. self.toolbartools.setObjectName('Tools_TB')
  476. self.addToolBar(self.toolbartools)
  477. self.exc_edit_toolbar = QtWidgets.QToolBar(_('Excellon Editor Toolbar'))
  478. self.exc_edit_toolbar.setObjectName('ExcEditor_TB')
  479. self.addToolBar(self.exc_edit_toolbar)
  480. self.geo_edit_toolbar = QtWidgets.QToolBar(_('Geometry Editor Toolbar'))
  481. self.geo_edit_toolbar.setObjectName('GeoEditor_TB')
  482. self.addToolBar(self.geo_edit_toolbar)
  483. self.grb_edit_toolbar = QtWidgets.QToolBar(_('Gerber Editor Toolbar'))
  484. self.grb_edit_toolbar.setObjectName('GrbEditor_TB')
  485. self.addToolBar(self.grb_edit_toolbar)
  486. self.snap_toolbar = QtWidgets.QToolBar(_('Grid Toolbar'))
  487. self.snap_toolbar.setObjectName('Snap_TB')
  488. self.addToolBar(self.snap_toolbar)
  489. settings = QSettings("Open Source", "FlatCAM")
  490. if settings.contains("layout"):
  491. layout = settings.value('layout', type=str)
  492. if layout == 'standard':
  493. pass
  494. elif layout == 'compact':
  495. self.removeToolBar(self.snap_toolbar)
  496. self.snap_toolbar.setMaximumHeight(30)
  497. self.splitter_left.addWidget(self.snap_toolbar)
  498. ### File Toolbar ###
  499. self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
  500. _("Open Gerber"))
  501. self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), _("Open Excellon"))
  502. self.toolbarfile.addSeparator()
  503. self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), _("Open project"))
  504. self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), _("Save project"))
  505. ### Edit Toolbar ###
  506. self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), _("New Blank Geometry"))
  507. self.newgrb_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32.png'), _("New Blank Gerber"))
  508. self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), _("New Blank Excellon"))
  509. self.toolbargeo.addSeparator()
  510. self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), _("Editor"))
  511. self.update_obj_btn = self.toolbargeo.addAction(
  512. QtGui.QIcon('share/edit_ok32_bis.png'), _("Save Object and close the Editor")
  513. )
  514. self.toolbargeo.addSeparator()
  515. self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), _("&Delete"))
  516. ### View Toolbar ###
  517. self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), _("&Replot"))
  518. self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), _("&Clear plot"))
  519. self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), _("Zoom In"))
  520. self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), _("Zoom Out"))
  521. self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), _("Zoom Fit"))
  522. # self.toolbarview.setVisible(False)
  523. ### Shell Toolbar ###
  524. self.shell_btn = self.toolbarshell.addAction(QtGui.QIcon('share/shell32.png'), _("&Command Line"))
  525. ### Tools Toolbar ###
  526. self.dblsided_btn = self.toolbartools.addAction(QtGui.QIcon('share/doubleside32.png'), _("2Sided Tool"))
  527. self.cutout_btn = self.toolbartools.addAction(QtGui.QIcon('share/cut16_bis.png'), _("&Cutout Tool"))
  528. self.ncc_btn = self.toolbartools.addAction(QtGui.QIcon('share/ncc16.png'), _("NCC Tool"))
  529. self.paint_btn = self.toolbartools.addAction(QtGui.QIcon('share/paint20_1.png'), _("Paint Tool"))
  530. self.toolbartools.addSeparator()
  531. self.panelize_btn = self.toolbartools.addAction(QtGui.QIcon('share/panel16.png'), _("Panel Tool"))
  532. self.film_btn = self.toolbartools.addAction(QtGui.QIcon('share/film16.png'),_( "Film Tool"))
  533. self.solder_btn = self.toolbartools.addAction(QtGui.QIcon('share/solderpastebis32.png'), _("SolderPaste Tool"))
  534. self.silk_btn = self.toolbartools.addAction(QtGui.QIcon('share/silk32.png'), _("Silkscreen Tool"))
  535. self.toolbartools.addSeparator()
  536. self.calculators_btn = self.toolbartools.addAction(QtGui.QIcon('share/calculator24.png'), _("Calculators Tool"))
  537. self.transform_btn = self.toolbartools.addAction(QtGui.QIcon('share/transform.png'), _("Transform Tool"))
  538. ### Drill Editor Toolbar ###
  539. self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
  540. self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), _('Add Drill Hole'))
  541. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  542. QtGui.QIcon('share/addarray16.png'), _('Add Drill Hole Array'))
  543. self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), _('Resize Drill'))
  544. self.exc_edit_toolbar.addSeparator()
  545. self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _('Copy Drill'))
  546. self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'), _("Delete Drill"))
  547. self.exc_edit_toolbar.addSeparator()
  548. self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Drill"))
  549. ### Geometry Editor Toolbar ###
  550. self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
  551. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), _('Add Circle'))
  552. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), _('Add Arc'))
  553. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'),
  554. _('Add Rectangle'))
  555. self.geo_edit_toolbar.addSeparator()
  556. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), _('Add Path'))
  557. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), _('Add Polygon'))
  558. self.geo_edit_toolbar.addSeparator()
  559. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), _('Add Text'))
  560. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), _('Add Buffer'))
  561. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), _('Paint Shape'))
  562. self.geo_edit_toolbar.addSeparator()
  563. self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), _('Polygon Union'))
  564. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
  565. _('Polygon Intersection'))
  566. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'),
  567. _('Polygon Subtraction'))
  568. self.geo_edit_toolbar.addSeparator()
  569. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), _('Cut Path'))
  570. self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _("Copy Shape(s)"))
  571. self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'),
  572. _("Delete Shape '-'"))
  573. self.geo_transform_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/transform.png'),
  574. _("Transformations"))
  575. self.geo_edit_toolbar.addSeparator()
  576. self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Objects "))
  577. ### Gerber Editor Toolbar ###
  578. self.grb_select_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
  579. self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/aperture32.png'), _("Add Pad"))
  580. self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/padarray32.png'), _('Add Pad Array'))
  581. self.grb_add_track_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/track32.png'), _("Add Track"))
  582. self.grb_add_region_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), _("Add Region"))
  583. self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/poligonize32.png'),
  584. _("Poligonize"))
  585. self.grb_add_semidisc_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/semidisc32.png'), _("SemiDisc"))
  586. self.grb_add_disc_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/disc32.png'), _("Disc"))
  587. self.grb_edit_toolbar.addSeparator()
  588. self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), _('Buffer'))
  589. self.aperture_scale_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/scale32.png'), _('Scale'))
  590. self.grb_edit_toolbar.addSeparator()
  591. self.aperture_copy_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _("Copy"))
  592. self.aperture_delete_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'),
  593. _("Delete"))
  594. self.grb_transform_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/transform.png'),
  595. _("Transformations"))
  596. self.grb_edit_toolbar.addSeparator()
  597. self.aperture_move_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
  598. ### Snap Toolbar ###
  599. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  600. # self.addToolBar(self.snap_toolbar)
  601. self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), _('Snap to grid'))
  602. self.grid_gap_x_entry = FCEntry2()
  603. self.grid_gap_x_entry.setMaximumWidth(70)
  604. self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
  605. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  606. self.grid_gap_y_entry = FCEntry2()
  607. self.grid_gap_y_entry.setMaximumWidth(70)
  608. self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
  609. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  610. self.grid_space_label = QtWidgets.QLabel(" ")
  611. self.snap_toolbar.addWidget(self.grid_space_label)
  612. self.grid_gap_link_cb = FCCheckBox()
  613. self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
  614. "is copied to the Grid_Y value."))
  615. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  616. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  617. self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), _('Snap to corner'))
  618. self.snap_max_dist_entry = FCEntry()
  619. self.snap_max_dist_entry.setMaximumWidth(70)
  620. self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
  621. self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  622. ################
  623. ### Notebook ###
  624. ################
  625. ### Project ###
  626. self.project_tab = QtWidgets.QWidget()
  627. self.project_tab.setObjectName("project_tab")
  628. # project_tab.setMinimumWidth(250) # Hack
  629. self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_tab)
  630. self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
  631. self.notebook.addTab(self.project_tab,_( "Project"))
  632. ### Selected ###
  633. self.selected_tab = QtWidgets.QWidget()
  634. self.selected_tab.setObjectName("selected_tab")
  635. self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab)
  636. self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
  637. self.selected_scroll_area = VerticalScrollArea()
  638. self.selected_tab_layout.addWidget(self.selected_scroll_area)
  639. self.notebook.addTab(self.selected_tab, _("Selected"))
  640. ### Tool ###
  641. self.tool_tab = QtWidgets.QWidget()
  642. self.tool_tab.setObjectName("tool_tab")
  643. self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab)
  644. self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
  645. self.notebook.addTab(self.tool_tab, _("Tool"))
  646. self.tool_scroll_area = VerticalScrollArea()
  647. self.tool_tab_layout.addWidget(self.tool_scroll_area)
  648. self.right_widget = QtWidgets.QWidget()
  649. self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
  650. self.splitter.addWidget(self.right_widget)
  651. self.right_lay = QtWidgets.QVBoxLayout()
  652. self.right_lay.setContentsMargins(0, 0, 0, 0)
  653. self.right_widget.setLayout(self.right_lay)
  654. # self.plot_tab_area = FCTab()
  655. self.plot_tab_area = FCDetachableTab(protect=False, protect_by_name=[_('Plot Area')])
  656. self.plot_tab_area.useOldIndex(True)
  657. self.right_lay.addWidget(self.plot_tab_area)
  658. self.plot_tab_area.setTabsClosable(True)
  659. self.plot_tab = QtWidgets.QWidget()
  660. self.plot_tab.setObjectName("plotarea")
  661. self.plot_tab_area.addTab(self.plot_tab, _("Plot Area"))
  662. self.right_layout = QtWidgets.QVBoxLayout()
  663. self.right_layout.setContentsMargins(2, 2, 2, 2)
  664. self.plot_tab.setLayout(self.right_layout)
  665. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  666. self.plot_tab_area.protectTab(0)
  667. ########################################
  668. ### HERE WE BUILD THE PREF. TAB AREA ###
  669. ########################################
  670. self.preferences_tab = QtWidgets.QWidget()
  671. self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
  672. self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
  673. self.pref_tab_area = FCTab()
  674. self.pref_tab_area.setTabsClosable(False)
  675. self.pref_tab_area_tabBar = self.pref_tab_area.tabBar()
  676. self.pref_tab_area_tabBar.setStyleSheet("QTabBar::tab{width:90px;}")
  677. self.pref_tab_area_tabBar.setExpanding(True)
  678. self.pref_tab_layout.addWidget(self.pref_tab_area)
  679. self.general_tab = QtWidgets.QWidget()
  680. self.pref_tab_area.addTab(self.general_tab, _("General"))
  681. self.general_tab_lay = QtWidgets.QVBoxLayout()
  682. self.general_tab_lay.setContentsMargins(2, 2, 2, 2)
  683. self.general_tab.setLayout(self.general_tab_lay)
  684. self.hlay1 = QtWidgets.QHBoxLayout()
  685. self.general_tab_lay.addLayout(self.hlay1)
  686. self.options_combo = QtWidgets.QComboBox()
  687. self.options_combo.addItem(_("APP. DEFAULTS"))
  688. self.options_combo.addItem(_("PROJ. OPTIONS "))
  689. self.hlay1.addWidget(self.options_combo)
  690. # disable this button as it may no longer be useful
  691. self.options_combo.setVisible(False)
  692. self.hlay1.addStretch()
  693. self.general_scroll_area = QtWidgets.QScrollArea()
  694. self.general_tab_lay.addWidget(self.general_scroll_area)
  695. self.gerber_tab = QtWidgets.QWidget()
  696. self.pref_tab_area.addTab(self.gerber_tab, _("GERBER"))
  697. self.gerber_tab_lay = QtWidgets.QVBoxLayout()
  698. self.gerber_tab_lay.setContentsMargins(2, 2, 2, 2)
  699. self.gerber_tab.setLayout(self.gerber_tab_lay)
  700. self.gerber_scroll_area = QtWidgets.QScrollArea()
  701. self.gerber_tab_lay.addWidget(self.gerber_scroll_area)
  702. self.excellon_tab = QtWidgets.QWidget()
  703. self.pref_tab_area.addTab(self.excellon_tab, _("EXCELLON"))
  704. self.excellon_tab_lay = QtWidgets.QVBoxLayout()
  705. self.excellon_tab_lay.setContentsMargins(2, 2, 2, 2)
  706. self.excellon_tab.setLayout(self.excellon_tab_lay)
  707. self.excellon_scroll_area = QtWidgets.QScrollArea()
  708. self.excellon_tab_lay.addWidget(self.excellon_scroll_area)
  709. self.geometry_tab = QtWidgets.QWidget()
  710. self.pref_tab_area.addTab(self.geometry_tab, _("GEOMETRY"))
  711. self.geometry_tab_lay = QtWidgets.QVBoxLayout()
  712. self.geometry_tab_lay.setContentsMargins(2, 2, 2, 2)
  713. self.geometry_tab.setLayout(self.geometry_tab_lay)
  714. self.geometry_scroll_area = QtWidgets.QScrollArea()
  715. self.geometry_tab_lay.addWidget(self.geometry_scroll_area)
  716. self.cncjob_tab = QtWidgets.QWidget()
  717. self.cncjob_tab.setObjectName("cncjob_tab")
  718. self.pref_tab_area.addTab(self.cncjob_tab, _("CNC-JOB"))
  719. self.cncjob_tab_lay = QtWidgets.QVBoxLayout()
  720. self.cncjob_tab_lay.setContentsMargins(2, 2, 2, 2)
  721. self.cncjob_tab.setLayout(self.cncjob_tab_lay)
  722. self.cncjob_scroll_area = QtWidgets.QScrollArea()
  723. self.cncjob_tab_lay.addWidget(self.cncjob_scroll_area)
  724. self.tools_tab = QtWidgets.QWidget()
  725. self.pref_tab_area.addTab(self.tools_tab, _("TOOLS"))
  726. self.tools_tab_lay = QtWidgets.QVBoxLayout()
  727. self.tools_tab_lay.setContentsMargins(2, 2, 2, 2)
  728. self.tools_tab.setLayout(self.tools_tab_lay)
  729. self.tools_scroll_area = QtWidgets.QScrollArea()
  730. self.tools_tab_lay.addWidget(self.tools_scroll_area)
  731. self.pref_tab_bottom_layout = QtWidgets.QHBoxLayout()
  732. self.pref_tab_bottom_layout.setAlignment(QtCore.Qt.AlignVCenter)
  733. self.pref_tab_layout.addLayout(self.pref_tab_bottom_layout)
  734. self.pref_tab_bottom_layout_1 = QtWidgets.QHBoxLayout()
  735. self.pref_tab_bottom_layout_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  736. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_1)
  737. self.pref_import_button = QtWidgets.QPushButton()
  738. self.pref_import_button.setText(_("Import Preferences"))
  739. self.pref_import_button.setFixedWidth(130)
  740. self.pref_import_button.setToolTip(
  741. _("Import a full set of FlatCAM settings from a file\n"
  742. "previously saved on HDD.\n\n"
  743. "FlatCAM automatically save a 'factory_defaults' file\n"
  744. "on the first start. Do not delete that file."))
  745. self.pref_tab_bottom_layout_1.addWidget(self.pref_import_button)
  746. self.pref_export_button = QtWidgets.QPushButton()
  747. self.pref_export_button.setText(_("Export Preferences"))
  748. self.pref_export_button.setFixedWidth(130)
  749. self.pref_export_button.setToolTip(
  750. _( "Export a full set of FlatCAM settings in a file\n"
  751. "that is saved on HDD."))
  752. self.pref_tab_bottom_layout_1.addWidget(self.pref_export_button)
  753. self.pref_open_button = QtWidgets.QPushButton()
  754. self.pref_open_button.setText(_("Open Pref Folder"))
  755. self.pref_open_button.setFixedWidth(130)
  756. self.pref_open_button.setToolTip(
  757. _("Open the folder where FlatCAM save the preferences files."))
  758. self.pref_tab_bottom_layout_1.addWidget(self.pref_open_button)
  759. self.pref_tab_bottom_layout_2 = QtWidgets.QHBoxLayout()
  760. self.pref_tab_bottom_layout_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  761. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_2)
  762. self.pref_save_button = QtWidgets.QPushButton()
  763. self.pref_save_button.setText(_("Save Preferences"))
  764. self.pref_save_button.setFixedWidth(130)
  765. self.pref_save_button.setToolTip(
  766. _("Save the current settings in the 'current_defaults' file\n"
  767. "which is the file storing the working default preferences."))
  768. self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
  769. ########################################
  770. ### HERE WE BUILD THE SHORTCUTS LIST. TAB AREA ###
  771. ########################################
  772. self.shortcuts_tab = QtWidgets.QWidget()
  773. self.sh_tab_layout = QtWidgets.QVBoxLayout()
  774. self.sh_tab_layout.setContentsMargins(2, 2, 2, 2)
  775. self.shortcuts_tab.setLayout(self.sh_tab_layout)
  776. self.sh_hlay = QtWidgets.QHBoxLayout()
  777. self.sh_title = QtWidgets.QTextEdit(
  778. _('<b>Shortcut Key List</b>'))
  779. self.sh_title.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  780. self.sh_title.setFrameStyle(QtWidgets.QFrame.NoFrame)
  781. self.sh_title.setMaximumHeight(30)
  782. font = self.sh_title.font()
  783. font.setPointSize(12)
  784. self.sh_title.setFont(font)
  785. self.sh_tab_layout.addWidget(self.sh_title)
  786. self.sh_tab_layout.addLayout(self.sh_hlay)
  787. self.app_sh_msg = _(
  788. '''<b>General Shortcut list</b><br>
  789. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  790. <tbody>
  791. <tr height="20">
  792. <td height="20" width="89"><strong>F3</strong></td>
  793. <td width="194"><span style="color:#006400"><strong>&nbsp;SHOW SHORTCUT LIST</strong></span></td>
  794. </tr>
  795. <tr height="20">
  796. <td height="20">&nbsp;</td>
  797. <td>&nbsp;</td>
  798. </tr>
  799. <tr height="20">
  800. <td height="20"><strong>1</strong></td>
  801. <td>&nbsp;Switch to Project Tab</td>
  802. </tr>
  803. <tr height="20">
  804. <td height="20"><strong>2</strong></td>
  805. <td>&nbsp;Switch to Selected Tab</td>
  806. </tr>
  807. <tr height="20">
  808. <td height="20"><strong>3</strong></td>
  809. <td>&nbsp;Switch to Tool Tab</td>
  810. </tr>
  811. <tr height="20">
  812. <td height="20">&nbsp;</td>
  813. <td>&nbsp;</td>
  814. </tr>
  815. <tr height="20">
  816. <td height="20"><strong>B</strong></td>
  817. <td>&nbsp;New Gerber</td>
  818. </tr>
  819. <tr height="20">
  820. <td height="20"><strong>E</strong></td>
  821. <td>&nbsp;Edit Object (if selected)</td>
  822. </tr>
  823. <tr height="20">
  824. <td height="20"><strong>G</strong></td>
  825. <td>&nbsp;Grid On/Off</td>
  826. </tr>
  827. <tr height="20">
  828. <td height="20"><strong>J</strong></td>
  829. <td>&nbsp;Jump to Coordinates</td>
  830. </tr>
  831. <tr height="20">
  832. <td height="20"><strong>L</strong></td>
  833. <td>&nbsp;New Excellon</td>
  834. </tr>
  835. <tr height="20">
  836. <td height="20"><strong>M</strong></td>
  837. <td>&nbsp;Move Obj</td>
  838. </tr>
  839. <tr height="20">
  840. <td height="20"><strong>N</strong></td>
  841. <td>&nbsp;New Geometry</td>
  842. </tr>
  843. <tr height="20">
  844. <td height="20"><strong>O</strong></td>
  845. <td>&nbsp;Set Origin</td>
  846. </tr>
  847. <tr height="20">
  848. <td height="20"><strong>Q</strong></td>
  849. <td>&nbsp;Change Units</td>
  850. </tr>
  851. <tr height="20">
  852. <td height="20"><strong>P</strong></td>
  853. <td>&nbsp;Open Properties Tool</td>
  854. </tr>
  855. <tr height="20">
  856. <td height="20"><strong>R</strong></td>
  857. <td>&nbsp;Rotate by 90 degree CW</td>
  858. </tr>
  859. <tr height="20">
  860. <td height="20"><strong>S</strong></td>
  861. <td>&nbsp;Shell Toggle</td>
  862. </tr>
  863. <tr height="20">
  864. <td height="20"><strong>T</strong></td>
  865. <td>&nbsp;Add a Tool (when in Geometry Selected Tab or in Tools NCC or Tools Paint)</td>
  866. </tr>
  867. <tr height="20">
  868. <td height="20"><strong>V</strong></td>
  869. <td>&nbsp;Zoom Fit</td>
  870. </tr>
  871. <tr height="20">
  872. <td height="20"><strong>X</strong></td>
  873. <td>&nbsp;Flip on X_axis</td>
  874. </tr>
  875. <tr height="20">
  876. <td height="20"><strong>Y</strong></td>
  877. <td>&nbsp;Flip on Y_axis</td>
  878. </tr>
  879. <tr height="20">
  880. <td height="20"><strong>&#39;=&#39;</strong></td>
  881. <td>&nbsp;Zoom Out</td>
  882. </tr>
  883. <tr height="20">
  884. <td height="20"><strong>&#39;-&#39;</strong></td>
  885. <td>&nbsp;Zoom In</td>
  886. </tr>
  887. <tr height="20">
  888. <td height="20">&nbsp;</td>
  889. <td>&nbsp;</td>
  890. </tr>
  891. <tr height="20">
  892. <td height="20"><strong>CTRL+A</strong></td>
  893. <td>&nbsp;Select All</td>
  894. </tr>
  895. <tr height="20">
  896. <td height="20"><strong>CTRL+C</strong></td>
  897. <td>&nbsp;Copy Obj</td>
  898. </tr>
  899. <tr height="20">
  900. <td height="20"><strong>CTRL+E</strong></td>
  901. <td>&nbsp;Open Excellon File</td>
  902. </tr>
  903. <tr height="20">
  904. <td height="20"><strong>CTRL+G</strong></td>
  905. <td>&nbsp;Open Gerber File</td>
  906. </tr>
  907. <tr height="20">
  908. <td height="20"><strong>CTRL+N</strong></td>
  909. <td>&nbsp;New Project</td>
  910. </tr>
  911. <tr height="20">
  912. <td height="20"><strong>CTRL+M</strong></td>
  913. <td>&nbsp;Measurement Tool</td>
  914. </tr>
  915. <tr height="20">
  916. <td height="20"><strong>CTRL+O</strong></td>
  917. <td>&nbsp;Open Project</td>
  918. </tr>
  919. <tr height="20">
  920. <td height="20"><strong>CTRL+S</strong></td>
  921. <td>&nbsp;Save Project As</td>
  922. </tr>
  923. <tr height="20">
  924. <td height="20"><strong>CTRL+F10</strong></td>
  925. <td>&nbsp;Toggle Plot Area</td>
  926. </tr>
  927. <tr height="20">
  928. <td height="20">&nbsp;</td>
  929. <td>&nbsp;</td>
  930. </tr>
  931. <tr height="20">
  932. <td height="20"><strong>SHIFT+C</strong></td>
  933. <td>&nbsp;Copy Obj_Name</td>
  934. </tr>
  935. <tr height="20">
  936. <td height="20"><strong>SHIFT+E</strong></td>
  937. <td>&nbsp;Toggle Code Editor</td>
  938. </tr>
  939. <tr height="20">
  940. <td height="20"><strong>SHIFT+G</strong></td>
  941. <td>&nbsp;Toggle the axis</td>
  942. </tr>
  943. <tr height="20">
  944. <td height="20"><strong>SHIFT+P</strong></td>
  945. <td>&nbsp;Open Preferences Window</td>
  946. </tr>
  947. <tr height="20">
  948. <td height="20"><strong>SHIFT+R</strong></td>
  949. <td>&nbsp;Rotate by 90 degree CCW</td>
  950. </tr>
  951. <tr height="20">
  952. <td height="20"><strong>SHIFT+S</strong></td>
  953. <td>&nbsp;Run a Script</td>
  954. </tr>
  955. <tr height="20">
  956. <td height="20"><strong>SHIFT+W</strong></td>
  957. <td>&nbsp;Toggle the workspace</td>
  958. </tr>
  959. <tr height="20">
  960. <td height="20"><strong>SHIFT+X</strong></td>
  961. <td>&nbsp;Skew on X axis</td>
  962. </tr>
  963. <tr height="20">
  964. <td height="20"><strong>SHIFT+Y</strong></td>
  965. <td>&nbsp;Skew on Y axis</td>
  966. </tr>
  967. <tr height="20">
  968. <td height="20">&nbsp;</td>
  969. <td>&nbsp;</td>
  970. </tr>
  971. <tr height="20">
  972. <td height="20"><strong>ALT+C</strong></td>
  973. <td>&nbsp;Calculators Tool</td>
  974. </tr>
  975. <tr height="20">
  976. <td height="20"><strong>ALT+D</strong></td>
  977. <td>&nbsp;2-Sided PCB Tool</td>
  978. </tr>
  979. <tr height="20">
  980. <td height="20"><strong>ALT+K</strong></td>
  981. <td>&nbsp;Solder Paste Dispensing Tool</td>
  982. </tr>
  983. <tr height="20">
  984. <td height="20"><strong>ALT+L</strong></td>
  985. <td>&nbsp;Film PCB Tool</td>
  986. </tr>
  987. <tr height="20">
  988. <td height="20"><strong>ALT+N</strong></td>
  989. <td>&nbsp;Non-Copper Clearing Tool</td>
  990. </tr>
  991. <tr height="20">
  992. <td height="20"><strong>ALT+P</strong></td>
  993. <td>&nbsp;Paint Area Tool</td>
  994. </tr>
  995. <tr height="20">
  996. <td height="20"><strong>ALT+Q</strong></td>
  997. <td>&nbsp;PDF Import Tool</td>
  998. </tr>
  999. <tr height="20">
  1000. <td height="20"><strong>ALT+R</strong></td>
  1001. <td>&nbsp;Transformations Tool</td>
  1002. </tr>
  1003. <tr height="20">
  1004. <td height="20"><strong>ALT+S</strong></td>
  1005. <td>&nbsp;View File Source</td>
  1006. </tr>
  1007. <tr height="20">
  1008. <td height="20"><strong>ALT+U</strong></td>
  1009. <td>&nbsp;Cutout PCB Tool</td>
  1010. </tr>
  1011. <tr height="20">
  1012. <td height="20"><strong>ALT+1</strong></td>
  1013. <td>&nbsp;Enable all Plots</td>
  1014. </tr>
  1015. <tr height="20">
  1016. <td height="20"><strong>ALT+2</strong></td>
  1017. <td>&nbsp;Disable all Plots</td>
  1018. </tr>
  1019. <tr height="20">
  1020. <td height="20"><strong>ALT+3</strong></td>
  1021. <td>&nbsp;Disable Non-selected Plots</td>
  1022. </tr>
  1023. <tr height="20">
  1024. <td height="20"><strong>ALT+F10</strong></td>
  1025. <td>&nbsp;Toggle Full Screen</td>
  1026. </tr>
  1027. <tr height="20">
  1028. <td height="20">&nbsp;</td>
  1029. <td>&nbsp;</td>
  1030. </tr>
  1031. <tr height="20">
  1032. <td height="20"><strong>F1</strong></td>
  1033. <td>&nbsp;Open Online Manual</td>
  1034. </tr>
  1035. <tr height="20">
  1036. <td height="20"><strong>F4</strong></td>
  1037. <td>&nbsp;Open Online Tutorials</td>
  1038. </tr>
  1039. <tr height="20">
  1040. <td height="20"><strong>Del</strong></td>
  1041. <td>&nbsp;Delete Object</td>
  1042. </tr>
  1043. <tr height="20">
  1044. <td height="20"><strong>Del</strong></td>
  1045. <td>&nbsp;Alternate: Delete Tool</td>
  1046. </tr>
  1047. <tr height="20">
  1048. <td height="20"><strong>'`'</strong></td>
  1049. <td>&nbsp;(left to Key_1)Toogle Notebook Area (Left Side)</td>
  1050. </tr>
  1051. <tr height="20">
  1052. <td height="20"><strong>SPACE</strong></td>
  1053. <td>&nbsp;En(Dis)able Obj Plot</td>
  1054. </tr>
  1055. <tr height="20">
  1056. <td height="20"><strong>Escape</strong></td>
  1057. <td>&nbsp;Deselects all objects</td>
  1058. </tr>
  1059. </tbody>
  1060. </table>
  1061. '''
  1062. )
  1063. self.sh_app = QtWidgets.QTextEdit()
  1064. self.sh_app.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1065. self.sh_app.setText(self.app_sh_msg)
  1066. self.sh_app.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  1067. self.sh_hlay.addWidget(self.sh_app)
  1068. self.editor_sh_msg = _(
  1069. '''<b>Editor Shortcut list</b><br>
  1070. <br>
  1071. <strong><span style="color:#0000ff">GEOMETRY EDITOR</span></strong><br>
  1072. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1073. <tbody>
  1074. <tr height="20">
  1075. <td height="20" width="89"><strong>A</strong></td>
  1076. <td width="194">&nbsp;Draw an Arc</td>
  1077. </tr>
  1078. <tr height="20">
  1079. <td height="20"><strong>B</strong></td>
  1080. <td>&nbsp;Buffer Tool</td>
  1081. </tr>
  1082. <tr height="20">
  1083. <td height="20"><strong>C</strong></td>
  1084. <td>&nbsp;Copy Geo Item</td>
  1085. </tr>
  1086. <tr height="20">
  1087. <td height="20"><strong>D</strong></td>
  1088. <td>&nbsp;Within Add Arc will toogle the ARC direction: CW or CCW</td>
  1089. </tr>
  1090. <tr height="20">
  1091. <td height="20"><strong>E</strong></td>
  1092. <td>&nbsp;Polygon Intersection Tool</td>
  1093. </tr>
  1094. <tr height="20">
  1095. <td height="20"><strong>I</strong></td>
  1096. <td>&nbsp;Paint Tool</td>
  1097. </tr>
  1098. <tr height="20">
  1099. <td height="20"><strong>J</strong></td>
  1100. <td>&nbsp;Jump to Location (x, y)</td>
  1101. </tr>
  1102. <tr height="20">
  1103. <td height="20"><strong>K</strong></td>
  1104. <td>&nbsp;Toggle Corner Snap</td>
  1105. </tr>
  1106. <tr height="20">
  1107. <td height="20"><strong>M</strong></td>
  1108. <td>&nbsp;Move Geo Item</td>
  1109. </tr>
  1110. <tr height="20">
  1111. <td height="20"><strong>M</strong></td>
  1112. <td>&nbsp;Within Add Arc will cycle through the ARC modes</td>
  1113. </tr>
  1114. <tr height="20">
  1115. <td height="20"><strong>N</strong></td>
  1116. <td>&nbsp;Draw a Polygon</td>
  1117. </tr>
  1118. <tr height="20">
  1119. <td height="20"><strong>O</strong></td>
  1120. <td>&nbsp;Draw a Circle</td>
  1121. </tr>
  1122. <tr height="20">
  1123. <td height="20"><strong>P</strong></td>
  1124. <td>&nbsp;Draw a Path</td>
  1125. </tr>
  1126. <tr height="20">
  1127. <td height="20"><strong>R</strong></td>
  1128. <td>&nbsp;Draw Rectangle</td>
  1129. </tr>
  1130. <tr height="20">
  1131. <td height="20"><strong>S</strong></td>
  1132. <td>&nbsp;Polygon Substraction Tool</td>
  1133. </tr>
  1134. <tr height="20">
  1135. <td height="20"><strong>T</strong></td>
  1136. <td>&nbsp;Add Text Tool</td>
  1137. </tr>
  1138. <tr height="20">
  1139. <td height="20"><strong>U</strong></td>
  1140. <td>&nbsp;Polygon Union Tool</td>
  1141. </tr>
  1142. <tr height="20">
  1143. <td height="20"><strong>X</strong></td>
  1144. <td>&nbsp;Flip shape on X axis</td>
  1145. </tr>
  1146. <tr height="20">
  1147. <td height="20"><strong>Y</strong></td>
  1148. <td>&nbsp;Flip shape on Y axis</td>
  1149. </tr>
  1150. <tr height="20">
  1151. <td height="20">&nbsp;</td>
  1152. <td>&nbsp;</td>
  1153. </tr>
  1154. <tr height="20">
  1155. <td height="20"><strong>SHIFT+X</strong></td>
  1156. <td>&nbsp;Skew shape on X axis</td>
  1157. </tr>
  1158. <tr height="20">
  1159. <td height="20"><strong>SHIFT+Y</strong></td>
  1160. <td>&nbsp;Skew shape on Y axis</td>
  1161. </tr>
  1162. <tr height="20">
  1163. <td height="20">&nbsp;</td>
  1164. <td>&nbsp;</td>
  1165. </tr>
  1166. <tr height="20">
  1167. <td height="20"><strong>ALT+R</strong></td>
  1168. <td>&nbsp;Editor Transformation Tool</td>
  1169. </tr>
  1170. <tr height="20">
  1171. <td height="20"><strong>ALT+X</strong></td>
  1172. <td>&nbsp;Offset shape on X axis</td>
  1173. </tr>
  1174. <tr height="20">
  1175. <td height="20"><strong>ALT+Y</strong></td>
  1176. <td>&nbsp;Offset shape on Y axis</td>
  1177. </tr>
  1178. <tr height="20">
  1179. <td height="20">&nbsp;</td>
  1180. <td>&nbsp;</td>
  1181. </tr>
  1182. <tr height="20">
  1183. <td height="20"><strong>CTRL+M</strong></td>
  1184. <td>&nbsp;Measurement Tool</td>
  1185. </tr>
  1186. <tr height="20">
  1187. <td height="20"><strong>CTRL+S</strong></td>
  1188. <td>&nbsp;Save Object and Exit Editor</td>
  1189. </tr>
  1190. <tr height="20">
  1191. <td height="20"><strong>CTRL+X</strong></td>
  1192. <td>&nbsp;Polygon Cut Tool</td>
  1193. </tr>
  1194. <tr height="20">
  1195. <td height="20">&nbsp;</td>
  1196. <td>&nbsp;</td>
  1197. </tr>
  1198. <tr height="20">
  1199. <td height="20"><strong>Space</strong></td>
  1200. <td>&nbsp;Rotate Geometry</td>
  1201. </tr>
  1202. <tr height="20">
  1203. <td height="20"><strong>ENTER</strong></td>
  1204. <td>&nbsp;Finish drawing for certain tools</td>
  1205. </tr>
  1206. <tr height="20">
  1207. <td height="20"><strong>ESC</strong></td>
  1208. <td>&nbsp;Abort and return to Select</td>
  1209. </tr>
  1210. <tr height="20">
  1211. <td height="20"><strong>Del</strong></td>
  1212. <td>&nbsp;Delete Shape</td>
  1213. </tr>
  1214. </tbody>
  1215. </table>
  1216. <br>
  1217. <br>
  1218. <strong><span style="color:#ff0000">EXCELLON EDITOR</span></strong><br>
  1219. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1220. <tbody>
  1221. <tr height="20">
  1222. <td height="20" width="89"><strong>A</strong></td>
  1223. <td width="194">&nbsp;Add Drill Array</td>
  1224. </tr>
  1225. <tr height="20">
  1226. <td height="20"><strong>C</strong></td>
  1227. <td>&nbsp;Copy Drill(s)</td>
  1228. </tr>
  1229. <tr height="20">
  1230. <td height="20"><strong>D</strong></td>
  1231. <td>&nbsp;Add Drill</td>
  1232. </tr>
  1233. <tr height="20">
  1234. <td height="20"><strong>J</strong></td>
  1235. <td>&nbsp;Jump to Location (x, y)</td>
  1236. </tr>
  1237. <tr height="20">
  1238. <td height="20"><strong>M</strong></td>
  1239. <td>&nbsp;Move Drill(s)</td>
  1240. </tr>
  1241. <tr height="20">
  1242. <td height="20"><strong>R</strong></td>
  1243. <td>&nbsp;Resize Drill(s)</td>
  1244. </tr>
  1245. <tr height="20">
  1246. <td height="20"><strong>T</strong></td>
  1247. <td>&nbsp;Add a new Tool</td>
  1248. </tr>
  1249. <tr height="20">
  1250. <td height="20">&nbsp;</td>
  1251. <td>&nbsp;</td>
  1252. </tr>
  1253. <tr height="20">
  1254. <td height="20"><strong>Del</strong></td>
  1255. <td>&nbsp;Delete Drill(s)</td>
  1256. </tr>
  1257. <tr height="20">
  1258. <td height="20"><strong>Del</strong></td>
  1259. <td>&nbsp;Alternate: Delete Tool(s)</td>
  1260. </tr>
  1261. <tr height="20">
  1262. <td height="20">&nbsp;</td>
  1263. <td>&nbsp;</td>
  1264. </tr>
  1265. <tr height="20">
  1266. <td height="20"><strong>ESC</strong></td>
  1267. <td>&nbsp;Abort and return to Select</td>
  1268. </tr>
  1269. <tr height="20">
  1270. <td height="20"><strong>CTRL+S</strong></td>
  1271. <td>&nbsp;Save Object and Exit Editor</td>
  1272. </tr>
  1273. </tbody>
  1274. </table>
  1275. <br>
  1276. <br>
  1277. <strong><span style="color:#00ff00">GERBER EDITOR</span></strong><br>
  1278. <table border="0" cellpadding="0" cellspacing="0" style="width:283px">
  1279. <tbody>
  1280. <tr height="20">
  1281. <td height="20" width="89"><strong>A</strong></td>
  1282. <td width="194">&nbsp;Add Pad Array</td>
  1283. </tr>
  1284. <tr height="20">
  1285. <td height="20"><strong>B</strong></td>
  1286. <td>&nbsp;Buffer</td>
  1287. </tr>
  1288. <tr height="20">
  1289. <td height="20"><strong>C</strong></td>
  1290. <td>&nbsp;Copy</td>
  1291. </tr>
  1292. <tr height="20">
  1293. <td height="20"><strong>D</strong></td>
  1294. <td>&nbsp;Add Disc</td>
  1295. </tr>
  1296. <tr height="20">
  1297. <td height="20"><strong>E</strong></td>
  1298. <td>&nbsp;Add SemiDisc</td>
  1299. </tr>
  1300. <tr height="20">
  1301. <td height="20"><strong>J</strong></td>
  1302. <td>&nbsp;Jump to Location (x, y)</td>
  1303. </tr>
  1304. <tr height="20">
  1305. <td height="20"><strong>M</strong></td>
  1306. <td>&nbsp;Move</td>
  1307. </tr>
  1308. <tr height="20">
  1309. <td height="20"><strong>N</strong></td>
  1310. <td>&nbsp;Add Region</td>
  1311. </tr>
  1312. <tr height="20">
  1313. <td height="20"><strong>P</strong></td>
  1314. <td>&nbsp;Add Pad</td>
  1315. </tr>
  1316. <tr height="20">
  1317. <td height="20"><strong>R</strong></td>
  1318. <td>&nbsp;Within Track & Region Tools will cycle in REVERSE the bend modes</td>
  1319. </tr>
  1320. <tr height="20">
  1321. <td height="20"><strong>S</strong></td>
  1322. <td>&nbsp;Scale</td>
  1323. </tr>
  1324. <tr height="20">
  1325. <td height="20"><strong>T</strong></td>
  1326. <td>&nbsp;Add Track</td>
  1327. </tr>
  1328. <tr height="20">
  1329. <td height="20"><strong>T</strong></td>
  1330. <td>&nbsp;Within Track & Region Tools will cycle FORWARD the bend modes</td>
  1331. </tr>
  1332. <tr height="20">
  1333. <td height="20">&nbsp;</td>
  1334. <td>&nbsp;</td>
  1335. </tr>
  1336. <tr height="20">
  1337. <td height="20"><strong>Del</strong></td>
  1338. <td>&nbsp;Delete</td>
  1339. </tr>
  1340. <tr height="20">
  1341. <td height="20"><strong>Del</strong></td>
  1342. <td>&nbsp;Alternate: Delete Apertures</td>
  1343. </tr>
  1344. <tr height="20">
  1345. <td height="20">&nbsp;</td>
  1346. <td>&nbsp;</td>
  1347. </tr>
  1348. <tr height="20">
  1349. <td height="20"><strong>ESC</strong></td>
  1350. <td>&nbsp;Abort and return to Select</td>
  1351. </tr>
  1352. <tr height="20">
  1353. <td height="20"><strong>CTRL+S</strong></td>
  1354. <td>&nbsp;Save Object and Exit Editor</td>
  1355. </tr>
  1356. <tr height="20">
  1357. <td height="20">&nbsp;</td>
  1358. <td>&nbsp;</td>
  1359. </tr>
  1360. <tr height="20">
  1361. <td height="20"><strong>ALT+R</strong></td>
  1362. <td>&nbsp;Transformation Tool</td>
  1363. </tr>
  1364. </tbody>
  1365. </table>
  1366. '''
  1367. )
  1368. self.sh_editor = QtWidgets.QTextEdit()
  1369. self.sh_editor.setTextInteractionFlags(QtCore.Qt.NoTextInteraction)
  1370. self.sh_editor.setText(self.editor_sh_msg)
  1371. self.sh_editor.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
  1372. self.sh_hlay.addWidget(self.sh_editor)
  1373. ##############################################################
  1374. ### HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS ###
  1375. ##############################################################
  1376. self.popMenu = FCMenu()
  1377. self.popmenu_disable = self.popMenu.addAction(QtGui.QIcon('share/clear_plot32.png'), _("Disable"))
  1378. self.popMenu.addSeparator()
  1379. self.cmenu_newmenu = self.popMenu.addMenu(QtGui.QIcon('share/file32.png'), _("New"))
  1380. self.popmenu_new_geo = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_geo32_bis.png'), _("Geometry"))
  1381. self.popmenu_new_exc = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_exc32.png'), _("Excellon"))
  1382. self.cmenu_newmenu.addSeparator()
  1383. self.popmenu_new_prj = self.cmenu_newmenu.addAction(QtGui.QIcon('share/file16.png'), _("Project"))
  1384. self.popMenu.addSeparator()
  1385. self.cmenu_gridmenu = self.popMenu.addMenu(QtGui.QIcon('share/grid32_menu.png'), _("Grids"))
  1386. self.cmenu_viewmenu = self.popMenu.addMenu(QtGui.QIcon('share/view64.png'), _("View"))
  1387. self.zoomfit = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/zoom_fit32.png'), _("Zoom Fit"))
  1388. self.clearplot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/clear_plot32.png'), _("Clear Plot"))
  1389. self.replot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/replot32.png'), _("Replot"))
  1390. self.popMenu.addSeparator()
  1391. self.g_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/draw32.png'), _("Geo Editor"))
  1392. self.draw_line = self.g_editor_cmenu.addAction(QtGui.QIcon('share/path32.png'), _("Line"))
  1393. self.draw_rect = self.g_editor_cmenu.addAction(QtGui.QIcon('share/rectangle32.png'), _("Rectangle"))
  1394. self.draw_cut = self.g_editor_cmenu.addAction(QtGui.QIcon('share/cutpath32.png'), _("Cut"))
  1395. self.g_editor_cmenu.addSeparator()
  1396. self.draw_move = self.g_editor_cmenu.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
  1397. self.grb_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/draw32.png'), _("Gerber Editor"))
  1398. self.grb_draw_pad = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/aperture32.png'), _("Pad"))
  1399. self.grb_draw_pad_array = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/padarray32.png'), _("Pad Array"))
  1400. self.grb_draw_track = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/track32.png'), _("Track"))
  1401. self.grb_draw_region = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/polygon32.png'), _("Region"))
  1402. self.grb_editor_cmenu.addSeparator()
  1403. self.grb_copy = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/copy.png'), _("Copy"))
  1404. self.grb_delete = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/trash32.png'), _("Delete"))
  1405. self.grb_move = self.grb_editor_cmenu.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
  1406. self.e_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/drill32.png'), _("Exc Editor"))
  1407. self.drill = self.e_editor_cmenu.addAction(QtGui.QIcon('share/drill32.png'), _("Add Drill"))
  1408. self.drill_array = self.e_editor_cmenu.addAction(QtGui.QIcon('share/addarray32.png'), _("Add Drill Array"))
  1409. self.drill_copy = self.e_editor_cmenu.addAction(QtGui.QIcon('share/copy32.png'), _("Copy Drill(s)"))
  1410. self.popMenu.addSeparator()
  1411. self.popmenu_copy = self.popMenu.addAction(QtGui.QIcon('share/copy32.png'), _("Copy"))
  1412. self.popmenu_delete = self.popMenu.addAction(QtGui.QIcon('share/delete32.png'), _("Delete"))
  1413. self.popmenu_edit = self.popMenu.addAction(QtGui.QIcon('share/edit32.png'), _("Edit"))
  1414. self.popmenu_save = self.popMenu.addAction(QtGui.QIcon('share/floppy32.png'), _("Close Editor"))
  1415. self.popmenu_save.setVisible(False)
  1416. self.popMenu.addSeparator()
  1417. self.popmenu_move = self.popMenu.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
  1418. self.popmenu_properties = self.popMenu.addAction(QtGui.QIcon('share/properties32.png'), _("Properties"))
  1419. ####################################
  1420. ### Here we build the CNCJob Tab ###
  1421. ####################################
  1422. self.cncjob_tab = QtWidgets.QWidget()
  1423. self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_tab)
  1424. self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
  1425. self.cncjob_tab.setLayout(self.cncjob_tab_layout)
  1426. self.code_editor = FCTextAreaExtended()
  1427. stylesheet = """
  1428. QTextEdit { selection-background-color:yellow;
  1429. selection-color:black;
  1430. }
  1431. """
  1432. self.code_editor.setStyleSheet(stylesheet)
  1433. self.buttonPreview = QtWidgets.QPushButton(_('Print Preview'))
  1434. self.buttonPrint = QtWidgets.QPushButton(_('Print Code'))
  1435. self.buttonFind = QtWidgets.QPushButton(_('Find in Code'))
  1436. self.buttonFind.setFixedWidth(100)
  1437. self.buttonPreview.setFixedWidth(100)
  1438. self.entryFind = FCEntry()
  1439. self.entryFind.setMaximumWidth(200)
  1440. self.buttonReplace = QtWidgets.QPushButton(_('Replace With'))
  1441. self.buttonReplace.setFixedWidth(100)
  1442. self.entryReplace = FCEntry()
  1443. self.entryReplace.setMaximumWidth(200)
  1444. self.sel_all_cb = QtWidgets.QCheckBox(_('All'))
  1445. self.sel_all_cb.setToolTip(
  1446. _("When checked it will replace all instances in the 'Find' box\n"
  1447. "with the text in the 'Replace' box..")
  1448. )
  1449. self.buttonOpen = QtWidgets.QPushButton(_('Open Code'))
  1450. self.buttonSave = QtWidgets.QPushButton(_('Save Code'))
  1451. self.cncjob_tab_layout.addWidget(self.code_editor, 0, 0, 1, 5)
  1452. cnc_tab_lay_1 = QtWidgets.QHBoxLayout()
  1453. cnc_tab_lay_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1454. cnc_tab_lay_1.addWidget(self.buttonFind)
  1455. cnc_tab_lay_1.addWidget(self.entryFind)
  1456. cnc_tab_lay_1.addWidget(self.buttonReplace)
  1457. cnc_tab_lay_1.addWidget(self.entryReplace)
  1458. cnc_tab_lay_1.addWidget(self.sel_all_cb)
  1459. self.cncjob_tab_layout.addLayout(cnc_tab_lay_1, 1, 0, 1, 1, QtCore.Qt.AlignLeft)
  1460. cnc_tab_lay_3 = QtWidgets.QHBoxLayout()
  1461. cnc_tab_lay_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1462. cnc_tab_lay_3.addWidget(self.buttonPreview)
  1463. cnc_tab_lay_3.addWidget(self.buttonPrint)
  1464. self.cncjob_tab_layout.addLayout(cnc_tab_lay_3, 2, 0, 1, 1, QtCore.Qt.AlignLeft)
  1465. cnc_tab_lay_4 = QtWidgets.QHBoxLayout()
  1466. cnc_tab_lay_4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  1467. cnc_tab_lay_4.addWidget(self.buttonOpen)
  1468. cnc_tab_lay_4.addWidget(self.buttonSave)
  1469. self.cncjob_tab_layout.addLayout(cnc_tab_lay_4, 2, 4, 1, 1)
  1470. ##################################
  1471. ### Build InfoBar is done here ###
  1472. ##################################
  1473. self.infobar = self.statusBar()
  1474. self.fcinfo = FlatCAMInfoBar()
  1475. self.infobar.addWidget(self.fcinfo, stretch=1)
  1476. self.rel_position_label = QtWidgets.QLabel(
  1477. "<b>Dx</b>: 0.0000&nbsp;&nbsp; <b>Dy</b>: 0.0000&nbsp;&nbsp;&nbsp;&nbsp;")
  1478. self.rel_position_label.setMinimumWidth(110)
  1479. self.rel_position_label.setToolTip(_("Relative neasurement.\nReference is last click position"))
  1480. self.infobar.addWidget(self.rel_position_label)
  1481. self.position_label = QtWidgets.QLabel(
  1482. "&nbsp;&nbsp;&nbsp;&nbsp;<b>X</b>: 0.0000&nbsp;&nbsp; <b>Y</b>: 0.0000")
  1483. self.position_label.setMinimumWidth(110)
  1484. self.position_label.setToolTip(_("Absolute neasurement.\nReference is (X=0, Y= 0) position"))
  1485. self.infobar.addWidget(self.position_label)
  1486. self.units_label = QtWidgets.QLabel("[in]")
  1487. self.units_label.setMargin(2)
  1488. self.infobar.addWidget(self.units_label)
  1489. # disabled
  1490. self.progress_bar = QtWidgets.QProgressBar()
  1491. self.progress_bar.setMinimum(0)
  1492. self.progress_bar.setMaximum(100)
  1493. # infobar.addWidget(self.progress_bar)
  1494. self.activity_view = FlatCAMActivityView()
  1495. self.infobar.addWidget(self.activity_view)
  1496. self.app_icon = QtGui.QIcon()
  1497. self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16))
  1498. self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24))
  1499. self.app_icon.addFile('share/flatcam_icon32.png', QtCore.QSize(32, 32))
  1500. self.app_icon.addFile('share/flatcam_icon48.png', QtCore.QSize(48, 48))
  1501. self.app_icon.addFile('share/flatcam_icon128.png', QtCore.QSize(128, 128))
  1502. self.app_icon.addFile('share/flatcam_icon256.png', QtCore.QSize(256, 256))
  1503. self.setWindowIcon(self.app_icon)
  1504. self.setGeometry(100, 100, 1024, 650)
  1505. self.setWindowTitle('FlatCAM %s %s - %s' % (version, ('BETA' if beta else ''), platform.architecture()[0]))
  1506. self.show()
  1507. self.filename = ""
  1508. self.setAcceptDrops(True)
  1509. # # restore the Toolbar State from file
  1510. # try:
  1511. # with open(self.app.data_path + '\gui_state.config', 'rb') as stream:
  1512. # self.restoreState(QtCore.QByteArray(stream.read()))
  1513. # log.debug("FlatCAMGUI.__init__() --> UI state restored.")
  1514. # except IOError:
  1515. # log.debug("FlatCAMGUI.__init__() --> UI state not restored. IOError")
  1516. # pass
  1517. ######################
  1518. ### INITIALIZE GUI ###
  1519. ######################
  1520. self.grid_snap_btn.setCheckable(True)
  1521. self.corner_snap_btn.setCheckable(True)
  1522. self.update_obj_btn.setEnabled(False)
  1523. # start with GRID activated
  1524. self.grid_snap_btn.trigger()
  1525. self.g_editor_cmenu.setEnabled(False)
  1526. self.grb_editor_cmenu.setEnabled(False)
  1527. self.e_editor_cmenu.setEnabled(False)
  1528. self.general_defaults_form = GeneralPreferencesUI()
  1529. self.gerber_defaults_form = GerberPreferencesUI()
  1530. self.excellon_defaults_form = ExcellonPreferencesUI()
  1531. self.geometry_defaults_form = GeometryPreferencesUI()
  1532. self.cncjob_defaults_form = CNCJobPreferencesUI()
  1533. self.tools_defaults_form = ToolsPreferencesUI()
  1534. self.general_options_form = GeneralPreferencesUI()
  1535. self.gerber_options_form = GerberPreferencesUI()
  1536. self.excellon_options_form = ExcellonPreferencesUI()
  1537. self.geometry_options_form = GeometryPreferencesUI()
  1538. self.cncjob_options_form = CNCJobPreferencesUI()
  1539. self.tools_options_form = ToolsPreferencesUI()
  1540. QtWidgets.qApp.installEventFilter(self)
  1541. # restore the Toolbar State from file
  1542. settings = QSettings("Open Source", "FlatCAM")
  1543. if settings.contains("saved_gui_state"):
  1544. saved_gui_state = settings.value('saved_gui_state')
  1545. self.restoreState(saved_gui_state)
  1546. log.debug("FlatCAMGUI.__init__() --> UI state restored.")
  1547. settings = QSettings("Open Source", "FlatCAM")
  1548. if settings.contains("layout"):
  1549. layout = settings.value('layout', type=str)
  1550. if layout == 'standard':
  1551. self.exc_edit_toolbar.setVisible(False)
  1552. self.exc_edit_toolbar.setDisabled(True)
  1553. self.geo_edit_toolbar.setVisible(False)
  1554. self.geo_edit_toolbar.setDisabled(True)
  1555. self.grb_edit_toolbar.setVisible(False)
  1556. self.grb_edit_toolbar.setDisabled(True)
  1557. self.corner_snap_btn.setVisible(False)
  1558. self.snap_magnet.setVisible(False)
  1559. elif layout == 'compact':
  1560. self.exc_edit_toolbar.setDisabled(True)
  1561. self.geo_edit_toolbar.setDisabled(True)
  1562. self.grb_edit_toolbar.setDisabled(True)
  1563. self.snap_magnet.setVisible(True)
  1564. self.corner_snap_btn.setVisible(True)
  1565. self.snap_magnet.setDisabled(True)
  1566. self.corner_snap_btn.setDisabled(True)
  1567. log.debug("FlatCAMGUI.__init__() --> UI layout restored from QSettings.")
  1568. else:
  1569. self.exc_edit_toolbar.setVisible(False)
  1570. self.exc_edit_toolbar.setDisabled(True)
  1571. self.geo_edit_toolbar.setVisible(False)
  1572. self.geo_edit_toolbar.setDisabled(True)
  1573. self.grb_edit_toolbar.setVisible(False)
  1574. self.grb_edit_toolbar.setDisabled(True)
  1575. self.corner_snap_btn.setVisible(False)
  1576. self.snap_magnet.setVisible(False)
  1577. settings.setValue('layout', "standard")
  1578. # This will write the setting to the platform specific storage.
  1579. del settings
  1580. log.debug("FlatCAMGUI.__init__() --> UI layout restored from defaults. QSettings set to 'standard'")
  1581. def eventFilter(self, obj, event):
  1582. if self.general_defaults_form.general_app_group.toggle_tooltips_cb.get_value() is False:
  1583. if event.type() == QtCore.QEvent.ToolTip:
  1584. return True
  1585. else:
  1586. return False
  1587. return False
  1588. def populate_toolbars(self):
  1589. ### File Toolbar ###
  1590. self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
  1591. _("Open Gerber"))
  1592. self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), _("Open Excellon"))
  1593. self.toolbarfile.addSeparator()
  1594. self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), _("Open project"))
  1595. self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), _("Save project"))
  1596. ### Edit Toolbar ###
  1597. self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), _("New Blank Geometry"))
  1598. self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), _("New Blank Excellon"))
  1599. self.toolbargeo.addSeparator()
  1600. self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), _("Editor"))
  1601. self.update_obj_btn = self.toolbargeo.addAction(
  1602. QtGui.QIcon('share/edit_ok32_bis.png'), _("Save Object and close the Editor")
  1603. )
  1604. self.toolbargeo.addSeparator()
  1605. self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), _("&Delete"))
  1606. ### View Toolbar ###
  1607. self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), _("&Replot"))
  1608. self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), _("&Clear plot"))
  1609. self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), _("Zoom In"))
  1610. self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), _("Zoom Out"))
  1611. self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), _("Zoom Fit"))
  1612. # self.toolbarview.setVisible(False)
  1613. ### Shell Toolbar ###
  1614. self.shell_btn = self.toolbarshell.addAction(QtGui.QIcon('share/shell32.png'), _("&Command Line"))
  1615. ### Tools Toolbar ###
  1616. self.dblsided_btn = self.toolbartools.addAction(QtGui.QIcon('share/doubleside32.png'), _("2Sided Tool"))
  1617. self.cutout_btn = self.toolbartools.addAction(QtGui.QIcon('share/cut16_bis.png'), _("&Cutout Tool"))
  1618. self.ncc_btn = self.toolbartools.addAction(QtGui.QIcon('share/ncc16.png'), _("NCC Tool"))
  1619. self.paint_btn = self.toolbartools.addAction(QtGui.QIcon('share/paint20_1.png'), _("Paint Tool"))
  1620. self.toolbartools.addSeparator()
  1621. self.panelize_btn = self.toolbartools.addAction(QtGui.QIcon('share/panel16.png'), _("Panel Tool"))
  1622. self.film_btn = self.toolbartools.addAction(QtGui.QIcon('share/film16.png'), _("Film Tool"))
  1623. self.solder_btn = self.toolbartools.addAction(QtGui.QIcon('share/solderpastebis32.png'),
  1624. _("SolderPaste Tool"))
  1625. self.silk_btn = self.toolbartools.addAction(QtGui.QIcon('share/silk32.png'), _("Silkscreen Tool"))
  1626. self.toolbartools.addSeparator()
  1627. self.calculators_btn = self.toolbartools.addAction(QtGui.QIcon('share/calculator24.png'),
  1628. _("Calculators Tool"))
  1629. self.transform_btn = self.toolbartools.addAction(QtGui.QIcon('share/transform.png'), _("Transform Tool"))
  1630. ### Excellon Editor Toolbar ###
  1631. self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
  1632. self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), _('Add Drill Hole'))
  1633. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  1634. QtGui.QIcon('share/addarray16.png'), _('Add Drill Hole Array'))
  1635. self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), _('Resize Drill'))
  1636. self.exc_edit_toolbar.addSeparator()
  1637. self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _('Copy Drill'))
  1638. self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'),
  1639. _("Delete Drill"))
  1640. self.exc_edit_toolbar.addSeparator()
  1641. self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Drill"))
  1642. ### Geometry Editor Toolbar ###
  1643. self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select 'Esc'"))
  1644. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), _('Add Circle'))
  1645. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), _('Add Arc'))
  1646. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'),
  1647. _('Add Rectangle'))
  1648. self.geo_edit_toolbar.addSeparator()
  1649. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), _('Add Path'))
  1650. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'),
  1651. _('Add Polygon'))
  1652. self.geo_edit_toolbar.addSeparator()
  1653. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), _('Add Text'))
  1654. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'),
  1655. _('Add Buffer'))
  1656. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), _('Paint Shape'))
  1657. self.geo_edit_toolbar.addSeparator()
  1658. self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), _('Polygon Union'))
  1659. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
  1660. _('Polygon Intersection'))
  1661. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'),
  1662. _('Polygon Subtraction'))
  1663. self.geo_edit_toolbar.addSeparator()
  1664. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), _('Cut Path'))
  1665. self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _("Copy Objects"))
  1666. self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'),
  1667. _("Delete Shape"))
  1668. self.geo_transform_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/transform.png'),
  1669. _("Transformations"))
  1670. self.geo_edit_toolbar.addSeparator()
  1671. self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move Objects"))
  1672. ### Gerber Editor Toolbar ###
  1673. self.grb_select_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), _("Select"))
  1674. self.grb_add_pad_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/aperture32.png'), _("Add Pad"))
  1675. self.add_pad_ar_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/padarray32.png'), _('Add Pad Array'))
  1676. self.grb_add_track_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/track32.png'), _("Add Track"))
  1677. self.grb_add_region_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), _("Add Region"))
  1678. self.grb_convert_poly_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/poligonize32.png'),
  1679. _("Poligonize"))
  1680. self.grb_add_semidisc_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/semidisc32.png'), _("SemiDisc"))
  1681. self.grb_add_disc_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/disc32.png'), _("Disc"))
  1682. self.grb_edit_toolbar.addSeparator()
  1683. self.aperture_buffer_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), _('Buffer'))
  1684. self.aperture_scale_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/scale32.png'), _('Scale'))
  1685. self.grb_edit_toolbar.addSeparator()
  1686. self.aperture_copy_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), _("Copy"))
  1687. self.aperture_delete_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/trash32.png'),
  1688. _("Delete"))
  1689. self.grb_transform_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/transform.png'),
  1690. _("Transformations"))
  1691. self.grb_edit_toolbar.addSeparator()
  1692. self.aperture_move_btn = self.grb_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), _("Move"))
  1693. ### Snap Toolbar ###
  1694. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  1695. # self.addToolBar(self.snap_toolbar)
  1696. self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), _('Snap to grid'))
  1697. self.grid_gap_x_entry = FCEntry2()
  1698. self.grid_gap_x_entry.setMaximumWidth(70)
  1699. self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
  1700. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  1701. self.grid_gap_y_entry = FCEntry2()
  1702. self.grid_gap_y_entry.setMaximumWidth(70)
  1703. self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
  1704. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  1705. self.grid_space_label = QtWidgets.QLabel(" ")
  1706. self.snap_toolbar.addWidget(self.grid_space_label)
  1707. self.grid_gap_link_cb = FCCheckBox()
  1708. self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
  1709. "is copied to the Grid_Y value."))
  1710. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  1711. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  1712. self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), _('Snap to corner'))
  1713. self.snap_max_dist_entry = FCEntry()
  1714. self.snap_max_dist_entry.setMaximumWidth(70)
  1715. self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
  1716. self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  1717. self.grid_snap_btn.setCheckable(True)
  1718. self.corner_snap_btn.setCheckable(True)
  1719. self.update_obj_btn.setEnabled(False)
  1720. # start with GRID activated
  1721. self.grid_snap_btn.trigger()
  1722. settings = QSettings("Open Source", "FlatCAM")
  1723. if settings.contains("layout"):
  1724. layout = settings.value('layout', type=str)
  1725. if layout == 'standard':
  1726. self.exc_edit_toolbar.setVisible(False)
  1727. self.exc_edit_toolbar.setDisabled(True)
  1728. self.geo_edit_toolbar.setVisible(False)
  1729. self.geo_edit_toolbar.setDisabled(True)
  1730. self.grb_edit_toolbar.setVisible(False)
  1731. self.grb_edit_toolbar.setDisabled(True)
  1732. self.corner_snap_btn.setVisible(False)
  1733. self.snap_magnet.setVisible(False)
  1734. elif layout == 'compact':
  1735. self.exc_edit_toolbar.setVisible(True)
  1736. self.exc_edit_toolbar.setDisabled(True)
  1737. self.geo_edit_toolbar.setVisible(True)
  1738. self.geo_edit_toolbar.setDisabled(True)
  1739. self.grb_edit_toolbar.setVisible(True)
  1740. self.grb_edit_toolbar.setDisabled(True)
  1741. self.corner_snap_btn.setVisible(True)
  1742. self.snap_magnet.setVisible(True)
  1743. self.corner_snap_btn.setDisabled(True)
  1744. self.snap_magnet.setDisabled(True)
  1745. def keyPressEvent(self, event):
  1746. modifiers = QtWidgets.QApplication.keyboardModifiers()
  1747. active = self.app.collection.get_active()
  1748. selected = self.app.collection.get_selected()
  1749. # events out of the self.app.collection view (it's about Project Tab) are of type int
  1750. if type(event) is int:
  1751. key = event
  1752. # events from the GUI are of type QKeyEvent
  1753. elif type(event) == QtGui.QKeyEvent:
  1754. key = event.key()
  1755. # events from Vispy are of type KeyEvent
  1756. else:
  1757. key = event.key
  1758. # Propagate to tool
  1759. response = None
  1760. if self.app.call_source == 'app':
  1761. if modifiers == QtCore.Qt.ControlModifier:
  1762. if key == QtCore.Qt.Key_A:
  1763. self.app.on_selectall()
  1764. if key == QtCore.Qt.Key_C:
  1765. self.app.on_copy_object()
  1766. if key == QtCore.Qt.Key_E:
  1767. self.app.on_fileopenexcellon()
  1768. if key == QtCore.Qt.Key_G:
  1769. self.app.on_fileopengerber()
  1770. if key == QtCore.Qt.Key_N:
  1771. self.app.on_file_new_click()
  1772. if key == QtCore.Qt.Key_M:
  1773. self.app.measurement_tool.run()
  1774. if key == QtCore.Qt.Key_O:
  1775. self.app.on_file_openproject()
  1776. if key == QtCore.Qt.Key_S:
  1777. self.app.on_file_saveproject()
  1778. # Toggle Plot Area
  1779. if key == QtCore.Qt.Key_F10 or key == 'F10':
  1780. self.app.on_toggle_plotarea()
  1781. return
  1782. elif modifiers == QtCore.Qt.ShiftModifier:
  1783. # Copy Object Name
  1784. if key == QtCore.Qt.Key_C:
  1785. self.app.on_copy_name()
  1786. # Toggle Code Editor
  1787. if key == QtCore.Qt.Key_E:
  1788. self.app.on_toggle_code_editor()
  1789. # Toggle axis
  1790. if key == QtCore.Qt.Key_G:
  1791. if self.app.toggle_axis is False:
  1792. self.app.plotcanvas.v_line.set_data(color=(0.70, 0.3, 0.3, 1.0))
  1793. self.app.plotcanvas.h_line.set_data(color=(0.70, 0.3, 0.3, 1.0))
  1794. self.app.plotcanvas.redraw()
  1795. self.app.toggle_axis = True
  1796. else:
  1797. self.app.plotcanvas.v_line.set_data(color=(0.0, 0.0, 0.0, 0.0))
  1798. self.app.plotcanvas.h_line.set_data(color=(0.0, 0.0, 0.0, 0.0))
  1799. self.app.plotcanvas.redraw()
  1800. self.app.toggle_axis = False
  1801. # Open Preferences Window
  1802. if key == QtCore.Qt.Key_P:
  1803. self.app.on_preferences()
  1804. return
  1805. # Rotate Object by 90 degree CCW
  1806. if key == QtCore.Qt.Key_R:
  1807. self.app.on_rotate(silent=True, preset=-float(self.app.defaults['tools_transform_rotate']))
  1808. return
  1809. # Run a Script
  1810. if key == QtCore.Qt.Key_S:
  1811. self.app.on_filerunscript()
  1812. return
  1813. # Toggle Workspace
  1814. if key == QtCore.Qt.Key_W:
  1815. self.app.on_workspace_menu()
  1816. return
  1817. # Skew on X axis
  1818. if key == QtCore.Qt.Key_X:
  1819. self.app.on_skewx()
  1820. return
  1821. # Skew on Y axis
  1822. if key == QtCore.Qt.Key_Y:
  1823. self.app.on_skewy()
  1824. return
  1825. elif modifiers == QtCore.Qt.AltModifier:
  1826. # Eanble all plots
  1827. if key == Qt.Key_1:
  1828. self.app.enable_all_plots()
  1829. # Disable all plots
  1830. if key == Qt.Key_2:
  1831. self.app.disable_all_plots()
  1832. # Disable all other plots
  1833. if key == Qt.Key_3:
  1834. self.app.disable_other_plots()
  1835. # Calculator Tool
  1836. if key == QtCore.Qt.Key_C:
  1837. self.app.calculator_tool.run(toggle=True)
  1838. # 2-Sided PCB Tool
  1839. if key == QtCore.Qt.Key_D:
  1840. self.app.dblsidedtool.run(toggle=True)
  1841. return
  1842. # Silkscreen Tool
  1843. if key == QtCore.Qt.Key_E:
  1844. self.app.silk_tool.run(toggle=True)
  1845. return
  1846. # Solder Paste Dispensing Tool
  1847. if key == QtCore.Qt.Key_K:
  1848. self.app.paste_tool.run(toggle=True)
  1849. return
  1850. # Film Tool
  1851. if key == QtCore.Qt.Key_L:
  1852. self.app.film_tool.run(toggle=True)
  1853. return
  1854. # Non-Copper Clear Tool
  1855. if key == QtCore.Qt.Key_N:
  1856. self.app.ncclear_tool.run(toggle=True)
  1857. return
  1858. # Paint Tool
  1859. if key == QtCore.Qt.Key_P:
  1860. self.app.paint_tool.run(toggle=True)
  1861. return
  1862. # Paint Tool
  1863. if key == QtCore.Qt.Key_Q:
  1864. self.app.pdf_tool.run()
  1865. return
  1866. # Transformation Tool
  1867. if key == QtCore.Qt.Key_R:
  1868. self.app.transform_tool.run(toggle=True)
  1869. return
  1870. # View Source Object Content
  1871. if key == QtCore.Qt.Key_S:
  1872. self.app.on_view_source()
  1873. return
  1874. # Cutout Tool
  1875. if key == QtCore.Qt.Key_U:
  1876. self.app.cutout_tool.run(toggle=True)
  1877. return
  1878. # Panelize Tool
  1879. if key == QtCore.Qt.Key_Z:
  1880. self.app.panelize_tool.run(toggle=True)
  1881. return
  1882. # Toggle Fullscreen
  1883. if key == QtCore.Qt.Key_F10 or key == 'F10':
  1884. self.app.on_fullscreen()
  1885. return
  1886. elif modifiers == QtCore.Qt.NoModifier:
  1887. # Open Manual
  1888. if key == QtCore.Qt.Key_F1 or key == 'F1':
  1889. webbrowser.open(self.app.manual_url)
  1890. # Show shortcut list
  1891. if key == QtCore.Qt.Key_F3 or key == 'F3':
  1892. self.app.on_shortcut_list()
  1893. # Open Video Help
  1894. if key == QtCore.Qt.Key_F4 or key == 'F4':
  1895. webbrowser.open(self.app.video_url)
  1896. # Switch to Project Tab
  1897. if key == QtCore.Qt.Key_1:
  1898. self.app.on_select_tab('project')
  1899. # Switch to Selected Tab
  1900. if key == QtCore.Qt.Key_2:
  1901. self.app.on_select_tab('selected')
  1902. # Switch to Tool Tab
  1903. if key == QtCore.Qt.Key_3:
  1904. self.app.on_select_tab('tool')
  1905. # Delete from PyQt
  1906. # It's meant to make a difference between delete objects and delete tools in
  1907. # Geometry Selected tool table
  1908. if key == QtCore.Qt.Key_Delete:
  1909. self.app.on_delete_keypress()
  1910. # Delete from canvas
  1911. if key == 'Delete':
  1912. # Delete via the application to
  1913. # ensure cleanup of the GUI
  1914. if active:
  1915. active.app.on_delete()
  1916. # Escape = Deselect All
  1917. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  1918. self.app.on_deselect_all()
  1919. # if in full screen, exit to normal view
  1920. self.showNormal()
  1921. self.app.restore_toolbar_view()
  1922. self.splitter_left.setVisible(True)
  1923. self.app.toggle_fscreen = False
  1924. # try to disconnect the slot from Set Origin
  1925. try:
  1926. self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_set_zero_click)
  1927. except:
  1928. pass
  1929. self.app.inform.emit("")
  1930. # Space = Toggle Active/Inactive
  1931. if key == QtCore.Qt.Key_Space:
  1932. for select in selected:
  1933. select.ui.plot_cb.toggle()
  1934. self.app.delete_selection_shape()
  1935. # New Geometry
  1936. if key == QtCore.Qt.Key_B:
  1937. self.app.new_gerber_object()
  1938. # Copy Object Name
  1939. if key == QtCore.Qt.Key_E:
  1940. self.app.object2editor()
  1941. # Grid toggle
  1942. if key == QtCore.Qt.Key_G:
  1943. self.app.ui.grid_snap_btn.trigger()
  1944. # Jump to coords
  1945. if key == QtCore.Qt.Key_J:
  1946. self.app.on_jump_to()
  1947. # New Excellon
  1948. if key == QtCore.Qt.Key_L:
  1949. self.app.new_excellon_object()
  1950. # Move tool toggle
  1951. if key == QtCore.Qt.Key_M:
  1952. self.app.move_tool.toggle()
  1953. # New Geometry
  1954. if key == QtCore.Qt.Key_N:
  1955. self.app.new_geometry_object()
  1956. # Set Origin
  1957. if key == QtCore.Qt.Key_O:
  1958. self.app.on_set_origin()
  1959. return
  1960. # Set Origin
  1961. if key == QtCore.Qt.Key_P:
  1962. self.app.properties_tool.run()
  1963. return
  1964. # Change Units
  1965. if key == QtCore.Qt.Key_Q:
  1966. if self.app.defaults["units"] == 'MM':
  1967. self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("IN")
  1968. else:
  1969. self.app.ui.general_defaults_form.general_app_group.units_radio.set_value("MM")
  1970. self.app.on_toggle_units()
  1971. # Rotate Object by 90 degree CW
  1972. if key == QtCore.Qt.Key_R:
  1973. self.app.on_rotate(silent=True, preset=self.app.defaults['tools_transform_rotate'])
  1974. # Shell toggle
  1975. if key == QtCore.Qt.Key_S:
  1976. self.app.on_toggle_shell()
  1977. # Add a Tool from shortcut
  1978. if key == QtCore.Qt.Key_T:
  1979. self.app.on_tool_add_keypress()
  1980. # Zoom Fit
  1981. if key == QtCore.Qt.Key_V:
  1982. self.app.on_zoom_fit(None)
  1983. # Mirror on X the selected object(s)
  1984. if key == QtCore.Qt.Key_X:
  1985. self.app.on_flipx()
  1986. # Mirror on Y the selected object(s)
  1987. if key == QtCore.Qt.Key_Y:
  1988. self.app.on_flipy()
  1989. # Zoom In
  1990. if key == QtCore.Qt.Key_Equal:
  1991. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'], self.app.mouse)
  1992. # Zoom Out
  1993. if key == QtCore.Qt.Key_Minus:
  1994. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'], self.app.mouse)
  1995. # toggle display of Notebook area
  1996. if key == QtCore.Qt.Key_QuoteLeft:
  1997. self.app.on_toggle_notebook()
  1998. return
  1999. elif self.app.call_source == 'geo_editor':
  2000. if modifiers == QtCore.Qt.ControlModifier:
  2001. # save (update) the current geometry and return to the App
  2002. if key == QtCore.Qt.Key_S or key == 'S':
  2003. self.app.editor2object()
  2004. return
  2005. # toggle the measurement tool
  2006. if key == QtCore.Qt.Key_M or key == 'M':
  2007. self.app.measurement_tool.run()
  2008. return
  2009. # Cut Action Tool
  2010. if key == QtCore.Qt.Key_X or key == 'X':
  2011. if self.app.geo_editor.get_selected() is not None:
  2012. self.app.geo_editor.cutpath()
  2013. else:
  2014. msg = _('Please first select a geometry item to be cutted\n' \
  2015. 'then select the geometry item that will be cutted\n' \
  2016. 'out of the first item. In the end press ~X~ key or\n' \
  2017. 'the toolbar button.')
  2018. messagebox = QtWidgets.QMessageBox()
  2019. messagebox.setText(msg)
  2020. messagebox.setWindowTitle(_("Warning"))
  2021. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  2022. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2023. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2024. messagebox.exec_()
  2025. return
  2026. elif modifiers == QtCore.Qt.ShiftModifier:
  2027. # Skew on X axis
  2028. if key == QtCore.Qt.Key_X or key == 'X':
  2029. self.app.geo_editor.transform_tool.on_skewx_key()
  2030. return
  2031. # Skew on Y axis
  2032. if key == QtCore.Qt.Key_Y or key == 'Y':
  2033. self.app.geo_editor.transform_tool.on_skewy_key()
  2034. return
  2035. elif modifiers == QtCore.Qt.AltModifier:
  2036. # Transformation Tool
  2037. if key == QtCore.Qt.Key_R or key == 'R':
  2038. self.app.geo_editor.select_tool('transform')
  2039. return
  2040. # Offset on X axis
  2041. if key == QtCore.Qt.Key_X or key == 'X':
  2042. self.app.geo_editor.transform_tool.on_offx_key()
  2043. return
  2044. # Offset on Y axis
  2045. if key == QtCore.Qt.Key_Y or key == 'Y':
  2046. self.app.geo_editor.transform_tool.on_offy_key()
  2047. return
  2048. elif modifiers == QtCore.Qt.NoModifier:
  2049. # toggle display of Notebook area
  2050. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2051. self.app.on_toggle_notebook()
  2052. # Finish the current action. Use with tools that do not
  2053. # complete automatically, like a polygon or path.
  2054. if key == QtCore.Qt.Key_Enter or key == 'Enter':
  2055. if isinstance(self.app.geo_editor.active_tool, FCShapeTool):
  2056. if self.app.geo_editor.active_tool.name == 'rotate':
  2057. self.app.geo_editor.active_tool.make()
  2058. if self.app.geo_editor.active_tool.complete:
  2059. self.app.geo_editor.on_shape_complete()
  2060. self.app.inform.emit(_("[success] Done."))
  2061. # automatically make the selection tool active after completing current action
  2062. self.app.geo_editor.select_tool('select')
  2063. return
  2064. else:
  2065. self.app.geo_editor.active_tool.click(
  2066. self.app.geo_editor.snap(self.app.geo_editor.x, self.app.geo_editor.y))
  2067. self.app.geo_editor.active_tool.make()
  2068. if self.app.geo_editor.active_tool.complete:
  2069. self.app.geo_editor.on_shape_complete()
  2070. self.app.inform.emit(_("[success] Done."))
  2071. # automatically make the selection tool active after completing current action
  2072. self.app.geo_editor.select_tool('select')
  2073. # Abort the current action
  2074. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2075. # TODO: ...?
  2076. # self.on_tool_select("select")
  2077. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled."))
  2078. self.app.geo_editor.delete_utility_geometry()
  2079. # deselect any shape that might be selected
  2080. self.app.geo_editor.selected = []
  2081. self.app.geo_editor.replot()
  2082. self.app.geo_editor.select_tool('select')
  2083. # hide the notebook
  2084. self.app.ui.splitter.setSizes([0, 1])
  2085. return
  2086. # Delete selected object
  2087. if key == QtCore.Qt.Key_Delete or key == 'Delete':
  2088. self.app.geo_editor.delete_selected()
  2089. self.app.geo_editor.replot()
  2090. # Rotate
  2091. if key == QtCore.Qt.Key_Space or key == 'Space':
  2092. self.app.geo_editor.transform_tool.on_rotate_key()
  2093. if key == QtCore.Qt.Key_Minus or key == '-':
  2094. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'],
  2095. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2096. if key == QtCore.Qt.Key_Equal or key == '=':
  2097. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'],
  2098. [self.app.geo_editor.snap_x, self.app.geo_editor.snap_y])
  2099. # Switch to Project Tab
  2100. if key == QtCore.Qt.Key_1 or key == '1':
  2101. self.app.on_select_tab('project')
  2102. # Switch to Selected Tab
  2103. if key == QtCore.Qt.Key_2 or key == '2':
  2104. self.app.on_select_tab('selected')
  2105. # Switch to Tool Tab
  2106. if key == QtCore.Qt.Key_3 or key == '3':
  2107. self.app.on_select_tab('tool')
  2108. if self.app.geo_editor.active_tool is not None and self.geo_select_btn.isChecked() == False:
  2109. response = self.app.geo_editor.active_tool.on_key(key=key)
  2110. if response is not None:
  2111. self.app.inform.emit(response)
  2112. else:
  2113. # Arc Tool
  2114. if key == QtCore.Qt.Key_A or key == 'A':
  2115. self.app.geo_editor.select_tool('arc')
  2116. # Buffer
  2117. if key == QtCore.Qt.Key_B or key == 'B':
  2118. self.app.geo_editor.select_tool('buffer')
  2119. # Copy
  2120. if key == QtCore.Qt.Key_C or key == 'C':
  2121. self.app.geo_editor.on_copy_click()
  2122. # Substract Tool
  2123. if key == QtCore.Qt.Key_E or key == 'E':
  2124. if self.app.geo_editor.get_selected() is not None:
  2125. self.app.geo_editor.intersection()
  2126. else:
  2127. msg = _("Please select geometry items \n" \
  2128. "on which to perform Intersection Tool.")
  2129. messagebox = QtWidgets.QMessageBox()
  2130. messagebox.setText(msg)
  2131. messagebox.setWindowTitle(_("Warning"))
  2132. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  2133. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2134. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2135. messagebox.exec_()
  2136. # Grid Snap
  2137. if key == QtCore.Qt.Key_G or key == 'G':
  2138. self.app.ui.grid_snap_btn.trigger()
  2139. # make sure that the cursor shape is enabled/disabled, too
  2140. if self.app.geo_editor.options['grid_snap'] is True:
  2141. self.app.app_cursor.enabled = True
  2142. else:
  2143. self.app.app_cursor.enabled = False
  2144. # Paint
  2145. if key == QtCore.Qt.Key_I or key == 'I':
  2146. self.app.geo_editor.select_tool('paint')
  2147. # Jump to coords
  2148. if key == QtCore.Qt.Key_J or key == 'J':
  2149. self.app.on_jump_to()
  2150. # Corner Snap
  2151. if key == QtCore.Qt.Key_K or key == 'K':
  2152. self.app.geo_editor.on_corner_snap()
  2153. # Move
  2154. if key == QtCore.Qt.Key_M or key == 'M':
  2155. self.app.geo_editor.on_move_click()
  2156. # Polygon Tool
  2157. if key == QtCore.Qt.Key_N or key == 'N':
  2158. self.app.geo_editor.select_tool('polygon')
  2159. # Circle Tool
  2160. if key == QtCore.Qt.Key_O or key == 'O':
  2161. self.app.geo_editor.select_tool('circle')
  2162. # Path Tool
  2163. if key == QtCore.Qt.Key_P or key == 'P':
  2164. self.app.geo_editor.select_tool('path')
  2165. # Rectangle Tool
  2166. if key == QtCore.Qt.Key_R or key == 'R':
  2167. self.app.geo_editor.select_tool('rectangle')
  2168. # Substract Tool
  2169. if key == QtCore.Qt.Key_S or key == 'S':
  2170. if self.app.geo_editor.get_selected() is not None:
  2171. self.app.geo_editor.subtract()
  2172. else:
  2173. msg = _(
  2174. "Please select geometry items \n"
  2175. "on which to perform Substraction Tool.")
  2176. messagebox = QtWidgets.QMessageBox()
  2177. messagebox.setText(msg)
  2178. messagebox.setWindowTitle(_("Warning"))
  2179. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  2180. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2181. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2182. messagebox.exec_()
  2183. # Add Text Tool
  2184. if key == QtCore.Qt.Key_T or key == 'T':
  2185. self.app.geo_editor.select_tool('text')
  2186. # Substract Tool
  2187. if key == QtCore.Qt.Key_U or key == 'U':
  2188. if self.app.geo_editor.get_selected() is not None:
  2189. self.app.geo_editor.union()
  2190. else:
  2191. msg = _("Please select geometry items \n"
  2192. "on which to perform union.")
  2193. messagebox = QtWidgets.QMessageBox()
  2194. messagebox.setText(msg)
  2195. messagebox.setWindowTitle(_("Warning"))
  2196. messagebox.setWindowIcon(QtGui.QIcon('share/warning.png'))
  2197. messagebox.setStandardButtons(QtWidgets.QMessageBox.Ok)
  2198. messagebox.setDefaultButton(QtWidgets.QMessageBox.Ok)
  2199. messagebox.exec_()
  2200. if key == QtCore.Qt.Key_V or key == 'V':
  2201. self.app.on_zoom_fit(None)
  2202. # Flip on X axis
  2203. if key == QtCore.Qt.Key_X or key == 'X':
  2204. self.app.geo_editor.transform_tool.on_flipx()
  2205. return
  2206. # Flip on Y axis
  2207. if key == QtCore.Qt.Key_Y or key == 'Y':
  2208. self.app.geo_editor.transform_tool.on_flipy()
  2209. return
  2210. # Show Shortcut list
  2211. if key == 'F3':
  2212. self.app.on_shortcut_list()
  2213. elif self.app.call_source == 'grb_editor':
  2214. if modifiers == QtCore.Qt.ControlModifier:
  2215. # save (update) the current geometry and return to the App
  2216. if key == QtCore.Qt.Key_S or key == 'S':
  2217. self.app.editor2object()
  2218. return
  2219. # toggle the measurement tool
  2220. if key == QtCore.Qt.Key_M or key == 'M':
  2221. self.app.measurement_tool.run()
  2222. return
  2223. elif modifiers == QtCore.Qt.ShiftModifier:
  2224. pass
  2225. elif modifiers == QtCore.Qt.AltModifier:
  2226. # Poligonize Tool
  2227. if key == QtCore.Qt.Key_N or key == 'N':
  2228. self.app.grb_editor.on_poligonize()
  2229. return
  2230. # Transformation Tool
  2231. if key == QtCore.Qt.Key_R or key == 'R':
  2232. self.app.grb_editor.on_transform()
  2233. return
  2234. elif modifiers == QtCore.Qt.NoModifier:
  2235. # Abort the current action
  2236. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2237. # self.on_tool_select("select")
  2238. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled."))
  2239. self.app.grb_editor.delete_utility_geometry()
  2240. # self.app.grb_editor.plot_all()
  2241. self.app.grb_editor.active_tool.clean_up()
  2242. self.app.grb_editor.select_tool('select')
  2243. return
  2244. # Delete selected object if delete key event comes out of canvas
  2245. if key == 'Delete':
  2246. self.app.grb_editor.launched_from_shortcuts = True
  2247. if self.app.grb_editor.selected:
  2248. self.app.grb_editor.delete_selected()
  2249. self.app.grb_editor.plot_all()
  2250. else:
  2251. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to delete."))
  2252. return
  2253. # Delete aperture in apertures table if delete key event comes from the Selected Tab
  2254. if key == QtCore.Qt.Key_Delete:
  2255. self.app.grb_editor.launched_from_shortcuts = True
  2256. self.app.grb_editor.on_aperture_delete()
  2257. return
  2258. if key == QtCore.Qt.Key_Minus or key == '-':
  2259. self.app.grb_editor.launched_from_shortcuts = True
  2260. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'],
  2261. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2262. return
  2263. if key == QtCore.Qt.Key_Equal or key == '=':
  2264. self.app.grb_editor.launched_from_shortcuts = True
  2265. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'],
  2266. [self.app.grb_editor.snap_x, self.app.grb_editor.snap_y])
  2267. return
  2268. # toggle display of Notebook area
  2269. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2270. self.app.grb_editor.launched_from_shortcuts = True
  2271. self.app.on_toggle_notebook()
  2272. return
  2273. # Rotate
  2274. if key == QtCore.Qt.Key_Space or key == 'Space':
  2275. self.app.grb_editor.transform_tool.on_rotate_key()
  2276. # Switch to Project Tab
  2277. if key == QtCore.Qt.Key_1 or key == '1':
  2278. self.app.grb_editor.launched_from_shortcuts = True
  2279. self.app.on_select_tab('project')
  2280. return
  2281. # Switch to Selected Tab
  2282. if key == QtCore.Qt.Key_2 or key == '2':
  2283. self.app.grb_editor.launched_from_shortcuts = True
  2284. self.app.on_select_tab('selected')
  2285. return
  2286. # Switch to Tool Tab
  2287. if key == QtCore.Qt.Key_3 or key == '3':
  2288. self.app.grb_editor.launched_from_shortcuts = True
  2289. self.app.on_select_tab('tool')
  2290. return
  2291. # we do this so we can reuse the following keys while inside a Tool
  2292. # the above keys are general enough so were left outside
  2293. if self.app.grb_editor.active_tool is not None and self.grb_select_btn.isChecked() == False:
  2294. response = self.app.grb_editor.active_tool.on_key(key=key)
  2295. if response is not None:
  2296. self.app.inform.emit(response)
  2297. else:
  2298. # Add Array of pads
  2299. if key == QtCore.Qt.Key_A or key == 'A':
  2300. self.app.grb_editor.launched_from_shortcuts = True
  2301. self.app.inform.emit("Click on target point.")
  2302. self.app.ui.add_pad_ar_btn.setChecked(True)
  2303. self.app.grb_editor.x = self.app.mouse[0]
  2304. self.app.grb_editor.y = self.app.mouse[1]
  2305. self.app.grb_editor.select_tool('array')
  2306. return
  2307. # Scale Tool
  2308. if key == QtCore.Qt.Key_B or key == 'B':
  2309. self.app.grb_editor.launched_from_shortcuts = True
  2310. self.app.grb_editor.select_tool('buffer')
  2311. return
  2312. # Copy
  2313. if key == QtCore.Qt.Key_C or key == 'C':
  2314. self.app.grb_editor.launched_from_shortcuts = True
  2315. if self.app.grb_editor.selected:
  2316. self.app.inform.emit(_("Click on target point."))
  2317. self.app.ui.aperture_copy_btn.setChecked(True)
  2318. self.app.grb_editor.on_tool_select('copy')
  2319. self.app.grb_editor.active_tool.set_origin(
  2320. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  2321. else:
  2322. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to copy."))
  2323. return
  2324. # Add Disc Tool
  2325. if key == QtCore.Qt.Key_D or key == 'D':
  2326. self.app.grb_editor.launched_from_shortcuts = True
  2327. self.app.grb_editor.select_tool('disc')
  2328. return
  2329. # Add SemiDisc Tool
  2330. if key == QtCore.Qt.Key_E or key == 'E':
  2331. self.app.grb_editor.launched_from_shortcuts = True
  2332. self.app.grb_editor.select_tool('semidisc')
  2333. return
  2334. # Grid Snap
  2335. if key == QtCore.Qt.Key_G or key == 'G':
  2336. self.app.grb_editor.launched_from_shortcuts = True
  2337. # make sure that the cursor shape is enabled/disabled, too
  2338. if self.app.grb_editor.options['grid_snap'] is True:
  2339. self.app.app_cursor.enabled = False
  2340. else:
  2341. self.app.app_cursor.enabled = True
  2342. self.app.ui.grid_snap_btn.trigger()
  2343. return
  2344. # Jump to coords
  2345. if key == QtCore.Qt.Key_J or key == 'J':
  2346. self.app.on_jump_to()
  2347. # Corner Snap
  2348. if key == QtCore.Qt.Key_K or key == 'K':
  2349. self.app.grb_editor.launched_from_shortcuts = True
  2350. self.app.ui.corner_snap_btn.trigger()
  2351. return
  2352. # Move
  2353. if key == QtCore.Qt.Key_M or key == 'M':
  2354. self.app.grb_editor.launched_from_shortcuts = True
  2355. if self.app.grb_editor.selected:
  2356. self.app.inform.emit(_("Click on target point."))
  2357. self.app.ui.aperture_move_btn.setChecked(True)
  2358. self.app.grb_editor.on_tool_select('move')
  2359. self.app.grb_editor.active_tool.set_origin(
  2360. (self.app.grb_editor.snap_x, self.app.grb_editor.snap_y))
  2361. else:
  2362. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to move."))
  2363. return
  2364. # Add Region Tool
  2365. if key == QtCore.Qt.Key_N or key == 'N':
  2366. self.app.grb_editor.launched_from_shortcuts = True
  2367. self.app.grb_editor.select_tool('region')
  2368. return
  2369. # Add Pad Tool
  2370. if key == QtCore.Qt.Key_P or key == 'P':
  2371. self.app.grb_editor.launched_from_shortcuts = True
  2372. self.app.inform.emit(_("Click on target point."))
  2373. self.app.ui.add_pad_ar_btn.setChecked(True)
  2374. self.app.grb_editor.x = self.app.mouse[0]
  2375. self.app.grb_editor.y = self.app.mouse[1]
  2376. self.app.grb_editor.select_tool('pad')
  2377. return
  2378. # Scale Tool
  2379. if key == QtCore.Qt.Key_S or key == 'S':
  2380. self.app.grb_editor.launched_from_shortcuts = True
  2381. self.app.grb_editor.select_tool('scale')
  2382. return
  2383. # Add Track
  2384. if key == QtCore.Qt.Key_T or key == 'T':
  2385. self.app.grb_editor.launched_from_shortcuts = True
  2386. ## Current application units in Upper Case
  2387. self.app.grb_editor.select_tool('track')
  2388. return
  2389. # Zoom Fit
  2390. if key == QtCore.Qt.Key_V or key == 'V':
  2391. self.app.grb_editor.launched_from_shortcuts = True
  2392. self.app.on_zoom_fit(None)
  2393. return
  2394. # Show Shortcut list
  2395. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2396. self.app.on_shortcut_list()
  2397. return
  2398. elif self.app.call_source == 'exc_editor':
  2399. if modifiers == QtCore.Qt.ControlModifier:
  2400. # save (update) the current geometry and return to the App
  2401. if key == QtCore.Qt.Key_S or key == 'S':
  2402. self.app.editor2object()
  2403. return
  2404. # toggle the measurement tool
  2405. if key == QtCore.Qt.Key_M or key == 'M':
  2406. self.app.measurement_tool.run()
  2407. return
  2408. elif modifiers == QtCore.Qt.ShiftModifier:
  2409. pass
  2410. elif modifiers == QtCore.Qt.AltModifier:
  2411. pass
  2412. elif modifiers == QtCore.Qt.NoModifier:
  2413. # Abort the current action
  2414. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2415. # TODO: ...?
  2416. # self.on_tool_select("select")
  2417. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled."))
  2418. self.app.exc_editor.delete_utility_geometry()
  2419. self.app.exc_editor.replot()
  2420. # self.select_btn.setChecked(True)
  2421. # self.on_tool_select('select')
  2422. self.app.exc_editor.select_tool('select')
  2423. return
  2424. # Delete selected object if delete key event comes out of canvas
  2425. if key == 'Delete':
  2426. self.app.exc_editor.launched_from_shortcuts = True
  2427. if self.app.exc_editor.selected:
  2428. self.app.exc_editor.delete_selected()
  2429. self.app.exc_editor.replot()
  2430. else:
  2431. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to delete."))
  2432. return
  2433. # Delete tools in tools table if delete key event comes from the Selected Tab
  2434. if key == QtCore.Qt.Key_Delete:
  2435. self.app.exc_editor.launched_from_shortcuts = True
  2436. self.app.exc_editor.on_tool_delete()
  2437. return
  2438. if key == QtCore.Qt.Key_Minus or key == '-':
  2439. self.app.exc_editor.launched_from_shortcuts = True
  2440. self.app.plotcanvas.zoom(1 / self.app.defaults['zoom_ratio'],
  2441. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  2442. return
  2443. if key == QtCore.Qt.Key_Equal or key == '=':
  2444. self.app.exc_editor.launched_from_shortcuts = True
  2445. self.app.plotcanvas.zoom(self.app.defaults['zoom_ratio'],
  2446. [self.app.exc_editor.snap_x, self.app.exc_editor.snap_y])
  2447. return
  2448. # toggle display of Notebook area
  2449. if key == QtCore.Qt.Key_QuoteLeft or key == '`':
  2450. self.app.exc_editor.launched_from_shortcuts = True
  2451. self.app.on_toggle_notebook()
  2452. return
  2453. # Switch to Project Tab
  2454. if key == QtCore.Qt.Key_1 or key == '1':
  2455. self.app.exc_editor.launched_from_shortcuts = True
  2456. self.app.on_select_tab('project')
  2457. return
  2458. # Switch to Selected Tab
  2459. if key == QtCore.Qt.Key_2 or key == '2':
  2460. self.app.exc_editor.launched_from_shortcuts = True
  2461. self.app.on_select_tab('selected')
  2462. return
  2463. # Switch to Tool Tab
  2464. if key == QtCore.Qt.Key_3 or key == '3':
  2465. self.app.exc_editor.launched_from_shortcuts = True
  2466. self.app.on_select_tab('tool')
  2467. return
  2468. # Add Array of Drill Hole Tool
  2469. if key == QtCore.Qt.Key_A or key == 'A':
  2470. self.app.exc_editor.launched_from_shortcuts = True
  2471. self.app.inform.emit("Click on target point.")
  2472. self.app.ui.add_drill_array_btn.setChecked(True)
  2473. self.app.exc_editor.x = self.app.mouse[0]
  2474. self.app.exc_editor.y = self.app.mouse[1]
  2475. self.app.exc_editor.select_tool('drill_array')
  2476. return
  2477. # Copy
  2478. if key == QtCore.Qt.Key_C or key == 'C':
  2479. self.app.exc_editor.launched_from_shortcuts = True
  2480. if self.app.exc_editor.selected:
  2481. self.app.inform.emit(_("Click on target point."))
  2482. self.app.ui.copy_drill_btn.setChecked(True)
  2483. self.app.exc_editor.on_tool_select('drill_copy')
  2484. self.app.exc_editor.active_tool.set_origin(
  2485. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  2486. else:
  2487. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to copy."))
  2488. return
  2489. # Add Drill Hole Tool
  2490. if key == QtCore.Qt.Key_D or key == 'D':
  2491. self.app.exc_editor.launched_from_shortcuts = True
  2492. self.app.inform.emit(_("Click on target point."))
  2493. self.app.ui.add_drill_btn.setChecked(True)
  2494. self.app.exc_editor.x = self.app.mouse[0]
  2495. self.app.exc_editor.y = self.app.mouse[1]
  2496. self.app.exc_editor.select_tool('drill_add')
  2497. return
  2498. # Grid Snap
  2499. if key == QtCore.Qt.Key_G or key == 'G':
  2500. self.app.exc_editor.launched_from_shortcuts = True
  2501. # make sure that the cursor shape is enabled/disabled, too
  2502. if self.app.exc_editor.options['grid_snap'] is True:
  2503. self.app.app_cursor.enabled = False
  2504. else:
  2505. self.app.app_cursor.enabled = True
  2506. self.app.ui.grid_snap_btn.trigger()
  2507. return
  2508. # Jump to coords
  2509. if key == QtCore.Qt.Key_J or key == 'J':
  2510. self.app.on_jump_to()
  2511. # Corner Snap
  2512. if key == QtCore.Qt.Key_K or key == 'K':
  2513. self.app.exc_editor.launched_from_shortcuts = True
  2514. self.app.ui.corner_snap_btn.trigger()
  2515. return
  2516. # Move
  2517. if key == QtCore.Qt.Key_M or key == 'M':
  2518. self.app.exc_editor.launched_from_shortcuts = True
  2519. if self.app.exc_editor.selected:
  2520. self.app.inform.emit(_("Click on target point."))
  2521. self.app.ui.move_drill_btn.setChecked(True)
  2522. self.app.exc_editor.on_tool_select('drill_move')
  2523. self.app.exc_editor.active_tool.set_origin(
  2524. (self.app.exc_editor.snap_x, self.app.exc_editor.snap_y))
  2525. else:
  2526. self.app.inform.emit(_("[WARNING_NOTCL] Cancelled. Nothing selected to move."))
  2527. return
  2528. # Resize Tool
  2529. if key == QtCore.Qt.Key_R or key == 'R':
  2530. self.app.exc_editor.launched_from_shortcuts = True
  2531. self.app.exc_editor.select_tool('drill_resize')
  2532. return
  2533. # Add Tool
  2534. if key == QtCore.Qt.Key_T or key == 'T':
  2535. self.app.exc_editor.launched_from_shortcuts = True
  2536. ## Current application units in Upper Case
  2537. self.units = self.general_defaults_group.general_app_group.units_radio.get_value().upper()
  2538. tool_add_popup = FCInputDialog(title=_("New Tool ..."),
  2539. text=_('Enter a Tool Diameter:'),
  2540. min=0.0000, max=99.9999, decimals=4)
  2541. tool_add_popup.setWindowIcon(QtGui.QIcon('share/letter_t_32.png'))
  2542. val, ok = tool_add_popup.get_value()
  2543. if ok:
  2544. self.app.exc_editor.on_tool_add(tooldia=val)
  2545. self.app.inform.emit(
  2546. _("[success] Added new tool with dia: {dia} {units}").format(dia='%.4f' % float(val), units=str(self.units)))
  2547. else:
  2548. self.app.inform.emit(
  2549. _("[WARNING_NOTCL] Adding Tool cancelled ..."))
  2550. return
  2551. # Zoom Fit
  2552. if key == QtCore.Qt.Key_V or key == 'V':
  2553. self.app.exc_editor.launched_from_shortcuts = True
  2554. self.app.on_zoom_fit(None)
  2555. return
  2556. # Propagate to tool
  2557. response = None
  2558. if self.app.exc_editor.active_tool is not None:
  2559. response = self.app.exc_editor.active_tool.on_key(key=key)
  2560. if response is not None:
  2561. self.app.inform.emit(response)
  2562. # Show Shortcut list
  2563. if key == QtCore.Qt.Key_F3 or key == 'F3':
  2564. self.app.on_shortcut_list()
  2565. return
  2566. elif self.app.call_source == 'measurement':
  2567. if modifiers == QtCore.Qt.ControlModifier:
  2568. pass
  2569. elif modifiers == QtCore.Qt.AltModifier:
  2570. pass
  2571. elif modifiers == QtCore.Qt.ShiftModifier:
  2572. pass
  2573. elif modifiers == QtCore.Qt.NoModifier:
  2574. if key == QtCore.Qt.Key_Escape or key == 'Escape':
  2575. # abort the measurement action
  2576. self.app.measurement_tool.deactivate_measure_tool()
  2577. self.app.inform.emit(_("Measurement Tool exit..."))
  2578. return
  2579. if key == QtCore.Qt.Key_G or key == 'G':
  2580. self.app.ui.grid_snap_btn.trigger()
  2581. return
  2582. def dragEnterEvent(self, event):
  2583. if event.mimeData().hasUrls:
  2584. event.accept()
  2585. else:
  2586. event.ignore()
  2587. def dragMoveEvent(self, event):
  2588. if event.mimeData().hasUrls:
  2589. event.accept()
  2590. else:
  2591. event.ignore()
  2592. def dropEvent(self, event):
  2593. if event.mimeData().hasUrls:
  2594. event.setDropAction(QtCore.Qt.CopyAction)
  2595. event.accept()
  2596. for url in event.mimeData().urls():
  2597. self.filename = str(url.toLocalFile())
  2598. if self.filename == "":
  2599. self.app.inform.emit("Open cancelled.")
  2600. else:
  2601. extension = self.filename.lower().rpartition('.')[-1]
  2602. if extension in self.app.grb_list:
  2603. self.app.worker_task.emit({'fcn': self.app.open_gerber,
  2604. 'params': [self.filename]})
  2605. else:
  2606. event.ignore()
  2607. if extension in self.app.exc_list:
  2608. self.app.worker_task.emit({'fcn': self.app.open_excellon,
  2609. 'params': [self.filename]})
  2610. else:
  2611. event.ignore()
  2612. if extension in self.app.gcode_list:
  2613. self.app.worker_task.emit({'fcn': self.app.open_gcode,
  2614. 'params': [self.filename]})
  2615. else:
  2616. event.ignore()
  2617. if extension in self.app.svg_list:
  2618. object_type = 'geometry'
  2619. self.app.worker_task.emit({'fcn': self.app.import_svg,
  2620. 'params': [self.filename, object_type, None]})
  2621. if extension in self.app.dxf_list:
  2622. object_type = 'geometry'
  2623. self.app.worker_task.emit({'fcn': self.app.import_dxf,
  2624. 'params': [self.filename, object_type, None]})
  2625. if extension in self.app.pdf_list:
  2626. self.app.pdf_tool.periodic_check(1000)
  2627. self.app.worker_task.emit({'fcn': self.app.pdf_tool.open_pdf,
  2628. 'params': [self.filename]})
  2629. if extension in self.app.prj_list:
  2630. # self.app.open_project() is not Thread Safe
  2631. self.app.open_project(self.filename)
  2632. else:
  2633. event.ignore()
  2634. else:
  2635. event.ignore()
  2636. def closeEvent(self, event):
  2637. if self.app.save_in_progress:
  2638. self.app.inform.emit(_("[WARNING_NOTCL] Application is saving the project. Please wait ..."))
  2639. else:
  2640. grect = self.geometry()
  2641. # self.splitter.sizes()[0] is actually the size of the "notebook"
  2642. if not self.isMaximized():
  2643. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
  2644. self.final_save.emit()
  2645. event.ignore()
  2646. class GeneralPreferencesUI(QtWidgets.QWidget):
  2647. def __init__(self, parent=None):
  2648. QtWidgets.QWidget.__init__(self, parent=parent)
  2649. self.layout = QtWidgets.QHBoxLayout()
  2650. self.setLayout(self.layout)
  2651. self.general_app_group = GeneralAppPrefGroupUI()
  2652. self.general_app_group.setFixedWidth(250)
  2653. self.general_gui_group = GeneralGUIPrefGroupUI()
  2654. self.general_gui_group.setFixedWidth(250)
  2655. self.general_gui_set_group = GeneralGUISetGroupUI()
  2656. self.general_gui_set_group.setFixedWidth(250)
  2657. self.layout.addWidget(self.general_app_group)
  2658. self.layout.addWidget(self.general_gui_group)
  2659. self.layout.addWidget(self.general_gui_set_group)
  2660. self.layout.addStretch()
  2661. class GerberPreferencesUI(QtWidgets.QWidget):
  2662. def __init__(self, parent=None):
  2663. QtWidgets.QWidget.__init__(self, parent=parent)
  2664. self.layout = QtWidgets.QHBoxLayout()
  2665. self.setLayout(self.layout)
  2666. self.gerber_gen_group = GerberGenPrefGroupUI()
  2667. self.gerber_gen_group.setFixedWidth(250)
  2668. self.gerber_opt_group = GerberOptPrefGroupUI()
  2669. self.gerber_opt_group.setFixedWidth(230)
  2670. self.gerber_adv_opt_group = GerberAdvOptPrefGroupUI()
  2671. self.gerber_adv_opt_group.setFixedWidth(200)
  2672. self.layout.addWidget(self.gerber_gen_group)
  2673. self.layout.addWidget(self.gerber_opt_group)
  2674. self.layout.addWidget(self.gerber_adv_opt_group)
  2675. self.layout.addStretch()
  2676. class ExcellonPreferencesUI(QtWidgets.QWidget):
  2677. def __init__(self, parent=None):
  2678. QtWidgets.QWidget.__init__(self, parent=parent)
  2679. self.layout = QtWidgets.QHBoxLayout()
  2680. self.setLayout(self.layout)
  2681. self.excellon_gen_group = ExcellonGenPrefGroupUI()
  2682. self.excellon_gen_group.setFixedWidth(220)
  2683. self.excellon_opt_group = ExcellonOptPrefGroupUI()
  2684. self.excellon_opt_group.setFixedWidth(250)
  2685. self.excellon_exp_group = ExcellonExpPrefGroupUI()
  2686. self.excellon_exp_group.setFixedWidth(250)
  2687. self.excellon_adv_opt_group = ExcellonAdvOptPrefGroupUI()
  2688. self.excellon_adv_opt_group.setFixedWidth(250)
  2689. self.vlay = QtWidgets.QVBoxLayout()
  2690. self.vlay.addWidget(self.excellon_opt_group)
  2691. self.vlay.addWidget(self.excellon_exp_group)
  2692. self.layout.addWidget(self.excellon_gen_group)
  2693. self.layout.addLayout(self.vlay)
  2694. self.layout.addWidget(self.excellon_adv_opt_group)
  2695. self.layout.addStretch()
  2696. class GeometryPreferencesUI(QtWidgets.QWidget):
  2697. def __init__(self, parent=None):
  2698. QtWidgets.QWidget.__init__(self, parent=parent)
  2699. self.layout = QtWidgets.QHBoxLayout()
  2700. self.setLayout(self.layout)
  2701. self.geometry_gen_group = GeometryGenPrefGroupUI()
  2702. self.geometry_gen_group.setFixedWidth(220)
  2703. self.geometry_opt_group = GeometryOptPrefGroupUI()
  2704. self.geometry_opt_group.setFixedWidth(250)
  2705. self.geometry_adv_opt_group = GeometryAdvOptPrefGroupUI()
  2706. self.geometry_adv_opt_group.setFixedWidth(250)
  2707. self.layout.addWidget(self.geometry_gen_group)
  2708. self.layout.addWidget(self.geometry_opt_group)
  2709. self.layout.addWidget(self.geometry_adv_opt_group)
  2710. self.layout.addStretch()
  2711. class ToolsPreferencesUI(QtWidgets.QWidget):
  2712. def __init__(self, parent=None):
  2713. QtWidgets.QWidget.__init__(self, parent=parent)
  2714. self.layout = QtWidgets.QHBoxLayout()
  2715. self.setLayout(self.layout)
  2716. self.tools_ncc_group = ToolsNCCPrefGroupUI()
  2717. self.tools_ncc_group.setMinimumWidth(200)
  2718. self.tools_paint_group = ToolsPaintPrefGroupUI()
  2719. self.tools_paint_group.setMinimumWidth(200)
  2720. self.tools_cutout_group = ToolsCutoutPrefGroupUI()
  2721. self.tools_cutout_group.setMinimumWidth(220)
  2722. self.tools_2sided_group = Tools2sidedPrefGroupUI()
  2723. self.tools_2sided_group.setMinimumWidth(220)
  2724. self.tools_film_group = ToolsFilmPrefGroupUI()
  2725. self.tools_film_group.setMinimumWidth(220)
  2726. self.tools_panelize_group = ToolsPanelizePrefGroupUI()
  2727. self.tools_panelize_group.setMinimumWidth(220)
  2728. self.tools_calculators_group = ToolsCalculatorsPrefGroupUI()
  2729. self.tools_calculators_group.setMinimumWidth(220)
  2730. self.tools_transform_group = ToolsTransformPrefGroupUI()
  2731. self.tools_transform_group.setMinimumWidth(200)
  2732. self.tools_solderpaste_group = ToolsSolderpastePrefGroupUI()
  2733. self.tools_solderpaste_group.setMinimumWidth(200)
  2734. self.vlay = QtWidgets.QVBoxLayout()
  2735. self.vlay.addWidget(self.tools_ncc_group)
  2736. self.vlay.addWidget(self.tools_paint_group)
  2737. self.vlay.addWidget(self.tools_film_group)
  2738. self.vlay1 = QtWidgets.QVBoxLayout()
  2739. self.vlay1.addWidget(self.tools_cutout_group)
  2740. self.vlay1.addWidget(self.tools_transform_group)
  2741. self.vlay1.addWidget(self.tools_2sided_group)
  2742. self.vlay2 = QtWidgets.QVBoxLayout()
  2743. self.vlay2.addWidget(self.tools_panelize_group)
  2744. self.vlay2.addWidget(self.tools_calculators_group)
  2745. self.vlay3 = QtWidgets.QVBoxLayout()
  2746. self.vlay3.addWidget(self.tools_solderpaste_group)
  2747. self.layout.addLayout(self.vlay)
  2748. self.layout.addLayout(self.vlay1)
  2749. self.layout.addLayout(self.vlay2)
  2750. self.layout.addLayout(self.vlay3)
  2751. self.layout.addStretch()
  2752. class CNCJobPreferencesUI(QtWidgets.QWidget):
  2753. def __init__(self, parent=None):
  2754. QtWidgets.QWidget.__init__(self, parent=parent)
  2755. self.layout = QtWidgets.QHBoxLayout()
  2756. self.setLayout(self.layout)
  2757. self.cncjob_gen_group = CNCJobGenPrefGroupUI()
  2758. self.cncjob_gen_group.setFixedWidth(270)
  2759. self.cncjob_opt_group = CNCJobOptPrefGroupUI()
  2760. self.cncjob_opt_group.setFixedWidth(260)
  2761. self.cncjob_adv_opt_group = CNCJobAdvOptPrefGroupUI()
  2762. self.cncjob_adv_opt_group.setFixedWidth(260)
  2763. self.layout.addWidget(self.cncjob_gen_group)
  2764. self.layout.addWidget(self.cncjob_opt_group)
  2765. self.layout.addWidget(self.cncjob_adv_opt_group)
  2766. self.layout.addStretch()
  2767. class OptionsGroupUI(QtWidgets.QGroupBox):
  2768. def __init__(self, title, parent=None):
  2769. # QtGui.QGroupBox.__init__(self, title, parent=parent)
  2770. super(OptionsGroupUI, self).__init__()
  2771. self.setStyleSheet("""
  2772. QGroupBox
  2773. {
  2774. font-size: 16px;
  2775. font-weight: bold;
  2776. }
  2777. """)
  2778. self.layout = QtWidgets.QVBoxLayout()
  2779. self.setLayout(self.layout)
  2780. class GeneralGUIPrefGroupUI(OptionsGroupUI):
  2781. def __init__(self, parent=None):
  2782. super(GeneralGUIPrefGroupUI, self).__init__(self)
  2783. self.setTitle(str("GUI Preferences"))
  2784. # Create a form layout for the Application general settings
  2785. self.form_box = QtWidgets.QFormLayout()
  2786. # Grid X Entry
  2787. self.gridx_label = QtWidgets.QLabel(_('Grid X value:'))
  2788. self.gridx_label.setToolTip(
  2789. _( "This is the Grid snap value on X axis.")
  2790. )
  2791. self.gridx_entry = LengthEntry()
  2792. # Grid Y Entry
  2793. self.gridy_label = QtWidgets.QLabel(_('Grid Y value:'))
  2794. self.gridy_label.setToolTip(
  2795. _("This is the Grid snap value on Y axis.")
  2796. )
  2797. self.gridy_entry = LengthEntry()
  2798. # Snap Max Entry
  2799. self.snap_max_label = QtWidgets.QLabel(_('Snap Max:'))
  2800. self.snap_max_label.setToolTip(_("Max. magnet distance"))
  2801. self.snap_max_dist_entry = FCEntry()
  2802. # Workspace
  2803. self.workspace_lbl = QtWidgets.QLabel(_('Workspace:'))
  2804. self.workspace_lbl.setToolTip(
  2805. _( "Draw a delimiting rectangle on canvas.\n"
  2806. "The purpose is to illustrate the limits for our work.")
  2807. )
  2808. self.workspace_type_lbl = QtWidgets.QLabel(_('Wk. format:'))
  2809. self.workspace_type_lbl.setToolTip(
  2810. _( "Select the type of rectangle to be used on canvas,\n"
  2811. "as valid workspace.")
  2812. )
  2813. self.workspace_cb = FCCheckBox()
  2814. self.wk_cb = FCComboBox()
  2815. self.wk_cb.addItem('A4P')
  2816. self.wk_cb.addItem('A4L')
  2817. self.wk_cb.addItem('A3P')
  2818. self.wk_cb.addItem('A3L')
  2819. self.wks = OptionalInputSection(self.workspace_cb, [self.workspace_type_lbl, self.wk_cb])
  2820. # Plot Fill Color
  2821. self.pf_color_label = QtWidgets.QLabel(_('Plot Fill:'))
  2822. self.pf_color_label.setToolTip(
  2823. _( "Set the fill color for plotted objects.\n"
  2824. "First 6 digits are the color and the last 2\n"
  2825. "digits are for alpha (transparency) level.")
  2826. )
  2827. self.pf_color_entry = FCEntry()
  2828. self.pf_color_button = QtWidgets.QPushButton()
  2829. self.pf_color_button.setFixedSize(15, 15)
  2830. self.form_box_child_1 = QtWidgets.QHBoxLayout()
  2831. self.form_box_child_1.addWidget(self.pf_color_entry)
  2832. self.form_box_child_1.addWidget(self.pf_color_button)
  2833. self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2834. # Plot Fill Transparency Level
  2835. self.pf_alpha_label = QtWidgets.QLabel(_('Alpha Level:'))
  2836. self.pf_alpha_label.setToolTip(
  2837. _( "Set the fill transparency for plotted objects.")
  2838. )
  2839. self.pf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  2840. self.pf_color_alpha_slider.setMinimum(0)
  2841. self.pf_color_alpha_slider.setMaximum(255)
  2842. self.pf_color_alpha_slider.setSingleStep(1)
  2843. self.pf_color_alpha_spinner = FCSpinner()
  2844. self.pf_color_alpha_spinner.setFixedWidth(70)
  2845. self.pf_color_alpha_spinner.setMinimum(0)
  2846. self.pf_color_alpha_spinner.setMaximum(255)
  2847. self.form_box_child_2 = QtWidgets.QHBoxLayout()
  2848. self.form_box_child_2.addWidget(self.pf_color_alpha_slider)
  2849. self.form_box_child_2.addWidget(self.pf_color_alpha_spinner)
  2850. # Plot Line Color
  2851. self.pl_color_label = QtWidgets.QLabel(_('Plot Line:'))
  2852. self.pl_color_label.setToolTip(
  2853. _( "Set the line color for plotted objects.")
  2854. )
  2855. self.pl_color_entry = FCEntry()
  2856. self.pl_color_button = QtWidgets.QPushButton()
  2857. self.pl_color_button.setFixedSize(15, 15)
  2858. self.form_box_child_3 = QtWidgets.QHBoxLayout()
  2859. self.form_box_child_3.addWidget(self.pl_color_entry)
  2860. self.form_box_child_3.addWidget(self.pl_color_button)
  2861. self.form_box_child_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2862. # Plot Selection (left - right) Fill Color
  2863. self.sf_color_label = QtWidgets.QLabel(_('Sel. Fill:'))
  2864. self.sf_color_label.setToolTip(
  2865. _("Set the fill color for the selection box\n"
  2866. "in case that the selection is done from left to right.\n"
  2867. "First 6 digits are the color and the last 2\n"
  2868. "digits are for alpha (transparency) level.")
  2869. )
  2870. self.sf_color_entry = FCEntry()
  2871. self.sf_color_button = QtWidgets.QPushButton()
  2872. self.sf_color_button.setFixedSize(15, 15)
  2873. self.form_box_child_4 = QtWidgets.QHBoxLayout()
  2874. self.form_box_child_4.addWidget(self.sf_color_entry)
  2875. self.form_box_child_4.addWidget(self.sf_color_button)
  2876. self.form_box_child_4.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2877. # Plot Selection (left - right) Fill Transparency Level
  2878. self.sf_alpha_label = QtWidgets.QLabel(_('Alpha Level:'))
  2879. self.sf_alpha_label.setToolTip(
  2880. _("Set the fill transparency for the 'left to right' selection box.")
  2881. )
  2882. self.sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  2883. self.sf_color_alpha_slider.setMinimum(0)
  2884. self.sf_color_alpha_slider.setMaximum(255)
  2885. self.sf_color_alpha_slider.setSingleStep(1)
  2886. self.sf_color_alpha_spinner = FCSpinner()
  2887. self.sf_color_alpha_spinner.setFixedWidth(70)
  2888. self.sf_color_alpha_spinner.setMinimum(0)
  2889. self.sf_color_alpha_spinner.setMaximum(255)
  2890. self.form_box_child_5 = QtWidgets.QHBoxLayout()
  2891. self.form_box_child_5.addWidget(self.sf_color_alpha_slider)
  2892. self.form_box_child_5.addWidget(self.sf_color_alpha_spinner)
  2893. # Plot Selection (left - right) Line Color
  2894. self.sl_color_label = QtWidgets.QLabel(_('Sel. Line:'))
  2895. self.sl_color_label.setToolTip(
  2896. _("Set the line color for the 'left to right' selection box.")
  2897. )
  2898. self.sl_color_entry = FCEntry()
  2899. self.sl_color_button = QtWidgets.QPushButton()
  2900. self.sl_color_button.setFixedSize(15, 15)
  2901. self.form_box_child_6 = QtWidgets.QHBoxLayout()
  2902. self.form_box_child_6.addWidget(self.sl_color_entry)
  2903. self.form_box_child_6.addWidget(self.sl_color_button)
  2904. self.form_box_child_6.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2905. # Plot Selection (right - left) Fill Color
  2906. self.alt_sf_color_label = QtWidgets.QLabel(_('Sel2. Fill:'))
  2907. self.alt_sf_color_label.setToolTip(
  2908. _("Set the fill color for the selection box\n"
  2909. "in case that the selection is done from right to left.\n"
  2910. "First 6 digits are the color and the last 2\n"
  2911. "digits are for alpha (transparency) level.")
  2912. )
  2913. self.alt_sf_color_entry = FCEntry()
  2914. self.alt_sf_color_button = QtWidgets.QPushButton()
  2915. self.alt_sf_color_button.setFixedSize(15, 15)
  2916. self.form_box_child_7 = QtWidgets.QHBoxLayout()
  2917. self.form_box_child_7.addWidget(self.alt_sf_color_entry)
  2918. self.form_box_child_7.addWidget(self.alt_sf_color_button)
  2919. self.form_box_child_7.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2920. # Plot Selection (right - left) Fill Transparency Level
  2921. self.alt_sf_alpha_label = QtWidgets.QLabel(_('Alpha Level:'))
  2922. self.alt_sf_alpha_label.setToolTip(
  2923. _("Set the fill transparency for selection 'right to left' box.")
  2924. )
  2925. self.alt_sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  2926. self.alt_sf_color_alpha_slider.setMinimum(0)
  2927. self.alt_sf_color_alpha_slider.setMaximum(255)
  2928. self.alt_sf_color_alpha_slider.setSingleStep(1)
  2929. self.alt_sf_color_alpha_spinner = FCSpinner()
  2930. self.alt_sf_color_alpha_spinner.setFixedWidth(70)
  2931. self.alt_sf_color_alpha_spinner.setMinimum(0)
  2932. self.alt_sf_color_alpha_spinner.setMaximum(255)
  2933. self.form_box_child_8 = QtWidgets.QHBoxLayout()
  2934. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_slider)
  2935. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_spinner)
  2936. # Plot Selection (right - left) Line Color
  2937. self.alt_sl_color_label = QtWidgets.QLabel(_('Sel2. Line:'))
  2938. self.alt_sl_color_label.setToolTip(
  2939. _("Set the line color for the 'right to left' selection box.")
  2940. )
  2941. self.alt_sl_color_entry = FCEntry()
  2942. self.alt_sl_color_button = QtWidgets.QPushButton()
  2943. self.alt_sl_color_button.setFixedSize(15, 15)
  2944. self.form_box_child_9 = QtWidgets.QHBoxLayout()
  2945. self.form_box_child_9.addWidget(self.alt_sl_color_entry)
  2946. self.form_box_child_9.addWidget(self.alt_sl_color_button)
  2947. self.form_box_child_9.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2948. # Editor Draw Color
  2949. self.draw_color_label = QtWidgets.QLabel(_('Editor Draw:'))
  2950. self.alt_sf_color_label.setToolTip(
  2951. _("Set the color for the shape.")
  2952. )
  2953. self.draw_color_entry = FCEntry()
  2954. self.draw_color_button = QtWidgets.QPushButton()
  2955. self.draw_color_button.setFixedSize(15, 15)
  2956. self.form_box_child_10 = QtWidgets.QHBoxLayout()
  2957. self.form_box_child_10.addWidget(self.draw_color_entry)
  2958. self.form_box_child_10.addWidget(self.draw_color_button)
  2959. self.form_box_child_10.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2960. # Editor Draw Selection Color
  2961. self.sel_draw_color_label = QtWidgets.QLabel(_('Editor Draw Sel.:'))
  2962. self.sel_draw_color_label.setToolTip(
  2963. _("Set the color of the shape when selected.")
  2964. )
  2965. self.sel_draw_color_entry = FCEntry()
  2966. self.sel_draw_color_button = QtWidgets.QPushButton()
  2967. self.sel_draw_color_button.setFixedSize(15, 15)
  2968. self.form_box_child_11 = QtWidgets.QHBoxLayout()
  2969. self.form_box_child_11.addWidget(self.sel_draw_color_entry)
  2970. self.form_box_child_11.addWidget(self.sel_draw_color_button)
  2971. self.form_box_child_11.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  2972. # Just to add empty rows
  2973. self.spacelabel = QtWidgets.QLabel('')
  2974. # Add (label - input field) pair to the QFormLayout
  2975. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2976. self.form_box.addRow(self.gridx_label, self.gridx_entry)
  2977. self.form_box.addRow(self.gridy_label, self.gridy_entry)
  2978. self.form_box.addRow(self.snap_max_label, self.snap_max_dist_entry)
  2979. self.form_box.addRow(self.workspace_lbl, self.workspace_cb)
  2980. self.form_box.addRow(self.workspace_type_lbl, self.wk_cb)
  2981. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2982. self.form_box.addRow(self.pf_color_label, self.form_box_child_1)
  2983. self.form_box.addRow(self.pf_alpha_label, self.form_box_child_2)
  2984. self.form_box.addRow(self.pl_color_label, self.form_box_child_3)
  2985. self.form_box.addRow(self.sf_color_label, self.form_box_child_4)
  2986. self.form_box.addRow(self.sf_alpha_label, self.form_box_child_5)
  2987. self.form_box.addRow(self.sl_color_label, self.form_box_child_6)
  2988. self.form_box.addRow(self.alt_sf_color_label, self.form_box_child_7)
  2989. self.form_box.addRow(self.alt_sf_alpha_label, self.form_box_child_8)
  2990. self.form_box.addRow(self.alt_sl_color_label, self.form_box_child_9)
  2991. self.form_box.addRow(self.draw_color_label, self.form_box_child_10)
  2992. self.form_box.addRow(self.sel_draw_color_label, self.form_box_child_11)
  2993. self.form_box.addRow(self.spacelabel, self.spacelabel)
  2994. # Add the QFormLayout that holds the Application general defaults
  2995. # to the main layout of this TAB
  2996. self.layout.addLayout(self.form_box)
  2997. class GeneralGUISetGroupUI(OptionsGroupUI):
  2998. def __init__(self, parent=None):
  2999. super(GeneralGUISetGroupUI, self).__init__(self)
  3000. self.setTitle(str(_("GUI Settings")))
  3001. # Create a form layout for the Application general settings
  3002. self.form_box = QtWidgets.QFormLayout()
  3003. # Layout selection
  3004. self.layout_label = QtWidgets.QLabel(_('Layout:'))
  3005. self.layout_label.setToolTip(
  3006. _("Select an layout for FlatCAM.\n"
  3007. "It is applied immediately.")
  3008. )
  3009. self.layout_combo = FCComboBox()
  3010. # don't translate the QCombo items as they are used in QSettings and identified by name
  3011. self.layout_combo.addItem("standard")
  3012. self.layout_combo.addItem("compact")
  3013. # Set the current index for layout_combo
  3014. settings = QSettings("Open Source", "FlatCAM")
  3015. if settings.contains("layout"):
  3016. layout = settings.value('layout', type=str)
  3017. idx = self.layout_combo.findText(layout.capitalize())
  3018. self.layout_combo.setCurrentIndex(idx)
  3019. # Style selection
  3020. self.style_label = QtWidgets.QLabel(_('Style:'))
  3021. self.style_label.setToolTip(
  3022. _("Select an style for FlatCAM.\n"
  3023. "It will be applied at the next app start.")
  3024. )
  3025. self.style_combo = FCComboBox()
  3026. self.style_combo.addItems(QtWidgets.QStyleFactory.keys())
  3027. # find current style
  3028. index = self.style_combo.findText(QtWidgets.qApp.style().objectName(), QtCore.Qt.MatchFixedString)
  3029. self.style_combo.setCurrentIndex(index)
  3030. self.style_combo.activated[str].connect(self.handle_style)
  3031. # Enable High DPI Support
  3032. self.hdpi_label = QtWidgets.QLabel(_('HDPI Support:'))
  3033. self.hdpi_label.setToolTip(
  3034. _("Enable High DPI support for FlatCAM.\n"
  3035. "It will be applied at the next app start.")
  3036. )
  3037. self.hdpi_cb = FCCheckBox()
  3038. settings = QSettings("Open Source", "FlatCAM")
  3039. if settings.contains("hdpi"):
  3040. self.hdpi_cb.set_value(settings.value('hdpi', type=int))
  3041. else:
  3042. self.hdpi_cb.set_value(False)
  3043. self.hdpi_cb.stateChanged.connect(self.handle_hdpi)
  3044. # Clear Settings
  3045. self.clear_label = QtWidgets.QLabel(_('Clear GUI Settings:'))
  3046. self.clear_label.setToolTip(
  3047. _("Clear the GUI settings for FlatCAM,\n"
  3048. "such as: layout, gui state, style, hdpi support etc.")
  3049. )
  3050. self.clear_btn = FCButton(_("Clear"))
  3051. self.clear_btn.clicked.connect(self.handle_clear)
  3052. # Enable Hover box
  3053. self.hover_label = QtWidgets.QLabel(_('Hover Shape:'))
  3054. self.hover_label.setToolTip(
  3055. _("Enable display of a hover shape for FlatCAM objects.\n"
  3056. "It is displayed whenever the mouse cursor is hovering\n"
  3057. "over any kind of not-selected object.")
  3058. )
  3059. self.hover_cb = FCCheckBox()
  3060. # Enable Selection box
  3061. self.selection_label = QtWidgets.QLabel(_('Sel. Shape:'))
  3062. self.selection_label.setToolTip(
  3063. _("Enable the display of a selection shape for FlatCAM objects.\n"
  3064. "It is displayed whenever the mouse selects an object\n"
  3065. "either by clicking or dragging mouse from left to right or\n"
  3066. "right to left.")
  3067. )
  3068. self.selection_cb = FCCheckBox()
  3069. # Just to add empty rows
  3070. self.spacelabel = QtWidgets.QLabel('')
  3071. # Add (label - input field) pair to the QFormLayout
  3072. self.form_box.addRow(self.spacelabel, self.spacelabel)
  3073. self.form_box.addRow(self.layout_label, self.layout_combo)
  3074. self.form_box.addRow(self.style_label, self.style_combo)
  3075. self.form_box.addRow(self.hdpi_label, self.hdpi_cb)
  3076. self.form_box.addRow(self.clear_label, self.clear_btn)
  3077. self.form_box.addRow(self.hover_label, self.hover_cb)
  3078. self.form_box.addRow(self.selection_label, self.selection_cb)
  3079. # Add the QFormLayout that holds the Application general defaults
  3080. # to the main layout of this TAB
  3081. self.layout.addLayout(self.form_box)
  3082. def handle_style(self, style):
  3083. # set current style
  3084. settings = QSettings("Open Source", "FlatCAM")
  3085. settings.setValue('style', style)
  3086. # This will write the setting to the platform specific storage.
  3087. del settings
  3088. def handle_hdpi(self, state):
  3089. # set current HDPI
  3090. settings = QSettings("Open Source", "FlatCAM")
  3091. settings.setValue('hdpi', state)
  3092. # This will write the setting to the platform specific storage.
  3093. del settings
  3094. def handle_clear(self):
  3095. msgbox = QtWidgets.QMessageBox()
  3096. msgbox.setText(_("Are you sure you want to delete the GUI Settings? "
  3097. "\n")
  3098. )
  3099. msgbox.setWindowTitle(_("Clear GUI Settings"))
  3100. msgbox.setWindowIcon(QtGui.QIcon('share/trash32.png'))
  3101. bt_yes = msgbox.addButton(_('Yes'), QtWidgets.QMessageBox.YesRole)
  3102. bt_no = msgbox.addButton(_('No'), QtWidgets.QMessageBox.NoRole)
  3103. msgbox.setDefaultButton(bt_no)
  3104. msgbox.exec_()
  3105. response = msgbox.clickedButton()
  3106. if response == bt_yes:
  3107. settings = QSettings("Open Source", "FlatCAM")
  3108. for key in settings.allKeys():
  3109. settings.remove(key)
  3110. # This will write the setting to the platform specific storage.
  3111. del settings
  3112. class GeneralAppPrefGroupUI(OptionsGroupUI):
  3113. def __init__(self, parent=None):
  3114. super(GeneralAppPrefGroupUI, self).__init__(self)
  3115. self.setTitle(str(_("App Preferences")))
  3116. # Create a form layout for the Application general settings
  3117. self.form_box = QtWidgets.QFormLayout()
  3118. # Units for FlatCAM
  3119. self.unitslabel = QtWidgets.QLabel(_('<b>Units:</b>'))
  3120. self.unitslabel.setToolTip(_("The default value for FlatCAM units.\n"
  3121. "Whatever is selected here is set every time\n"
  3122. "FLatCAM is started."))
  3123. self.units_radio = RadioSet([{'label': 'IN', 'value': 'IN'},
  3124. {'label': 'MM', 'value': 'MM'}])
  3125. # Application Level for FlatCAM
  3126. self.app_level_label = QtWidgets.QLabel(_('<b>APP. LEVEL:</b>'))
  3127. self.app_level_label.setToolTip(_("Choose the default level of usage for FlatCAM.\n"
  3128. "BASIC level -> reduced functionality, best for beginner's.\n"
  3129. "ADVANCED level -> full functionality.\n\n"
  3130. "The choice here will influence the parameters in\n"
  3131. "the Selected Tab for all kinds of FlatCAM objects."))
  3132. self.app_level_radio = RadioSet([{'label': _('Basic'), 'value': 'b'},
  3133. {'label': _('Advanced'), 'value': 'a'}])
  3134. # Languages for FlatCAM
  3135. self.languagelabel = QtWidgets.QLabel(_('<b>Languages:</b>'))
  3136. self.languagelabel.setToolTip(_("Set the language used throughout FlatCAM."))
  3137. self.language_cb = FCComboBox()
  3138. self.languagespace = QtWidgets.QLabel('')
  3139. self.language_apply_btn = FCButton(_("Apply Language"))
  3140. # Shell StartUp CB
  3141. self.shell_startup_label = QtWidgets.QLabel(_('Shell at StartUp:'))
  3142. self.shell_startup_label.setToolTip(
  3143. _("Check this box if you want the shell to\n"
  3144. "start automatically at startup.")
  3145. )
  3146. self.shell_startup_cb = FCCheckBox(label='')
  3147. self.shell_startup_cb.setToolTip(
  3148. _("Check this box if you want the shell to\n"
  3149. "start automatically at startup.")
  3150. )
  3151. # Version Check CB
  3152. self.version_check_label = QtWidgets.QLabel(_('Version Check:'))
  3153. self.version_check_label.setToolTip(
  3154. _("Check this box if you want to check\n"
  3155. "for a new version automatically at startup.")
  3156. )
  3157. self.version_check_cb = FCCheckBox(label='')
  3158. self.version_check_cb.setToolTip(
  3159. _("Check this box if you want to check\n"
  3160. "for a new version automatically at startup.")
  3161. )
  3162. # Send Stats CB
  3163. self.send_stats_label = QtWidgets.QLabel(_('Send Stats:'))
  3164. self.send_stats_label.setToolTip(
  3165. _("Check this box if you agree to send anonymous\n"
  3166. "stats automatically at startup, to help improve FlatCAM.")
  3167. )
  3168. self.send_stats_cb= FCCheckBox(label='')
  3169. self.send_stats_cb.setToolTip(
  3170. _("Check this box if you agree to send anonymous\n"
  3171. "stats automatically at startup, to help improve FlatCAM.")
  3172. )
  3173. self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
  3174. # Select mouse pan button
  3175. self.panbuttonlabel = QtWidgets.QLabel(_('<b>Pan Button:</b>'))
  3176. self.panbuttonlabel.setToolTip(_("Select the mouse button to use for panning:\n"
  3177. "- MMB --> Middle Mouse Button\n"
  3178. "- RMB --> Right Mouse Button"))
  3179. self.pan_button_radio = RadioSet([{'label': _('MMB'), 'value': '3'},
  3180. {'label': _('RMB'), 'value': '2'}])
  3181. # Multiple Selection Modifier Key
  3182. self.mselectlabel = QtWidgets.QLabel(_('<b>Multiple Sel:</b>'))
  3183. self.mselectlabel.setToolTip(_("Select the key used for multiple selection."))
  3184. self.mselect_radio = RadioSet([{'label': _('CTRL'), 'value': 'Control'},
  3185. {'label': _('SHIFT'), 'value': 'Shift'}])
  3186. # Project at StartUp CB
  3187. self.project_startup_label = QtWidgets.QLabel(_('Project at StartUp:'))
  3188. self.project_startup_label.setToolTip(
  3189. _("Check this box if you want the project/selected/tool tab area to\n"
  3190. "to be shown automatically at startup.")
  3191. )
  3192. self.project_startup_cb = FCCheckBox(label='')
  3193. self.project_startup_cb.setToolTip(
  3194. _("Check this box if you want the project/selected/tool tab area to\n"
  3195. "to be shown automatically at startup.")
  3196. )
  3197. # Project autohide CB
  3198. self.project_autohide_label = QtWidgets.QLabel(_('Project AutoHide:'))
  3199. self.project_autohide_label.setToolTip(
  3200. _( "Check this box if you want the project/selected/tool tab area to\n"
  3201. "hide automatically when there are no objects loaded and\n"
  3202. "to show whenever a new object is created.")
  3203. )
  3204. self.project_autohide_cb = FCCheckBox(label='')
  3205. self.project_autohide_cb.setToolTip(
  3206. _("Check this box if you want the project/selected/tool tab area to\n"
  3207. "hide automatically when there are no objects loaded and\n"
  3208. "to show whenever a new object is created.")
  3209. )
  3210. # Enable/Disable ToolTips globally
  3211. self.toggle_tooltips_label = QtWidgets.QLabel(_('<b>Enable ToolTips:</b>'))
  3212. self.toggle_tooltips_label.setToolTip(
  3213. _( "Check this box if you want to have toolTips displayed\n"
  3214. "when hovering with mouse over items throughout the App.")
  3215. )
  3216. self.toggle_tooltips_cb = FCCheckBox(label='')
  3217. self.toggle_tooltips_cb.setToolTip(
  3218. _( "Check this box if you want to have toolTips displayed\n"
  3219. "when hovering with mouse over items throughout the App.")
  3220. )
  3221. self.worker_number_label = QtWidgets.QLabel(_('Workers number:'))
  3222. self.worker_number_label.setToolTip(
  3223. _("The number of Qthreads made available to the App.\n"
  3224. "A bigger number may finish the jobs more quickly but\n"
  3225. "depending on your computer speed, may make the App\n"
  3226. "unresponsive. Can have a value between 2 and 16.\n"
  3227. "Default value is 2.\n"
  3228. "After change, it will be applied at next App start.")
  3229. )
  3230. self.worker_number_sb = FCSpinner()
  3231. self.worker_number_sb.setToolTip(
  3232. _("The number of Qthreads made available to the App.\n"
  3233. "A bigger number may finish the jobs more quickly but\n"
  3234. "depending on your computer speed, may make the App\n"
  3235. "unresponsive. Can have a value between 2 and 16.\n"
  3236. "Default value is 2.\n"
  3237. "After change, it will be applied at next App start.")
  3238. )
  3239. self.worker_number_sb.set_range(2, 16)
  3240. # Just to add empty rows
  3241. self.spacelabel = QtWidgets.QLabel('')
  3242. # Add (label - input field) pair to the QFormLayout
  3243. self.form_box.addRow(self.unitslabel, self.units_radio)
  3244. self.form_box.addRow(self.app_level_label, self.app_level_radio)
  3245. self.form_box.addRow(self.languagelabel, self.language_cb)
  3246. self.form_box.addRow(self.languagespace, self.language_apply_btn)
  3247. self.form_box.addRow(self.spacelabel, self.spacelabel)
  3248. self.form_box.addRow(self.shell_startup_label, self.shell_startup_cb)
  3249. self.form_box.addRow(self.version_check_label, self.version_check_cb)
  3250. self.form_box.addRow(self.send_stats_label, self.send_stats_cb)
  3251. self.form_box.addRow(self.panbuttonlabel, self.pan_button_radio)
  3252. self.form_box.addRow(self.mselectlabel, self.mselect_radio)
  3253. self.form_box.addRow(self.project_startup_label, self.project_startup_cb)
  3254. self.form_box.addRow(self.project_autohide_label, self.project_autohide_cb)
  3255. self.form_box.addRow(self.toggle_tooltips_label, self.toggle_tooltips_cb)
  3256. self.form_box.addRow(self.worker_number_label, self.worker_number_sb)
  3257. self.form_box.addRow(self.spacelabel, self.spacelabel)
  3258. # Add the QFormLayout that holds the Application general defaults
  3259. # to the main layout of this TAB
  3260. self.layout.addLayout(self.form_box)
  3261. # hlay = QtWidgets.QHBoxLayout()
  3262. # self.layout.addLayout(hlay)
  3263. # hlay.addStretch()
  3264. # Save compressed project CB
  3265. self.save_type_cb = FCCheckBox(_('Save Compressed Project'))
  3266. self.save_type_cb.setToolTip(
  3267. _("Whether to save a compressed or uncompressed project.\n"
  3268. "When checked it will save a compressed FlatCAM project.")
  3269. )
  3270. # self.advanced_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  3271. self.layout.addWidget(self.save_type_cb)
  3272. hlay1 = QtWidgets.QHBoxLayout()
  3273. self.layout.addLayout(hlay1)
  3274. # Project LZMA Comppression Level
  3275. self.compress_combo = FCComboBox()
  3276. self.compress_label = QtWidgets.QLabel(_('Compression Level:'))
  3277. self.compress_label.setToolTip(
  3278. _("The level of compression used when saving\n"
  3279. "a FlatCAM project. Higher value means better compression\n"
  3280. "but require more RAM usage and more processing time.")
  3281. )
  3282. # self.advanced_cb.setLayoutDirection(QtCore.Qt.RightToLeft)
  3283. self.compress_combo.addItems([str(i) for i in range(10)])
  3284. hlay1.addWidget(self.compress_label)
  3285. hlay1.addWidget(self.compress_combo)
  3286. self.proj_ois = OptionalInputSection(self.save_type_cb, [self.compress_label, self.compress_combo], True)
  3287. self.form_box_2 = QtWidgets.QFormLayout()
  3288. self.layout.addLayout(self.form_box_2)
  3289. self.layout.addStretch()
  3290. class GerberGenPrefGroupUI(OptionsGroupUI):
  3291. def __init__(self, parent=None):
  3292. # OptionsGroupUI.__init__(self, "Gerber General Preferences", parent=parent)
  3293. super(GerberGenPrefGroupUI, self).__init__(self)
  3294. self.setTitle(str("Gerber General"))
  3295. ## Plot options
  3296. self.plot_options_label = QtWidgets.QLabel(_("<b>Plot Options:</b>"))
  3297. self.layout.addWidget(self.plot_options_label)
  3298. grid0 = QtWidgets.QGridLayout()
  3299. self.layout.addLayout(grid0)
  3300. # Solid CB
  3301. self.solid_cb = FCCheckBox(label=_('Solid'))
  3302. self.solid_cb.setToolTip(
  3303. _("Solid color polygons.")
  3304. )
  3305. grid0.addWidget(self.solid_cb, 0, 0)
  3306. # Multicolored CB
  3307. self.multicolored_cb = FCCheckBox(label=_('M-Color'))
  3308. self.multicolored_cb.setToolTip(
  3309. _("Draw polygons in different colors.")
  3310. )
  3311. grid0.addWidget(self.multicolored_cb, 0, 1)
  3312. # Plot CB
  3313. self.plot_cb = FCCheckBox(label=_('Plot'))
  3314. self.plot_options_label.setToolTip(
  3315. _("Plot (show) this object.")
  3316. )
  3317. grid0.addWidget(self.plot_cb, 0, 2)
  3318. # Number of circle steps for circular aperture linear approximation
  3319. self.circle_steps_label = QtWidgets.QLabel(_("Circle Steps:"))
  3320. self.circle_steps_label.setToolTip(
  3321. _("The number of circle steps for Gerber \n"
  3322. "circular aperture linear approximation.")
  3323. )
  3324. grid0.addWidget(self.circle_steps_label, 1, 0)
  3325. self.circle_steps_entry = IntEntry()
  3326. grid0.addWidget(self.circle_steps_entry, 1, 1)
  3327. self.layout.addStretch()
  3328. class GerberOptPrefGroupUI(OptionsGroupUI):
  3329. def __init__(self, parent=None):
  3330. # OptionsGroupUI.__init__(self, "Gerber Options Preferences", parent=parent)
  3331. super(GerberOptPrefGroupUI, self).__init__(self)
  3332. self.setTitle(str(_("Gerber Options")))
  3333. ## Isolation Routing
  3334. self.isolation_routing_label = QtWidgets.QLabel(_("<b>Isolation Routing:</b>"))
  3335. self.isolation_routing_label.setToolTip(
  3336. _("Create a Geometry object with\n"
  3337. "toolpaths to cut outside polygons.")
  3338. )
  3339. self.layout.addWidget(self.isolation_routing_label)
  3340. # Cutting Tool Diameter
  3341. grid0 = QtWidgets.QGridLayout()
  3342. self.layout.addLayout(grid0)
  3343. tdlabel = QtWidgets.QLabel(_('Tool dia:'))
  3344. tdlabel.setToolTip(
  3345. _("Diameter of the cutting tool.")
  3346. )
  3347. grid0.addWidget(tdlabel, 0, 0)
  3348. self.iso_tool_dia_entry = LengthEntry()
  3349. grid0.addWidget(self.iso_tool_dia_entry, 0, 1)
  3350. # Nr of passes
  3351. passlabel = QtWidgets.QLabel(_('Width (# passes):'))
  3352. passlabel.setToolTip(
  3353. _("Width of the isolation gap in\n"
  3354. "number (integer) of tool widths.")
  3355. )
  3356. grid0.addWidget(passlabel, 1, 0)
  3357. self.iso_width_entry = IntEntry()
  3358. grid0.addWidget(self.iso_width_entry, 1, 1)
  3359. # Pass overlap
  3360. overlabel = QtWidgets.QLabel(_('Pass overlap:'))
  3361. overlabel.setToolTip(
  3362. _("How much (fraction) of the tool width to overlap each tool pass.\n"
  3363. "Example:\n"
  3364. "A value here of 0.25 means an overlap of 25%% from the tool diameter found above.")
  3365. )
  3366. grid0.addWidget(overlabel, 2, 0)
  3367. self.iso_overlap_entry = FloatEntry()
  3368. grid0.addWidget(self.iso_overlap_entry, 2, 1)
  3369. milling_type_label = QtWidgets.QLabel(_('Milling Type:'))
  3370. milling_type_label.setToolTip(
  3371. _("Milling type:\n"
  3372. "- climb / best for precision milling and to reduce tool usage\n"
  3373. "- conventional / useful when there is no backlash compensation")
  3374. )
  3375. grid0.addWidget(milling_type_label, 3, 0)
  3376. self.milling_type_radio = RadioSet([{'label': _('Climb'), 'value': 'cl'},
  3377. {'label': _('Conv.'), 'value': 'cv'}])
  3378. grid0.addWidget(self.milling_type_radio, 3, 1)
  3379. # Combine passes
  3380. self.combine_passes_cb = FCCheckBox(label=_('Combine Passes'))
  3381. self.combine_passes_cb.setToolTip(
  3382. _("Combine all passes into one object")
  3383. )
  3384. grid0.addWidget(self.combine_passes_cb, 4, 0)
  3385. ## Clear non-copper regions
  3386. self.clearcopper_label = QtWidgets.QLabel(_("<b>Clear non-copper:</b>"))
  3387. self.clearcopper_label.setToolTip(
  3388. _("Create a Geometry object with\n"
  3389. "toolpaths to cut all non-copper regions.")
  3390. )
  3391. self.layout.addWidget(self.clearcopper_label)
  3392. grid1 = QtWidgets.QGridLayout()
  3393. self.layout.addLayout(grid1)
  3394. # Margin
  3395. bmlabel = QtWidgets.QLabel(_('Boundary Margin:'))
  3396. bmlabel.setToolTip(
  3397. _("Specify the edge of the PCB\n"
  3398. "by drawing a box around all\n"
  3399. "objects with this minimum\n"
  3400. "distance.")
  3401. )
  3402. grid1.addWidget(bmlabel, 0, 0)
  3403. self.noncopper_margin_entry = LengthEntry()
  3404. grid1.addWidget(self.noncopper_margin_entry, 0, 1)
  3405. # Rounded corners
  3406. self.noncopper_rounded_cb = FCCheckBox(label=_("Rounded corners"))
  3407. self.noncopper_rounded_cb.setToolTip(
  3408. _("Creates a Geometry objects with polygons\n"
  3409. "covering the copper-free areas of the PCB.")
  3410. )
  3411. grid1.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  3412. ## Bounding box
  3413. self.boundingbox_label = QtWidgets.QLabel(_('<b>Bounding Box:</b>'))
  3414. self.layout.addWidget(self.boundingbox_label)
  3415. grid2 = QtWidgets.QGridLayout()
  3416. self.layout.addLayout(grid2)
  3417. bbmargin = QtWidgets.QLabel(_('Boundary Margin:'))
  3418. bbmargin.setToolTip(
  3419. _("Distance of the edges of the box\n"
  3420. "to the nearest polygon.")
  3421. )
  3422. grid2.addWidget(bbmargin, 0, 0)
  3423. self.bbmargin_entry = LengthEntry()
  3424. grid2.addWidget(self.bbmargin_entry, 0, 1)
  3425. self.bbrounded_cb = FCCheckBox(label=_("Rounded corners"))
  3426. self.bbrounded_cb.setToolTip(
  3427. _("If the bounding box is \n"
  3428. "to have rounded corners\n"
  3429. "their radius is equal to\n"
  3430. "the margin.")
  3431. )
  3432. grid2.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  3433. self.layout.addStretch()
  3434. class GerberAdvOptPrefGroupUI(OptionsGroupUI):
  3435. def __init__(self, parent=None):
  3436. # OptionsGroupUI.__init__(self, "Gerber Adv. Options Preferences", parent=parent)
  3437. super(GerberAdvOptPrefGroupUI, self).__init__(self)
  3438. self.setTitle(str(_("Gerber Adv. Options")))
  3439. ## Advanced Gerber Parameters
  3440. self.adv_param_label = QtWidgets.QLabel(_("<b>Advanced Param.:</b>"))
  3441. self.adv_param_label.setToolTip(
  3442. _("A list of Gerber advanced parameters.\n"
  3443. "Those parameters are available only for\n"
  3444. "Advanced App. Level.")
  3445. )
  3446. self.layout.addWidget(self.adv_param_label)
  3447. grid0 = QtWidgets.QGridLayout()
  3448. self.layout.addLayout(grid0)
  3449. # Follow Attribute
  3450. self.follow_cb = FCCheckBox(label=_('"Follow"'))
  3451. self.follow_cb.setToolTip(
  3452. _("Generate a 'Follow' geometry.\n"
  3453. "This means that it will cut through\n"
  3454. "the middle of the trace.")
  3455. )
  3456. grid0.addWidget(self.follow_cb, 0, 0)
  3457. # Aperture Table Visibility CB
  3458. self.aperture_table_visibility_cb = FCCheckBox(label=_('Table Show/Hide'))
  3459. self.aperture_table_visibility_cb.setToolTip(
  3460. _("Toggle the display of the Gerber Apertures Table.\n"
  3461. "Also, on hide, it will delete all mark shapes\n"
  3462. "that are drawn on canvas.")
  3463. )
  3464. grid0.addWidget(self.aperture_table_visibility_cb, 1, 0)
  3465. # Scale Aperture Factor
  3466. self.scale_aperture_label = QtWidgets.QLabel(_('Ap. Scale Factor:'))
  3467. self.scale_aperture_label.setToolTip(
  3468. _("Change the size of the selected apertures.\n"
  3469. "Factor by which to multiply\n"
  3470. "geometric features of this object.")
  3471. )
  3472. grid0.addWidget(self.scale_aperture_label, 2, 0)
  3473. self.scale_aperture_entry = FloatEntry2()
  3474. grid0.addWidget(self.scale_aperture_entry, 2, 1)
  3475. # Buffer Aperture Factor
  3476. self.buffer_aperture_label = QtWidgets.QLabel(_('Ap. Buffer Factor:'))
  3477. self.buffer_aperture_label.setToolTip(
  3478. _("Change the size of the selected apertures.\n"
  3479. "Factor by which to expand/shrink\n"
  3480. "geometric features of this object.")
  3481. )
  3482. grid0.addWidget(self.buffer_aperture_label, 3, 0)
  3483. self.buffer_aperture_entry = FloatEntry2()
  3484. grid0.addWidget(self.buffer_aperture_entry, 3, 1)
  3485. self.layout.addStretch()
  3486. class ExcellonGenPrefGroupUI(OptionsGroupUI):
  3487. def __init__(self, parent=None):
  3488. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  3489. super(ExcellonGenPrefGroupUI, self).__init__(self)
  3490. self.setTitle(str(_("Excellon General")))
  3491. # Plot options
  3492. self.plot_options_label = QtWidgets.QLabel(_("<b>Plot Options:</b>"))
  3493. self.layout.addWidget(self.plot_options_label)
  3494. grid1 = QtWidgets.QGridLayout()
  3495. self.layout.addLayout(grid1)
  3496. self.plot_cb = FCCheckBox(label=_('Plot'))
  3497. self.plot_cb.setToolTip(
  3498. "Plot (show) this object."
  3499. )
  3500. grid1.addWidget(self.plot_cb, 0, 0)
  3501. self.solid_cb = FCCheckBox(label=_('Solid'))
  3502. self.solid_cb.setToolTip(
  3503. "Plot as solid circles."
  3504. )
  3505. grid1.addWidget(self.solid_cb, 0, 1)
  3506. # Excellon format
  3507. self.excellon_format_label = QtWidgets.QLabel(_("<b>Excellon Format:</b>"))
  3508. self.excellon_format_label.setToolTip(
  3509. _("The NC drill files, usually named Excellon files\n"
  3510. "are files that can be found in different formats.\n"
  3511. "Here we set the format used when the provided\n"
  3512. "coordinates are not using period.\n"
  3513. "\n"
  3514. "Possible presets:\n"
  3515. "\n"
  3516. "PROTEUS 3:3 MM LZ\n"
  3517. "DipTrace 5:2 MM TZ\n"
  3518. "DipTrace 4:3 MM LZ\n"
  3519. "\n"
  3520. "EAGLE 3:3 MM TZ\n"
  3521. "EAGLE 4:3 MM TZ\n"
  3522. "EAGLE 2:5 INCH TZ\n"
  3523. "EAGLE 3:5 INCH TZ\n"
  3524. "\n"
  3525. "ALTIUM 2:4 INCH LZ\n"
  3526. "Sprint Layout 2:4 INCH LZ"
  3527. "\n"
  3528. "KiCAD 3:5 INCH TZ")
  3529. )
  3530. self.layout.addWidget(self.excellon_format_label)
  3531. hlay1 = QtWidgets.QHBoxLayout()
  3532. self.layout.addLayout(hlay1)
  3533. self.excellon_format_in_label = QtWidgets.QLabel(_("INCH:"))
  3534. self.excellon_format_in_label.setAlignment(QtCore.Qt.AlignLeft)
  3535. self.excellon_format_in_label.setToolTip(
  3536. _("Default values for INCH are 2:4"))
  3537. hlay1.addWidget(self.excellon_format_in_label, QtCore.Qt.AlignLeft)
  3538. self.excellon_format_upper_in_entry = IntEntry()
  3539. self.excellon_format_upper_in_entry.setMaxLength(1)
  3540. self.excellon_format_upper_in_entry.setAlignment(QtCore.Qt.AlignRight)
  3541. self.excellon_format_upper_in_entry.setFixedWidth(30)
  3542. self.excellon_format_upper_in_entry.setToolTip(
  3543. _( "This numbers signify the number of digits in\n"
  3544. "the whole part of Excellon coordinates.")
  3545. )
  3546. hlay1.addWidget(self.excellon_format_upper_in_entry, QtCore.Qt.AlignLeft)
  3547. excellon_separator_in_label= QtWidgets.QLabel(':')
  3548. excellon_separator_in_label.setFixedWidth(5)
  3549. hlay1.addWidget(excellon_separator_in_label, QtCore.Qt.AlignLeft)
  3550. self.excellon_format_lower_in_entry = IntEntry()
  3551. self.excellon_format_lower_in_entry.setMaxLength(1)
  3552. self.excellon_format_lower_in_entry.setAlignment(QtCore.Qt.AlignRight)
  3553. self.excellon_format_lower_in_entry.setFixedWidth(30)
  3554. self.excellon_format_lower_in_entry.setToolTip(
  3555. _("This numbers signify the number of digits in\n"
  3556. "the decimal part of Excellon coordinates.")
  3557. )
  3558. hlay1.addWidget(self.excellon_format_lower_in_entry, QtCore.Qt.AlignLeft)
  3559. hlay1.addStretch()
  3560. hlay2 = QtWidgets.QHBoxLayout()
  3561. self.layout.addLayout(hlay2)
  3562. self.excellon_format_mm_label = QtWidgets.QLabel(_("METRIC:"))
  3563. self.excellon_format_mm_label.setAlignment(QtCore.Qt.AlignLeft)
  3564. self.excellon_format_mm_label.setToolTip(
  3565. _("Default values for METRIC are 3:3"))
  3566. hlay2.addWidget(self.excellon_format_mm_label, QtCore.Qt.AlignLeft)
  3567. self.excellon_format_upper_mm_entry = IntEntry()
  3568. self.excellon_format_upper_mm_entry.setMaxLength(1)
  3569. self.excellon_format_upper_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  3570. self.excellon_format_upper_mm_entry.setFixedWidth(30)
  3571. self.excellon_format_upper_mm_entry.setToolTip(
  3572. _("This numbers signify the number of digits in\n"
  3573. "the whole part of Excellon coordinates.")
  3574. )
  3575. hlay2.addWidget(self.excellon_format_upper_mm_entry, QtCore.Qt.AlignLeft)
  3576. excellon_separator_mm_label= QtWidgets.QLabel(':')
  3577. excellon_separator_mm_label.setFixedWidth(5)
  3578. hlay2.addWidget(excellon_separator_mm_label, QtCore.Qt.AlignLeft)
  3579. self.excellon_format_lower_mm_entry = IntEntry()
  3580. self.excellon_format_lower_mm_entry.setMaxLength(1)
  3581. self.excellon_format_lower_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  3582. self.excellon_format_lower_mm_entry.setFixedWidth(30)
  3583. self.excellon_format_lower_mm_entry.setToolTip(
  3584. _("This numbers signify the number of digits in\n"
  3585. "the decimal part of Excellon coordinates.")
  3586. )
  3587. hlay2.addWidget(self.excellon_format_lower_mm_entry, QtCore.Qt.AlignLeft)
  3588. hlay2.addStretch()
  3589. hlay3 = QtWidgets.QHBoxLayout()
  3590. self.layout.addLayout(hlay3)
  3591. self.excellon_zeros_label = QtWidgets.QLabel(_('Default <b>Zeros</b>:'))
  3592. self.excellon_zeros_label.setAlignment(QtCore.Qt.AlignLeft)
  3593. self.excellon_zeros_label.setToolTip(
  3594. _("This sets the type of Excellon zeros.\n"
  3595. "If LZ then Leading Zeros are kept and\n"
  3596. "Trailing Zeros are removed.\n"
  3597. "If TZ is checked then Trailing Zeros are kept\n"
  3598. "and Leading Zeros are removed.")
  3599. )
  3600. hlay3.addWidget(self.excellon_zeros_label)
  3601. self.excellon_zeros_radio = RadioSet([{'label': _('LZ'), 'value': 'L'},
  3602. {'label': _('TZ'), 'value': 'T'}])
  3603. self.excellon_zeros_radio.setToolTip(
  3604. _("This sets the default type of Excellon zeros.\n"
  3605. "If it is not detected in the parsed file the value here\n"
  3606. "will be used."
  3607. "If LZ then Leading Zeros are kept and\n"
  3608. "Trailing Zeros are removed.\n"
  3609. "If TZ is checked then Trailing Zeros are kept\n"
  3610. "and Leading Zeros are removed.")
  3611. )
  3612. hlay3.addStretch()
  3613. hlay3.addWidget(self.excellon_zeros_radio, QtCore.Qt.AlignRight)
  3614. hlay4 = QtWidgets.QHBoxLayout()
  3615. self.layout.addLayout(hlay4)
  3616. self.excellon_units_label = QtWidgets.QLabel(_('Default <b>Units</b>:'))
  3617. self.excellon_units_label.setAlignment(QtCore.Qt.AlignLeft)
  3618. self.excellon_units_label.setToolTip(
  3619. _("This sets the default units of Excellon files.\n"
  3620. "If it is not detected in the parsed file the value here\n"
  3621. "will be used."
  3622. "Some Excellon files don't have an header\n"
  3623. "therefore this parameter will be used.")
  3624. )
  3625. hlay4.addWidget(self.excellon_units_label)
  3626. self.excellon_units_radio = RadioSet([{'label': _('INCH'), 'value': 'INCH'},
  3627. {'label': _('MM'), 'value': 'METRIC'}])
  3628. self.excellon_units_radio.setToolTip(
  3629. _("This sets the units of Excellon files.\n"
  3630. "Some Excellon files don't have an header\n"
  3631. "therefore this parameter will be used.")
  3632. )
  3633. hlay4.addStretch()
  3634. hlay4.addWidget(self.excellon_units_radio, QtCore.Qt.AlignRight)
  3635. hlay5 = QtWidgets.QVBoxLayout()
  3636. self.layout.addLayout(hlay5)
  3637. self.empty_label = QtWidgets.QLabel("")
  3638. hlay5.addWidget(self.empty_label)
  3639. hlay6 = QtWidgets.QVBoxLayout()
  3640. self.layout.addLayout(hlay6)
  3641. self.excellon_general_label = QtWidgets.QLabel(_("<b>Excellon Optimization:</b>"))
  3642. hlay6.addWidget(self.excellon_general_label)
  3643. # Create a form layout for the Excellon general settings
  3644. form_box_excellon = QtWidgets.QFormLayout()
  3645. hlay6.addLayout(form_box_excellon)
  3646. self.excellon_optimization_label = QtWidgets.QLabel(_('Algorithm: '))
  3647. self.excellon_optimization_label.setAlignment(QtCore.Qt.AlignLeft)
  3648. self.excellon_optimization_label.setToolTip(
  3649. _("This sets the optimization type for the Excellon drill path.\n"
  3650. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  3651. "Guided Local Path is used. Default search time is 3sec.\n"
  3652. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  3653. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  3654. "\n"
  3655. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  3656. "Travelling Salesman algorithm for path optimization.")
  3657. )
  3658. self.excellon_optimization_radio = RadioSet([{'label': _('MH'), 'value': 'M'},
  3659. {'label': _('Basic'), 'value': 'B'}])
  3660. self.excellon_optimization_radio.setToolTip(
  3661. _("This sets the optimization type for the Excellon drill path.\n"
  3662. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  3663. "Guided Local Path is used. Default search time is 3sec.\n"
  3664. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  3665. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  3666. "\n"
  3667. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  3668. "Travelling Salesman algorithm for path optimization.")
  3669. )
  3670. form_box_excellon.addRow(self.excellon_optimization_label, self.excellon_optimization_radio)
  3671. self.optimization_time_label = QtWidgets.QLabel(_('Optimization Time: '))
  3672. self.optimization_time_label.setAlignment(QtCore.Qt.AlignLeft)
  3673. self.optimization_time_label.setToolTip(
  3674. _("When OR-Tools Metaheuristic (MH) is enabled there is a\n"
  3675. "maximum threshold for how much time is spent doing the\n"
  3676. "path optimization. This max duration is set here.\n"
  3677. "In seconds.")
  3678. )
  3679. self.optimization_time_entry = LengthEntry()
  3680. form_box_excellon.addRow(self.optimization_time_label, self.optimization_time_entry)
  3681. current_platform = platform.architecture()[0]
  3682. if current_platform == '64bit':
  3683. self.excellon_optimization_label.setDisabled(False)
  3684. self.excellon_optimization_radio.setDisabled(False)
  3685. self.optimization_time_label.setDisabled(False)
  3686. self.optimization_time_entry.setDisabled(False)
  3687. self.excellon_optimization_radio.activated_custom.connect(self.optimization_selection)
  3688. else:
  3689. self.excellon_optimization_label.setDisabled(True)
  3690. self.excellon_optimization_radio.setDisabled(True)
  3691. self.optimization_time_label.setDisabled(True)
  3692. self.optimization_time_entry.setDisabled(True)
  3693. self.layout.addStretch()
  3694. def optimization_selection(self):
  3695. if self.excellon_optimization_radio.get_value() == 'M':
  3696. self.optimization_time_label.setDisabled(False)
  3697. self.optimization_time_entry.setDisabled(False)
  3698. else:
  3699. self.optimization_time_label.setDisabled(True)
  3700. self.optimization_time_entry.setDisabled(True)
  3701. class ExcellonOptPrefGroupUI(OptionsGroupUI):
  3702. def __init__(self, parent=None):
  3703. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  3704. super(ExcellonOptPrefGroupUI, self).__init__(self)
  3705. self.setTitle(str(_("Excellon Options")))
  3706. ## Create CNC Job
  3707. self.cncjob_label = QtWidgets.QLabel(_('<b>Create CNC Job</b>'))
  3708. self.cncjob_label.setToolTip(
  3709. _("Parameters used to create a CNC Job object\n"
  3710. "for this drill object.")
  3711. )
  3712. self.layout.addWidget(self.cncjob_label)
  3713. grid2 = QtWidgets.QGridLayout()
  3714. self.layout.addLayout(grid2)
  3715. cutzlabel = QtWidgets.QLabel(_('Cut Z:'))
  3716. cutzlabel.setToolTip(
  3717. _("Drill depth (negative)\n"
  3718. "below the copper surface.")
  3719. )
  3720. grid2.addWidget(cutzlabel, 0, 0)
  3721. self.cutz_entry = LengthEntry()
  3722. grid2.addWidget(self.cutz_entry, 0, 1)
  3723. travelzlabel = QtWidgets.QLabel(_('Travel Z:'))
  3724. travelzlabel.setToolTip(
  3725. _("Tool height when travelling\n"
  3726. "across the XY plane.")
  3727. )
  3728. grid2.addWidget(travelzlabel, 1, 0)
  3729. self.travelz_entry = LengthEntry()
  3730. grid2.addWidget(self.travelz_entry, 1, 1)
  3731. # Tool change:
  3732. toolchlabel = QtWidgets.QLabel(_("Tool change:"))
  3733. toolchlabel.setToolTip(
  3734. _("Include tool-change sequence\n"
  3735. "in G-Code (Pause for tool change).")
  3736. )
  3737. self.toolchange_cb = FCCheckBox()
  3738. grid2.addWidget(toolchlabel, 2, 0)
  3739. grid2.addWidget(self.toolchange_cb, 2, 1)
  3740. toolchangezlabel = QtWidgets.QLabel(_('Toolchange Z:'))
  3741. toolchangezlabel.setToolTip(
  3742. _("Toolchange Z position.")
  3743. )
  3744. grid2.addWidget(toolchangezlabel, 3, 0)
  3745. self.toolchangez_entry = LengthEntry()
  3746. grid2.addWidget(self.toolchangez_entry, 3, 1)
  3747. frlabel = QtWidgets.QLabel(_('Feedrate:'))
  3748. frlabel.setToolTip(
  3749. _("Tool speed while drilling\n"
  3750. "(in units per minute).")
  3751. )
  3752. grid2.addWidget(frlabel, 4, 0)
  3753. self.feedrate_entry = LengthEntry()
  3754. grid2.addWidget(self.feedrate_entry, 4, 1)
  3755. # Spindle speed
  3756. spdlabel = QtWidgets.QLabel(_('Spindle Speed:'))
  3757. spdlabel.setToolTip(
  3758. _("Speed of the spindle\n"
  3759. "in RPM (optional)")
  3760. )
  3761. grid2.addWidget(spdlabel, 5, 0)
  3762. self.spindlespeed_entry = IntEntry(allow_empty=True)
  3763. grid2.addWidget(self.spindlespeed_entry, 5, 1)
  3764. # Dwell
  3765. dwelllabel = QtWidgets.QLabel(_('Dwell:'))
  3766. dwelllabel.setToolTip(
  3767. _("Pause to allow the spindle to reach its\n"
  3768. "speed before cutting.")
  3769. )
  3770. dwelltime = QtWidgets.QLabel(_('Duration:'))
  3771. dwelltime.setToolTip(
  3772. _("Number of milliseconds for spindle to dwell.")
  3773. )
  3774. self.dwell_cb = FCCheckBox()
  3775. self.dwelltime_entry = FCEntry()
  3776. grid2.addWidget(dwelllabel, 6, 0)
  3777. grid2.addWidget(self.dwell_cb, 6, 1)
  3778. grid2.addWidget(dwelltime, 7, 0)
  3779. grid2.addWidget(self.dwelltime_entry, 7, 1)
  3780. self.ois_dwell_exc = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  3781. # postprocessor selection
  3782. pp_excellon_label = QtWidgets.QLabel(_("Postprocessor:"))
  3783. pp_excellon_label.setToolTip(
  3784. _("The postprocessor file that dictates\n"
  3785. "gcode output.")
  3786. )
  3787. grid2.addWidget(pp_excellon_label, 8, 0)
  3788. self.pp_excellon_name_cb = FCComboBox()
  3789. self.pp_excellon_name_cb.setFocusPolicy(Qt.StrongFocus)
  3790. grid2.addWidget(self.pp_excellon_name_cb, 8, 1)
  3791. #### Choose what to use for Gcode creation: Drills, Slots or Both
  3792. excellon_gcode_type_label = QtWidgets.QLabel(_('<b>Gcode: </b>'))
  3793. excellon_gcode_type_label.setToolTip(
  3794. _("Choose what to use for GCode generation:\n"
  3795. "'Drills', 'Slots' or 'Both'.\n"
  3796. "When choosing 'Slots' or 'Both', slots will be\n"
  3797. "converted to drills.")
  3798. )
  3799. self.excellon_gcode_type_radio = RadioSet([{'label': _('Drills'), 'value': 'drills'},
  3800. {'label': _('Slots'), 'value': 'slots'},
  3801. {'label': _('Both'), 'value': 'both'}])
  3802. grid2.addWidget(excellon_gcode_type_label, 9, 0)
  3803. grid2.addWidget(self.excellon_gcode_type_radio, 9, 1)
  3804. # until I decide to implement this feature those remain disabled
  3805. excellon_gcode_type_label.hide()
  3806. self.excellon_gcode_type_radio.setVisible(False)
  3807. #### Milling Holes ####
  3808. self.mill_hole_label = QtWidgets.QLabel(_('<b>Mill Holes</b>'))
  3809. self.mill_hole_label.setToolTip(
  3810. _("Create Geometry for milling holes.")
  3811. )
  3812. self.layout.addWidget(self.mill_hole_label)
  3813. grid3 = QtWidgets.QGridLayout()
  3814. self.layout.addLayout(grid3)
  3815. tdlabel = QtWidgets.QLabel(_('Drill Tool dia:'))
  3816. tdlabel.setToolTip(
  3817. _("Diameter of the cutting tool.")
  3818. )
  3819. grid3.addWidget(tdlabel, 0, 0)
  3820. self.tooldia_entry = LengthEntry()
  3821. grid3.addWidget(self.tooldia_entry, 0, 1)
  3822. stdlabel = QtWidgets.QLabel(_('Slot Tool dia:'))
  3823. stdlabel.setToolTip(
  3824. _("Diameter of the cutting tool\n"
  3825. "when milling slots.")
  3826. )
  3827. grid3.addWidget(stdlabel, 1, 0)
  3828. self.slot_tooldia_entry = LengthEntry()
  3829. grid3.addWidget(self.slot_tooldia_entry, 1, 1)
  3830. grid4 = QtWidgets.QGridLayout()
  3831. self.layout.addLayout(grid4)
  3832. # Adding the Excellon Format Defaults Button
  3833. self.excellon_defaults_button = QtWidgets.QPushButton()
  3834. self.excellon_defaults_button.setText(str(_("Defaults")))
  3835. self.excellon_defaults_button.setFixedWidth(80)
  3836. grid4.addWidget(self.excellon_defaults_button, 0, 0, QtCore.Qt.AlignRight)
  3837. self.layout.addStretch()
  3838. class ExcellonAdvOptPrefGroupUI(OptionsGroupUI):
  3839. def __init__(self, parent=None):
  3840. # OptionsGroupUI.__init__(self, "Excellon Advanced Options", parent=parent)
  3841. super(ExcellonAdvOptPrefGroupUI, self).__init__(self)
  3842. self.setTitle(str(_("Excellon Adv. Options")))
  3843. ######################
  3844. ## ADVANCED OPTIONS ##
  3845. ######################
  3846. self.cncjob_label = QtWidgets.QLabel(_('<b>Advanced Options:</b>'))
  3847. self.cncjob_label.setToolTip(
  3848. _("Parameters used to create a CNC Job object\n"
  3849. "for this drill object that are shown when App Level is Advanced.")
  3850. )
  3851. self.layout.addWidget(self.cncjob_label)
  3852. grid1 = QtWidgets.QGridLayout()
  3853. self.layout.addLayout(grid1)
  3854. offsetlabel = QtWidgets.QLabel(_('Offset Z:'))
  3855. offsetlabel.setToolTip(
  3856. _("Some drill bits (the larger ones) need to drill deeper\n"
  3857. "to create the desired exit hole diameter due of the tip shape.\n"
  3858. "The value here can compensate the Cut Z parameter."))
  3859. grid1.addWidget(offsetlabel, 0, 0)
  3860. self.offset_entry = LengthEntry()
  3861. grid1.addWidget(self.offset_entry, 0, 1)
  3862. toolchange_xy_label = QtWidgets.QLabel(_('Toolchange X,Y:'))
  3863. toolchange_xy_label.setToolTip(
  3864. _("Toolchange X,Y position.")
  3865. )
  3866. grid1.addWidget(toolchange_xy_label, 1, 0)
  3867. self.toolchangexy_entry = FCEntry()
  3868. grid1.addWidget(self.toolchangexy_entry, 1, 1)
  3869. startzlabel = QtWidgets.QLabel(_('Start move Z:'))
  3870. startzlabel.setToolTip(
  3871. _("Height of the tool just after start.\n"
  3872. "Delete the value if you don't need this feature.")
  3873. )
  3874. grid1.addWidget(startzlabel, 2, 0)
  3875. self.estartz_entry = FloatEntry()
  3876. grid1.addWidget(self.estartz_entry, 2, 1)
  3877. endzlabel = QtWidgets.QLabel(_('End move Z:'))
  3878. endzlabel.setToolTip(
  3879. _("Height of the tool after\n"
  3880. "the last move at the end of the job.")
  3881. )
  3882. grid1.addWidget(endzlabel, 3, 0)
  3883. self.eendz_entry = LengthEntry()
  3884. grid1.addWidget(self.eendz_entry, 3, 1)
  3885. fr_rapid_label = QtWidgets.QLabel(_('Feedrate Rapids:'))
  3886. fr_rapid_label.setToolTip(
  3887. _("Tool speed while drilling\n"
  3888. "(in units per minute).\n"
  3889. "This is for the rapid move G00.\n"
  3890. "It is useful only for Marlin,\n"
  3891. "ignore for any other cases.")
  3892. )
  3893. grid1.addWidget(fr_rapid_label, 4, 0)
  3894. self.feedrate_rapid_entry = LengthEntry()
  3895. grid1.addWidget(self.feedrate_rapid_entry, 4, 1)
  3896. # Probe depth
  3897. self.pdepth_label = QtWidgets.QLabel(_("Probe Z depth:"))
  3898. self.pdepth_label.setToolTip(
  3899. _("The maximum depth that the probe is allowed\n"
  3900. "to probe. Negative value, in current units.")
  3901. )
  3902. grid1.addWidget(self.pdepth_label, 5, 0)
  3903. self.pdepth_entry = FCEntry()
  3904. grid1.addWidget(self.pdepth_entry, 5, 1)
  3905. # Probe feedrate
  3906. self.feedrate_probe_label = QtWidgets.QLabel(_("Feedrate Probe:"))
  3907. self.feedrate_probe_label.setToolTip(
  3908. _( "The feedrate used while the probe is probing.")
  3909. )
  3910. grid1.addWidget(self.feedrate_probe_label, 6, 0)
  3911. self.feedrate_probe_entry = FCEntry()
  3912. grid1.addWidget(self.feedrate_probe_entry, 6, 1)
  3913. fplungelabel = QtWidgets.QLabel(_('Fast Plunge:'))
  3914. fplungelabel.setToolTip(
  3915. _("By checking this, the vertical move from\n"
  3916. "Z_Toolchange to Z_move is done with G0,\n"
  3917. "meaning the fastest speed available.\n"
  3918. "WARNING: the move is done at Toolchange X,Y coords.")
  3919. )
  3920. self.fplunge_cb = FCCheckBox()
  3921. grid1.addWidget(fplungelabel, 7, 0)
  3922. grid1.addWidget(self.fplunge_cb, 7, 1)
  3923. fretractlabel = QtWidgets.QLabel(_('Fast Retract:'))
  3924. fretractlabel.setToolTip(
  3925. _("Exit hole strategy.\n"
  3926. " - When uncheked, while exiting the drilled hole the drill bit\n"
  3927. "will travel slow, with set feedrate (G1), up to zero depth and then\n"
  3928. "travel as fast as possible (G0) to the Z Move (travel height).\n"
  3929. " - When checked the travel from Z cut (cut depth) to Z_move\n"
  3930. "(travel height) is done as fast as possible (G0) in one move.")
  3931. )
  3932. self.fretract_cb = FCCheckBox()
  3933. grid1.addWidget(fretractlabel, 8, 0)
  3934. grid1.addWidget(self.fretract_cb, 8, 1)
  3935. self.layout.addStretch()
  3936. class ExcellonExpPrefGroupUI(OptionsGroupUI):
  3937. def __init__(self, parent=None):
  3938. super(ExcellonExpPrefGroupUI, self).__init__(self)
  3939. self.setTitle(str(_("Excellon Export")))
  3940. # Plot options
  3941. self.export_options_label = QtWidgets.QLabel(_("<b>Export Options:</b>"))
  3942. self.export_options_label.setToolTip(
  3943. _("The parameters set here are used in the file exported\n"
  3944. "when using the File -> Export -> Export Excellon menu entry.")
  3945. )
  3946. self.layout.addWidget(self.export_options_label)
  3947. form = QtWidgets.QFormLayout()
  3948. self.layout.addLayout(form)
  3949. # Excellon Units
  3950. self.excellon_units_label = QtWidgets.QLabel(_('<b>Units</b>:'))
  3951. self.excellon_units_label.setToolTip(
  3952. _("The units used in the Excellon file.")
  3953. )
  3954. self.excellon_units_radio = RadioSet([{'label': _('INCH'), 'value': 'INCH'},
  3955. {'label': _('MM'), 'value': 'METRIC'}])
  3956. self.excellon_units_radio.setToolTip(
  3957. _("The units used in the Excellon file.")
  3958. )
  3959. form.addRow(self.excellon_units_label, self.excellon_units_radio)
  3960. # Excellon non-decimal format
  3961. self.digits_label = QtWidgets.QLabel(_("<b>Int/Decimals:</b>"))
  3962. self.digits_label.setToolTip(
  3963. _("The NC drill files, usually named Excellon files\n"
  3964. "are files that can be found in different formats.\n"
  3965. "Here we set the format used when the provided\n"
  3966. "coordinates are not using period.")
  3967. )
  3968. hlay1 = QtWidgets.QHBoxLayout()
  3969. self.format_whole_entry = IntEntry()
  3970. self.format_whole_entry.setMaxLength(1)
  3971. self.format_whole_entry.setAlignment(QtCore.Qt.AlignRight)
  3972. self.format_whole_entry.setFixedWidth(30)
  3973. self.format_whole_entry.setToolTip(
  3974. _("This numbers signify the number of digits in\n"
  3975. "the whole part of Excellon coordinates.")
  3976. )
  3977. hlay1.addWidget(self.format_whole_entry, QtCore.Qt.AlignLeft)
  3978. excellon_separator_label= QtWidgets.QLabel(':')
  3979. excellon_separator_label.setFixedWidth(5)
  3980. hlay1.addWidget(excellon_separator_label, QtCore.Qt.AlignLeft)
  3981. self.format_dec_entry = IntEntry()
  3982. self.format_dec_entry.setMaxLength(1)
  3983. self.format_dec_entry.setAlignment(QtCore.Qt.AlignRight)
  3984. self.format_dec_entry.setFixedWidth(30)
  3985. self.format_dec_entry.setToolTip(
  3986. _("This numbers signify the number of digits in\n"
  3987. "the decimal part of Excellon coordinates.")
  3988. )
  3989. hlay1.addWidget(self.format_dec_entry, QtCore.Qt.AlignLeft)
  3990. hlay1.addStretch()
  3991. form.addRow(self.digits_label, hlay1)
  3992. # Select the Excellon Format
  3993. self.format_label = QtWidgets.QLabel(_("<b>Format:</b>"))
  3994. self.format_label.setToolTip(
  3995. _("Select the kind of coordinates format used.\n"
  3996. "Coordinates can be saved with decimal point or without.\n"
  3997. "When there is no decimal point, it is required to specify\n"
  3998. "the number of digits for integer part and the number of decimals.\n"
  3999. "Also it will have to be specified if LZ = leading zeros are kept\n"
  4000. "or TZ = trailing zeros are kept.")
  4001. )
  4002. self.format_radio = RadioSet([{'label': _('Decimal'), 'value': 'dec'},
  4003. {'label': _('No-Decimal'), 'value': 'ndec'}])
  4004. self.format_radio.setToolTip(
  4005. _("Select the kind of coordinates format used.\n"
  4006. "Coordinates can be saved with decimal point or without.\n"
  4007. "When there is no decimal point, it is required to specify\n"
  4008. "the number of digits for integer part and the number of decimals.\n"
  4009. "Also it will have to be specified if LZ = leading zeros are kept\n"
  4010. "or TZ = trailing zeros are kept.")
  4011. )
  4012. form.addRow(self.format_label, self.format_radio)
  4013. # Excellon Zeros
  4014. self.zeros_label = QtWidgets.QLabel(_('<b>Zeros</b>:'))
  4015. self.zeros_label.setAlignment(QtCore.Qt.AlignLeft)
  4016. self.zeros_label.setToolTip(
  4017. _("This sets the type of Excellon zeros.\n"
  4018. "If LZ then Leading Zeros are kept and\n"
  4019. "Trailing Zeros are removed.\n"
  4020. "If TZ is checked then Trailing Zeros are kept\n"
  4021. "and Leading Zeros are removed.")
  4022. )
  4023. self.zeros_radio = RadioSet([{'label': _('LZ'), 'value': 'LZ'},
  4024. {'label': _('TZ'), 'value': 'TZ'}])
  4025. self.zeros_radio.setToolTip(
  4026. _("This sets the default type of Excellon zeros.\n"
  4027. "If LZ then Leading Zeros are kept and\n"
  4028. "Trailing Zeros are removed.\n"
  4029. "If TZ is checked then Trailing Zeros are kept\n"
  4030. "and Leading Zeros are removed.")
  4031. )
  4032. form.addRow(self.zeros_label, self.zeros_radio)
  4033. self.layout.addStretch()
  4034. self.format_radio.activated_custom.connect(self.optimization_selection)
  4035. def optimization_selection(self):
  4036. if self.format_radio.get_value() == 'dec':
  4037. self.zeros_label.setDisabled(True)
  4038. self.zeros_radio.setDisabled(True)
  4039. else:
  4040. self.zeros_label.setDisabled(False)
  4041. self.zeros_radio.setDisabled(False)
  4042. class GeometryGenPrefGroupUI(OptionsGroupUI):
  4043. def __init__(self, parent=None):
  4044. # OptionsGroupUI.__init__(self, "Geometry General Preferences", parent=parent)
  4045. super(GeometryGenPrefGroupUI, self).__init__(self)
  4046. self.setTitle(str(_("Geometry General")))
  4047. ## Plot options
  4048. self.plot_options_label = QtWidgets.QLabel(_("<b>Plot Options:</b>"))
  4049. self.layout.addWidget(self.plot_options_label)
  4050. # Plot CB
  4051. self.plot_cb = FCCheckBox(label=_('Plot'))
  4052. self.plot_cb.setToolTip(
  4053. _("Plot (show) this object.")
  4054. )
  4055. self.layout.addWidget(self.plot_cb)
  4056. grid0 = QtWidgets.QGridLayout()
  4057. self.layout.addLayout(grid0)
  4058. # Number of circle steps for circular aperture linear approximation
  4059. self.circle_steps_label = QtWidgets.QLabel(_("Circle Steps:"))
  4060. self.circle_steps_label.setToolTip(
  4061. _("The number of circle steps for <b>Geometry</b> \n"
  4062. "circle and arc shapes linear approximation.")
  4063. )
  4064. grid0.addWidget(self.circle_steps_label, 1, 0)
  4065. self.circle_steps_entry = IntEntry()
  4066. grid0.addWidget(self.circle_steps_entry, 1, 1)
  4067. # Tools
  4068. self.tools_label = QtWidgets.QLabel(_("<b>Tools</b>"))
  4069. self.layout.addWidget(self.tools_label)
  4070. grid0_b = QtWidgets.QGridLayout()
  4071. self.layout.addLayout(grid0_b)
  4072. # Tooldia
  4073. tdlabel = QtWidgets.QLabel(_('Tool dia: '))
  4074. tdlabel.setToolTip(
  4075. _("The diameter of the cutting\n"
  4076. "tool..")
  4077. )
  4078. grid0_b.addWidget(tdlabel, 0, 0)
  4079. self.cnctooldia_entry = LengthEntry()
  4080. grid0_b.addWidget(self.cnctooldia_entry, 0, 1)
  4081. self.layout.addStretch()
  4082. class GeometryOptPrefGroupUI(OptionsGroupUI):
  4083. def __init__(self, parent=None):
  4084. # OptionsGroupUI.__init__(self, "Geometry Options Preferences", parent=parent)
  4085. super(GeometryOptPrefGroupUI, self).__init__(self)
  4086. self.setTitle(str(_("Geometry Options")))
  4087. # ------------------------------
  4088. ## Create CNC Job
  4089. # ------------------------------
  4090. self.cncjob_label = QtWidgets.QLabel(_('<b>Create CNC Job:</b>'))
  4091. self.cncjob_label.setToolTip(
  4092. _("Create a CNC Job object\n"
  4093. "tracing the contours of this\n"
  4094. "Geometry object.")
  4095. )
  4096. self.layout.addWidget(self.cncjob_label)
  4097. grid1 = QtWidgets.QGridLayout()
  4098. self.layout.addLayout(grid1)
  4099. # Cut Z
  4100. cutzlabel = QtWidgets.QLabel(_('Cut Z:'))
  4101. cutzlabel.setToolTip(
  4102. _("Cutting depth (negative)\n"
  4103. "below the copper surface.")
  4104. )
  4105. grid1.addWidget(cutzlabel, 0, 0)
  4106. self.cutz_entry = LengthEntry()
  4107. grid1.addWidget(self.cutz_entry, 0, 1)
  4108. # Multidepth CheckBox
  4109. self.multidepth_cb = FCCheckBox(label=_('Multidepth'))
  4110. self.multidepth_cb.setToolTip(
  4111. _("Multidepth usage: True or False.")
  4112. )
  4113. grid1.addWidget(self.multidepth_cb, 1, 0)
  4114. # Depth/pass
  4115. dplabel = QtWidgets.QLabel(_('Depth/Pass:'))
  4116. dplabel.setToolTip(
  4117. _("The depth to cut on each pass,\n"
  4118. "when multidepth is enabled.\n"
  4119. "It has positive value although\n"
  4120. "it is a fraction from the depth\n"
  4121. "which has negative value.")
  4122. )
  4123. grid1.addWidget(dplabel, 2, 0)
  4124. self.depthperpass_entry = LengthEntry()
  4125. grid1.addWidget(self.depthperpass_entry, 2, 1)
  4126. self.ois_multidepth = OptionalInputSection(self.multidepth_cb, [self.depthperpass_entry])
  4127. # Travel Z
  4128. travelzlabel = QtWidgets.QLabel(_('Travel Z:'))
  4129. travelzlabel.setToolTip(
  4130. _("Height of the tool when\n"
  4131. "moving without cutting.")
  4132. )
  4133. grid1.addWidget(travelzlabel, 3, 0)
  4134. self.travelz_entry = LengthEntry()
  4135. grid1.addWidget(self.travelz_entry, 3, 1)
  4136. # Tool change:
  4137. toolchlabel = QtWidgets.QLabel(_("Tool change:"))
  4138. toolchlabel.setToolTip(
  4139. _("Include tool-change sequence\n"
  4140. "in G-Code (Pause for tool change).")
  4141. )
  4142. self.toolchange_cb = FCCheckBox()
  4143. grid1.addWidget(toolchlabel, 4, 0)
  4144. grid1.addWidget(self.toolchange_cb, 4, 1)
  4145. # Toolchange Z
  4146. toolchangezlabel = QtWidgets.QLabel(_('Toolchange Z:'))
  4147. toolchangezlabel.setToolTip(
  4148. _("Toolchange Z position.")
  4149. )
  4150. grid1.addWidget(toolchangezlabel, 5, 0)
  4151. self.toolchangez_entry = LengthEntry()
  4152. grid1.addWidget(self.toolchangez_entry, 5, 1)
  4153. # Feedrate X-Y
  4154. frlabel = QtWidgets.QLabel(_('Feed Rate X-Y:'))
  4155. frlabel.setToolTip(
  4156. _("Cutting speed in the XY\n"
  4157. "plane in units per minute")
  4158. )
  4159. grid1.addWidget(frlabel, 6, 0)
  4160. self.cncfeedrate_entry = LengthEntry()
  4161. grid1.addWidget(self.cncfeedrate_entry, 6, 1)
  4162. # Feedrate Z (Plunge)
  4163. frz_label = QtWidgets.QLabel(_('Feed Rate Z:'))
  4164. frz_label.setToolTip(
  4165. _("Cutting speed in the XY\n"
  4166. "plane in units per minute.\n"
  4167. "It is called also Plunge.")
  4168. )
  4169. grid1.addWidget(frz_label, 7, 0)
  4170. self.cncplunge_entry = LengthEntry()
  4171. grid1.addWidget(self.cncplunge_entry, 7, 1)
  4172. # Spindle Speed
  4173. spdlabel = QtWidgets.QLabel(_('Spindle speed:'))
  4174. spdlabel.setToolTip(
  4175. _("Speed of the spindle\n"
  4176. "in RPM (optional)")
  4177. )
  4178. grid1.addWidget(spdlabel, 8, 0)
  4179. self.cncspindlespeed_entry = IntEntry(allow_empty=True)
  4180. grid1.addWidget(self.cncspindlespeed_entry, 8, 1)
  4181. # Dwell
  4182. self.dwell_cb = FCCheckBox(label=_('Dwell:'))
  4183. self.dwell_cb.setToolTip(
  4184. _("Pause to allow the spindle to reach its\n"
  4185. "speed before cutting.")
  4186. )
  4187. dwelltime = QtWidgets.QLabel(_('Duration:'))
  4188. dwelltime.setToolTip(
  4189. _("Number of milliseconds for spindle to dwell.")
  4190. )
  4191. self.dwelltime_entry = FCEntry()
  4192. grid1.addWidget(self.dwell_cb, 9, 0)
  4193. grid1.addWidget(dwelltime, 10, 0)
  4194. grid1.addWidget(self.dwelltime_entry, 10, 1)
  4195. self.ois_dwell = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  4196. # postprocessor selection
  4197. pp_label = QtWidgets.QLabel(_("Postprocessor:"))
  4198. pp_label.setToolTip(
  4199. _("The postprocessor file that dictates\n"
  4200. "Machine Code output.")
  4201. )
  4202. grid1.addWidget(pp_label, 11, 0)
  4203. self.pp_geometry_name_cb = FCComboBox()
  4204. self.pp_geometry_name_cb.setFocusPolicy(Qt.StrongFocus)
  4205. grid1.addWidget(self.pp_geometry_name_cb, 11, 1)
  4206. self.layout.addStretch()
  4207. class GeometryAdvOptPrefGroupUI(OptionsGroupUI):
  4208. def __init__(self, parent=None):
  4209. # OptionsGroupUI.__init__(self, "Geometry Advanced Options Preferences", parent=parent)
  4210. super(GeometryAdvOptPrefGroupUI, self).__init__(self)
  4211. self.setTitle(str(_("Geometry Adv. Options")))
  4212. # ------------------------------
  4213. ## Advanced Options
  4214. # ------------------------------
  4215. self.cncjob_label = QtWidgets.QLabel(_('<b>Advanced Options:</b>'))
  4216. self.cncjob_label.setToolTip(
  4217. _("Parameters to create a CNC Job object\n"
  4218. "tracing the contours of a Geometry object.")
  4219. )
  4220. self.layout.addWidget(self.cncjob_label)
  4221. grid1 = QtWidgets.QGridLayout()
  4222. self.layout.addLayout(grid1)
  4223. # Toolchange X,Y
  4224. toolchange_xy_label = QtWidgets.QLabel(_('Toolchange X,Y:'))
  4225. toolchange_xy_label.setToolTip(
  4226. _("Toolchange X,Y position.")
  4227. )
  4228. grid1.addWidget(toolchange_xy_label, 1, 0)
  4229. self.toolchangexy_entry = FCEntry()
  4230. grid1.addWidget(self.toolchangexy_entry, 1, 1)
  4231. # Start move Z
  4232. startzlabel = QtWidgets.QLabel(_('Start move Z:'))
  4233. startzlabel.setToolTip(
  4234. _("Height of the tool just after starting the work.\n"
  4235. "Delete the value if you don't need this feature.")
  4236. )
  4237. grid1.addWidget(startzlabel, 2, 0)
  4238. self.gstartz_entry = FloatEntry()
  4239. grid1.addWidget(self.gstartz_entry, 2, 1)
  4240. # End move Z
  4241. endzlabel = QtWidgets.QLabel(_('End move Z:'))
  4242. endzlabel.setToolTip(
  4243. _("Height of the tool after\n"
  4244. "the last move at the end of the job.")
  4245. )
  4246. grid1.addWidget(endzlabel, 3, 0)
  4247. self.gendz_entry = LengthEntry()
  4248. grid1.addWidget(self.gendz_entry, 3, 1)
  4249. # Feedrate rapids
  4250. fr_rapid_label = QtWidgets.QLabel(_('Feedrate Rapids:'))
  4251. fr_rapid_label.setToolTip(
  4252. _("Cutting speed in the XY plane\n"
  4253. "(in units per minute).\n"
  4254. "This is for the rapid move G00.\n"
  4255. "It is useful only for Marlin,\n"
  4256. "ignore for any other cases."
  4257. )
  4258. )
  4259. grid1.addWidget(fr_rapid_label, 4, 0)
  4260. self.cncfeedrate_rapid_entry = LengthEntry()
  4261. grid1.addWidget(self.cncfeedrate_rapid_entry, 4, 1)
  4262. # End move extra cut
  4263. self.extracut_cb = FCCheckBox(label=_('Re-cut 1st pt.'))
  4264. self.extracut_cb.setToolTip(
  4265. _("In order to remove possible\n"
  4266. "copper leftovers where first cut\n"
  4267. "meet with last cut, we generate an\n"
  4268. "extended cut over the first cut section.")
  4269. )
  4270. grid1.addWidget(self.extracut_cb, 5, 0)
  4271. # Probe depth
  4272. self.pdepth_label = QtWidgets.QLabel(_("Probe Z depth:"))
  4273. self.pdepth_label.setToolTip(
  4274. _("The maximum depth that the probe is allowed\n"
  4275. "to probe. Negative value, in current units.")
  4276. )
  4277. grid1.addWidget(self.pdepth_label, 6, 0)
  4278. self.pdepth_entry = FCEntry()
  4279. grid1.addWidget(self.pdepth_entry, 6, 1)
  4280. # Probe feedrate
  4281. self.feedrate_probe_label = QtWidgets.QLabel(_("Feedrate Probe:"))
  4282. self.feedrate_probe_label.setToolTip(
  4283. _("The feedrate used while the probe is probing.")
  4284. )
  4285. grid1.addWidget(self.feedrate_probe_label, 7, 0)
  4286. self.feedrate_probe_entry = FCEntry()
  4287. grid1.addWidget(self.feedrate_probe_entry, 7, 1)
  4288. # Fast Move from Z Toolchange
  4289. fplungelabel = QtWidgets.QLabel(_('Fast Plunge:'))
  4290. fplungelabel.setToolTip(
  4291. _("By checking this, the vertical move from\n"
  4292. "Z_Toolchange to Z_move is done with G0,\n"
  4293. "meaning the fastest speed available.\n"
  4294. "WARNING: the move is done at Toolchange X,Y coords.")
  4295. )
  4296. self.fplunge_cb = FCCheckBox()
  4297. grid1.addWidget(fplungelabel, 8, 0)
  4298. grid1.addWidget(self.fplunge_cb, 8, 1)
  4299. # Size of trace segment on X axis
  4300. segx_label = QtWidgets.QLabel(_("Seg. X size:"))
  4301. segx_label.setToolTip(
  4302. _("The size of the trace segment on the X axis.\n"
  4303. "Useful for auto-leveling.\n"
  4304. "A value of 0 means no segmentation on the X axis.")
  4305. )
  4306. grid1.addWidget(segx_label, 9, 0)
  4307. self.segx_entry = FCEntry()
  4308. grid1.addWidget(self.segx_entry, 9, 1)
  4309. # Size of trace segment on Y axis
  4310. segy_label = QtWidgets.QLabel(_("Seg. Y size:"))
  4311. segy_label.setToolTip(
  4312. _("The size of the trace segment on the Y axis.\n"
  4313. "Useful for auto-leveling.\n"
  4314. "A value of 0 means no segmentation on the Y axis.")
  4315. )
  4316. grid1.addWidget(segy_label, 10, 0)
  4317. self.segy_entry = FCEntry()
  4318. grid1.addWidget(self.segy_entry, 10, 1)
  4319. self.layout.addStretch()
  4320. class CNCJobGenPrefGroupUI(OptionsGroupUI):
  4321. def __init__(self, parent=None):
  4322. # OptionsGroupUI.__init__(self, "CNC Job General Preferences", parent=None)
  4323. super(CNCJobGenPrefGroupUI, self).__init__(self)
  4324. self.setTitle(str(_("CNC Job General")))
  4325. ## Plot options
  4326. self.plot_options_label = QtWidgets.QLabel(_("<b>Plot Options:</b>"))
  4327. self.layout.addWidget(self.plot_options_label)
  4328. grid0 = QtWidgets.QGridLayout()
  4329. self.layout.addLayout(grid0)
  4330. grid0.setColumnStretch(1, 1)
  4331. grid0.setColumnStretch(2, 1)
  4332. # Plot CB
  4333. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  4334. self.plot_cb = FCCheckBox(_('Plot Object'))
  4335. self.plot_cb.setToolTip(
  4336. "Plot (show) this object."
  4337. )
  4338. grid0.addWidget(self.plot_cb, 0, 0)
  4339. # Plot Kind
  4340. self.cncplot_method_label = QtWidgets.QLabel(_("Plot kind:"))
  4341. self.cncplot_method_label.setToolTip(
  4342. _("This selects the kind of geometries on the canvas to plot.\n"
  4343. "Those can be either of type 'Travel' which means the moves\n"
  4344. "above the work piece or it can be of type 'Cut',\n"
  4345. "which means the moves that cut into the material.")
  4346. )
  4347. self.cncplot_method_radio = RadioSet([
  4348. {"label": _("All"), "value": "all"},
  4349. {"label": _("Travel"), "value": "travel"},
  4350. {"label": _("Cut"), "value": "cut"}
  4351. ], stretch=False)
  4352. grid0.addWidget(self.cncplot_method_label, 1, 0)
  4353. grid0.addWidget(self.cncplot_method_radio, 1, 1)
  4354. grid0.addWidget(QtWidgets.QLabel(''), 1, 2)
  4355. # Number of circle steps for circular aperture linear approximation
  4356. self.steps_per_circle_label = QtWidgets.QLabel(_("Circle Steps:"))
  4357. self.steps_per_circle_label.setToolTip(
  4358. _("The number of circle steps for <b>GCode</b> \n"
  4359. "circle and arc shapes linear approximation.")
  4360. )
  4361. grid0.addWidget(self.steps_per_circle_label, 2, 0)
  4362. self.steps_per_circle_entry = IntEntry()
  4363. grid0.addWidget(self.steps_per_circle_entry, 2, 1)
  4364. # Tool dia for plot
  4365. tdlabel = QtWidgets.QLabel(_('Tool dia:'))
  4366. tdlabel.setToolTip(
  4367. _("Diameter of the tool to be\n"
  4368. "rendered in the plot.")
  4369. )
  4370. grid0.addWidget(tdlabel, 3, 0)
  4371. self.tooldia_entry = LengthEntry()
  4372. grid0.addWidget(self.tooldia_entry, 3, 1)
  4373. # Number of decimals to use in GCODE coordinates
  4374. cdeclabel = QtWidgets.QLabel(_('Coords dec.:'))
  4375. cdeclabel.setToolTip(
  4376. _("The number of decimals to be used for \n"
  4377. "the X, Y, Z coordinates in CNC code (GCODE, etc.)")
  4378. )
  4379. grid0.addWidget(cdeclabel, 4, 0)
  4380. self.coords_dec_entry = IntEntry()
  4381. grid0.addWidget(self.coords_dec_entry, 4, 1)
  4382. # Number of decimals to use in GCODE feedrate
  4383. frdeclabel = QtWidgets.QLabel(_('Feedrate dec.:'))
  4384. frdeclabel.setToolTip(
  4385. _("The number of decimals to be used for \n"
  4386. "the Feedrate parameter in CNC code (GCODE, etc.)")
  4387. )
  4388. grid0.addWidget(frdeclabel, 5, 0)
  4389. self.fr_dec_entry = IntEntry()
  4390. grid0.addWidget(self.fr_dec_entry, 5, 1)
  4391. self.layout.addStretch()
  4392. class CNCJobOptPrefGroupUI(OptionsGroupUI):
  4393. def __init__(self, parent=None):
  4394. # OptionsGroupUI.__init__(self, "CNC Job Options Preferences", parent=None)
  4395. super(CNCJobOptPrefGroupUI, self).__init__(self)
  4396. self.setTitle(str(_("CNC Job Options")))
  4397. ## Export G-Code
  4398. self.export_gcode_label = QtWidgets.QLabel(_("<b>Export G-Code:</b>"))
  4399. self.export_gcode_label.setToolTip(
  4400. _("Export and save G-Code to\n"
  4401. "make this object to a file.")
  4402. )
  4403. self.layout.addWidget(self.export_gcode_label)
  4404. # Prepend to G-Code
  4405. prependlabel = QtWidgets.QLabel(_('Prepend to G-Code:'))
  4406. prependlabel.setToolTip(
  4407. _("Type here any G-Code commands you would\n"
  4408. "like to add at the beginning of the G-Code file.")
  4409. )
  4410. self.layout.addWidget(prependlabel)
  4411. self.prepend_text = FCTextArea()
  4412. self.layout.addWidget(self.prepend_text)
  4413. # Append text to G-Code
  4414. appendlabel = QtWidgets.QLabel(_('Append to G-Code:'))
  4415. appendlabel.setToolTip(
  4416. _("Type here any G-Code commands you would\n"
  4417. "like to append to the generated file.\n"
  4418. "I.e.: M2 (End of program)")
  4419. )
  4420. self.layout.addWidget(appendlabel)
  4421. self.append_text = FCTextArea()
  4422. self.layout.addWidget(self.append_text)
  4423. self.layout.addStretch()
  4424. class CNCJobAdvOptPrefGroupUI(OptionsGroupUI):
  4425. def __init__(self, parent=None):
  4426. # OptionsGroupUI.__init__(self, "CNC Job Advanced Options Preferences", parent=None)
  4427. super(CNCJobAdvOptPrefGroupUI, self).__init__(self)
  4428. self.setTitle(str(_("CNC Job Adv. Options")))
  4429. ## Export G-Code
  4430. self.export_gcode_label = QtWidgets.QLabel(_("<b>Export G-Code:</b>"))
  4431. self.export_gcode_label.setToolTip(
  4432. _("Export and save G-Code to\n"
  4433. "make this object to a file.")
  4434. )
  4435. self.layout.addWidget(self.export_gcode_label)
  4436. # Prepend to G-Code
  4437. toolchangelabel = QtWidgets.QLabel(_('Toolchange G-Code:'))
  4438. toolchangelabel.setToolTip(
  4439. _("Type here any G-Code commands you would\n"
  4440. "like to be executed when Toolchange event is encountered.\n"
  4441. "This will constitute a Custom Toolchange GCode,\n"
  4442. "or a Toolchange Macro.")
  4443. )
  4444. self.layout.addWidget(toolchangelabel)
  4445. self.toolchange_text = FCTextArea()
  4446. self.layout.addWidget(self.toolchange_text)
  4447. hlay = QtWidgets.QHBoxLayout()
  4448. self.layout.addLayout(hlay)
  4449. # Toolchange Replacement GCode
  4450. self.toolchange_cb = FCCheckBox(label=_('Use Toolchange Macro'))
  4451. self.toolchange_cb.setToolTip(
  4452. _("Check this box if you want to use\n"
  4453. "a Custom Toolchange GCode (macro).")
  4454. )
  4455. hlay.addWidget(self.toolchange_cb)
  4456. hlay.addStretch()
  4457. hlay1 = QtWidgets.QHBoxLayout()
  4458. self.layout.addLayout(hlay1)
  4459. # Variable list
  4460. self.tc_variable_combo = FCComboBox()
  4461. self.tc_variable_combo.setToolTip(
  4462. _("A list of the FlatCAM variables that can be used\n"
  4463. "in the Toolchange event.\n"
  4464. "They have to be surrounded by the '%' symbol")
  4465. )
  4466. hlay1.addWidget(self.tc_variable_combo)
  4467. # Populate the Combo Box
  4468. variables = [_('Parameters'), 'tool', 'tooldia', 't_drills', 'x_toolchange', 'y_toolchange', 'z_toolchange',
  4469. 'z_cut', 'z_move', 'z_depthpercut', 'spindlespeed', 'dwelltime']
  4470. self.tc_variable_combo.addItems(variables)
  4471. self.tc_variable_combo.setItemData(0, _("FlatCAM CNC parameters"), Qt.ToolTipRole)
  4472. self.tc_variable_combo.setItemData(1, _("tool = tool number"), Qt.ToolTipRole)
  4473. self.tc_variable_combo.setItemData(2, _("tooldia = tool diameter"), Qt.ToolTipRole)
  4474. self.tc_variable_combo.setItemData(3, _("t_drills = for Excellon, total number of drills"), Qt.ToolTipRole)
  4475. self.tc_variable_combo.setItemData(4, _("x_toolchange = X coord for Toolchange"), Qt.ToolTipRole)
  4476. self.tc_variable_combo.setItemData(5, _("y_toolchange = Y coord for Toolchange"), Qt.ToolTipRole)
  4477. self.tc_variable_combo.setItemData(6, _("z_toolchange = Z coord for Toolchange"), Qt.ToolTipRole)
  4478. self.tc_variable_combo.setItemData(7, _("z_cut = Z depth for the cut"), Qt.ToolTipRole)
  4479. self.tc_variable_combo.setItemData(8, _("z_move = Z height for travel"), Qt.ToolTipRole)
  4480. self.tc_variable_combo.setItemData(9, _("z_depthpercut = the step value for multidepth cut"), Qt.ToolTipRole)
  4481. self.tc_variable_combo.setItemData(10, _("spindlesspeed = the value for the spindle speed"), Qt.ToolTipRole)
  4482. self.tc_variable_combo.setItemData(11, _("dwelltime = time to dwell to allow the spindle to reach it's set RPM"),
  4483. Qt.ToolTipRole)
  4484. hlay1.addStretch()
  4485. # Insert Variable into the Toolchange G-Code Text Box
  4486. # self.tc_insert_buton = FCButton("Insert")
  4487. # self.tc_insert_buton.setToolTip(
  4488. # "Insert the variable in the GCode Box\n"
  4489. # "surrounded by the '%' symbol."
  4490. # )
  4491. # hlay1.addWidget(self.tc_insert_buton)
  4492. self.layout.addStretch()
  4493. class ToolsNCCPrefGroupUI(OptionsGroupUI):
  4494. def __init__(self, parent=None):
  4495. # OptionsGroupUI.__init__(self, "NCC Tool Options", parent=parent)
  4496. super(ToolsNCCPrefGroupUI, self).__init__(self)
  4497. self.setTitle(str(_("NCC Tool Options")))
  4498. ## Clear non-copper regions
  4499. self.clearcopper_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4500. self.clearcopper_label.setToolTip(
  4501. _("Create a Geometry object with\n"
  4502. "toolpaths to cut all non-copper regions.")
  4503. )
  4504. self.layout.addWidget(self.clearcopper_label)
  4505. grid0 = QtWidgets.QGridLayout()
  4506. self.layout.addLayout(grid0)
  4507. ncctdlabel = QtWidgets.QLabel(_('Tools dia:'))
  4508. ncctdlabel.setToolTip(
  4509. _("Diameters of the cutting tools, separated by ','")
  4510. )
  4511. grid0.addWidget(ncctdlabel, 0, 0)
  4512. self.ncc_tool_dia_entry = FCEntry()
  4513. grid0.addWidget(self.ncc_tool_dia_entry, 0, 1)
  4514. nccoverlabel = QtWidgets.QLabel(_('Overlap Rate:'))
  4515. nccoverlabel.setToolTip(
  4516. _( "How much (fraction) of the tool width to overlap each tool pass.\n"
  4517. "Example:\n"
  4518. "A value here of 0.25 means 25% from the tool diameter found above.\n\n"
  4519. "Adjust the value starting with lower values\n"
  4520. "and increasing it if areas that should be cleared are still \n"
  4521. "not cleared.\n"
  4522. "Lower values = faster processing, faster execution on PCB.\n"
  4523. "Higher values = slow processing and slow execution on CNC\n"
  4524. "due of too many paths.")
  4525. )
  4526. grid0.addWidget(nccoverlabel, 1, 0)
  4527. self.ncc_overlap_entry = FloatEntry()
  4528. grid0.addWidget(self.ncc_overlap_entry, 1, 1)
  4529. nccmarginlabel = QtWidgets.QLabel(_('Margin:'))
  4530. nccmarginlabel.setToolTip(
  4531. _("Bounding box margin.")
  4532. )
  4533. grid0.addWidget(nccmarginlabel, 2, 0)
  4534. self.ncc_margin_entry = FloatEntry()
  4535. grid0.addWidget(self.ncc_margin_entry, 2, 1)
  4536. # Method
  4537. methodlabel = QtWidgets.QLabel(_('Method:'))
  4538. methodlabel.setToolTip(
  4539. _("Algorithm for non-copper clearing:<BR>"
  4540. "<B>Standard</B>: Fixed step inwards.<BR>"
  4541. "<B>Seed-based</B>: Outwards from seed.<BR>"
  4542. "<B>Line-based</B>: Parallel lines.")
  4543. )
  4544. grid0.addWidget(methodlabel, 3, 0)
  4545. self.ncc_method_radio = RadioSet([
  4546. {"label": _("Standard"), "value": "standard"},
  4547. {"label": _("Seed-based"), "value": "seed"},
  4548. {"label": _("Straight lines"), "value": "lines"}
  4549. ], orientation='vertical', stretch=False)
  4550. grid0.addWidget(self.ncc_method_radio, 3, 1)
  4551. # Connect lines
  4552. pathconnectlabel = QtWidgets.QLabel(_("Connect:"))
  4553. pathconnectlabel.setToolTip(
  4554. _("Draw lines between resulting\n"
  4555. "segments to minimize tool lifts.")
  4556. )
  4557. grid0.addWidget(pathconnectlabel, 4, 0)
  4558. self.ncc_connect_cb = FCCheckBox()
  4559. grid0.addWidget(self.ncc_connect_cb, 4, 1)
  4560. contourlabel = QtWidgets.QLabel(_("Contour:"))
  4561. contourlabel.setToolTip(
  4562. _( "Cut around the perimeter of the polygon\n"
  4563. "to trim rough edges.")
  4564. )
  4565. grid0.addWidget(contourlabel, 5, 0)
  4566. self.ncc_contour_cb = FCCheckBox()
  4567. grid0.addWidget(self.ncc_contour_cb, 5, 1)
  4568. restlabel = QtWidgets.QLabel(_("Rest M.:"))
  4569. restlabel.setToolTip(
  4570. _("If checked, use 'rest machining'.\n"
  4571. "Basically it will clear copper outside PCB features,\n"
  4572. "using the biggest tool and continue with the next tools,\n"
  4573. "from bigger to smaller, to clear areas of copper that\n"
  4574. "could not be cleared by previous tool.\n"
  4575. "If not checked, use the standard algorithm.")
  4576. )
  4577. grid0.addWidget(restlabel, 6, 0)
  4578. self.ncc_rest_cb = FCCheckBox()
  4579. grid0.addWidget(self.ncc_rest_cb, 6, 1)
  4580. self.layout.addStretch()
  4581. class ToolsCutoutPrefGroupUI(OptionsGroupUI):
  4582. def __init__(self, parent=None):
  4583. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  4584. super(ToolsCutoutPrefGroupUI, self).__init__(self)
  4585. self.setTitle(str(_("Cutout Tool Options")))
  4586. ## Board cuttout
  4587. self.board_cutout_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4588. self.board_cutout_label.setToolTip(
  4589. _("Create toolpaths to cut around\n"
  4590. "the PCB and separate it from\n"
  4591. "the original board.")
  4592. )
  4593. self.layout.addWidget(self.board_cutout_label)
  4594. grid0 = QtWidgets.QGridLayout()
  4595. self.layout.addLayout(grid0)
  4596. tdclabel = QtWidgets.QLabel(_('Tool dia:'))
  4597. tdclabel.setToolTip(
  4598. _( "Diameter of the cutting tool.")
  4599. )
  4600. grid0.addWidget(tdclabel, 0, 0)
  4601. self.cutout_tooldia_entry = LengthEntry()
  4602. grid0.addWidget(self.cutout_tooldia_entry, 0, 1)
  4603. marginlabel = QtWidgets.QLabel(_('Margin:'))
  4604. marginlabel.setToolTip(
  4605. _("Distance from objects at which\n"
  4606. "to draw the cutout.")
  4607. )
  4608. grid0.addWidget(marginlabel, 1, 0)
  4609. self.cutout_margin_entry = LengthEntry()
  4610. grid0.addWidget(self.cutout_margin_entry, 1, 1)
  4611. gaplabel = QtWidgets.QLabel(_('Gap size:'))
  4612. gaplabel.setToolTip(
  4613. _("Size of the gaps in the toolpath\n"
  4614. "that will remain to hold the\n"
  4615. "board in place.")
  4616. )
  4617. grid0.addWidget(gaplabel, 2, 0)
  4618. self.cutout_gap_entry = LengthEntry()
  4619. grid0.addWidget(self.cutout_gap_entry, 2, 1)
  4620. gaps_label = QtWidgets.QLabel(_('Gaps:'))
  4621. gaps_label.setToolTip(
  4622. _("Number of bridge gaps used for the cutout.\n"
  4623. "There can be maximum 8 bridges/gaps.\n"
  4624. "The choices are:\n"
  4625. "- lr - left + right\n"
  4626. "- tb - top + bottom\n"
  4627. "- 4 - left + right +top + bottom\n"
  4628. "- 2lr - 2*left + 2*right\n"
  4629. "- 2tb - 2*top + 2*bottom\n"
  4630. "- 8 - 2*left + 2*right +2*top + 2*bottom")
  4631. )
  4632. grid0.addWidget(gaps_label, 3, 0)
  4633. self.gaps_combo = FCComboBox()
  4634. grid0.addWidget(self.gaps_combo, 3, 1)
  4635. gaps_items = ['LR', 'TB', '4', '2LR', '2TB', '8']
  4636. for it in gaps_items:
  4637. self.gaps_combo.addItem(it)
  4638. self.gaps_combo.setStyleSheet('background-color: rgb(255,255,255)')
  4639. # Surrounding convex box shape
  4640. self.convex_box = FCCheckBox()
  4641. self.convex_box_label = QtWidgets.QLabel(_("Convex Sh.:"))
  4642. self.convex_box_label.setToolTip(
  4643. _("Create a convex shape surrounding the entire PCB.")
  4644. )
  4645. grid0.addWidget(self.convex_box_label, 4, 0)
  4646. grid0.addWidget(self.convex_box, 4, 1)
  4647. self.layout.addStretch()
  4648. class Tools2sidedPrefGroupUI(OptionsGroupUI):
  4649. def __init__(self, parent=None):
  4650. # OptionsGroupUI.__init__(self, "2sided Tool Options", parent=parent)
  4651. super(Tools2sidedPrefGroupUI, self).__init__(self)
  4652. self.setTitle(str(_("2Sided Tool Options")))
  4653. ## Board cuttout
  4654. self.dblsided_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4655. self.dblsided_label.setToolTip(
  4656. _("A tool to help in creating a double sided\n"
  4657. "PCB using alignment holes.")
  4658. )
  4659. self.layout.addWidget(self.dblsided_label)
  4660. grid0 = QtWidgets.QGridLayout()
  4661. self.layout.addLayout(grid0)
  4662. ## Drill diameter for alignment holes
  4663. self.drill_dia_entry = LengthEntry()
  4664. self.dd_label = QtWidgets.QLabel(_("Drill diam.:"))
  4665. self.dd_label.setToolTip(
  4666. _("Diameter of the drill for the "
  4667. "alignment holes.")
  4668. )
  4669. grid0.addWidget(self.dd_label, 0, 0)
  4670. grid0.addWidget(self.drill_dia_entry, 0, 1)
  4671. ## Axis
  4672. self.mirror_axis_radio = RadioSet([{'label': _('X'), 'value': 'X'},
  4673. {'label': _('Y'), 'value': 'Y'}])
  4674. self.mirax_label = QtWidgets.QLabel(_("Mirror Axis:"))
  4675. self.mirax_label.setToolTip(
  4676. _("Mirror vertically (X) or horizontally (Y).")
  4677. )
  4678. # grid_lay.addRow("Mirror Axis:", self.mirror_axis)
  4679. self.empty_lb1 = QtWidgets.QLabel("")
  4680. grid0.addWidget(self.empty_lb1, 1, 0)
  4681. grid0.addWidget(self.mirax_label, 2, 0)
  4682. grid0.addWidget(self.mirror_axis_radio, 2, 1)
  4683. ## Axis Location
  4684. self.axis_location_radio = RadioSet([{'label': _('Point'), 'value': 'point'},
  4685. {'label': _('Box'), 'value': 'box'}])
  4686. self.axloc_label = QtWidgets.QLabel(_("Axis Ref:"))
  4687. self.axloc_label.setToolTip(
  4688. _("The axis should pass through a <b>point</b> or cut\n "
  4689. "a specified <b>box</b> (in a Geometry object) in \n"
  4690. "the middle.")
  4691. )
  4692. # grid_lay.addRow("Axis Location:", self.axis_location)
  4693. grid0.addWidget(self.axloc_label, 3, 0)
  4694. grid0.addWidget(self.axis_location_radio, 3, 1)
  4695. self.layout.addStretch()
  4696. class ToolsPaintPrefGroupUI(OptionsGroupUI):
  4697. def __init__(self, parent=None):
  4698. # OptionsGroupUI.__init__(self, "Paint Area Tool Options", parent=parent)
  4699. super(ToolsPaintPrefGroupUI, self).__init__(self)
  4700. self.setTitle(str(_("Paint Tool Options")))
  4701. # ------------------------------
  4702. ## Paint area
  4703. # ------------------------------
  4704. self.paint_label = QtWidgets.QLabel(_('<b>Parameters:</b>'))
  4705. self.paint_label.setToolTip(
  4706. _("Creates tool paths to cover the\n"
  4707. "whole area of a polygon (remove\n"
  4708. "all copper). You will be asked\n"
  4709. "to click on the desired polygon.")
  4710. )
  4711. self.layout.addWidget(self.paint_label)
  4712. grid0 = QtWidgets.QGridLayout()
  4713. self.layout.addLayout(grid0)
  4714. # Tool dia
  4715. ptdlabel = QtWidgets.QLabel(_('Tool dia:'))
  4716. ptdlabel.setToolTip(
  4717. _("Diameter of the tool to\n"
  4718. "be used in the operation.")
  4719. )
  4720. grid0.addWidget(ptdlabel, 0, 0)
  4721. self.painttooldia_entry = LengthEntry()
  4722. grid0.addWidget(self.painttooldia_entry, 0, 1)
  4723. # Overlap
  4724. ovlabel = QtWidgets.QLabel(_('Overlap Rate:'))
  4725. ovlabel.setToolTip(
  4726. _("How much (fraction) of the tool\n"
  4727. "width to overlap each tool pass.")
  4728. )
  4729. grid0.addWidget(ovlabel, 1, 0)
  4730. self.paintoverlap_entry = LengthEntry()
  4731. grid0.addWidget(self.paintoverlap_entry, 1, 1)
  4732. # Margin
  4733. marginlabel = QtWidgets.QLabel(_('Margin:'))
  4734. marginlabel.setToolTip(
  4735. _("Distance by which to avoid\n"
  4736. "the edges of the polygon to\n"
  4737. "be painted.")
  4738. )
  4739. grid0.addWidget(marginlabel, 2, 0)
  4740. self.paintmargin_entry = LengthEntry()
  4741. grid0.addWidget(self.paintmargin_entry, 2, 1)
  4742. # Method
  4743. methodlabel = QtWidgets.QLabel(_('Method:'))
  4744. methodlabel.setToolTip(
  4745. _("Algorithm to paint the polygon:<BR>"
  4746. "<B>Standard</B>: Fixed step inwards.<BR>"
  4747. "<B>Seed-based</B>: Outwards from seed.")
  4748. )
  4749. grid0.addWidget(methodlabel, 3, 0)
  4750. self.paintmethod_combo = RadioSet([
  4751. {"label": _("Standard"), "value": "standard"},
  4752. {"label": _("Seed-based"), "value": "seed"},
  4753. {"label": _("Straight lines"), "value": "lines"}
  4754. ], orientation='vertical', stretch=False)
  4755. grid0.addWidget(self.paintmethod_combo, 3, 1)
  4756. # Connect lines
  4757. pathconnectlabel = QtWidgets.QLabel(_("Connect:"))
  4758. pathconnectlabel.setToolTip(
  4759. _("Draw lines between resulting\n"
  4760. "segments to minimize tool lifts.")
  4761. )
  4762. grid0.addWidget(pathconnectlabel, 4, 0)
  4763. self.pathconnect_cb = FCCheckBox()
  4764. grid0.addWidget(self.pathconnect_cb, 4, 1)
  4765. # Paint contour
  4766. contourlabel = QtWidgets.QLabel(_("Contour:"))
  4767. contourlabel.setToolTip(
  4768. _("Cut around the perimeter of the polygon\n"
  4769. "to trim rough edges.")
  4770. )
  4771. grid0.addWidget(contourlabel, 5, 0)
  4772. self.contour_cb = FCCheckBox()
  4773. grid0.addWidget(self.contour_cb, 5, 1)
  4774. # Polygon selection
  4775. selectlabel = QtWidgets.QLabel(_('Selection:'))
  4776. selectlabel.setToolTip(
  4777. _("How to select the polygons to paint.")
  4778. )
  4779. grid0.addWidget(selectlabel, 6, 0)
  4780. self.selectmethod_combo = RadioSet([
  4781. {"label": _("Single"), "value": "single"},
  4782. {"label": _("All"), "value": "all"},
  4783. # {"label": "Rectangle", "value": "rectangle"}
  4784. ])
  4785. grid0.addWidget(self.selectmethod_combo, 6, 1)
  4786. self.layout.addStretch()
  4787. class ToolsFilmPrefGroupUI(OptionsGroupUI):
  4788. def __init__(self, parent=None):
  4789. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  4790. super(ToolsFilmPrefGroupUI, self).__init__(self)
  4791. self.setTitle(str(_("Film Tool Options")))
  4792. ## Board cuttout
  4793. self.film_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4794. self.film_label.setToolTip(
  4795. _("Create a PCB film from a Gerber or Geometry\n"
  4796. "FlatCAM object.\n"
  4797. "The file is saved in SVG format.")
  4798. )
  4799. self.layout.addWidget(self.film_label)
  4800. grid0 = QtWidgets.QGridLayout()
  4801. self.layout.addLayout(grid0)
  4802. self.film_type_radio = RadioSet([{'label': _('Pos'), 'value': 'pos'},
  4803. {'label': _('Neg'), 'value': 'neg'}])
  4804. ftypelbl = QtWidgets.QLabel(_('Film Type:'))
  4805. ftypelbl.setToolTip(
  4806. _("Generate a Positive black film or a Negative film.\n"
  4807. "Positive means that it will print the features\n"
  4808. "with black on a white canvas.\n"
  4809. "Negative means that it will print the features\n"
  4810. "with white on a black canvas.\n"
  4811. "The Film format is SVG.")
  4812. )
  4813. grid0.addWidget(ftypelbl, 0, 0)
  4814. grid0.addWidget(self.film_type_radio, 0, 1)
  4815. self.film_boundary_entry = FCEntry()
  4816. self.film_boundary_label = QtWidgets.QLabel(_("Border:"))
  4817. self.film_boundary_label.setToolTip(
  4818. _("Specify a border around the object.\n"
  4819. "Only for negative film.\n"
  4820. "It helps if we use as a Box Object the same \n"
  4821. "object as in Film Object. It will create a thick\n"
  4822. "black bar around the actual print allowing for a\n"
  4823. "better delimitation of the outline features which are of\n"
  4824. "white color like the rest and which may confound with the\n"
  4825. "surroundings if not for this border.")
  4826. )
  4827. grid0.addWidget(self.film_boundary_label, 1, 0)
  4828. grid0.addWidget(self.film_boundary_entry, 1, 1)
  4829. self.film_scale_entry = FCEntry()
  4830. self.film_scale_label = QtWidgets.QLabel(_("Scale Stroke:"))
  4831. self.film_scale_label.setToolTip(
  4832. _("Scale the line stroke thickness of each feature in the SVG file.\n"
  4833. "It means that the line that envelope each SVG feature will be thicker or thinner,\n"
  4834. "therefore the fine features may be more affected by this parameter.")
  4835. )
  4836. grid0.addWidget(self.film_scale_label, 2, 0)
  4837. grid0.addWidget(self.film_scale_entry, 2, 1)
  4838. self.layout.addStretch()
  4839. class ToolsPanelizePrefGroupUI(OptionsGroupUI):
  4840. def __init__(self, parent=None):
  4841. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  4842. super(ToolsPanelizePrefGroupUI, self).__init__(self)
  4843. self.setTitle(str(_("Panelize Tool Options")))
  4844. ## Board cuttout
  4845. self.panelize_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  4846. self.panelize_label.setToolTip(
  4847. _("Create an object that contains an array of (x, y) elements,\n"
  4848. "each element is a copy of the source object spaced\n"
  4849. "at a X distance, Y distance of each other.")
  4850. )
  4851. self.layout.addWidget(self.panelize_label)
  4852. grid0 = QtWidgets.QGridLayout()
  4853. self.layout.addLayout(grid0)
  4854. ## Spacing Columns
  4855. self.pspacing_columns = FCEntry()
  4856. self.spacing_columns_label = QtWidgets.QLabel(_("Spacing cols:"))
  4857. self.spacing_columns_label.setToolTip(
  4858. _("Spacing between columns of the desired panel.\n"
  4859. "In current units.")
  4860. )
  4861. grid0.addWidget(self.spacing_columns_label, 0, 0)
  4862. grid0.addWidget(self.pspacing_columns, 0, 1)
  4863. ## Spacing Rows
  4864. self.pspacing_rows = FCEntry()
  4865. self.spacing_rows_label = QtWidgets.QLabel(_("Spacing rows:"))
  4866. self.spacing_rows_label.setToolTip(
  4867. _("Spacing between rows of the desired panel.\n"
  4868. "In current units.")
  4869. )
  4870. grid0.addWidget(self.spacing_rows_label, 1, 0)
  4871. grid0.addWidget(self.pspacing_rows, 1, 1)
  4872. ## Columns
  4873. self.pcolumns = FCEntry()
  4874. self.columns_label = QtWidgets.QLabel(_("Columns:"))
  4875. self.columns_label.setToolTip(
  4876. _("Number of columns of the desired panel")
  4877. )
  4878. grid0.addWidget(self.columns_label, 2, 0)
  4879. grid0.addWidget(self.pcolumns, 2, 1)
  4880. ## Rows
  4881. self.prows = FCEntry()
  4882. self.rows_label = QtWidgets.QLabel(_("Rows:"))
  4883. self.rows_label.setToolTip(
  4884. _("Number of rows of the desired panel")
  4885. )
  4886. grid0.addWidget(self.rows_label, 3, 0)
  4887. grid0.addWidget(self.prows, 3, 1)
  4888. ## Type of resulting Panel object
  4889. self.panel_type_radio = RadioSet([{'label': _('Gerber'), 'value': 'gerber'},
  4890. {'label': _('Geo'), 'value': 'geometry'}])
  4891. self.panel_type_label = QtWidgets.QLabel(_("Panel Type:"))
  4892. self.panel_type_label.setToolTip(
  4893. _( "Choose the type of object for the panel object:\n"
  4894. "- Gerber\n"
  4895. "- Geometry")
  4896. )
  4897. grid0.addWidget(self.panel_type_label, 4, 0)
  4898. grid0.addWidget(self.panel_type_radio, 4, 1)
  4899. ## Constrains
  4900. self.pconstrain_cb = FCCheckBox(_("Constrain within:"))
  4901. self.pconstrain_cb.setToolTip(
  4902. _("Area define by DX and DY within to constrain the panel.\n"
  4903. "DX and DY values are in current units.\n"
  4904. "Regardless of how many columns and rows are desired,\n"
  4905. "the final panel will have as many columns and rows as\n"
  4906. "they fit completely within selected area.")
  4907. )
  4908. grid0.addWidget(self.pconstrain_cb, 5, 0)
  4909. self.px_width_entry = FCEntry()
  4910. self.x_width_lbl = QtWidgets.QLabel(_("Width (DX):"))
  4911. self.x_width_lbl.setToolTip(
  4912. _("The width (DX) within which the panel must fit.\n"
  4913. "In current units.")
  4914. )
  4915. grid0.addWidget(self.x_width_lbl, 6, 0)
  4916. grid0.addWidget(self.px_width_entry, 6, 1)
  4917. self.py_height_entry = FCEntry()
  4918. self.y_height_lbl = QtWidgets.QLabel(_("Height (DY):"))
  4919. self.y_height_lbl.setToolTip(
  4920. _("The height (DY)within which the panel must fit.\n"
  4921. "In current units.")
  4922. )
  4923. grid0.addWidget(self.y_height_lbl, 7, 0)
  4924. grid0.addWidget(self.py_height_entry, 7, 1)
  4925. self.layout.addStretch()
  4926. class ToolsCalculatorsPrefGroupUI(OptionsGroupUI):
  4927. def __init__(self, parent=None):
  4928. # OptionsGroupUI.__init__(self, "Calculators Tool Options", parent=parent)
  4929. super(ToolsCalculatorsPrefGroupUI, self).__init__(self)
  4930. self.setTitle(str(_("Calculators Tool Options")))
  4931. ## V-shape Calculator Tool
  4932. self.vshape_tool_label = QtWidgets.QLabel(_("<b>V-Shape Tool Calculator:</b>"))
  4933. self.vshape_tool_label.setToolTip(
  4934. _("Calculate the tool diameter for a given V-shape tool,\n"
  4935. "having the tip diameter, tip angle and\n"
  4936. "depth-of-cut as parameters.")
  4937. )
  4938. self.layout.addWidget(self.vshape_tool_label)
  4939. grid0 = QtWidgets.QGridLayout()
  4940. self.layout.addLayout(grid0)
  4941. ## Tip Diameter
  4942. self.tip_dia_entry = FCEntry()
  4943. self.tip_dia_label = QtWidgets.QLabel(_("Tip Diameter:"))
  4944. self.tip_dia_label.setToolTip(
  4945. _("This is the tool tip diameter.\n"
  4946. "It is specified by manufacturer.")
  4947. )
  4948. grid0.addWidget(self.tip_dia_label, 0, 0)
  4949. grid0.addWidget(self.tip_dia_entry, 0, 1)
  4950. ## Tip angle
  4951. self.tip_angle_entry = FCEntry()
  4952. self.tip_angle_label = QtWidgets.QLabel(_("Tip angle:"))
  4953. self.tip_angle_label.setToolTip(
  4954. _("This is the angle on the tip of the tool.\n"
  4955. "It is specified by manufacturer.")
  4956. )
  4957. grid0.addWidget(self.tip_angle_label, 1, 0)
  4958. grid0.addWidget(self.tip_angle_entry, 1, 1)
  4959. ## Depth-of-cut Cut Z
  4960. self.cut_z_entry = FCEntry()
  4961. self.cut_z_label = QtWidgets.QLabel(_("Cut Z:"))
  4962. self.cut_z_label.setToolTip(
  4963. _("This is depth to cut into material.\n"
  4964. "In the CNCJob object it is the CutZ parameter.")
  4965. )
  4966. grid0.addWidget(self.cut_z_label, 2, 0)
  4967. grid0.addWidget(self.cut_z_entry, 2, 1)
  4968. ## Electroplating Calculator Tool
  4969. self.plate_title_label = QtWidgets.QLabel(_("<b>ElectroPlating Calculator:</b>"))
  4970. self.plate_title_label.setToolTip(
  4971. _("This calculator is useful for those who plate the via/pad/drill holes,\n"
  4972. "using a method like grahite ink or calcium hypophosphite ink or palladium chloride.")
  4973. )
  4974. self.layout.addWidget(self.plate_title_label)
  4975. grid1 = QtWidgets.QGridLayout()
  4976. self.layout.addLayout(grid1)
  4977. ## PCB Length
  4978. self.pcblength_entry = FCEntry()
  4979. self.pcblengthlabel = QtWidgets.QLabel(_("Board Length:"))
  4980. self.pcblengthlabel.setToolTip(_('This is the board length. In centimeters.'))
  4981. grid1.addWidget(self.pcblengthlabel, 0, 0)
  4982. grid1.addWidget(self.pcblength_entry, 0, 1)
  4983. ## PCB Width
  4984. self.pcbwidth_entry = FCEntry()
  4985. self.pcbwidthlabel = QtWidgets.QLabel(_("Board Width:"))
  4986. self.pcbwidthlabel.setToolTip(_('This is the board width.In centimeters.'))
  4987. grid1.addWidget(self.pcbwidthlabel, 1, 0)
  4988. grid1.addWidget(self.pcbwidth_entry, 1, 1)
  4989. ## Current Density
  4990. self.cdensity_label = QtWidgets.QLabel(_("Current Density:"))
  4991. self.cdensity_entry = FCEntry()
  4992. self.cdensity_label.setToolTip(_("Current density to pass through the board. \n"
  4993. "In Amps per Square Feet ASF."))
  4994. grid1.addWidget(self.cdensity_label, 2, 0)
  4995. grid1.addWidget(self.cdensity_entry, 2, 1)
  4996. ## PCB Copper Growth
  4997. self.growth_label = QtWidgets.QLabel(_("Copper Growth:"))
  4998. self.growth_entry = FCEntry()
  4999. self.growth_label.setToolTip(_("How thick the copper growth is intended to be.\n"
  5000. "In microns."))
  5001. grid1.addWidget(self.growth_label, 3, 0)
  5002. grid1.addWidget(self.growth_entry, 3, 1)
  5003. self.layout.addStretch()
  5004. class ToolsTransformPrefGroupUI(OptionsGroupUI):
  5005. def __init__(self, parent=None):
  5006. super(ToolsTransformPrefGroupUI, self).__init__(self)
  5007. self.setTitle(str(_("Transform Tool Options")))
  5008. ## Transformations
  5009. self.transform_label = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  5010. self.transform_label.setToolTip(
  5011. _("Various transformations that can be applied\n"
  5012. "on a FlatCAM object.")
  5013. )
  5014. self.layout.addWidget(self.transform_label)
  5015. grid0 = QtWidgets.QGridLayout()
  5016. self.layout.addLayout(grid0)
  5017. ## Rotate Angle
  5018. self.rotate_entry = FCEntry()
  5019. self.rotate_label = QtWidgets.QLabel(_("Rotate Angle:"))
  5020. self.rotate_label.setToolTip(
  5021. _("Angle for rotation. In degrees.")
  5022. )
  5023. grid0.addWidget(self.rotate_label, 0, 0)
  5024. grid0.addWidget(self.rotate_entry, 0, 1)
  5025. ## Skew/Shear Angle on X axis
  5026. self.skewx_entry = FCEntry()
  5027. self.skewx_label = QtWidgets.QLabel(_("Skew_X angle:"))
  5028. self.skewx_label.setToolTip(
  5029. _("Angle for Skew/Shear on X axis. In degrees.")
  5030. )
  5031. grid0.addWidget(self.skewx_label, 1, 0)
  5032. grid0.addWidget(self.skewx_entry, 1, 1)
  5033. ## Skew/Shear Angle on Y axis
  5034. self.skewy_entry = FCEntry()
  5035. self.skewy_label = QtWidgets.QLabel(_("Skew_Y angle:"))
  5036. self.skewy_label.setToolTip(
  5037. _("Angle for Skew/Shear on Y axis. In degrees.")
  5038. )
  5039. grid0.addWidget(self.skewy_label, 2, 0)
  5040. grid0.addWidget(self.skewy_entry, 2, 1)
  5041. ## Scale factor on X axis
  5042. self.scalex_entry = FCEntry()
  5043. self.scalex_label = QtWidgets.QLabel(_("Scale_X factor:"))
  5044. self.scalex_label.setToolTip(
  5045. _("Factor for scaling on X axis.")
  5046. )
  5047. grid0.addWidget(self.scalex_label, 3, 0)
  5048. grid0.addWidget(self.scalex_entry, 3, 1)
  5049. ## Scale factor on X axis
  5050. self.scaley_entry = FCEntry()
  5051. self.scaley_label = QtWidgets.QLabel(_("Scale_Y factor:"))
  5052. self.scaley_label.setToolTip(
  5053. _("Factor for scaling on Y axis.")
  5054. )
  5055. grid0.addWidget(self.scaley_label, 4, 0)
  5056. grid0.addWidget(self.scaley_entry, 4, 1)
  5057. ## Link Scale factors
  5058. self.link_cb = FCCheckBox(_("Link"))
  5059. self.link_cb.setToolTip(
  5060. _("Scale the selected object(s)\n"
  5061. "using the Scale_X factor for both axis.")
  5062. )
  5063. grid0.addWidget(self.link_cb, 5, 0)
  5064. ## Scale Reference
  5065. self.reference_cb = FCCheckBox(_("Scale Reference"))
  5066. self.reference_cb.setToolTip(
  5067. _("Scale the selected object(s)\n"
  5068. "using the origin reference when checked,\n"
  5069. "and the center of the biggest bounding box\n"
  5070. "of the selected objects when unchecked.")
  5071. )
  5072. grid0.addWidget(self.reference_cb, 5, 1)
  5073. ## Offset distance on X axis
  5074. self.offx_entry = FCEntry()
  5075. self.offx_label = QtWidgets.QLabel(_("Offset_X val:"))
  5076. self.offx_label.setToolTip(
  5077. _( "Distance to offset on X axis. In current units.")
  5078. )
  5079. grid0.addWidget(self.offx_label, 6, 0)
  5080. grid0.addWidget(self.offx_entry, 6, 1)
  5081. ## Offset distance on Y axis
  5082. self.offy_entry = FCEntry()
  5083. self.offy_label = QtWidgets.QLabel(_("Offset_Y val:"))
  5084. self.offy_label.setToolTip(
  5085. _("Distance to offset on Y axis. In current units.")
  5086. )
  5087. grid0.addWidget(self.offy_label, 7, 0)
  5088. grid0.addWidget(self.offy_entry, 7, 1)
  5089. ## Mirror (Flip) Reference Point
  5090. self.mirror_reference_cb = FCCheckBox(_("Mirror Reference"))
  5091. self.mirror_reference_cb.setToolTip(
  5092. _("Flip the selected object(s)\n"
  5093. "around the point in Point Entry Field.\n"
  5094. "\n"
  5095. "The point coordinates can be captured by\n"
  5096. "left click on canvas together with pressing\n"
  5097. "SHIFT key. \n"
  5098. "Then click Add button to insert coordinates.\n"
  5099. "Or enter the coords in format (x, y) in the\n"
  5100. "Point Entry field and click Flip on X(Y)"))
  5101. grid0.addWidget(self.mirror_reference_cb, 8, 1)
  5102. self.flip_ref_label = QtWidgets.QLabel(_(" Mirror Ref. Point:"))
  5103. self.flip_ref_label.setToolTip(
  5104. _("Coordinates in format (x, y) used as reference for mirroring.\n"
  5105. "The 'x' in (x, y) will be used when using Flip on X and\n"
  5106. "the 'y' in (x, y) will be used when using Flip on Y and")
  5107. )
  5108. self.flip_ref_entry = EvalEntry2("(0, 0)")
  5109. grid0.addWidget(self.flip_ref_label, 9, 0)
  5110. grid0.addWidget(self.flip_ref_entry, 9, 1)
  5111. self.layout.addStretch()
  5112. class ToolsSolderpastePrefGroupUI(OptionsGroupUI):
  5113. def __init__(self, parent=None):
  5114. super(ToolsSolderpastePrefGroupUI, self).__init__(self)
  5115. self.setTitle(str(_("SolderPaste Tool Options")))
  5116. ## Solder Paste Dispensing
  5117. self.solderpastelabel = QtWidgets.QLabel(_("<b>Parameters:</b>"))
  5118. self.solderpastelabel.setToolTip(
  5119. _("A tool to create GCode for dispensing\n"
  5120. "solder paste onto a PCB.")
  5121. )
  5122. self.layout.addWidget(self.solderpastelabel)
  5123. grid0 = QtWidgets.QGridLayout()
  5124. self.layout.addLayout(grid0)
  5125. # Nozzle Tool Diameters
  5126. nozzletdlabel = QtWidgets.QLabel(_('Tools dia:'))
  5127. nozzletdlabel.setToolTip(
  5128. _("Diameters of nozzle tools, separated by ','")
  5129. )
  5130. self.nozzle_tool_dia_entry = FCEntry()
  5131. grid0.addWidget(nozzletdlabel, 0, 0)
  5132. grid0.addWidget(self.nozzle_tool_dia_entry, 0, 1)
  5133. # New Nozzle Tool Dia
  5134. self.addtool_entry_lbl = QtWidgets.QLabel(_('<b>New Nozzle Dia:</b>'))
  5135. self.addtool_entry_lbl.setToolTip(
  5136. _("Diameter for the new Nozzle tool to add in the Tool Table")
  5137. )
  5138. self.addtool_entry = FCEntry()
  5139. grid0.addWidget(self.addtool_entry_lbl, 1, 0)
  5140. grid0.addWidget(self.addtool_entry, 1, 1)
  5141. # Z dispense start
  5142. self.z_start_entry = FCEntry()
  5143. self.z_start_label = QtWidgets.QLabel(_("Z Dispense Start:"))
  5144. self.z_start_label.setToolTip(
  5145. _("The height (Z) when solder paste dispensing starts.")
  5146. )
  5147. grid0.addWidget(self.z_start_label, 2, 0)
  5148. grid0.addWidget(self.z_start_entry, 2, 1)
  5149. # Z dispense
  5150. self.z_dispense_entry = FCEntry()
  5151. self.z_dispense_label = QtWidgets.QLabel(_("Z Dispense:"))
  5152. self.z_dispense_label.setToolTip(
  5153. _("The height (Z) when doing solder paste dispensing.")
  5154. )
  5155. grid0.addWidget(self.z_dispense_label, 3, 0)
  5156. grid0.addWidget(self.z_dispense_entry, 3, 1)
  5157. # Z dispense stop
  5158. self.z_stop_entry = FCEntry()
  5159. self.z_stop_label = QtWidgets.QLabel(_("Z Dispense Stop:"))
  5160. self.z_stop_label.setToolTip(
  5161. _("The height (Z) when solder paste dispensing stops.")
  5162. )
  5163. grid0.addWidget(self.z_stop_label, 4, 0)
  5164. grid0.addWidget(self.z_stop_entry, 4, 1)
  5165. # Z travel
  5166. self.z_travel_entry = FCEntry()
  5167. self.z_travel_label = QtWidgets.QLabel(_("Z Travel:"))
  5168. self.z_travel_label.setToolTip(
  5169. _("The height (Z) for travel between pads\n"
  5170. "(without dispensing solder paste).")
  5171. )
  5172. grid0.addWidget(self.z_travel_label, 5, 0)
  5173. grid0.addWidget(self.z_travel_entry, 5, 1)
  5174. # Z toolchange location
  5175. self.z_toolchange_entry = FCEntry()
  5176. self.z_toolchange_label = QtWidgets.QLabel(_("Z Toolchange:"))
  5177. self.z_toolchange_label.setToolTip(
  5178. _("The height (Z) for tool (nozzle) change.")
  5179. )
  5180. grid0.addWidget(self.z_toolchange_label, 6, 0)
  5181. grid0.addWidget(self.z_toolchange_entry, 6, 1)
  5182. # X,Y Toolchange location
  5183. self.xy_toolchange_entry = FCEntry()
  5184. self.xy_toolchange_label = QtWidgets.QLabel(_("XY Toolchange:"))
  5185. self.xy_toolchange_label.setToolTip(
  5186. _("The X,Y location for tool (nozzle) change.\n"
  5187. "The format is (x, y) where x and y are real numbers.")
  5188. )
  5189. grid0.addWidget(self.xy_toolchange_label, 7, 0)
  5190. grid0.addWidget(self.xy_toolchange_entry, 7, 1)
  5191. # Feedrate X-Y
  5192. self.frxy_entry = FCEntry()
  5193. self.frxy_label = QtWidgets.QLabel(_("Feedrate X-Y:"))
  5194. self.frxy_label.setToolTip(
  5195. _("Feedrate (speed) while moving on the X-Y plane.")
  5196. )
  5197. grid0.addWidget(self.frxy_label, 8, 0)
  5198. grid0.addWidget(self.frxy_entry, 8, 1)
  5199. # Feedrate Z
  5200. self.frz_entry = FCEntry()
  5201. self.frz_label = QtWidgets.QLabel(_("Feedrate Z:"))
  5202. self.frz_label.setToolTip(
  5203. _("Feedrate (speed) while moving vertically\n"
  5204. "(on Z plane).")
  5205. )
  5206. grid0.addWidget(self.frz_label, 9, 0)
  5207. grid0.addWidget(self.frz_entry, 9, 1)
  5208. # Feedrate Z Dispense
  5209. self.frz_dispense_entry = FCEntry()
  5210. self.frz_dispense_label = QtWidgets.QLabel(_("Feedrate Z Dispense:"))
  5211. self.frz_dispense_label.setToolTip(
  5212. _("Feedrate (speed) while moving up vertically\n"
  5213. " to Dispense position (on Z plane).")
  5214. )
  5215. grid0.addWidget(self.frz_dispense_label, 10, 0)
  5216. grid0.addWidget(self.frz_dispense_entry, 10, 1)
  5217. # Spindle Speed Forward
  5218. self.speedfwd_entry = FCEntry()
  5219. self.speedfwd_label = QtWidgets.QLabel(_("Spindle Speed FWD:"))
  5220. self.speedfwd_label.setToolTip(
  5221. _("The dispenser speed while pushing solder paste\n"
  5222. "through the dispenser nozzle.")
  5223. )
  5224. grid0.addWidget(self.speedfwd_label, 11, 0)
  5225. grid0.addWidget(self.speedfwd_entry, 11, 1)
  5226. # Dwell Forward
  5227. self.dwellfwd_entry = FCEntry()
  5228. self.dwellfwd_label = QtWidgets.QLabel(_("Dwell FWD:"))
  5229. self.dwellfwd_label.setToolTip(
  5230. _("Pause after solder dispensing.")
  5231. )
  5232. grid0.addWidget(self.dwellfwd_label, 12, 0)
  5233. grid0.addWidget(self.dwellfwd_entry, 12, 1)
  5234. # Spindle Speed Reverse
  5235. self.speedrev_entry = FCEntry()
  5236. self.speedrev_label = QtWidgets.QLabel(_("Spindle Speed REV:"))
  5237. self.speedrev_label.setToolTip(
  5238. _("The dispenser speed while retracting solder paste\n"
  5239. "through the dispenser nozzle.")
  5240. )
  5241. grid0.addWidget(self.speedrev_label, 13, 0)
  5242. grid0.addWidget(self.speedrev_entry, 13, 1)
  5243. # Dwell Reverse
  5244. self.dwellrev_entry = FCEntry()
  5245. self.dwellrev_label = QtWidgets.QLabel(_("Dwell REV:"))
  5246. self.dwellrev_label.setToolTip(
  5247. _("Pause after solder paste dispenser retracted,\n"
  5248. "to allow pressure equilibrium.")
  5249. )
  5250. grid0.addWidget(self.dwellrev_label, 14, 0)
  5251. grid0.addWidget(self.dwellrev_entry, 14, 1)
  5252. # Postprocessors
  5253. pp_label = QtWidgets.QLabel(_('PostProcessors:'))
  5254. pp_label.setToolTip(
  5255. _("Files that control the GCode generation.")
  5256. )
  5257. self.pp_combo = FCComboBox()
  5258. grid0.addWidget(pp_label, 15, 0)
  5259. grid0.addWidget(self.pp_combo, 15, 1)
  5260. self.layout.addStretch()
  5261. class FlatCAMActivityView(QtWidgets.QWidget):
  5262. def __init__(self, parent=None):
  5263. super().__init__(parent=parent)
  5264. self.setMinimumWidth(200)
  5265. self.icon = QtWidgets.QLabel(self)
  5266. self.icon.setGeometry(0, 0, 16, 12)
  5267. self.movie = QtGui.QMovie("share/active.gif")
  5268. self.icon.setMovie(self.movie)
  5269. # self.movie.start()
  5270. layout = QtWidgets.QHBoxLayout()
  5271. layout.setContentsMargins(5, 0, 5, 0)
  5272. layout.setAlignment(QtCore.Qt.AlignLeft)
  5273. self.setLayout(layout)
  5274. layout.addWidget(self.icon)
  5275. self.text = QtWidgets.QLabel(self)
  5276. self.text.setText(_("Idle."))
  5277. layout.addWidget(self.text)
  5278. def set_idle(self):
  5279. self.movie.stop()
  5280. self.text.setText(_("Idle."))
  5281. def set_busy(self, msg):
  5282. self.movie.start()
  5283. self.text.setText(msg)
  5284. class FlatCAMInfoBar(QtWidgets.QWidget):
  5285. def __init__(self, parent=None):
  5286. super(FlatCAMInfoBar, self).__init__(parent=parent)
  5287. self.icon = QtWidgets.QLabel(self)
  5288. self.icon.setGeometry(0, 0, 12, 12)
  5289. self.pmap = QtGui.QPixmap('share/graylight12.png')
  5290. self.icon.setPixmap(self.pmap)
  5291. layout = QtWidgets.QHBoxLayout()
  5292. layout.setContentsMargins(5, 0, 5, 0)
  5293. self.setLayout(layout)
  5294. layout.addWidget(self.icon)
  5295. self.text = QtWidgets.QLabel(self)
  5296. self.text.setText(_("Application started ..."))
  5297. self.text.setToolTip(_("Hello!"))
  5298. layout.addWidget(self.text)
  5299. layout.addStretch()
  5300. def set_text_(self, text, color=None):
  5301. self.text.setText(text)
  5302. self.text.setToolTip(text)
  5303. if color:
  5304. self.text.setStyleSheet('color: %s' % str(color))
  5305. def set_status(self, text, level="info"):
  5306. level = str(level)
  5307. self.pmap.fill()
  5308. if level == "ERROR" or level == "ERROR_NOTCL":
  5309. self.pmap = QtGui.QPixmap('share/redlight12.png')
  5310. elif level == "success" or level == "SUCCESS":
  5311. self.pmap = QtGui.QPixmap('share/greenlight12.png')
  5312. elif level == "WARNING" or level == "WARNING_NOTCL":
  5313. self.pmap = QtGui.QPixmap('share/yellowlight12.png')
  5314. elif level == "selected" or level == "SELECTED":
  5315. self.pmap = QtGui.QPixmap('share/bluelight12.png')
  5316. else:
  5317. self.pmap = QtGui.QPixmap('share/graylight12.png')
  5318. self.set_text_(text)
  5319. self.icon.setPixmap(self.pmap)
  5320. # end of file