FlatCAMGUI.py 201 KB

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