From 89052379b2f68a0b4e2b0da5a209f5f763af7cc0 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 19 Feb 2019 17:48:24 +0200 Subject: [PATCH] - started to work on Solder Paste Dispensing Tool --- FlatCAMApp.py | 5 +- README.md | 1 + flatcamTools/ToolCutOut.py | 3 +- flatcamTools/ToolSolderPaste.py | 272 ++++++++++++++++++++++++++++++++ flatcamTools/__init__.py | 1 + 5 files changed, 280 insertions(+), 2 deletions(-) create mode 100644 flatcamTools/ToolSolderPaste.py diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 311a7141..f2f969f8 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -1580,7 +1580,10 @@ class App(QtCore.QObject): self.panelize_tool.install(icon=QtGui.QIcon('share/panel16.png')) self.film_tool = Film(self) - self.film_tool.install(icon=QtGui.QIcon('share/film16.png'), separator=True) + self.film_tool.install(icon=QtGui.QIcon('share/film16.png')) + + self.paste_tool = ToolSolderPaste(self) + self.paste_tool.install(icon=QtGui.QIcon('share/film16.png'), separator=True) self.move_tool = ToolMove(self) self.move_tool.install(icon=QtGui.QIcon('share/move16.png'), pos=self.ui.menuedit, diff --git a/README.md b/README.md index 74d40d84..638cb0e6 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ CAD program, and create G-Code for Isolation routing. - removed the Open Gerber with 'follow' menu entry and also the open_gerber Tcl Command attribute 'follow'. This is no longer required because now the follow_geometry is stored by default in a Gerber object attribute gerber_obj.follow_geometry - added a new parameter for the Tcl CommandIsolate, named: 'follow'. When follow = 1 (True) the resulting geometry will follow the Gerber paths. - added a new setting in Edit -> Preferences -> General that allow to select the type of saving for the FlatCAM project: either compressed or uncompressed. Compression introduce an time overhead to the saving/restoring of a FlatCAM project. +- started to work on Solder Paste Dispensing Tool 18.02.2019 diff --git a/flatcamTools/ToolCutOut.py b/flatcamTools/ToolCutOut.py index 5b248ce2..d6f901f4 100644 --- a/flatcamTools/ToolCutOut.py +++ b/flatcamTools/ToolCutOut.py @@ -3,7 +3,7 @@ from copy import copy,deepcopy from ObjectCollection import * from FlatCAMApp import * from PyQt5 import QtGui, QtCore, QtWidgets -from GUIElements import IntEntry, RadioSet, LengthEntry +from GUIElements import IntEntry, RadioSet, LengthEntry, FloatEntry from FlatCAMObj import FlatCAMGeometry, FlatCAMExcellon, FlatCAMGerber @@ -472,3 +472,4 @@ class ToolCutOut(FlatCAMTool): def reset_fields(self): self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) + diff --git a/flatcamTools/ToolSolderPaste.py b/flatcamTools/ToolSolderPaste.py new file mode 100644 index 00000000..9fbefacb --- /dev/null +++ b/flatcamTools/ToolSolderPaste.py @@ -0,0 +1,272 @@ +from FlatCAMTool import FlatCAMTool +from copy import copy,deepcopy +from ObjectCollection import * +from FlatCAMApp import * +from PyQt5 import QtGui, QtCore, QtWidgets +from GUIElements import IntEntry, RadioSet, LengthEntry + +from FlatCAMObj import FlatCAMGeometry, FlatCAMExcellon, FlatCAMGerber + + +class ToolSolderPaste(FlatCAMTool): + + toolName = "Solder Paste Tool" + + def __init__(self, app): + FlatCAMTool.__init__(self, app) + + ## Title + title_label = QtWidgets.QLabel("%s" % self.toolName) + title_label.setStyleSheet(""" + QLabel + { + font-size: 16px; + font-weight: bold; + } + """) + self.layout.addWidget(title_label) + + ## Form Layout + form_layout = QtWidgets.QFormLayout() + self.layout.addLayout(form_layout) + + ## Type of object to be cutout + self.type_obj_combo = QtWidgets.QComboBox() + self.type_obj_combo.addItem("Gerber") + self.type_obj_combo.addItem("Excellon") + self.type_obj_combo.addItem("Geometry") + + # we get rid of item1 ("Excellon") as it is not suitable for creating solderpaste + self.type_obj_combo.view().setRowHidden(1, True) + self.type_obj_combo.setItemIcon(0, QtGui.QIcon("share/flatcam_icon16.png")) + self.type_obj_combo.setItemIcon(2, QtGui.QIcon("share/geometry16.png")) + + self.type_obj_combo_label = QtWidgets.QLabel("Object Type:") + self.type_obj_combo_label.setToolTip( + "Specify the type of object to be used for solder paste dispense.\n" + "It can be of type: Gerber or Geometry.\n" + "What is selected here will dictate the kind\n" + "of objects that will populate the 'Object' combobox." + ) + form_layout.addRow(self.type_obj_combo_label, self.type_obj_combo) + + ## Object to be used for solderpaste dispensing + self.obj_combo = QtWidgets.QComboBox() + self.obj_combo.setModel(self.app.collection) + self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) + self.obj_combo.setCurrentIndex(1) + + self.object_label = QtWidgets.QLabel("Object:") + self.object_label.setToolTip( + "Solder paste object. " + ) + form_layout.addRow(self.object_label, self.obj_combo) + + # Offset distance + self.offset_entry = FloatEntry() + self.offset_entry.setValidator(QtGui.QDoubleValidator(-99.9999, 0.0000, 4)) + self.offset_label = QtWidgets.QLabel(" Solder Offset:") + self.offset_label.setToolTip( + "The offset for the solder paste.\n" + "Due of the diameter of the solder paste dispenser\n" + "we need to adjust the quantity of solder paste\n" + "so it will not overflow over the pad." + ) + form_layout.addRow(self.offset_label, self.offset_entry) + + # Z dispense start + self.z_start_entry = FCEntry() + self.z_start_label = QtWidgets.QLabel("Z Dispense Start:") + self.z_start_label.setToolTip( + "The size of the gaps in the cutout\n" + "used to keep the board connected to\n" + "the surrounding material (the one \n" + "from which the PCB is cutout)." + ) + form_layout.addRow(self.z_start_label, self.z_start_entry) + + # Z dispense + self.z_dispense_entry = FCEntry() + self.z_dispense_label = QtWidgets.QLabel("Z Dispense:") + self.z_dispense_label.setToolTip( + "Margin over bounds. A positive value here\n" + "will make the cutout of the PCB further from\n" + "the actual PCB border" + ) + form_layout.addRow(self.z_dispense_label, self.z_dispense_entry) + + # Z dispense stop + self.z_stop_entry = FCEntry() + self.z_stop_label = QtWidgets.QLabel("Z Dispense Stop:") + self.z_stop_label.setToolTip( + "The size of the gaps in the cutout\n" + "used to keep the board connected to\n" + "the surrounding material (the one \n" + "from which the PCB is cutout)." + ) + form_layout.addRow(self.z_stop_label, self.z_stop_entry) + + # Z travel + self.z_travel_entry = FCEntry() + self.z_travel_label = QtWidgets.QLabel("Z Travel:") + self.z_travel_label.setToolTip( + "The size of the gaps in the cutout\n" + "used to keep the board connected to\n" + "the surrounding material (the one \n" + "from which the PCB is cutout)." + ) + form_layout.addRow(self.z_travel_label, self.z_travel_entry) + + # Feedrate X-Y + self.frxy_entry = FCEntry() + self.frxy_label = QtWidgets.QLabel("Feedrate X-Y:") + self.frxy_label.setToolTip( + "The size of the gaps in the cutout\n" + "used to keep the board connected to\n" + "the surrounding material (the one \n" + "from which the PCB is cutout)." + ) + form_layout.addRow(self.frxy_label, self.frxy_entry) + + # Feedrate Z + self.frz_entry = FCEntry() + self.frz_label = QtWidgets.QLabel("Feedrate Z:") + self.frz_label.setToolTip( + "The size of the gaps in the cutout\n" + "used to keep the board connected to\n" + "the surrounding material (the one \n" + "from which the PCB is cutout)." + ) + form_layout.addRow(self.frz_label, self.frz_entry) + + # Spindle Speed Forward + self.speedfwd_entry = FCEntry() + self.speedfwd_label = QtWidgets.QLabel("Spindle Speed FWD:") + self.speedfwd_label.setToolTip( + "The size of the gaps in the cutout\n" + "used to keep the board connected to\n" + "the surrounding material (the one \n" + "from which the PCB is cutout)." + ) + form_layout.addRow(self.speedfwd_label, self.speedfwd_entry) + + # Dwell Forward + self.dwellfwd_entry = FCEntry() + self.dwellfwd_label = QtWidgets.QLabel("Dwell FWD:") + self.dwellfwd_label.setToolTip( + "The size of the gaps in the cutout\n" + "used to keep the board connected to\n" + "the surrounding material (the one \n" + "from which the PCB is cutout)." + ) + form_layout.addRow(self.dwellfwd_label, self.dwellfwd_entry) + + # Spindle Speed Reverse + self.speedrev_entry = FCEntry() + self.speedrev_label = QtWidgets.QLabel("Spindle Speed REV:") + self.speedrev_label.setToolTip( + "The size of the gaps in the cutout\n" + "used to keep the board connected to\n" + "the surrounding material (the one \n" + "from which the PCB is cutout)." + ) + form_layout.addRow(self.speedrev_label, self.speedrev_entry) + + # Dwell Reverse + self.dwellrev_entry = FCEntry() + self.dwellrev_label = QtWidgets.QLabel("Dwell REV:") + self.dwellrev_label.setToolTip( + "The size of the gaps in the cutout\n" + "used to keep the board connected to\n" + "the surrounding material (the one \n" + "from which the PCB is cutout)." + ) + form_layout.addRow(self.dwellrev_label, self.dwellrev_entry) + + # Postprocessors + pp_label = QtWidgets.QLabel('PostProcessors:') + pp_label.setToolTip( + "Files that control the GCoe generation." + ) + + self.pp_combo = FCComboBox() + pp_items = [1, 2, 3, 4, 5] + for it in pp_items: + self.pp_combo.addItem(str(it)) + self.pp_combo.setStyleSheet('background-color: rgb(255,255,255)') + form_layout.addRow(pp_label, self.pp_combo) + + ## Buttons + hlay = QtWidgets.QHBoxLayout() + self.layout.addLayout(hlay) + + hlay.addStretch() + self.soldergeo_btn = QtWidgets.QPushButton("Generate Geo") + self.soldergeo_btn.setToolTip( + "Generate solder paste dispensing geometry." + ) + hlay.addWidget(self.soldergeo_btn) + + + self.solder_gcode = QtWidgets.QPushButton("Generate GCode") + self.solder_gcode.setToolTip( + "Generate GCode to dispense Solder Paste\n" + "on PCB pads." + ) + hlay.addWidget(self.solder_gcode) + + + self.layout.addStretch() + + ## Signals + self.soldergeo_btn.clicked.connect(self.on_create_geo) + self.solder_gcode.clicked.connect(self.on_create_gcode) + + self.type_obj_combo.currentIndexChanged.connect(self.on_type_obj_index_changed) + + def on_type_obj_index_changed(self, index): + obj_type = self.type_obj_combo.currentIndex() + self.obj_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex())) + self.obj_combo.setCurrentIndex(0) + + def run(self): + self.app.report_usage("ToolSolderPaste()") + + FlatCAMTool.run(self) + self.set_tool_ui() + + # if the splitter us hidden, display it + if self.app.ui.splitter.sizes()[0] == 0: + self.app.ui.splitter.setSizes([1, 1]) + + self.app.ui.notebook.setTabText(2, "SolderPaste Tool") + + def install(self, icon=None, separator=None, **kwargs): + FlatCAMTool.install(self, icon, separator, shortcut='ALT+K', **kwargs) + + def set_tool_ui(self): + self.reset_fields() + pass + + def on_create_geo(self): + name = self.obj_combo.currentText() + + def geo_init(geo_obj, app_obj): + pass + + # self.app.new_object("geometry", name + "_cutout", geo_init) + # self.app.inform.emit("[success] Rectangular CutOut operation finished.") + # self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab) + + def on_create_gcode(self): + name = self.obj_combo.currentText() + + def geo_init(geo_obj, app_obj): + pass + + # self.app.new_object("geometry", name + "_cutout", geo_init) + # self.app.inform.emit("[success] Rectangular CutOut operation finished.") + # self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab) + + def reset_fields(self): + self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) diff --git a/flatcamTools/__init__.py b/flatcamTools/__init__.py index e5e1e84f..8ec21eb7 100644 --- a/flatcamTools/__init__.py +++ b/flatcamTools/__init__.py @@ -13,5 +13,6 @@ from flatcamTools.ToolImage import ToolImage from flatcamTools.ToolPaint import ToolPaint from flatcamTools.ToolNonCopperClear import NonCopperClear from flatcamTools.ToolTransform import ToolTransform +from flatcamTools.ToolSolderPaste import ToolSolderPaste from flatcamTools.ToolShell import FCShell