FlatCAMGUI.py 257 KB

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