- some PEP8 corrections

This commit is contained in:
Marius Stanciu
2019-07-15 01:16:02 +03:00
parent 43cb92e1d8
commit 7c0a8b73e3
9 changed files with 220 additions and 222 deletions

View File

@@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
================================================= =================================================
15.07.2019
- some PEP8 corrections
13.07.2019 13.07.2019
- fixed a possible issue in Gerber Object class - fixed a possible issue in Gerber Object class

View File

@@ -42,9 +42,9 @@ class ToolCalculator(FlatCAMTool):
""") """)
self.layout.addWidget(title_label) self.layout.addWidget(title_label)
#################### ## # #####################
# ## Units Calculator # ## # ## Units Calculator #
#################### ## # #####################
self.unists_spacer_label = QtWidgets.QLabel(" ") self.unists_spacer_label = QtWidgets.QLabel(" ")
self.layout.addWidget(self.unists_spacer_label) self.layout.addWidget(self.unists_spacer_label)
@@ -53,14 +53,14 @@ class ToolCalculator(FlatCAMTool):
units_label = QtWidgets.QLabel("<font size=3><b>%s</b></font>" % self.unitsName) units_label = QtWidgets.QLabel("<font size=3><b>%s</b></font>" % self.unitsName)
self.layout.addWidget(units_label) self.layout.addWidget(units_label)
#Grid Layout # Grid Layout
grid_units_layout = QtWidgets.QGridLayout() grid_units_layout = QtWidgets.QGridLayout()
self.layout.addLayout(grid_units_layout) self.layout.addLayout(grid_units_layout)
inch_label = QtWidgets.QLabel("INCH") inch_label = QtWidgets.QLabel("INCH")
mm_label = QtWidgets.QLabel("MM") mm_label = QtWidgets.QLabel("MM")
grid_units_layout.addWidget(mm_label, 0, 0) grid_units_layout.addWidget(mm_label, 0, 0)
grid_units_layout.addWidget( inch_label, 0, 1) grid_units_layout.addWidget(inch_label, 0, 1)
self.inch_entry = FCEntry() self.inch_entry = FCEntry()
# self.inch_entry.setFixedWidth(70) # self.inch_entry.setFixedWidth(70)
@@ -75,11 +75,9 @@ class ToolCalculator(FlatCAMTool):
grid_units_layout.addWidget(self.mm_entry, 1, 0) grid_units_layout.addWidget(self.mm_entry, 1, 0)
grid_units_layout.addWidget(self.inch_entry, 1, 1) grid_units_layout.addWidget(self.inch_entry, 1, 1)
# ##############################
########################## ## # ## V-shape Tool Calculator ###
# ## V-shape Tool Calculator # ## # ##############################
########################## ##
self.v_shape_spacer_label = QtWidgets.QLabel(" ") self.v_shape_spacer_label = QtWidgets.QLabel(" ")
self.layout.addWidget(self.v_shape_spacer_label) self.layout.addWidget(self.v_shape_spacer_label)
@@ -121,7 +119,6 @@ class ToolCalculator(FlatCAMTool):
"In the CNCJob section it is called >Tool dia<.")) "In the CNCJob section it is called >Tool dia<."))
# self.effectiveToolDia_entry.setEnabled(False) # self.effectiveToolDia_entry.setEnabled(False)
form_layout.addRow(self.tipDia_label, self.tipDia_entry) form_layout.addRow(self.tipDia_label, self.tipDia_entry)
form_layout.addRow(self.tipAngle_label, self.tipAngle_entry) form_layout.addRow(self.tipAngle_label, self.tipAngle_entry)
form_layout.addRow(self.cutDepth_label, self.cutDepth_entry) form_layout.addRow(self.cutDepth_label, self.cutDepth_entry)
@@ -138,10 +135,9 @@ class ToolCalculator(FlatCAMTool):
form_layout.addRow(self.empty_label, self.calculate_vshape_button) form_layout.addRow(self.empty_label, self.calculate_vshape_button)
# ####################################
################################## ## # ## ElectroPlating Tool Calculator ##
# ## ElectroPlating Tool Calculator # ## # ####################################
################################## ##
self.plate_spacer_label = QtWidgets.QLabel(" ") self.plate_spacer_label = QtWidgets.QLabel(" ")
self.layout.addWidget(self.plate_spacer_label) self.layout.addWidget(self.plate_spacer_label)
@@ -177,7 +173,6 @@ class ToolCalculator(FlatCAMTool):
self.cdensity_label.setToolTip(_("Current density to pass through the board. \n" self.cdensity_label.setToolTip(_("Current density to pass through the board. \n"
"In Amps per Square Feet ASF.")) "In Amps per Square Feet ASF."))
self.growth_label = QtWidgets.QLabel(_("Copper Growth:")) self.growth_label = QtWidgets.QLabel(_("Copper Growth:"))
self.growth_entry = FCEntry() self.growth_entry = FCEntry()
# self.growth_entry.setFixedWidth(70) # self.growth_entry.setFixedWidth(70)
@@ -214,7 +209,7 @@ class ToolCalculator(FlatCAMTool):
self.calculate_plate_button = QtWidgets.QPushButton(_("Calculate")) self.calculate_plate_button = QtWidgets.QPushButton(_("Calculate"))
# self.calculate_button.setFixedWidth(70) # self.calculate_button.setFixedWidth(70)
self.calculate_plate_button.setToolTip( self.calculate_plate_button.setToolTip(
_("Calculate the current intensity value and the procedure time,\n " _("Calculate the current intensity value and the procedure time,\n"
"depending on the parameters above") "depending on the parameters above")
) )
self.empty_label_2 = QtWidgets.QLabel(" ") self.empty_label_2 = QtWidgets.QLabel(" ")
@@ -223,6 +218,8 @@ class ToolCalculator(FlatCAMTool):
self.layout.addStretch() self.layout.addStretch()
self.units = ''
# ## Signals # ## Signals
self.cutDepth_entry.textChanged.connect(self.on_calculate_tool_dia) self.cutDepth_entry.textChanged.connect(self.on_calculate_tool_dia)
self.cutDepth_entry.editingFinished.connect(self.on_calculate_tool_dia) self.cutDepth_entry.editingFinished.connect(self.on_calculate_tool_dia)

