FlatCAMGUI.py 37 KB

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