FlatCAMGUI.py 273 KB

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