FlatCAMGUI.py 275 KB

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