diff options
author | Arjen Hiemstra <ahiemstra@heimr.nl> | 2016-10-24 18:04:30 +0300 |
---|---|---|
committer | Arjen Hiemstra <ahiemstra@heimr.nl> | 2016-10-24 18:10:26 +0300 |
commit | bdaa4a5a6dde66f152d2012625ca42fb881a7058 (patch) | |
tree | 7b6b6dc6b62d370e41b857241b983d59a46ac89a /cura | |
parent | b718109f72d0229d0c2a01eb1e5e135e820c7fb5 (diff) |
Add a method to get overrides for a specified (extruder)stack
Since the main getOverrides method only accounts for the active extruder
and we sometimes need to check other extruders in case of
limit_to_extruder.
Contributes to CURA-2752
Diffstat (limited to 'cura')
-rw-r--r-- | cura/Settings/SettingInheritanceManager.py | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/cura/Settings/SettingInheritanceManager.py b/cura/Settings/SettingInheritanceManager.py index b110febd87..68891c7f4f 100644 --- a/cura/Settings/SettingInheritanceManager.py +++ b/cura/Settings/SettingInheritanceManager.py @@ -38,6 +38,22 @@ class SettingInheritanceManager(QObject): result.append(key) return result + @pyqtSlot(str, str, result = "QStringList") + def getOverridesForExtruder(self, key, extruder): + extruder = cura.Settings.ExtruderManager.getInstance().getExtruderStack(extruder) + if not extruder: + return [] + + definitions = self._global_container_stack.getBottom().findDefinitions(key=key) + if not definitions: + return + result = [] + for key in definitions[0].getAllKeys(): + if self._settingIsOverwritingInheritance(key, extruder): + result.append(key) + + return result + @pyqtSlot(str) def manualRemoveOverride(self, key): if key in self._settings_with_inheritance_warning: @@ -115,22 +131,23 @@ class SettingInheritanceManager(QObject): return self._settings_with_inheritance_warning ## Check if a setting has an inheritance function that is overwritten - def _settingIsOverwritingInheritance(self, key): + def _settingIsOverwritingInheritance(self, key, stack = None): has_setting_function = False - stack = self._active_container_stack + if not stack: + stack = self._active_container_stack containers = [] ## Check if the setting has a user state. If not, it is never overwritten. - has_user_state = self._active_container_stack.getProperty(key, "state") == UM.Settings.InstanceState.User + has_user_state = stack.getProperty(key, "state") == UM.Settings.InstanceState.User if not has_user_state: return False ## If a setting is not enabled, don't label it as overwritten (It's never visible anyway). - if not self._active_container_stack.getProperty(key, "enabled"): + if not stack.getProperty(key, "enabled"): 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): + if isinstance(stack.getTop().getProperty(key, "value"), UM.Settings.SettingFunction): return False ## Mash all containers for all the stacks together. @@ -186,4 +203,4 @@ class SettingInheritanceManager(QObject): @staticmethod def createSettingInheritanceManager(engine=None, script_engine=None): - return SettingInheritanceManager()
\ No newline at end of file + return SettingInheritanceManager() |