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.
This commit is contained in:
Roy-043
2024-05-03 13:10:15 +02:00
committed by Yorik van Havre
parent 68ed7c1503
commit 6c2bdabc3d

View File

@@ -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])