FlatCAMGUI.py 144 KB

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