- 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)
@@ -96,32 +94,31 @@ class ToolCalculator(FlatCAMTool):
# self.tipDia_entry.setFixedWidth(70) # self.tipDia_entry.setFixedWidth(70)
self.tipDia_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.tipDia_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.tipDia_label.setToolTip(_('This is the diameter of the tool tip.\n' self.tipDia_label.setToolTip(_('This is the diameter of the tool tip.\n'
'The manufacturer specifies it.')) 'The manufacturer specifies it.'))
self.tipAngle_label = QtWidgets.QLabel(_("Tip Angle:")) self.tipAngle_label = QtWidgets.QLabel(_("Tip Angle:"))
self.tipAngle_entry = FCEntry() self.tipAngle_entry = FCEntry()
# self.tipAngle_entry.setFixedWidth(70) # self.tipAngle_entry.setFixedWidth(70)
self.tipAngle_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.tipAngle_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.tipAngle_label.setToolTip(_("This is the angle of the tip of the tool.\n" self.tipAngle_label.setToolTip(_("This is the angle of the tip of the tool.\n"
"It is specified by manufacturer.")) "It is specified by manufacturer."))
self.cutDepth_label = QtWidgets.QLabel(_("Cut Z:")) self.cutDepth_label = QtWidgets.QLabel(_("Cut Z:"))
self.cutDepth_entry = FCEntry() self.cutDepth_entry = FCEntry()
# self.cutDepth_entry.setFixedWidth(70) # self.cutDepth_entry.setFixedWidth(70)
self.cutDepth_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.cutDepth_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.cutDepth_label.setToolTip(_("This is the depth to cut into the material.\n" self.cutDepth_label.setToolTip(_("This is the depth to cut into the material.\n"
"In the CNCJob is the CutZ parameter.")) "In the CNCJob is the CutZ parameter."))
self.effectiveToolDia_label = QtWidgets.QLabel(_("Tool Diameter:")) self.effectiveToolDia_label = QtWidgets.QLabel(_("Tool Diameter:"))
self.effectiveToolDia_entry = FCEntry() self.effectiveToolDia_entry = FCEntry()
# self.effectiveToolDia_entry.setFixedWidth(70) # self.effectiveToolDia_entry.setFixedWidth(70)
self.effectiveToolDia_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.effectiveToolDia_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.effectiveToolDia_label.setToolTip(_("This is the tool diameter to be entered into\n" self.effectiveToolDia_label.setToolTip(_("This is the tool diameter to be entered into\n"
"FlatCAM Gerber section.\n" "FlatCAM Gerber section.\n"
"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)
@@ -132,16 +129,15 @@ class ToolCalculator(FlatCAMTool):
# self.calculate_button.setFixedWidth(70) # self.calculate_button.setFixedWidth(70)
self.calculate_vshape_button.setToolTip( self.calculate_vshape_button.setToolTip(
_("Calculate either the Cut Z or the effective tool diameter,\n " _("Calculate either the Cut Z or the effective tool diameter,\n "
"depending on which is desired and which is known. ") "depending on which is desired and which is known. ")
) )
self.empty_label = QtWidgets.QLabel(" ") self.empty_label = QtWidgets.QLabel(" ")
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)
@@ -150,7 +146,7 @@ class ToolCalculator(FlatCAMTool):
plate_title_label = QtWidgets.QLabel("<font size=3><b>%s</b></font>" % self.eplateName) plate_title_label = QtWidgets.QLabel("<font size=3><b>%s</b></font>" % self.eplateName)
plate_title_label.setToolTip( plate_title_label.setToolTip(
_("This calculator is useful for those who plate the via/pad/drill holes,\n" _("This calculator is useful for those who plate the via/pad/drill holes,\n"
"using a method like grahite ink or calcium hypophosphite ink or palladium chloride.") "using a method like grahite ink or calcium hypophosphite ink or palladium chloride.")
) )
self.layout.addWidget(plate_title_label) self.layout.addWidget(plate_title_label)
@@ -175,15 +171,14 @@ class ToolCalculator(FlatCAMTool):
# self.cdensity_entry.setFixedWidth(70) # self.cdensity_entry.setFixedWidth(70)
self.cdensity_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.cdensity_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
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)
self.growth_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.growth_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.growth_label.setToolTip(_("How thick the copper growth is intended to be.\n" self.growth_label.setToolTip(_("How thick the copper growth is intended to be.\n"
"In microns.")) "In microns."))
# self.growth_entry.setEnabled(False) # self.growth_entry.setEnabled(False)
@@ -192,7 +187,7 @@ class ToolCalculator(FlatCAMTool):
# self.cvaluelabel.setFixedWidth(70) # self.cvaluelabel.setFixedWidth(70)
self.cvalue_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.cvalue_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.cvaluelabel.setToolTip(_('This is the current intensity value\n' self.cvaluelabel.setToolTip(_('This is the current intensity value\n'
'to be set on the Power Supply. In Amps.')) 'to be set on the Power Supply. In Amps.'))
self.cvalue_entry.setDisabled(True) self.cvalue_entry.setDisabled(True)
self.timelabel = QtWidgets.QLabel(_("Time:")) self.timelabel = QtWidgets.QLabel(_("Time:"))
@@ -200,7 +195,7 @@ class ToolCalculator(FlatCAMTool):
# self.timelabel.setFixedWidth(70) # self.timelabel.setFixedWidth(70)
self.time_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.time_entry.setAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter)
self.timelabel.setToolTip(_('This is the calculated time required for the procedure.\n' self.timelabel.setToolTip(_('This is the calculated time required for the procedure.\n'
'In minutes.')) 'In minutes.'))
self.time_entry.setDisabled(True) self.time_entry.setDisabled(True)
plate_form_layout.addRow(self.pcblengthlabel, self.pcblength_entry) plate_form_layout.addRow(self.pcblengthlabel, self.pcblength_entry)
@@ -214,8 +209,8 @@ 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)
@@ -305,7 +302,7 @@ class ToolCalculator(FlatCAMTool):
tip_diameter = float(self.tipDia_entry.get_value().replace(',', '.')) tip_diameter = float(self.tipDia_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
try: try:
@@ -316,7 +313,7 @@ class ToolCalculator(FlatCAMTool):
half_tip_angle = float(self.tipAngle_entry.get_value().replace(',', '.')) half_tip_angle = float(self.tipAngle_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
half_tip_angle /= 2 half_tip_angle /= 2
@@ -328,7 +325,7 @@ class ToolCalculator(FlatCAMTool):
cut_depth = float(self.cutDepth_entry.get_value().replace(',', '.')) cut_depth = float(self.cutDepth_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
tool_diameter = tip_diameter + (2 * cut_depth * math.tan(math.radians(half_tip_angle))) tool_diameter = tip_diameter + (2 * cut_depth * math.tan(math.radians(half_tip_angle)))
@@ -343,7 +340,7 @@ class ToolCalculator(FlatCAMTool):
mm_val = float(self.mm_entry.get_value().replace(',', '.')) mm_val = float(self.mm_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
self.inch_entry.set_value('%.6f' % (mm_val / 25.4)) self.inch_entry.set_value('%.6f' % (mm_val / 25.4))
@@ -356,7 +353,7 @@ class ToolCalculator(FlatCAMTool):
inch_val = float(self.inch_entry.get_value().replace(',', '.')) inch_val = float(self.inch_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
self.mm_entry.set_value('%.6f' % (inch_val * 25.4)) self.mm_entry.set_value('%.6f' % (inch_val * 25.4))
@@ -370,7 +367,7 @@ class ToolCalculator(FlatCAMTool):
length = float(self.pcblength_entry.get_value().replace(',', '.')) length = float(self.pcblength_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
try: try:
@@ -381,7 +378,7 @@ class ToolCalculator(FlatCAMTool):
width = float(self.pcbwidth_entry.get_value().replace(',', '.')) width = float(self.pcbwidth_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
try: try:
@@ -392,7 +389,7 @@ class ToolCalculator(FlatCAMTool):
density = float(self.cdensity_entry.get_value().replace(',', '.')) density = float(self.cdensity_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
try: try:
@@ -403,7 +400,7 @@ class ToolCalculator(FlatCAMTool):
copper = float(self.growth_entry.get_value().replace(',', '.')) copper = float(self.growth_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
calculated_current = (length * width * density) * 0.0021527820833419 calculated_current = (length * width * density) * 0.0021527820833419
@@ -412,4 +409,4 @@ class ToolCalculator(FlatCAMTool):
self.cvalue_entry.set_value('%.2f' % calculated_current) self.cvalue_entry.set_value('%.2f' % calculated_current)
self.time_entry.set_value('%.1f' % calculated_time) self.time_entry.set_value('%.1f' % calculated_time)
# end of file # end of file

View File

@@ -354,7 +354,7 @@ class CutOut(FlatCAMTool):
dia = float(self.dia.get_value().replace(',', '.')) dia = float(self.dia.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[WARNING_NOTCL] Tool diameter value is missing or wrong format. " self.app.inform.emit(_("[WARNING_NOTCL] Tool diameter value is missing or wrong format. "
"Add it and retry.")) "Add it and retry."))
return return
if 0 in {dia}: if 0 in {dia}:
@@ -369,7 +369,7 @@ class CutOut(FlatCAMTool):
margin = float(self.margin.get_value().replace(',', '.')) margin = float(self.margin.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[WARNING_NOTCL] Margin value is missing or wrong format. " self.app.inform.emit(_("[WARNING_NOTCL] Margin value is missing or wrong format. "
"Add it and retry.")) "Add it and retry."))
return return
try: try:
@@ -380,7 +380,7 @@ class CutOut(FlatCAMTool):
gapsize = float(self.gapsize.get_value().replace(',', '.')) gapsize = float(self.gapsize.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[WARNING_NOTCL] Gap size value is missing or wrong format. " self.app.inform.emit(_("[WARNING_NOTCL] Gap size value is missing or wrong format. "
"Add it and retry.")) "Add it and retry."))
return return
try: try:
@@ -391,7 +391,7 @@ class CutOut(FlatCAMTool):
if gaps not in ['LR', 'TB', '2LR', '2TB', '4', '8']: if gaps not in ['LR', 'TB', '2LR', '2TB', '4', '8']:
self.app.inform.emit(_("[WARNING_NOTCL] Gaps value can be only one of: 'lr', 'tb', '2lr', '2tb', 4 or 8. " self.app.inform.emit(_("[WARNING_NOTCL] Gaps value can be only one of: 'lr', 'tb', '2lr', '2tb', 4 or 8. "
"Fill in a correct value and retry. ")) "Fill in a correct value and retry. "))
return return
if cutout_obj.multigeo is True: if cutout_obj.multigeo is True:
@@ -523,7 +523,7 @@ class CutOut(FlatCAMTool):
dia = float(self.dia.get_value().replace(',', '.')) dia = float(self.dia.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[WARNING_NOTCL] Tool diameter value is missing or wrong format. " self.app.inform.emit(_("[WARNING_NOTCL] Tool diameter value is missing or wrong format. "
"Add it and retry.")) "Add it and retry."))
return return
if 0 in {dia}: if 0 in {dia}:
@@ -538,7 +538,7 @@ class CutOut(FlatCAMTool):
margin = float(self.margin.get_value().replace(',', '.')) margin = float(self.margin.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[WARNING_NOTCL] Margin value is missing or wrong format. " self.app.inform.emit(_("[WARNING_NOTCL] Margin value is missing or wrong format. "
"Add it and retry.")) "Add it and retry."))
return return
try: try:
@@ -549,7 +549,7 @@ class CutOut(FlatCAMTool):
gapsize = float(self.gapsize.get_value().replace(',', '.')) gapsize = float(self.gapsize.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[WARNING_NOTCL] Gap size value is missing or wrong format. " self.app.inform.emit(_("[WARNING_NOTCL] Gap size value is missing or wrong format. "
"Add it and retry.")) "Add it and retry."))
return return
try: try:
@@ -560,13 +560,13 @@ class CutOut(FlatCAMTool):
if gaps not in ['LR', 'TB', '2LR', '2TB', '4', '8']: if gaps not in ['LR', 'TB', '2LR', '2TB', '4', '8']:
self.app.inform.emit(_("[WARNING_NOTCL] Gaps value can be only one of: 'lr', 'tb', '2lr', '2tb', 4 or 8. " self.app.inform.emit(_("[WARNING_NOTCL] Gaps value can be only one of: 'lr', 'tb', '2lr', '2tb', 4 or 8. "
"Fill in a correct value and retry. ")) "Fill in a correct value and retry. "))
return return
if cutout_obj.multigeo is True: if cutout_obj.multigeo is True:
self.app.inform.emit(_("[ERROR]Cutout operation cannot be done on a multi-geo Geometry.\n" self.app.inform.emit(_("[ERROR]Cutout operation cannot be done on a multi-geo Geometry.\n"
"Optionally, this Multi-geo Geometry can be converted to Single-geo Geometry,\n" "Optionally, this Multi-geo Geometry can be converted to Single-geo Geometry,\n"
"and after that perform Cutout.")) "and after that perform Cutout."))
return return
# Get min and max data for each object as we just cut rectangles across X or Y # Get min and max data for each object as we just cut rectangles across X or Y
@@ -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
@@ -52,8 +52,8 @@ class DblSidedTool(FlatCAMTool):
self.mirror_gerber_button = QtWidgets.QPushButton(_("Mirror")) self.mirror_gerber_button = QtWidgets.QPushButton(_("Mirror"))
self.mirror_gerber_button.setToolTip( self.mirror_gerber_button.setToolTip(
_("Mirrors (flips) the specified object around \n" _("Mirrors (flips) the specified object around \n"
"the specified axis. Does not create a new \n" "the specified axis. Does not create a new \n"
"object, but modifies it.") "object, but modifies it.")
) )
self.mirror_gerber_button.setFixedWidth(60) self.mirror_gerber_button.setFixedWidth(60)
@@ -76,8 +76,8 @@ class DblSidedTool(FlatCAMTool):
self.mirror_exc_button = QtWidgets.QPushButton(_("Mirror")) self.mirror_exc_button = QtWidgets.QPushButton(_("Mirror"))
self.mirror_exc_button.setToolTip( self.mirror_exc_button.setToolTip(
_("Mirrors (flips) the specified object around \n" _("Mirrors (flips) the specified object around \n"
"the specified axis. Does not create a new \n" "the specified axis. Does not create a new \n"
"object, but modifies it.") "object, but modifies it.")
) )
self.mirror_exc_button.setFixedWidth(60) self.mirror_exc_button.setFixedWidth(60)
@@ -100,8 +100,8 @@ class DblSidedTool(FlatCAMTool):
self.mirror_geo_button = QtWidgets.QPushButton(_("Mirror")) self.mirror_geo_button = QtWidgets.QPushButton(_("Mirror"))
self.mirror_geo_button.setToolTip( self.mirror_geo_button.setToolTip(
_("Mirrors (flips) the specified object around \n" _("Mirrors (flips) the specified object around \n"
"the specified axis. Does not create a new \n" "the specified axis. Does not create a new \n"
"object, but modifies it.") "object, but modifies it.")
) )
self.mirror_geo_button.setFixedWidth(60) self.mirror_geo_button.setFixedWidth(60)
@@ -133,8 +133,8 @@ class DblSidedTool(FlatCAMTool):
self.axloc_label = QtWidgets.QLabel(_("Axis Ref:")) self.axloc_label = QtWidgets.QLabel(_("Axis Ref:"))
self.axloc_label.setToolTip( self.axloc_label.setToolTip(
_("The axis should pass through a <b>point</b> or cut\n " _("The axis should pass through a <b>point</b> or cut\n "
"a specified <b>box</b> (in a FlatCAM object) through \n" "a specified <b>box</b> (in a FlatCAM object) through \n"
"the center.") "the center.")
) )
# grid_lay.addRow("Axis Location:", self.axis_location) # grid_lay.addRow("Axis Location:", self.axis_location)
grid_lay1.addWidget(self.axloc_label, 8, 0) grid_lay1.addWidget(self.axloc_label, 8, 0)
@@ -152,17 +152,17 @@ class DblSidedTool(FlatCAMTool):
self.pb_label = QtWidgets.QLabel("<b>%s</b>" % _('Point/Box Reference:')) self.pb_label = QtWidgets.QLabel("<b>%s</b>" % _('Point/Box Reference:'))
self.pb_label.setToolTip( self.pb_label.setToolTip(
_("If 'Point' is selected above it store the coordinates (x, y) through which\n" _("If 'Point' is selected above it store the coordinates (x, y) through which\n"
"the mirroring axis passes.\n" "the mirroring axis passes.\n"
"If 'Box' is selected above, select here a FlatCAM object (Gerber, Exc or Geo).\n" "If 'Box' is selected above, select here a FlatCAM object (Gerber, Exc or Geo).\n"
"Through the center of this object pass the mirroring axis selected above.") "Through the center of this object pass the mirroring axis selected above.")
) )
self.add_point_button = QtWidgets.QPushButton(_("Add")) self.add_point_button = QtWidgets.QPushButton(_("Add"))
self.add_point_button.setToolTip( self.add_point_button.setToolTip(
_("Add the coordinates in format <b>(x, y)</b> through which the mirroring axis \n " _("Add the coordinates in format <b>(x, y)</b> through which the mirroring axis \n "
"selected in 'MIRROR AXIS' pass.\n" "selected in 'MIRROR AXIS' pass.\n"
"The (x, y) coordinates are captured by pressing SHIFT key\n" "The (x, y) coordinates are captured by pressing SHIFT key\n"
"and left mouse button click on canvas or you can enter the coords manually.") "and left mouse button click on canvas or you can enter the coords manually.")
) )
self.add_point_button.setFixedWidth(60) self.add_point_button.setFixedWidth(60)
@@ -188,15 +188,14 @@ 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"
"- one drill in mirror position over the axis selected above in the 'Mirror Axis'.") "- one drill in mirror position over the axis selected above in the 'Mirror Axis'.")
) )
self.layout.addWidget(self.ah_label) self.layout.addWidget(self.ah_label)
@@ -208,12 +207,12 @@ class DblSidedTool(FlatCAMTool):
self.add_drill_point_button = QtWidgets.QPushButton(_("Add")) self.add_drill_point_button = QtWidgets.QPushButton(_("Add"))
self.add_drill_point_button.setToolTip( self.add_drill_point_button.setToolTip(
_("Add alignment drill holes coords in the format: (x1, y1), (x2, y2), ... \n" _("Add alignment drill holes coords in the format: (x1, y1), (x2, y2), ... \n"
"on one side of the mirror axis.\n\n" "on one side of the mirror axis.\n\n"
"The coordinates set can be obtained:\n" "The coordinates set can be obtained:\n"
"- press SHIFT key and left mouse clicking on canvas. Then click Add.\n" "- press SHIFT key and left mouse clicking on canvas. Then click Add.\n"
"- press SHIFT key and left mouse clicking on canvas. Then CTRL+V in the field.\n" "- press SHIFT key and left mouse clicking on canvas. Then CTRL+V in the field.\n"
"- press SHIFT key and left mouse clicking on canvas. Then RMB click in the field and click Paste.\n" "- press SHIFT key and left mouse clicking on canvas. Then RMB click in the field and click Paste.\n"
"- by entering the coords manually in the format: (x1, y1), (x2, y2), ...") "- by entering the coords manually in the format: (x1, y1), (x2, y2), ...")
) )
self.add_drill_point_button.setFixedWidth(60) self.add_drill_point_button.setFixedWidth(60)
@@ -224,7 +223,7 @@ class DblSidedTool(FlatCAMTool):
self.dt_label = QtWidgets.QLabel("<b>%s</b>:" % _('Alignment Drill Diameter')) self.dt_label = QtWidgets.QLabel("<b>%s</b>:" % _('Alignment Drill Diameter'))
self.dt_label.setToolTip( self.dt_label.setToolTip(
_("Diameter of the drill for the " _("Diameter of the drill for the "
"alignment holes.") "alignment holes.")
) )
self.layout.addWidget(self.dt_label) self.layout.addWidget(self.dt_label)
@@ -235,7 +234,7 @@ class DblSidedTool(FlatCAMTool):
self.dd_label = QtWidgets.QLabel(_("Drill diam.:")) self.dd_label = QtWidgets.QLabel(_("Drill diam.:"))
self.dd_label.setToolTip( self.dd_label.setToolTip(
_("Diameter of the drill for the " _("Diameter of the drill for the "
"alignment holes.") "alignment holes.")
) )
hlay.addWidget(self.dd_label) hlay.addWidget(self.dd_label)
hlay.addWidget(self.drill_dia) hlay.addWidget(self.drill_dia)
@@ -247,8 +246,8 @@ class DblSidedTool(FlatCAMTool):
self.create_alignment_hole_button = QtWidgets.QPushButton(_("Create Excellon Object")) self.create_alignment_hole_button = QtWidgets.QPushButton(_("Create Excellon Object"))
self.create_alignment_hole_button.setToolTip( self.create_alignment_hole_button.setToolTip(
_("Creates an Excellon Object containing the\n" _("Creates an Excellon Object containing the\n"
"specified alignment holes and their mirror\n" "specified alignment holes and their mirror\n"
"images.") "images.")
) )
hlay2.addWidget(self.create_alignment_hole_button) hlay2.addWidget(self.create_alignment_hole_button)
@@ -325,7 +324,7 @@ class DblSidedTool(FlatCAMTool):
px, py = self.point_entry.get_value() px, py = self.point_entry.get_value()
except TypeError: except TypeError:
self.app.inform.emit(_("[WARNING_NOTCL] 'Point' reference is selected and 'Point' coordinates " self.app.inform.emit(_("[WARNING_NOTCL] 'Point' reference is selected and 'Point' coordinates "
"are missing. Add them and retry.")) "are missing. Add them and retry."))
return return
else: else:
selection_index = self.box_combo.currentIndex() selection_index = self.box_combo.currentIndex()
@@ -361,7 +360,7 @@ class DblSidedTool(FlatCAMTool):
self.drill_dia.set_value(dia) self.drill_dia.set_value(dia)
except ValueError: except ValueError:
self.app.inform.emit(_("[WARNING_NOTCL] Tool diameter value is missing or wrong format. " self.app.inform.emit(_("[WARNING_NOTCL] Tool diameter value is missing or wrong format. "
"Add it and retry.")) "Add it and retry."))
return return
if dia is '': if dia is '':
@@ -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 = []
@@ -418,7 +418,7 @@ class DblSidedTool(FlatCAMTool):
px, py = self.point_entry.get_value() px, py = self.point_entry.get_value()
except TypeError: except TypeError:
self.app.inform.emit(_("[WARNING_NOTCL] 'Point' coordinates missing. " self.app.inform.emit(_("[WARNING_NOTCL] 'Point' coordinates missing. "
"Using Origin (0, 0) as mirroring reference.")) "Using Origin (0, 0) as mirroring reference."))
px, py = (0, 0) px, py = (0, 0)
else: else:
@@ -462,7 +462,7 @@ class DblSidedTool(FlatCAMTool):
except Exception as e: except Exception as e:
log.debug("DblSidedTool.on_mirror_geo() --> %s" % str(e)) log.debug("DblSidedTool.on_mirror_geo() --> %s" % str(e))
self.app.inform.emit(_("[WARNING_NOTCL] There are no Point coordinates in the Point field. " self.app.inform.emit(_("[WARNING_NOTCL] There are no Point coordinates in the Point field. "
"Add coords and try again ...")) "Add coords and try again ..."))
return return
else: else:
selection_index_box = self.box_combo.currentIndex() selection_index_box = self.box_combo.currentIndex()
@@ -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
@@ -56,9 +56,9 @@ class Film(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 for which to create the film.\n" _("Specify the type of object for which to create the film.\n"
"The object can be of type: Gerber or Geometry.\n" "The object can be of type: Gerber or Geometry.\n"
"The selection here decide the type of objects that will be\n" "The selection here decide the type of objects that will be\n"
"in the Film Object combobox.") "in the Film Object combobox.")
) )
tf_form_layout.addRow(self.tf_type_obj_combo_label, self.tf_type_obj_combo) tf_form_layout.addRow(self.tf_type_obj_combo_label, self.tf_type_obj_combo)
@@ -89,9 +89,9 @@ class Film(FlatCAMTool):
self.tf_type_box_combo_label = QtWidgets.QLabel(_("Box Type:")) self.tf_type_box_combo_label = QtWidgets.QLabel(_("Box Type:"))
self.tf_type_box_combo_label.setToolTip( self.tf_type_box_combo_label.setToolTip(
_("Specify the type of object to be used as an container for\n" _("Specify the type of object to be used as an container for\n"
"film creation. It can be: Gerber or Geometry type." "film creation. It can be: Gerber or Geometry type."
"The selection here decide the type of objects that will be\n" "The selection here decide the type of objects that will be\n"
"in the Box Object combobox.") "in the Box Object combobox.")
) )
tf_form_layout.addRow(self.tf_type_box_combo_label, self.tf_type_box_combo) tf_form_layout.addRow(self.tf_type_box_combo_label, self.tf_type_box_combo)
@@ -104,23 +104,23 @@ class Film(FlatCAMTool):
self.tf_box_combo_label = QtWidgets.QLabel(_("Box Object:")) self.tf_box_combo_label = QtWidgets.QLabel(_("Box Object:"))
self.tf_box_combo_label.setToolTip( self.tf_box_combo_label.setToolTip(
_("The actual object that is used a container for the\n " _("The actual object that is used a container for the\n "
"selected object for which we create the film.\n" "selected object for which we create the film.\n"
"Usually it is the PCB outline but it can be also the\n" "Usually it is the PCB outline but it can be also the\n"
"same object for which the film is created.") "same object for which the film is created.")
) )
tf_form_layout.addRow(self.tf_box_combo_label, self.tf_box_combo) tf_form_layout.addRow(self.tf_box_combo_label, self.tf_box_combo)
# Film Type # Film Type
self.film_type = RadioSet([{'label': 'Positive', 'value': 'pos'}, self.film_type = RadioSet([{'label': 'Positive', 'value': 'pos'},
{'label': 'Negative', 'value': 'neg'}]) {'label': 'Negative', 'value': 'neg'}])
self.film_type_label = QtWidgets.QLabel(_("Film Type:")) self.film_type_label = QtWidgets.QLabel(_("Film Type:"))
self.film_type_label.setToolTip( self.film_type_label.setToolTip(
_("Generate a Positive black film or a Negative film.\n" _("Generate a Positive black film or a Negative film.\n"
"Positive means that it will print the features\n" "Positive means that it will print the features\n"
"with black on a white canvas.\n" "with black on a white canvas.\n"
"Negative means that it will print the features\n" "Negative means that it will print the features\n"
"with white on a black canvas.\n" "with white on a black canvas.\n"
"The Film format is SVG.") "The Film format is SVG.")
) )
tf_form_layout.addRow(self.film_type_label, self.film_type) tf_form_layout.addRow(self.film_type_label, self.film_type)
@@ -130,13 +130,13 @@ class Film(FlatCAMTool):
self.boundary_label = QtWidgets.QLabel(_("Border:")) self.boundary_label = QtWidgets.QLabel(_("Border:"))
self.boundary_label.setToolTip( self.boundary_label.setToolTip(
_("Specify a border around the object.\n" _("Specify a border around the object.\n"
"Only for negative film.\n" "Only for negative film.\n"
"It helps if we use as a Box Object the same \n" "It helps if we use as a Box Object the same \n"
"object as in Film Object. It will create a thick\n" "object as in Film Object. It will create a thick\n"
"black bar around the actual print allowing for a\n" "black bar around the actual print allowing for a\n"
"better delimitation of the outline features which are of\n" "better delimitation of the outline features which are of\n"
"white color like the rest and which may confound with the\n" "white color like the rest and which may confound with the\n"
"surroundings if not for this border.") "surroundings if not for this border.")
) )
tf_form_layout.addRow(self.boundary_label, self.boundary_entry) tf_form_layout.addRow(self.boundary_label, self.boundary_entry)
@@ -144,8 +144,8 @@ class Film(FlatCAMTool):
self.film_scale_label = QtWidgets.QLabel(_("Scale Stroke:")) self.film_scale_label = QtWidgets.QLabel(_("Scale Stroke:"))
self.film_scale_label.setToolTip( self.film_scale_label.setToolTip(
_("Scale the line stroke thickness of each feature in the SVG file.\n" _("Scale the line stroke thickness of each feature in the SVG file.\n"
"It means that the line that envelope each SVG feature will be thicker or thinner,\n" "It means that the line that envelope each SVG feature will be thicker or thinner,\n"
"therefore the fine features may be more affected by this parameter.") "therefore the fine features may be more affected by this parameter.")
) )
tf_form_layout.addRow(self.film_scale_label, self.film_scale_entry) tf_form_layout.addRow(self.film_scale_label, self.film_scale_entry)
@@ -157,9 +157,9 @@ class Film(FlatCAMTool):
self.film_object_button = QtWidgets.QPushButton(_("Save Film")) self.film_object_button = QtWidgets.QPushButton(_("Save Film"))
self.film_object_button.setToolTip( self.film_object_button.setToolTip(
_("Create a Film for the selected object, within\n" _("Create a Film for the selected object, within\n"
"the specified box. Does not create a new \n " "the specified box. Does not create a new \n "
"FlatCAM object, but directly save it in SVG format\n" "FlatCAM object, but directly save it in SVG format\n"
"which can be opened with Inkscape.") "which can be opened with Inkscape.")
) )
hlay.addWidget(self.film_object_button) hlay.addWidget(self.film_object_button)
@@ -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,8 +52,8 @@ 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.")
) )
ti_form_layout.addRow(self.tf_type_obj_combo_label, self.tf_type_obj_combo) ti_form_layout.addRow(self.tf_type_obj_combo_label, self.tf_type_obj_combo)
@@ -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)
@@ -77,11 +77,11 @@ class ToolImage(FlatCAMTool):
# Type of image interpretation # Type of image interpretation
self.image_type = RadioSet([{'label': 'B/W', 'value': 'black'}, self.image_type = RadioSet([{'label': 'B/W', 'value': 'black'},
{'label': 'Color', 'value': 'color'}]) {'label': 'Color', 'value': 'color'}])
self.image_type_label = QtWidgets.QLabel("<b>%s:</b>" % _('Image type')) self.image_type_label = QtWidgets.QLabel("<b>%s:</b>" % _('Image type'))
self.image_type_label.setToolTip( self.image_type_label.setToolTip(
_("Choose a method for the image interpretation.\n" _("Choose a method for the image interpretation.\n"
"B/W means a black & white image. Color means a colored image.") "B/W means a black & white image. Color means a colored image.")
) )
ti2_form_layout.addRow(self.image_type_label, self.image_type) ti2_form_layout.addRow(self.image_type_label, self.image_type)
@@ -90,11 +90,11 @@ class ToolImage(FlatCAMTool):
self.mask_bw_label = QtWidgets.QLabel("%s <b>B/W</b>:" % _('Mask value')) self.mask_bw_label = QtWidgets.QLabel("%s <b>B/W</b>:" % _('Mask value'))
self.mask_bw_label.setToolTip( self.mask_bw_label.setToolTip(
_("Mask for monochrome image.\n" _("Mask for monochrome image.\n"
"Takes values between [0 ... 255].\n" "Takes values between [0 ... 255].\n"
"Decides the level of details to include\n" "Decides the level of details to include\n"
"in the resulting geometry.\n" "in the resulting geometry.\n"
"0 means no detail and 255 means everything \n" "0 means no detail and 255 means everything \n"
"(which is totally black).") "(which is totally black).")
) )
ti2_form_layout.addRow(self.mask_bw_label, self.mask_bw_entry) ti2_form_layout.addRow(self.mask_bw_label, self.mask_bw_entry)
@@ -103,9 +103,9 @@ class ToolImage(FlatCAMTool):
self.mask_r_label = QtWidgets.QLabel("%s <b>R:</b>" % _('Mask value')) self.mask_r_label = QtWidgets.QLabel("%s <b>R:</b>" % _('Mask value'))
self.mask_r_label.setToolTip( self.mask_r_label.setToolTip(
_("Mask for RED color.\n" _("Mask for RED color.\n"
"Takes values between [0 ... 255].\n" "Takes values between [0 ... 255].\n"
"Decides the level of details to include\n" "Decides the level of details to include\n"
"in the resulting geometry.") "in the resulting geometry.")
) )
ti2_form_layout.addRow(self.mask_r_label, self.mask_r_entry) ti2_form_layout.addRow(self.mask_r_label, self.mask_r_entry)
@@ -114,9 +114,9 @@ class ToolImage(FlatCAMTool):
self.mask_g_label = QtWidgets.QLabel("%s <b>G:</b>" % _('Mask value')) self.mask_g_label = QtWidgets.QLabel("%s <b>G:</b>" % _('Mask value'))
self.mask_g_label.setToolTip( self.mask_g_label.setToolTip(
_("Mask for GREEN color.\n" _("Mask for GREEN color.\n"
"Takes values between [0 ... 255].\n" "Takes values between [0 ... 255].\n"
"Decides the level of details to include\n" "Decides the level of details to include\n"
"in the resulting geometry.") "in the resulting geometry.")
) )
ti2_form_layout.addRow(self.mask_g_label, self.mask_g_entry) ti2_form_layout.addRow(self.mask_g_label, self.mask_g_entry)
@@ -125,9 +125,9 @@ class ToolImage(FlatCAMTool):
self.mask_b_label = QtWidgets.QLabel("%s <b>B:</b>" % _('Mask value')) self.mask_b_label = QtWidgets.QLabel("%s <b>B:</b>" % _('Mask value'))
self.mask_b_label.setToolTip( self.mask_b_label.setToolTip(
_("Mask for BLUE color.\n" _("Mask for BLUE color.\n"
"Takes values between [0 ... 255].\n" "Takes values between [0 ... 255].\n"
"Decides the level of details to include\n" "Decides the level of details to include\n"
"in the resulting geometry.") "in the resulting geometry.")
) )
ti2_form_layout.addRow(self.mask_b_label, self.mask_b_entry) ti2_form_layout.addRow(self.mask_b_label, self.mask_b_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
@@ -72,7 +72,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
self.tools_table_label = QtWidgets.QLabel('<b>%s</b>' % _('Tools Table')) self.tools_table_label = QtWidgets.QLabel('<b>%s</b>' % _('Tools Table'))
self.tools_table_label.setToolTip( self.tools_table_label.setToolTip(
_("Tools pool from which the algorithm\n" _("Tools pool from which the algorithm\n"
"will pick the ones used for copper clearing.") "will pick the ones used for copper clearing.")
) )
self.tools_box.addWidget(self.tools_table_label) self.tools_box.addWidget(self.tools_table_label)
@@ -87,33 +87,33 @@ class NonCopperClear(FlatCAMTool, Gerber):
self.tools_table.horizontalHeaderItem(0).setToolTip( self.tools_table.horizontalHeaderItem(0).setToolTip(
_("This is the Tool Number.\n" _("This is the Tool Number.\n"
"Non copper clearing will start with the tool with the biggest \n" "Non copper clearing will start with the tool with the biggest \n"
"diameter, continuing until there are no more tools.\n" "diameter, continuing until there are no more tools.\n"
"Only tools that create NCC clearing geometry will still be present\n" "Only tools that create NCC clearing geometry will still be present\n"
"in the resulting geometry. This is because with some tools\n" "in the resulting geometry. This is because with some tools\n"
"this function will not be able to create painting geometry.") "this function will not be able to create painting geometry.")
) )
self.tools_table.horizontalHeaderItem(1).setToolTip( self.tools_table.horizontalHeaderItem(1).setToolTip(
_("Tool Diameter. It's value (in current FlatCAM units) \n" _("Tool Diameter. It's value (in current FlatCAM units) \n"
"is the cut width into the material.")) "is the cut width into the material."))
self.tools_table.horizontalHeaderItem(2).setToolTip( self.tools_table.horizontalHeaderItem(2).setToolTip(
_("The Tool Type (TT) can be:<BR>" _("The Tool Type (TT) can be:<BR>"
"- <B>Circular</B> with 1 ... 4 teeth -> it is informative only. Being circular, <BR>" "- <B>Circular</B> with 1 ... 4 teeth -> it is informative only. Being circular, <BR>"
"the cut width in material is exactly the tool diameter.<BR>" "the cut width in material is exactly the tool diameter.<BR>"
"- <B>Ball</B> -> informative only and make reference to the Ball type endmill.<BR>" "- <B>Ball</B> -> informative only and make reference to the Ball type endmill.<BR>"
"- <B>V-Shape</B> -> it will disable de Z-Cut parameter in the resulting geometry UI form " "- <B>V-Shape</B> -> it will disable de Z-Cut parameter in the resulting geometry UI form "
"and enable two additional UI form fields in the resulting geometry: V-Tip Dia and " "and enable two additional UI form fields in the resulting geometry: V-Tip Dia and "
"V-Tip Angle. Adjusting those two values will adjust the Z-Cut parameter such " "V-Tip Angle. Adjusting those two values will adjust the Z-Cut parameter such "
"as the cut width into material will be equal with the value in the Tool Diameter " "as the cut width into material will be equal with the value in the Tool Diameter "
"column of this table.<BR>" "column of this table.<BR>"
"Choosing the <B>V-Shape</B> Tool Type automatically will select the Operation Type " "Choosing the <B>V-Shape</B> Tool Type automatically will select the Operation Type "
"in the resulting geometry as Isolation.")) "in the resulting geometry as Isolation."))
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)
@@ -134,7 +134,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
self.addtool_btn = QtWidgets.QPushButton(_('Add')) self.addtool_btn = QtWidgets.QPushButton(_('Add'))
self.addtool_btn.setToolTip( self.addtool_btn.setToolTip(
_("Add a new tool to the Tool Table\n" _("Add a new tool to the Tool Table\n"
"with the diameter specified above.") "with the diameter specified above.")
) )
# self.copytool_btn = QtWidgets.QPushButton('Copy') # self.copytool_btn = QtWidgets.QPushButton('Copy')
@@ -146,12 +146,12 @@ class NonCopperClear(FlatCAMTool, Gerber):
self.deltool_btn = QtWidgets.QPushButton(_('Delete')) self.deltool_btn = QtWidgets.QPushButton(_('Delete'))
self.deltool_btn.setToolTip( self.deltool_btn.setToolTip(
_("Delete a selection of tools in the Tool Table\n" _("Delete a selection of tools in the Tool Table\n"
"by first selecting a row(s) in the Tool Table.") "by first selecting a row(s) in the Tool Table.")
) )
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)
@@ -165,14 +165,14 @@ class NonCopperClear(FlatCAMTool, Gerber):
nccoverlabel = QtWidgets.QLabel(_('Overlap Rate:')) nccoverlabel = QtWidgets.QLabel(_('Overlap Rate:'))
nccoverlabel.setToolTip( nccoverlabel.setToolTip(
_("How much (fraction) of the tool width to overlap each tool pass.\n" _("How much (fraction) of the tool width to overlap each tool pass.\n"
"Example:\n" "Example:\n"
"A value here of 0.25 means 25% from the tool diameter found above.\n\n" "A value here of 0.25 means 25% from the tool diameter found above.\n\n"
"Adjust the value starting with lower values\n" "Adjust the value starting with lower values\n"
"and increasing it if areas that should be cleared are still \n" "and increasing it if areas that should be cleared are still \n"
"not cleared.\n" "not cleared.\n"
"Lower values = faster processing, faster execution on PCB.\n" "Lower values = faster processing, faster execution on PCB.\n"
"Higher values = slow processing and slow execution on CNC\n" "Higher values = slow processing and slow execution on CNC\n"
"due of too many paths.") "due of too many paths.")
) )
grid3.addWidget(nccoverlabel, 1, 0) grid3.addWidget(nccoverlabel, 1, 0)
self.ncc_overlap_entry = FCEntry() self.ncc_overlap_entry = FCEntry()
@@ -190,9 +190,9 @@ class NonCopperClear(FlatCAMTool, Gerber):
methodlabel = QtWidgets.QLabel(_('Method:')) methodlabel = QtWidgets.QLabel(_('Method:'))
methodlabel.setToolTip( methodlabel.setToolTip(
_("Algorithm for non-copper clearing:<BR>" _("Algorithm for non-copper clearing:<BR>"
"<B>Standard</B>: Fixed step inwards.<BR>" "<B>Standard</B>: Fixed step inwards.<BR>"
"<B>Seed-based</B>: Outwards from seed.<BR>" "<B>Seed-based</B>: Outwards from seed.<BR>"
"<B>Line-based</B>: Parallel lines.") "<B>Line-based</B>: Parallel lines.")
) )
grid3.addWidget(methodlabel, 3, 0) grid3.addWidget(methodlabel, 3, 0)
self.ncc_method_radio = RadioSet([ self.ncc_method_radio = RadioSet([
@@ -206,7 +206,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
pathconnectlabel = QtWidgets.QLabel(_("Connect:")) pathconnectlabel = QtWidgets.QLabel(_("Connect:"))
pathconnectlabel.setToolTip( pathconnectlabel.setToolTip(
_("Draw lines between resulting\n" _("Draw lines between resulting\n"
"segments to minimize tool lifts.") "segments to minimize tool lifts.")
) )
grid3.addWidget(pathconnectlabel, 4, 0) grid3.addWidget(pathconnectlabel, 4, 0)
self.ncc_connect_cb = FCCheckBox() self.ncc_connect_cb = FCCheckBox()
@@ -215,7 +215,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
contourlabel = QtWidgets.QLabel(_("Contour:")) contourlabel = QtWidgets.QLabel(_("Contour:"))
contourlabel.setToolTip( contourlabel.setToolTip(
_("Cut around the perimeter of the polygon\n" _("Cut around the perimeter of the polygon\n"
"to trim rough edges.") "to trim rough edges.")
) )
grid3.addWidget(contourlabel, 5, 0) grid3.addWidget(contourlabel, 5, 0)
self.ncc_contour_cb = FCCheckBox() self.ncc_contour_cb = FCCheckBox()
@@ -224,12 +224,12 @@ class NonCopperClear(FlatCAMTool, Gerber):
restlabel = QtWidgets.QLabel(_("Rest M.:")) restlabel = QtWidgets.QLabel(_("Rest M.:"))
restlabel.setToolTip( restlabel.setToolTip(
_("If checked, use 'rest machining'.\n" _("If checked, use 'rest machining'.\n"
"Basically it will clear copper outside PCB features,\n" "Basically it will clear copper outside PCB features,\n"
"using the biggest tool and continue with the next tools,\n" "using the biggest tool and continue with the next tools,\n"
"from bigger to smaller, to clear areas of copper that\n" "from bigger to smaller, to clear areas of copper that\n"
"could not be cleared by previous tool, until there is\n" "could not be cleared by previous tool, until there is\n"
"no more copper to clear or there are no more tools.\n" "no more copper to clear or there are no more tools.\n"
"If not checked, use the standard algorithm.") "If not checked, use the standard algorithm.")
) )
grid3.addWidget(restlabel, 6, 0) grid3.addWidget(restlabel, 6, 0)
self.ncc_rest_cb = FCCheckBox() self.ncc_rest_cb = FCCheckBox()
@@ -238,7 +238,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
self.generate_ncc_button = QtWidgets.QPushButton(_('Generate Geometry')) self.generate_ncc_button = QtWidgets.QPushButton(_('Generate Geometry'))
self.generate_ncc_button.setToolTip( self.generate_ncc_button.setToolTip(
_("Create the Geometry Object\n" _("Create the Geometry Object\n"
"for non-copper routing.") "for non-copper routing.")
) )
self.tools_box.addWidget(self.generate_ncc_button) self.tools_box.addWidget(self.generate_ncc_button)
@@ -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
@@ -478,7 +479,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
tool_dia = float(self.addtool_entry.get_value().replace(',', '.')) tool_dia = float(self.addtool_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
if tool_dia is None: if tool_dia is None:
self.build_ui() self.build_ui()
@@ -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):
@@ -625,13 +628,13 @@ class NonCopperClear(FlatCAMTool, Gerber):
over = float(self.ncc_overlap_entry.get_value().replace(',', '.')) over = float(self.ncc_overlap_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
over = over if over else self.app.defaults["tools_nccoverlap"] over = over if over else self.app.defaults["tools_nccoverlap"]
if over >= 1 or over < 0: if over >= 1 or over < 0:
self.app.inform.emit(_("[ERROR_NOTCL] Overlap value must be between " self.app.inform.emit(_("[ERROR_NOTCL] Overlap value must be between "
"0 (inclusive) and 1 (exclusive), ")) "0 (inclusive) and 1 (exclusive), "))
return return
try: try:
@@ -642,7 +645,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
margin = float(self.ncc_margin_entry.get_value().replace(',', '.')) margin = float(self.ncc_margin_entry.get_value().replace(',', '.'))
except ValueError: except ValueError:
self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, " self.app.inform.emit(_("[ERROR_NOTCL] Wrong value format entered, "
"use a number.")) "use a number."))
return return
margin = margin if margin else self.app.defaults["tools_nccmargin"] margin = margin if margin else self.app.defaults["tools_nccmargin"]
@@ -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
@@ -850,7 +854,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
tool = sorted_tools.pop(0) tool = sorted_tools.pop(0)
self.app.inform.emit(_('[success] Non-Copper Rest Clearing with ToolDia = %s started.') % str(tool)) self.app.inform.emit(_('[success] Non-Copper Rest Clearing with ToolDia = %s started.') % str(tool))
tool_used = tool - 1e-12 tool_used = tool - 1e-12
cleared_geo[:] = [] cleared_geo[:] = []
# Area to clear # Area to clear
@@ -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()))