FlatCAMGUI.py 260 KB

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