FlatCAMGUI.py 112 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621
  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
  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')
  212. self.menuviewdisableall = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  213. 'Disable all plots')
  214. self.menuviewdisableother = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  215. 'Disable non-selected')
  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_grid = self.menuview.addAction(QtGui.QIcon('share/grid32.png'), "&Toggle Grid\tG")
  223. self.menuview_toggle_axis = self.menuview.addAction(QtGui.QIcon('share/axis32.png'), "&Toggle Axis\tSHIFT+G")
  224. self.menuview_toggle_workspace = self.menuview.addAction(QtGui.QIcon('share/workspace24.png'),
  225. "Toggle Workspace\tSHIFT+W")
  226. ### FlatCAM Editor menu ###
  227. # self.editor_menu = QtWidgets.QMenu("Editor")
  228. # self.menu.addMenu(self.editor_menu)
  229. self.geo_editor_menu = QtWidgets.QMenu("Geo Editor")
  230. self.menu.addMenu(self.geo_editor_menu)
  231. # self.select_menuitem = self.menu.addAction(QtGui.QIcon('share/pointer16.png'), "Select 'Esc'")
  232. self.geo_add_circle_menuitem = self.geo_editor_menu.addAction(
  233. QtGui.QIcon('share/circle32.png'), 'Add Circle\tO'
  234. )
  235. self.geo_add_arc_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/arc16.png'), 'Add Arc\tA')
  236. self.geo_editor_menu.addSeparator()
  237. self.geo_add_rectangle_menuitem = self.geo_editor_menu.addAction(
  238. QtGui.QIcon('share/rectangle32.png'), 'Add Rectangle\tR'
  239. )
  240. self.geo_add_polygon_menuitem = self.geo_editor_menu.addAction(
  241. QtGui.QIcon('share/polygon32.png'), 'Add Polygon\tN'
  242. )
  243. self.geo_add_path_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/path32.png'), 'Add Path\tP')
  244. self.geo_editor_menu.addSeparator()
  245. self.geo_add_text_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/text32.png'), 'Add Text\tT')
  246. self.geo_editor_menu.addSeparator()
  247. self.geo_union_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/union16.png'), 'Polygon Union')
  248. self.geo_intersection_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/intersection16.png'),
  249. 'Polygon Intersection')
  250. self.geo_subtract_menuitem = self.geo_editor_menu.addAction(
  251. QtGui.QIcon('share/subtract16.png'), 'Polygon Subtraction'
  252. )
  253. self.geo_editor_menu.addSeparator()
  254. self.geo_cutpath_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/cutpath16.png'), 'Cut Path\tX')
  255. # self.move_menuitem = self.menu.addAction(QtGui.QIcon('share/move16.png'), "Move Objects 'm'")
  256. self.geo_copy_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/copy16.png'), "Copy Geom\tC")
  257. self.geo_delete_menuitem = self.geo_editor_menu.addAction(
  258. QtGui.QIcon('share/deleteshape16.png'), "Delete Shape\tDEL"
  259. )
  260. self.geo_editor_menu.addSeparator()
  261. self.geo_move_menuitem = self.geo_editor_menu.addAction(QtGui.QIcon('share/move32.png'), "Move\tM")
  262. self.geo_buffer_menuitem = self.geo_editor_menu.addAction(
  263. QtGui.QIcon('share/buffer16.png'), "Buffer Selection\tB"
  264. )
  265. self.geo_paint_menuitem = self.geo_editor_menu.addAction(
  266. QtGui.QIcon('share/paint16.png'), "Paint Selection\tI"
  267. )
  268. self.geo_editor_menu.addSeparator()
  269. self.geo_cornersnap_menuitem = self.geo_editor_menu.addAction(
  270. QtGui.QIcon('share/corner32.png'), "Toggle Corner Snap\tK"
  271. )
  272. # self.exc_editor_menu = QtWidgets.QMenu("Excellon Editor")
  273. # self.menu.addMenu(self.exc_editor_menu)
  274. self.geo_editor_menu.setDisabled(True)
  275. # self.exc_editor_menu.setDisabled(True)
  276. ### Tool ###
  277. # self.menutool = self.menu.addMenu('&Tool')
  278. self.menutool = QtWidgets.QMenu('&Tool')
  279. self.menutoolaction = self.menu.addMenu(self.menutool)
  280. self.menutoolshell = self.menutool.addAction(QtGui.QIcon('share/shell16.png'), '&Command Line\tS')
  281. ### Help ###
  282. self.menuhelp = self.menu.addMenu('&Help')
  283. self.menuhelp_about = self.menuhelp.addAction(QtGui.QIcon('share/tv16.png'), 'About FlatCAM')
  284. self.menuhelp_home = self.menuhelp.addAction(QtGui.QIcon('share/home16.png'), 'Home')
  285. self.menuhelp_manual = self.menuhelp.addAction(QtGui.QIcon('share/globe16.png'), 'Manual')
  286. self.menuhelp.addSeparator()
  287. self.menuhelp_shortcut_list = self.menuhelp.addAction(QtGui.QIcon('share/shortcuts24.png'), 'Shortcuts List')
  288. self.menuhelp_videohelp = self.menuhelp.addAction(QtGui.QIcon('share/videohelp24.png'), 'See on YouTube')
  289. ################################
  290. ### Project Tab Context menu ###
  291. ################################
  292. self.menuproject = QtWidgets.QMenu()
  293. self.menuprojectenable = self.menuproject.addAction(QtGui.QIcon('share/replot32.png'), 'Enable Plot')
  294. self.menuprojectdisable = self.menuproject.addAction(QtGui.QIcon('share/clear_plot32.png'), 'Disable Plot')
  295. self.menuproject.addSeparator()
  296. self.menuprojectgeneratecnc = self.menuproject.addAction(QtGui.QIcon('share/cnc32.png'), 'Generate CNC')
  297. self.menuproject.addSeparator()
  298. self.menuprojectcopy = self.menuproject.addAction(QtGui.QIcon('share/copy32.png'), 'Copy')
  299. self.menuprojectdelete = self.menuproject.addAction(QtGui.QIcon('share/delete32.png'), 'Delete')
  300. self.menuprojectedit = self.menuproject.addAction(QtGui.QIcon('share/edit_ok32.png'), 'Edit')
  301. self.menuproject.addSeparator()
  302. self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), 'Properties')
  303. ###############
  304. ### Toolbar ###
  305. ###############
  306. self.toolbarfile = QtWidgets.QToolBar('File Toolbar')
  307. self.addToolBar(self.toolbarfile)
  308. self.file_open_gerber_btn = self.toolbarfile.addAction(QtGui.QIcon('share/flatcam_icon32.png'),
  309. "Open GERBER")
  310. self.file_open_excellon_btn = self.toolbarfile.addAction(QtGui.QIcon('share/drill32.png'), "Open EXCELLON")
  311. self.toolbarfile.addSeparator()
  312. self.file_open_btn = self.toolbarfile.addAction(QtGui.QIcon('share/folder32.png'), "Open project")
  313. self.file_save_btn = self.toolbarfile.addAction(QtGui.QIcon('share/floppy32.png'), "Save project")
  314. self.toolbargeo = QtWidgets.QToolBar('Edit Toolbar')
  315. self.addToolBar(self.toolbargeo)
  316. self.newgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "New Blank Geometry")
  317. self.newexc_btn = self.toolbargeo.addAction(QtGui.QIcon('share/new_exc32.png'), "New Blank Excellon")
  318. self.toolbargeo.addSeparator()
  319. self.editgeo_btn = self.toolbargeo.addAction(QtGui.QIcon('share/edit32.png'), "Editor")
  320. self.update_obj_btn = self.toolbargeo.addAction(
  321. QtGui.QIcon('share/edit_ok32_bis.png'), "Save Object and close the Editor"
  322. )
  323. self.update_obj_btn.setEnabled(False)
  324. self.toolbargeo.addSeparator()
  325. self.delete_btn = self.toolbargeo.addAction(QtGui.QIcon('share/cancel_edit32.png'), "&Delete")
  326. self.toolbarview = QtWidgets.QToolBar('View Toolbar')
  327. self.addToolBar(self.toolbarview)
  328. self.replot_btn = self.toolbarview.addAction(QtGui.QIcon('share/replot32.png'), "&Replot")
  329. self.clear_plot_btn = self.toolbarview.addAction(QtGui.QIcon('share/clear_plot32.png'), "&Clear plot")
  330. self.zoom_in_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_in32.png'), "Zoom In")
  331. self.zoom_out_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_out32.png'), "Zoom Out")
  332. self.zoom_fit_btn = self.toolbarview.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
  333. # self.toolbarview.setVisible(False)
  334. self.toolbartools = QtWidgets.QToolBar('Tools Toolbar')
  335. self.addToolBar(self.toolbartools)
  336. self.shell_btn = self.toolbartools.addAction(QtGui.QIcon('share/shell32.png'), "&Command Line")
  337. ### Drill Editor Toolbar ###
  338. self.exc_edit_toolbar = QtWidgets.QToolBar('Excellon Editor Toolbar')
  339. self.addToolBar(self.exc_edit_toolbar)
  340. self.select_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
  341. self.add_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/plus16.png'), 'Add Drill Hole')
  342. self.add_drill_array_btn = self.exc_edit_toolbar.addAction(
  343. QtGui.QIcon('share/addarray16.png'), 'Add Drill Hole Array')
  344. self.resize_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/resize16.png'), 'Resize Drill')
  345. self.exc_edit_toolbar.addSeparator()
  346. self.copy_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), 'Copy Drill')
  347. self.delete_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Drill")
  348. self.exc_edit_toolbar.addSeparator()
  349. self.move_drill_btn = self.exc_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Drill")
  350. self.exc_edit_toolbar.setDisabled(True)
  351. self.exc_edit_toolbar.setVisible(False)
  352. ### Geometry Editor Toolbar ###
  353. self.geo_edit_toolbar = QtWidgets.QToolBar('Geometry Editor Toolbar')
  354. self.geo_edit_toolbar.setVisible(False)
  355. self.addToolBar(self.geo_edit_toolbar)
  356. self.geo_select_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/pointer32.png'), "Select 'Esc'")
  357. self.geo_add_circle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/circle32.png'), 'Add Circle')
  358. self.geo_add_arc_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/arc32.png'), 'Add Arc')
  359. self.geo_add_rectangle_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rectangle32.png'), 'Add Rectangle')
  360. self.geo_edit_toolbar.addSeparator()
  361. self.geo_add_path_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/path32.png'), 'Add Path')
  362. self.geo_add_polygon_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/polygon32.png'), 'Add Polygon')
  363. self.geo_edit_toolbar.addSeparator()
  364. self.geo_add_text_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/text32.png'), 'Add Text')
  365. self.geo_add_buffer_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/buffer16-2.png'), 'Add Buffer')
  366. self.geo_add_paint_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/paint20_1.png'), 'Paint Shape')
  367. self.geo_edit_toolbar.addSeparator()
  368. self.geo_union_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/union32.png'), 'Polygon Union')
  369. self.geo_intersection_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/intersection32.png'),
  370. 'Polygon Intersection')
  371. self.geo_subtract_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/subtract32.png'), 'Polygon Subtraction')
  372. self.geo_edit_toolbar.addSeparator()
  373. self.geo_cutpath_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/cutpath32.png'), 'Cut Path')
  374. self.geo_copy_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/copy32.png'), "Copy Objects 'c'")
  375. self.geo_rotate_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/rotate.png'), "Rotate Objects 'Space'")
  376. self.geo_delete_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/deleteshape32.png'), "Delete Shape '-'")
  377. self.geo_edit_toolbar.addSeparator()
  378. self.geo_move_btn = self.geo_edit_toolbar.addAction(QtGui.QIcon('share/move32.png'), "Move Objects 'm'")
  379. ### Snap Toolbar ###
  380. self.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
  381. # Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
  382. self.addToolBar(self.snap_toolbar)
  383. self.grid_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/grid32.png'), 'Snap to grid')
  384. self.grid_gap_x_entry = FCEntry2()
  385. self.grid_gap_x_entry.setMaximumWidth(70)
  386. self.grid_gap_x_entry.setToolTip("Grid X distance")
  387. self.snap_toolbar.addWidget(self.grid_gap_x_entry)
  388. self.grid_gap_y_entry = FCEntry2()
  389. self.grid_gap_y_entry.setMaximumWidth(70)
  390. self.grid_gap_y_entry.setToolTip("Grid Y distance")
  391. self.snap_toolbar.addWidget(self.grid_gap_y_entry)
  392. self.grid_space_label = QtWidgets.QLabel(" ")
  393. self.snap_toolbar.addWidget(self.grid_space_label)
  394. self.grid_gap_link_cb = FCCheckBox()
  395. self.grid_gap_link_cb.setToolTip("When active, value on Grid_X\n"
  396. "is copied to the Grid_Y value.")
  397. self.snap_toolbar.addWidget(self.grid_gap_link_cb)
  398. self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
  399. self.corner_snap_btn = self.snap_toolbar.addAction(QtGui.QIcon('share/corner32.png'), 'Snap to corner')
  400. self.snap_max_dist_entry = QtWidgets.QLineEdit()
  401. self.snap_max_dist_entry.setMaximumWidth(70)
  402. self.snap_max_dist_entry.setToolTip("Max. magnet distance")
  403. self.snap_toolbar.addWidget(self.snap_max_dist_entry)
  404. self.grid_snap_btn.setCheckable(True)
  405. self.corner_snap_btn.setCheckable(True)
  406. ################
  407. ### Splitter ###
  408. ################
  409. self.splitter = QtWidgets.QSplitter()
  410. self.setCentralWidget(self.splitter)
  411. ################
  412. ### Notebook ###
  413. ################
  414. self.notebook = QtWidgets.QTabWidget()
  415. self.splitter.addWidget(self.notebook)
  416. ### Project ###
  417. self.project_tab = QtWidgets.QWidget()
  418. # project_tab.setMinimumWidth(250) # Hack
  419. self.project_tab_layout = QtWidgets.QVBoxLayout(self.project_tab)
  420. self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
  421. self.notebook.addTab(self.project_tab, "Project")
  422. ### Selected ###
  423. self.selected_tab = QtWidgets.QWidget()
  424. self.selected_tab_layout = QtWidgets.QVBoxLayout(self.selected_tab)
  425. self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
  426. self.selected_scroll_area = VerticalScrollArea()
  427. self.selected_tab_layout.addWidget(self.selected_scroll_area)
  428. self.notebook.addTab(self.selected_tab, "Selected")
  429. ### Tool ###
  430. self.tool_tab = QtWidgets.QWidget()
  431. self.tool_tab_layout = QtWidgets.QVBoxLayout(self.tool_tab)
  432. self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
  433. self.notebook.addTab(self.tool_tab, "Tool")
  434. self.tool_scroll_area = VerticalScrollArea()
  435. self.tool_tab_layout.addWidget(self.tool_scroll_area)
  436. self.right_widget = QtWidgets.QWidget()
  437. self.right_widget.setSizePolicy(QtWidgets.QSizePolicy.Ignored, QtWidgets.QSizePolicy.Ignored)
  438. self.splitter.addWidget(self.right_widget)
  439. self.right_lay = QtWidgets.QVBoxLayout()
  440. self.right_lay.setContentsMargins(0, 0, 0, 0)
  441. self.right_widget.setLayout(self.right_lay)
  442. self.plot_tab_area = FCTab()
  443. self.right_lay.addWidget(self.plot_tab_area)
  444. self.plot_tab_area.setTabsClosable(True)
  445. plot_tab = QtWidgets.QWidget()
  446. self.plot_tab_area.addTab(plot_tab, "Plot Area")
  447. self.right_layout = QtWidgets.QVBoxLayout()
  448. self.right_layout.setContentsMargins(2, 2, 2, 2)
  449. plot_tab.setLayout(self.right_layout)
  450. # remove the close button from the Plot Area tab (first tab index = 0) as this one will always be ON
  451. self.plot_tab_area.protectTab(0)
  452. ########################################
  453. ### HERE WE BUILD THE PREF. TAB AREA ###
  454. ########################################
  455. self.preferences_tab = QtWidgets.QWidget()
  456. self.pref_tab_layout = QtWidgets.QVBoxLayout(self.preferences_tab)
  457. self.pref_tab_layout.setContentsMargins(2, 2, 2, 2)
  458. self.pref_tab_area = FCTab()
  459. self.pref_tab_area.setTabsClosable(False)
  460. self.pref_tab_area_tabBar = self.pref_tab_area.tabBar()
  461. self.pref_tab_area_tabBar.setStyleSheet("QTabBar::tab{width:80px;}")
  462. self.pref_tab_area_tabBar.setExpanding(True)
  463. self.pref_tab_layout.addWidget(self.pref_tab_area)
  464. self.general_tab = QtWidgets.QWidget()
  465. self.pref_tab_area.addTab(self.general_tab, "General")
  466. self.general_tab_lay = QtWidgets.QVBoxLayout()
  467. self.general_tab_lay.setContentsMargins(2, 2, 2, 2)
  468. self.general_tab.setLayout(self.general_tab_lay)
  469. self.hlay1 = QtWidgets.QHBoxLayout()
  470. self.general_tab_lay.addLayout(self.hlay1)
  471. self.options_combo = QtWidgets.QComboBox()
  472. self.options_combo.addItem("APP. DEFAULTS")
  473. self.options_combo.addItem("PROJ. OPTIONS ")
  474. self.hlay1.addWidget(self.options_combo)
  475. self.hlay1.addStretch()
  476. self.general_scroll_area = VerticalScrollArea()
  477. self.general_tab_lay.addWidget(self.general_scroll_area)
  478. self.gerber_tab = QtWidgets.QWidget()
  479. self.pref_tab_area.addTab(self.gerber_tab, "GERBER")
  480. self.gerber_tab_lay = QtWidgets.QVBoxLayout()
  481. self.gerber_tab_lay.setContentsMargins(2, 2, 2, 2)
  482. self.gerber_tab.setLayout(self.gerber_tab_lay)
  483. self.gerber_scroll_area = VerticalScrollArea()
  484. self.gerber_tab_lay.addWidget(self.gerber_scroll_area)
  485. self.excellon_tab = QtWidgets.QWidget()
  486. self.pref_tab_area.addTab(self.excellon_tab, "EXCELLON")
  487. self.excellon_tab_lay = QtWidgets.QVBoxLayout()
  488. self.excellon_tab_lay.setContentsMargins(2, 2, 2, 2)
  489. self.excellon_tab.setLayout(self.excellon_tab_lay)
  490. self.excellon_scroll_area = VerticalScrollArea()
  491. self.excellon_tab_lay.addWidget(self.excellon_scroll_area)
  492. self.geometry_tab = QtWidgets.QWidget()
  493. self.pref_tab_area.addTab(self.geometry_tab, "GEOMETRY")
  494. self.geometry_tab_lay = QtWidgets.QVBoxLayout()
  495. self.geometry_tab_lay.setContentsMargins(2, 2, 2, 2)
  496. self.geometry_tab.setLayout(self.geometry_tab_lay)
  497. self.geometry_scroll_area = VerticalScrollArea()
  498. self.geometry_tab_lay.addWidget(self.geometry_scroll_area)
  499. self.cncjob_tab = QtWidgets.QWidget()
  500. self.pref_tab_area.addTab(self.cncjob_tab, "CNC-JOB")
  501. self.cncjob_tab_lay = QtWidgets.QVBoxLayout()
  502. self.cncjob_tab_lay.setContentsMargins(2, 2, 2, 2)
  503. self.cncjob_tab.setLayout(self.cncjob_tab_lay)
  504. self.cncjob_scroll_area = VerticalScrollArea()
  505. self.cncjob_tab_lay.addWidget(self.cncjob_scroll_area)
  506. self.tools_tab = QtWidgets.QWidget()
  507. self.pref_tab_area.addTab(self.tools_tab, "TOOLS")
  508. self.tools_tab_lay = QtWidgets.QVBoxLayout()
  509. self.tools_tab_lay.setContentsMargins(2, 2, 2, 2)
  510. self.tools_tab.setLayout(self.tools_tab_lay)
  511. self.tools_scroll_area = VerticalScrollArea()
  512. self.tools_tab_lay.addWidget(self.tools_scroll_area)
  513. self.pref_tab_bottom_layout = QtWidgets.QHBoxLayout()
  514. self.pref_tab_bottom_layout.setAlignment(QtCore.Qt.AlignVCenter)
  515. self.pref_tab_layout.addLayout(self.pref_tab_bottom_layout)
  516. self.pref_tab_bottom_layout_1 = QtWidgets.QHBoxLayout()
  517. self.pref_tab_bottom_layout_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  518. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_1)
  519. self.pref_import_button = QtWidgets.QPushButton()
  520. self.pref_import_button.setText("Import Preferences")
  521. self.pref_import_button.setFixedWidth(130)
  522. self.pref_import_button.setToolTip(
  523. "Import a full set of FlatCAM settings from a file\n"
  524. "previously saved on HDD.\n\n"
  525. "FlatCAM automatically save a 'factory_defaults' file\n"
  526. "on the first start. Do not delete that file.")
  527. self.pref_tab_bottom_layout_1.addWidget(self.pref_import_button)
  528. self.pref_export_button = QtWidgets.QPushButton()
  529. self.pref_export_button.setText("Export Preferences")
  530. self.pref_export_button.setFixedWidth(130)
  531. self.pref_export_button.setToolTip(
  532. "Export a full set of FlatCAM settings in a file\n"
  533. "that is saved on HDD.")
  534. self.pref_tab_bottom_layout_1.addWidget(self.pref_export_button)
  535. self.pref_open_button = QtWidgets.QPushButton()
  536. self.pref_open_button.setText("Open Pref Folder")
  537. self.pref_open_button.setFixedWidth(130)
  538. self.pref_open_button.setToolTip(
  539. "Open the folder where FlatCAM save the preferences files.")
  540. self.pref_tab_bottom_layout_1.addWidget(self.pref_open_button)
  541. self.pref_tab_bottom_layout_2 = QtWidgets.QHBoxLayout()
  542. self.pref_tab_bottom_layout_2.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  543. self.pref_tab_bottom_layout.addLayout(self.pref_tab_bottom_layout_2)
  544. self.pref_save_button = QtWidgets.QPushButton()
  545. self.pref_save_button.setText("Save Preferences")
  546. self.pref_save_button.setFixedWidth(130)
  547. self.pref_save_button.setToolTip(
  548. "Save the current settings in the 'current_defaults' file\n"
  549. "which is the file storing the working default preferences.")
  550. self.pref_tab_bottom_layout_2.addWidget(self.pref_save_button)
  551. ##############################################################
  552. ### HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS ###
  553. ##############################################################
  554. self.popMenu = QtWidgets.QMenu()
  555. self.cmenu_newmenu = self.popMenu.addMenu(QtGui.QIcon('share/file32.png'), "New")
  556. self.popmenu_new_geo = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_geo32_bis.png'), "Geo Obj")
  557. self.popmenu_new_exc = self.cmenu_newmenu.addAction(QtGui.QIcon('share/new_exc32.png'), "Exc. Obj")
  558. self.cmenu_newmenu.addSeparator()
  559. self.popmenu_new_prj = self.cmenu_newmenu.addAction(QtGui.QIcon('share/file16.png'), "Project")
  560. self.popMenu.addSeparator()
  561. self.cmenu_gridmenu = self.popMenu.addMenu(QtGui.QIcon('share/grid32_menu.png'), "Grids")
  562. self.gridmenu_1 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.05")
  563. self.gridmenu_2 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.10")
  564. self.gridmenu_3 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.20")
  565. self.gridmenu_4 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "0.50")
  566. self.gridmenu_5 = self.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "1.00")
  567. self.cmenu_viewmenu = self.popMenu.addMenu(QtGui.QIcon('share/view64.png'), "View")
  568. self.zoomfit = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/zoom_fit32.png'), "Zoom Fit")
  569. self.clearplot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/clear_plot32.png'), "Clear Plot")
  570. self.replot = self.cmenu_viewmenu.addAction(QtGui.QIcon('share/replot32.png'), "Replot")
  571. self.popMenu.addSeparator()
  572. self.g_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/draw32.png'), "Geo Editor")
  573. self.draw_line = self.g_editor_cmenu.addAction(QtGui.QIcon('share/path32.png'), "Line")
  574. self.draw_rect = self.g_editor_cmenu.addAction(QtGui.QIcon('share/rectangle32.png'), "Rectangle")
  575. self.draw_cut = self.g_editor_cmenu.addAction(QtGui.QIcon('share/cutpath32.png'), "Cut")
  576. self.g_editor_cmenu.addSeparator()
  577. self.draw_move = self.g_editor_cmenu.addAction(QtGui.QIcon('share/move32.png'), "Move")
  578. self.e_editor_cmenu = self.popMenu.addMenu(QtGui.QIcon('share/drill32.png'), "Exc Editor")
  579. self.drill = self.e_editor_cmenu.addAction(QtGui.QIcon('share/drill32.png'), "Add Drill")
  580. self.drill_array = self.e_editor_cmenu.addAction(QtGui.QIcon('share/addarray32.png'), "Add Drill Array")
  581. self.drill_copy = self.e_editor_cmenu.addAction(QtGui.QIcon('share/copy32.png'), "Copy Drill(s)")
  582. self.popMenu.addSeparator()
  583. self.popmenu_copy = self.popMenu.addAction(QtGui.QIcon('share/copy32.png'), "Copy")
  584. self.popmenu_delete = self.popMenu.addAction(QtGui.QIcon('share/delete32.png'), "Delete")
  585. self.popmenu_edit = self.popMenu.addAction(QtGui.QIcon('share/edit32.png'), "Edit")
  586. self.popmenu_save = self.popMenu.addAction(QtGui.QIcon('share/floppy32.png'), "Save && Close Edit")
  587. self.popmenu_save.setVisible(False)
  588. self.popMenu.addSeparator()
  589. self.popmenu_move = self.popMenu.addAction(QtGui.QIcon('share/move32.png'), "Move")
  590. self.popmenu_properties = self.popMenu.addAction(QtGui.QIcon('share/properties32.png'), "Properties")
  591. ####################################
  592. ### Here we build the CNCJob Tab ###
  593. ####################################
  594. self.cncjob_tab = QtWidgets.QWidget()
  595. self.cncjob_tab_layout = QtWidgets.QGridLayout(self.cncjob_tab)
  596. self.cncjob_tab_layout.setContentsMargins(2, 2, 2, 2)
  597. self.cncjob_tab.setLayout(self.cncjob_tab_layout)
  598. self.code_editor = QtWidgets.QTextEdit()
  599. stylesheet = """
  600. QTextEdit { selection-background-color:yellow;
  601. selection-color:black;
  602. }
  603. """
  604. self.code_editor.setStyleSheet(stylesheet)
  605. self.buttonPreview = QtWidgets.QPushButton('Print Preview')
  606. self.buttonPrint = QtWidgets.QPushButton('Print CNC Code')
  607. self.buttonFind = QtWidgets.QPushButton('Find in CNC Code')
  608. self.buttonFind.setFixedWidth(100)
  609. self.buttonPreview.setFixedWidth(100)
  610. self.entryFind = FCEntry()
  611. self.entryFind.setMaximumWidth(200)
  612. self.buttonReplace = QtWidgets.QPushButton('Replace With')
  613. self.buttonReplace.setFixedWidth(100)
  614. self.entryReplace = FCEntry()
  615. self.entryReplace.setMaximumWidth(200)
  616. self.sel_all_cb = QtWidgets.QCheckBox('All')
  617. self.sel_all_cb.setToolTip(
  618. "When checked it will replace all instances in the 'Find' box\n"
  619. "with the text in the 'Replace' box.."
  620. )
  621. self.buttonOpen = QtWidgets.QPushButton('Open CNC Code')
  622. self.buttonSave = QtWidgets.QPushButton('Save CNC Code')
  623. self.cncjob_tab_layout.addWidget(self.code_editor, 0, 0, 1, 5)
  624. cnc_tab_lay_1 = QtWidgets.QHBoxLayout()
  625. cnc_tab_lay_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  626. cnc_tab_lay_1.addWidget(self.buttonFind)
  627. cnc_tab_lay_1.addWidget(self.entryFind)
  628. cnc_tab_lay_1.addWidget(self.buttonReplace)
  629. cnc_tab_lay_1.addWidget(self.entryReplace)
  630. cnc_tab_lay_1.addWidget(self.sel_all_cb)
  631. self.cncjob_tab_layout.addLayout(cnc_tab_lay_1, 1, 0, 1, 1, QtCore.Qt.AlignLeft)
  632. cnc_tab_lay_3 = QtWidgets.QHBoxLayout()
  633. cnc_tab_lay_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  634. cnc_tab_lay_3.addWidget(self.buttonPreview)
  635. cnc_tab_lay_3.addWidget(self.buttonPrint)
  636. self.cncjob_tab_layout.addLayout(cnc_tab_lay_3, 2, 0, 1, 1, QtCore.Qt.AlignLeft)
  637. cnc_tab_lay_4 = QtWidgets.QHBoxLayout()
  638. cnc_tab_lay_4.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
  639. cnc_tab_lay_4.addWidget(self.buttonOpen)
  640. cnc_tab_lay_4.addWidget(self.buttonSave)
  641. self.cncjob_tab_layout.addLayout(cnc_tab_lay_4, 2, 4, 1, 1)
  642. ##################################
  643. ### Build InfoBar is done here ###
  644. ##################################
  645. self.infobar = self.statusBar()
  646. self.fcinfo = FlatCAMInfoBar()
  647. self.infobar.addWidget(self.fcinfo, stretch=1)
  648. self.rel_position_label = QtWidgets.QLabel(
  649. "<b>Dx</b>: 0.0000&nbsp;&nbsp; <b>Dy</b>: 0.0000&nbsp;&nbsp;&nbsp;&nbsp;")
  650. self.rel_position_label.setMinimumWidth(110)
  651. self.rel_position_label.setToolTip("Relative neasurement.\nReference is last click position")
  652. self.infobar.addWidget(self.rel_position_label)
  653. self.position_label = QtWidgets.QLabel(
  654. "&nbsp;&nbsp;&nbsp;&nbsp;<b>X</b>: 0.0000&nbsp;&nbsp; <b>Y</b>: 0.0000")
  655. self.position_label.setMinimumWidth(110)
  656. self.position_label.setToolTip("Absolute neasurement.\nReference is (X=0, Y= 0) position")
  657. self.infobar.addWidget(self.position_label)
  658. self.units_label = QtWidgets.QLabel("[in]")
  659. self.units_label.setMargin(2)
  660. self.infobar.addWidget(self.units_label)
  661. # disabled
  662. self.progress_bar = QtWidgets.QProgressBar()
  663. self.progress_bar.setMinimum(0)
  664. self.progress_bar.setMaximum(100)
  665. # infobar.addWidget(self.progress_bar)
  666. self.activity_view = FlatCAMActivityView()
  667. self.infobar.addWidget(self.activity_view)
  668. self.app_icon = QtGui.QIcon()
  669. self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16))
  670. self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24))
  671. self.app_icon.addFile('share/flatcam_icon32.png', QtCore.QSize(32, 32))
  672. self.app_icon.addFile('share/flatcam_icon48.png', QtCore.QSize(48, 48))
  673. self.app_icon.addFile('share/flatcam_icon128.png', QtCore.QSize(128, 128))
  674. self.app_icon.addFile('share/flatcam_icon256.png', QtCore.QSize(256, 256))
  675. self.setWindowIcon(self.app_icon)
  676. self.setGeometry(100, 100, 1024, 650)
  677. self.setWindowTitle('FlatCAM %s %s - %s' % (version, ('BETA' if beta else ''), platform.architecture()[0]))
  678. self.show()
  679. self.filename = ""
  680. self.setAcceptDrops(True)
  681. def dragEnterEvent(self, event):
  682. if event.mimeData().hasUrls:
  683. event.accept()
  684. else:
  685. event.ignore()
  686. def dragMoveEvent(self, event):
  687. if event.mimeData().hasUrls:
  688. event.accept()
  689. else:
  690. event.ignore()
  691. def dropEvent(self, event):
  692. if event.mimeData().hasUrls:
  693. event.setDropAction(QtCore.Qt.CopyAction)
  694. event.accept()
  695. for url in event.mimeData().urls():
  696. self.filename = str(url.toLocalFile())
  697. if self.filename == "":
  698. self.app.inform.emit("Open cancelled.")
  699. else:
  700. if self.filename.lower().rpartition('.')[-1] in self.app.grb_list:
  701. self.app.worker_task.emit({'fcn': self.app.open_gerber,
  702. 'params': [self.filename]})
  703. else:
  704. event.ignore()
  705. if self.filename.lower().rpartition('.')[-1] in self.app.exc_list:
  706. self.app.worker_task.emit({'fcn': self.app.open_excellon,
  707. 'params': [self.filename]})
  708. else:
  709. event.ignore()
  710. if self.filename.lower().rpartition('.')[-1] in self.app.gcode_list:
  711. self.app.worker_task.emit({'fcn': self.app.open_gcode,
  712. 'params': [self.filename]})
  713. else:
  714. event.ignore()
  715. if self.filename.lower().rpartition('.')[-1] in self.app.svg_list:
  716. object_type = 'geometry'
  717. self.app.worker_task.emit({'fcn': self.app.import_svg,
  718. 'params': [self.filename, object_type, None]})
  719. if self.filename.lower().rpartition('.')[-1] in self.app.dxf_list:
  720. object_type = 'geometry'
  721. self.app.worker_task.emit({'fcn': self.app.import_dxf,
  722. 'params': [self.filename, object_type, None]})
  723. if self.filename.lower().rpartition('.')[-1] in self.app.prj_list:
  724. # self.app.open_project() is not Thread Safe
  725. self.app.open_project(self.filename)
  726. else:
  727. event.ignore()
  728. else:
  729. event.ignore()
  730. def closeEvent(self, event):
  731. grect = self.geometry()
  732. # self.splitter.sizes()[0] is actually the size of the "notebook"
  733. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height(), self.splitter.sizes()[0])
  734. self.final_save.emit()
  735. if self.app.should_we_quit is True:
  736. QtWidgets.qApp.quit()
  737. else:
  738. self.app.should_we_quit = True
  739. event.ignore()
  740. class GeneralPreferencesUI(QtWidgets.QWidget):
  741. def __init__(self, parent=None):
  742. QtWidgets.QWidget.__init__(self, parent=parent)
  743. self.layout = QtWidgets.QHBoxLayout()
  744. self.setLayout(self.layout)
  745. self.general_app_group = GeneralAppPrefGroupUI()
  746. self.general_app_group.setFixedWidth(260)
  747. self.general_gui_group = GeneralGUIPrefGroupUI()
  748. self.general_gui_group.setFixedWidth(260)
  749. self.layout.addWidget(self.general_app_group)
  750. self.layout.addWidget(self.general_gui_group)
  751. self.layout.addStretch()
  752. class GerberPreferencesUI(QtWidgets.QWidget):
  753. def __init__(self, parent=None):
  754. QtWidgets.QWidget.__init__(self, parent=parent)
  755. self.layout = QtWidgets.QVBoxLayout()
  756. self.setLayout(self.layout)
  757. self.gerber_group = GerberPrefGroupUI()
  758. self.gerber_group.setFixedWidth(260)
  759. self.layout.addWidget(self.gerber_group)
  760. class ExcellonPreferencesUI(QtWidgets.QWidget):
  761. def __init__(self, parent=None):
  762. QtWidgets.QWidget.__init__(self, parent=parent)
  763. self.layout = QtWidgets.QHBoxLayout()
  764. self.setLayout(self.layout)
  765. self.excellon_gen_group = ExcellonGenPrefGroupUI()
  766. self.excellon_gen_group.setFixedWidth(260)
  767. self.excellon_opt_group = ExcellonOptPrefGroupUI()
  768. self.excellon_opt_group.setFixedWidth(260)
  769. self.layout.addWidget(self.excellon_gen_group)
  770. self.layout.addWidget(self.excellon_opt_group)
  771. self.layout.addStretch()
  772. class GeometryPreferencesUI(QtWidgets.QWidget):
  773. def __init__(self, parent=None):
  774. QtWidgets.QWidget.__init__(self, parent=parent)
  775. self.layout = QtWidgets.QVBoxLayout()
  776. self.setLayout(self.layout)
  777. self.geometry_group = GeometryPrefGroupUI()
  778. self.geometry_group.setFixedWidth(260)
  779. self.layout.addWidget(self.geometry_group)
  780. class ToolsPreferencesUI(QtWidgets.QWidget):
  781. def __init__(self, parent=None):
  782. QtWidgets.QWidget.__init__(self, parent=parent)
  783. self.layout = QtWidgets.QHBoxLayout()
  784. self.setLayout(self.layout)
  785. self.tools_ncc_group = ToolsNCCPrefGroupUI()
  786. self.tools_ncc_group.setFixedWidth(260)
  787. self.tools_cutout_group = ToolsCutoutPrefGroupUI()
  788. self.tools_cutout_group.setFixedWidth(260)
  789. self.layout.addWidget(self.tools_ncc_group)
  790. self.layout.addWidget(self.tools_cutout_group)
  791. self.layout.addStretch()
  792. class CNCJobPreferencesUI(QtWidgets.QWidget):
  793. def __init__(self, parent=None):
  794. QtWidgets.QWidget.__init__(self, parent=parent)
  795. self.layout = QtWidgets.QVBoxLayout()
  796. self.setLayout(self.layout)
  797. self.cncjob_group = CNCJobPrefGroupUI()
  798. self.cncjob_group.setFixedWidth(260)
  799. self.layout.addWidget(self.cncjob_group)
  800. class OptionsGroupUI(QtWidgets.QGroupBox):
  801. def __init__(self, title, parent=None):
  802. # QtGui.QGroupBox.__init__(self, title, parent=parent)
  803. super(OptionsGroupUI, self).__init__()
  804. self.setStyleSheet("""
  805. QGroupBox
  806. {
  807. font-size: 16px;
  808. font-weight: bold;
  809. }
  810. """)
  811. self.layout = QtWidgets.QVBoxLayout()
  812. self.setLayout(self.layout)
  813. class GeneralGUIPrefGroupUI(OptionsGroupUI):
  814. def __init__(self, parent=None):
  815. super(GeneralGUIPrefGroupUI, self).__init__(self)
  816. self.setTitle(str("GUI Preferences"))
  817. # Create a form layout for the Application general settings
  818. self.form_box = QtWidgets.QFormLayout()
  819. # Grid X Entry
  820. self.gridx_label = QtWidgets.QLabel('Grid X value:')
  821. self.gridx_label.setToolTip(
  822. "This is the Grid value on X axis\n"
  823. )
  824. self.gridx_entry = LengthEntry()
  825. # Grid Y Entry
  826. self.gridy_label = QtWidgets.QLabel('Grid Y value:')
  827. self.gridy_label.setToolTip(
  828. "This is the Grid value on Y axis\n"
  829. )
  830. self.gridy_entry = LengthEntry()
  831. # Workspace
  832. self.workspace_lbl = QtWidgets.QLabel('Workspace:')
  833. self.workspace_lbl.setToolTip(
  834. "Draw a delimiting rectangle on canvas.\n"
  835. "The purpose is to illustrate the limits for our work."
  836. )
  837. self.workspace_type_lbl = QtWidgets.QLabel('Wk. format:')
  838. self.workspace_type_lbl.setToolTip(
  839. "Select the type of rectangle to be used on canvas,\n"
  840. "as valid workspace."
  841. )
  842. self.workspace_cb = FCCheckBox()
  843. self.wk_cb = FCComboBox()
  844. self.wk_cb.addItem('A4P')
  845. self.wk_cb.addItem('A4L')
  846. self.wk_cb.addItem('A3P')
  847. self.wk_cb.addItem('A3L')
  848. self.wks = OptionalInputSection(self.workspace_cb, [self.workspace_type_lbl, self.wk_cb])
  849. # Plot Fill Color
  850. self.pf_color_label = QtWidgets.QLabel('Plot Fill:')
  851. self.pf_color_label.setToolTip(
  852. "Set the fill color for plotted objects.\n"
  853. "First 6 digits are the color and the last 2\n"
  854. "digits are for alpha (transparency) level."
  855. )
  856. self.pf_color_entry = FCEntry()
  857. self.pf_color_button = QtWidgets.QPushButton()
  858. self.pf_color_button.setFixedSize(15, 15)
  859. self.form_box_child_1 = QtWidgets.QHBoxLayout()
  860. self.form_box_child_1.addWidget(self.pf_color_entry)
  861. self.form_box_child_1.addWidget(self.pf_color_button)
  862. self.form_box_child_1.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  863. # Plot Fill Transparency Level
  864. self.pf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  865. self.pf_alpha_label.setToolTip(
  866. "Set the fill transparency for plotted objects."
  867. )
  868. self.pf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  869. self.pf_color_alpha_slider.setMinimum(0)
  870. self.pf_color_alpha_slider.setMaximum(255)
  871. self.pf_color_alpha_slider.setSingleStep(1)
  872. self.pf_color_alpha_spinner = FCSpinner()
  873. self.pf_color_alpha_spinner.setFixedWidth(70)
  874. self.pf_color_alpha_spinner.setMinimum(0)
  875. self.pf_color_alpha_spinner.setMaximum(255)
  876. self.form_box_child_2 = QtWidgets.QHBoxLayout()
  877. self.form_box_child_2.addWidget(self.pf_color_alpha_slider)
  878. self.form_box_child_2.addWidget(self.pf_color_alpha_spinner)
  879. # Plot Line Color
  880. self.pl_color_label = QtWidgets.QLabel('Plot Line:')
  881. self.pl_color_label.setToolTip(
  882. "Set the line color for plotted objects."
  883. )
  884. self.pl_color_entry = FCEntry()
  885. self.pl_color_button = QtWidgets.QPushButton()
  886. self.pl_color_button.setFixedSize(15, 15)
  887. self.form_box_child_3 = QtWidgets.QHBoxLayout()
  888. self.form_box_child_3.addWidget(self.pl_color_entry)
  889. self.form_box_child_3.addWidget(self.pl_color_button)
  890. self.form_box_child_3.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  891. # Plot Selection (left - right) Fill Color
  892. self.sf_color_label = QtWidgets.QLabel('Sel. Fill:')
  893. self.sf_color_label.setToolTip(
  894. "Set the fill color for the selection box\n"
  895. "in case that the selection is done from left to right.\n"
  896. "First 6 digits are the color and the last 2\n"
  897. "digits are for alpha (transparency) level."
  898. )
  899. self.sf_color_entry = FCEntry()
  900. self.sf_color_button = QtWidgets.QPushButton()
  901. self.sf_color_button.setFixedSize(15, 15)
  902. self.form_box_child_4 = QtWidgets.QHBoxLayout()
  903. self.form_box_child_4.addWidget(self.sf_color_entry)
  904. self.form_box_child_4.addWidget(self.sf_color_button)
  905. self.form_box_child_4.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  906. # Plot Selection (left - right) Fill Transparency Level
  907. self.sf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  908. self.sf_alpha_label.setToolTip(
  909. "Set the fill transparency for the 'left to right' selection box."
  910. )
  911. self.sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  912. self.sf_color_alpha_slider.setMinimum(0)
  913. self.sf_color_alpha_slider.setMaximum(255)
  914. self.sf_color_alpha_slider.setSingleStep(1)
  915. self.sf_color_alpha_spinner = FCSpinner()
  916. self.sf_color_alpha_spinner.setFixedWidth(70)
  917. self.sf_color_alpha_spinner.setMinimum(0)
  918. self.sf_color_alpha_spinner.setMaximum(255)
  919. self.form_box_child_5 = QtWidgets.QHBoxLayout()
  920. self.form_box_child_5.addWidget(self.sf_color_alpha_slider)
  921. self.form_box_child_5.addWidget(self.sf_color_alpha_spinner)
  922. # Plot Selection (left - right) Line Color
  923. self.sl_color_label = QtWidgets.QLabel('Sel. Line:')
  924. self.sl_color_label.setToolTip(
  925. "Set the line color for the 'left to right' selection box."
  926. )
  927. self.sl_color_entry = FCEntry()
  928. self.sl_color_button = QtWidgets.QPushButton()
  929. self.sl_color_button.setFixedSize(15, 15)
  930. self.form_box_child_6 = QtWidgets.QHBoxLayout()
  931. self.form_box_child_6.addWidget(self.sl_color_entry)
  932. self.form_box_child_6.addWidget(self.sl_color_button)
  933. self.form_box_child_6.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  934. # Plot Selection (right - left) Fill Color
  935. self.alt_sf_color_label = QtWidgets.QLabel('Sel2. Fill:')
  936. self.alt_sf_color_label.setToolTip(
  937. "Set the fill color for the selection box\n"
  938. "in case that the selection is done from right to left.\n"
  939. "First 6 digits are the color and the last 2\n"
  940. "digits are for alpha (transparency) level."
  941. )
  942. self.alt_sf_color_entry = FCEntry()
  943. self.alt_sf_color_button = QtWidgets.QPushButton()
  944. self.alt_sf_color_button.setFixedSize(15, 15)
  945. self.form_box_child_7 = QtWidgets.QHBoxLayout()
  946. self.form_box_child_7.addWidget(self.alt_sf_color_entry)
  947. self.form_box_child_7.addWidget(self.alt_sf_color_button)
  948. self.form_box_child_7.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  949. # Plot Selection (right - left) Fill Transparency Level
  950. self.alt_sf_alpha_label = QtWidgets.QLabel('Alpha Level:')
  951. self.alt_sf_alpha_label.setToolTip(
  952. "Set the fill transparency for selection 'right to left' box."
  953. )
  954. self.alt_sf_color_alpha_slider = QtWidgets.QSlider(QtCore.Qt.Horizontal)
  955. self.alt_sf_color_alpha_slider.setMinimum(0)
  956. self.alt_sf_color_alpha_slider.setMaximum(255)
  957. self.alt_sf_color_alpha_slider.setSingleStep(1)
  958. self.alt_sf_color_alpha_spinner = FCSpinner()
  959. self.alt_sf_color_alpha_spinner.setFixedWidth(70)
  960. self.alt_sf_color_alpha_spinner.setMinimum(0)
  961. self.alt_sf_color_alpha_spinner.setMaximum(255)
  962. self.form_box_child_8 = QtWidgets.QHBoxLayout()
  963. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_slider)
  964. self.form_box_child_8.addWidget(self.alt_sf_color_alpha_spinner)
  965. # Plot Selection (right - left) Line Color
  966. self.alt_sl_color_label = QtWidgets.QLabel('Sel2. Line:')
  967. self.alt_sl_color_label.setToolTip(
  968. "Set the line color for the 'right to left' selection box."
  969. )
  970. self.alt_sl_color_entry = FCEntry()
  971. self.alt_sl_color_button = QtWidgets.QPushButton()
  972. self.alt_sl_color_button.setFixedSize(15, 15)
  973. self.form_box_child_9 = QtWidgets.QHBoxLayout()
  974. self.form_box_child_9.addWidget(self.alt_sl_color_entry)
  975. self.form_box_child_9.addWidget(self.alt_sl_color_button)
  976. self.form_box_child_9.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  977. # Editor Draw Color
  978. self.draw_color_label = QtWidgets.QLabel('Editor Draw:')
  979. self.alt_sf_color_label.setToolTip(
  980. "Set the color for the shape."
  981. )
  982. self.draw_color_entry = FCEntry()
  983. self.draw_color_button = QtWidgets.QPushButton()
  984. self.draw_color_button.setFixedSize(15, 15)
  985. self.form_box_child_10 = QtWidgets.QHBoxLayout()
  986. self.form_box_child_10.addWidget(self.draw_color_entry)
  987. self.form_box_child_10.addWidget(self.draw_color_button)
  988. self.form_box_child_10.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  989. # Editor Draw Selection Color
  990. self.sel_draw_color_label = QtWidgets.QLabel('Editor Draw Sel.:')
  991. self.sel_draw_color_label.setToolTip(
  992. "Set the color of the shape when selected."
  993. )
  994. self.sel_draw_color_entry = FCEntry()
  995. self.sel_draw_color_button = QtWidgets.QPushButton()
  996. self.sel_draw_color_button.setFixedSize(15, 15)
  997. self.form_box_child_11 = QtWidgets.QHBoxLayout()
  998. self.form_box_child_11.addWidget(self.sel_draw_color_entry)
  999. self.form_box_child_11.addWidget(self.sel_draw_color_button)
  1000. self.form_box_child_11.setAlignment(QtCore.Qt.AlignLeft | QtCore.Qt.AlignVCenter)
  1001. # Just to add empty rows
  1002. self.spacelabel = QtWidgets.QLabel('')
  1003. # Add (label - input field) pair to the QFormLayout
  1004. self.form_box.addRow(self.spacelabel, self.spacelabel)
  1005. self.form_box.addRow(self.gridx_label, self.gridx_entry)
  1006. self.form_box.addRow(self.gridy_label, self.gridy_entry)
  1007. self.form_box.addRow(self.workspace_lbl, self.workspace_cb)
  1008. self.form_box.addRow(self.workspace_type_lbl, self.wk_cb)
  1009. self.form_box.addRow(self.spacelabel, self.spacelabel)
  1010. self.form_box.addRow(self.pf_color_label, self.form_box_child_1)
  1011. self.form_box.addRow(self.pf_alpha_label, self.form_box_child_2)
  1012. self.form_box.addRow(self.pl_color_label, self.form_box_child_3)
  1013. self.form_box.addRow(self.sf_color_label, self.form_box_child_4)
  1014. self.form_box.addRow(self.sf_alpha_label, self.form_box_child_5)
  1015. self.form_box.addRow(self.sl_color_label, self.form_box_child_6)
  1016. self.form_box.addRow(self.alt_sf_color_label, self.form_box_child_7)
  1017. self.form_box.addRow(self.alt_sf_alpha_label, self.form_box_child_8)
  1018. self.form_box.addRow(self.alt_sl_color_label, self.form_box_child_9)
  1019. self.form_box.addRow(self.draw_color_label, self.form_box_child_10)
  1020. self.form_box.addRow(self.sel_draw_color_label, self.form_box_child_11)
  1021. # Add the QFormLayout that holds the Application general defaults
  1022. # to the main layout of this TAB
  1023. self.layout.addLayout(self.form_box)
  1024. class GeneralAppPrefGroupUI(OptionsGroupUI):
  1025. def __init__(self, parent=None):
  1026. super(GeneralAppPrefGroupUI, self).__init__(self)
  1027. self.setTitle(str("App Preferences"))
  1028. # Create a form layout for the Application general settings
  1029. self.form_box = QtWidgets.QFormLayout()
  1030. # Units for FlatCAM
  1031. self.unitslabel = QtWidgets.QLabel('<b>Units:</b>')
  1032. self.unitslabel.setToolTip("Those are units in which FlatCAM works.")
  1033. self.units_radio = RadioSet([{'label': 'IN', 'value': 'IN'},
  1034. {'label': 'MM', 'value': 'MM'}])
  1035. # Languages for FlatCAM
  1036. self.languagelabel = QtWidgets.QLabel('<b>Languages:</b>')
  1037. self.languagelabel.setToolTip("Set the language used for FlatCAM texts.")
  1038. self.language_cb = FCComboBox()
  1039. self.languagespace = QtWidgets.QLabel('')
  1040. self.language_apply_btn = FCButton("Apply Language")
  1041. # Shell StartUp CB
  1042. self.shell_startup_label = QtWidgets.QLabel('Shell at StartUp:')
  1043. self.shell_startup_label.setToolTip(
  1044. "Check this box if you want the shell to\n"
  1045. "start automatically at startup."
  1046. )
  1047. self.shell_startup_cb = FCCheckBox(label='')
  1048. self.shell_startup_cb.setToolTip(
  1049. "Check this box if you want the shell to\n"
  1050. "start automatically at startup."
  1051. )
  1052. # Version Check CB
  1053. self.version_check_label = QtWidgets.QLabel('Version Check:')
  1054. self.version_check_label.setToolTip(
  1055. "Check this box if you want to check\n"
  1056. "for a new version automatically at startup."
  1057. )
  1058. self.version_check_cb = FCCheckBox(label='')
  1059. self.version_check_cb.setToolTip(
  1060. "Check this box if you want to check\n"
  1061. "for a new version automatically at startup."
  1062. )
  1063. # Send Stats CB
  1064. self.send_stats_label = QtWidgets.QLabel('Send Stats:')
  1065. self.send_stats_label.setToolTip(
  1066. "Check this box if you agree to send anonymous\n"
  1067. "stats automatically at startup, to help improve FlatCAM."
  1068. )
  1069. self.send_stats_cb= FCCheckBox(label='')
  1070. self.send_stats_cb.setToolTip(
  1071. "Check this box if you agree to send anonymous\n"
  1072. "stats automatically at startup, to help improve FlatCAM."
  1073. )
  1074. self.ois_version_check = OptionalInputSection(self.version_check_cb, [self.send_stats_cb])
  1075. # Select mouse pan button
  1076. self.panbuttonlabel = QtWidgets.QLabel('<b>Pan Button:</b>')
  1077. self.panbuttonlabel.setToolTip("Select the mouse button to use for panning.")
  1078. self.pan_button_radio = RadioSet([{'label': 'Middle But.', 'value': '3'},
  1079. {'label': 'Right But.', 'value': '2'}])
  1080. # Multiple Selection Modifier Key
  1081. self.mselectlabel = QtWidgets.QLabel('<b>Multiple Sel:</b>')
  1082. self.mselectlabel.setToolTip("Select the key used for multiple selection.")
  1083. self.mselect_radio = RadioSet([{'label': 'CTRL', 'value': 'Control'},
  1084. {'label': 'SHIFT', 'value': 'Shift'}])
  1085. # # Mouse panning with "Space" key, CB
  1086. # self.pan_with_space_label = QtWidgets.QLabel('Pan w/ Space:')
  1087. # self.pan_with_space_label.setToolTip(
  1088. # "Check this box if you want to pan when mouse is moved,\n"
  1089. # "and key 'Space' is pressed."
  1090. # )
  1091. # self.pan_with_space_cb = FCCheckBox(label='')
  1092. # self.pan_with_space_cb.setToolTip(
  1093. # "Check this box if you want to pan when mouse is moved,\n"
  1094. # "and key 'Space' is pressed."
  1095. # )
  1096. # Just to add empty rows
  1097. self.spacelabel = QtWidgets.QLabel('')
  1098. # Add (label - input field) pair to the QFormLayout
  1099. self.form_box.addRow(self.unitslabel, self.units_radio)
  1100. self.form_box.addRow(self.languagelabel, self.language_cb)
  1101. self.form_box.addRow(self.languagespace, self.language_apply_btn)
  1102. self.form_box.addRow(self.spacelabel, self.spacelabel)
  1103. self.form_box.addRow(self.shell_startup_label, self.shell_startup_cb)
  1104. self.form_box.addRow(self.version_check_label, self.version_check_cb)
  1105. self.form_box.addRow(self.send_stats_label, self.send_stats_cb)
  1106. self.form_box.addRow(self.panbuttonlabel, self.pan_button_radio)
  1107. self.form_box.addRow(self.mselectlabel, self.mselect_radio)
  1108. # self.form_box.addRow(self.pan_with_space_label, self.pan_with_space_cb)
  1109. self.form_box.addRow(self.spacelabel, self.spacelabel)
  1110. # Add the QFormLayout that holds the Application general defaults
  1111. # to the main layout of this TAB
  1112. self.layout.addLayout(self.form_box)
  1113. class GerberPrefGroupUI(OptionsGroupUI):
  1114. def __init__(self, parent=None):
  1115. # OptionsGroupUI.__init__(self, "Gerber Options", parent=parent)
  1116. super(GerberPrefGroupUI, self).__init__(self)
  1117. self.setTitle(str("Gerber Options"))
  1118. ## Plot options
  1119. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1120. self.layout.addWidget(self.plot_options_label)
  1121. grid0 = QtWidgets.QGridLayout()
  1122. self.layout.addLayout(grid0)
  1123. # Plot CB
  1124. self.plot_cb = FCCheckBox(label='Plot')
  1125. self.plot_options_label.setToolTip(
  1126. "Plot (show) this object."
  1127. )
  1128. grid0.addWidget(self.plot_cb, 0, 0)
  1129. # Solid CB
  1130. self.solid_cb = FCCheckBox(label='Solid')
  1131. self.solid_cb.setToolTip(
  1132. "Solid color polygons."
  1133. )
  1134. grid0.addWidget(self.solid_cb, 0, 1)
  1135. # Multicolored CB
  1136. self.multicolored_cb = FCCheckBox(label='M-Color')
  1137. self.multicolored_cb.setToolTip(
  1138. "Draw polygons in different colors."
  1139. )
  1140. grid0.addWidget(self.multicolored_cb, 0, 2)
  1141. # Number of circle steps for circular aperture linear approximation
  1142. self.circle_steps_label = QtWidgets.QLabel("Circle Steps:")
  1143. self.circle_steps_label.setToolTip(
  1144. "The number of circle steps for Gerber \n"
  1145. "circular aperture linear approximation."
  1146. )
  1147. grid0.addWidget(self.circle_steps_label, 1, 0)
  1148. self.circle_steps_entry = IntEntry()
  1149. grid0.addWidget(self.circle_steps_entry, 1, 1)
  1150. ## Isolation Routing
  1151. self.isolation_routing_label = QtWidgets.QLabel("<b>Isolation Routing:</b>")
  1152. self.isolation_routing_label.setToolTip(
  1153. "Create a Geometry object with\n"
  1154. "toolpaths to cut outside polygons."
  1155. )
  1156. self.layout.addWidget(self.isolation_routing_label)
  1157. # Cutting Tool Diameter
  1158. grid1 = QtWidgets.QGridLayout()
  1159. self.layout.addLayout(grid1)
  1160. tdlabel = QtWidgets.QLabel('Tool dia:')
  1161. tdlabel.setToolTip(
  1162. "Diameter of the cutting tool."
  1163. )
  1164. grid1.addWidget(tdlabel, 0, 0)
  1165. self.iso_tool_dia_entry = LengthEntry()
  1166. grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
  1167. # Nr of passes
  1168. passlabel = QtWidgets.QLabel('Width (# passes):')
  1169. passlabel.setToolTip(
  1170. "Width of the isolation gap in\n"
  1171. "number (integer) of tool widths."
  1172. )
  1173. grid1.addWidget(passlabel, 1, 0)
  1174. self.iso_width_entry = IntEntry()
  1175. grid1.addWidget(self.iso_width_entry, 1, 1)
  1176. # Pass overlap
  1177. overlabel = QtWidgets.QLabel('Pass overlap:')
  1178. overlabel.setToolTip(
  1179. "How much (fraction) of the tool width to overlap each tool pass.\n"
  1180. "Example:\n"
  1181. "A value here of 0.25 means an overlap of 25% from the tool diameter found above."
  1182. )
  1183. grid1.addWidget(overlabel, 2, 0)
  1184. self.iso_overlap_entry = FloatEntry()
  1185. grid1.addWidget(self.iso_overlap_entry, 2, 1)
  1186. milling_type_label = QtWidgets.QLabel('Milling Type:')
  1187. milling_type_label.setToolTip(
  1188. "Milling type:\n"
  1189. "- climb / best for precision milling and to reduce tool usage\n"
  1190. "- conventional / useful when there is no backlash compensation"
  1191. )
  1192. grid1.addWidget(milling_type_label, 3, 0)
  1193. self.milling_type_radio = RadioSet([{'label': 'Climb', 'value': 'cl'},
  1194. {'label': 'Conv.', 'value': 'cv'}])
  1195. grid1.addWidget(self.milling_type_radio, 3, 1)
  1196. # Combine passes
  1197. self.combine_passes_cb = FCCheckBox(label='Combine Passes')
  1198. self.combine_passes_cb.setToolTip(
  1199. "Combine all passes into one object"
  1200. )
  1201. grid1.addWidget(self.combine_passes_cb, 4, 0)
  1202. ## Clear non-copper regions
  1203. self.clearcopper_label = QtWidgets.QLabel("<b>Clear non-copper:</b>")
  1204. self.clearcopper_label.setToolTip(
  1205. "Create a Geometry object with\n"
  1206. "toolpaths to cut all non-copper regions."
  1207. )
  1208. self.layout.addWidget(self.clearcopper_label)
  1209. grid3 = QtWidgets.QGridLayout()
  1210. self.layout.addLayout(grid3)
  1211. # Margin
  1212. bmlabel = QtWidgets.QLabel('Boundary Margin:')
  1213. bmlabel.setToolTip(
  1214. "Specify the edge of the PCB\n"
  1215. "by drawing a box around all\n"
  1216. "objects with this minimum\n"
  1217. "distance."
  1218. )
  1219. grid3.addWidget(bmlabel, 0, 0)
  1220. self.noncopper_margin_entry = LengthEntry()
  1221. grid3.addWidget(self.noncopper_margin_entry, 0, 1)
  1222. # Rounded corners
  1223. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  1224. self.noncopper_rounded_cb.setToolTip(
  1225. "Creates a Geometry objects with polygons\n"
  1226. "covering the copper-free areas of the PCB."
  1227. )
  1228. grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  1229. ## Bounding box
  1230. self.boundingbox_label = QtWidgets.QLabel('<b>Bounding Box:</b>')
  1231. self.layout.addWidget(self.boundingbox_label)
  1232. grid4 = QtWidgets.QGridLayout()
  1233. self.layout.addLayout(grid4)
  1234. bbmargin = QtWidgets.QLabel('Boundary Margin:')
  1235. bbmargin.setToolTip(
  1236. "Distance of the edges of the box\n"
  1237. "to the nearest polygon."
  1238. )
  1239. grid4.addWidget(bbmargin, 0, 0)
  1240. self.bbmargin_entry = LengthEntry()
  1241. grid4.addWidget(self.bbmargin_entry, 0, 1)
  1242. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  1243. self.bbrounded_cb.setToolTip(
  1244. "If the bounding box is \n"
  1245. "to have rounded corners\n"
  1246. "their radius is equal to\n"
  1247. "the margin."
  1248. )
  1249. grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  1250. self.layout.addStretch()
  1251. class ExcellonGenPrefGroupUI(OptionsGroupUI):
  1252. def __init__(self, parent=None):
  1253. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  1254. super(ExcellonGenPrefGroupUI, self).__init__(self)
  1255. self.setTitle(str("Excellon General"))
  1256. # Plot options
  1257. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1258. self.layout.addWidget(self.plot_options_label)
  1259. grid1 = QtWidgets.QGridLayout()
  1260. self.layout.addLayout(grid1)
  1261. self.plot_cb = FCCheckBox(label='Plot')
  1262. self.plot_cb.setToolTip(
  1263. "Plot (show) this object."
  1264. )
  1265. grid1.addWidget(self.plot_cb, 0, 0)
  1266. self.solid_cb = FCCheckBox(label='Solid')
  1267. self.solid_cb.setToolTip(
  1268. "Plot as solid circles."
  1269. )
  1270. grid1.addWidget(self.solid_cb, 0, 1)
  1271. # Excellon format
  1272. self.excellon_format_label = QtWidgets.QLabel("<b>Excellon Format:</b>")
  1273. self.excellon_format_label.setToolTip(
  1274. "The NC drill files, usually named Excellon files\n"
  1275. "are files that can be found in different formats.\n"
  1276. "Here we set the format used when the provided\n"
  1277. "coordinates are not using period.\n"
  1278. "\n"
  1279. "Possible presets:\n"
  1280. "\n"
  1281. "PROTEUS 3:3 MM LZ\n"
  1282. "DipTrace 5:2 MM TZ\n"
  1283. "DipTrace 4:3 MM LZ\n"
  1284. "\n"
  1285. "EAGLE 3:3 MM TZ\n"
  1286. "EAGLE 4:3 MM TZ\n"
  1287. "EAGLE 2:5 INCH TZ\n"
  1288. "EAGLE 3:5 INCH TZ\n"
  1289. "\n"
  1290. "ALTIUM 2:4 INCH LZ\n"
  1291. "Sprint Layout 2:4 INCH LZ"
  1292. "\n"
  1293. "KiCAD 3:5 INCH TZ"
  1294. )
  1295. self.layout.addWidget(self.excellon_format_label)
  1296. hlay1 = QtWidgets.QHBoxLayout()
  1297. self.layout.addLayout(hlay1)
  1298. self.excellon_format_in_label = QtWidgets.QLabel("INCH:")
  1299. self.excellon_format_in_label.setAlignment(QtCore.Qt.AlignLeft)
  1300. self.excellon_format_in_label.setToolTip(
  1301. "Default values for INCH are 2:4")
  1302. hlay1.addWidget(self.excellon_format_in_label, QtCore.Qt.AlignLeft)
  1303. self.excellon_format_upper_in_entry = IntEntry()
  1304. self.excellon_format_upper_in_entry.setMaxLength(1)
  1305. self.excellon_format_upper_in_entry.setAlignment(QtCore.Qt.AlignRight)
  1306. self.excellon_format_upper_in_entry.setFixedWidth(30)
  1307. self.excellon_format_upper_in_entry.setToolTip(
  1308. "This numbers signify the number of digits in\n"
  1309. "the whole part of Excellon coordinates."
  1310. )
  1311. hlay1.addWidget(self.excellon_format_upper_in_entry, QtCore.Qt.AlignLeft)
  1312. excellon_separator_in_label= QtWidgets.QLabel(':')
  1313. excellon_separator_in_label.setFixedWidth(5)
  1314. hlay1.addWidget(excellon_separator_in_label, QtCore.Qt.AlignLeft)
  1315. self.excellon_format_lower_in_entry = IntEntry()
  1316. self.excellon_format_lower_in_entry.setMaxLength(1)
  1317. self.excellon_format_lower_in_entry.setAlignment(QtCore.Qt.AlignRight)
  1318. self.excellon_format_lower_in_entry.setFixedWidth(30)
  1319. self.excellon_format_lower_in_entry.setToolTip(
  1320. "This numbers signify the number of digits in\n"
  1321. "the decimal part of Excellon coordinates."
  1322. )
  1323. hlay1.addWidget(self.excellon_format_lower_in_entry, QtCore.Qt.AlignLeft)
  1324. hlay1.addStretch()
  1325. hlay2 = QtWidgets.QHBoxLayout()
  1326. self.layout.addLayout(hlay2)
  1327. self.excellon_format_mm_label = QtWidgets.QLabel("METRIC:")
  1328. self.excellon_format_mm_label.setAlignment(QtCore.Qt.AlignLeft)
  1329. self.excellon_format_mm_label.setToolTip(
  1330. "Default values for METRIC are 3:3")
  1331. hlay2.addWidget(self.excellon_format_mm_label, QtCore.Qt.AlignLeft)
  1332. self.excellon_format_upper_mm_entry = IntEntry()
  1333. self.excellon_format_upper_mm_entry.setMaxLength(1)
  1334. self.excellon_format_upper_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  1335. self.excellon_format_upper_mm_entry.setFixedWidth(30)
  1336. self.excellon_format_upper_mm_entry.setToolTip(
  1337. "This numbers signify the number of digits in\n"
  1338. "the whole part of Excellon coordinates."
  1339. )
  1340. hlay2.addWidget(self.excellon_format_upper_mm_entry, QtCore.Qt.AlignLeft)
  1341. excellon_separator_mm_label= QtWidgets.QLabel(':')
  1342. excellon_separator_mm_label.setFixedWidth(5)
  1343. hlay2.addWidget(excellon_separator_mm_label, QtCore.Qt.AlignLeft)
  1344. self.excellon_format_lower_mm_entry = IntEntry()
  1345. self.excellon_format_lower_mm_entry.setMaxLength(1)
  1346. self.excellon_format_lower_mm_entry.setAlignment(QtCore.Qt.AlignRight)
  1347. self.excellon_format_lower_mm_entry.setFixedWidth(30)
  1348. self.excellon_format_lower_mm_entry.setToolTip(
  1349. "This numbers signify the number of digits in\n"
  1350. "the decimal part of Excellon coordinates."
  1351. )
  1352. hlay2.addWidget(self.excellon_format_lower_mm_entry, QtCore.Qt.AlignLeft)
  1353. hlay2.addStretch()
  1354. hlay3 = QtWidgets.QHBoxLayout()
  1355. self.layout.addLayout(hlay3)
  1356. self.excellon_zeros_label = QtWidgets.QLabel('Default <b>Zeros</b>:')
  1357. self.excellon_zeros_label.setAlignment(QtCore.Qt.AlignLeft)
  1358. self.excellon_zeros_label.setToolTip(
  1359. "This sets the type of Excellon zeros.\n"
  1360. "If LZ then Leading Zeros are kept and\n"
  1361. "Trailing Zeros are removed.\n"
  1362. "If TZ is checked then Trailing Zeros are kept\n"
  1363. "and Leading Zeros are removed."
  1364. )
  1365. hlay3.addWidget(self.excellon_zeros_label)
  1366. self.excellon_zeros_radio = RadioSet([{'label': 'LZ', 'value': 'L'},
  1367. {'label': 'TZ', 'value': 'T'}])
  1368. self.excellon_zeros_radio.setToolTip(
  1369. "This sets the default type of Excellon zeros.\n"
  1370. "If it is not detected in the parsed file the value here\n"
  1371. "will be used."
  1372. "If LZ then Leading Zeros are kept and\n"
  1373. "Trailing Zeros are removed.\n"
  1374. "If TZ is checked then Trailing Zeros are kept\n"
  1375. "and Leading Zeros are removed."
  1376. )
  1377. hlay3.addStretch()
  1378. hlay3.addWidget(self.excellon_zeros_radio, QtCore.Qt.AlignRight)
  1379. hlay4 = QtWidgets.QHBoxLayout()
  1380. self.layout.addLayout(hlay4)
  1381. self.excellon_units_label = QtWidgets.QLabel('Default <b>Units</b>:')
  1382. self.excellon_units_label.setAlignment(QtCore.Qt.AlignLeft)
  1383. self.excellon_units_label.setToolTip(
  1384. "This sets the default units of Excellon files.\n"
  1385. "If it is not detected in the parsed file the value here\n"
  1386. "will be used."
  1387. "Some Excellon files don't have an header\n"
  1388. "therefore this parameter will be used.\n"
  1389. )
  1390. hlay4.addWidget(self.excellon_units_label)
  1391. self.excellon_units_radio = RadioSet([{'label': 'INCH', 'value': 'INCH'},
  1392. {'label': 'MM', 'value': 'METRIC'}])
  1393. self.excellon_units_radio.setToolTip(
  1394. "This sets the units of Excellon files.\n"
  1395. "Some Excellon files don't have an header\n"
  1396. "therefore this parameter will be used.\n"
  1397. )
  1398. hlay4.addStretch()
  1399. hlay4.addWidget(self.excellon_units_radio, QtCore.Qt.AlignRight)
  1400. hlay5 = QtWidgets.QVBoxLayout()
  1401. self.layout.addLayout(hlay5)
  1402. self.empty_label = QtWidgets.QLabel("")
  1403. hlay5.addWidget(self.empty_label)
  1404. hlay6 = QtWidgets.QVBoxLayout()
  1405. self.layout.addLayout(hlay6)
  1406. self.excellon_general_label = QtWidgets.QLabel("<b>Excellon Optimization:</b>")
  1407. hlay6.addWidget(self.excellon_general_label)
  1408. # Create a form layout for the Excellon general settings
  1409. form_box_excellon = QtWidgets.QFormLayout()
  1410. hlay6.addLayout(form_box_excellon)
  1411. self.excellon_optimization_label = QtWidgets.QLabel('Path Optimization: ')
  1412. self.excellon_optimization_label.setAlignment(QtCore.Qt.AlignLeft)
  1413. self.excellon_optimization_label.setToolTip(
  1414. "This sets the optimization type for the Excellon drill path.\n"
  1415. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  1416. "Guided Local Path is used. Default search time is 3sec.\n"
  1417. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  1418. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  1419. "\n"
  1420. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  1421. "Travelling Salesman algorithm for path optimization."
  1422. )
  1423. self.excellon_optimization_radio = RadioSet([{'label': 'MH', 'value': 'M'},
  1424. {'label': 'Basic', 'value': 'B'}])
  1425. self.excellon_optimization_radio.setToolTip(
  1426. "This sets the optimization type for the Excellon drill path.\n"
  1427. "If MH is checked then Google OR-Tools algorithm with MetaHeuristic\n"
  1428. "Guided Local Path is used. Default search time is 3sec.\n"
  1429. "Use set_sys excellon_search_time value Tcl Command to set other values.\n"
  1430. "If Basic is checked then Google OR-Tools Basic algorithm is used.\n"
  1431. "\n"
  1432. "If DISABLED, then FlatCAM works in 32bit mode and it uses \n"
  1433. "Travelling Salesman algorithm for path optimization."
  1434. )
  1435. form_box_excellon.addRow(self.excellon_optimization_label, self.excellon_optimization_radio)
  1436. current_platform = platform.architecture()[0]
  1437. if current_platform == '64bit':
  1438. self.excellon_optimization_label.setDisabled(False)
  1439. self.excellon_optimization_radio.setDisabled(False)
  1440. else:
  1441. self.excellon_optimization_label.setDisabled(True)
  1442. self.excellon_optimization_radio.setDisabled(True)
  1443. self.layout.addStretch()
  1444. class ExcellonOptPrefGroupUI(OptionsGroupUI):
  1445. def __init__(self, parent=None):
  1446. # OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  1447. super(ExcellonOptPrefGroupUI, self).__init__(self)
  1448. self.setTitle(str("Excellon Options"))
  1449. ## Create CNC Job
  1450. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job</b>')
  1451. self.cncjob_label.setToolTip(
  1452. "Create a CNC Job object\n"
  1453. "for this drill object."
  1454. )
  1455. self.layout.addWidget(self.cncjob_label)
  1456. grid2 = QtWidgets.QGridLayout()
  1457. self.layout.addLayout(grid2)
  1458. cutzlabel = QtWidgets.QLabel('Cut Z:')
  1459. cutzlabel.setToolTip(
  1460. "Drill depth (negative)\n"
  1461. "below the copper surface."
  1462. )
  1463. grid2.addWidget(cutzlabel, 0, 0)
  1464. self.cutz_entry = LengthEntry()
  1465. grid2.addWidget(self.cutz_entry, 0, 1)
  1466. travelzlabel = QtWidgets.QLabel('Travel Z:')
  1467. travelzlabel.setToolTip(
  1468. "Tool height when travelling\n"
  1469. "across the XY plane."
  1470. )
  1471. grid2.addWidget(travelzlabel, 1, 0)
  1472. self.travelz_entry = LengthEntry()
  1473. grid2.addWidget(self.travelz_entry, 1, 1)
  1474. # Tool change:
  1475. toolchlabel = QtWidgets.QLabel("Tool change:")
  1476. toolchlabel.setToolTip(
  1477. "Include tool-change sequence\n"
  1478. "in G-Code (Pause for tool change)."
  1479. )
  1480. self.toolchange_cb = FCCheckBox()
  1481. grid2.addWidget(toolchlabel, 2, 0)
  1482. grid2.addWidget(self.toolchange_cb, 2, 1)
  1483. toolchangezlabel = QtWidgets.QLabel('Toolchange Z:')
  1484. toolchangezlabel.setToolTip(
  1485. "Toolchange Z position."
  1486. )
  1487. grid2.addWidget(toolchangezlabel, 3, 0)
  1488. self.toolchangez_entry = LengthEntry()
  1489. grid2.addWidget(self.toolchangez_entry, 3, 1)
  1490. toolchange_xy_label = QtWidgets.QLabel('Toolchange X,Y:')
  1491. toolchange_xy_label.setToolTip(
  1492. "Toolchange X,Y position."
  1493. )
  1494. grid2.addWidget(toolchange_xy_label, 4, 0)
  1495. self.toolchangexy_entry = FCEntry()
  1496. grid2.addWidget(self.toolchangexy_entry, 4, 1)
  1497. startzlabel = QtWidgets.QLabel('Start move Z:')
  1498. startzlabel.setToolTip(
  1499. "Height of the tool just after start.\n"
  1500. "Delete the value if you don't need this feature."
  1501. )
  1502. grid2.addWidget(startzlabel, 5, 0)
  1503. self.estartz_entry = FloatEntry()
  1504. grid2.addWidget(self.estartz_entry, 5, 1)
  1505. endzlabel = QtWidgets.QLabel('End move Z:')
  1506. endzlabel.setToolTip(
  1507. "Height of the tool after\n"
  1508. "the last move at the end of the job."
  1509. )
  1510. grid2.addWidget(endzlabel, 6, 0)
  1511. self.eendz_entry = LengthEntry()
  1512. grid2.addWidget(self.eendz_entry, 6, 1)
  1513. frlabel = QtWidgets.QLabel('Feedrate:')
  1514. frlabel.setToolTip(
  1515. "Tool speed while drilling\n"
  1516. "(in units per minute)."
  1517. )
  1518. grid2.addWidget(frlabel, 7, 0)
  1519. self.feedrate_entry = LengthEntry()
  1520. grid2.addWidget(self.feedrate_entry, 7, 1)
  1521. fr_rapid_label = QtWidgets.QLabel('Feedrate Rapids:')
  1522. fr_rapid_label.setToolTip(
  1523. "Tool speed while drilling\n"
  1524. "with rapid move\n"
  1525. "(in units per minute)."
  1526. )
  1527. grid2.addWidget(fr_rapid_label, 8, 0)
  1528. self.feedrate_rapid_entry = LengthEntry()
  1529. grid2.addWidget(self.feedrate_rapid_entry, 8, 1)
  1530. # Spindle speed
  1531. spdlabel = QtWidgets.QLabel('Spindle speed:')
  1532. spdlabel.setToolTip(
  1533. "Speed of the spindle\n"
  1534. "in RPM (optional)"
  1535. )
  1536. grid2.addWidget(spdlabel, 9, 0)
  1537. self.spindlespeed_entry = IntEntry(allow_empty=True)
  1538. grid2.addWidget(self.spindlespeed_entry, 9, 1)
  1539. # Dwell
  1540. dwelllabel = QtWidgets.QLabel('Dwell:')
  1541. dwelllabel.setToolTip(
  1542. "Pause to allow the spindle to reach its\n"
  1543. "speed before cutting."
  1544. )
  1545. dwelltime = QtWidgets.QLabel('Duration [m-sec.]:')
  1546. dwelltime.setToolTip(
  1547. "Number of milliseconds for spindle to dwell."
  1548. )
  1549. self.dwell_cb = FCCheckBox()
  1550. self.dwelltime_entry = FCEntry()
  1551. grid2.addWidget(dwelllabel, 10, 0)
  1552. grid2.addWidget(self.dwell_cb, 10, 1)
  1553. grid2.addWidget(dwelltime, 11, 0)
  1554. grid2.addWidget(self.dwelltime_entry, 11, 1)
  1555. self.ois_dwell_exc = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  1556. # postprocessor selection
  1557. pp_excellon_label = QtWidgets.QLabel("Postprocessor:")
  1558. pp_excellon_label.setToolTip(
  1559. "The postprocessor file that dictates\n"
  1560. "gcode output."
  1561. )
  1562. grid2.addWidget(pp_excellon_label, 12, 0)
  1563. self.pp_excellon_name_cb = FCComboBox()
  1564. self.pp_excellon_name_cb.setFocusPolicy(Qt.StrongFocus)
  1565. grid2.addWidget(self.pp_excellon_name_cb, 12, 1)
  1566. #### Choose what to use for Gcode creation: Drills, Slots or Both
  1567. excellon_gcode_type_label = QtWidgets.QLabel('<b>Gcode: </b>')
  1568. excellon_gcode_type_label.setToolTip(
  1569. "Choose what to use for GCode generation:\n"
  1570. "'Drills', 'Slots' or 'Both'.\n"
  1571. "When choosing 'Slots' or 'Both', slots will be\n"
  1572. "converted to drills."
  1573. )
  1574. self.excellon_gcode_type_radio = RadioSet([{'label': 'Drills', 'value': 'drills'},
  1575. {'label': 'Slots', 'value': 'slots'},
  1576. {'label': 'Both', 'value': 'both'}])
  1577. grid2.addWidget(excellon_gcode_type_label, 13, 0)
  1578. grid2.addWidget(self.excellon_gcode_type_radio, 13, 1)
  1579. # until I decide to implement this feature those remain disabled
  1580. excellon_gcode_type_label.setDisabled(True)
  1581. self.excellon_gcode_type_radio.setDisabled(True)
  1582. #### Milling Holes ####
  1583. self.mill_hole_label = QtWidgets.QLabel('<b>Mill Holes</b>')
  1584. self.mill_hole_label.setToolTip(
  1585. "Create Geometry for milling holes."
  1586. )
  1587. self.layout.addWidget(self.mill_hole_label)
  1588. grid3 = QtWidgets.QGridLayout()
  1589. self.layout.addLayout(grid3)
  1590. tdlabel = QtWidgets.QLabel('Drill Tool dia:')
  1591. tdlabel.setToolTip(
  1592. "Diameter of the cutting tool."
  1593. )
  1594. grid3.addWidget(tdlabel, 0, 0)
  1595. self.tooldia_entry = LengthEntry()
  1596. grid3.addWidget(self.tooldia_entry, 0, 1)
  1597. stdlabel = QtWidgets.QLabel('Slot Tool dia:')
  1598. stdlabel.setToolTip(
  1599. "Diameter of the cutting tool\n"
  1600. "when milling slots."
  1601. )
  1602. grid3.addWidget(stdlabel, 1, 0)
  1603. self.slot_tooldia_entry = LengthEntry()
  1604. grid3.addWidget(self.slot_tooldia_entry, 1, 1)
  1605. grid4 = QtWidgets.QGridLayout()
  1606. self.layout.addLayout(grid4)
  1607. # Adding the Excellon Format Defaults Button
  1608. self.excellon_defaults_button = QtWidgets.QPushButton()
  1609. self.excellon_defaults_button.setText(str("Defaults"))
  1610. self.excellon_defaults_button.setFixedWidth(80)
  1611. grid4.addWidget(self.excellon_defaults_button, 0, 0, QtCore.Qt.AlignRight)
  1612. self.layout.addStretch()
  1613. class GeometryPrefGroupUI(OptionsGroupUI):
  1614. def __init__(self, parent=None):
  1615. # OptionsGroupUI.__init__(self, "Geometry Options", parent=parent)
  1616. super(GeometryPrefGroupUI, self).__init__(self)
  1617. self.setTitle(str("Geometry Options"))
  1618. ## Plot options
  1619. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1620. self.layout.addWidget(self.plot_options_label)
  1621. # Plot CB
  1622. self.plot_cb = FCCheckBox(label='Plot')
  1623. self.plot_cb.setToolTip(
  1624. "Plot (show) this object."
  1625. )
  1626. self.layout.addWidget(self.plot_cb)
  1627. grid0 = QtWidgets.QGridLayout()
  1628. self.layout.addLayout(grid0)
  1629. # Number of circle steps for circular aperture linear approximation
  1630. self.circle_steps_label = QtWidgets.QLabel("Circle Steps:")
  1631. self.circle_steps_label.setToolTip(
  1632. "The number of circle steps for <b>Geometry</b> \n"
  1633. "circle and arc shapes linear approximation."
  1634. )
  1635. grid0.addWidget(self.circle_steps_label, 1, 0)
  1636. self.circle_steps_entry = IntEntry()
  1637. grid0.addWidget(self.circle_steps_entry, 1, 1)
  1638. # Tools
  1639. self.tools_label = QtWidgets.QLabel("<b>Tools</b>")
  1640. self.layout.addWidget(self.tools_label)
  1641. grid1 = QtWidgets.QGridLayout()
  1642. self.layout.addLayout(grid1)
  1643. # Tooldia
  1644. tdlabel = QtWidgets.QLabel('Tool dia: ')
  1645. tdlabel.setToolTip(
  1646. "The diameter of the cutting\n"
  1647. "tool (just for display)."
  1648. )
  1649. grid1.addWidget(tdlabel, 0, 0)
  1650. self.cnctooldia_entry = LengthEntry()
  1651. grid1.addWidget(self.cnctooldia_entry, 0, 1)
  1652. # ------------------------------
  1653. ## Create CNC Job
  1654. # ------------------------------
  1655. self.cncjob_label = QtWidgets.QLabel('<b>Create CNC Job:</b>')
  1656. self.cncjob_label.setToolTip(
  1657. "Create a CNC Job object\n"
  1658. "tracing the contours of this\n"
  1659. "Geometry object."
  1660. )
  1661. self.layout.addWidget(self.cncjob_label)
  1662. grid2 = QtWidgets.QGridLayout()
  1663. self.layout.addLayout(grid2)
  1664. # Cut Z
  1665. cutzlabel = QtWidgets.QLabel('Cut Z:')
  1666. cutzlabel.setToolTip(
  1667. "Cutting depth (negative)\n"
  1668. "below the copper surface."
  1669. )
  1670. grid2.addWidget(cutzlabel, 0, 0)
  1671. self.cutz_entry = LengthEntry()
  1672. grid2.addWidget(self.cutz_entry, 0, 1)
  1673. # Multidepth CheckBox
  1674. self.multidepth_cb = FCCheckBox(label='Multidepth')
  1675. self.multidepth_cb.setToolTip(
  1676. "Multidepth usage: True or False."
  1677. )
  1678. grid2.addWidget(self.multidepth_cb, 1, 0)
  1679. # Depth/pass
  1680. dplabel = QtWidgets.QLabel('Depth/Pass:')
  1681. dplabel.setToolTip(
  1682. "The depth to cut on each pass,\n"
  1683. "when multidepth is enabled.\n"
  1684. "It has positive value although\n"
  1685. "it is a fraction from the depth\n"
  1686. "which has negative value."
  1687. )
  1688. grid2.addWidget(dplabel, 2, 0)
  1689. self.depthperpass_entry = LengthEntry()
  1690. grid2.addWidget(self.depthperpass_entry, 2, 1)
  1691. self.ois_multidepth = OptionalInputSection(self.multidepth_cb, [self.depthperpass_entry])
  1692. # Travel Z
  1693. travelzlabel = QtWidgets.QLabel('Travel Z:')
  1694. travelzlabel.setToolTip(
  1695. "Height of the tool when\n"
  1696. "moving without cutting."
  1697. )
  1698. grid2.addWidget(travelzlabel, 3, 0)
  1699. self.travelz_entry = LengthEntry()
  1700. grid2.addWidget(self.travelz_entry, 3, 1)
  1701. # Tool change:
  1702. toolchlabel = QtWidgets.QLabel("Tool change:")
  1703. toolchlabel.setToolTip(
  1704. "Include tool-change sequence\n"
  1705. "in G-Code (Pause for tool change)."
  1706. )
  1707. self.toolchange_cb = FCCheckBox()
  1708. grid2.addWidget(toolchlabel, 4, 0)
  1709. grid2.addWidget(self.toolchange_cb, 4, 1)
  1710. # Toolchange Z
  1711. toolchangezlabel = QtWidgets.QLabel('Toolchange Z:')
  1712. toolchangezlabel.setToolTip(
  1713. "Toolchange Z position."
  1714. )
  1715. grid2.addWidget(toolchangezlabel, 5, 0)
  1716. self.toolchangez_entry = LengthEntry()
  1717. grid2.addWidget(self.toolchangez_entry, 5, 1)
  1718. # Toolchange X,Y
  1719. toolchange_xy_label = QtWidgets.QLabel('Toolchange X,Y:')
  1720. toolchange_xy_label.setToolTip(
  1721. "Toolchange X,Y position."
  1722. )
  1723. grid2.addWidget(toolchange_xy_label, 6, 0)
  1724. self.toolchangexy_entry = FCEntry()
  1725. grid2.addWidget(self.toolchangexy_entry, 6, 1)
  1726. # Start move Z
  1727. startzlabel = QtWidgets.QLabel('Start move Z:')
  1728. startzlabel.setToolTip(
  1729. "Height of the tool just after starting the work.\n"
  1730. "Delete the value if you don't need this feature."
  1731. )
  1732. grid2.addWidget(startzlabel, 7, 0)
  1733. self.gstartz_entry = FloatEntry()
  1734. grid2.addWidget(self.gstartz_entry, 7, 1)
  1735. # End move Z
  1736. endzlabel = QtWidgets.QLabel('End move Z:')
  1737. endzlabel.setToolTip(
  1738. "Height of the tool after\n"
  1739. "the last move at the end of the job."
  1740. )
  1741. grid2.addWidget(endzlabel, 8, 0)
  1742. self.gendz_entry = LengthEntry()
  1743. grid2.addWidget(self.gendz_entry, 8, 1)
  1744. # Feedrate X-Y
  1745. frlabel = QtWidgets.QLabel('Feed Rate X-Y:')
  1746. frlabel.setToolTip(
  1747. "Cutting speed in the XY\n"
  1748. "plane in units per minute"
  1749. )
  1750. grid2.addWidget(frlabel, 9, 0)
  1751. self.cncfeedrate_entry = LengthEntry()
  1752. grid2.addWidget(self.cncfeedrate_entry, 9, 1)
  1753. # Feedrate Z (Plunge)
  1754. frz_label = QtWidgets.QLabel('Feed Rate Z:')
  1755. frz_label.setToolTip(
  1756. "Cutting speed in the XY\n"
  1757. "plane in units per minute.\n"
  1758. "It is called also Plunge."
  1759. )
  1760. grid2.addWidget(frz_label, 10, 0)
  1761. self.cncplunge_entry = LengthEntry()
  1762. grid2.addWidget(self.cncplunge_entry, 10, 1)
  1763. # Feedrate rapids
  1764. fr_rapid_label = QtWidgets.QLabel('Feed Rate Rapids:')
  1765. fr_rapid_label.setToolTip(
  1766. "Cutting speed in the XY\n"
  1767. "plane in units per minute"
  1768. )
  1769. grid2.addWidget(fr_rapid_label, 11, 0)
  1770. self.cncfeedrate_rapid_entry = LengthEntry()
  1771. grid2.addWidget(self.cncfeedrate_rapid_entry, 11, 1)
  1772. # End move extra cut
  1773. self.extracut_cb = FCCheckBox(label='Cut over 1st pt.')
  1774. self.extracut_cb.setToolTip(
  1775. "In order to remove possible\n"
  1776. "copper leftovers where first cut\n"
  1777. "meet with last cut, we generate an\n"
  1778. "extended cut over the first cut section."
  1779. )
  1780. grid2.addWidget(self.extracut_cb, 12, 0)
  1781. # Spindle Speed
  1782. spdlabel = QtWidgets.QLabel('Spindle speed:')
  1783. spdlabel.setToolTip(
  1784. "Speed of the spindle\n"
  1785. "in RPM (optional)"
  1786. )
  1787. grid2.addWidget(spdlabel, 13, 0)
  1788. self.cncspindlespeed_entry = IntEntry(allow_empty=True)
  1789. grid2.addWidget(self.cncspindlespeed_entry, 13, 1)
  1790. # Dwell
  1791. self.dwell_cb = FCCheckBox(label='Dwell:')
  1792. self.dwell_cb.setToolTip(
  1793. "Pause to allow the spindle to reach its\n"
  1794. "speed before cutting."
  1795. )
  1796. dwelltime = QtWidgets.QLabel('Duration [m-sec.]:')
  1797. dwelltime.setToolTip(
  1798. "Number of milliseconds for spindle to dwell."
  1799. )
  1800. self.dwelltime_entry = FCEntry()
  1801. grid2.addWidget(self.dwell_cb, 14, 0)
  1802. grid2.addWidget(dwelltime, 15, 0)
  1803. grid2.addWidget(self.dwelltime_entry, 15, 1)
  1804. self.ois_dwell = OptionalInputSection(self.dwell_cb, [self.dwelltime_entry])
  1805. # postprocessor selection
  1806. pp_label = QtWidgets.QLabel("Postprocessor:")
  1807. pp_label.setToolTip(
  1808. "The postprocessor file that dictates\n"
  1809. "Machine Code output."
  1810. )
  1811. grid2.addWidget(pp_label, 16, 0)
  1812. self.pp_geometry_name_cb = FCComboBox()
  1813. self.pp_geometry_name_cb.setFocusPolicy(Qt.StrongFocus)
  1814. grid2.addWidget(self.pp_geometry_name_cb, 16, 1)
  1815. # Size of trace segment on X axis
  1816. segx_label = QtWidgets.QLabel("Seg. X size:")
  1817. segx_label.setToolTip(
  1818. "The size of the trace segment on the X axis.\n"
  1819. "Useful for auto-leveling.\n"
  1820. "A value of 0 means no segmentation on the X axis."
  1821. )
  1822. grid2.addWidget(segx_label, 17, 0)
  1823. self.segx_entry = FCEntry()
  1824. grid2.addWidget(self.segx_entry, 17, 1)
  1825. # Size of trace segment on Y axis
  1826. segy_label = QtWidgets.QLabel("Seg. Y size:")
  1827. segy_label.setToolTip(
  1828. "The size of the trace segment on the Y axis.\n"
  1829. "Useful for auto-leveling.\n"
  1830. "A value of 0 means no segmentation on the Y axis."
  1831. )
  1832. grid2.addWidget(segy_label, 18, 0)
  1833. self.segy_entry = FCEntry()
  1834. grid2.addWidget(self.segy_entry, 18, 1)
  1835. # ------------------------------
  1836. ## Paint area
  1837. # ------------------------------
  1838. self.paint_label = QtWidgets.QLabel('<b>Paint Area:</b>')
  1839. self.paint_label.setToolTip(
  1840. "Creates tool paths to cover the\n"
  1841. "whole area of a polygon (remove\n"
  1842. "all copper). You will be asked\n"
  1843. "to click on the desired polygon."
  1844. )
  1845. self.layout.addWidget(self.paint_label)
  1846. grid4 = QtWidgets.QGridLayout()
  1847. self.layout.addLayout(grid4)
  1848. # Tool dia
  1849. ptdlabel = QtWidgets.QLabel('Tool dia:')
  1850. ptdlabel.setToolTip(
  1851. "Diameter of the tool to\n"
  1852. "be used in the operation."
  1853. )
  1854. grid4.addWidget(ptdlabel, 0, 0)
  1855. self.painttooldia_entry = LengthEntry()
  1856. grid4.addWidget(self.painttooldia_entry, 0, 1)
  1857. # Overlap
  1858. ovlabel = QtWidgets.QLabel('Overlap:')
  1859. ovlabel.setToolTip(
  1860. "How much (fraction) of the tool\n"
  1861. "width to overlap each tool pass."
  1862. )
  1863. grid4.addWidget(ovlabel, 1, 0)
  1864. self.paintoverlap_entry = LengthEntry()
  1865. grid4.addWidget(self.paintoverlap_entry, 1, 1)
  1866. # Margin
  1867. marginlabel = QtWidgets.QLabel('Margin:')
  1868. marginlabel.setToolTip(
  1869. "Distance by which to avoid\n"
  1870. "the edges of the polygon to\n"
  1871. "be painted."
  1872. )
  1873. grid4.addWidget(marginlabel, 2, 0)
  1874. self.paintmargin_entry = LengthEntry()
  1875. grid4.addWidget(self.paintmargin_entry, 2, 1)
  1876. # Method
  1877. methodlabel = QtWidgets.QLabel('Method:')
  1878. methodlabel.setToolTip(
  1879. "Algorithm to paint the polygon:<BR>"
  1880. "<B>Standard</B>: Fixed step inwards.<BR>"
  1881. "<B>Seed-based</B>: Outwards from seed."
  1882. )
  1883. grid4.addWidget(methodlabel, 3, 0)
  1884. self.paintmethod_combo = RadioSet([
  1885. {"label": "Standard", "value": "standard"},
  1886. {"label": "Seed-based", "value": "seed"},
  1887. {"label": "Straight lines", "value": "lines"}
  1888. ], orientation='vertical', stretch=False)
  1889. grid4.addWidget(self.paintmethod_combo, 3, 1)
  1890. # Connect lines
  1891. pathconnectlabel = QtWidgets.QLabel("Connect:")
  1892. pathconnectlabel.setToolTip(
  1893. "Draw lines between resulting\n"
  1894. "segments to minimize tool lifts."
  1895. )
  1896. grid4.addWidget(pathconnectlabel, 4, 0)
  1897. self.pathconnect_cb = FCCheckBox()
  1898. grid4.addWidget(self.pathconnect_cb, 4, 1)
  1899. # Paint contour
  1900. contourlabel = QtWidgets.QLabel("Contour:")
  1901. contourlabel.setToolTip(
  1902. "Cut around the perimeter of the polygon\n"
  1903. "to trim rough edges."
  1904. )
  1905. grid4.addWidget(contourlabel, 5, 0)
  1906. self.contour_cb = FCCheckBox()
  1907. grid4.addWidget(self.contour_cb, 5, 1)
  1908. # Polygon selection
  1909. selectlabel = QtWidgets.QLabel('Selection:')
  1910. selectlabel.setToolTip(
  1911. "How to select the polygons to paint."
  1912. )
  1913. grid4.addWidget(selectlabel, 6, 0)
  1914. self.selectmethod_combo = RadioSet([
  1915. {"label": "Single", "value": "single"},
  1916. {"label": "All", "value": "all"},
  1917. # {"label": "Rectangle", "value": "rectangle"}
  1918. ])
  1919. grid4.addWidget(self.selectmethod_combo, 6, 1)
  1920. self.layout.addStretch()
  1921. class CNCJobPrefGroupUI(OptionsGroupUI):
  1922. def __init__(self, parent=None):
  1923. # OptionsGroupUI.__init__(self, "CNC Job Options", parent=None)
  1924. super(CNCJobPrefGroupUI, self).__init__(self)
  1925. self.setTitle(str("CNC Job Options"))
  1926. ## Plot options
  1927. self.plot_options_label = QtWidgets.QLabel("<b>Plot Options:</b>")
  1928. self.layout.addWidget(self.plot_options_label)
  1929. grid0 = QtWidgets.QGridLayout()
  1930. self.layout.addLayout(grid0)
  1931. # Plot CB
  1932. # self.plot_cb = QtWidgets.QCheckBox('Plot')
  1933. self.plot_cb = FCCheckBox('Plot')
  1934. self.plot_cb.setToolTip(
  1935. "Plot (show) this object."
  1936. )
  1937. grid0.addWidget(self.plot_cb, 0, 0)
  1938. # Number of circle steps for circular aperture linear approximation
  1939. self.steps_per_circle_label = QtWidgets.QLabel("Circle Steps:")
  1940. self.steps_per_circle_label.setToolTip(
  1941. "The number of circle steps for <b>GCode</b> \n"
  1942. "circle and arc shapes linear approximation."
  1943. )
  1944. grid0.addWidget(self.steps_per_circle_label, 1, 0)
  1945. self.steps_per_circle_entry = IntEntry()
  1946. grid0.addWidget(self.steps_per_circle_entry, 1, 1)
  1947. # Tool dia for plot
  1948. tdlabel = QtWidgets.QLabel('Tool dia:')
  1949. tdlabel.setToolTip(
  1950. "Diameter of the tool to be\n"
  1951. "rendered in the plot."
  1952. )
  1953. grid0.addWidget(tdlabel, 2, 0)
  1954. self.tooldia_entry = LengthEntry()
  1955. grid0.addWidget(self.tooldia_entry, 2, 1)
  1956. # Number of decimals to use in GCODE coordinates
  1957. cdeclabel = QtWidgets.QLabel('Coords decimals:')
  1958. cdeclabel.setToolTip(
  1959. "The number of decimals to be used for \n"
  1960. "the X, Y, Z coordinates in CNC code (GCODE, etc.)"
  1961. )
  1962. grid0.addWidget(cdeclabel, 3, 0)
  1963. self.coords_dec_entry = IntEntry()
  1964. grid0.addWidget(self.coords_dec_entry, 3, 1)
  1965. # Number of decimals to use in GCODE feedrate
  1966. frdeclabel = QtWidgets.QLabel('Feedrate decimals:')
  1967. frdeclabel.setToolTip(
  1968. "The number of decimals to be used for \n"
  1969. "the feedrate in CNC code (GCODE, etc.)"
  1970. )
  1971. grid0.addWidget(frdeclabel, 4, 0)
  1972. self.fr_dec_entry = IntEntry()
  1973. grid0.addWidget(self.fr_dec_entry, 4, 1)
  1974. ## Export G-Code
  1975. self.export_gcode_label = QtWidgets.QLabel("<b>Export G-Code:</b>")
  1976. self.export_gcode_label.setToolTip(
  1977. "Export and save G-Code to\n"
  1978. "make this object to a file."
  1979. )
  1980. self.layout.addWidget(self.export_gcode_label)
  1981. # Prepend to G-Code
  1982. prependlabel = QtWidgets.QLabel('Prepend to G-Code:')
  1983. prependlabel.setToolTip(
  1984. "Type here any G-Code commands you would\n"
  1985. "like to add at the beginning of the G-Code file."
  1986. )
  1987. self.layout.addWidget(prependlabel)
  1988. self.prepend_text = FCTextArea()
  1989. self.layout.addWidget(self.prepend_text)
  1990. # Append text to G-Code
  1991. appendlabel = QtWidgets.QLabel('Append to G-Code:')
  1992. appendlabel.setToolTip(
  1993. "Type here any G-Code commands you would\n"
  1994. "like to append to the generated file.\n"
  1995. "I.e.: M2 (End of program)"
  1996. )
  1997. self.layout.addWidget(appendlabel)
  1998. self.append_text = FCTextArea()
  1999. self.layout.addWidget(self.append_text)
  2000. grid0 = QtWidgets.QGridLayout()
  2001. self.layout.addLayout(grid0)
  2002. class ToolsNCCPrefGroupUI(OptionsGroupUI):
  2003. def __init__(self, parent=None):
  2004. # OptionsGroupUI.__init__(self, "NCC Tool Options", parent=parent)
  2005. super(ToolsNCCPrefGroupUI, self).__init__(self)
  2006. self.setTitle(str("NCC Tool Options"))
  2007. ## Clear non-copper regions
  2008. self.clearcopper_label = QtWidgets.QLabel("<b>Clear non-copper:</b>")
  2009. self.clearcopper_label.setToolTip(
  2010. "Create a Geometry object with\n"
  2011. "toolpaths to cut all non-copper regions."
  2012. )
  2013. self.layout.addWidget(self.clearcopper_label)
  2014. grid0 = QtWidgets.QGridLayout()
  2015. self.layout.addLayout(grid0)
  2016. ncctdlabel = QtWidgets.QLabel('Tools dia:')
  2017. ncctdlabel.setToolTip(
  2018. "Diameters of the cutting tools, separated by ','"
  2019. )
  2020. grid0.addWidget(ncctdlabel, 0, 0)
  2021. self.ncc_tool_dia_entry = FCEntry()
  2022. grid0.addWidget(self.ncc_tool_dia_entry, 0, 1)
  2023. nccoverlabel = QtWidgets.QLabel('Overlap:')
  2024. nccoverlabel.setToolTip(
  2025. "How much (fraction) of the tool width to overlap each tool pass.\n"
  2026. "Example:\n"
  2027. "A value here of 0.25 means 25% from the tool diameter found above.\n\n"
  2028. "Adjust the value starting with lower values\n"
  2029. "and increasing it if areas that should be cleared are still \n"
  2030. "not cleared.\n"
  2031. "Lower values = faster processing, faster execution on PCB.\n"
  2032. "Higher values = slow processing and slow execution on CNC\n"
  2033. "due of too many paths."
  2034. )
  2035. grid0.addWidget(nccoverlabel, 1, 0)
  2036. self.ncc_overlap_entry = FloatEntry()
  2037. grid0.addWidget(self.ncc_overlap_entry, 1, 1)
  2038. nccmarginlabel = QtWidgets.QLabel('Margin:')
  2039. nccmarginlabel.setToolTip(
  2040. "Bounding box margin."
  2041. )
  2042. grid0.addWidget(nccmarginlabel, 2, 0)
  2043. self.ncc_margin_entry = FloatEntry()
  2044. grid0.addWidget(self.ncc_margin_entry, 2, 1)
  2045. # Method
  2046. methodlabel = QtWidgets.QLabel('Method:')
  2047. methodlabel.setToolTip(
  2048. "Algorithm for non-copper clearing:<BR>"
  2049. "<B>Standard</B>: Fixed step inwards.<BR>"
  2050. "<B>Seed-based</B>: Outwards from seed.<BR>"
  2051. "<B>Line-based</B>: Parallel lines."
  2052. )
  2053. grid0.addWidget(methodlabel, 3, 0)
  2054. self.ncc_method_radio = RadioSet([
  2055. {"label": "Standard", "value": "standard"},
  2056. {"label": "Seed-based", "value": "seed"},
  2057. {"label": "Straight lines", "value": "lines"}
  2058. ], orientation='vertical', stretch=False)
  2059. grid0.addWidget(self.ncc_method_radio, 3, 1)
  2060. # Connect lines
  2061. pathconnectlabel = QtWidgets.QLabel("Connect:")
  2062. pathconnectlabel.setToolTip(
  2063. "Draw lines between resulting\n"
  2064. "segments to minimize tool lifts."
  2065. )
  2066. grid0.addWidget(pathconnectlabel, 4, 0)
  2067. self.ncc_connect_cb = FCCheckBox()
  2068. grid0.addWidget(self.ncc_connect_cb, 4, 1)
  2069. contourlabel = QtWidgets.QLabel("Contour:")
  2070. contourlabel.setToolTip(
  2071. "Cut around the perimeter of the polygon\n"
  2072. "to trim rough edges."
  2073. )
  2074. grid0.addWidget(contourlabel, 5, 0)
  2075. self.ncc_contour_cb = FCCheckBox()
  2076. grid0.addWidget(self.ncc_contour_cb, 5, 1)
  2077. restlabel = QtWidgets.QLabel("Rest M.:")
  2078. restlabel.setToolTip(
  2079. "If checked, use 'rest machining'.\n"
  2080. "Basically it will clear copper outside PCB features,\n"
  2081. "using the biggest tool and continue with the next tools,\n"
  2082. "from bigger to smaller, to clear areas of copper that\n"
  2083. "could not be cleared by previous tool.\n"
  2084. "If not checked, use the standard algorithm."
  2085. )
  2086. grid0.addWidget(restlabel, 6, 0)
  2087. self.ncc_rest_cb = FCCheckBox()
  2088. grid0.addWidget(self.ncc_rest_cb, 6, 1)
  2089. self.layout.addStretch()
  2090. class ToolsCutoutPrefGroupUI(OptionsGroupUI):
  2091. def __init__(self, parent=None):
  2092. # OptionsGroupUI.__init__(self, "Cutout Tool Options", parent=parent)
  2093. super(ToolsCutoutPrefGroupUI, self).__init__(self)
  2094. self.setTitle(str("Cutout Tool Options"))
  2095. ## Board cuttout
  2096. self.board_cutout_label = QtWidgets.QLabel("<b>Board cutout:</b>")
  2097. self.board_cutout_label.setToolTip(
  2098. "Create toolpaths to cut around\n"
  2099. "the PCB and separate it from\n"
  2100. "the original board."
  2101. )
  2102. self.layout.addWidget(self.board_cutout_label)
  2103. grid0 = QtWidgets.QGridLayout()
  2104. self.layout.addLayout(grid0)
  2105. tdclabel = QtWidgets.QLabel('Tool dia:')
  2106. tdclabel.setToolTip(
  2107. "Diameter of the cutting tool."
  2108. )
  2109. grid0.addWidget(tdclabel, 0, 0)
  2110. self.cutout_tooldia_entry = LengthEntry()
  2111. grid0.addWidget(self.cutout_tooldia_entry, 0, 1)
  2112. marginlabel = QtWidgets.QLabel('Margin:')
  2113. marginlabel.setToolTip(
  2114. "Distance from objects at which\n"
  2115. "to draw the cutout."
  2116. )
  2117. grid0.addWidget(marginlabel, 1, 0)
  2118. self.cutout_margin_entry = LengthEntry()
  2119. grid0.addWidget(self.cutout_margin_entry, 1, 1)
  2120. gaplabel = QtWidgets.QLabel('Gap size:')
  2121. gaplabel.setToolTip(
  2122. "Size of the gaps in the toolpath\n"
  2123. "that will remain to hold the\n"
  2124. "board in place."
  2125. )
  2126. grid0.addWidget(gaplabel, 2, 0)
  2127. self.cutout_gap_entry = LengthEntry()
  2128. grid0.addWidget(self.cutout_gap_entry, 2, 1)
  2129. gapslabel = QtWidgets.QLabel('Gaps:')
  2130. gapslabel.setToolTip(
  2131. "Where to place the gaps, Top/Bottom\n"
  2132. "Left/Rigt, or on all 4 sides."
  2133. )
  2134. grid0.addWidget(gapslabel, 3, 0)
  2135. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  2136. {'label': '2 (L/R)', 'value': 'lr'},
  2137. {'label': '4', 'value': '4'}])
  2138. grid0.addWidget(self.gaps_radio, 3, 1)
  2139. self.layout.addStretch()
  2140. class FlatCAMActivityView(QtWidgets.QWidget):
  2141. def __init__(self, parent=None):
  2142. super().__init__(parent=parent)
  2143. self.setMinimumWidth(200)
  2144. self.icon = QtWidgets.QLabel(self)
  2145. self.icon.setGeometry(0, 0, 16, 12)
  2146. self.movie = QtGui.QMovie("share/active.gif")
  2147. self.icon.setMovie(self.movie)
  2148. # self.movie.start()
  2149. layout = QtWidgets.QHBoxLayout()
  2150. layout.setContentsMargins(5, 0, 5, 0)
  2151. layout.setAlignment(QtCore.Qt.AlignLeft)
  2152. self.setLayout(layout)
  2153. layout.addWidget(self.icon)
  2154. self.text = QtWidgets.QLabel(self)
  2155. self.text.setText("Idle.")
  2156. layout.addWidget(self.text)
  2157. def set_idle(self):
  2158. self.movie.stop()
  2159. self.text.setText("Idle.")
  2160. def set_busy(self, msg):
  2161. self.movie.start()
  2162. self.text.setText(msg)
  2163. class FlatCAMInfoBar(QtWidgets.QWidget):
  2164. def __init__(self, parent=None):
  2165. super(FlatCAMInfoBar, self).__init__(parent=parent)
  2166. self.icon = QtWidgets.QLabel(self)
  2167. self.icon.setGeometry(0, 0, 12, 12)
  2168. self.pmap = QtGui.QPixmap('share/graylight12.png')
  2169. self.icon.setPixmap(self.pmap)
  2170. layout = QtWidgets.QHBoxLayout()
  2171. layout.setContentsMargins(5, 0, 5, 0)
  2172. self.setLayout(layout)
  2173. layout.addWidget(self.icon)
  2174. self.text = QtWidgets.QLabel(self)
  2175. self.text.setText("Hello!")
  2176. self.text.setToolTip("Hello!")
  2177. layout.addWidget(self.text)
  2178. layout.addStretch()
  2179. def set_text_(self, text):
  2180. self.text.setText(text)
  2181. self.text.setToolTip(text)
  2182. def set_status(self, text, level="info"):
  2183. level = str(level)
  2184. self.pmap.fill()
  2185. if level == "error" or level == "error_notcl":
  2186. self.pmap = QtGui.QPixmap('share/redlight12.png')
  2187. elif level == "success":
  2188. self.pmap = QtGui.QPixmap('share/greenlight12.png')
  2189. elif level == "warning" or level == "warning_notcl":
  2190. self.pmap = QtGui.QPixmap('share/yellowlight12.png')
  2191. else:
  2192. self.pmap = QtGui.QPixmap('share/graylight12.png')
  2193. self.icon.setPixmap(self.pmap)
  2194. self.set_text_(text)
  2195. # end of file