FlatCAMGUI.py 101 KB

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