- fixed a bug in milling holes due of a message wrongly formatted

This commit is contained in:
Marius Stanciu
2019-10-17 15:29:52 +03:00
parent e57b6ad082
commit 9f99520683
5 changed files with 49 additions and 107 deletions

View File

@@ -562,7 +562,6 @@ class FCSlotArray(FCShapeTool):
_("To add an Slot Array first select a tool in Tool Table"))
return
try:
QtGui.QGuiApplication.restoreOverrideCursor()
except Exception as e:
@@ -1012,7 +1011,6 @@ class FCDrillResize(FCShapeTool):
sel_shapes_to_be_deleted.append(select_shape)
# a hack to make the tool_table display more drills/slots per diameter when shape(drill/slot)
# is added.
# self.points_edit it's only useful first time when we load the data into the storage
@@ -3090,7 +3088,6 @@ class FlatCAMExcEditor(QtCore.QObject):
# element[1] of the tuple is a list of coordinates (a tuple themselves)
ordered_edited_points = sorted(zip(edited_points.keys(), edited_points.values()))
current_tool = 0
for tool_dia in ordered_edited_points:
current_tool += 1
@@ -3214,7 +3211,7 @@ class FlatCAMExcEditor(QtCore.QObject):
except KeyError:
self.app.inform.emit('[ERROR_NOTCL] %s' %
_("There are no Tools definitions in the file. Aborting Excellon creation.")
)
)
except:
msg = '[ERROR] %s' % \
_("An internal error has ocurred. See Shell.\n")
@@ -3325,7 +3322,7 @@ class FlatCAMExcEditor(QtCore.QObject):
self.pos = self.canvas.translate_coords(event_pos)
if self.app.grid_status() == True:
self.pos = self.app.geo_editor.snap(self.pos[0], self.pos[1])
self.pos = self.app.geo_editor.snap(self.pos[0], self.pos[1])
else:
self.pos = (self.pos[0], self.pos[1])
@@ -3560,14 +3557,14 @@ class FlatCAMExcEditor(QtCore.QObject):
for storage in self.storage_dict:
for obj in self.storage_dict[storage].get_objects():
if (sel_type is True and poly_selection.contains(obj.geo)) or \
(sel_type is False and poly_selection.intersects(obj.geo)):
(sel_type is False and poly_selection.intersects(obj.geo)):
if obj in self.selected:
# remove the shape object from the selected shapes storage
self.selected.remove(obj)
else:
# add the shape object to the selected shapes storage
self.selected.append(obj)
if obj in self.selected:
# remove the shape object from the selected shapes storage
self.selected.remove(obj)
else:
# add the shape object to the selected shapes storage
self.selected.append(obj)
else:
# clear the selection shapes storage
self.selected = []
@@ -3883,7 +3880,8 @@ class FlatCAMExcEditor(QtCore.QObject):
# self.points_edit it's only useful first time when we load the data into the storage
# but is still used as referecen when building tool_table in self.build_ui()
# the number of drills displayed in column 2 is just a len(self.points_edit) therefore
# deleting self.points_edit elements (doesn't matter who but just the number) solved the display issue.
# deleting self.points_edit elements (doesn't matter who but just the number)
# solved the display issue.
del self.points_edit[storage][0]
else:
self.storage_dict[storage].remove(del_shape)

View File

