FlatCAMGUI.py 163 KB

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