mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-22 22:23:57 -06:00
WIP: Simplify global stack and extruder stack activation and fixes
This commit is contained in:
parent
21c4753443
commit
c432d4ffbb
6 changed files with 14 additions and 21 deletions
|
@ -102,6 +102,7 @@ class CuraStackBuilder:
|
|||
variant_container = variant_container,
|
||||
material_container = material_container,
|
||||
quality_container = application.empty_quality_container,
|
||||
global_stack = new_global_stack,
|
||||
)
|
||||
new_extruder.setNextStack(new_global_stack)
|
||||
new_global_stack.addExtruder(new_extruder)
|
||||
|
@ -133,11 +134,11 @@ class CuraStackBuilder:
|
|||
@classmethod
|
||||
def createExtruderStack(cls, new_stack_id: str, extruder_definition: DefinitionContainerInterface, machine_definition_id: str,
|
||||
position: int,
|
||||
variant_container, material_container, quality_container) -> ExtruderStack:
|
||||
variant_container, material_container, quality_container, global_stack) -> ExtruderStack:
|
||||
from cura.CuraApplication import CuraApplication
|
||||
application = CuraApplication.getInstance()
|
||||
|
||||
stack = ExtruderStack(new_stack_id)
|
||||
stack = ExtruderStack(new_stack_id, parent = global_stack)
|
||||
stack.setName(extruder_definition.getName())
|
||||
stack.setDefinition(extruder_definition)
|
||||
|
||||
|
|
|
@ -36,22 +36,15 @@ class ExtruderManager(QObject):
|
|||
self._global_container_stack_definition_id = None
|
||||
self._addCurrentMachineExtruders()
|
||||
|
||||
Application.getInstance().globalContainerStackChanged.connect(self.__globalContainerStackChanged)
|
||||
#Application.getInstance().globalContainerStackChanged.connect(self._globalContainerStackChanged)
|
||||
Selection.selectionChanged.connect(self.resetSelectedObjectExtruders)
|
||||
|
||||
## Signal to notify other components when the list of extruders for a machine definition changes.
|
||||
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.
|
||||
activeExtruderChanged = pyqtSignal()
|
||||
|
||||
## The signal notifies subscribers if extruders are added
|
||||
extrudersAdded = pyqtSignal()
|
||||
|
||||
## Gets the unique identifier of the currently active extruder stack.
|
||||
#
|
||||
# The currently active extruder stack is the stack that is currently being
|
||||
|
@ -371,11 +364,10 @@ class ExtruderManager(QObject):
|
|||
|
||||
return result[:machine_extruder_count]
|
||||
|
||||
def __globalContainerStackChanged(self) -> None:
|
||||
def _globalContainerStackChanged(self) -> None:
|
||||
global_container_stack = 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()
|
||||
|
||||
# If the global container changed, the machine changed and might have extruders that were not registered yet
|
||||
self._addCurrentMachineExtruders()
|
||||
|
@ -415,7 +407,6 @@ class ExtruderManager(QObject):
|
|||
|
||||
if extruders_changed:
|
||||
self.extrudersChanged.emit(global_stack_id)
|
||||
self.extrudersAdded.emit()
|
||||
self.setActiveExtruderIndex(0)
|
||||
|
||||
## Get all extruder values for a certain setting.
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
from typing import Any, TYPE_CHECKING, Optional
|
||||
|
||||
from UM.Application import Application
|
||||
from UM.Decorators import override
|
||||
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
|
||||
from UM.Settings.ContainerStack import ContainerStack
|
||||
|
@ -34,7 +33,7 @@ class ExtruderStack(CuraContainerStack):
|
|||
#
|
||||
# This will set the next stack and ensure that we register this stack as an extruder.
|
||||
@override(ContainerStack)
|
||||
def setNextStack(self, stack: ContainerStack) -> None:
|
||||
def setNextStack(self, stack: CuraContainerStack) -> None:
|
||||
super().setNextStack(stack)
|
||||
stack.addExtruder(self)
|
||||
self.addMetaDataEntry("machine", stack.id)
|
||||
|
|
|
@ -283,6 +283,7 @@ class MachineManager(QObject):
|
|||
containers = container_registry.findContainerStacks(id = stack_id)
|
||||
if containers:
|
||||
Application.getInstance().setGlobalContainerStack(containers[0])
|
||||
ExtruderManager.getInstance()._globalContainerStackChanged()
|
||||
|
||||
self.__emitChangedSignals()
|
||||
|
||||
|
@ -877,9 +878,10 @@ class MachineManager(QObject):
|
|||
|
||||
@pyqtSlot(int, result = QObject)
|
||||
def getExtruder(self, position: int):
|
||||
extruder = None
|
||||
if self._global_container_stack:
|
||||
return self._global_container_stack.extruders.get(str(position))
|
||||
return None
|
||||
extruder = self._global_container_stack.extruders.get(str(position))
|
||||
return extruder
|
||||
|
||||
def _onMachineNameChanged(self):
|
||||
self.globalContainerChanged.emit()
|
||||
|
|
|
@ -88,7 +88,6 @@ class CuraEngineBackend(QObject, Backend):
|
|||
#
|
||||
self._global_container_stack = None
|
||||
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalStackChanged)
|
||||
Application.getInstance().getExtruderManager().extrudersAdded.connect(self._onGlobalStackChanged)
|
||||
self._onGlobalStackChanged()
|
||||
|
||||
Application.getInstance().stacksValidationFinished.connect(self._onStackErrorCheckFinished)
|
||||
|
|
|
@ -13,7 +13,8 @@ Menu
|
|||
title: "Nozzle"
|
||||
|
||||
property int extruderIndex: 0
|
||||
property var extruderStack: Cura.MachineManager.getExtruder(menu.extruderIndex)
|
||||
property QtObject extruderStack: Cura.MachineManager.getExtruder(menu.extruderIndex)
|
||||
property bool hasExtruderStack: extruderStack != null
|
||||
|
||||
Cura.NozzleModel
|
||||
{
|
||||
|
@ -24,7 +25,7 @@ Menu
|
|||
{
|
||||
target: Cura.MachineManager
|
||||
onGlobalContainerChanged: {
|
||||
menu.extruderStack = Cura.MachineManager.getExtruder(extruderIndex);
|
||||
menu.extruderStack = Cura.MachineManager.getExtruder(menu.extruderIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +37,7 @@ Menu
|
|||
{
|
||||
text: model.hotend_name
|
||||
checkable: true
|
||||
checked: extruderStack.variant.name == model.hotend_name
|
||||
checked: menu.hasExtruderStack && extruderStack.variant.name == model.hotend_name
|
||||
exclusiveGroup: group
|
||||
onTriggered: {
|
||||
Cura.MachineManager.setVariantGroup(extruderIndex, model.container_node);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue