From 759d44dbef23f3c5de81619552130435a585d7cb Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Wed, 23 Aug 2017 14:39:05 +0200 Subject: [PATCH 01/11] Add stack context for function evaluation CURA-4186 --- cura/Settings/ExtruderStack.py | 19 ++++++++++++++----- cura/Settings/GlobalStack.py | 14 +++++++++++--- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/cura/Settings/ExtruderStack.py b/cura/Settings/ExtruderStack.py index 908bc4cd6f..0a9bddfb30 100644 --- a/cura/Settings/ExtruderStack.py +++ b/cura/Settings/ExtruderStack.py @@ -7,7 +7,7 @@ from UM.Decorators import override from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase from UM.Settings.ContainerStack import ContainerStack from UM.Settings.ContainerRegistry import ContainerRegistry -from UM.Settings.Interfaces import ContainerInterface +from UM.Settings.Interfaces import ContainerInterface, PropertyEvaluationContext from . import Exceptions from .CuraContainerStack import CuraContainerStack @@ -57,21 +57,30 @@ class ExtruderStack(CuraContainerStack): # \throws Exceptions.NoGlobalStackError Raised when trying to get a property from an extruder without # having a next stack set. @override(ContainerStack) - def getProperty(self, key: str, property_name: str) -> Any: + def getProperty(self, key: str, property_name: str, context: Optional[PropertyEvaluationContext] = None) -> Any: if not self._next_stack: raise Exceptions.NoGlobalStackError("Extruder {id} is missing the next stack!".format(id = self.id)) + if context is None: + context = PropertyEvaluationContext() + context.pushContainer(self) + if not super().getProperty(key, "settable_per_extruder"): - return self.getNextStack().getProperty(key, property_name) + result = self.getNextStack().getProperty(key, property_name, context) + context.popContainer() + return result limit_to_extruder = super().getProperty(key, "limit_to_extruder") if (limit_to_extruder is not None and limit_to_extruder != "-1") and self.getMetaDataEntry("position") != str(limit_to_extruder): if str(limit_to_extruder) in self.getNextStack().extruders: - result = self.getNextStack().extruders[str(limit_to_extruder)].getProperty(key, property_name) + result = self.getNextStack().extruders[str(limit_to_extruder)].getProperty(key, property_name, context) if result is not None: + context.popContainer() return result - return super().getProperty(key, property_name) + result = super().getProperty(key, property_name, context) + context.popContainer() + return result @override(CuraContainerStack) def _getMachineDefinition(self) -> ContainerInterface: diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index c09889c9c5..ed99429fa3 100755 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -11,6 +11,7 @@ from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase from UM.Settings.ContainerStack import ContainerStack from UM.Settings.SettingInstance import InstanceState from UM.Settings.ContainerRegistry import ContainerRegistry +from UM.Settings.Interfaces import PropertyEvaluationContext from UM.Logger import Logger from . import Exceptions @@ -91,7 +92,7 @@ class GlobalStack(CuraContainerStack): # # \return The value of the property for the specified setting, or None if not found. @override(ContainerStack) - def getProperty(self, key: str, property_name: str) -> Any: + def getProperty(self, key: str, property_name: str, context: Optional[PropertyEvaluationContext] = None) -> Any: if not self.definition.findDefinitions(key = key): return None @@ -103,17 +104,24 @@ class GlobalStack(CuraContainerStack): if resolve is not None: return resolve + if context is None: + context = PropertyEvaluationContext() + context.pushContainer(self) + # Handle the "limit_to_extruder" property. limit_to_extruder = super().getProperty(key, "limit_to_extruder") if limit_to_extruder is not None and limit_to_extruder != "-1" and limit_to_extruder in self._extruders: if super().getProperty(key, "settable_per_extruder"): - result = self._extruders[str(limit_to_extruder)].getProperty(key, property_name) + result = self._extruders[str(limit_to_extruder)].getProperty(key, property_name, context) if result is not None: + context.popContainer() return result else: Logger.log("e", "Setting {setting} has limit_to_extruder but is not settable per extruder!", setting = key) - return super().getProperty(key, property_name) + result = super().getProperty(key, property_name, context) + context.popContainer() + return result ## Overridden from ContainerStack # From 2ec7c14422eb6b50814af5a64daac5e9d673d80f Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 24 Aug 2017 16:57:10 +0200 Subject: [PATCH 02/11] Fix PerObjectSettingsPanel.qml CURA-4186 - The UI shouldn't be bound to the limit_to_extruder stack, it should always be bound to the per-object stack. - The ActiveTool.getValue() calls cannot be bound in QML, so use a Connections to update the values based on signals. --- .../PerObjectSettingsPanel.qml | 38 ++++++------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index 07a8fc21bc..d31bf162e2 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -135,6 +135,8 @@ Item { } } + // Specialty provider that only watches global_inherits (we cant filter on what property changed we get events + // so we bypass that to make a dedicated provider). UM.SettingPropertyProvider { id: provider @@ -146,8 +148,6 @@ Item { removeUnusedValue: false } - // Specialty provider that only watches global_inherits (we cant filter on what property changed we get events - // so we bypass that to make a dedicated provider). UM.SettingPropertyProvider { id: inheritStackProvider @@ -156,36 +156,22 @@ Item { watchedProperties: [ "limit_to_extruder" ] } - Binding + Connections { - target: provider - property: "containerStackId" - when: model.settable_per_extruder || (inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0); - value: + target: UM.ActiveTool + onPropertiesChanged: { - // associate this binding with Cura.MachineManager.activeMachineId in the beginning so this - // binding will be triggered when activeMachineId is changed too. - // Otherwise, if this value only depends on the extruderIds, it won't get updated when the - // machine gets changed. - var activeMachineId = Cura.MachineManager.activeMachineId; - - if(!model.settable_per_extruder || machineExtruderCount.properties.value == 1) + // the values cannot be bound with UM.ActiveTool.properties.getValue() calls, + // so here we connect to the signal and update the those values. + if (typeof UM.ActiveTool.properties.getValue("SelectedObjectId") !== "undefined") { - //Not settable per extruder or there only is global, so we must pick global. - return activeMachineId; + addedSettingsModel.visibilityHandler.selectedObjectId = UM.ActiveTool.properties.getValue("SelectedObjectId"); } - if(inheritStackProvider.properties.limit_to_extruder != null && inheritStackProvider.properties.limit_to_extruder >= 0) + if (typeof UM.ActiveTool.properties.getValue("ContainerID") !== "undefined") { - //We have limit_to_extruder, so pick that stack. - return ExtruderManager.extruderIds[String(inheritStackProvider.properties.limit_to_extruder)]; + provider.containerStackId = UM.ActiveTool.properties.getValue("ContainerID"); + inheritStackProvider.containerStackId = UM.ActiveTool.properties.getValue("ContainerID"); } - if(UM.ActiveTool.properties.getValue("ContainerID")) - { - //We're on an extruder tab. Pick the current extruder. - return UM.ActiveTool.properties.getValue("ContainerID"); - } - //No extruder tab is selected. Pick the global stack. Shouldn't happen any more since we removed the global tab. - return activeMachineId; } } } From 365379f7352dd49be6dc0d7dee3da4e4e6b36691 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 24 Aug 2017 17:01:01 +0200 Subject: [PATCH 03/11] Add missing context in getProperty() in global and extruder stacks CURA-4186 All getProperty() calls should use the provided context. --- cura/Settings/ExtruderStack.py | 6 ++++-- cura/Settings/GlobalStack.py | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cura/Settings/ExtruderStack.py b/cura/Settings/ExtruderStack.py index 0a9bddfb30..0319b2a9ba 100644 --- a/cura/Settings/ExtruderStack.py +++ b/cura/Settings/ExtruderStack.py @@ -65,12 +65,14 @@ class ExtruderStack(CuraContainerStack): context = PropertyEvaluationContext() context.pushContainer(self) - if not super().getProperty(key, "settable_per_extruder"): + if not super().getProperty(key, "settable_per_extruder", context): result = self.getNextStack().getProperty(key, property_name, context) context.popContainer() return result - limit_to_extruder = super().getProperty(key, "limit_to_extruder") + limit_to_extruder = super().getProperty(key, "limit_to_extruder", context) + if limit_to_extruder is not None: + limit_to_extruder = str(limit_to_extruder) if (limit_to_extruder is not None and limit_to_extruder != "-1") and self.getMetaDataEntry("position") != str(limit_to_extruder): if str(limit_to_extruder) in self.getNextStack().extruders: result = self.getNextStack().extruders[str(limit_to_extruder)].getProperty(key, property_name, context) diff --git a/cura/Settings/GlobalStack.py b/cura/Settings/GlobalStack.py index ed99429fa3..bee82e2272 100755 --- a/cura/Settings/GlobalStack.py +++ b/cura/Settings/GlobalStack.py @@ -99,7 +99,7 @@ class GlobalStack(CuraContainerStack): # Handle the "resolve" property. if self._shouldResolve(key, property_name): self._resolving_settings.add(key) - resolve = super().getProperty(key, "resolve") + resolve = super().getProperty(key, "resolve", context) self._resolving_settings.remove(key) if resolve is not None: return resolve @@ -109,9 +109,11 @@ class GlobalStack(CuraContainerStack): context.pushContainer(self) # Handle the "limit_to_extruder" property. - limit_to_extruder = super().getProperty(key, "limit_to_extruder") + limit_to_extruder = super().getProperty(key, "limit_to_extruder", context) + if limit_to_extruder is not None: + limit_to_extruder = str(limit_to_extruder) if limit_to_extruder is not None and limit_to_extruder != "-1" and limit_to_extruder in self._extruders: - if super().getProperty(key, "settable_per_extruder"): + if super().getProperty(key, "settable_per_extruder", context): result = self._extruders[str(limit_to_extruder)].getProperty(key, property_name, context) if result is not None: context.popContainer() From 50a7e8146fb984297d349dd3a0f9fe7c30e3af7d Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 24 Aug 2017 17:09:28 +0200 Subject: [PATCH 04/11] Add a dedicated stack class for per-object settings CURA-4186 Add a dedicated stack class PerObjectContainerStack for per-object settings to evaluate limit_to_extruder values correctly. --- cura/Settings/PerObjectContainerStack.py | 49 +++++++++++++++++++++++ cura/Settings/SettingOverrideDecorator.py | 4 +- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 cura/Settings/PerObjectContainerStack.py diff --git a/cura/Settings/PerObjectContainerStack.py b/cura/Settings/PerObjectContainerStack.py new file mode 100644 index 0000000000..58b7e297e6 --- /dev/null +++ b/cura/Settings/PerObjectContainerStack.py @@ -0,0 +1,49 @@ +from typing import Any, Optional + +from UM.Decorators import override +from UM.Logger import Logger +from UM.Settings.Interfaces import PropertyEvaluationContext +from UM.Settings.ContainerStack import ContainerStack + + +class PerObjectContainerStack(ContainerStack): + + @override(ContainerStack) + def getProperty(self, key: str, property_name: str, context: Optional[PropertyEvaluationContext] = None) -> Any: + if context is None: + context = PropertyEvaluationContext() + context.pushContainer(self) + + # this import has to be here otherwise there will be a circular import loop + from cura.CuraApplication import CuraApplication + global_stack = CuraApplication.getInstance().getGlobalContainerStack() + + # Handle the "limit_to_extruder" property. + limit_to_extruder = super().getProperty(key, "limit_to_extruder", context) + if limit_to_extruder is not None: + limit_to_extruder = str(limit_to_extruder) + + # if this stack has the limit_to_extruder "not overriden", use the original limit_to_extruder as the current + # limit_to_extruder, so the values retrieved will be from the perspective of the original limit_to_extruder + # stack. + if limit_to_extruder == "-1": + if 'original_limit_to_extruder' in context.context: + limit_to_extruder = context.context['original_limit_to_extruder'] + + if limit_to_extruder is not None and limit_to_extruder != "-1" and limit_to_extruder in global_stack.extruders: + # set the original limit_to_extruder if this is the first stack that has a non-overriden limit_to_extruder + if 'original_limit_to_extruder' not in context.context: + context.context['original_limit_to_extruder'] = limit_to_extruder + + if super().getProperty(key, "settable_per_extruder", context): + result = global_stack.extruders[str(limit_to_extruder)].getProperty(key, property_name, context) + if result is not None: + context.popContainer() + return result + else: + Logger.log("e", "Setting {setting} has limit_to_extruder but is not settable per extruder!", setting = key) + + result = super().getProperty(key, property_name, context) + context.popContainer() + return result + diff --git a/cura/Settings/SettingOverrideDecorator.py b/cura/Settings/SettingOverrideDecorator.py index 503e0b2490..2a69353885 100644 --- a/cura/Settings/SettingOverrideDecorator.py +++ b/cura/Settings/SettingOverrideDecorator.py @@ -5,13 +5,13 @@ import copy from UM.Scene.SceneNodeDecorator import SceneNodeDecorator from UM.Signal import Signal, signalemitter -from UM.Settings.ContainerStack import ContainerStack from UM.Settings.InstanceContainer import InstanceContainer from UM.Settings.ContainerRegistry import ContainerRegistry from UM.Logger import Logger from UM.Application import Application +from cura.Settings.PerObjectContainerStack import PerObjectContainerStack from cura.Settings.ExtruderManager import ExtruderManager ## A decorator that adds a container stack to a Node. This stack should be queried for all settings regarding @@ -24,7 +24,7 @@ class SettingOverrideDecorator(SceneNodeDecorator): def __init__(self): super().__init__() - self._stack = ContainerStack(stack_id = id(self)) + self._stack = PerObjectContainerStack(stack_id = id(self)) self._stack.setDirty(False) # This stack does not need to be saved. self._stack.addContainer(InstanceContainer(container_id = "SettingOverrideInstanceContainer")) From f85a76b4bd9bfa90d9e24cc8a0f675474e419db0 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 24 Aug 2017 17:38:16 +0200 Subject: [PATCH 05/11] Fix per-object settings qml --- .../PerObjectSettingsPanel.qml | 17 ++++++++++++++--- resources/qml/Settings/SettingItem.qml | 6 +++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index d31bf162e2..4bf69f33b8 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -165,12 +165,23 @@ Item { // so here we connect to the signal and update the those values. if (typeof UM.ActiveTool.properties.getValue("SelectedObjectId") !== "undefined") { - addedSettingsModel.visibilityHandler.selectedObjectId = UM.ActiveTool.properties.getValue("SelectedObjectId"); + const selectedObjectId = UM.ActiveTool.properties.getValue("SelectedObjectId"); + if (addedSettingsModel.visibilityHandler.selectedObjectId != selectedObjectId) + { + addedSettingsModel.visibilityHandler.selectedObjectId = selectedObjectId; + } } if (typeof UM.ActiveTool.properties.getValue("ContainerID") !== "undefined") { - provider.containerStackId = UM.ActiveTool.properties.getValue("ContainerID"); - inheritStackProvider.containerStackId = UM.ActiveTool.properties.getValue("ContainerID"); + const containerId = UM.ActiveTool.properties.getValue("ContainerID"); + if (provider.containerStackId != containerId) + { + provider.containerStackId = containerId; + } + if (inheritStackProvider.containerStackId != containerId) + { + inheritStackProvider.containerStackId = containerId; + } } } } diff --git a/resources/qml/Settings/SettingItem.qml b/resources/qml/Settings/SettingItem.qml index 112edb5049..829a0b5c12 100644 --- a/resources/qml/Settings/SettingItem.qml +++ b/resources/qml/Settings/SettingItem.qml @@ -142,7 +142,7 @@ Item { { id: linkedSettingIcon; - visible: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId && (!definition.settable_per_extruder || globalPropertyProvider.properties.limit_to_extruder != "-1") && base.showLinkedSettingIcon + visible: Cura.MachineManager.activeStackId != Cura.MachineManager.activeMachineId && (!definition.settable_per_extruder || String(globalPropertyProvider.properties.limit_to_extruder) != "-1") && base.showLinkedSettingIcon height: parent.height; width: height; @@ -222,7 +222,7 @@ Item { } // If the setting does not have a limit_to_extruder property (or is -1), use the active stack. - if(globalPropertyProvider.properties.limit_to_extruder == null || globalPropertyProvider.properties.limit_to_extruder == -1) + if(globalPropertyProvider.properties.limit_to_extruder == null || String(globalPropertyProvider.properties.limit_to_extruder) == "-1") { return Cura.SettingInheritanceManager.settingsWithInheritanceWarning.indexOf(definition.key) >= 0; } @@ -232,7 +232,7 @@ Item { // Observed when loading workspace, probably when SettingItems are removed. return false; } - return Cura.SettingInheritanceManager.getOverridesForExtruder(definition.key, globalPropertyProvider.properties.limit_to_extruder).indexOf(definition.key) >= 0; + return Cura.SettingInheritanceManager.getOverridesForExtruder(definition.key, String(globalPropertyProvider.properties.limit_to_extruder)).indexOf(definition.key) >= 0; } height: parent.height; From c44e527305f67a8d50e7b446d061b7693622102b Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 25 Aug 2017 11:57:50 +0200 Subject: [PATCH 06/11] Remove warning in /PerObjectContainerStack CURA-4186 --- cura/Settings/PerObjectContainerStack.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cura/Settings/PerObjectContainerStack.py b/cura/Settings/PerObjectContainerStack.py index 58b7e297e6..654e18c33e 100644 --- a/cura/Settings/PerObjectContainerStack.py +++ b/cura/Settings/PerObjectContainerStack.py @@ -1,7 +1,6 @@ from typing import Any, Optional from UM.Decorators import override -from UM.Logger import Logger from UM.Settings.Interfaces import PropertyEvaluationContext from UM.Settings.ContainerStack import ContainerStack @@ -40,10 +39,7 @@ class PerObjectContainerStack(ContainerStack): if result is not None: context.popContainer() return result - else: - Logger.log("e", "Setting {setting} has limit_to_extruder but is not settable per extruder!", setting = key) result = super().getProperty(key, property_name, context) context.popContainer() return result - From 414901ae84417449614211615fddf01dee8a524b Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 25 Aug 2017 11:58:37 +0200 Subject: [PATCH 07/11] Force update the provider when the setting's limit_to_extruder gets changed CURA-4186 In the per-object settings, when a setting's limit_to_extruder gets changed, its value should be updated too. --- plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml index 4bf69f33b8..28cd2759f6 100644 --- a/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml +++ b/plugins/PerObjectSettingsTool/PerObjectSettingsPanel.qml @@ -156,6 +156,15 @@ Item { watchedProperties: [ "limit_to_extruder" ] } + Connections + { + target: inheritStackProvider + onPropertiesChanged: + { + provider.forcePropertiesChanged(); + } + } + Connections { target: UM.ActiveTool From a320784a6d96d8526e40890c019d3b39fea13cc1 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 25 Aug 2017 12:19:05 +0200 Subject: [PATCH 08/11] For a per-object setting, use the user-defined value first CURA-4186 In a per-object setting, if there is user defined value, use that first. If the value is default, then evaluate it with the normal routine. --- cura/Settings/PerObjectContainerStack.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cura/Settings/PerObjectContainerStack.py b/cura/Settings/PerObjectContainerStack.py index 654e18c33e..fdb314f695 100644 --- a/cura/Settings/PerObjectContainerStack.py +++ b/cura/Settings/PerObjectContainerStack.py @@ -3,6 +3,7 @@ from typing import Any, Optional from UM.Decorators import override from UM.Settings.Interfaces import PropertyEvaluationContext from UM.Settings.ContainerStack import ContainerStack +from UM.Settings.SettingInstance import InstanceState class PerObjectContainerStack(ContainerStack): @@ -17,6 +18,13 @@ class PerObjectContainerStack(ContainerStack): from cura.CuraApplication import CuraApplication global_stack = CuraApplication.getInstance().getGlobalContainerStack() + # Return the user defined value if present, otherwise, evaluate the value according to the default routine. + if self.getContainer(0).hasProperty(key, property_name): + if self.getContainer(0)._instances[key].state == InstanceState.User: + result = super().getProperty(key, property_name, context) + context.popContainer() + return result + # Handle the "limit_to_extruder" property. limit_to_extruder = super().getProperty(key, "limit_to_extruder", context) if limit_to_extruder is not None: From 141aad5513351c5f9b345f744725190ab4fca912 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Fri, 25 Aug 2017 12:48:47 +0200 Subject: [PATCH 09/11] Trigger to re-evaluate default settings in per-object settings when the active stack gets changed. CURA-4186 Trigger signals to re-evaluate default settings in pre-object settings when the active stack gets changed. Otherwise the values won't be updated directly. --- cura/Settings/PerObjectContainerStack.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/cura/Settings/PerObjectContainerStack.py b/cura/Settings/PerObjectContainerStack.py index fdb314f695..a0b080d099 100644 --- a/cura/Settings/PerObjectContainerStack.py +++ b/cura/Settings/PerObjectContainerStack.py @@ -51,3 +51,16 @@ class PerObjectContainerStack(ContainerStack): result = super().getProperty(key, property_name, context) context.popContainer() return result + + @override(ContainerStack) + def setNextStack(self, stack: ContainerStack): + super().setNextStack(stack) + + # trigger signal to re-evaluate all default settings + for key, instance in self.getContainer(0)._instances.items(): + # only evaluate default settings + if instance.state != InstanceState.Default: + continue + + self._collectPropertyChanges(key, "value") + self._emitCollectedPropertyChanges() From 37414e7bc7c85ee85ce47289a3268f1214bda2b3 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 28 Aug 2017 14:34:51 +0200 Subject: [PATCH 10/11] Fix code style: double quotes instead of single quotes CURA-4186 --- cura/Settings/PerObjectContainerStack.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cura/Settings/PerObjectContainerStack.py b/cura/Settings/PerObjectContainerStack.py index a0b080d099..f0395823bd 100644 --- a/cura/Settings/PerObjectContainerStack.py +++ b/cura/Settings/PerObjectContainerStack.py @@ -34,13 +34,13 @@ class PerObjectContainerStack(ContainerStack): # limit_to_extruder, so the values retrieved will be from the perspective of the original limit_to_extruder # stack. if limit_to_extruder == "-1": - if 'original_limit_to_extruder' in context.context: - limit_to_extruder = context.context['original_limit_to_extruder'] + if "original_limit_to_extruder" in context.context: + limit_to_extruder = context.context["original_limit_to_extruder"] if limit_to_extruder is not None and limit_to_extruder != "-1" and limit_to_extruder in global_stack.extruders: # set the original limit_to_extruder if this is the first stack that has a non-overriden limit_to_extruder - if 'original_limit_to_extruder' not in context.context: - context.context['original_limit_to_extruder'] = limit_to_extruder + if "original_limit_to_extruder" not in context.context: + context.context["original_limit_to_extruder"] = limit_to_extruder if super().getProperty(key, "settable_per_extruder", context): result = global_stack.extruders[str(limit_to_extruder)].getProperty(key, property_name, context) From b84500f742db7ffb9352065027024b0a3f913ec6 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 28 Aug 2017 14:35:34 +0200 Subject: [PATCH 11/11] Import Application instead of inline import CuraApplication CURA-4186 --- cura/Settings/PerObjectContainerStack.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cura/Settings/PerObjectContainerStack.py b/cura/Settings/PerObjectContainerStack.py index f0395823bd..6c54ed46d5 100644 --- a/cura/Settings/PerObjectContainerStack.py +++ b/cura/Settings/PerObjectContainerStack.py @@ -1,5 +1,6 @@ from typing import Any, Optional +from UM.Application import Application from UM.Decorators import override from UM.Settings.Interfaces import PropertyEvaluationContext from UM.Settings.ContainerStack import ContainerStack @@ -14,9 +15,7 @@ class PerObjectContainerStack(ContainerStack): context = PropertyEvaluationContext() context.pushContainer(self) - # this import has to be here otherwise there will be a circular import loop - from cura.CuraApplication import CuraApplication - global_stack = CuraApplication.getInstance().getGlobalContainerStack() + global_stack = Application.getInstance().getGlobalContainerStack() # Return the user defined value if present, otherwise, evaluate the value according to the default routine. if self.getContainer(0).hasProperty(key, property_name):