FlatCAMGUI.py 342 KB

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