FlatCAMGUI.py 257 KB

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