FlatCAMGUI.py 244 KB

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