FlatCAMGUI.py 336 KB

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