FlatCAMGUI.py 348 KB

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