FlatCAMGUI.py 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818
  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. self.combine_passes_cb = FCCheckBox(label='Combine Passes')
  326. self.combine_passes_cb.setToolTip(
  327. "Combine all passes into one object"
  328. )
  329. grid1.addWidget(self.combine_passes_cb, 3, 0)
  330. ## Board cuttout
  331. self.board_cutout_label = QtGui.QLabel("<b>Board cutout:</b>")
  332. self.board_cutout_label.setToolTip(
  333. "Create toolpaths to cut around\n"
  334. "the PCB and separate it from\n"
  335. "the original board."
  336. )
  337. self.layout.addWidget(self.board_cutout_label)
  338. grid2 = QtGui.QGridLayout()
  339. self.layout.addLayout(grid2)
  340. tdclabel = QtGui.QLabel('Tool dia:')
  341. tdclabel.setToolTip(
  342. "Diameter of the cutting tool."
  343. )
  344. grid2.addWidget(tdclabel, 0, 0)
  345. self.cutout_tooldia_entry = LengthEntry()
  346. grid2.addWidget(self.cutout_tooldia_entry, 0, 1)
  347. marginlabel = QtGui.QLabel('Margin:')
  348. marginlabel.setToolTip(
  349. "Distance from objects at which\n"
  350. "to draw the cutout."
  351. )
  352. grid2.addWidget(marginlabel, 1, 0)
  353. self.cutout_margin_entry = LengthEntry()
  354. grid2.addWidget(self.cutout_margin_entry, 1, 1)
  355. gaplabel = QtGui.QLabel('Gap size:')
  356. gaplabel.setToolTip(
  357. "Size of the gaps in the toolpath\n"
  358. "that will remain to hold the\n"
  359. "board in place."
  360. )
  361. grid2.addWidget(gaplabel, 2, 0)
  362. self.cutout_gap_entry = LengthEntry()
  363. grid2.addWidget(self.cutout_gap_entry, 2, 1)
  364. gapslabel = QtGui.QLabel('Gaps:')
  365. gapslabel.setToolTip(
  366. "Where to place the gaps, Top/Bottom\n"
  367. "Left/Rigt, or on all 4 sides."
  368. )
  369. grid2.addWidget(gapslabel, 3, 0)
  370. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  371. {'label': '2 (L/R)', 'value': 'lr'},
  372. {'label': '4', 'value': '4'}])
  373. grid2.addWidget(self.gaps_radio, 3, 1)
  374. ## Non-copper regions
  375. self.noncopper_label = QtGui.QLabel("<b>Non-copper regions:</b>")
  376. self.noncopper_label.setToolTip(
  377. "Create polygons covering the\n"
  378. "areas without copper on the PCB.\n"
  379. "Equivalent to the inverse of this\n"
  380. "object. Can be used to remove all\n"
  381. "copper from a specified region."
  382. )
  383. self.layout.addWidget(self.noncopper_label)
  384. grid3 = QtGui.QGridLayout()
  385. self.layout.addLayout(grid3)
  386. # Margin
  387. bmlabel = QtGui.QLabel('Boundary Margin:')
  388. bmlabel.setToolTip(
  389. "Specify the edge of the PCB\n"
  390. "by drawing a box around all\n"
  391. "objects with this minimum\n"
  392. "distance."
  393. )
  394. grid3.addWidget(bmlabel, 0, 0)
  395. self.noncopper_margin_entry = LengthEntry()
  396. grid3.addWidget(self.noncopper_margin_entry, 0, 1)
  397. # Rounded corners
  398. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  399. self.noncopper_rounded_cb.setToolTip(
  400. "Creates a Geometry objects with polygons\n"
  401. "covering the copper-free areas of the PCB."
  402. )
  403. grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  404. ## Bounding box
  405. self.boundingbox_label = QtGui.QLabel('<b>Bounding Box:</b>')
  406. self.layout.addWidget(self.boundingbox_label)
  407. grid4 = QtGui.QGridLayout()
  408. self.layout.addLayout(grid4)
  409. bbmargin = QtGui.QLabel('Boundary Margin:')
  410. bbmargin.setToolTip(
  411. "Distance of the edges of the box\n"
  412. "to the nearest polygon."
  413. )
  414. grid4.addWidget(bbmargin, 0, 0)
  415. self.bbmargin_entry = LengthEntry()
  416. grid4.addWidget(self.bbmargin_entry, 0, 1)
  417. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  418. self.bbrounded_cb.setToolTip(
  419. "If the bounding box is \n"
  420. "to have rounded corners\n"
  421. "their radius is equal to\n"
  422. "the margin."
  423. )
  424. grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  425. class ExcellonOptionsGroupUI(OptionsGroupUI):
  426. def __init__(self, parent=None):
  427. OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  428. ## Plot options
  429. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  430. self.layout.addWidget(self.plot_options_label)
  431. grid0 = QtGui.QGridLayout()
  432. self.layout.addLayout(grid0)
  433. self.plot_cb = FCCheckBox(label='Plot')
  434. self.plot_cb.setToolTip(
  435. "Plot (show) this object."
  436. )
  437. grid0.addWidget(self.plot_cb, 0, 0)
  438. self.solid_cb = FCCheckBox(label='Solid')
  439. self.solid_cb.setToolTip(
  440. "Solid circles."
  441. )
  442. grid0.addWidget(self.solid_cb, 0, 1)
  443. ## Create CNC Job
  444. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job</b>')
  445. self.cncjob_label.setToolTip(
  446. "Create a CNC Job object\n"
  447. "for this drill object."
  448. )
  449. self.layout.addWidget(self.cncjob_label)
  450. grid1 = QtGui.QGridLayout()
  451. self.layout.addLayout(grid1)
  452. cutzlabel = QtGui.QLabel('Cut Z:')
  453. cutzlabel.setToolTip(
  454. "Drill depth (negative)\n"
  455. "below the copper surface."
  456. )
  457. grid1.addWidget(cutzlabel, 0, 0)
  458. self.cutz_entry = LengthEntry()
  459. grid1.addWidget(self.cutz_entry, 0, 1)
  460. travelzlabel = QtGui.QLabel('Travel Z:')
  461. travelzlabel.setToolTip(
  462. "Tool height when travelling\n"
  463. "across the XY plane."
  464. )
  465. grid1.addWidget(travelzlabel, 1, 0)
  466. self.travelz_entry = LengthEntry()
  467. grid1.addWidget(self.travelz_entry, 1, 1)
  468. frlabel = QtGui.QLabel('Feed rate:')
  469. frlabel.setToolTip(
  470. "Tool speed while drilling\n"
  471. "(in units per minute)."
  472. )
  473. grid1.addWidget(frlabel, 2, 0)
  474. self.feedrate_entry = LengthEntry()
  475. grid1.addWidget(self.feedrate_entry, 2, 1)
  476. spdlabel = QtGui.QLabel('Spindle speed:')
  477. spdlabel.setToolTip(
  478. "Speed of the spindle\n"
  479. "in RPM (optional)"
  480. )
  481. grid1.addWidget(spdlabel, 3, 0)
  482. self.spindlespeed_entry = LengthEntry()
  483. grid1.addWidget(self.spindlespeed_entry, 3, 1)
  484. class GeometryOptionsGroupUI(OptionsGroupUI):
  485. def __init__(self, parent=None):
  486. OptionsGroupUI.__init__(self, "Geometry Options", parent=parent)
  487. ## Plot options
  488. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  489. self.layout.addWidget(self.plot_options_label)
  490. # Plot CB
  491. self.plot_cb = FCCheckBox(label='Plot')
  492. self.plot_cb.setToolTip(
  493. "Plot (show) this object."
  494. )
  495. self.layout.addWidget(self.plot_cb)
  496. ## Create CNC Job
  497. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job:</b>')
  498. self.cncjob_label.setToolTip(
  499. "Create a CNC Job object\n"
  500. "tracing the contours of this\n"
  501. "Geometry object."
  502. )
  503. self.layout.addWidget(self.cncjob_label)
  504. grid1 = QtGui.QGridLayout()
  505. self.layout.addLayout(grid1)
  506. cutzlabel = QtGui.QLabel('Cut Z:')
  507. cutzlabel.setToolTip(
  508. "Cutting depth (negative)\n"
  509. "below the copper surface."
  510. )
  511. grid1.addWidget(cutzlabel, 0, 0)
  512. self.cutz_entry = LengthEntry()
  513. grid1.addWidget(self.cutz_entry, 0, 1)
  514. # Travel Z
  515. travelzlabel = QtGui.QLabel('Travel Z:')
  516. travelzlabel.setToolTip(
  517. "Height of the tool when\n"
  518. "moving without cutting."
  519. )
  520. grid1.addWidget(travelzlabel, 1, 0)
  521. self.travelz_entry = LengthEntry()
  522. grid1.addWidget(self.travelz_entry, 1, 1)
  523. # Feedrate
  524. frlabel = QtGui.QLabel('Feed Rate:')
  525. frlabel.setToolTip(
  526. "Cutting speed in the XY\n"
  527. "plane in units per minute"
  528. )
  529. grid1.addWidget(frlabel, 2, 0)
  530. self.cncfeedrate_entry = LengthEntry()
  531. grid1.addWidget(self.cncfeedrate_entry, 2, 1)
  532. # Tooldia
  533. tdlabel = QtGui.QLabel('Tool dia:')
  534. tdlabel.setToolTip(
  535. "The diameter of the cutting\n"
  536. "tool (just for display)."
  537. )
  538. grid1.addWidget(tdlabel, 3, 0)
  539. self.cnctooldia_entry = LengthEntry()
  540. grid1.addWidget(self.cnctooldia_entry, 3, 1)
  541. spdlabel = QtGui.QLabel('Spindle speed:')
  542. spdlabel.setToolTip(
  543. "Speed of the spindle\n"
  544. "in RPM (optional)"
  545. )
  546. grid1.addWidget(spdlabel, 4, 0)
  547. self.cncspindlespeed_entry = LengthEntry()
  548. grid1.addWidget(self.cncspindlespeed_entry, 4, 1)
  549. ## Paint area
  550. self.paint_label = QtGui.QLabel('<b>Paint Area:</b>')
  551. self.paint_label.setToolTip(
  552. "Creates tool paths to cover the\n"
  553. "whole area of a polygon (remove\n"
  554. "all copper). You will be asked\n"
  555. "to click on the desired polygon."
  556. )
  557. self.layout.addWidget(self.paint_label)
  558. grid2 = QtGui.QGridLayout()
  559. self.layout.addLayout(grid2)
  560. # Tool dia
  561. ptdlabel = QtGui.QLabel('Tool dia:')
  562. ptdlabel.setToolTip(
  563. "Diameter of the tool to\n"
  564. "be used in the operation."
  565. )
  566. grid2.addWidget(ptdlabel, 0, 0)
  567. self.painttooldia_entry = LengthEntry()
  568. grid2.addWidget(self.painttooldia_entry, 0, 1)
  569. # Overlap
  570. ovlabel = QtGui.QLabel('Overlap:')
  571. ovlabel.setToolTip(
  572. "How much (fraction) of the tool\n"
  573. "width to overlap each tool pass."
  574. )
  575. grid2.addWidget(ovlabel, 1, 0)
  576. self.paintoverlap_entry = LengthEntry()
  577. grid2.addWidget(self.paintoverlap_entry, 1, 1)
  578. # Margin
  579. marginlabel = QtGui.QLabel('Margin:')
  580. marginlabel.setToolTip(
  581. "Distance by which to avoid\n"
  582. "the edges of the polygon to\n"
  583. "be painted."
  584. )
  585. grid2.addWidget(marginlabel, 2, 0)
  586. self.paintmargin_entry = LengthEntry()
  587. grid2.addWidget(self.paintmargin_entry)
  588. class CNCJobOptionsGroupUI(OptionsGroupUI):
  589. def __init__(self, parent=None):
  590. OptionsGroupUI.__init__(self, "CNC Job Options", parent=None)
  591. ## Plot options
  592. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  593. self.layout.addWidget(self.plot_options_label)
  594. grid0 = QtGui.QGridLayout()
  595. self.layout.addLayout(grid0)
  596. # Plot CB
  597. # self.plot_cb = QtGui.QCheckBox('Plot')
  598. self.plot_cb = FCCheckBox('Plot')
  599. self.plot_cb.setToolTip(
  600. "Plot (show) this object."
  601. )
  602. grid0.addWidget(self.plot_cb, 0, 0)
  603. # Tool dia for plot
  604. tdlabel = QtGui.QLabel('Tool dia:')
  605. tdlabel.setToolTip(
  606. "Diameter of the tool to be\n"
  607. "rendered in the plot."
  608. )
  609. grid0.addWidget(tdlabel, 1, 0)
  610. self.tooldia_entry = LengthEntry()
  611. grid0.addWidget(self.tooldia_entry, 1, 1)
  612. ## Export G-Code
  613. self.export_gcode_label = QtGui.QLabel("<b>Export G-Code:</b>")
  614. self.export_gcode_label.setToolTip(
  615. "Export and save G-Code to\n"
  616. "make this object to a file."
  617. )
  618. self.layout.addWidget(self.export_gcode_label)
  619. # Append text to Gerber
  620. appendlabel = QtGui.QLabel('Append to G-Code:')
  621. appendlabel.setToolTip(
  622. "Type here any G-Code commands you would\n"
  623. "like to append to the generated file.\n"
  624. "I.e.: M2 (End of program)"
  625. )
  626. self.layout.addWidget(appendlabel)
  627. self.append_text = FCTextArea()
  628. self.layout.addWidget(self.append_text)
  629. class GlobalOptionsUI(QtGui.QWidget):
  630. """
  631. This is the app and project options editor.
  632. """
  633. def __init__(self, parent=None):
  634. QtGui.QWidget.__init__(self, parent=parent)
  635. layout = QtGui.QVBoxLayout()
  636. self.setLayout(layout)
  637. hlay1 = QtGui.QHBoxLayout()
  638. layout.addLayout(hlay1)
  639. unitslabel = QtGui.QLabel('Units:')
  640. hlay1.addWidget(unitslabel)
  641. self.units_radio = RadioSet([{'label': 'inch', 'value': 'IN'},
  642. {'label': 'mm', 'value': 'MM'}])
  643. hlay1.addWidget(self.units_radio)
  644. ####### Gerber #######
  645. # gerberlabel = QtGui.QLabel('<b>Gerber Options</b>')
  646. # layout.addWidget(gerberlabel)
  647. self.gerber_group = GerberOptionsGroupUI()
  648. # self.gerber_group.setFrameStyle(QtGui.QFrame.StyledPanel)
  649. layout.addWidget(self.gerber_group)
  650. ####### Excellon #######
  651. # excellonlabel = QtGui.QLabel('<b>Excellon Options</b>')
  652. # layout.addWidget(excellonlabel)
  653. self.excellon_group = ExcellonOptionsGroupUI()
  654. # self.excellon_group.setFrameStyle(QtGui.QFrame.StyledPanel)
  655. layout.addWidget(self.excellon_group)
  656. ####### Geometry #######
  657. # geometrylabel = QtGui.QLabel('<b>Geometry Options</b>')
  658. # layout.addWidget(geometrylabel)
  659. self.geometry_group = GeometryOptionsGroupUI()
  660. # self.geometry_group.setStyle(QtGui.QFrame.StyledPanel)
  661. layout.addWidget(self.geometry_group)
  662. ####### CNC #######
  663. # cnclabel = QtGui.QLabel('<b>CNC Job Options</b>')
  664. # layout.addWidget(cnclabel)
  665. self.cncjob_group = CNCJobOptionsGroupUI()
  666. # self.cncjob_group.setStyle(QtGui.QFrame.StyledPanel)
  667. layout.addWidget(self.cncjob_group)
  668. # def main():
  669. #
  670. # app = QtGui.QApplication(sys.argv)
  671. # fc = FlatCAMGUI()
  672. # sys.exit(app.exec_())
  673. #
  674. #
  675. # if __name__ == '__main__':
  676. # main()