Merge branch 'master' of github.com:Ultimaker/Cura

This commit is contained in:
Tim Kuipers 2016-09-19 13:44:00 +02:00
commit 530d582c6c
3 changed files with 19 additions and 13 deletions

View File

@ -243,11 +243,11 @@ class MachineManager(QObject):
def _onPropertyChanged(self, key, property_name): def _onPropertyChanged(self, key, property_name):
if property_name == "value": if property_name == "value":
# If a setting is not settable per extruder, but "has enabled relations" that are settable per extruder # If a setting is not settable per extruder, but "has enabled" or "value" relations that are settable per extruder
# we need to copy the value to global, so that the front-end displays the right settings. # we need to copy the value to global, so that the front-end displays the right settings.
if not self._active_container_stack.getProperty(key, "settable_per_extruder"): if not self._active_container_stack.getProperty(key, "settable_per_extruder"):
relations = self._global_container_stack.getBottom()._getDefinition(key).relations relations = self._global_container_stack.getBottom()._getDefinition(key).relations
for relation in filter(lambda r: r.role == "enabled" and r.type == RelationType.RequiredByTarget, relations): for relation in filter(lambda r: (r.role == "enabled" or r.role == "value") and r.type == RelationType.RequiredByTarget, relations):
# Target setting is settable per extruder # Target setting is settable per extruder
if self._active_container_stack.getProperty(relation.target.key, "settable_per_extruder"): if self._active_container_stack.getProperty(relation.target.key, "settable_per_extruder"):
new_value = self._global_container_stack.getProperty(key, "value") new_value = self._global_container_stack.getProperty(key, "value")

View File

@ -1,10 +1,17 @@
# Copyright (c) 2016 Ultimaker B.V.
# Cura is released under the terms of the AGPLv3 or higher.
from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal from PyQt5.QtCore import QObject, pyqtSlot, pyqtProperty, pyqtSignal
import UM.Settings import UM.Settings
from UM.Application import Application from UM.Application import Application
import cura.Settings import cura.Settings
## The settingInheritance manager is responsible for checking each setting in order to see if one of the "deeper"
# containers has a setting function and the topmost one with a value has a value. We need to have this check
# because some profiles tend to have 'hardcoded' values that break our inheritance. A good example of that are the
# speed settings. If all the children of print_speed have a single value override, changing the speed won't
# actually do anything, as only the 'leaf' settings are used by the engine.
class SettingInheritanceManager(QObject): class SettingInheritanceManager(QObject):
def __init__(self, parent = None): def __init__(self, parent = None):
super().__init__(parent) super().__init__(parent)
@ -18,10 +25,6 @@ class SettingInheritanceManager(QObject):
settingsWithIntheritanceChanged = pyqtSignal() settingsWithIntheritanceChanged = pyqtSignal()
@pyqtSlot()
def test(self):
pass
## Get the keys of all children settings with an override. ## Get the keys of all children settings with an override.
@pyqtSlot(str, result = "QStringList") @pyqtSlot(str, result = "QStringList")
def getChildrenKeysWithOverride(self, key): def getChildrenKeysWithOverride(self, key):
@ -106,7 +109,6 @@ class SettingInheritanceManager(QObject):
return True return True
return False return False
@pyqtProperty("QVariantList", notify = settingsWithIntheritanceChanged) @pyqtProperty("QVariantList", notify = settingsWithIntheritanceChanged)
def settingsWithInheritanceWarning(self): def settingsWithInheritanceWarning(self):
return self._settings_with_inheritance_warning return self._settings_with_inheritance_warning
@ -126,6 +128,10 @@ class SettingInheritanceManager(QObject):
if not self._active_container_stack.getProperty(key, "enabled"): if not self._active_container_stack.getProperty(key, "enabled"):
return False return False
## Also check if the top container is not a setting function (this happens if the inheritance is restored).
if isinstance(self._active_container_stack.getTop().getProperty(key, "value"), UM.Settings.SettingFunction):
return False
## Mash all containers for all the stacks together. ## Mash all containers for all the stacks together.
while stack: while stack:
containers.extend(stack.getContainers()) containers.extend(stack.getContainers())
@ -144,8 +150,7 @@ class SettingInheritanceManager(QObject):
if has_setting_function: if has_setting_function:
break # There is a setting function somewhere, stop looking deeper. break # There is a setting function somewhere, stop looking deeper.
## Also check if the top container is not a setting function (this happens if the inheritance is restored). return has_setting_function and has_non_function_value
return has_setting_function and not isinstance(self._active_container_stack.getTop().getProperty(key, "value"), UM.Settings.SettingFunction) and has_non_function_value
def _update(self): def _update(self):
self._settings_with_inheritance_warning = [] # Reset previous data. self._settings_with_inheritance_warning = [] # Reset previous data.

View File

@ -101,8 +101,9 @@ class SliceInfo(Extension):
print_information = Application.getInstance().getPrintInformation() print_information = Application.getInstance().getPrintInformation()
material_radius = 0.5 * global_container_stack.getProperty("material_diameter", "value") material_radius = 0.5 * global_container_stack.getProperty("material_diameter", "value")
# TODO: Send material per extruder instead of mashing it on a pile # Send material per extruder
material_used = math.pi * material_radius * material_radius * sum(print_information.materialLengths) #Volume of all materials used material_used = [str(math.pi * material_radius * material_radius * material_length) for material_length in print_information.materialLengths]
material_used = ",".join(material_used)
# Bundle the collected data # Bundle the collected data
submitted_data = { submitted_data = {
@ -139,4 +140,4 @@ class SliceInfo(Extension):
except Exception as e: except Exception as e:
# We really can't afford to have a mistake here, as this would break the sending of g-code to a device # We really can't afford to have a mistake here, as this would break the sending of g-code to a device
# (Either saving or directly to a printer). The functionality of the slice data is not *that* important. # (Either saving or directly to a printer). The functionality of the slice data is not *that* important.
Logger.log("e", "Exception raised while sending slice info: %s" %(repr(e))) # But we should be notified about these problems of course. Logger.log("e", "Exception raised while sending slice info: %s" %(repr(e))) # But we should be notified about these problems of course.