@@ -2222,7 +2222,7 @@ class FCRectangle(FCShapeTool):
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
self.draw_app.app.inform.emit( _("Click on 1st corner ..."))
self.draw_app.app.inform.emit(_("Click on 1st corner ..."))
def click(self, point):
self.points.append(point)
@@ -2699,7 +2699,6 @@ class FCText(FCShapeTool):
self.cursor = QtGui.QCursor(QtGui.QPixmap('share/aero_text.png'))
QtGui.QGuiApplication.setOverrideCursor(self.cursor)
# self.shape_buffer = self.draw_app.shape_buffer
self.draw_app = draw_app
self.app = draw_app.app
@@ -2722,21 +2721,19 @@ class FCText(FCShapeTool):
log.debug("Font geometry is empty or incorrect: %s" % str(e))
self.draw_app.app.inform.emit('[ERROR] %s: %s' %
(_("Font not supported. Only Regular, Bold, Italic and BoldItalic are "
"supported. Error"), str(e)))
"supported. Error"), str(e)))
self.text_gui.text_path = []
self.text_gui.hide_tool()
self.draw_app.select_tool('select')
return
else:
self.draw_app.app.inform.emit('[WARNING_NOTCL] %s' %
_("No text to add."))
self.draw_app.app.inform.emit('[WARNING_NOTCL] %s' % _("No text to add."))
return
self.text_gui.text_path = []
self.text_gui.hide_tool()
self.complete = True
self.draw_app.app.inform.emit('[success]%s' %
_(" Done. Adding Text completed."))
self.draw_app.app.inform.emit('[success]%s' % _(" Done. Adding Text completed."))
def utility_geometry(self, data=None):
"""
@@ -3054,7 +3051,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
"text": {"button": self.app.ui.geo_add_text_btn,
"constructor": FCText},
"buffer": {"button": self.app.ui.geo_add_buffer_btn,
"constructor": FCBuffer},
"constructor": FCBuffer},
"paint": {"button": self.app.ui.geo_add_paint_btn,
"constructor": FCPaint},
"eraser": {"button": self.app.ui.geo_eraser_btn,
@@ -3062,11 +3059,11 @@ class FlatCAMGeoEditor(QtCore.QObject):
"move": {"button": self.app.ui.geo_move_btn,
"constructor": FCMove},
"transform": {"button": self.app.ui.geo_transform_btn,
"constructor": FCTransform},
"constructor": FCTransform},
"copy": {"button": self.app.ui.geo_copy_btn,
"constructor": FCCopy},
"explode": {"button": self.app.ui.geo_explode_btn,
"constructor": FCExplode}
"constructor": FCExplode}
}
# # ## Data
@@ -3496,7 +3493,6 @@ class FlatCAMGeoEditor(QtCore.QObject):
except (TypeError, AttributeError):
pass
try:
self.app.ui.draw_text.triggered.disconnect()
except (TypeError, AttributeError):
@@ -3555,12 +3551,8 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.add_shape(subshape)
return
assert isinstance(shape, DrawToolShape), \
"Expected a DrawToolShape, got %s" % type(shape)
assert shape.geo is not None, \
"Shape object has empty geometry (None)"
assert isinstance(shape, DrawToolShape), "Expected a DrawToolShape, got %s" % type(shape)
assert shape.geo is not None, "Shape object has empty geometry (None)"
assert (isinstance(shape.geo, list) and len(shape.geo) > 0) or \
not isinstance(shape.geo, list), "Shape objects has empty geometry ([])"
@@ -4116,13 +4108,17 @@ class FlatCAMGeoEditor(QtCore.QObject):
continue
if shape in self.selected:
self.plot_shape(geometry=shape.geo, color=self.app.defaults['global_sel_draw_color'] + 'FF', linewidth=2)
self.plot_shape(geometry=shape.geo,
color=self.app.defaults['global_sel_draw_color'] + 'FF',
linewidth=2)
continue
self.plot_shape(geometry=shape.geo, color=self.app.defaults['global_draw_color'] + "FF")
self.plot_shape(geometry=shape.geo,
color=self.app.defaults['global_draw_color'] + "FF")
for shape in self.utility:
self.plot_shape(geometry=shape.geo, linewidth=1)
self.plot_shape(geometry=shape.geo,
linewidth=1)
continue
self.shapes.redraw()
@@ -4482,7 +4478,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
results = []
for t in selected:
if isinstance(t.geo, Polygon) and not t.geo.is_empty:
results.append((t.geo.exterior).buffer(
results.append(t.geo.exterior.buffer(
buf_distance - 1e-10,
resolution=int(int(self.app.defaults["geometry_circle_steps"]) / 4),
join_style=join_style)
@@ -4513,22 +4509,18 @@ class FlatCAMGeoEditor(QtCore.QObject):
selected = self.get_selected()
if buf_distance < 0:
self.app.inform.emit('[ERROR_NOTCL] %s' %
_("Negative buffer value is not accepted.")
)
self.app.inform.emit('[ERROR_NOTCL] %s' % _("Negative buffer value is not accepted."))
# deselect everything
self.selected = []
self.replot()
return 'fail'
if len(selected) == 0:
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("Nothing selected for buffering."))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Nothing selected for buffering."))
return 'fail'
if not isinstance(buf_distance, float):
self.app.inform.emit('[WARNING_NOTCL] %s' %
_("Invalid distance for buffering."))
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Invalid distance for buffering."))
# deselect everything
self.selected = []
self.replot()
@@ -4540,7 +4532,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
t.geo = Polygon(t.geo)
if isinstance(t.geo, Polygon) and not t.geo.is_empty:
results.append((t.geo).buffer(
results.append(t.geo.buffer(
-buf_distance + 1e-10,
resolution=int(int(self.app.defaults["geometry_circle_steps"]) / 4),
join_style=join_style)
@@ -4558,8 +4550,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.add_shape(DrawToolShape(sha))
self.replot()
self.app.inform.emit('[success] %s' %
_("Interior buffer geometry created."))
self.app.inform.emit('[success] %s' % _("Interior buffer geometry created."))
def buffer_ext(self, buf_distance, join_style):
selected = self.get_selected()
@@ -4592,7 +4583,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
t.geo = Polygon(t.geo)
if isinstance(t.geo, Polygon) and not t.geo.is_empty:
results.append((t.geo).buffer(
results.append(t.geo.buffer(
buf_distance,
resolution=int(int(self.app.defaults["geometry_circle_steps"]) / 4),
join_style=join_style)
@@ -4610,68 +4601,11 @@ class FlatCAMGeoEditor(QtCore.QObject):
self.add_shape(DrawToolShape(sha))
self.replot()
self.app.inform.emit('[success] %s' %
_("Exterior buffer geometry created."))
# def paint(self, tooldia, overlap, margin, method):
# selected = self.get_selected()
#
# if len(selected) == 0:
# self.app.inform.emit("[WARNING] Nothing selected for painting.")
# return
#
# for param in [tooldia, overlap, margin]:
# if not isinstance(param, float):
# param_name = [k for k, v in locals().items() if v is param][0]
# self.app.inform.emit("[WARNING] Invalid value for {}".format(param))
#
# # Todo: Check for valid method.
#
# # Todo: This is the 3rd implementation on painting polys... try to consolidate
#
# results = []
#
# def recurse(geo):
# try:
# for subg in geo:
# for subsubg in recurse(subg):
# yield subsubg
# except TypeError:
# if isinstance(geo, LinearRing):
# yield geo
#
# raise StopIteration
#
# for geo in selected:
# print(type(geo.geo))
#
# local_results = []
# for poly in recurse(geo.geo):
# if method == "seed":
# # Type(cp) == FlatCAMRTreeStorage | None
# cp = Geometry.clear_polygon2(poly.buffer(-margin),
# tooldia, overlap=overlap)
#
# else:
# # Type(cp) == FlatCAMRTreeStorage | None
# cp = Geometry.clear_polygon(poly.buffer(-margin),
# tooldia, overlap=overlap)
#
# if cp is not None:
# local_results += list(cp.get_objects())
#
# results.append(cascaded_union(local_results))
#
# # This is a dirty patch:
# for r in results:
# self.add_shape(DrawToolShape(r))
#
# self.replot()
self.app.inform.emit('[success] %s' % _("Exterior buffer geometry created."))
def paint(self, tooldia, overlap, margin, connect, contour, method):
self.paint_tooldia = tooldia
selected = self.get_selected()
if len(selected) == 0: