FlatCAMGUI.py 345 KB

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