FlatCAMGUI.py 28 KB

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