FlatCAMGUI.py 30 KB

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