FlatCAMGUI.py 231 KB

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