- some cleanup in ToolCutout

This commit is contained in:
Marius Stanciu
2019-05-17 03:04:28 +03:00
parent d172a3ca49
commit e0001dc9b7

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