FlatCAMGUI.py 34 KB

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