Store the actual extruder stack in ExtruderManager instead of just the ID

Contributes to CURA-340
This commit is contained in:
Arjen Hiemstra 2016-06-09 13:30:17 +02:00
parent a070684ade
commit 8729dce531

View File

@ -36,7 +36,7 @@ class ExtruderManager(QObject):
if not UM.Application.getInstance().getGlobalContainerStack():
return None #No active machine, so no active extruder.
try:
return self._extruder_trains[UM.Application.getInstance().getGlobalContainerStack().getBottom().getId()][str(self._active_extruder_index)]
return self._extruder_trains[UM.Application.getInstance().getGlobalContainerStack().getBottom().getId()][str(self._active_extruder_index)].getId()
except KeyError: #Extruder index could be -1 if the global tab is selected, or the entry doesn't exist if the machine definition is wrong.
return None
@ -87,7 +87,7 @@ class ExtruderManager(QObject):
#Gets the extruder trains that we just created as well as any that still existed.
extruder_trains = container_registry.findContainerStacks(type = "extruder_train", machine = machine_definition.getId())
for extruder_train in extruder_trains:
self._extruder_trains[machine_id][extruder_train.getMetaDataEntry("position")] = extruder_train.getId()
self._extruder_trains[machine_id][extruder_train.getMetaDataEntry("position")] = extruder_train
if extruder_trains:
self.extrudersChanged.emit(machine_definition)
@ -194,15 +194,11 @@ class ExtruderManager(QObject):
if not machine_id in self._extruder_trains:
UM.Logger.log("w", "Tried to get the extruder trains for machine %s, which doesn't exist.", machine_id)
return
for _,extruder_train_id in self._extruder_trains[machine_id].items():
extruder_train = container_registry.findContainerStacks(id = extruder_train_id)
if extruder_train:
yield extruder_train[0]
else:
UM.Logger.log("w", "Machine %s refers to an extruder train with ID %s, which doesn't exist.", machine_id, extruder_train_id)
for name in self._extruder_trains[machine_id]:
yield self._extruder_trains[machine_id][name]
## Adds the extruders of the currently active machine.
def _addCurrentMachineExtruders(self):
global_stack = UM.Application.getInstance().getGlobalContainerStack()
if global_stack and global_stack.getBottom():
self.addMachineExtruders(global_stack.getBottom())
self.addMachineExtruders(global_stack.getBottom())