FlatCAMGUI.py 36 KB

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