From d897299b314c797203062e8b3451148a0806f751 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 23 Jun 2020 12:55:13 +0200 Subject: [PATCH] Simplify recomputeConvexHull code CURA-7106 --- cura/Scene/ConvexHullDecorator.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/cura/Scene/ConvexHullDecorator.py b/cura/Scene/ConvexHullDecorator.py index 46caa5b9e0..3465cd3ef9 100644 --- a/cura/Scene/ConvexHullDecorator.py +++ b/cura/Scene/ConvexHullDecorator.py @@ -53,6 +53,8 @@ class ConvexHullDecorator(SceneNodeDecorator): CuraApplication.getInstance().getController().toolOperationStarted.connect(self._onChanged) CuraApplication.getInstance().getController().toolOperationStopped.connect(self._onChanged) + self._root = Application.getInstance().getController().getScene().getRoot() + self._onGlobalStackChanged() def createRecomputeConvexHullTimer(self) -> None: @@ -198,23 +200,16 @@ class ConvexHullDecorator(SceneNodeDecorator): CuraApplication.getInstance().callLater(self.recomputeConvexHullDelayed) def recomputeConvexHull(self) -> None: - controller = Application.getInstance().getController() - root = controller.getScene().getRoot() - if self._node is None or controller.isToolOperationActive() or not self.__isDescendant(root, self._node): - # If the tool operation is still active, we need to compute the convex hull later after the controller is - # no longer active. - if controller.isToolOperationActive(): - self.recomputeConvexHullDelayed() - return - + if self._node is None or not self.__isDescendant(self._root, self._node): if self._convex_hull_node: + # Convex hull node still exists, but the node is removed or no longer in the scene. self._convex_hull_node.setParent(None) self._convex_hull_node = None return if self._convex_hull_node: self._convex_hull_node.setParent(None) - hull_node = ConvexHullNode.ConvexHullNode(self._node, self.getPrintingArea(), self._raft_thickness, root) + hull_node = ConvexHullNode.ConvexHullNode(self._node, self.getPrintingArea(), self._raft_thickness, self._root) self._convex_hull_node = hull_node def _onSettingValueChanged(self, key: str, property_name: str) -> None: