mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-07 15:07:28 -06:00
Machine manager now creates ExtruderTrainStacks
CURA-340
This commit is contained in:
parent
2f3352bfa0
commit
c79b7bdd7a
2 changed files with 33 additions and 6 deletions
|
@ -269,7 +269,13 @@ class CuraApplication(QtApplication):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
file_name = urllib.parse.quote_plus(stack.getId()) + ".stack.cfg"
|
file_name = urllib.parse.quote_plus(stack.getId()) + ".stack.cfg"
|
||||||
|
stack_type = stack.getMetaDataEntry("type", None)
|
||||||
|
path = None
|
||||||
|
if not stack_type:
|
||||||
path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
|
path = Resources.getStoragePath(self.ResourceTypes.MachineStack, file_name)
|
||||||
|
elif stack_type == "extruder":
|
||||||
|
path = Resources.getStoragePath(self.ResourceTypes.ExtruderStack, file_name)
|
||||||
|
if path:
|
||||||
with SaveFile(path, "wt", -1, "utf-8") as f:
|
with SaveFile(path, "wt", -1, "utf-8") as f:
|
||||||
f.write(data)
|
f.write(data)
|
||||||
|
|
||||||
|
|
|
@ -33,8 +33,6 @@ class MachineManagerModel(QObject):
|
||||||
|
|
||||||
active_machine_id = Preferences.getInstance().getValue("cura/active_machine")
|
active_machine_id = Preferences.getInstance().getValue("cura/active_machine")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
|
@ -46,9 +44,15 @@ class MachineManagerModel(QObject):
|
||||||
activeVariantChanged = pyqtSignal()
|
activeVariantChanged = pyqtSignal()
|
||||||
activeQualityChanged = pyqtSignal()
|
activeQualityChanged = pyqtSignal()
|
||||||
|
|
||||||
|
activeExtrudersChanged = 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)
|
||||||
|
def activeExtruders(self):
|
||||||
|
return {}
|
||||||
|
|
||||||
def _onGlobalPropertyChanged(self, key, property_name):
|
def _onGlobalPropertyChanged(self, key, property_name):
|
||||||
if property_name == "value":
|
if property_name == "value":
|
||||||
self.globalValueChanged.emit()
|
self.globalValueChanged.emit()
|
||||||
|
@ -115,7 +119,7 @@ class MachineManagerModel(QObject):
|
||||||
UM.Settings.ContainerRegistry.getInstance().addContainer(current_settings_instance_container)
|
UM.Settings.ContainerRegistry.getInstance().addContainer(current_settings_instance_container)
|
||||||
|
|
||||||
# If a definition is found, its a list. Should only have one item.
|
# If a definition is found, its a list. Should only have one item.
|
||||||
new_global_stack.addContainer(definitions[0])
|
new_global_stack.addContainer(definition)
|
||||||
if variant_instance_container:
|
if variant_instance_container:
|
||||||
new_global_stack.addContainer(variant_instance_container)
|
new_global_stack.addContainer(variant_instance_container)
|
||||||
if material_instance_container:
|
if material_instance_container:
|
||||||
|
@ -124,6 +128,23 @@ class MachineManagerModel(QObject):
|
||||||
new_global_stack.addContainer(quality_instance_container)
|
new_global_stack.addContainer(quality_instance_container)
|
||||||
new_global_stack.addContainer(current_settings_instance_container)
|
new_global_stack.addContainer(current_settings_instance_container)
|
||||||
|
|
||||||
|
## Check if the machine has extruder trains
|
||||||
|
extruder_trains = definition.getMetaDataEntry("machine_extruder_trains", {})
|
||||||
|
for extruder in extruder_trains:
|
||||||
|
extruder_train_stack = UM.Settings.ContainerStack(name + "_extruder_" + extruder)
|
||||||
|
extruder_train_stack.addMetaDataEntry("type", "extruder")
|
||||||
|
extruder_definitions = UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id=extruder_trains[extruder])
|
||||||
|
if extruder_definitions:
|
||||||
|
extruder_train_stack.addContainer(extruder_definitions[0])
|
||||||
|
current_settings_container_extruder = UM.Settings.InstanceContainer(extruder_train_stack.getName() + "_current_settings")
|
||||||
|
current_settings_container_extruder.addMetaDataEntry("machine", name)
|
||||||
|
current_settings_container_extruder.addMetaDataEntry("type", "user")
|
||||||
|
extruder_train_stack.addContainer(current_settings_container_extruder)
|
||||||
|
extruder_train_stack.setNextStack(new_global_stack)
|
||||||
|
UM.Settings.ContainerRegistry.getInstance().addContainer(extruder_train_stack)
|
||||||
|
else:
|
||||||
|
Logger.log("W", "Unable to find definition for extruder")
|
||||||
|
|
||||||
Application.getInstance().setGlobalContainerStack(new_global_stack)
|
Application.getInstance().setGlobalContainerStack(new_global_stack)
|
||||||
|
|
||||||
# Create a name that is not empty and unique
|
# Create a name that is not empty and unique
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue