FlatCAMGUI.py 25 KB

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