FlatCAMGUI.py 346 KB

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