FlatCAMGUI.py 217 KB

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