FlatCAMGUI.py 344 KB

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