FlatCAMGUI.py 25 KB

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