FlatCAMGUI.py 220 KB

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