Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGhostkeeper <rubend@tutanota.com>2020-09-02 03:43:43 +0300
committerGhostkeeper <rubend@tutanota.com>2020-09-02 03:43:43 +0300
commitf613a54b79a225d05ba4d96b70da71cd3573e045 (patch)
tree4cdc2a665f8590e2ede3a34f49194c12d9170d06 /cura/Scene
parentbc0ac0f2a06467963f776dda13c723ddb7314c3d (diff)
Compute centre of current mesh group
This is either the centre of the bounding box around all printable nodes in the scene, or the centre of the bounding box of the most-ancestral node that is not yet the scene root itself in one-at-a-time mode. Contributes to issue CURA-7118.
Diffstat (limited to 'cura/Scene')
-rw-r--r--cura/Scene/ConvexHullDecorator.py28
1 files changed, 23 insertions, 5 deletions
diff --git a/cura/Scene/ConvexHullDecorator.py b/cura/Scene/ConvexHullDecorator.py
index 5a47514f1e..ac1e7e66ad 100644
--- a/cura/Scene/ConvexHullDecorator.py
+++ b/cura/Scene/ConvexHullDecorator.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2016 Ultimaker B.V.
+# Copyright (c) 2020 Ultimaker B.V.
# Cura is released under the terms of the LGPLv3 or higher.
from PyQt5.QtCore import QTimer
@@ -381,11 +381,29 @@ class ConvexHullDecorator(SceneNodeDecorator):
"""
scale_factor = self._global_stack.getProperty("material_shrinkage_percentage", "value") / 100.0
+ result = convex_hull
if scale_factor != 1.0:
- center = self.getNode().getBoundingBox().center
- result = convex_hull.scale(scale_factor, [center.x, center.z]) # Yes, use Z instead of Y. Mixed conventions there with how the OpenGL coordinates are transmitted.
- else:
- result = convex_hull
+ center = None
+ if self._global_stack.getProperty("print_sequence", "value") == "one_at_a_time":
+ # Find the root node that's placed in the scene; the root of the mesh group.
+ ancestor = self.getNode()
+ while ancestor.getParent() != self._root:
+ ancestor = ancestor.getParent()
+ center = ancestor.getBoundingBox().center
+ else:
+ # Find the bounding box of the entire scene, which is all one mesh group then.
+ aabb = None
+ for printed_node in self._root.getChildren():
+ if not printed_node.callDecoration("isSliceable"):
+ continue # Not a printed node.
+ if aabb is None:
+ aabb = printed_node.getBoundingBox()
+ else:
+ aabb = aabb + printed_node.getBoundingBox()
+ if aabb:
+ center = aabb.center
+ if center:
+ result = convex_hull.scale(scale_factor, [center.x, center.z]) # Yes, use Z instead of Y. Mixed conventions there with how the OpenGL coordinates are transmitted.
horizontal_expansion = max(
self._getSettingProperty("xy_offset", "value"),