From 4d6528e90d5ed3d624358847e58e6297659d9181 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Mon, 14 Sep 2015 13:25:03 +0200 Subject: [PATCH] Fixes to grouping. Fixes Ultimaker/Cura#377 --- cura/CuraApplication.py | 26 ++++++++++++++++++-------- cura/PlatformPhysics.py | 13 +++++++------ 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 719f9dac7e..3f0dea914d 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -47,6 +47,7 @@ import sys import os import os.path import numpy +import copy numpy.seterr(all="ignore") class CuraApplication(QtApplication): @@ -270,14 +271,22 @@ class CuraApplication(QtApplication): if node: op = GroupedOperation() for i in range(count): - new_node = SceneNode() - new_node.setMeshData(node.getMeshData()) + if node.getParent() and node.getParent().callDecoration("isGroup"): + new_node = copy.deepcopy(node.getParent()) #Copy the group node. + new_node.callDecoration("setConvexHull",None) - new_node.translate(Vector((i + 1) * node.getBoundingBox().width, node.getPosition().y, 0)) - new_node.setOrientation(node.getOrientation()) - new_node.setScale(node.getScale()) - new_node.setSelectable(True) - op.addOperation(AddSceneNodeOperation(new_node, node.getParent())) + op.addOperation(AddSceneNodeOperation(new_node,node.getParent().getParent())) + + pass + else: + new_node = SceneNode() + new_node.setMeshData(node.getMeshData()) + + new_node.translate(Vector((i + 1) * node.getBoundingBox().width, node.getPosition().y, 0)) + new_node.setOrientation(node.getOrientation()) + new_node.setScale(node.getScale()) + new_node.setSelectable(True) + op.addOperation(AddSceneNodeOperation(new_node, node.getParent())) op.push() ## Center object on platform. @@ -450,7 +459,8 @@ class CuraApplication(QtApplication): for node in Selection.getAllSelectedObjects(): node.setParent(group_node) group_node.setCenterPosition(group_node.getBoundingBox().center) - group_node.translate(Vector(0,group_node.getBoundingBox().center.y,0)) + #group_node.translate(Vector(0,group_node.getBoundingBox().center.y,0)) + group_node.translate(group_node.getBoundingBox().center) for node in group_node.getChildren(): Selection.remove(node) diff --git a/cura/PlatformPhysics.py b/cura/PlatformPhysics.py index 53e803187f..2b1b84b7c9 100644 --- a/cura/PlatformPhysics.py +++ b/cura/PlatformPhysics.py @@ -98,9 +98,10 @@ class PlatformPhysics: continue # Ignore colissions within a group - if other_node.getParent().callDecoration("isGroup") is not None: - if node.getParent().callDecoration("isGroup") is other_node.getParent().callDecoration("isGroup"): - continue + if other_node.getParent().callDecoration("isGroup") is not None or node.getParent().callDecoration("isGroup") is not None: + continue + #if node.getParent().callDecoration("isGroup") is other_node.getParent().callDecoration("isGroup"): + # continue # Ignore nodes that do not have the right properties set. if not other_node.callDecoration("getConvexHull") or not other_node.getBoundingBox(): @@ -126,9 +127,9 @@ class PlatformPhysics: if overlap is None: continue - - move_vector.setX(overlap[0] * 1.1) - move_vector.setZ(overlap[1] * 1.1) + print(overlap) + move_vector.setX(overlap[0] * 1.01) + move_vector.setZ(overlap[1] * 1.01) convex_hull = node.callDecoration("getConvexHull") if convex_hull: if not convex_hull.isValid():