Fix "Reset all model transformations" for groups

CURA-2291
This commit is contained in:
fieldOfView 2016-09-07 16:06:42 +02:00
parent 15101ec53d
commit cab5f4d823

View File

@ -693,17 +693,17 @@ class CuraApplication(QtApplication):
continue # Node that doesnt have a mesh and is not a group. continue # Node that doesnt have a mesh and is not a group.
if node.getParent() and node.getParent().callDecoration("isGroup"): if node.getParent() and node.getParent().callDecoration("isGroup"):
continue # Grouped nodes don't need resetting as their parent (the group) is resetted) continue # Grouped nodes don't need resetting as their parent (the group) is resetted)
nodes.append(node) nodes.append(node)
if nodes: if nodes:
op = GroupedOperation() op = GroupedOperation()
for node in nodes: for node in nodes:
# Ensure that the object is above the build platform
node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator) node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator)
op.addOperation(SetTransformOperation(node, Vector(0, node.getWorldPosition().y - node.getBoundingBox().bottom, 0))) op.addOperation(SetTransformOperation(node, Vector(0, node.getWorldPosition().y - node.getBoundingBox().bottom, 0)))
op.push() op.push()
## Reset all transformations on nodes with mesh data. ## Reset all transformations on nodes with mesh data.
@pyqtSlot() @pyqtSlot()
def resetAll(self): def resetAll(self):
Logger.log("i", "Resetting all scene transformations") Logger.log("i", "Resetting all scene transformations")
@ -719,15 +719,17 @@ class CuraApplication(QtApplication):
if nodes: if nodes:
op = GroupedOperation() op = GroupedOperation()
for node in nodes: for node in nodes:
# Ensure that the object is above the build platform # Ensure that the object is above the build platform
node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator) node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator)
center_y = 0
op.addOperation(SetTransformOperation(node, Vector(0, node.getMeshData().getCenterPosition().y, 0), Quaternion(), Vector(1, 1, 1))) if node.callDecoration("isGroup"):
center_y = node.getWorldPosition().y - node.getBoundingBox().bottom
else:
center_y = node.getMeshData().getCenterPosition().y
op.addOperation(SetTransformOperation(node, Vector(0, center_y, 0), Quaternion(), Vector(1, 1, 1)))
op.push() op.push()
## Reload all mesh data on the screen from file. ## Reload all mesh data on the screen from file.
@pyqtSlot() @pyqtSlot()
def reloadAll(self): def reloadAll(self):