|
|
@@ -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()))
|