Introduce a getActiveGlobalAndExtruderStacks method to ExtruderManager

It can be used to iterate over the active global and extruder stacks

Contributes to CURA-2006
This commit is contained in:
Arjen Hiemstra 2016-08-11 17:49:02 +02:00
parent c557cd1a7a
commit 6049d6f3a5

View File

@ -277,6 +277,20 @@ class ExtruderManager(QObject):
for name in self._extruder_trains[machine_id]:
yield self._extruder_trains[machine_id][name]
## Returns a generator that will iterate over the global stack and per-extruder stacks.
#
# The first generated element is the global container stack. After that any extruder stacks are generated.
def getActiveGlobalAndExtruderStacks(self):
global_stack = UM.Application.getInstance().getGlobalContainerStack()
if not global_stack:
return
yield global_stack
global_id = global_stack.getId()
for name in self._extruder_trains[global_id]:
yield self._extruder_trains[global_id][name]
def __globalContainerStackChanged(self):
self._addCurrentMachineExtruders()
self.activeExtruderChanged.emit()