FlatCAMGUI.py 25 KB

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