FlatCAMGUI.py 350 KB

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