FlatCAMGUI.py 28 KB

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