FlatCAMGUI.py 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864
  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. # 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. self.setWindowTitle('FlatCAM %s - Development Version' % version)
  203. self.show()
  204. def closeEvent(self, event):
  205. grect = self.geometry()
  206. self.geom_update.emit(grect.x(), grect.y(), grect.width(), grect.height())
  207. QtGui.qApp.quit()
  208. class FlatCAMActivityView(QtGui.QWidget):
  209. def __init__(self, parent=None):
  210. super(FlatCAMActivityView, self).__init__(parent=parent)
  211. self.setMinimumWidth(200)
  212. self.icon = QtGui.QLabel(self)
  213. self.icon.setGeometry(0, 0, 12, 12)
  214. self.movie = QtGui.QMovie("share/active.gif")
  215. self.icon.setMovie(self.movie)
  216. #self.movie.start()
  217. layout = QtGui.QHBoxLayout()
  218. layout.setContentsMargins(5, 0, 5, 0)
  219. layout.setAlignment(QtCore.Qt.AlignLeft)
  220. self.setLayout(layout)
  221. layout.addWidget(self.icon)
  222. self.text = QtGui.QLabel(self)
  223. self.text.setText("Idle.")
  224. layout.addWidget(self.text)
  225. def set_idle(self):
  226. self.movie.stop()
  227. self.text.setText("Idle.")
  228. def set_busy(self, msg):
  229. self.movie.start()
  230. self.text.setText(msg)
  231. class FlatCAMInfoBar(QtGui.QWidget):
  232. def __init__(self, parent=None):
  233. super(FlatCAMInfoBar, self).__init__(parent=parent)
  234. self.icon = QtGui.QLabel(self)
  235. self.icon.setGeometry(0, 0, 12, 12)
  236. self.pmap = QtGui.QPixmap('share/graylight12.png')
  237. self.icon.setPixmap(self.pmap)
  238. layout = QtGui.QHBoxLayout()
  239. layout.setContentsMargins(5, 0, 5, 0)
  240. self.setLayout(layout)
  241. layout.addWidget(self.icon)
  242. self.text = QtGui.QLabel(self)
  243. self.text.setText("Hello!")
  244. self.text.setToolTip("Hello!")
  245. layout.addWidget(self.text)
  246. layout.addStretch()
  247. def set_text_(self, text):
  248. self.text.setText(text)
  249. self.text.setToolTip(text)
  250. def set_status(self, text, level="info"):
  251. level = str(level)
  252. self.pmap.fill()
  253. if level == "error":
  254. self.pmap = QtGui.QPixmap('share/redlight12.png')
  255. elif level == "success":
  256. self.pmap = QtGui.QPixmap('share/greenlight12.png')
  257. elif level == "warning":
  258. self.pmap = QtGui.QPixmap('share/yellowlight12.png')
  259. else:
  260. self.pmap = QtGui.QPixmap('share/graylight12.png')
  261. self.icon.setPixmap(self.pmap)
  262. self.set_text_(text)
  263. class OptionsGroupUI(QtGui.QGroupBox):
  264. def __init__(self, title, parent=None):
  265. QtGui.QGroupBox.__init__(self, title, parent=parent)
  266. self.setStyleSheet("""
  267. QGroupBox
  268. {
  269. font-size: 16px;
  270. font-weight: bold;
  271. }
  272. """)
  273. self.layout = QtGui.QVBoxLayout()
  274. self.setLayout(self.layout)
  275. class GerberOptionsGroupUI(OptionsGroupUI):
  276. def __init__(self, parent=None):
  277. OptionsGroupUI.__init__(self, "Gerber Options", parent=parent)
  278. ## Plot options
  279. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  280. self.layout.addWidget(self.plot_options_label)
  281. grid0 = QtGui.QGridLayout()
  282. self.layout.addLayout(grid0)
  283. # Plot CB
  284. self.plot_cb = FCCheckBox(label='Plot')
  285. self.plot_options_label.setToolTip(
  286. "Plot (show) this object."
  287. )
  288. grid0.addWidget(self.plot_cb, 0, 0)
  289. # Solid CB
  290. self.solid_cb = FCCheckBox(label='Solid')
  291. self.solid_cb.setToolTip(
  292. "Solid color polygons."
  293. )
  294. grid0.addWidget(self.solid_cb, 0, 1)
  295. # Multicolored CB
  296. self.multicolored_cb = FCCheckBox(label='Multicolored')
  297. self.multicolored_cb.setToolTip(
  298. "Draw polygons in different colors."
  299. )
  300. grid0.addWidget(self.multicolored_cb, 0, 2)
  301. ## Isolation Routing
  302. self.isolation_routing_label = QtGui.QLabel("<b>Isolation Routing:</b>")
  303. self.isolation_routing_label.setToolTip(
  304. "Create a Geometry object with\n"
  305. "toolpaths to cut outside polygons."
  306. )
  307. self.layout.addWidget(self.isolation_routing_label)
  308. grid1 = QtGui.QGridLayout()
  309. self.layout.addLayout(grid1)
  310. tdlabel = QtGui.QLabel('Tool dia:')
  311. tdlabel.setToolTip(
  312. "Diameter of the cutting tool."
  313. )
  314. grid1.addWidget(tdlabel, 0, 0)
  315. self.iso_tool_dia_entry = LengthEntry()
  316. grid1.addWidget(self.iso_tool_dia_entry, 0, 1)
  317. passlabel = QtGui.QLabel('Width (# passes):')
  318. passlabel.setToolTip(
  319. "Width of the isolation gap in\n"
  320. "number (integer) of tool widths."
  321. )
  322. grid1.addWidget(passlabel, 1, 0)
  323. self.iso_width_entry = IntEntry()
  324. grid1.addWidget(self.iso_width_entry, 1, 1)
  325. overlabel = QtGui.QLabel('Pass overlap:')
  326. overlabel.setToolTip(
  327. "How much (fraction of tool width)\n"
  328. "to overlap each pass."
  329. )
  330. grid1.addWidget(overlabel, 2, 0)
  331. self.iso_overlap_entry = FloatEntry()
  332. grid1.addWidget(self.iso_overlap_entry, 2, 1)
  333. self.combine_passes_cb = FCCheckBox(label='Combine Passes')
  334. self.combine_passes_cb.setToolTip(
  335. "Combine all passes into one object"
  336. )
  337. grid1.addWidget(self.combine_passes_cb, 3, 0)
  338. ## Board cuttout
  339. self.board_cutout_label = QtGui.QLabel("<b>Board cutout:</b>")
  340. self.board_cutout_label.setToolTip(
  341. "Create toolpaths to cut around\n"
  342. "the PCB and separate it from\n"
  343. "the original board."
  344. )
  345. self.layout.addWidget(self.board_cutout_label)
  346. grid2 = QtGui.QGridLayout()
  347. self.layout.addLayout(grid2)
  348. tdclabel = QtGui.QLabel('Tool dia:')
  349. tdclabel.setToolTip(
  350. "Diameter of the cutting tool."
  351. )
  352. grid2.addWidget(tdclabel, 0, 0)
  353. self.cutout_tooldia_entry = LengthEntry()
  354. grid2.addWidget(self.cutout_tooldia_entry, 0, 1)
  355. marginlabel = QtGui.QLabel('Margin:')
  356. marginlabel.setToolTip(
  357. "Distance from objects at which\n"
  358. "to draw the cutout."
  359. )
  360. grid2.addWidget(marginlabel, 1, 0)
  361. self.cutout_margin_entry = LengthEntry()
  362. grid2.addWidget(self.cutout_margin_entry, 1, 1)
  363. gaplabel = QtGui.QLabel('Gap size:')
  364. gaplabel.setToolTip(
  365. "Size of the gaps in the toolpath\n"
  366. "that will remain to hold the\n"
  367. "board in place."
  368. )
  369. grid2.addWidget(gaplabel, 2, 0)
  370. self.cutout_gap_entry = LengthEntry()
  371. grid2.addWidget(self.cutout_gap_entry, 2, 1)
  372. gapslabel = QtGui.QLabel('Gaps:')
  373. gapslabel.setToolTip(
  374. "Where to place the gaps, Top/Bottom\n"
  375. "Left/Rigt, or on all 4 sides."
  376. )
  377. grid2.addWidget(gapslabel, 3, 0)
  378. self.gaps_radio = RadioSet([{'label': '2 (T/B)', 'value': 'tb'},
  379. {'label': '2 (L/R)', 'value': 'lr'},
  380. {'label': '4', 'value': '4'}])
  381. grid2.addWidget(self.gaps_radio, 3, 1)
  382. ## Non-copper regions
  383. self.noncopper_label = QtGui.QLabel("<b>Non-copper regions:</b>")
  384. self.noncopper_label.setToolTip(
  385. "Create polygons covering the\n"
  386. "areas without copper on the PCB.\n"
  387. "Equivalent to the inverse of this\n"
  388. "object. Can be used to remove all\n"
  389. "copper from a specified region."
  390. )
  391. self.layout.addWidget(self.noncopper_label)
  392. grid3 = QtGui.QGridLayout()
  393. self.layout.addLayout(grid3)
  394. # Margin
  395. bmlabel = QtGui.QLabel('Boundary Margin:')
  396. bmlabel.setToolTip(
  397. "Specify the edge of the PCB\n"
  398. "by drawing a box around all\n"
  399. "objects with this minimum\n"
  400. "distance."
  401. )
  402. grid3.addWidget(bmlabel, 0, 0)
  403. self.noncopper_margin_entry = LengthEntry()
  404. grid3.addWidget(self.noncopper_margin_entry, 0, 1)
  405. # Rounded corners
  406. self.noncopper_rounded_cb = FCCheckBox(label="Rounded corners")
  407. self.noncopper_rounded_cb.setToolTip(
  408. "Creates a Geometry objects with polygons\n"
  409. "covering the copper-free areas of the PCB."
  410. )
  411. grid3.addWidget(self.noncopper_rounded_cb, 1, 0, 1, 2)
  412. ## Bounding box
  413. self.boundingbox_label = QtGui.QLabel('<b>Bounding Box:</b>')
  414. self.layout.addWidget(self.boundingbox_label)
  415. grid4 = QtGui.QGridLayout()
  416. self.layout.addLayout(grid4)
  417. bbmargin = QtGui.QLabel('Boundary Margin:')
  418. bbmargin.setToolTip(
  419. "Distance of the edges of the box\n"
  420. "to the nearest polygon."
  421. )
  422. grid4.addWidget(bbmargin, 0, 0)
  423. self.bbmargin_entry = LengthEntry()
  424. grid4.addWidget(self.bbmargin_entry, 0, 1)
  425. self.bbrounded_cb = FCCheckBox(label="Rounded corners")
  426. self.bbrounded_cb.setToolTip(
  427. "If the bounding box is \n"
  428. "to have rounded corners\n"
  429. "their radius is equal to\n"
  430. "the margin."
  431. )
  432. grid4.addWidget(self.bbrounded_cb, 1, 0, 1, 2)
  433. class ExcellonOptionsGroupUI(OptionsGroupUI):
  434. def __init__(self, parent=None):
  435. OptionsGroupUI.__init__(self, "Excellon Options", parent=parent)
  436. ## Plot options
  437. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  438. self.layout.addWidget(self.plot_options_label)
  439. grid0 = QtGui.QGridLayout()
  440. self.layout.addLayout(grid0)
  441. self.plot_cb = FCCheckBox(label='Plot')
  442. self.plot_cb.setToolTip(
  443. "Plot (show) this object."
  444. )
  445. grid0.addWidget(self.plot_cb, 0, 0)
  446. self.solid_cb = FCCheckBox(label='Solid')
  447. self.solid_cb.setToolTip(
  448. "Solid circles."
  449. )
  450. grid0.addWidget(self.solid_cb, 0, 1)
  451. ## Create CNC Job
  452. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job</b>')
  453. self.cncjob_label.setToolTip(
  454. "Create a CNC Job object\n"
  455. "for this drill object."
  456. )
  457. self.layout.addWidget(self.cncjob_label)
  458. grid1 = QtGui.QGridLayout()
  459. self.layout.addLayout(grid1)
  460. cutzlabel = QtGui.QLabel('Cut Z:')
  461. cutzlabel.setToolTip(
  462. "Drill depth (negative)\n"
  463. "below the copper surface."
  464. )
  465. grid1.addWidget(cutzlabel, 0, 0)
  466. self.cutz_entry = LengthEntry()
  467. grid1.addWidget(self.cutz_entry, 0, 1)
  468. travelzlabel = QtGui.QLabel('Travel Z:')
  469. travelzlabel.setToolTip(
  470. "Tool height when travelling\n"
  471. "across the XY plane."
  472. )
  473. grid1.addWidget(travelzlabel, 1, 0)
  474. self.travelz_entry = LengthEntry()
  475. grid1.addWidget(self.travelz_entry, 1, 1)
  476. frlabel = QtGui.QLabel('Feed rate:')
  477. frlabel.setToolTip(
  478. "Tool speed while drilling\n"
  479. "(in units per minute)."
  480. )
  481. grid1.addWidget(frlabel, 2, 0)
  482. self.feedrate_entry = LengthEntry()
  483. grid1.addWidget(self.feedrate_entry, 2, 1)
  484. toolchangezlabel = QtGui.QLabel('Toolchange Z:')
  485. toolchangezlabel.setToolTip(
  486. "Tool Z where user can change drill bit\n"
  487. )
  488. grid1.addWidget(toolchangezlabel, 3, 0)
  489. self.toolchangez_entry = LengthEntry()
  490. grid1.addWidget(self.toolchangez_entry, 3, 1)
  491. spdlabel = QtGui.QLabel('Spindle speed:')
  492. spdlabel.setToolTip(
  493. "Speed of the spindle\n"
  494. "in RPM (optional)"
  495. )
  496. grid1.addWidget(spdlabel, 4, 0)
  497. self.spindlespeed_entry = IntEntry(allow_empty=True)
  498. grid1.addWidget(self.spindlespeed_entry, 4, 1)
  499. #### Milling Holes ####
  500. self.mill_hole_label = QtGui.QLabel('<b>Mill Holes</b>')
  501. self.mill_hole_label.setToolTip(
  502. "Create Geometry for milling holes."
  503. )
  504. self.layout.addWidget(self.mill_hole_label)
  505. grid1 = QtGui.QGridLayout()
  506. self.layout.addLayout(grid1)
  507. tdlabel = QtGui.QLabel('Tool dia:')
  508. tdlabel.setToolTip(
  509. "Diameter of the cutting tool."
  510. )
  511. grid1.addWidget(tdlabel, 0, 0)
  512. self.tooldia_entry = LengthEntry()
  513. grid1.addWidget(self.tooldia_entry, 0, 1)
  514. class GeometryOptionsGroupUI(OptionsGroupUI):
  515. def __init__(self, parent=None):
  516. OptionsGroupUI.__init__(self, "Geometry Options", parent=parent)
  517. ## Plot options
  518. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  519. self.layout.addWidget(self.plot_options_label)
  520. # Plot CB
  521. self.plot_cb = FCCheckBox(label='Plot')
  522. self.plot_cb.setToolTip(
  523. "Plot (show) this object."
  524. )
  525. self.layout.addWidget(self.plot_cb)
  526. ## Create CNC Job
  527. self.cncjob_label = QtGui.QLabel('<b>Create CNC Job:</b>')
  528. self.cncjob_label.setToolTip(
  529. "Create a CNC Job object\n"
  530. "tracing the contours of this\n"
  531. "Geometry object."
  532. )
  533. self.layout.addWidget(self.cncjob_label)
  534. grid1 = QtGui.QGridLayout()
  535. self.layout.addLayout(grid1)
  536. cutzlabel = QtGui.QLabel('Cut Z:')
  537. cutzlabel.setToolTip(
  538. "Cutting depth (negative)\n"
  539. "below the copper surface."
  540. )
  541. grid1.addWidget(cutzlabel, 0, 0)
  542. self.cutz_entry = LengthEntry()
  543. grid1.addWidget(self.cutz_entry, 0, 1)
  544. # Travel Z
  545. travelzlabel = QtGui.QLabel('Travel Z:')
  546. travelzlabel.setToolTip(
  547. "Height of the tool when\n"
  548. "moving without cutting."
  549. )
  550. grid1.addWidget(travelzlabel, 1, 0)
  551. self.travelz_entry = LengthEntry()
  552. grid1.addWidget(self.travelz_entry, 1, 1)
  553. # Feedrate
  554. frlabel = QtGui.QLabel('Feed Rate:')
  555. frlabel.setToolTip(
  556. "Cutting speed in the XY\n"
  557. "plane in units per minute"
  558. )
  559. grid1.addWidget(frlabel, 2, 0)
  560. self.cncfeedrate_entry = LengthEntry()
  561. grid1.addWidget(self.cncfeedrate_entry, 2, 1)
  562. # Tooldia
  563. tdlabel = QtGui.QLabel('Tool dia:')
  564. tdlabel.setToolTip(
  565. "The diameter of the cutting\n"
  566. "tool (just for display)."
  567. )
  568. grid1.addWidget(tdlabel, 3, 0)
  569. self.cnctooldia_entry = LengthEntry()
  570. grid1.addWidget(self.cnctooldia_entry, 3, 1)
  571. spdlabel = QtGui.QLabel('Spindle speed:')
  572. spdlabel.setToolTip(
  573. "Speed of the spindle\n"
  574. "in RPM (optional)"
  575. )
  576. grid1.addWidget(spdlabel, 4, 0)
  577. self.cncspindlespeed_entry = IntEntry(allow_empty=True)
  578. grid1.addWidget(self.cncspindlespeed_entry, 4, 1)
  579. ## Paint area
  580. self.paint_label = QtGui.QLabel('<b>Paint Area:</b>')
  581. self.paint_label.setToolTip(
  582. "Creates tool paths to cover the\n"
  583. "whole area of a polygon (remove\n"
  584. "all copper). You will be asked\n"
  585. "to click on the desired polygon."
  586. )
  587. self.layout.addWidget(self.paint_label)
  588. grid2 = QtGui.QGridLayout()
  589. self.layout.addLayout(grid2)
  590. # Tool dia
  591. ptdlabel = QtGui.QLabel('Tool dia:')
  592. ptdlabel.setToolTip(
  593. "Diameter of the tool to\n"
  594. "be used in the operation."
  595. )
  596. grid2.addWidget(ptdlabel, 0, 0)
  597. self.painttooldia_entry = LengthEntry()
  598. grid2.addWidget(self.painttooldia_entry, 0, 1)
  599. # Overlap
  600. ovlabel = QtGui.QLabel('Overlap:')
  601. ovlabel.setToolTip(
  602. "How much (fraction) of the tool\n"
  603. "width to overlap each tool pass."
  604. )
  605. grid2.addWidget(ovlabel, 1, 0)
  606. self.paintoverlap_entry = LengthEntry()
  607. grid2.addWidget(self.paintoverlap_entry, 1, 1)
  608. # Margin
  609. marginlabel = QtGui.QLabel('Margin:')
  610. marginlabel.setToolTip(
  611. "Distance by which to avoid\n"
  612. "the edges of the polygon to\n"
  613. "be painted."
  614. )
  615. grid2.addWidget(marginlabel, 2, 0)
  616. self.paintmargin_entry = LengthEntry()
  617. grid2.addWidget(self.paintmargin_entry)
  618. class CNCJobOptionsGroupUI(OptionsGroupUI):
  619. def __init__(self, parent=None):
  620. OptionsGroupUI.__init__(self, "CNC Job Options", parent=None)
  621. ## Plot options
  622. self.plot_options_label = QtGui.QLabel("<b>Plot Options:</b>")
  623. self.layout.addWidget(self.plot_options_label)
  624. grid0 = QtGui.QGridLayout()
  625. self.layout.addLayout(grid0)
  626. # Plot CB
  627. # self.plot_cb = QtGui.QCheckBox('Plot')
  628. self.plot_cb = FCCheckBox('Plot')
  629. self.plot_cb.setToolTip(
  630. "Plot (show) this object."
  631. )
  632. grid0.addWidget(self.plot_cb, 0, 0)
  633. # Tool dia for plot
  634. tdlabel = QtGui.QLabel('Tool dia:')
  635. tdlabel.setToolTip(
  636. "Diameter of the tool to be\n"
  637. "rendered in the plot."
  638. )
  639. grid0.addWidget(tdlabel, 1, 0)
  640. self.tooldia_entry = LengthEntry()
  641. grid0.addWidget(self.tooldia_entry, 1, 1)
  642. ## Export G-Code
  643. self.export_gcode_label = QtGui.QLabel("<b>Export G-Code:</b>")
  644. self.export_gcode_label.setToolTip(
  645. "Export and save G-Code to\n"
  646. "make this object to a file."
  647. )
  648. self.layout.addWidget(self.export_gcode_label)
  649. # Prepend to G-Code
  650. prependlabel = QtGui.QLabel('Prepend to G-Code:')
  651. prependlabel.setToolTip(
  652. "Type here any G-Code commands you would\n"
  653. "like to add at the beginning of the G-Code file."
  654. )
  655. self.layout.addWidget(prependlabel)
  656. self.prepend_text = FCTextArea()
  657. self.layout.addWidget(self.prepend_text)
  658. # Append text to G-Code
  659. appendlabel = QtGui.QLabel('Append to G-Code:')
  660. appendlabel.setToolTip(
  661. "Type here any G-Code commands you would\n"
  662. "like to append to the generated file.\n"
  663. "I.e.: M2 (End of program)"
  664. )
  665. self.layout.addWidget(appendlabel)
  666. self.append_text = FCTextArea()
  667. self.layout.addWidget(self.append_text)
  668. class GlobalOptionsUI(QtGui.QWidget):
  669. """
  670. This is the app and project options editor.
  671. """
  672. def __init__(self, parent=None):
  673. QtGui.QWidget.__init__(self, parent=parent)
  674. layout = QtGui.QVBoxLayout()
  675. self.setLayout(layout)
  676. hlay1 = QtGui.QHBoxLayout()
  677. layout.addLayout(hlay1)
  678. unitslabel = QtGui.QLabel('Units:')
  679. hlay1.addWidget(unitslabel)
  680. self.units_radio = RadioSet([{'label': 'inch', 'value': 'IN'},
  681. {'label': 'mm', 'value': 'MM'}])
  682. hlay1.addWidget(self.units_radio)
  683. ####### Gerber #######
  684. # gerberlabel = QtGui.QLabel('<b>Gerber Options</b>')
  685. # layout.addWidget(gerberlabel)
  686. self.gerber_group = GerberOptionsGroupUI()
  687. # self.gerber_group.setFrameStyle(QtGui.QFrame.StyledPanel)
  688. layout.addWidget(self.gerber_group)
  689. ####### Excellon #######
  690. # excellonlabel = QtGui.QLabel('<b>Excellon Options</b>')
  691. # layout.addWidget(excellonlabel)
  692. self.excellon_group = ExcellonOptionsGroupUI()
  693. # self.excellon_group.setFrameStyle(QtGui.QFrame.StyledPanel)
  694. layout.addWidget(self.excellon_group)
  695. ####### Geometry #######
  696. # geometrylabel = QtGui.QLabel('<b>Geometry Options</b>')
  697. # layout.addWidget(geometrylabel)
  698. self.geometry_group = GeometryOptionsGroupUI()
  699. # self.geometry_group.setStyle(QtGui.QFrame.StyledPanel)
  700. layout.addWidget(self.geometry_group)
  701. ####### CNC #######
  702. # cnclabel = QtGui.QLabel('<b>CNC Job Options</b>')
  703. # layout.addWidget(cnclabel)
  704. self.cncjob_group = CNCJobOptionsGroupUI()
  705. # self.cncjob_group.setStyle(QtGui.QFrame.StyledPanel)
  706. layout.addWidget(self.cncjob_group)
  707. # def main():
  708. #
  709. # app = QtGui.QApplication(sys.argv)
  710. # fc = FlatCAMGUI()
  711. # sys.exit(app.exec_())
  712. #
  713. #
  714. # if __name__ == '__main__':
  715. # main()