FlatCAMGUI.py 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702
  1. from PyQt4 import QtGui, QtCore, Qt
  2. from GUIElements import *
  3. class FlatCAMGUI(QtGui.QMainWindow):
  4. def __init__(self, version):
  5. super(FlatCAMGUI, self).__init__()
  6. # Divine icon pack by Ipapun @ finicons.com
  7. ############
  8. ### Menu ###
  9. ############
  10. self.menu = self.menuBar()
  11. ### File ###
  12. self.menufile = self.menu.addMenu('&File')
  13. # New
  14. self.menufilenew = QtGui.QAction(QtGui.QIcon('share/file16.png'), '&New', self)
  15. self.menufile.addAction(self.menufilenew)
  16. # Open recent
  17. # Recent
  18. self.recent = self.menufile.addMenu(QtGui.QIcon('share/folder16.png'), "Open recent ...")
  19. # Open gerber
  20. self.menufileopengerber = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Gerber ...', self)
  21. self.menufile.addAction(self.menufileopengerber)
  22. # Open Excellon ...
  23. self.menufileopenexcellon = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Excellon ...', self)
  24. self.menufile.addAction(self.menufileopenexcellon)
  25. # Open G-Code ...
  26. self.menufileopengcode = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open G-&Code ...', self)
  27. self.menufile.addAction(self.menufileopengcode)
  28. # Open Project ...
  29. self.menufileopenproject = QtGui.QAction(QtGui.QIcon('share/folder16.png'), 'Open &Project ...', self)
  30. self.menufile.addAction(self.menufileopenproject)
  31. # Save Project
  32. self.menufilesaveproject = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), '&Save Project', self)
  33. self.menufile.addAction(self.menufilesaveproject)
  34. # Save Project As ...
  35. self.menufilesaveprojectas = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), 'Save Project &As ...', self)
  36. self.menufile.addAction(self.menufilesaveprojectas)
  37. # Save Project Copy ...
  38. self.menufilesaveprojectcopy = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), 'Save Project C&opy ...', self)
  39. self.menufile.addAction(self.menufilesaveprojectcopy)
  40. # Save Defaults
  41. self.menufilesavedefaults = QtGui.QAction(QtGui.QIcon('share/floppy16.png'), 'Save &Defaults', self)
  42. self.menufile.addAction(self.menufilesavedefaults)
  43. # Quit
  44. exit_action = QtGui.QAction(QtGui.QIcon('share/power16.png'), '&Exit', self)
  45. # exitAction.setShortcut('Ctrl+Q')
  46. # exitAction.setStatusTip('Exit application')
  47. exit_action.triggered.connect(QtGui.qApp.quit)
  48. self.menufile.addAction(exit_action)
  49. ### Edit ###
  50. self.menuedit = self.menu.addMenu('&Edit')
  51. self.menueditnew = self.menuedit.addAction(QtGui.QIcon('share/new_geo16.png'), 'New Geometry')
  52. self.menueditedit = self.menuedit.addAction(QtGui.QIcon('share/edit16.png'), 'Edit Geometry')
  53. self.menueditok = self.menuedit.addAction(QtGui.QIcon('share/edit_ok16.png'), 'Update Geometry')
  54. #self.menueditcancel = self.menuedit.addAction(QtGui.QIcon('share/cancel_edit16.png'), "Cancel Edit")
  55. self.menueditdelete = self.menuedit.addAction(QtGui.QIcon('share/trash16.png'), 'Delete')
  56. ### Options ###
  57. self.menuoptions = self.menu.addMenu('&Options')
  58. self.menuoptions_transfer = self.menuoptions.addMenu('Transfer options')
  59. self.menuoptions_transfer_a2p = self.menuoptions_transfer.addAction("Application to Project")
  60. self.menuoptions_transfer_p2a = self.menuoptions_transfer.addAction("Project to Application")
  61. self.menuoptions_transfer_p2o = self.menuoptions_transfer.addAction("Project to Object")
  62. self.menuoptions_transfer_o2p = self.menuoptions_transfer.addAction("Object to Project")
  63. self.menuoptions_transfer_a2o = self.menuoptions_transfer.addAction("Application to Object")
  64. self.menuoptions_transfer_o2a = self.menuoptions_transfer.addAction("Object to Application")
  65. ### View ###
  66. self.menuview = self.menu.addMenu('&View')
  67. self.menuviewdisableall = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'), 'Disable all plots')
  68. self.menuviewdisableother = self.menuview.addAction(QtGui.QIcon('share/clear_plot16.png'),
  69. 'Disable all plots but this one')
  70. self.menuviewenable = self.menuview.addAction(QtGui.QIcon('share/replot16.png'), 'Enable all plots')
  71. ### Tool ###
  72. self.menutool = self.menu.addMenu('&Tool')
  73. self.menutoolshell = self.menutool.addAction(QtGui.QIcon('share/shell16.png'), '&Command Line')
  74. ### Help ###
  75. self.menuhelp = self.menu.addMenu('&Help')
  76. self.menuhelp_about = self.menuhelp.addAction(QtGui.QIcon('share/tv16.png'), 'About FlatCAM')
  77. self.menuhelp_home = self.menuhelp.addAction(QtGui.QIcon('share/home16.png'), 'Home')
  78. self.menuhelp_manual = self.menuhelp.addAction(QtGui.QIcon('share/globe16.png'), 'Manual')
  79. ###############
  80. ### Toolbar ###
  81. ###############
  82. self.toolbar = QtGui.QToolBar()
  83. self.addToolBar(self.toolbar)
  84. self.zoom_fit_btn = self.toolbar.addAction(QtGui.QIcon('share/zoom_fit32.png'), "&Zoom Fit")
  85. self.zoom_out_btn = self.toolbar.addAction(QtGui.QIcon('share/zoom_out32.png'), "&Zoom Out")
  86. self.zoom_in_btn = self.toolbar.addAction(QtGui.QIcon('share/zoom_in32.png'), "&Zoom In")
  87. self.clear_plot_btn = self.toolbar.addAction(QtGui.QIcon('share/clear_plot32.png'), "&Clear Plot")
  88. self.replot_btn = self.toolbar.addAction(QtGui.QIcon('share/replot32.png'), "&Replot")
  89. self.newgeo_btn = self.toolbar.addAction(QtGui.QIcon('share/new_geo32.png'), "New Blank Geometry")
  90. self.editgeo_btn = self.toolbar.addAction(QtGui.QIcon('share/edit32.png'), "Edit Geometry")
  91. self.updategeo_btn = self.toolbar.addAction(QtGui.QIcon('share/edit_ok32.png'), "Update Geometry")
  92. #self.canceledit_btn = self.toolbar.addAction(QtGui.QIcon('share/cancel_edit32.png'), "Cancel Edit")
  93. self.delete_btn = self.toolbar.addAction(QtGui.QIcon('share/delete32.png'), "&Delete")
  94. self.shell_btn = self.toolbar.addAction(QtGui.QIcon('share/shell32.png'), "&Command Line")
  95. ################
  96. ### Splitter ###
  97. ################
  98. self.splitter = QtGui.QSplitter()
  99. self.setCentralWidget(self.splitter)
  100. ################
  101. ### Notebook ###
  102. ################
  103. self.notebook = QtGui.QTabWidget()
  104. # self.notebook.setMinimumWidth(250)
  105. ### Projet ###
  106. project_tab = QtGui.QWidget()
  107. project_tab.setMinimumWidth(250) # Hack
  108. self.project_tab_layout = QtGui.QVBoxLayout(project_tab)
  109. self.project_tab_layout.setContentsMargins(2, 2, 2, 2)
  110. self.notebook.addTab(project_tab, "Project")
  111. ### Selected ###
  112. self.selected_tab = QtGui.QWidget()
  113. self.selected_tab_layout = QtGui.QVBoxLayout(self.selected_tab)
  114. self.selected_tab_layout.setContentsMargins(2, 2, 2, 2)
  115. self.selected_scroll_area = VerticalScrollArea()
  116. self.selected_tab_layout.addWidget(self.selected_scroll_area)
  117. self.notebook.addTab(self.selected_tab, "Selected")
  118. ### Options ###
  119. self.options_tab = QtGui.QWidget()
  120. self.options_tab.setContentsMargins(0, 0, 0, 0)
  121. self.options_tab_layout = QtGui.QVBoxLayout(self.options_tab)
  122. self.options_tab_layout.setContentsMargins(2, 2, 2, 2)
  123. hlay1 = QtGui.QHBoxLayout()
  124. self.options_tab_layout.addLayout(hlay1)
  125. self.icon = QtGui.QLabel()
  126. self.icon.setPixmap(QtGui.QPixmap('share/gear48.png'))
  127. hlay1.addWidget(self.icon)
  128. self.options_combo = QtGui.QComboBox()
  129. self.options_combo.addItem("APPLICATION DEFAULTS")
  130. self.options_combo.addItem("PROJECT OPTIONS")
  131. hlay1.addWidget(self.options_combo)
  132. hlay1.addStretch()
  133. self.options_scroll_area = VerticalScrollArea()
  134. self.options_tab_layout.addWidget(self.options_scroll_area)
  135. self.notebook.addTab(self.options_tab, "Options")
  136. ### Tool ###
  137. self.tool_tab = QtGui.QWidget()
  138. self.tool_tab_layout = QtGui.QVBoxLayout(self.tool_tab)
  139. self.tool_tab_layout.setContentsMargins(2, 2, 2, 2)
  140. self.notebook.addTab(self.tool_tab, "Tool")
  141. self.tool_scroll_area = VerticalScrollArea()
  142. self.tool_tab_layout.addWidget(self.tool_scroll_area)
  143. self.splitter.addWidget(self.notebook)
  144. ######################
  145. ### Plot and other ###
  146. ######################
  147. right_widget = QtGui.QWidget()
  148. # right_widget.setContentsMargins(0, 0, 0, 0)
  149. self.splitter.addWidget(right_widget)
  150. self.right_layout = QtGui.QVBoxLayout()
  151. self.right_layout.setMargin(0)
  152. # self.right_layout.setContentsMargins(0, 0, 0, 0)
  153. right_widget.setLayout(self.right_layout)
  154. ################
  155. ### Info bar ###
  156. ################
  157. infobar = self.statusBar()
  158. self.info_label = QtGui.QLabel("Welcome to FlatCAM.")
  159. self.info_label.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain)
  160. infobar.addWidget(self.info_label, stretch=1)
  161. self.position_label = QtGui.QLabel("")
  162. self.position_label.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain)
  163. self.position_label.setMinimumWidth(110)
  164. infobar.addWidget(self.position_label)
  165. self.units_label = QtGui.QLabel("[in]")
  166. # self.units_label.setFrameStyle(QtGui.QFrame.StyledPanel | QtGui.QFrame.Plain)
  167. self.units_label.setMargin(2)
  168. infobar.addWidget(self.units_label)
  169. self.progress_bar = QtGui.QProgressBar()
  170. self.progress_bar.setMinimum(0)
  171. self.progress_bar.setMaximum(100)
  172. infobar.addWidget(self.progress_bar)
  173. #############
  174. ### Icons ###
  175. #############
  176. self.app_icon = QtGui.QIcon()
  177. self.app_icon.addFile('share/flatcam_icon16.png', QtCore.QSize(16, 16))
  178. self.app_icon.addFile('share/flatcam_icon24.png', QtCore.QSize(24, 24))
  179. self.app_icon.addFile('share/flatcam_icon32.png', QtCore.QSize(32, 32))
  180. self.app_icon.addFile('share/flatcam_icon48.png', QtCore.QSize(48, 48))
  181. self.app_icon.addFile('share/flatcam_icon128.png', QtCore.QSize(128, 128))
  182. self.app_icon.addFile('share/flatcam_icon256.png', QtCore.QSize(256, 256))
  183. self.setWindowIcon(self.app_icon)
  184. self.setGeometry(100, 100, 1024, 650)
  185. self.setWindowTitle('FlatCAM %s' % version)
  186. self.show()
  187. class OptionsGroupUI(QtGui.QGroupBox):
  188. def __init__(self, title, parent=None):
  189. QtGui.QGroupBox.__init__(self, title, parent=parent)
  190. self.setStyleSheet("""
  191. QGroupBox
  192. {
  193. font-size: 16px;
  194. font-weight: bold;
  195. }
  196. """)
  197. self.layout = QtGui.QVBoxLayout()
  198. self.setLayout(self.layout)
  199. class GerberOptionsGroupUI(OptionsGroupUI):
  200. def __init__(self, parent=None):
  201. OptionsGroupUI.__init__(self, "Gerber Options", parent=parent)
  202. ## Plot options
  203. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  204. self.layout.addWidget(self.plot_options_label)
  205. grid0 = QtGui.QGridLayout()
  206. self.layout.addLayout(grid0)
  207. # Plot CB
  208. self.plot_cb = FCCheckBox(label='Plot')
  209. self.plot_options_label.setToolTip(
  210. "Plot (show) this object."
  211. )
  212. grid0.addWidget(self.plot_cb, 0, 0)
  213. # Solid CB
  214. self.solid_cb = FCCheckBox(label='Solid')
  215. self.solid_cb.setToolTip(
  216. "Solid color polygons."
  217. )
  218. grid0.addWidget(self.solid_cb, 0, 1)
  219. # Multicolored CB
  220. self.multicolored_cb = FCCheckBox(label='Multicolored')
  221. self.multicolored_cb.setToolTip(
  222. "Draw polygons in different colors."
  223. )
  224. grid0.addWidget(self.multicolored_cb, 0, 2)
  225. ## Isolation Routing
  226. self.isolation_routing_label = QtGui.QLabel("<b>Isolation Routing:</b>")
  227. self.isolation_routing_label.setToolTip(
  228. "Create a Geometry object with\n"
  229. "toolpaths to cut outside polygons."
  230. )
  231. self.layout.addWidget(self.isolation_routing_label)
  232. grid1 = QtGui.QGridLayout()
  233. self.layout.addLayout(grid1)
  234. tdlabel = QtGui.QLabel('Tool dia:')
  235. tdlabel.setToolTip(
  236. "Diameter of the cutting tool."
  237. )
  238. grid1.addWidget(tdlabel, 0, 0)
  239. self.iso_tool_dia_entry = LengthEntry()
  240. grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
  241. passlabel = QtGui.QLabel('Width (# passes):')
  242. passlabel.setToolTip(
  243. "Width of the isolation gap in\n"
  244. "number (integer) of tool widths."
  245. )
  246. grid1.addWidget(passlabel, 1, 0)
  247. self.iso_width_entry = IntEntry()
  248. grid1.addWidget(self.iso_width_entry, 1, 1)
  249. overlabel = QtGui.QLabel('Pass overlap:')
  250. overlabel.setToolTip(
  251. "How much (fraction of tool width)\n"
  252. "to overlap each pass."
  253. )
  254. grid1.addWidget(overlabel, 2, 0)
  255. self.iso_overlap_entry = FloatEntry()
  256. grid1.addWidget(self.iso_overlap_entry, 2, 1)
  257. ## Board cuttout
  258. self.board_cutout_label = QtGui.QLabel("<b>Board cutout:</b>")
  259. self.board_cutout_label.setToolTip(
  260. "Create toolpaths to cut around\n"
  261. "the PCB and separate it from\n"
  262. "the original board."
  263. )
  264. self.layout.addWidget(self.board_cutout_label)
  265. grid2 = QtGui.QGridLayout()
  266. self.layout.addLayout(grid2)
  267. tdclabel = QtGui.QLabel('Tool dia:')
  268. tdclabel.setToolTip(
  269. "Diameter of the cutting tool."
  270. )
  271. grid2.addWidget(tdclabel, 0, 0)
  272. self.cutout_tooldia_entry = LengthEntry()
  273. grid2.addWidget(self.cutout_tooldia_entry, 0, 1)
  274. marginlabel = QtGui.QLabel('Margin:')
  275. marginlabel.setToolTip(
  276. "Distance from objects at which\n"
  277. "to draw the cutout."
  278. )
  279. grid2.addWidget(marginlabel, 1, 0)
  280. self.cutout_margin_entry = LengthEntry()
  281. grid2.addWidget(self.cutout_margin_entry, 1, 1)
  282. gaplabel = QtGui.QLabel('Gap size:')
  283. gaplabel.setToolTip(
  284. "Size of the gaps in the toolpath\n"
  285. "that will remain to hold the\n"
  286. "board in place."
  287. )
  288. grid2.addWidget(gaplabel, 2, 0)
  289. self.cutout_gap_entry = LengthEntry()
  290. grid2.addWidget(self.cutout_gap_entry, 2, 1)
  291. gapslabel = QtGui.QLabel('Gaps:')
  292. gapslabel.setToolTip(
  293. "Where to place the gaps, Top/Bottom\n"
  294. "Left/Rigt, or on all 4 sides."
  295. )
  296. grid2.addWidget(gapslabel, 3, 0)
  297. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  298. {'label': '2 (L/R)', 'value': 'lr'},
  299. {'label': '4', 'value': '4'}])
  300. grid2.addWidget(self.gaps_radio, 3, 1)
  301. ## Non-copper regions
  302. self.noncopper_label = QtGui.QLabel("<b>Non-copper regions:</b>")
  303. self.noncopper_label.setToolTip(
  304. "Create polygons covering the\n"
  305. "areas without copper on the PCB.\n"
  306. "Equivalent to the inverse of this\n"
  307. "object. Can be used to remove all\n"
  308. "copper from a specified region."
  309. )
  310. self.layout.addWidget(self.noncopper_label)
  311. grid3 = QtGui.QGridLayout()
  312. self.layout.addLayout(grid3)
  313. # Margin
  314. bmlabel = QtGui.QLabel('Boundary Margin:')
  315. bmlabel.setToolTip(
  316. "Specify the edge of the PCB\n"
  317. "by drawing a box around all\n"
  318. "objects with this minimum\n"
  319. "distance."
  320. )
  321. grid3.addWidget(bmlabel, 0, 0)
  322. self.noncopper_margin_entry = LengthEntry()
  323. grid3.addWidget(self.noncopper_margin_entry, 0, 1)
  324. # Rounded corners
  325. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  326. self.noncopper_rounded_cb.setToolTip(
  327. "Creates a Geometry objects with polygons\n"
  328. "covering the copper-free areas of the PCB."
  329. )
  330. grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  331. ## Bounding box
  332. self.boundingbox_label = QtGui.QLabel('<b>Bounding Box:</b>')
  333. self.layout.addWidget(self.boundingbox_label)
  334. grid4 = QtGui.QGridLayout()
  335. self.layout.addLayout(grid4)
  336. bbmargin = QtGui.QLabel('Boundary Margin:')
  337. bbmargin.setToolTip(
  338. "Distance of the edges of the box\n"
  339. "to the nearest polygon."
  340. )
  341. grid4.addWidget(bbmargin, 0, 0)
  342. self.bbmargin_entry = LengthEntry()
  343. grid4.addWidget(self.bbmargin_entry, 0, 1)
  344. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  345. self.bbrounded_cb.setToolTip(
  346. "If the bounding box is \n"
  347. "to have rounded corners\n"
  348. "their radius is equal to\n"
  349. "the margin."
  350. )
  351. grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  352. class ExcellonOptionsGroupUI(OptionsGroupUI):
  353. def __init__(self, parent=None):
  354. OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  355. ## Plot options
  356. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  357. self.layout.addWidget(self.plot_options_label)
  358. grid0 = QtGui.QGridLayout()
  359. self.layout.addLayout(grid0)
  360. self.plot_cb = FCCheckBox(label='Plot')
  361. self.plot_cb.setToolTip(
  362. "Plot (show) this object."
  363. )
  364. grid0.addWidget(self.plot_cb, 0, 0)
  365. self.solid_cb = FCCheckBox(label='Solid')
  366. self.solid_cb.setToolTip(
  367. "Solid circles."
  368. )
  369. grid0.addWidget(self.solid_cb, 0, 1)
  370. ## Create CNC Job
  371. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job</b>')
  372. self.cncjob_label.setToolTip(
  373. "Create a CNC Job object\n"
  374. "for this drill object."
  375. )
  376. self.layout.addWidget(self.cncjob_label)
  377. grid1 = QtGui.QGridLayout()
  378. self.layout.addLayout(grid1)
  379. cutzlabel = QtGui.QLabel('Cut Z:')
  380. cutzlabel.setToolTip(
  381. "Drill depth (negative)\n"
  382. "below the copper surface."
  383. )
  384. grid1.addWidget(cutzlabel, 0, 0)
  385. self.cutz_entry = LengthEntry()
  386. grid1.addWidget(self.cutz_entry, 0, 1)
  387. travelzlabel = QtGui.QLabel('Travel Z:')
  388. travelzlabel.setToolTip(
  389. "Tool height when travelling\n"
  390. "across the XY plane."
  391. )
  392. grid1.addWidget(travelzlabel, 1, 0)
  393. self.travelz_entry = LengthEntry()
  394. grid1.addWidget(self.travelz_entry, 1, 1)
  395. frlabel = QtGui.QLabel('Feed rate:')
  396. frlabel.setToolTip(
  397. "Tool speed while drilling\n"
  398. "(in units per minute)."
  399. )
  400. grid1.addWidget(frlabel, 2, 0)
  401. self.feedrate_entry = LengthEntry()
  402. grid1.addWidget(self.feedrate_entry, 2, 1)
  403. class GeometryOptionsGroupUI(OptionsGroupUI):
  404. def __init__(self, parent=None):
  405. OptionsGroupUI.__init__(self, "Geometry Options", parent=parent)
  406. ## Plot options
  407. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  408. self.layout.addWidget(self.plot_options_label)
  409. # Plot CB
  410. self.plot_cb = FCCheckBox(label='Plot')
  411. self.plot_cb.setToolTip(
  412. "Plot (show) this object."
  413. )
  414. self.layout.addWidget(self.plot_cb)
  415. ## Create CNC Job
  416. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job:</b>')
  417. self.cncjob_label.setToolTip(
  418. "Create a CNC Job object\n"
  419. "tracing the contours of this\n"
  420. "Geometry object."
  421. )
  422. self.layout.addWidget(self.cncjob_label)
  423. grid1 = QtGui.QGridLayout()
  424. self.layout.addLayout(grid1)
  425. cutzlabel = QtGui.QLabel('Cut Z:')
  426. cutzlabel.setToolTip(
  427. "Cutting depth (negative)\n"
  428. "below the copper surface."
  429. )
  430. grid1.addWidget(cutzlabel, 0, 0)
  431. self.cutz_entry = LengthEntry()
  432. grid1.addWidget(self.cutz_entry, 0, 1)
  433. # Travel Z
  434. travelzlabel = QtGui.QLabel('Travel Z:')
  435. travelzlabel.setToolTip(
  436. "Height of the tool when\n"
  437. "moving without cutting."
  438. )
  439. grid1.addWidget(travelzlabel, 1, 0)
  440. self.travelz_entry = LengthEntry()
  441. grid1.addWidget(self.travelz_entry, 1, 1)
  442. # Feedrate
  443. frlabel = QtGui.QLabel('Feed Rate:')
  444. frlabel.setToolTip(
  445. "Cutting speed in the XY\n"
  446. "plane in units per minute"
  447. )
  448. grid1.addWidget(frlabel, 2, 0)
  449. self.cncfeedrate_entry = LengthEntry()
  450. grid1.addWidget(self.cncfeedrate_entry, 2, 1)
  451. # Tooldia
  452. tdlabel = QtGui.QLabel('Tool dia:')
  453. tdlabel.setToolTip(
  454. "The diameter of the cutting\n"
  455. "tool (just for display)."
  456. )
  457. grid1.addWidget(tdlabel, 3, 0)
  458. self.cnctooldia_entry = LengthEntry()
  459. grid1.addWidget(self.cnctooldia_entry, 3, 1)
  460. ## Paint area
  461. self.paint_label = QtGui.QLabel('<b>Paint Area:</b>')
  462. self.paint_label.setToolTip(
  463. "Creates tool paths to cover the\n"
  464. "whole area of a polygon (remove\n"
  465. "all copper). You will be asked\n"
  466. "to click on the desired polygon."
  467. )
  468. self.layout.addWidget(self.paint_label)
  469. grid2 = QtGui.QGridLayout()
  470. self.layout.addLayout(grid2)
  471. # Tool dia
  472. ptdlabel = QtGui.QLabel('Tool dia:')
  473. ptdlabel.setToolTip(
  474. "Diameter of the tool to\n"
  475. "be used in the operation."
  476. )
  477. grid2.addWidget(ptdlabel, 0, 0)
  478. self.painttooldia_entry = LengthEntry()
  479. grid2.addWidget(self.painttooldia_entry, 0, 1)
  480. # Overlap
  481. ovlabel = QtGui.QLabel('Overlap:')
  482. ovlabel.setToolTip(
  483. "How much (fraction) of the tool\n"
  484. "width to overlap each tool pass."
  485. )
  486. grid2.addWidget(ovlabel, 1, 0)
  487. self.paintoverlap_entry = LengthEntry()
  488. grid2.addWidget(self.paintoverlap_entry, 1, 1)
  489. # Margin
  490. marginlabel = QtGui.QLabel('Margin:')
  491. marginlabel.setToolTip(
  492. "Distance by which to avoid\n"
  493. "the edges of the polygon to\n"
  494. "be painted."
  495. )
  496. grid2.addWidget(marginlabel, 2, 0)
  497. self.paintmargin_entry = LengthEntry()
  498. grid2.addWidget(self.paintmargin_entry)
  499. class CNCJobOptionsGroupUI(OptionsGroupUI):
  500. def __init__(self, parent=None):
  501. OptionsGroupUI.__init__(self, "CNC Job Options", parent=None)
  502. ## Plot options
  503. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  504. self.layout.addWidget(self.plot_options_label)
  505. grid0 = QtGui.QGridLayout()
  506. self.layout.addLayout(grid0)
  507. # Plot CB
  508. # self.plot_cb = QtGui.QCheckBox('Plot')
  509. self.plot_cb = FCCheckBox('Plot')
  510. self.plot_cb.setToolTip(
  511. "Plot (show) this object."
  512. )
  513. grid0.addWidget(self.plot_cb, 0, 0)
  514. # Tool dia for plot
  515. tdlabel = QtGui.QLabel('Tool dia:')
  516. tdlabel.setToolTip(
  517. "Diameter of the tool to be\n"
  518. "rendered in the plot."
  519. )
  520. grid0.addWidget(tdlabel, 1, 0)
  521. self.tooldia_entry = LengthEntry()
  522. grid0.addWidget(self.tooldia_entry, 1, 1)
  523. ## Export G-Code
  524. self.export_gcode_label = QtGui.QLabel("<b>Export G-Code:</b>")
  525. self.export_gcode_label.setToolTip(
  526. "Export and save G-Code to\n"
  527. "make this object to a file."
  528. )
  529. self.layout.addWidget(self.export_gcode_label)
  530. # Append text to Gerber
  531. appendlabel = QtGui.QLabel('Append to G-Code:')
  532. appendlabel.setToolTip(
  533. "Type here any G-Code commands you would\n"
  534. "like to append to the generated file.\n"
  535. "I.e.: M2 (End of program)"
  536. )
  537. self.layout.addWidget(appendlabel)
  538. self.append_text = FCTextArea()
  539. self.layout.addWidget(self.append_text)
  540. class GlobalOptionsUI(QtGui.QWidget):
  541. """
  542. This is the app and project options editor.
  543. """
  544. def __init__(self, parent=None):
  545. QtGui.QWidget.__init__(self, parent=parent)
  546. layout = QtGui.QVBoxLayout()
  547. self.setLayout(layout)
  548. hlay1 = QtGui.QHBoxLayout()
  549. layout.addLayout(hlay1)
  550. unitslabel = QtGui.QLabel('Units:')
  551. hlay1.addWidget(unitslabel)
  552. self.units_radio = RadioSet([{'label': 'inch', 'value': 'IN'},
  553. {'label': 'mm', 'value': 'MM'}])
  554. hlay1.addWidget(self.units_radio)
  555. ####### Gerber #######
  556. # gerberlabel = QtGui.QLabel('<b>Gerber Options</b>')
  557. # layout.addWidget(gerberlabel)
  558. self.gerber_group = GerberOptionsGroupUI()
  559. # self.gerber_group.setFrameStyle(QtGui.QFrame.StyledPanel)
  560. layout.addWidget(self.gerber_group)
  561. ####### Excellon #######
  562. # excellonlabel = QtGui.QLabel('<b>Excellon Options</b>')
  563. # layout.addWidget(excellonlabel)
  564. self.excellon_group = ExcellonOptionsGroupUI()
  565. # self.excellon_group.setFrameStyle(QtGui.QFrame.StyledPanel)
  566. layout.addWidget(self.excellon_group)
  567. ####### Geometry #######
  568. # geometrylabel = QtGui.QLabel('<b>Geometry Options</b>')
  569. # layout.addWidget(geometrylabel)
  570. self.geometry_group = GeometryOptionsGroupUI()
  571. # self.geometry_group.setStyle(QtGui.QFrame.StyledPanel)
  572. layout.addWidget(self.geometry_group)
  573. ####### CNC #######
  574. # cnclabel = QtGui.QLabel('<b>CNC Job Options</b>')
  575. # layout.addWidget(cnclabel)
  576. self.cncjob_group = CNCJobOptionsGroupUI()
  577. # self.cncjob_group.setStyle(QtGui.QFrame.StyledPanel)
  578. layout.addWidget(self.cncjob_group)
  579. # def main():
  580. #
  581. # app = QtGui.QApplication(sys.argv)
  582. # fc = FlatCAMGUI()
  583. # sys.exit(app.exec_())
  584. #
  585. #
  586. # if __name__ == '__main__':
  587. # main()