View File

@@ -643,7 +643,6 @@ class CutOut(FlatCAMTool):
geo_obj.solid_geometry = deepcopy(solid_geo) geo_obj.solid_geometry = deepcopy(solid_geo)
geo_obj.options['cnctooldia'] = str(dia) geo_obj.options['cnctooldia'] = str(dia)
outname = cutout_obj.options["name"] + "_cutout" outname = cutout_obj.options["name"] + "_cutout"
self.app.new_object('geometry', outname, geo_init) self.app.new_object('geometry', outname, geo_init)

View File

@@ -6,9 +6,9 @@ from PyQt5 import QtCore
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
@@ -188,11 +188,10 @@ class DblSidedTool(FlatCAMTool):
self.box_combo.hide() self.box_combo.hide()
self.box_combo_type.hide() self.box_combo_type.hide()
# ## Alignment holes # ## Alignment holes
self.ah_label = QtWidgets.QLabel("<b>%s</b>" % _('Alignment Drill Coordinates:')) self.ah_label = QtWidgets.QLabel("<b>%s</b>" % _('Alignment Drill Coordinates:'))
self.ah_label.setToolTip( self.ah_label.setToolTip(
_( "Alignment holes (x1, y1), (x2, y2), ... " _("Alignment holes (x1, y1), (x2, y2), ... "
"on one side of the mirror axis. For each set of (x, y) coordinates\n" "on one side of the mirror axis. For each set of (x, y) coordinates\n"
"entered here, a pair of drills will be created:\n\n" "entered here, a pair of drills will be created:\n\n"
"- one drill at the coordinates from the field\n" "- one drill at the coordinates from the field\n"
@@ -372,7 +371,8 @@ class DblSidedTool(FlatCAMTool):
# holes = self.alignment_holes.get_value() # holes = self.alignment_holes.get_value()
holes = eval('[{}]'.format(self.alignment_holes.text())) holes = eval('[{}]'.format(self.alignment_holes.text()))
if not holes: if not holes:
self.app.inform.emit(_("[WARNING_NOTCL] There are no Alignment Drill Coordinates to use. Add them and retry.")) self.app.inform.emit(_("[WARNING_NOTCL] There are no Alignment Drill Coordinates to use. "
"Add them and retry."))
return return
drills = [] drills = []
@@ -553,8 +553,4 @@ class DblSidedTool(FlatCAMTool):
self.box_combo.setCurrentIndex(0) self.box_combo.setCurrentIndex(0)
self.box_combo_type.setCurrentIndex(0) self.box_combo_type.setCurrentIndex(0)
self.drill_values = "" self.drill_values = ""

View File

@@ -13,9 +13,9 @@ from PyQt5 import QtGui, QtCore, QtWidgets
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
@@ -221,13 +221,13 @@ class Film(FlatCAMTool):
def on_film_creation(self): def on_film_creation(self):
try: try:
name = self.tf_object_combo.currentText() name = self.tf_object_combo.currentText()
except: except Exception as e:
self.app.inform.emit(_("[ERROR_NOTCL] No FlatCAM object selected. Load an object for Film and retry.")) self.app.inform.emit(_("[ERROR_NOTCL] No FlatCAM object selected. Load an object for Film and retry."))
return return
try: try:
boxname = self.tf_box_combo.currentText() boxname = self.tf_box_combo.currentText()
except: except Exception as e:
self.app.inform.emit(_("[ERROR_NOTCL] No FlatCAM object selected. Load an object for Box and retry.")) self.app.inform.emit(_("[ERROR_NOTCL] No FlatCAM object selected. Load an object for Box and retry."))
return return

View File

@@ -13,9 +13,9 @@ from PyQt5 import QtGui, QtWidgets
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
@@ -52,7 +52,7 @@ class ToolImage(FlatCAMTool):
self.tf_type_obj_combo_label = QtWidgets.QLabel(_("Object Type:")) self.tf_type_obj_combo_label = QtWidgets.QLabel(_("Object Type:"))
self.tf_type_obj_combo_label.setToolTip( self.tf_type_obj_combo_label.setToolTip(
_( "Specify the type of object to create from the image.\n" _("Specify the type of object to create from the image.\n"
"It can be of type: Gerber or Geometry.") "It can be of type: Gerber or Geometry.")
) )
@@ -62,7 +62,7 @@ class ToolImage(FlatCAMTool):
self.dpi_entry = IntEntry() self.dpi_entry = IntEntry()
self.dpi_label = QtWidgets.QLabel(_("DPI value:")) self.dpi_label = QtWidgets.QLabel(_("DPI value:"))
self.dpi_label.setToolTip( self.dpi_label.setToolTip(
_( "Specify a DPI value for the image.") _("Specify a DPI value for the image.")
) )
ti_form_layout.addRow(self.dpi_label, self.dpi_entry) ti_form_layout.addRow(self.dpi_label, self.dpi_entry)
@@ -191,27 +191,27 @@ class ToolImage(FlatCAMTool):
mask = [] mask = []
self.app.log.debug("on_file_importimage()") self.app.log.debug("on_file_importimage()")
filter = "Image Files(*.BMP *.PNG *.JPG *.JPEG);;" \ _filter = "Image Files(*.BMP *.PNG *.JPG *.JPEG);;" \
"Bitmap File (*.BMP);;" \ "Bitmap File (*.BMP);;" \
"PNG File (*.PNG);;" \ "PNG File (*.PNG);;" \
"Jpeg File (*.JPG);;" \ "Jpeg File (*.JPG);;" \
"All Files (*.*)" "All Files (*.*)"
try: try:
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Import IMAGE"), filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Import IMAGE"),
directory=self.app.get_last_folder(), filter=filter) directory=self.app.get_last_folder(), filter=_filter)
except TypeError: except TypeError:
filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Import IMAGE"), filter=filter) filename, _f = QtWidgets.QFileDialog.getOpenFileName(caption=_("Import IMAGE"), filter=filter)
filename = str(filename) filename = str(filename)
type = self.tf_type_obj_combo.get_value().lower() type_obj = self.tf_type_obj_combo.get_value().lower()
dpi = self.dpi_entry.get_value() dpi = self.dpi_entry.get_value()
mode = self.image_type.get_value() mode = self.image_type.get_value()
mask = [self.mask_bw_entry.get_value(), self.mask_r_entry.get_value(),self.mask_g_entry.get_value(), mask = [self.mask_bw_entry.get_value(), self.mask_r_entry.get_value(), self.mask_g_entry.get_value(),
self.mask_b_entry.get_value()] self.mask_b_entry.get_value()]
if filename == "": if filename == "":
self.app.inform.emit(_("Open cancelled.")) self.app.inform.emit(_("Open cancelled."))
else: else:
self.app.worker_task.emit({'fcn': self.app.import_image, self.app.worker_task.emit({'fcn': self.app.import_image,
'params': [filename, type, dpi, mode, mask]}) 'params': [filename, type_obj, dpi, mode, mask]})
# self.import_svg(filename, "geometry") # self.import_svg(filename, "geometry")

View File

@@ -14,9 +14,9 @@ from math import sqrt
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
@@ -40,7 +40,6 @@ class Measurement(FlatCAMTool):
form_layout = QtWidgets.QFormLayout() form_layout = QtWidgets.QFormLayout()
self.layout.addLayout(form_layout) self.layout.addLayout(form_layout)
self.units_label = QtWidgets.QLabel(_("Units:")) self.units_label = QtWidgets.QLabel(_("Units:"))
self.units_label.setToolTip(_("Those are the units in which the distance is measured.")) self.units_label.setToolTip(_("Those are the units in which the distance is measured."))
self.units_value = QtWidgets.QLabel("%s" % str({'mm': "METRIC (mm)", 'in': "INCH (in)"}[self.units])) self.units_value = QtWidgets.QLabel("%s" % str({'mm': "METRIC (mm)", 'in': "INCH (in)"}[self.units]))
@@ -73,12 +72,10 @@ class Measurement(FlatCAMTool):
self.distance_x_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.distance_x_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.distance_x_entry.setToolTip(_("This is the distance measured over the X axis.")) self.distance_x_entry.setToolTip(_("This is the distance measured over the X axis."))
self.distance_y_entry = FCEntry() self.distance_y_entry = FCEntry()
self.distance_y_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.distance_y_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.distance_y_entry.setToolTip(_("This is the distance measured over the Y axis.")) self.distance_y_entry.setToolTip(_("This is the distance measured over the Y axis."))
self.total_distance_entry = FCEntry() self.total_distance_entry = FCEntry()
self.total_distance_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.total_distance_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.total_distance_entry.setToolTip(_("This is the point to point Euclidian distance.")) self.total_distance_entry.setToolTip(_("This is the point to point Euclidian distance."))
@@ -110,6 +107,8 @@ class Measurement(FlatCAMTool):
self.rel_point2 = None self.rel_point2 = None
self.active = False self.active = False
self.clicked_meas = None
self.meas_line = None
self.original_call_source = 'app' self.original_call_source = 'app'
@@ -312,7 +311,7 @@ class Measurement(FlatCAMTool):
# update utility geometry # update utility geometry
if len(self.points) == 1: if len(self.points) == 1:
self.utility_geometry(pos=pos) self.utility_geometry(pos=pos)
except: except Exception as e:
self.app.ui.position_label.setText("") self.app.ui.position_label.setText("")
self.app.ui.rel_position_label.setText("") self.app.ui.rel_position_label.setText("")

View File

@@ -14,9 +14,9 @@ from copy import copy
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
@@ -97,7 +97,7 @@ class ToolMove(FlatCAMTool):
pos_canvas = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos) pos_canvas = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
# if GRID is active we need to get the snapped positions # if GRID is active we need to get the snapped positions
if self.app.grid_status() == True: if self.app.grid_status() is True:
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1]) pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
else: else:
pos = pos_canvas pos = pos_canvas
@@ -117,7 +117,7 @@ class ToolMove(FlatCAMTool):
self.delete_shape() self.delete_shape()
# if GRID is active we need to get the snapped positions # if GRID is active we need to get the snapped positions
if self.app.grid_status() == True: if self.app.grid_status() is True:
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1]) pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
else: else:
pos = pos_canvas pos = pos_canvas
@@ -143,11 +143,11 @@ class ToolMove(FlatCAMTool):
try: try:
sel_obj.replotApertures.emit() sel_obj.replotApertures.emit()
except: except Exception as e:
pass pass
# Update the object bounding box options # Update the object bounding box options
a,b,c,d = sel_obj.bounds() a, b, c, d = sel_obj.bounds()
sel_obj.options['xmin'] = a sel_obj.options['xmin'] = a
sel_obj.options['ymin'] = b sel_obj.options['ymin'] = b
sel_obj.options['xmax'] = c sel_obj.options['xmax'] = c
@@ -181,7 +181,7 @@ class ToolMove(FlatCAMTool):
pos_canvas = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos) pos_canvas = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
# if GRID is active we need to get the snapped positions # if GRID is active we need to get the snapped positions
if self.app.grid_status() == True: if self.app.grid_status() is True:
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1]) pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
else: else:
pos = pos_canvas pos = pos_canvas

