FlatCAMGUI.py 263 KB

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