FlatCAMGUI.py 266 KB

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