FlatCAMGUI.py 190 KB

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