FlatCAMGUI.py 271 KB

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