FlatCAMGUI.py 190 KB

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