FlatCAMGUI.py 231 KB

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