FlatCAMGUI.py 211 KB

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