This commit is contained in:
fieldOfView 2016-06-07 15:58:08 +02:00
commit f7e299a750
3 changed files with 19 additions and 12 deletions

View File

@ -4,7 +4,7 @@
from PyQt5.QtCore import pyqtSignal, pyqtProperty, pyqtSlot, QObject #For communicating data and events to Qt.
import UM.Application #To get the global container stack to find the current machine.
from UM.Logger import Logger
import UM.Logger
import UM.Settings.ContainerRegistry #Finding containers by ID.
@ -65,15 +65,12 @@ class ExtruderManager(QObject):
return
#Add the extruder trains that don't exist yet.
for position, extruder_definition_id in machine_definition.getMetaDataEntry("machine_extruder_trains", default = {}).items():
extruder_definition = container_registry.findDefinitionContainers(machine = machine_definition.getId())
if extruder_definition:
extruder_definition = extruder_definition[0]
else:
Logger.log("w", "Machine %s references an extruder with ID %s, which doesn't exist.", machine_definition.getName(), extruder_definition_id)
continue
name = container_registry.uniqueName(extruder_definition_id) #Make a name based on the ID of the definition.
if not container_registry.findContainerStacks(id = name): #Doesn't exist yet.
for extruder_definition in container_registry.findDefinitionContainers(machine = machine_definition.getId()):
position = extruder_definition.getMetaDataEntry("position", None)
if not position:
UM.Logger.Log("w", "Extruder definition %s specifies no position metadata entry.", extruder_definition.getId())
if not container_registry.findContainerStacks(machine = machine_id, position = position): #Doesn't exist yet.
name = container_registry.uniqueName(extruder_definition.getId()) #Make a name based on the ID of the definition.
self.createExtruderTrain(extruder_definition, machine_definition, name, position)
#Gets the extruder trains that we just created as well as any that still existed.

View File

@ -7,7 +7,7 @@ from UM.Settings.InstanceContainer import InstanceContainer
from UM.Settings.ContainerRegistry import ContainerRegistry
from UM.Application import Application
import copy
## A decorator that adds a container stack to a Node. This stack should be queried for all settings regarding
# the linked node. The Stack in question will refer to the global stack (so that settings that are not defined by
# this stack still resolve.
@ -15,6 +15,7 @@ class SettingOverrideDecorator(SceneNodeDecorator):
def __init__(self):
super().__init__()
self._stack = ContainerStack(stack_id = id(self))
self._stack.setDirty(False) # This stack does not need to be saved.
self._instance = InstanceContainer(container_id = "SettingOverrideInstanceContainer")
self._stack.addContainer(self._instance)
@ -25,6 +26,15 @@ class SettingOverrideDecorator(SceneNodeDecorator):
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged)
self._onGlobalContainerStackChanged()
def __deepcopy__(self, memo):
## Create a fresh decorator object
deep_copy = SettingOverrideDecorator()
## Copy the instance
deep_copy._instance = copy.deepcopy(self._instance, memo)
## Set the copied instance as the first (and only) instance container of the stack.
deep_copy._stack.replaceContainer(0, deep_copy._instance)
return deep_copy
def _onSettingChanged(self, instance, property):
if property == "value": # Only reslice if the value has changed.
Application.getInstance().getBackend().forceSlice()

View File

@ -120,7 +120,7 @@ Item {
containerStackId: UM.ActiveTool.properties.getValue("ContainerID")
key: model.key
watchedProperties: [ "value", "enabled", "state", "validationState" ]
watchedProperties: [ "value", "enabled", "validationState" ]
storeIndex: 0
}
}