mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-06-04 11:14:21 +08:00
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.
This commit is contained in:
parent
bc0ac0f2a0
commit
f613a54b79
@ -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.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
|
|
||||||
from PyQt5.QtCore import QTimer
|
from PyQt5.QtCore import QTimer
|
||||||
@ -381,11 +381,29 @@ class ConvexHullDecorator(SceneNodeDecorator):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
scale_factor = self._global_stack.getProperty("material_shrinkage_percentage", "value") / 100.0
|
scale_factor = self._global_stack.getProperty("material_shrinkage_percentage", "value") / 100.0
|
||||||
|
result = convex_hull
|
||||||
if scale_factor != 1.0:
|
if scale_factor != 1.0:
|
||||||
center = self.getNode().getBoundingBox().center
|
center = None
|
||||||
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.
|
if self._global_stack.getProperty("print_sequence", "value") == "one_at_a_time":
|
||||||
else:
|
# Find the root node that's placed in the scene; the root of the mesh group.
|
||||||
result = convex_hull
|
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(
|
horizontal_expansion = max(
|
||||||
self._getSettingProperty("xy_offset", "value"),
|
self._getSettingProperty("xy_offset", "value"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user