mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-06 22:47:29 -06:00
Force updating the convex hull of a group node if one of its children is removed
Before this fix, if a subselection of a group was deleted from the group, the convex hull would not update. CURA-1054
This commit is contained in:
parent
4830943113
commit
9f2e87fdcb
1 changed files with 27 additions and 16 deletions
|
@ -8,11 +8,11 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
|||
def __init__(self):
|
||||
super().__init__()
|
||||
self._convex_hull = None
|
||||
|
||||
|
||||
# In case of printing all at once this is the same as the convex hull.
|
||||
# For one at the time this is the area without the head.
|
||||
self._convex_hull_boundary = None
|
||||
|
||||
|
||||
# In case of printing all at once this is the same as the convex hull.
|
||||
# For one at the time this is area with intersection of mirrored head
|
||||
self._convex_hull_head = None
|
||||
|
@ -20,15 +20,23 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
|||
# In case of printing all at once this is the same as the convex hull.
|
||||
# For one at the time this is area with intersection of full head
|
||||
self._convex_hull_head_full = None
|
||||
|
||||
|
||||
self._convex_hull_node = None
|
||||
self._convex_hull_job = None
|
||||
|
||||
# Keep track of the previous parent so we can clear its convex hull when the object is reparented
|
||||
self._parent_node = None
|
||||
|
||||
self._profile = None
|
||||
Application.getInstance().getMachineManager().activeProfileChanged.connect(self._onActiveProfileChanged)
|
||||
Application.getInstance().getMachineManager().activeMachineInstanceChanged.connect(self._onActiveMachineInstanceChanged)
|
||||
self._onActiveProfileChanged()
|
||||
|
||||
def setNode(self, node):
|
||||
super().setNode(node)
|
||||
self._parent_node = node.getParent()
|
||||
node.parentChanged.connect(self._onParentChanged)
|
||||
|
||||
## Force that a new (empty) object is created upon copy.
|
||||
def __deepcopy__(self, memo):
|
||||
copy = ConvexHullDecorator()
|
||||
|
@ -59,7 +67,7 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
|||
if not self._convex_hull_boundary:
|
||||
return self.getConvexHull()
|
||||
return self._convex_hull_boundary
|
||||
|
||||
|
||||
def setConvexHullBoundary(self, hull):
|
||||
self._convex_hull_boundary = hull
|
||||
|
||||
|
@ -68,22 +76,25 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
|||
|
||||
def setConvexHullHead(self, hull):
|
||||
self._convex_hull_head = hull
|
||||
|
||||
|
||||
def setConvexHull(self, hull):
|
||||
self._convex_hull = hull
|
||||
|
||||
if not hull and self._convex_hull_node:
|
||||
self._convex_hull_node.setParent(None)
|
||||
self._convex_hull_node = None
|
||||
|
||||
def getConvexHullJob(self):
|
||||
return self._convex_hull_job
|
||||
|
||||
|
||||
def setConvexHullJob(self, job):
|
||||
self._convex_hull_job = job
|
||||
|
||||
|
||||
def getConvexHullNode(self):
|
||||
return self._convex_hull_node
|
||||
|
||||
|
||||
def setConvexHullNode(self, node):
|
||||
self._convex_hull_node = node
|
||||
|
||||
|
||||
def _onActiveProfileChanged(self):
|
||||
if self._profile:
|
||||
self._profile.settingValueChanged.disconnect(self._onSettingValueChanged)
|
||||
|
@ -97,15 +108,15 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
|||
if self._convex_hull_job:
|
||||
self._convex_hull_job.cancel()
|
||||
self.setConvexHull(None)
|
||||
if self._convex_hull_node:
|
||||
self._convex_hull_node.setParent(None)
|
||||
self._convex_hull_node = None
|
||||
|
||||
def _onSettingValueChanged(self, setting):
|
||||
if setting == "print_sequence":
|
||||
if self._convex_hull_job:
|
||||
self._convex_hull_job.cancel()
|
||||
self.setConvexHull(None)
|
||||
if self._convex_hull_node:
|
||||
self._convex_hull_node.setParent(None)
|
||||
self._convex_hull_node = None
|
||||
|
||||
def _onParentChanged(self, node):
|
||||
# Force updating the convex hull of the parent group if the object is in a group
|
||||
if self._parent_node and self._parent_node.callDecoration("isGroup"):
|
||||
self._parent_node.callDecoration("setConvexHull", None)
|
||||
self._parent_node = self.getNode().getParent()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue