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