FlatCAMGUI.py 109 KB

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