Use a decorator to track Z offset

This makes it much easier to correct for Z offset after operations

CURA-196 #Ready-for-Review
This commit is contained in:
Arjen Hiemstra 2015-10-23 14:03:43 +02:00
parent d0b5fe84b8
commit 07c9ecc931
3 changed files with 36 additions and 10 deletions

View file

@ -37,6 +37,7 @@ from . import CameraAnimation
from . import PrintInformation
from . import CuraActions
from . import MultiMaterialDecorator
from . import ZOffsetDecorator
from PyQt5.QtCore import pyqtSlot, QUrl, Qt, pyqtSignal, pyqtProperty, QEvent, Q_ENUMS
from PyQt5.QtGui import QColor, QIcon
@ -342,14 +343,12 @@ class CuraApplication(QtApplication):
continue #Grouped nodes don't need resetting as their parent (the group) is resetted)
nodes.append(node)
if nodes:
op = GroupedOperation()
for node in nodes:
# Ensure that the object is above the build platform
move_distance = node.getBoundingBox().center.y
if move_distance <= 0:
move_distance = -node.getBoundingBox().bottom
op.addOperation(SetTransformOperation(node, Vector(0,move_distance,0)))
node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator)
op.addOperation(SetTransformOperation(node, Vector(0,0,0)))
op.push()
@ -371,10 +370,8 @@ class CuraApplication(QtApplication):
for node in nodes:
# Ensure that the object is above the build platform
move_distance = node.getBoundingBox().center.y
if move_distance <= 0:
move_distance = -node.getBoundingBox().bottom
op.addOperation(SetTransformOperation(node, Vector(0,move_distance,0), Quaternion(), Vector(1, 1, 1)))
node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator)
op.addOperation(SetTransformOperation(node, Vector(0,0,0), Quaternion(), Vector(1, 1, 1)))
op.push()