Skip to content

Commit

Permalink
Draft: Do not show temporary line object in tree (additional)
Browse files Browse the repository at this point in the history
#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.
  • Loading branch information
Roy-043 authored and yorikvanhavre committed May 6, 2024
1 parent fb51358 commit 22dc172
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/Mod/Draft/draftguitools/gui_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,19 @@ def action(self, arg):
"""
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
Expand Down Expand Up @@ -219,6 +226,7 @@ def undolast(self):

def drawSegment(self, point):
"""Draws new line segment."""

import Part
if self.planetrack and self.node:
self.planetrack.set(self.node[-1])
Expand All @@ -229,6 +237,7 @@ def drawSegment(self, point):
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:
Expand All @@ -238,13 +247,15 @@ def drawSegment(self, point):
newseg = Part.LineSegment(last, point).toShape()
newshape = currentshape.fuse(newseg)
self.obj.Shape = newshape

_toolmsg(translate("draft", "Pick next point"))

def wipe(self):
"""Remove all previous segments and starts from last point."""
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])
Expand Down

0 comments on commit 22dc172

Please sign in to comment.