diff options
author | Jack Ha <jackha@gmail.com> | 2017-11-06 11:25:42 +0300 |
---|---|---|
committer | Jack Ha <jackha@gmail.com> | 2017-11-06 16:03:03 +0300 |
commit | 5b368fbfd5e8c588b6679c62fb81f20a47052489 (patch) | |
tree | 6f8e2b4a50226b16bc1c49113d0cc7ff8a6572e2 /cura/CuraActions.py | |
parent | 74a7f02166ce56bba6c4977b6d011f8d839e583e (diff) |
CURA-4104 added first sucky build plate selection options
Diffstat (limited to 'cura/CuraActions.py')
-rw-r--r-- | cura/CuraActions.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/cura/CuraActions.py b/cura/CuraActions.py index b51728f028..663da3ec09 100644 --- a/cura/CuraActions.py +++ b/cura/CuraActions.py @@ -19,6 +19,11 @@ from cura.MultiplyObjectsJob import MultiplyObjectsJob from cura.Settings.SetObjectExtruderOperation import SetObjectExtruderOperation from cura.Settings.ExtruderManager import ExtruderManager +from cura.Operations.SetBuildPlateNumberOperation import SetBuildPlateNumberOperation + +from UM.Logger import Logger + + class CuraActions(QObject): def __init__(self, parent = None): super().__init__(parent) @@ -124,5 +129,43 @@ class CuraActions(QObject): operation.addOperation(SetObjectExtruderOperation(node, extruder_id)) operation.push() + @pyqtSlot(int) + def setBuildPlateForSelection(self, build_plate_nr: int) -> None: + Logger.log("d", "Setting build plate number... %d" % build_plate_nr) + operation = GroupedOperation() + + nodes_to_change = [] + for node in Selection.getAllSelectedObjects(): + # Do not change any nodes that already have the right extruder set. + if node.callDecoration("getBuildPlateNumber") == build_plate_nr: + continue + + # If the node is a group, apply the active extruder to all children of the group. + if node.callDecoration("isGroup"): + for grouped_node in BreadthFirstIterator(node): + if grouped_node.callDecoration("getBuildPlateNumber") == build_plate_nr: + continue + + if grouped_node.callDecoration("isGroup"): + continue + + nodes_to_change.append(grouped_node) + continue + + nodes_to_change.append(node) + + if not nodes_to_change: + Logger.log("d", "Nothing to change.") + # If there are no changes to make, we still need to reset the selected extruders. + # This is a workaround for checked menu items being deselected while still being + # selected. + #ExtruderManager.getInstance().resetSelectedObjectExtruders() + return + + Logger.log("d", "Yes: %s", nodes_to_change) + for node in nodes_to_change: + operation.addOperation(SetBuildPlateNumberOperation(node, build_plate_nr)) + operation.push() + def _openUrl(self, url): QDesktopServices.openUrl(url) |