FlatCAMGUI.py 261 KB

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