mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-13 11:09:00 +08:00
Properly position groups and nodes once ungrouped
CURA-273 #Review
This commit is contained in:
parent
886083d2eb
commit
63765eb522
@ -471,17 +471,20 @@ class CuraApplication(QtApplication):
|
|||||||
group_decorator = GroupDecorator()
|
group_decorator = GroupDecorator()
|
||||||
group_node.addDecorator(group_decorator)
|
group_node.addDecorator(group_decorator)
|
||||||
group_node.setParent(self.getController().getScene().getRoot())
|
group_node.setParent(self.getController().getScene().getRoot())
|
||||||
|
center = Selection.getSelectionCenter()
|
||||||
|
group_node.setPosition(center)
|
||||||
|
group_node.setCenterPosition(center)
|
||||||
|
|
||||||
for node in Selection.getAllSelectedObjects():
|
for node in Selection.getAllSelectedObjects():
|
||||||
|
world = node.getWorldPosition()
|
||||||
node.setParent(group_node)
|
node.setParent(group_node)
|
||||||
group_node.setCenterPosition(group_node.getBoundingBox().center)
|
node.setPosition(world - center)
|
||||||
#group_node.translate(Vector(0,group_node.getBoundingBox().center.y,0))
|
|
||||||
group_node.translate(group_node.getBoundingBox().center)
|
|
||||||
for node in group_node.getChildren():
|
for node in group_node.getChildren():
|
||||||
Selection.remove(node)
|
Selection.remove(node)
|
||||||
|
|
||||||
Selection.add(group_node)
|
Selection.add(group_node)
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def ungroupSelected(self):
|
def ungroupSelected(self):
|
||||||
ungrouped_nodes = []
|
ungrouped_nodes = []
|
||||||
@ -492,12 +495,11 @@ class CuraApplication(QtApplication):
|
|||||||
for child in node.getChildren():
|
for child in node.getChildren():
|
||||||
if type(child) is SceneNode:
|
if type(child) is SceneNode:
|
||||||
children_to_move.append(child)
|
children_to_move.append(child)
|
||||||
|
|
||||||
for child in children_to_move:
|
for child in children_to_move:
|
||||||
|
position = child.getWorldPosition()
|
||||||
child.setParent(node.getParent())
|
child.setParent(node.getParent())
|
||||||
print(node.getPosition())
|
child.setPosition(position - node.getParent().getWorldPosition())
|
||||||
child.translate(node.getPosition())
|
|
||||||
child.setPosition(child.getPosition().scale(node.getScale()))
|
|
||||||
child.scale(node.getScale())
|
child.scale(node.getScale())
|
||||||
child.rotate(node.getOrientation())
|
child.rotate(node.getOrientation())
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user