FlatCAMGUI.py 268 KB

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