FlatCAMGUI.py 29 KB

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