No longer use brute force approach for per object

CURA-1754
This commit is contained in:
Jaime van Kessel 2016-07-29 15:44:34 +02:00
parent 601a6e987d
commit fa78cf2d39

View File

@ -13,6 +13,7 @@ from UM.Scene.SceneNode import SceneNode
from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator from UM.Scene.Iterator.DepthFirstIterator import DepthFirstIterator
from UM.Settings.Validator import ValidatorState from UM.Settings.Validator import ValidatorState
from UM.Settings.SettingRelation import RelationType
from cura.OneAtATimeIterator import OneAtATimeIterator from cura.OneAtATimeIterator import OneAtATimeIterator
@ -213,9 +214,27 @@ class StartSliceJob(Job):
stack = node.callDecoration("getStack") stack = node.callDecoration("getStack")
# Check if the node has a stack attached to it and the stack has any settings in the top container. # Check if the node has a stack attached to it and the stack has any settings in the top container.
if stack: if stack:
# Because we want to use inheritance correctly, we send all settings as seen from the per object stack. # Check all settings for relations, so we can also calculate the correct values for dependant settings.
for key in stack.getAllKeys(): changed_setting_keys = set(stack.getTop().getAllKeys())
for key in stack.getTop().getAllKeys():
instance = stack.getTop().getInstance(key)
self._addRelations(changed_setting_keys, instance.definition.relations)
Job.yieldThread()
# Ensure that the engine is aware what the build extruder is
changed_setting_keys.add("extruder_nr")
# Get values for all changed settings
for key in changed_setting_keys:
setting = message.addRepeatedMessage("settings") setting = message.addRepeatedMessage("settings")
setting.name = key setting.name = key
setting.value = str(stack.getProperty(key, "value")).encode("utf-8") setting.value = str(stack.getProperty(key, "value")).encode("utf-8")
Job.yieldThread() Job.yieldThread()
def _addRelations(self, relations_set, relations):
for relation in filter(lambda r: r.role == "value", relations):
if relation.type == RelationType.RequiresTarget:
continue
relations_set.add(relation.target.key)
self._addRelations(relations_set, relation.target.relations)