View File

@@ -7,16 +7,16 @@
# ########################################################## ## # ########################################################## ##
from FlatCAMTool import FlatCAMTool from FlatCAMTool import FlatCAMTool
from copy import copy,deepcopy from copy import copy, deepcopy
from ObjectCollection import * from ObjectCollection import *
import time import time
import gettext import gettext
import FlatCAMTranslation as fcTranslate import FlatCAMTranslation as fcTranslate
from shapely.geometry import base from shapely.geometry import base
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
@@ -113,7 +113,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
self.empty_label = QtWidgets.QLabel('') self.empty_label = QtWidgets.QLabel('')
self.tools_box.addWidget(self.empty_label) self.tools_box.addWidget(self.empty_label)
#### Add a new Tool ## ## # ### Add a new Tool ####
hlay = QtWidgets.QHBoxLayout() hlay = QtWidgets.QHBoxLayout()
self.tools_box.addLayout(hlay) self.tools_box.addLayout(hlay)
@@ -151,7 +151,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
grid2.addWidget(self.addtool_btn, 0, 0) grid2.addWidget(self.addtool_btn, 0, 0)
# grid2.addWidget(self.copytool_btn, 0, 1) # grid2.addWidget(self.copytool_btn, 0, 1)
grid2.addWidget(self.deltool_btn, 0,2) grid2.addWidget(self.deltool_btn, 0, 2)
self.empty_label_0 = QtWidgets.QLabel('') self.empty_label_0 = QtWidgets.QLabel('')
self.tools_box.addWidget(self.empty_label_0) self.tools_box.addWidget(self.empty_label_0)
@@ -344,8 +344,9 @@ class NonCopperClear(FlatCAMTool, Gerber):
try: try:
dias = [float(eval(dia)) for dia in self.app.defaults["tools_ncctools"].split(",") if dia != ''] dias = [float(eval(dia)) for dia in self.app.defaults["tools_ncctools"].split(",") if dia != '']
except: except Exception as e:
log.error("At least one tool diameter needed. Verify in Edit -> Preferences -> TOOLS -> NCC Tools.") log.error("At least one tool diameter needed. "
"Verify in Edit -> Preferences -> TOOLS -> NCC Tools. %s" % str(e))
return return
self.tooluid = 0 self.tooluid = 0
@@ -393,10 +394,10 @@ class NonCopperClear(FlatCAMTool, Gerber):
for tooluid_key, tooluid_value in self.ncc_tools.items(): for tooluid_key, tooluid_value in self.ncc_tools.items():
if float('%.4f' % tooluid_value['tooldia']) == tool_sorted: if float('%.4f' % tooluid_value['tooldia']) == tool_sorted:
tool_id += 1 tool_id += 1
id = QtWidgets.QTableWidgetItem('%d' % int(tool_id)) id_ = QtWidgets.QTableWidgetItem('%d' % int(tool_id))
id.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled) id_.setFlags(QtCore.Qt.ItemIsSelectable | QtCore.Qt.ItemIsEnabled)
row_no = tool_id - 1 row_no = tool_id - 1
self.tools_table.setItem(row_no, 0, id) # Tool name/id self.tools_table.setItem(row_no, 0, id_) # Tool name/id
# Make sure that the drill diameter when in MM is with no more than 2 decimals # Make sure that the drill diameter when in MM is with no more than 2 decimals
# There are no drill bits in MM with more than 3 decimals diameter # There are no drill bits in MM with more than 3 decimals diameter
@@ -486,7 +487,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
return return
if tool_dia == 0: if tool_dia == 0:
self.app.inform.emit(_("[WARNING_NOTCL] Please enter a tool diameter with non-zero value, in Float format.")) self.app.inform.emit(_("[WARNING_NOTCL] Please enter a tool diameter with non-zero value, "
"in Float format."))
return return
# construct a list of all 'tooluid' in the self.tools # construct a list of all 'tooluid' in the self.tools
@@ -568,7 +570,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
break break
restore_dia_item = self.tools_table.item(row, 1) restore_dia_item = self.tools_table.item(row, 1)
restore_dia_item.setText(str(old_tool_dia)) restore_dia_item.setText(str(old_tool_dia))
self.app.inform.emit(_("[WARNING_NOTCL] Edit cancelled. New diameter value is already in the Tool Table.")) self.app.inform.emit(_("[WARNING_NOTCL] Edit cancelled. "
"New diameter value is already in the Tool Table."))
self.build_ui() self.build_ui()
def on_tool_delete(self, rows_to_delete=None, all=None): def on_tool_delete(self, rows_to_delete=None, all=None):
@@ -662,13 +665,14 @@ class NonCopperClear(FlatCAMTool, Gerber):
# Get source object. # Get source object.
try: try:
self.ncc_obj = self.app.collection.get_by_name(self.obj_name) self.ncc_obj = self.app.collection.get_by_name(self.obj_name)
except: except Exception as e:
self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % self.obj_name) self.app.inform.emit(_("[ERROR_NOTCL] Could not retrieve object: %s") % self.obj_name)
return "Could not retrieve object: %s" % self.obj_name return "Could not retrieve object: %s" % self.obj_name
# Prepare non-copper polygons # Prepare non-copper polygons
try: try:
bounding_box = self.ncc_obj.solid_geometry.envelope.buffer(distance=margin, join_style=base.JOIN_STYLE.mitre) bounding_box = self.ncc_obj.solid_geometry.envelope.buffer(distance=margin,
join_style=base.JOIN_STYLE.mitre)
except AttributeError: except AttributeError:
self.app.inform.emit(_("[ERROR_NOTCL] No Gerber file available.")) self.app.inform.emit(_("[ERROR_NOTCL] No Gerber file available."))
return return
@@ -679,7 +683,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
empty = MultiPolygon([empty]) empty = MultiPolygon([empty])
# clear non copper using standard algorithm # clear non copper using standard algorithm
if clearing_method == False: if clearing_method is False:
self.clear_non_copper( self.clear_non_copper(
empty=empty, empty=empty,
over=over, over=over,
@@ -736,7 +740,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
area = empty.buffer(-offset) area = empty.buffer(-offset)
try: try:
area = area.difference(cleared) area = area.difference(cleared)
except: except Exception as e:
continue continue
# Transform area to MultiPolygon # Transform area to MultiPolygon
@@ -758,8 +762,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
overlap=over, contour=contour, connect=connect) overlap=over, contour=contour, connect=connect)
if cp: if cp:
cleared_geo += list(cp.get_objects()) cleared_geo += list(cp.get_objects())
except: except Exception as e:
log.warning("Polygon can not be cleared.") log.warning("Polygon can not be cleared. %s" % str(e))
app_obj.poly_not_cleared = True app_obj.poly_not_cleared = True
continue continue
@@ -973,4 +977,3 @@ class NonCopperClear(FlatCAMTool, Gerber):
def reset_fields(self): def reset_fields(self):
self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex())) self.object_combo.setRootModelIndex(self.app.collection.index(0, 0, QtCore.QModelIndex()))