Introduced resolveOrValue which fixes resolvement with dependencies for the most part. CURA-2232

This commit is contained in:
Jack Ha 2016-09-26 10:37:44 +02:00
parent 281f9e18a3
commit 4547cfe504
5 changed files with 59 additions and 15 deletions

View file

@ -103,6 +103,7 @@ class CuraApplication(QtApplication):
SettingFunction.registerOperator("extruderValues", cura.Settings.ExtruderManager.getExtruderValues) SettingFunction.registerOperator("extruderValues", cura.Settings.ExtruderManager.getExtruderValues)
SettingFunction.registerOperator("extruderValue", cura.Settings.ExtruderManager.getExtruderValue) SettingFunction.registerOperator("extruderValue", cura.Settings.ExtruderManager.getExtruderValue)
SettingFunction.registerOperator("resolveOrValue", cura.Settings.ExtruderManager.getResolveOrValue)
## Add the 4 types of profiles to storage. ## Add the 4 types of profiles to storage.
Resources.addStorageType(self.ResourceTypes.QualityInstanceContainer, "quality") Resources.addStorageType(self.ResourceTypes.QualityInstanceContainer, "quality")

View file

@ -433,9 +433,16 @@ class ContainerManager(QObject):
def clearUserContainers(self): def clearUserContainers(self):
self._machine_manager.blurSettings.emit() self._machine_manager.blurSettings.emit()
send_emits_containers = []
# Go through global and extruder stacks and clear their topmost container (the user settings). # Go through global and extruder stacks and clear their topmost container (the user settings).
for stack in cura.Settings.ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks(): for stack in cura.Settings.ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks():
stack.getTop().clear() container = stack.getTop()
container.clear()
send_emits_containers.append(container)
for container in send_emits_containers:
container.sendPostponedEmits()
## Create quality changes containers from the user containers in the active stacks. ## Create quality changes containers from the user containers in the active stacks.
# #

View file

@ -347,7 +347,7 @@ class ExtruderManager(QObject):
for extruder in ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()): for extruder in ExtruderManager.getInstance().getMachineExtruders(global_stack.getId()):
value = extruder.getRawProperty(key, "value") value = extruder.getRawProperty(key, "value")
if not value: if value is None:
continue continue
if isinstance(value, UM.Settings.SettingFunction): if isinstance(value, UM.Settings.SettingFunction):
@ -392,3 +392,29 @@ class ExtruderManager(QObject):
value = UM.Application.getInstance().getGlobalContainerStack().getProperty(key, "value") value = UM.Application.getInstance().getGlobalContainerStack().getProperty(key, "value")
return value return value
## Get the resolve value or value for a given key
#
# This is the effective value for a given key, it is used for values in the global stack.
# This is exposed to SettingFunction to use in value functions.
# \param key The key of the setting to get the value of.
#
# \return The effective value
@staticmethod
def getResolveOrValue(key):
global_stack = UM.Application.getInstance().getGlobalContainerStack()
resolved_value = global_stack.getProperty(key, "resolve")
if resolved_value is not None:
user_container = global_stack.findContainer({"type": "user"})
quality_changes_container = global_stack.findContainer({"type": "quality_changes"})
if user_container.hasProperty(key, "value") or quality_changes_container.hasProperty(key, "value"):
# Normal case
value = global_stack.getProperty(key, "value")
else:
# We have a resolved value and we're using it because of no user and quality_changes value
value = resolved_value
else:
value = global_stack.getRawProperty(key, "value")
return value

View file

@ -356,7 +356,8 @@ class MachineManager(QObject):
if self._global_container_stack.getTop().findInstances(): if self._global_container_stack.getTop().findInstances():
return True return True
for stack in ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId()): stacks = list(ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId()))
for stack in stacks:
if stack.getTop().findInstances(): if stack.getTop().findInstances():
return True return True
@ -369,10 +370,19 @@ class MachineManager(QObject):
if not self._global_container_stack: if not self._global_container_stack:
return return
self._global_container_stack.getTop().removeInstance(key) send_emits_containers = []
top_container = self._global_container_stack.getTop()
top_container.removeInstance(key, postpone_emit=True)
send_emits_containers.append(top_container)
for stack in ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId()): for stack in ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId()):
stack.getTop().removeInstance(key) container = stack.getTop()
container.removeInstance(key, postpone_emit=True)
send_emits_containers.append(container)
for container in send_emits_containers:
container.sendPostponedEmits()
## Check if the global profile does not contain error states ## Check if the global profile does not contain error states
# Note that the _active_stack_valid is cached due to performance issues # Note that the _active_stack_valid is cached due to performance issues

View file

