mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-16 19:28:07 -06:00
Added activeExtruder stack to machineManager model
CURA-340
This commit is contained in:
parent
c79b7bdd7a
commit
1e44abb9be
2 changed files with 27 additions and 5 deletions
|
@ -33,6 +33,8 @@ class MachineManagerModel(QObject):
|
||||||
|
|
||||||
active_machine_id = Preferences.getInstance().getValue("cura/active_machine")
|
active_machine_id = Preferences.getInstance().getValue("cura/active_machine")
|
||||||
|
|
||||||
|
self._active_extruder_index = 0
|
||||||
|
|
||||||
if active_machine_id != "":
|
if active_machine_id != "":
|
||||||
# An active machine was saved, so restore it.
|
# An active machine was saved, so restore it.
|
||||||
self.setActiveMachine(active_machine_id)
|
self.setActiveMachine(active_machine_id)
|
||||||
|
@ -44,14 +46,28 @@ class MachineManagerModel(QObject):
|
||||||
activeVariantChanged = pyqtSignal()
|
activeVariantChanged = pyqtSignal()
|
||||||
activeQualityChanged = pyqtSignal()
|
activeQualityChanged = pyqtSignal()
|
||||||
|
|
||||||
activeExtrudersChanged = pyqtSignal()
|
activeExtruderChanged = pyqtSignal()
|
||||||
|
|
||||||
globalValueChanged = pyqtSignal() # Emitted whenever a value inside global container is changed.
|
globalValueChanged = pyqtSignal() # Emitted whenever a value inside global container is changed.
|
||||||
globalValidationChanged = pyqtSignal() # Emitted whenever a validation inside global container is changed.
|
globalValidationChanged = pyqtSignal() # Emitted whenever a validation inside global container is changed.
|
||||||
|
|
||||||
@pyqtProperty("QVariantMap", notify = activeExtrudersChanged)
|
@pyqtProperty(str, notify=activeExtruderChanged)
|
||||||
def activeExtruders(self):
|
def activeExtruderStackId(self):
|
||||||
return {}
|
return self.extrudersIds[str(self._active_extruder_index)]
|
||||||
|
|
||||||
|
@pyqtSlot(int)
|
||||||
|
def setActiveExtruderIndex(self, index):
|
||||||
|
self._active_extruder_index = index
|
||||||
|
self.activeExtruderChanged.emit()
|
||||||
|
|
||||||
|
@pyqtProperty("QVariantMap", notify = globalContainerChanged)
|
||||||
|
def extrudersIds(self):
|
||||||
|
## Find all extruders that reference the new stack
|
||||||
|
extruders = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(**{"machine": self._global_container_stack.getId()})
|
||||||
|
result = {}
|
||||||
|
for extruder in extruders:
|
||||||
|
result[extruder.getMetaDataEntry("position")] = extruder.getId()
|
||||||
|
return result
|
||||||
|
|
||||||
def _onGlobalPropertyChanged(self, key, property_name):
|
def _onGlobalPropertyChanged(self, key, property_name):
|
||||||
if property_name == "value":
|
if property_name == "value":
|
||||||
|
@ -133,6 +149,8 @@ class MachineManagerModel(QObject):
|
||||||
for extruder in extruder_trains:
|
for extruder in extruder_trains:
|
||||||
extruder_train_stack = UM.Settings.ContainerStack(name + "_extruder_" + extruder)
|
extruder_train_stack = UM.Settings.ContainerStack(name + "_extruder_" + extruder)
|
||||||
extruder_train_stack.addMetaDataEntry("type", "extruder")
|
extruder_train_stack.addMetaDataEntry("type", "extruder")
|
||||||
|
extruder_train_stack.addMetaDataEntry("machine", name) # What global stack is this extruder linked with?
|
||||||
|
extruder_train_stack.addMetaDataEntry("position", extruder) # What is the position of the extruder (as defined by machine definition)
|
||||||
extruder_definitions = UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id=extruder_trains[extruder])
|
extruder_definitions = UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id=extruder_trains[extruder])
|
||||||
if extruder_definitions:
|
if extruder_definitions:
|
||||||
extruder_train_stack.addContainer(extruder_definitions[0])
|
extruder_train_stack.addContainer(extruder_definitions[0])
|
||||||
|
|
|
@ -108,7 +108,11 @@ Item
|
||||||
exclusiveGroup: extruderMenuGroup;
|
exclusiveGroup: extruderMenuGroup;
|
||||||
checkable: true;
|
checkable: true;
|
||||||
checked: base.currentExtruderIndex == index
|
checked: base.currentExtruderIndex == index
|
||||||
onClicked: base.currentExtruderIndex = index
|
onClicked:
|
||||||
|
{
|
||||||
|
base.currentExtruderIndex = index
|
||||||
|
Cura.MachineManager.setActiveExtruderIndex(index)
|
||||||
|
}
|
||||||
|
|
||||||
style: ButtonStyle {
|
style: ButtonStyle {
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue