FlatCAMGUI.py 199 KB

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