From c85d04bc0a5658710254dce1baf299e025eebaea Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 18 Jan 2023 01:32:28 +0200 Subject: [PATCH] - in Autolevelling Tool, when adding manual probe points, added an option that prevent adding a probe point within a drill hole of an Excellon object that is plotted on canvas --- CHANGELOG.md | 2 +- appPlugins/ToolLevelling.py | 33 +++++++++++++++++++++++++++++++-- defaults.py | 2 ++ 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b0d8b928..a7310c70 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ CHANGELOG for FlatCAM Evo beta 18.01.2023 - in Autolevelling Tool made sure that when adding manual probe points mouse dragging with the right button is not counted as end of adding operation - +- in Autolevelling Tool, when adding manual probe points, added an option that prevent adding a probe point within a drill hole of an Excellon object that is plotted on canvas 16.01.2023 diff --git a/appPlugins/ToolLevelling.py b/appPlugins/ToolLevelling.py index 9957c288..eeaeea11 100644 --- a/appPlugins/ToolLevelling.py +++ b/appPlugins/ToolLevelling.py @@ -828,7 +828,6 @@ class ToolLevelling(AppTool, CNCjob): # To be called after clicking on the plot. def on_mouse_click_release(self, event): - if self.app.use_3d_engine: event_pos = event.pos right_button = 2 @@ -845,8 +844,9 @@ class ToolLevelling(AppTool, CNCjob): # do paint single only for left mouse clicks if event.button == 1: - pos = self.app.plotcanvas.translate_coords(event_pos) + check_for_exc_hole = self.ui.avoid_exc_holes_cb.get_value() + pos = self.app.plotcanvas.translate_coords(event_pos) # use the snapped position as reference snapped_pos = self.app.geo_editor.snap(pos[0], pos[1]) @@ -855,6 +855,7 @@ class ToolLevelling(AppTool, CNCjob): if (snapped_pos[0], snapped_pos[1]) in old_points_coords: return + # Clicked Point probe_pt = Point(snapped_pos) xxmin, yymin, xxmax, yymax = self.solid_geo.bounds @@ -863,6 +864,16 @@ class ToolLevelling(AppTool, CNCjob): self.app.inform.emit(_("Point is not within the object area. Choose another point.")) return + # check if chosen point is within an Excellon drill hole geometry + if check_for_exc_hole is True: + for obj_in_collection in self.app.collection.get_list(): + if obj_in_collection.kind == 'excellon' and obj_in_collection.obj_options['plot'] is True: + exc_solid_geometry = MultiPolygon(obj_in_collection.solid_geometry) + for exc_geo in exc_solid_geometry.geoms: + if probe_pt.within(exc_geo): + self.app.inform.emit(_("Point on an Excellon drill hole. Choose another point.")) + return + int_keys = [int(k) for k in self.al_voronoi_geo_storage.keys()] new_id = max(int_keys) + 1 if int_keys else 1 new_dict = { @@ -1847,6 +1858,7 @@ class LevelUI: tool_grid = GLay(v_spacing=5, h_spacing=3, c_stretch=[0, 0]) tt_frame.setLayout(tool_grid) + # Probe Points table self.al_probe_points_table = FCTable() self.al_probe_points_table.setColumnCount(3) self.al_probe_points_table.setColumnWidth(0, 20) @@ -1854,6 +1866,7 @@ class LevelUI: tool_grid.addWidget(self.al_probe_points_table, 0, 0, 1, 2) + # Plot Probe Points self.plot_probing_pts_cb = FCCheckBox(_("Plot probing points")) self.plot_probing_pts_cb.setToolTip( _("Plot the probing points in the table.\n" @@ -1862,6 +1875,13 @@ class LevelUI: ) tool_grid.addWidget(self.plot_probing_pts_cb, 2, 0, 1, 2) + # Avoid Excellon holes + self.avoid_exc_holes_cb = FCCheckBox(_("Avoid Excellon holes")) + self.avoid_exc_holes_cb.setToolTip( + _("When active, the user cannot add probe points over a drill hole.") + ) + tool_grid.addWidget(self.avoid_exc_holes_cb, 4, 0, 1, 2) + # ############################################################################################################# # ############### Probe GCode Generation ###################################################################### # ############################################################################################################# @@ -2364,6 +2384,9 @@ class LevelUI: # ############################ FINISHED GUI ################################### # ############################################################################# + self.plot_probing_pts_cb.stateChanged.connect(self.on_plot_points_changed) + self.avoid_exc_holes_cb.stateChanged.connect(self.on_avoid_exc_holes_changed) + def confirmation_message(self, accepted, minval, maxval): if accepted is False: self.app.inform[str, bool].emit('[WARNING_NOTCL] %s: [%.*f, %.*f]' % (_("Edited value is out of range"), @@ -2380,3 +2403,9 @@ class LevelUI: (_("Edited value is out of range"), minval, maxval), False) else: self.app.inform[str, bool].emit('[success] %s' % _("Edited value is within limits."), False) + + def on_plot_points_changed(self, state): + self.app.defaults["tools_al_plot_points"] = False if not state else True + + def on_avoid_exc_holes_changed(self, state): + self.app.defaults["tools_al_avoid_exc_holes"] = False if not state else True diff --git a/defaults.py b/defaults.py index 32135555..4c79a9d0 100644 --- a/defaults.py +++ b/defaults.py @@ -503,6 +503,8 @@ class AppDefaults: "tools_mill_search_time": 3, # Autolevelling Plugin + "tools_al_plot_points": False, + "tools_al_avoid_exc_holes": False, "tools_al_status": False, "tools_al_mode": 'grid', "tools_al_method": 'v',