@ -691,7 +691,7 @@
"description": "Width of a single prime tower line.", "description": "Width of a single prime tower line.",
"type": "float", "type": "float",
"unit": "mm", "unit": "mm",
"enabled": "prime_tower_enable", "enabled": "resolveOrValue('prime_tower_enable')",
"default_value": 0.4, "default_value": 0.4,
"value": "line_width", "value": "line_width",
"minimum_value": "0.0001", "minimum_value": "0.0001",
@ -1540,7 +1540,7 @@
"description": "The speed at which the prime tower is printed. Printing the prime tower slower can make it more stable when the adhesion between the different filaments is suboptimal.", "description": "The speed at which the prime tower is printed. Printing the prime tower slower can make it more stable when the adhesion between the different filaments is suboptimal.",
"type": "float", "type": "float",
"unit": "mm/s", "unit": "mm/s",
"enabled": "prime_tower_enable", "enabled": "resolveOrValue('prime_tower_enable')",
"default_value": 60, "default_value": 60,
"value": "speed_print", "value": "speed_print",
"minimum_value": "0.1", "minimum_value": "0.1",
@ -1814,7 +1814,7 @@
"maximum_value_warning": "10000", "maximum_value_warning": "10000",
"default_value": 3000, "default_value": 3000,
"value": "acceleration_print", "value": "acceleration_print",
"enabled": "prime_tower_enable and acceleration_enabled", "enabled": "resolveOrValue('prime_tower_enable') and acceleration_enabled",
"settable_per_mesh": false "settable_per_mesh": false
} }
} }
@ -2035,7 +2035,7 @@
"maximum_value_warning": "50", "maximum_value_warning": "50",
"default_value": 20, "default_value": 20,
"value": "jerk_print", "value": "jerk_print",
"enabled": "prime_tower_enable and jerk_enabled", "enabled": "resolveOrValue('prime_tower_enable') and jerk_enabled",
"settable_per_mesh": false "settable_per_mesh": false
} }
} }
@ -3345,9 +3345,9 @@
"description": "The width of the prime tower.", "description": "The width of the prime tower.",
"type": "float", "type": "float",
"unit": "mm", "unit": "mm",
"enabled": "prime_tower_enable", "enabled": "resolveOrValue('prime_tower_enable')",
"default_value": 15, "default_value": 15,
"value": "15 if prime_tower_enable else 0", "value": "15 if resolveOrValue('prime_tower_enable') else 0",
"minimum_value": "0", "minimum_value": "0",
"maximum_value": "min(0.5 * machine_width, 0.5 * machine_depth)", "maximum_value": "min(0.5 * machine_width, 0.5 * machine_depth)",
"maximum_value_warning": "20", "maximum_value_warning": "20",
@ -3360,7 +3360,7 @@
"description": "The x coordinate of the position of the prime tower.", "description": "The x coordinate of the position of the prime tower.",
"type": "float", "type": "float",
"unit": "mm", "unit": "mm",
"enabled": "prime_tower_enable", "enabled": "resolveOrValue('prime_tower_enable')",
"default_value": 200, "default_value": 200,
"minimum_value_warning": "-1000", "minimum_value_warning": "-1000",
"maximum_value_warning": "1000", "maximum_value_warning": "1000",
@ -3375,7 +3375,7 @@
"description": "The y coordinate of the position of the prime tower.", "description": "The y coordinate of the position of the prime tower.",
"type": "float", "type": "float",
"unit": "mm", "unit": "mm",
"enabled": "prime_tower_enable", "enabled": "resolveOrValue('prime_tower_enable')",
"default_value": 200, "default_value": 200,
"minimum_value_warning": "-1000", "minimum_value_warning": "-1000",
"maximum_value_warning": "1000", "maximum_value_warning": "1000",
@ -3390,7 +3390,7 @@
"description": "Flow compensation: the amount of material extruded is multiplied by this value.", "description": "Flow compensation: the amount of material extruded is multiplied by this value.",
"type": "float", "type": "float",
"unit": "%", "unit": "%",
"enabled": "prime_tower_enable", "enabled": "resolveOrValue('prime_tower_enable')",
"default_value": 100, "default_value": 100,
"minimum_value": "0.0001", "minimum_value": "0.0001",
"minimum_value_warning": "50", "minimum_value_warning": "50",
@ -3403,7 +3403,7 @@
"label": "Wipe Nozzle on Prime Tower", "label": "Wipe Nozzle on Prime Tower",
"description": "After printing the prime tower with one nozzle, wipe the oozed material from the other nozzle off on the prime tower.", "description": "After printing the prime tower with one nozzle, wipe the oozed material from the other nozzle off on the prime tower.",
"type": "bool", "type": "bool",
"enabled": "prime_tower_enable", "enabled": "resolveOrValue('prime_tower_enable')",
"default_value": false, "default_value": false,
"settable_per_mesh": false, "settable_per_mesh": false,
"settable_per_extruder": false "settable_per_extruder": false