Robustly get layer height even if quality has none

If the quality profile doesn't define a layer height (which it currently always has) then this should still get the proper layer height. It proceeds properly down the stack now.

Contributes to issue CURA-2737.
This commit is contained in:
Ghostkeeper 2016-10-21 11:51:10 +02:00
parent 57b0275384
commit 16491d8d23
No known key found for this signature in database
GPG key ID: C5F96EE2BC0F7E75

View file

@ -478,21 +478,27 @@ class MachineManager(QObject):
#
# This is indicated together with the name of the active quality profile.
#
# \return The layer height of the currently active quality profile.
# \return The layer height of the currently active quality profile. If
# there is no quality profile, this returns 0.
@pyqtProperty(float, notify=activeQualityChanged)
def activeQualityLayerHeight(self):
if not self._global_container_stack:
return 0
quality = self._global_container_stack.findContainer({"type": "quality_changes"})
if quality and quality.hasProperty("layer_height", "value"):
print(quality.getProperty("layer_height", "value"))
return quality.getProperty("layer_height", "value")
quality_changes = self._global_container_stack.findContainer({"type": "quality_changes"})
if quality_changes:
value = self._global_container_stack.getRawProperty("layer_height", "value", skip_until_container = quality_changes.getId())
if isinstance(value, UM.Settings.SettingFunction):
value = value(self._global_container_stack)
return value
quality = self._global_container_stack.findContainer({"type": "quality"})
if quality and quality.hasProperty("layer_height", "value"): #This depends on layer_height always being present in the quality.
#If it isn't, there is no way we can find the layer_height while excluding any layer_height in the user profile.
return quality.getProperty("layer_height", "value")
return 0
if quality:
value = self._global_container_stack.getRawProperty("layer_height", "value", skip_until_container = quality.getId())
if isinstance(value, UM.Settings.SettingFunction):
value = value(self._global_container_stack)
return value
return 0 #No quality profile.
## Get the Material ID associated with the currently active material
# \returns MaterialID (string) if found, empty string otherwise