mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 14:39:02 +08:00
Simplify recomputeConvexHull code
CURA-7106
This commit is contained in:
parent
1900b0841a
commit
d897299b31
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user