From 6c2bdabc3d839637e1bfae3c36f1a3de2301b38e Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Fri, 3 May 2024 13:10:15 +0200 Subject: [PATCH] Draft: Do not show temporary line object in tree (additional) #13778 introduced `self.obj.ViewObject.ShowInTree = False` to hide the temporary object. But objects that are hidden in the tree are displayed in the tree when they are selected in the 3D view. This selection occurs during commands that take more than 2 points. The solution is to change `self.obj.ViewObject.Selectable` on mouse button up/down. Fixes #13700. --- src/Mod/Draft/draftguitools/gui_lines.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_lines.py b/src/Mod/Draft/draftguitools/gui_lines.py index 8286d65742..4fbd8232ff 100644 --- a/src/Mod/Draft/draftguitools/gui_lines.py +++ b/src/Mod/Draft/draftguitools/gui_lines.py @@ -95,12 +95,19 @@ class Line(gui_base_original.Creator): """ if arg["Type"] == "SoKeyboardEvent" and arg["Key"] == "ESCAPE": self.finish() - elif arg["Type"] == "SoLocation2Event": + return + if arg["Type"] == "SoLocation2Event": self.point, ctrlPoint, info = gui_tool_utils.getPoint(self, arg) gui_tool_utils.redraw3DView() - elif (arg["Type"] == "SoMouseButtonEvent" - and arg["State"] == "DOWN" - and arg["Button"] == "BUTTON1"): + return + if arg["Type"] != "SoMouseButtonEvent": + return + if arg["State"] == "UP": + self.obj.ViewObject.Selectable = True + return + if arg["State"] == "DOWN" and arg["Button"] == "BUTTON1": + # Stop self.obj from being selected to avoid its display in the tree: + self.obj.ViewObject.Selectable = False if arg["Position"] == self.pos: self.finish(cont=None) return @@ -219,6 +226,7 @@ class Line(gui_base_original.Creator): def drawSegment(self, point): """Draws new line segment.""" + import Part if self.planetrack and self.node: self.planetrack.set(self.node[-1]) @@ -229,6 +237,7 @@ class Line(gui_base_original.Creator): newseg = Part.LineSegment(last, point).toShape() self.obj.Shape = newseg self.obj.ViewObject.Visibility = True + self.obj.ViewObject.ShowInTree = False if self.isWire: _toolmsg(translate("draft", "Pick next point")) else: @@ -238,6 +247,7 @@ class Line(gui_base_original.Creator): newseg = Part.LineSegment(last, point).toShape() newshape = currentshape.fuse(newseg) self.obj.Shape = newshape + _toolmsg(translate("draft", "Pick next point")) def wipe(self): @@ -245,6 +255,7 @@ class Line(gui_base_original.Creator): if len(self.node) > 1: # self.obj.Shape.nullify() # For some reason this fails self.obj.ViewObject.Visibility = False + self.obj.ViewObject.ShowInTree = False self.node = [self.node[-1]] if self.planetrack: self.planetrack.set(self.node[0])