FlatCAMGUI.py 330 KB

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