FlatCAMGUI.py 103 KB

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