CURA-4104 added first sucky build plate selection options

This commit is contained in:
Jack Ha 2017-11-06 09:25:42 +01:00
parent 74a7f02166
commit 5b368fbfd5
7 changed files with 179 additions and 2 deletions

View file

@ -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)