From 2683fa0958be738e62e72d68f41fe17f6491b007 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 14 Jul 2015 10:25:08 +0200 Subject: [PATCH] Added grouping action --- cura/CuraApplication.py | 12 ++++++++++++ resources/qml/Actions.qml | 9 +++++++++ resources/qml/Cura.qml | 6 ++++++ 3 files changed, 27 insertions(+) diff --git a/cura/CuraApplication.py b/cura/CuraApplication.py index 3beafb9284..7c1034059b 100644 --- a/cura/CuraApplication.py +++ b/cura/CuraApplication.py @@ -22,6 +22,7 @@ from UM.Math.Polygon import Polygon from UM.Scene.BoxRenderer import BoxRenderer from UM.Scene.Selection import Selection +from UM.Scene.GroupDecorator import GroupDecorator from UM.Operations.AddSceneNodeOperation import AddSceneNodeOperation from UM.Operations.RemoveSceneNodeOperation import RemoveSceneNodeOperation @@ -416,6 +417,17 @@ class CuraApplication(QtApplication): return self.getActiveMachine().setSettingValueByKey(key, value) + + + @pyqtSlot() + def groupSelected(self): + group_node = SceneNode() + group_decorator = GroupDecorator() + group_node.addDecorator(group_decorator) + group_node.setParent(self.getController().getScene().getRoot()) + for node in Selection.getAllSelectedObjects(): + node.setParent(group_node) + ## Add an output device that can be written to. # diff --git a/resources/qml/Actions.qml b/resources/qml/Actions.qml index b29b260f28..a98d94b62c 100644 --- a/resources/qml/Actions.qml +++ b/resources/qml/Actions.qml @@ -3,6 +3,7 @@ import QtQuick 2.2 import QtQuick.Controls 1.1 +import UM 1.0 as UM Item { property alias open: openAction; @@ -16,6 +17,7 @@ Item { property alias deleteObject: deleteObjectAction; property alias centerObject: centerObjectAction; + property alias groupObjects: groupObjectsAction; property alias multiplyObject: multiplyObjectAction; property alias splitObject: splitObjectAction; @@ -120,6 +122,13 @@ Item { //: Center object action text: qsTr("Center Object on Platform"); } + + Action + { + id: groupObjectsAction + text: qsTr("Group objects"); + enabled: UM.Scene.numObjectsSelected > 1 ? true: false + } Action { id: multiplyObjectAction; diff --git a/resources/qml/Cura.qml b/resources/qml/Cura.qml index f8e80367eb..514ea77bb3 100644 --- a/resources/qml/Cura.qml +++ b/resources/qml/Cura.qml @@ -347,6 +347,11 @@ UM.MainWindow { objectContextMenu.objectId = 0; } } + + groupObjects.onTriggered: + { + Printer.groupSelected() + } deleteAll.onTriggered: Printer.deleteAll() resetAllTranslation.onTriggered: Printer.resetAllTranslation() @@ -373,6 +378,7 @@ UM.MainWindow { MenuItem { action: actions.deleteObject; } MenuItem { action: actions.multiplyObject; } MenuItem { action: actions.splitObject; } + MenuItem { action: actions.groupObjects;} MenuSeparator { } MenuItem { action: actions.deleteAll; } MenuItem { action: actions.reloadAll; }