From 9855405b2e52cb45eac10ea02aabd4cc21785042 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sun, 7 Mar 2021 20:44:34 +0200 Subject: [PATCH] - Levelling Tool - mare sure that there are no duplicate seed points when creating Voronoi polygons - Levelling Tool - fix of missing variable declaration (forgot to take everything when I moved the functionality from the CNCJob class to its own class) --- CHANGELOG.md | 5 +++++ appObjects/FlatCAMCNCJob.py | 3 --- appPlugins/ToolLevelling.py | 14 +++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 030c0c2c..a11fe4ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ CHANGELOG for FlatCAM beta ================================================= +7.03.2021 + +- Levelling Tool - mare sure that there are no duplicate seed points when creating Voronoi polygons +- Levelling Tool - fix of missing variable declaration (forgot to take everything when I moved the functionality from the CNCJob class to its own class) + 6.03.2021 - some minor updates to NCC Tool diff --git a/appObjects/FlatCAMCNCJob.py b/appObjects/FlatCAMCNCJob.py index bb7259f3..300b5b53 100644 --- a/appObjects/FlatCAMCNCJob.py +++ b/appObjects/FlatCAMCNCJob.py @@ -164,9 +164,6 @@ class CNCJobObject(FlatCAMObj, CNCjob): self.source_file = '' self.units_found = self.app.defaults['units'] - # store the current selection shape status to be restored after manual adding test points - self.old_selection_state = self.app.defaults['global_selection_shape'] - self.prepend_snippet = '' self.append_snippet = '' self.gc_header = self.gcode_header() diff --git a/appPlugins/ToolLevelling.py b/appPlugins/ToolLevelling.py index 36f22efa..1a948ebf 100644 --- a/appPlugins/ToolLevelling.py +++ b/appPlugins/ToolLevelling.py @@ -124,6 +124,9 @@ class ToolLevelling(AppTool, CNCjob): self.gcode_viewer_tab = None + # store the current selection shape status to be restored after manual adding test points + self.old_selection_state = self.app.defaults['global_selection_shape'] + # ############################################################################################################# # ####################################### Signals ########################################################### # ############################################################################################################# @@ -520,7 +523,9 @@ class ToolLevelling(AppTool, CNCjob): self.app.dec_format(new_x, self.app.decimals), self.app.dec_format(new_y, self.app.decimals) ) - points.append(formatted_point) + # do not add the point if is already added + if formatted_point not in points: + points.append(formatted_point) new_x += dx new_y += dy @@ -812,6 +817,11 @@ class ToolLevelling(AppTool, CNCjob): # use the snapped position as reference snapped_pos = self.app.geo_editor.snap(pos[0], pos[1]) + # do not add the point if is already added + old_points_coords = [(pt['point'].x, pt['point'].y) for pt in self.al_voronoi_geo_storage.values()] + if (snapped_pos[0], snapped_pos[1]) in old_points_coords: + return + probe_pt = Point(snapped_pos) xxmin, yymin, xxmax, yymax = self.solid_geo.bounds @@ -930,6 +940,8 @@ class ToolLevelling(AppTool, CNCjob): self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot) self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot) + # restore selection + self.app.defaults['global_selection_shape'] = self.old_selection_state # Grid toggle if key == QtCore.Qt.Key_G or key == 'G':