FlatCAMGUI.py 267 KB

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