2019-09-27 14:45:30 +00:00
|
|
|
# ########################################################## ##
|
|
|
|
# FlatCAM: 2D Post-processing for Manufacturing #
|
|
|
|
# http://flatcam.org #
|
|
|
|
# File Author: Marius Adrian Stanciu (c) #
|
|
|
|
# Date: 09/27/2019 #
|
|
|
|
# MIT Licence #
|
|
|
|
# ########################################################## ##
|
|
|
|
|
|
|
|
from FlatCAMTool import FlatCAMTool
|
|
|
|
from copy import copy, deepcopy
|
|
|
|
from ObjectCollection import *
|
|
|
|
import time
|
2019-09-28 18:29:23 +00:00
|
|
|
from FlatCAMPool import *
|
|
|
|
from os import getpid
|
|
|
|
import copyreg, types, sys
|
2019-09-27 14:45:30 +00:00
|
|
|
|
|
|
|
import gettext
|
|
|
|
import FlatCAMTranslation as fcTranslate
|
|
|
|
import builtins
|
|
|
|
|
|
|
|
fcTranslate.apply_language('strings')
|
|
|
|
if '_' not in builtins.__dict__:
|
|
|
|
_ = gettext.gettext
|
|
|
|
|
|
|
|
|
2019-09-28 18:29:23 +00:00
|
|
|
def _pickle_method(m):
|
|
|
|
class_self = m.im_class if m.im_self is None else m.im_self
|
|
|
|
print(getattr, (class_self, m.im_func.func_name))
|
|
|
|
return getattr, (class_self, m.im_func.func_name)
|
|
|
|
|
|
|
|
|
|
|
|
copyreg.pickle(types.MethodType, _pickle_method)
|
|
|
|
|
|
|
|
|
2019-09-27 14:45:30 +00:00
|
|
|
class RulesCheck(FlatCAMTool):
|
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
toolName = _("Check Rules")
|
2019-09-27 14:45:30 +00:00
|
|
|
|
|
|
|
def __init__(self, app):
|
|
|
|
super(RulesCheck, self).__init__(self)
|
|
|
|
self.app = 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
|
2019-09-27 21:34:18 +00:00
|
|
|
form_layout = QtWidgets.QFormLayout()
|
|
|
|
self.layout.addLayout(form_layout)
|
|
|
|
|
|
|
|
self.gerber_title_lbl = QtWidgets.QLabel('<b>%s</b>:' % _("Gerber Files"))
|
|
|
|
self.gerber_title_lbl.setToolTip(
|
|
|
|
_("Gerber files for which to check rules.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
# Copper object
|
|
|
|
self.copper_object = QtWidgets.QComboBox()
|
|
|
|
self.copper_object.setModel(self.app.collection)
|
|
|
|
self.copper_object.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
|
|
|
self.copper_object.setCurrentIndex(1)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
self.copper_object_lbl = QtWidgets.QLabel('%s:' % _("Copper"))
|
|
|
|
self.copper_object_lbl.setToolTip(
|
2019-09-27 14:45:30 +00:00
|
|
|
_("Object to be panelized. This means that it will\n"
|
|
|
|
"be duplicated in an array of rows and columns.")
|
|
|
|
)
|
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
# SolderMask object
|
|
|
|
self.sm_object = QtWidgets.QComboBox()
|
|
|
|
self.sm_object.setModel(self.app.collection)
|
|
|
|
self.sm_object.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
|
|
|
self.sm_object.setCurrentIndex(1)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
self.sm_object_lbl = QtWidgets.QLabel('%s:' % _("SolderMask"))
|
|
|
|
self.sm_object_lbl.setToolTip(
|
|
|
|
_("Object to be panelized. This means that it will\n"
|
|
|
|
"be duplicated in an array of rows and columns.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
|
|
|
|
# SilkScreen object
|
|
|
|
self.ss_object = QtWidgets.QComboBox()
|
|
|
|
self.ss_object.setModel(self.app.collection)
|
|
|
|
self.ss_object.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
|
|
|
self.ss_object.setCurrentIndex(1)
|
|
|
|
|
|
|
|
self.ss_object_lbl = QtWidgets.QLabel('%s:' % _("Silkscreen"))
|
|
|
|
self.ss_object_lbl.setToolTip(
|
|
|
|
_("Object to be panelized. This means that it will\n"
|
|
|
|
"be duplicated in an array of rows and columns.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
|
|
|
|
# Outline object
|
|
|
|
self.outline_object = QtWidgets.QComboBox()
|
|
|
|
self.outline_object.setModel(self.app.collection)
|
|
|
|
self.outline_object.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
|
|
|
self.outline_object.setCurrentIndex(1)
|
|
|
|
|
|
|
|
self.outline_object_lbl = QtWidgets.QLabel('%s:' % _("Outline"))
|
|
|
|
self.outline_object_lbl.setToolTip(
|
|
|
|
_("Object to be panelized. This means that it will\n"
|
|
|
|
"be duplicated in an array of rows and columns.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
form_layout.addRow(self.gerber_title_lbl)
|
|
|
|
form_layout.addRow(self.copper_object_lbl, self.copper_object)
|
|
|
|
form_layout.addRow(self.sm_object_lbl, self.sm_object)
|
|
|
|
form_layout.addRow(self.ss_object_lbl, self.ss_object)
|
|
|
|
form_layout.addRow(self.outline_object_lbl, self.outline_object)
|
2019-09-27 14:45:30 +00:00
|
|
|
form_layout.addRow(QtWidgets.QLabel(""))
|
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
self.excellon_title_lbl = QtWidgets.QLabel('<b>%s</b>:' % _("Excellon Files"))
|
|
|
|
self.excellon_title_lbl.setToolTip(
|
|
|
|
_("Excellon files for which to check rules.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
|
|
|
|
# Excellon 1 object
|
|
|
|
self.e1_object = QtWidgets.QComboBox()
|
|
|
|
self.e1_object.setModel(self.app.collection)
|
|
|
|
self.e1_object.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex()))
|
|
|
|
self.e1_object.setCurrentIndex(1)
|
|
|
|
|
|
|
|
self.e1_object_lbl = QtWidgets.QLabel('%s:' % _("Excellon 1"))
|
|
|
|
self.e1_object_lbl.setToolTip(
|
|
|
|
_("Object to be panelized. This means that it will\n"
|
|
|
|
"be duplicated in an array of rows and columns.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
|
|
|
|
# Excellon 2 object
|
|
|
|
self.e2_object = QtWidgets.QComboBox()
|
|
|
|
self.e2_object.setModel(self.app.collection)
|
|
|
|
self.e2_object.setRootModelIndex(self.app.collection.index(1, 0, QtCore.QModelIndex()))
|
|
|
|
self.e2_object.setCurrentIndex(1)
|
|
|
|
|
|
|
|
self.e2_object_lbl = QtWidgets.QLabel('%s:' % _("Excellon 2"))
|
|
|
|
self.e2_object_lbl.setToolTip(
|
|
|
|
_("Object to be panelized. This means that it will\n"
|
|
|
|
"be duplicated in an array of rows and columns.")
|
|
|
|
)
|
|
|
|
|
|
|
|
form_layout.addRow(self.excellon_title_lbl)
|
|
|
|
form_layout.addRow(self.e1_object_lbl, self.e1_object)
|
|
|
|
form_layout.addRow(self.e2_object_lbl, self.e2_object)
|
|
|
|
form_layout.addRow(QtWidgets.QLabel(""))
|
|
|
|
|
|
|
|
# Form Layout
|
|
|
|
form_layout_1 = QtWidgets.QFormLayout()
|
|
|
|
self.layout.addLayout(form_layout_1)
|
|
|
|
|
|
|
|
# Copper2copper clearance
|
|
|
|
self.clearance_copper2copper_cb = FCCheckBox('%s:' % _("Copper to copper clearance"))
|
|
|
|
self.clearance_copper2copper_cb.setToolTip(
|
|
|
|
_("This checks if the minimum clearance between copper\n"
|
|
|
|
"features is met.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
form_layout_1.addRow(self.clearance_copper2copper_cb)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
# Copper2copper clearance value
|
|
|
|
self.clearance_copper2copper_entry = FCEntry()
|
|
|
|
self.clearance_copper2copper_lbl = QtWidgets.QLabel('%s:' % _("Min value"))
|
|
|
|
self.clearance_copper2copper_lbl.setToolTip(
|
|
|
|
_("Minimum acceptable clearance value.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
form_layout_1.addRow(self.clearance_copper2copper_lbl, self.clearance_copper2copper_entry)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
self.c2c = OptionalInputSection(
|
|
|
|
self.clearance_copper2copper_cb, [self.clearance_copper2copper_lbl, self.clearance_copper2copper_entry])
|
|
|
|
|
|
|
|
# Copper2soldermask clearance
|
|
|
|
self.clearance_copper2sm_cb = FCCheckBox('%s:' % _("Copper to soldermask clearance"))
|
|
|
|
self.clearance_copper2sm_cb.setToolTip(
|
|
|
|
_("This checks if the minimum clearance between copper\n"
|
|
|
|
"features and soldermask features is met.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
form_layout_1.addRow(self.clearance_copper2sm_cb)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
# Copper2soldermask clearance value
|
|
|
|
self.clearance_copper2sm_entry = FCEntry()
|
|
|
|
self.clearance_copper2sm_lbl = QtWidgets.QLabel('%s:' % _("Min value"))
|
|
|
|
self.clearance_copper2sm_lbl.setToolTip(
|
|
|
|
_("Minimum acceptable clearance value.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
form_layout_1.addRow(self.clearance_copper2sm_lbl, self.clearance_copper2sm_entry)
|
|
|
|
|
|
|
|
self.c2sm = OptionalInputSection(
|
|
|
|
self.clearance_copper2sm_cb, [self.clearance_copper2sm_lbl, self.clearance_copper2sm_entry])
|
|
|
|
|
|
|
|
# Copper2silkscreen clearance
|
|
|
|
self.clearance_copper2sk_cb = FCCheckBox('%s:' % _("Copper to silkscreen clearance"))
|
|
|
|
self.clearance_copper2sk_cb.setToolTip(
|
|
|
|
_("This checks if the minimum clearance between copper\n"
|
|
|
|
"features and silkscreen features is met.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.clearance_copper2sk_cb)
|
|
|
|
|
|
|
|
# Copper2silkscreen clearance value
|
|
|
|
self.clearance_copper2sk_entry = FCEntry()
|
|
|
|
self.clearance_copper2sk_lbl = QtWidgets.QLabel('%s:' % _("Min value"))
|
|
|
|
self.clearance_copper2sk_lbl.setToolTip(
|
|
|
|
_("Minimum acceptable clearance value.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.clearance_copper2sk_lbl, self.clearance_copper2sk_entry)
|
|
|
|
|
|
|
|
self.c2sk = OptionalInputSection(
|
|
|
|
self.clearance_copper2sk_cb, [self.clearance_copper2sk_lbl, self.clearance_copper2sk_entry])
|
|
|
|
|
|
|
|
# Copper2outline clearance
|
|
|
|
self.clearance_copper2ol_cb = FCCheckBox('%s:' % _("Copper to outline clearance"))
|
|
|
|
self.clearance_copper2ol_cb.setToolTip(
|
|
|
|
_("This checks if the minimum clearance between copper\n"
|
|
|
|
"features and the outline is met.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
form_layout_1.addRow(self.clearance_copper2ol_cb)
|
|
|
|
|
|
|
|
# Copper2outline clearance value
|
|
|
|
self.clearance_copper2ol_entry = FCEntry()
|
|
|
|
self.clearance_copper2ol_lbl = QtWidgets.QLabel('%s:' % _("Min value"))
|
|
|
|
self.clearance_copper2ol_lbl.setToolTip(
|
|
|
|
_("Minimum acceptable clearance value.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.clearance_copper2ol_lbl, self.clearance_copper2ol_entry)
|
|
|
|
|
|
|
|
self.c2ol = OptionalInputSection(
|
|
|
|
self.clearance_copper2ol_cb, [self.clearance_copper2ol_lbl, self.clearance_copper2ol_entry])
|
2019-09-27 14:45:30 +00:00
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
# Silkscreen2silkscreen clearance
|
|
|
|
self.clearance_silk2silk_cb = FCCheckBox('%s:' % _("Silkscreen to silkscreen clearance"))
|
|
|
|
self.clearance_silk2silk_cb.setToolTip(
|
|
|
|
_("This checks if the minimum clearance between silkscreen\n"
|
|
|
|
"features and silkscreen features is met.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
form_layout_1.addRow(self.clearance_silk2silk_cb)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
# Copper2silkscreen clearance value
|
|
|
|
self.clearance_silk2silk_entry = FCEntry()
|
|
|
|
self.clearance_silk2silk_lbl = QtWidgets.QLabel('%s:' % _("Min value"))
|
|
|
|
self.clearance_silk2silk_lbl.setToolTip(
|
|
|
|
_("Minimum acceptable clearance value.")
|
2019-09-27 14:45:30 +00:00
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
form_layout_1.addRow(self.clearance_silk2silk_lbl, self.clearance_silk2silk_entry)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
self.s2s = OptionalInputSection(
|
|
|
|
self.clearance_silk2silk_cb, [self.clearance_silk2silk_lbl, self.clearance_silk2silk_entry])
|
|
|
|
|
|
|
|
# Silkscreen2soldermask clearance
|
|
|
|
self.clearance_silk2sm_cb = FCCheckBox('%s:' % _("Silkscreen to soldermask clearance"))
|
|
|
|
self.clearance_silk2sm_cb.setToolTip(
|
|
|
|
_("This checks if the minimum clearance between silkscreen\n"
|
|
|
|
"features and soldermask features is met.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.clearance_silk2sm_cb)
|
|
|
|
|
|
|
|
# Silkscreen2soldermask clearance value
|
|
|
|
self.clearance_silk2sm_entry = FCEntry()
|
|
|
|
self.clearance_silk2sm_lbl = QtWidgets.QLabel('%s:' % _("Min value"))
|
|
|
|
self.clearance_silk2sm_lbl.setToolTip(
|
|
|
|
_("Minimum acceptable clearance value.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.clearance_silk2sm_lbl, self.clearance_silk2sm_entry)
|
|
|
|
|
|
|
|
self.s2sm = OptionalInputSection(
|
|
|
|
self.clearance_silk2sm_cb, [self.clearance_silk2sm_lbl, self.clearance_silk2sm_entry])
|
|
|
|
|
|
|
|
# Soldermask2soldermask clearance
|
|
|
|
self.clearance_sm2sm_cb = FCCheckBox('%s:' % _("Soldermask to soldermask clearance"))
|
|
|
|
self.clearance_sm2sm_cb.setToolTip(
|
|
|
|
_("This checks if the minimum clearance between soldermask\n"
|
|
|
|
"features and soldermask features is met.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.clearance_sm2sm_cb)
|
|
|
|
|
|
|
|
# Soldermask2soldermask clearance value
|
|
|
|
self.clearance_sm2sm_entry = FCEntry()
|
|
|
|
self.clearance_sm2sm_lbl = QtWidgets.QLabel('%s:' % _("Min value"))
|
|
|
|
self.clearance_sm2sm_lbl.setToolTip(
|
|
|
|
_("Minimum acceptable clearance value.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.clearance_sm2sm_lbl, self.clearance_sm2sm_entry)
|
|
|
|
|
|
|
|
self.sm2sm = OptionalInputSection(
|
|
|
|
self.clearance_sm2sm_cb, [self.clearance_sm2sm_lbl, self.clearance_sm2sm_entry])
|
|
|
|
|
|
|
|
form_layout_1.addRow(QtWidgets.QLabel(""))
|
|
|
|
|
|
|
|
# Drill2Drill clearance
|
|
|
|
self.clearance_d2d_cb = FCCheckBox('%s:' % _("Drill hole to drill hole clearance"))
|
|
|
|
self.clearance_d2d_cb.setToolTip(
|
|
|
|
_("This checks if the minimum clearance between a drill hole\n"
|
|
|
|
"and another drill hole is met.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.clearance_d2d_cb)
|
|
|
|
|
|
|
|
# Drill2Drill clearance value
|
|
|
|
self.clearance_d2d_entry = FCEntry()
|
|
|
|
self.clearance_d2d_lbl = QtWidgets.QLabel('%s:' % _("Min value"))
|
|
|
|
self.clearance_d2d_lbl.setToolTip(
|
|
|
|
_("Minimum acceptable clearance value.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.clearance_d2d_lbl, self.clearance_d2d_entry)
|
|
|
|
|
|
|
|
self.d2d = OptionalInputSection(
|
|
|
|
self.clearance_d2d_cb, [self.clearance_d2d_lbl, self.clearance_d2d_entry])
|
|
|
|
|
|
|
|
# Ring integrity check
|
|
|
|
self.ring_integrity_cb = FCCheckBox('%s:' % _("Ring integrity check"))
|
|
|
|
self.ring_integrity_cb.setToolTip(
|
|
|
|
_("This checks if the minimum copper ring left by drilling\n"
|
|
|
|
"a hole into a pad is met.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.ring_integrity_cb)
|
|
|
|
|
|
|
|
# Ring integrity value
|
|
|
|
self.ring_integrity_entry = FCEntry()
|
|
|
|
self.ring_integrity_lbl = QtWidgets.QLabel('%s:' % _("Min value"))
|
|
|
|
self.ring_integrity_lbl.setToolTip(
|
|
|
|
_("Minimum acceptable ring value.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.ring_integrity_lbl, self.ring_integrity_entry)
|
|
|
|
|
|
|
|
self.d2d = OptionalInputSection(
|
|
|
|
self.ring_integrity_cb, [self.ring_integrity_lbl, self.ring_integrity_entry])
|
|
|
|
|
|
|
|
# Drill holes overlap check
|
|
|
|
self.drill_overlap_cb = FCCheckBox('%s:' % _("Drill hole overlap check"))
|
|
|
|
self.drill_overlap_cb.setToolTip(
|
|
|
|
_("This checks if drill holes are overlapping\n"
|
|
|
|
"one over another.")
|
|
|
|
)
|
|
|
|
form_layout_1.addRow(self.drill_overlap_cb)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
|
|
|
# Buttons
|
|
|
|
hlay_2 = QtWidgets.QHBoxLayout()
|
|
|
|
self.layout.addLayout(hlay_2)
|
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
# hlay_2.addStretch()
|
|
|
|
self.run_button = QtWidgets.QPushButton(_("Run Rules Check"))
|
|
|
|
self.run_button.setToolTip(
|
2019-09-27 14:45:30 +00:00
|
|
|
_("Panelize the specified object around the specified box.\n"
|
|
|
|
"In other words it creates multiple copies of the source object,\n"
|
|
|
|
"arranged in a 2D array of rows and columns.")
|
|
|
|
)
|
2019-09-27 21:34:18 +00:00
|
|
|
hlay_2.addWidget(self.run_button)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
|
|
|
self.layout.addStretch()
|
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
# #######################################################
|
|
|
|
# ################ SIGNALS ##############################
|
|
|
|
# #######################################################
|
2019-09-28 18:29:23 +00:00
|
|
|
self.run_button.clicked.connect(self.execute)
|
2019-09-27 21:34:18 +00:00
|
|
|
# self.app.collection.rowsInserted.connect(self.on_object_loaded)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
|
|
|
# list to hold the temporary objects
|
|
|
|
self.objs = []
|
|
|
|
|
|
|
|
# final name for the panel object
|
|
|
|
self.outname = ""
|
|
|
|
|
|
|
|
# flag to signal the constrain was activated
|
|
|
|
self.constrain_flag = False
|
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
# def on_object_loaded(self, index, row):
|
|
|
|
# print(index.internalPointer().child_items[row].obj.options['name'], index.data())
|
|
|
|
|
2019-09-27 14:45:30 +00:00
|
|
|
def run(self, toggle=True):
|
2019-09-27 21:34:18 +00:00
|
|
|
self.app.report_usage("ToolRulesCheck()")
|
2019-09-27 14:45:30 +00:00
|
|
|
|
|
|
|
if toggle:
|
|
|
|
# if the splitter is hidden, display it, else hide it but only if the current widget is the same
|
|
|
|
if self.app.ui.splitter.sizes()[0] == 0:
|
|
|
|
self.app.ui.splitter.setSizes([1, 1])
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
if self.app.ui.tool_scroll_area.widget().objectName() == self.toolName:
|
|
|
|
# if tab is populated with the tool but it does not have the focus, focus on it
|
|
|
|
if not self.app.ui.notebook.currentWidget() is self.app.ui.tool_tab:
|
|
|
|
# focus on Tool Tab
|
|
|
|
self.app.ui.notebook.setCurrentWidget(self.app.ui.tool_tab)
|
|
|
|
else:
|
|
|
|
self.app.ui.splitter.setSizes([0, 1])
|
|
|
|
except AttributeError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
if self.app.ui.splitter.sizes()[0] == 0:
|
|
|
|
self.app.ui.splitter.setSizes([1, 1])
|
|
|
|
|
|
|
|
FlatCAMTool.run(self)
|
|
|
|
self.set_tool_ui()
|
|
|
|
|
2019-09-27 21:34:18 +00:00
|
|
|
self.app.ui.notebook.setTabText(2, _("Rules Tool"))
|
2019-09-27 14:45:30 +00:00
|
|
|
|
|
|
|
def install(self, icon=None, separator=None, **kwargs):
|
2019-09-27 21:34:18 +00:00
|
|
|
FlatCAMTool.install(self, icon, separator, shortcut='ALT+R', **kwargs)
|
2019-09-27 14:45:30 +00:00
|
|
|
|
|
|
|
def set_tool_ui(self):
|
|
|
|
self.reset_fields()
|
|
|
|
|
2019-09-28 18:29:23 +00:00
|
|
|
def foo(self, bar, baz):
|
|
|
|
print("start", getpid())
|
|
|
|
bar = bar ** 2
|
|
|
|
print(bar, getpid())
|
|
|
|
print("end", getpid())
|
|
|
|
return bar, baz
|
|
|
|
|
|
|
|
def execute(self):
|
|
|
|
log.debug("started")
|
|
|
|
self.pool = Pool()
|
|
|
|
log.debug("executing")
|
|
|
|
self.results = list()
|
|
|
|
i = 50
|
|
|
|
while i < 100:
|
|
|
|
j = i + 1
|
|
|
|
while j < 150:
|
|
|
|
self.results.append(self.pool.apply_async(self.foo, args=(i, j)))
|
|
|
|
j = j + 1
|
|
|
|
i = i + 1
|
|
|
|
|
|
|
|
output = [p.get() for p in self.results]
|
|
|
|
print(output)
|
|
|
|
log.debug("finished")
|
|
|
|
|
|
|
|
def __getstate__(self):
|
|
|
|
self_dict = self.__dict__.copy()
|
|
|
|
del self_dict['pool']
|
|
|
|
return self_dict
|
2019-09-27 14:45:30 +00:00
|
|
|
|
|
|
|
def reset_fields(self):
|
2019-09-27 21:34:18 +00:00
|
|
|
# self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
|
|
|
# self.box_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
|
|
|
|
pass
|