FlatCAMGUI.py 32 KB

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