From 4695862b491dc0edd2560b89f689b170f385e391 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 7 Jun 2016 13:33:19 +0200 Subject: [PATCH 1/8] Added deepcopy function to settingOverrideDecorator CURA-1636 --- cura/SettingOverrideDecorator.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/cura/SettingOverrideDecorator.py b/cura/SettingOverrideDecorator.py index e212d93dac..04e77b0d3f 100644 --- a/cura/SettingOverrideDecorator.py +++ b/cura/SettingOverrideDecorator.py @@ -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. @@ -25,6 +25,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 stack + deep_copy._stack = copy.deepcopy(self._stack, memo) + ## Ensure that the id is unique. + deep_copy._stack._id = id(deep_copy) + return deep_copy + def _onSettingChanged(self, instance, property): if property == "value": # Only reslice if the value has changed. Application.getInstance().getBackend().forceSlice() From 08d116590d2aac424be9f222b171a9ada751eabf Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Jun 2016 13:32:36 +0200 Subject: [PATCH 2/8] Revert "Fix ExtruderManager.py" That is not a fix. That is a patch. This reverts commit b991743053edf2778a2395dc9ede7007b99386eb. --- cura/ExtruderManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/ExtruderManager.py b/cura/ExtruderManager.py index b2c3b47e8e..d157cbb08e 100644 --- a/cura/ExtruderManager.py +++ b/cura/ExtruderManager.py @@ -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. @@ -57,7 +57,7 @@ class ExtruderManager(QObject): # \param machine_definition The machine to add the extruders for. def addMachineExtruders(self, machine_definition): machine_id = machine_definition.getId() - if machine_id not in self._extruder_trains: + if not self._extruder_trains[machine_id]: self._extruder_trains[machine_id] = { } container_registry = UM.Settings.ContainerRegistry.getInstance() From 8feed746bf82d7fccaf5c6966685aba49c96b8ac Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Jun 2016 13:40:49 +0200 Subject: [PATCH 3/8] Re-apply part of b991743053edf2778a2395dc9ede7007b99386eb that worked This was indeed a mistake. Contributes to issues CURA-340 and CURA-1278. --- cura/ExtruderManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/ExtruderManager.py b/cura/ExtruderManager.py index d157cbb08e..9fbfc8eb84 100644 --- a/cura/ExtruderManager.py +++ b/cura/ExtruderManager.py @@ -57,7 +57,7 @@ class ExtruderManager(QObject): # \param machine_definition The machine to add the extruders for. def addMachineExtruders(self, machine_definition): machine_id = machine_definition.getId() - if not self._extruder_trains[machine_id]: + if machine_id not in self._extruder_trains: self._extruder_trains[machine_id] = { } container_registry = UM.Settings.ContainerRegistry.getInstance() From a9376cffd1b19c43ecc068e8c579b6ab96d1e3d0 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Jun 2016 13:41:28 +0200 Subject: [PATCH 4/8] Fix logging Specify the fully qualified name. Contributes to issues CURA-340 and CURA-1278. --- cura/ExtruderManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/ExtruderManager.py b/cura/ExtruderManager.py index 9fbfc8eb84..9ec17c1abd 100644 --- a/cura/ExtruderManager.py +++ b/cura/ExtruderManager.py @@ -70,7 +70,7 @@ class ExtruderManager(QObject): 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) + UM.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. From 499a0557bd55492871a0160f7cd6f9b61fe1d0cb Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Tue, 7 Jun 2016 13:59:58 +0200 Subject: [PATCH 5/8] Fix checking if an extruder train already exists Contributes to issues CURA-340 and CURA-1278. --- cura/ExtruderManager.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/cura/ExtruderManager.py b/cura/ExtruderManager.py index 9ec17c1abd..df31cbacdf 100644 --- a/cura/ExtruderManager.py +++ b/cura/ExtruderManager.py @@ -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: - UM.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. From d2405a24d26f0c23b1be3349438232142234e842 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 7 Jun 2016 14:56:29 +0200 Subject: [PATCH 6/8] Perobject stacks are no longer saved CURA-1278 --- cura/SettingOverrideDecorator.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cura/SettingOverrideDecorator.py b/cura/SettingOverrideDecorator.py index 04e77b0d3f..10a14007f3 100644 --- a/cura/SettingOverrideDecorator.py +++ b/cura/SettingOverrideDecorator.py @@ -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) From 5761307b336c5dcdea2c8d162a78d04f4ac39863 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 7 Jun 2016 15:45:51 +0200 Subject: [PATCH 7/8] Updated deepcopy to correctly copy the instance container CURA-1636 --- cura/SettingOverrideDecorator.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cura/SettingOverrideDecorator.py b/cura/SettingOverrideDecorator.py index 10a14007f3..f9878e436c 100644 --- a/cura/SettingOverrideDecorator.py +++ b/cura/SettingOverrideDecorator.py @@ -29,10 +29,10 @@ class SettingOverrideDecorator(SceneNodeDecorator): def __deepcopy__(self, memo): ## Create a fresh decorator object deep_copy = SettingOverrideDecorator() - ## Copy the stack - deep_copy._stack = copy.deepcopy(self._stack, memo) - ## Ensure that the id is unique. - deep_copy._stack._id = id(deep_copy) + ## 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): From 9a14a3e8b755bb9f85015670d0fb85bf2c90f50f Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Tue, 7 Jun 2016 15:46:37 +0200 Subject: [PATCH 8/8] Per object settings no longer watches "state" property CURA-1278 --- plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index c89485517e..9565b0e345 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -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 } }