FlatCAMGUI.py 270 KB

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