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:
authorArjen Hiemstra <ahiemstra@heimr.nl>2015-10-23 15:03:43 +0300
committerArjen Hiemstra <ahiemstra@heimr.nl>2015-10-23 15:04:27 +0300
commit07c9ecc931e1b4c086ab1a8b8ddd028411fcff35 (patch)
tree63ceb4ce15fb45a0af22fa6063ad20674bb9deee /cura/PlatformPhysics.py
parentd0b5fe84b8fb6e039652ca0ffabfabfcaf853c79 (diff)
Use a decorator to track Z offset
This makes it much easier to correct for Z offset after operations CURA-196 #Ready-for-Review
Diffstat (limited to 'cura/PlatformPhysics.py')
-rw-r--r--cura/PlatformPhysics.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py
index 2e4d77b77f..3933802135 100644
--- a/cura/PlatformPhysics.py
+++ b/cura/PlatformPhysics.py
@@ -17,6 +17,7 @@ from cura.ConvexHullDecorator import ConvexHullDecorator
from . import PlatformPhysicsOperation
from . import ConvexHullJob
+from . import ZOffsetDecorator
import time
import threading
@@ -69,8 +70,12 @@ class PlatformPhysics:
# Move it downwards if bottom is above platform
move_vector = Vector()
if not (node.getParent() and node.getParent().callDecoration("isGroup")): #If an object is grouped, don't move it down
+ z_offset = node.callDecoration("getZOffset") if node.getDecorator(ZOffsetDecorator.ZOffsetDecorator) else 0
if bbox.bottom > 0:
- move_vector.setY(-bbox.bottom)
+ move_vector.setY(-bbox.bottom + z_offset)
+ elif bbox.bottom < z_offset:
+ move_vector.setY((-bbox.bottom) - z_offset)
+
#if not Float.fuzzyCompare(bbox.bottom, 0.0):
# pass#move_vector.setY(-bbox.bottom)
@@ -149,5 +154,16 @@ class PlatformPhysics:
self._enabled = False
def _onToolOperationStopped(self, tool):
+ if tool.getPluginId() == "TranslateTool":
+ for node in Selection.getAllSelectedObjects():
+ if node.getBoundingBox().bottom < 0:
+ if not node.getDecorator(ZOffsetDecorator.ZOffsetDecorator):
+ node.addDecorator(ZOffsetDecorator.ZOffsetDecorator())
+
+ node.callDecoration("setZOffset", node.getBoundingBox().bottom)
+ else:
+ if node.getDecorator(ZOffsetDecorator.ZOffsetDecorator):
+ node.removeDecorator(ZOffsetDecorator.ZOffsetDecorator)
+
self._enabled = True
self._onChangeTimerFinished()