mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Speed up switching between multiextrusion machines
ExtruderManager.addMachineExtruders is supposed to create a cache, but this cache was always rebuilt because of an indentation error.
This commit is contained in:
parent
983e963dd3
commit
847d6429d0
2 changed files with 12 additions and 3 deletions
|
@ -13,9 +13,13 @@ import UM.Settings.SettingFunction
|
||||||
#
|
#
|
||||||
# This keeps a list of extruder stacks for each machine.
|
# This keeps a list of extruder stacks for each machine.
|
||||||
class ExtruderManager(QObject):
|
class ExtruderManager(QObject):
|
||||||
## Signal to notify other components when the list of extruders changes.
|
## Signal to notify other components when the list of extruders for a machine definition changes.
|
||||||
extrudersChanged = pyqtSignal(QVariant)
|
extrudersChanged = pyqtSignal(QVariant)
|
||||||
|
|
||||||
|
## Signal to notify other components when the global container stack is switched to a definition
|
||||||
|
# that has different extruders than the previous global container stack
|
||||||
|
globalContainerStackDefinitionChanged = pyqtSignal()
|
||||||
|
|
||||||
## Notify when the user switches the currently active extruder.
|
## Notify when the user switches the currently active extruder.
|
||||||
activeExtruderChanged = pyqtSignal()
|
activeExtruderChanged = pyqtSignal()
|
||||||
|
|
||||||
|
@ -25,6 +29,7 @@ class ExtruderManager(QObject):
|
||||||
self._extruder_trains = { } #Per machine, a dictionary of extruder container stack IDs.
|
self._extruder_trains = { } #Per machine, a dictionary of extruder container stack IDs.
|
||||||
self._active_extruder_index = 0
|
self._active_extruder_index = 0
|
||||||
UM.Application.getInstance().globalContainerStackChanged.connect(self.__globalContainerStackChanged)
|
UM.Application.getInstance().globalContainerStackChanged.connect(self.__globalContainerStackChanged)
|
||||||
|
self._global_container_stack_definition_id = None
|
||||||
self._addCurrentMachineExtruders()
|
self._addCurrentMachineExtruders()
|
||||||
|
|
||||||
## Gets the unique identifier of the currently active extruder stack.
|
## Gets the unique identifier of the currently active extruder stack.
|
||||||
|
@ -141,7 +146,7 @@ class ExtruderManager(QObject):
|
||||||
shallow_stack = UM.Settings.ContainerStack(machine_id + "_shallow")
|
shallow_stack = UM.Settings.ContainerStack(machine_id + "_shallow")
|
||||||
shallow_stack.addContainer(machine_definition)
|
shallow_stack.addContainer(machine_definition)
|
||||||
extruder_train.setNextStack(shallow_stack)
|
extruder_train.setNextStack(shallow_stack)
|
||||||
changed = True
|
changed = True
|
||||||
if changed:
|
if changed:
|
||||||
self.extrudersChanged.emit(machine_id)
|
self.extrudersChanged.emit(machine_id)
|
||||||
|
|
||||||
|
@ -301,6 +306,10 @@ class ExtruderManager(QObject):
|
||||||
|
|
||||||
def __globalContainerStackChanged(self):
|
def __globalContainerStackChanged(self):
|
||||||
self._addCurrentMachineExtruders()
|
self._addCurrentMachineExtruders()
|
||||||
|
global_container_stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||||
|
if global_container_stack and global_container_stack.getBottom() and global_container_stack.getBottom().getId() != self._global_container_stack_definition_id:
|
||||||
|
self._global_container_stack_definition_id = global_container_stack.getBottom().getId()
|
||||||
|
self.globalContainerStackDefinitionChanged.emit()
|
||||||
self.activeExtruderChanged.emit()
|
self.activeExtruderChanged.emit()
|
||||||
|
|
||||||
## Adds the extruders of the currently active machine.
|
## Adds the extruders of the currently active machine.
|
||||||
|
|
|
@ -52,7 +52,7 @@ class ExtrudersModel(UM.Qt.ListModel.ListModel):
|
||||||
|
|
||||||
#Listen to changes.
|
#Listen to changes.
|
||||||
manager = ExtruderManager.getInstance()
|
manager = ExtruderManager.getInstance()
|
||||||
manager.extrudersChanged.connect(self._updateExtruders) #When the list of extruders changes in general.
|
manager.globalContainerStackDefinitionChanged.connect(self._updateExtruders) #When the global stack changes to a printer with different extruders.
|
||||||
|
|
||||||
self._updateExtruders()
|
self._updateExtruders()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue