From d8bf1a8a4ec63bf5ab684a5f1e99b01371635e05 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 30 May 2020 17:15:42 +0300 Subject: [PATCH] - In Tool Isolation made sure that the use of ESC key while some processes are active will disconnect the mouse events that may be connected, correctly --- AppTools/ToolIsolation.py | 94 ++++++++++++++++++++++++--------------- App_Main.py | 6 ++- CHANGELOG.md | 1 + 3 files changed, 65 insertions(+), 36 deletions(-) diff --git a/AppTools/ToolIsolation.py b/AppTools/ToolIsolation.py index c58de96a..d0375faf 100644 --- a/AppTools/ToolIsolation.py +++ b/AppTools/ToolIsolation.py @@ -669,6 +669,10 @@ class ToolIsolation(AppTool, Gerber): self.pool = self.app.pool self.results = [] + # disconnect flags + self.area_sel_disconnect_flag = False + self.poly_sel_disconnect_flag = False + self.form_fields = { "tools_iso_passes": self.passes_entry, "tools_iso_overlap": self.iso_overlap_entry, @@ -1676,6 +1680,9 @@ class ToolIsolation(AppTool, Gerber): self.mm = self.app.plotcanvas.graph_event_connect('mouse_move', self.on_mouse_move) self.kp = self.app.plotcanvas.graph_event_connect('key_press', self.on_key_press) + # disconnect flags + self.area_sel_disconnect_flag = True + elif selection == _("Polygon Selection"): # disengage the grid snapping since it may be hard to click on polygons with grid snapping on if self.app.ui.grid_snap_btn.isChecked(): @@ -1693,6 +1700,9 @@ class ToolIsolation(AppTool, Gerber): else: self.app.plotcanvas.graph_event_disconnect(self.app.mr) + # disconnect flags + self.poly_sel_disconnect_flag = True + self.app.inform.emit('[WARNING_NOTCL] %s' % _("Click on a polygon to isolate it.")) elif selection == _("Reference Object"): ref_obj = self.app.collection.get_by_name(self.reference_combo.get_value()) @@ -1800,24 +1810,9 @@ class ToolIsolation(AppTool, Gerber): self.app.proc_container.update_view_text(' %s' % _("Intersecting Geo")) iso_geo = self.area_intersection(iso_geo, intersection_geo=limited_area) - # transfer the Cut Z and Vtip and VAngle values in case that we use the V-Shape tool in - # Gerber UI - if tool_type.lower() == 'v': - new_cutz = self.cutz_entry.get_value() - new_vtipdia = self.tipdia_entry.get_value() - new_vtipangle = self.tipangle_entry.get_value() - tool_type = 'V' - tool_data.update({ - "name": iso_name, - "cutz": new_cutz, - "vtipdia": new_vtipdia, - "vtipangle": new_vtipangle, - }) - else: - tool_data.update({ - "name": iso_name, - }) - tool_type = 'C1' + tool_data.update({ + "name": iso_name, + }) def iso_init(geo_obj, fc_obj): # Propagate options @@ -2148,10 +2143,14 @@ class ToolIsolation(AppTool, Gerber): geo_obj.multigeo = True else: if to_follow: - passes_no = 1 + geo_obj.multigeo = False else: - passes_no = float(tools_storage[0]['data']['tools_iso_passes']) - geo_obj.multigeo = True if passes_no > 1 else False + passes_no = 1 + for ky in tools_storage.keys(): + passes_no = float(tools_storage[ky]['data']['tools_iso_passes']) + geo_obj.multigeo = True if passes_no > 1 else False + break + geo_obj.multigeo = True if passes_no > 1 else False # detect if solid_geometry is empty and this require list flattening which is "heavy" # or just looking in the lists (they are one level depth) and if any is not empty @@ -2361,6 +2360,9 @@ class ToolIsolation(AppTool, Gerber): self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot) + # disconnect flags + self.poly_sel_disconnect_flag = False + self.app.tool_shapes.clear(update=True) if self.poly_dict: @@ -2547,6 +2549,9 @@ class ToolIsolation(AppTool, Gerber): self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot) + # disconnect flags + self.area_sel_disconnect_flag = False + if len(self.sel_rect) == 0: return @@ -2651,21 +2656,39 @@ class ToolIsolation(AppTool, Gerber): key = event.key if key == QtCore.Qt.Key_Escape or key == 'Escape': - if self.app.is_legacy is False: - self.app.plotcanvas.graph_event_disconnect('mouse_release', self.on_mouse_release) - self.app.plotcanvas.graph_event_disconnect('mouse_move', self.on_mouse_move) - self.app.plotcanvas.graph_event_disconnect('key_press', self.on_key_press) - else: - self.app.plotcanvas.graph_event_disconnect(self.mr) - self.app.plotcanvas.graph_event_disconnect(self.mm) - self.app.plotcanvas.graph_event_disconnect(self.kp) - self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press', - self.app.on_mouse_click_over_plot) - self.app.mm = self.app.plotcanvas.graph_event_connect('mouse_move', - self.app.on_mouse_move_over_plot) - self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release', - self.app.on_mouse_click_release_over_plot) + if self.area_sel_disconnect_flag is True: + if self.app.is_legacy is False: + self.app.plotcanvas.graph_event_disconnect('mouse_release', self.on_mouse_release) + self.app.plotcanvas.graph_event_disconnect('mouse_move', self.on_mouse_move) + self.app.plotcanvas.graph_event_disconnect('key_press', self.on_key_press) + else: + self.app.plotcanvas.graph_event_disconnect(self.mr) + self.app.plotcanvas.graph_event_disconnect(self.mm) + self.app.plotcanvas.graph_event_disconnect(self.kp) + + self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press', + self.app.on_mouse_click_over_plot) + self.app.mm = self.app.plotcanvas.graph_event_connect('mouse_move', + self.app.on_mouse_move_over_plot) + self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release', + self.app.on_mouse_click_release_over_plot) + + if self.poly_sel_disconnect_flag is False: + # restore the Grid snapping if it was active before + if self.grid_status_memory is True: + self.app.ui.grid_snap_btn.trigger() + + if self.app.is_legacy is False: + self.app.plotcanvas.graph_event_disconnect('mouse_release', self.on_poly_mouse_click_release) + self.app.plotcanvas.graph_event_disconnect('key_press', self.on_key_pres) + else: + self.app.plotcanvas.graph_event_disconnect(self.mr) + self.app.plotcanvas.graph_event_disconnect(self.kp) + + self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release', + self.app.on_mouse_click_release_over_plot) + self.points = [] self.poly_drawn = False self.delete_moving_selection_shape() @@ -2909,6 +2932,7 @@ class ToolIsolation(AppTool, Gerber): 'solid_geometry': [] } }) + self.iso_tools[tooluid]['data']['name'] = '_iso' self.app.inform.emit('[success] %s' % _("New tool added to Tool Table.")) diff --git a/App_Main.py b/App_Main.py index bef8defb..c708399b 100644 --- a/App_Main.py +++ b/App_Main.py @@ -4257,6 +4257,10 @@ class App(QtCore.QObject): # and only if the tool is Solder Paste Dispensing Tool elif tool_widget == self.paste_tool.toolName: self.paste_tool.on_tool_delete() + + # and only if the tool is Isolation Tool + elif tool_widget == self.isolation_tool.toolName: + self.isolation_tool.on_tool_delete() else: self.on_delete() @@ -4312,7 +4316,7 @@ class App(QtCore.QObject): obj_active.mark_shapes[el].enabled = False # obj_active.mark_shapes[el] = None del el - elif isinstance(obj_active, CNCJobObject): + elif obj_active.kind == 'cncjob': try: obj_active.text_col.enabled = False del obj_active.text_col diff --git a/CHANGELOG.md b/CHANGELOG.md index aa2da91e..649d7089 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ CHANGELOG for FlatCAM beta - Isolation Tool: updated the tools dict with the common parameters value on isolating - Fixed a recent change that made the edited Geometry objects in the Geometry Editor not to be plotted after saving changes - modified the Tool Database such that when a tool shape is selected as 'V' any change in the Vdia or Vangle or CutZ parameters will update the tool diameter value +- In Tool Isolation made sure that the use of ESC key while some processes are active will disconnect the mouse events that may be connected, correctly 29.05.2020