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>2017-04-20 18:26:49 +0300
committerArjen Hiemstra <ahiemstra@heimr.nl>2017-04-20 18:42:06 +0300
commitb56802a52305ed1edc1588dfb51d3d16e99314f5 (patch)
treef0ab12ee5f804b810e42c55e6ef7d57937bceb3b /cura/CuraActions.py
parentc21895de978c79edf177b6162da50a095bca1740 (diff)
Add a deleteSelection method to CuraActions
It does the same as CuraApplication::deleteSelection but this is a better place for it. Contributes to CURA-3609
Diffstat (limited to 'cura/CuraActions.py')
-rw-r--r--cura/CuraActions.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/cura/CuraActions.py b/cura/CuraActions.py
index 4fd51a8513..c617980bc5 100644
--- a/cura/CuraActions.py
+++ b/cura/CuraActions.py
@@ -10,8 +10,10 @@ from UM.Application import Application
from UM.Math.Vector import Vector
from UM.Scene.Selection import Selection
from UM.Operations.GroupedOperation import GroupedOperation
+from UM.Operations.RemoveSceneNodeOperation import RemoveSceneNodeOperation
from UM.Operations.SetTransformOperation import SetTransformOperation
+from .SetParentOperation import SetParentOperation
from .MultiplyObjectsJob import MultiplyObjectsJob
class CuraActions(QObject):
@@ -52,5 +54,25 @@ class CuraActions(QObject):
job = MultiplyObjectsJob(Selection.getAllSelectedObjects(), count, 8)
job.start()
return
+
+ ## Delete all selected objects.
+ @pyqtSlot()
+ def deleteSelection(self) -> None:
+ if not Application.getInstance().getController().getToolsEnabled():
+ return
+
+ removed_group_nodes = []
+ op = GroupedOperation()
+ nodes = Selection.getAllSelectedObjects()
+ for node in nodes:
+ op.addOperation(RemoveSceneNodeOperation(node))
+ group_node = node.getParent()
+ if group_node and group_node.callDecoration("isGroup") and group_node not in removed_group_nodes:
+ remaining_nodes_in_group = list(set(group_node.getChildren()) - set(nodes))
+ if len(remaining_nodes_in_group) == 1:
+ removed_group_nodes.append(group_node)
+ op.addOperation(SetParentOperation(remaining_nodes_in_group[0], group_node.getParent()))
+ op.addOperation(RemoveSceneNodeOperation(group_node))
+ op.push()
def _openUrl(self, url):
QDesktopServices.openUrl(url)