- some cleanup in ToolCutout

This commit is contained in:
Marius Stanciu 2019-05-17 03:04:28 +03:00
parent d172a3ca49
commit e0001dc9b7
1 changed files with 60 additions and 62 deletions

View File

@ -5,9 +5,9 @@ from shapely.geometry import box
import gettext import gettext
import FlatCAMTranslation as fcTranslate import FlatCAMTranslation as fcTranslate
import builtins
fcTranslate.apply_language('strings') fcTranslate.apply_language('strings')
import builtins
if '_' not in builtins.__dict__: if '_' not in builtins.__dict__:
_ = gettext.gettext _ = gettext.gettext
@ -23,7 +23,7 @@ class CutOut(FlatCAMTool):
self.app = app self.app = app
self.canvas = app.plotcanvas self.canvas = app.plotcanvas
## Title # Title
title_label = QtWidgets.QLabel("%s" % self.toolName) title_label = QtWidgets.QLabel("%s" % self.toolName)
title_label.setStyleSheet(""" title_label.setStyleSheet("""
QLabel QLabel
@ -34,11 +34,11 @@ class CutOut(FlatCAMTool):
""") """)
self.layout.addWidget(title_label) self.layout.addWidget(title_label)
## Form Layout # Form Layout
form_layout = QtWidgets.QFormLayout() form_layout = QtWidgets.QFormLayout()
self.layout.addLayout(form_layout) self.layout.addLayout(form_layout)
## Type of object to be cutout # Type of object to be cutout
self.type_obj_combo = QtWidgets.QComboBox() self.type_obj_combo = QtWidgets.QComboBox()
self.type_obj_combo.addItem("Gerber") self.type_obj_combo.addItem("Gerber")
self.type_obj_combo.addItem("Excellon") self.type_obj_combo.addItem("Excellon")
@ -60,7 +60,7 @@ class CutOut(FlatCAMTool):
self.type_obj_combo_label.setFixedWidth(60) self.type_obj_combo_label.setFixedWidth(60)
form_layout.addRow(self.type_obj_combo_label, self.type_obj_combo) form_layout.addRow(self.type_obj_combo_label, self.type_obj_combo)
## Object to be cutout # Object to be cutout
self.obj_combo = QtWidgets.QComboBox() self.obj_combo = QtWidgets.QComboBox()
self.obj_combo.setModel(self.app.collection) self.obj_combo.setModel(self.app.collection)
self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))
@ -76,7 +76,7 @@ class CutOut(FlatCAMTool):
self.dia = FCEntry() self.dia = FCEntry()
self.dia_label = QtWidgets.QLabel(_("Tool Dia:")) self.dia_label = QtWidgets.QLabel(_("Tool Dia:"))
self.dia_label.setToolTip( self.dia_label.setToolTip(
_( "Diameter of the tool used to cutout\n" _("Diameter of the tool used to cutout\n"
"the PCB shape out of the surrounding material.") "the PCB shape out of the surrounding material.")
) )
form_layout.addRow(self.dia_label, self.dia) form_layout.addRow(self.dia_label, self.dia)
@ -85,7 +85,7 @@ class CutOut(FlatCAMTool):
self.margin = FCEntry() self.margin = FCEntry()
self.margin_label = QtWidgets.QLabel(_("Margin:")) self.margin_label = QtWidgets.QLabel(_("Margin:"))
self.margin_label.setToolTip( self.margin_label.setToolTip(
_( "Margin over bounds. A positive value here\n" _("Margin over bounds. A positive value here\n"
"will make the cutout of the PCB further from\n" "will make the cutout of the PCB further from\n"
"the actual PCB border") "the actual PCB border")
) )
@ -95,7 +95,7 @@ class CutOut(FlatCAMTool):
self.gapsize = FCEntry() self.gapsize = FCEntry()
self.gapsize_label = QtWidgets.QLabel(_("Gap size:")) self.gapsize_label = QtWidgets.QLabel(_("Gap size:"))
self.gapsize_label.setToolTip( self.gapsize_label.setToolTip(
_( "The size of the bridge gaps in the cutout\n" _("The size of the bridge gaps in the cutout\n"
"used to keep the board connected to\n" "used to keep the board connected to\n"
"the surrounding material (the one \n" "the surrounding material (the one \n"
"from which the PCB is cutout).") "from which the PCB is cutout).")
@ -118,14 +118,14 @@ class CutOut(FlatCAMTool):
) )
form_layout.addRow(self.convex_box_label, self.convex_box) form_layout.addRow(self.convex_box_label, self.convex_box)
## Title2 # Title2
title_param_label = QtWidgets.QLabel("<font size=4><b>%s</b></font>" % _('A. Automatic Bridge Gaps')) title_param_label = QtWidgets.QLabel("<font size=4><b>%s</b></font>" % _('A. Automatic Bridge Gaps'))
title_param_label.setToolTip( title_param_label.setToolTip(
_("This section handle creation of automatic bridge gaps.") _("This section handle creation of automatic bridge gaps.")
) )
self.layout.addWidget(title_param_label) self.layout.addWidget(title_param_label)
## Form Layout # Form Layout
form_layout_2 = QtWidgets.QFormLayout() form_layout_2 = QtWidgets.QFormLayout()
self.layout.addLayout(form_layout_2) self.layout.addLayout(form_layout_2)
@ -151,7 +151,7 @@ class CutOut(FlatCAMTool):
self.gaps.setStyleSheet('background-color: rgb(255,255,255)') self.gaps.setStyleSheet('background-color: rgb(255,255,255)')
form_layout_2.addRow(gaps_label, self.gaps) form_layout_2.addRow(gaps_label, self.gaps)
## Buttons # Buttons
hlay = QtWidgets.QHBoxLayout() hlay = QtWidgets.QHBoxLayout()
self.layout.addLayout(hlay) self.layout.addLayout(hlay)
@ -193,7 +193,7 @@ class CutOut(FlatCAMTool):
) )
hlay2.addWidget(self.rect_cutout_object_btn) hlay2.addWidget(self.rect_cutout_object_btn)
## Title5 # Title5
title_manual_label = QtWidgets.QLabel("<font size=4><b>%s</b></font>" % _('B. Manual Bridge Gaps')) title_manual_label = QtWidgets.QLabel("<font size=4><b>%s</b></font>" % _('B. Manual Bridge Gaps'))
title_manual_label.setToolTip( title_manual_label.setToolTip(
_("This section handle creation of manual bridge gaps.\n" _("This section handle creation of manual bridge gaps.\n"
@ -202,11 +202,11 @@ class CutOut(FlatCAMTool):
) )
self.layout.addWidget(title_manual_label) self.layout.addWidget(title_manual_label)
## Form Layout # Form Layout
form_layout_3 = QtWidgets.QFormLayout() form_layout_3 = QtWidgets.QFormLayout()
self.layout.addLayout(form_layout_3) self.layout.addLayout(form_layout_3)
## Manual Geo Object # Manual Geo Object
self.man_object_combo = QtWidgets.QComboBox() self.man_object_combo = QtWidgets.QComboBox()
self.man_object_combo.setModel(self.app.collection) self.man_object_combo.setModel(self.app.collection)
self.man_object_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex())) self.man_object_combo.setRootModelIndex(self.app.collection.index(2, 0, QtCore.QModelIndex()))
@ -276,7 +276,7 @@ class CutOut(FlatCAMTool):
self.flat_geometry = [] self.flat_geometry = []
## Signals # Signals
self.ff_cutout_object_btn.clicked.connect(self.on_freeform_cutout) self.ff_cutout_object_btn.clicked.connect(self.on_freeform_cutout)
self.rect_cutout_object_btn.clicked.connect(self.on_rectangular_cutout) self.rect_cutout_object_btn.clicked.connect(self.on_rectangular_cutout)
@ -355,7 +355,6 @@ class CutOut(FlatCAMTool):
"Add it and retry.")) "Add it and retry."))
return return
if 0 in {dia}: if 0 in {dia}:
self.app.inform.emit(_("[WARNING_NOTCL] Tool Diameter is zero value. Change it to a positive real number.")) self.app.inform.emit(_("[WARNING_NOTCL] Tool Diameter is zero value. Change it to a positive real number."))
return "Tool Diameter is zero value. Change it to a positive real number." return "Tool Diameter is zero value. Change it to a positive real number."
@ -410,7 +409,7 @@ class CutOut(FlatCAMTool):
gapsize = gapsize / 2 + (dia / 2) gapsize = gapsize / 2 + (dia / 2)
if isinstance(cutout_obj,FlatCAMGeometry): if isinstance(cutout_obj, FlatCAMGeometry):
# rename the obj name so it can be identified as cutout # rename the obj name so it can be identified as cutout
cutout_obj.options["name"] += "_cutout" cutout_obj.options["name"] += "_cutout"
else: else:
@ -866,7 +865,7 @@ class CutOut(FlatCAMTool):
if reset: if reset:
self.flat_geometry = [] self.flat_geometry = []
## If iterable, expand recursively. # If iterable, expand recursively.
try: try:
for geo in geometry: for geo in geometry:
if geo is not None: if geo is not None:
@ -874,7 +873,7 @@ class CutOut(FlatCAMTool):
reset=False, reset=False,
pathonly=pathonly) pathonly=pathonly)
## Not iterable, do the actual indexing and add. # Not iterable, do the actual indexing and add.
except TypeError: except TypeError:
if pathonly and type(geometry) == Polygon: if pathonly and type(geometry) == Polygon:
self.flat_geometry.append(geometry.exterior) self.flat_geometry.append(geometry.exterior)
@ -892,7 +891,7 @@ class CutOut(FlatCAMTool):
i.e. it converts polygons into paths. i.e. it converts polygons into paths.
:param points: The vertices of the polygon. :param points: The vertices of the polygon.
:param geo: Geometry from which to substract. If none, use the solid_geomety property of the object :param solid_geo: Geometry from which to substract. If none, use the solid_geomety property of the object
:return: none :return: none
""" """
@ -913,4 +912,3 @@ class CutOut(FlatCAMTool):
def reset_fields(self): def reset_fields(self):
self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.obj_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))