mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-11 15:39:00 +08:00
Store the actual extruder stack in ExtruderManager instead of just the ID
Contributes to CURA-340
This commit is contained in:
parent
a070684ade
commit
8729dce531
@ -36,7 +36,7 @@ class ExtruderManager(QObject):
|
|||||||
if not UM.Application.getInstance().getGlobalContainerStack():
|
if not UM.Application.getInstance().getGlobalContainerStack():
|
||||||
return None #No active machine, so no active extruder.
|
return None #No active machine, so no active extruder.
|
||||||
try:
|
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.
|
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
|
return None
|
||||||
|
|
||||||
@ -87,7 +87,7 @@ class ExtruderManager(QObject):
|
|||||||
#Gets the extruder trains that we just created as well as any that still existed.
|
#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())
|
extruder_trains = container_registry.findContainerStacks(type = "extruder_train", machine = machine_definition.getId())
|
||||||
for extruder_train in extruder_trains:
|
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:
|
if extruder_trains:
|
||||||
self.extrudersChanged.emit(machine_definition)
|
self.extrudersChanged.emit(machine_definition)
|
||||||
|
|
||||||
@ -194,15 +194,11 @@ class ExtruderManager(QObject):
|
|||||||
if not machine_id in self._extruder_trains:
|
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)
|
UM.Logger.log("w", "Tried to get the extruder trains for machine %s, which doesn't exist.", machine_id)
|
||||||
return
|
return
|
||||||
for _,extruder_train_id in self._extruder_trains[machine_id].items():
|
for name in self._extruder_trains[machine_id]:
|
||||||
extruder_train = container_registry.findContainerStacks(id = extruder_train_id)
|
yield self._extruder_trains[machine_id][name]
|
||||||
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)
|
|
||||||
|
|
||||||
## Adds the extruders of the currently active machine.
|
## Adds the extruders of the currently active machine.
|
||||||
def _addCurrentMachineExtruders(self):
|
def _addCurrentMachineExtruders(self):
|
||||||
global_stack = UM.Application.getInstance().getGlobalContainerStack()
|
global_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||||
if global_stack and global_stack.getBottom():
|
if global_stack and global_stack.getBottom():
|
||||||
self.addMachineExtruders(global_stack.getBottom())
|
self.addMachineExtruders(global_stack.getBottom())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user