mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 21:19:01 +08:00
Merge branch 'master' of github.com:Ultimaker/Cura
This commit is contained in:
commit
24805b3883
@ -1,6 +1,6 @@
|
|||||||
# Copyright (c) 2017 Ultimaker B.V.
|
# Copyright (c) 2017 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the LGPLv3 or higher.
|
# Cura is released under the terms of the LGPLv3 or higher.
|
||||||
from typing import List
|
from typing import List, Optional, TYPE_CHECKING
|
||||||
|
|
||||||
from PyQt5.QtCore import QObject, QTimer, pyqtProperty, pyqtSignal
|
from PyQt5.QtCore import QObject, QTimer, pyqtProperty, pyqtSignal
|
||||||
from UM.FlameProfiler import pyqtSlot
|
from UM.FlameProfiler import pyqtSlot
|
||||||
@ -20,13 +20,18 @@ from UM.Settings.SettingInstance import InstanceState
|
|||||||
|
|
||||||
from cura.Settings.ExtruderManager import ExtruderManager
|
from cura.Settings.ExtruderManager import ExtruderManager
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
from cura.Settings.ExtruderStack import ExtruderStack
|
||||||
|
from UM.Settings.SettingDefinition import SettingDefinition
|
||||||
|
|
||||||
|
|
||||||
class SettingInheritanceManager(QObject):
|
class SettingInheritanceManager(QObject):
|
||||||
def __init__(self, parent = None):
|
def __init__(self, parent = None) -> None:
|
||||||
super().__init__(parent)
|
super().__init__(parent)
|
||||||
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerChanged)
|
||||||
self._global_container_stack = None
|
self._global_container_stack = None # type: Optional[ContainerStack]
|
||||||
self._settings_with_inheritance_warning = []
|
self._settings_with_inheritance_warning = [] # type: List[str]
|
||||||
self._active_container_stack = None
|
self._active_container_stack = None # type: Optional[ExtruderStack]
|
||||||
self._onGlobalContainerChanged()
|
self._onGlobalContainerChanged()
|
||||||
|
|
||||||
ExtruderManager.getInstance().activeExtruderChanged.connect(self._onActiveExtruderChanged)
|
ExtruderManager.getInstance().activeExtruderChanged.connect(self._onActiveExtruderChanged)
|
||||||
@ -41,7 +46,9 @@ class SettingInheritanceManager(QObject):
|
|||||||
|
|
||||||
## 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: str) -> List[str]:
|
||||||
|
if self._global_container_stack is None:
|
||||||
|
return []
|
||||||
definitions = self._global_container_stack.definition.findDefinitions(key=key)
|
definitions = self._global_container_stack.definition.findDefinitions(key=key)
|
||||||
if not definitions:
|
if not definitions:
|
||||||
Logger.log("w", "Could not find definition for key [%s]", key)
|
Logger.log("w", "Could not find definition for key [%s]", key)
|
||||||
@ -53,9 +60,11 @@ class SettingInheritanceManager(QObject):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@pyqtSlot(str, str, result = "QStringList")
|
@pyqtSlot(str, str, result = "QStringList")
|
||||||
def getOverridesForExtruder(self, key, extruder_index):
|
def getOverridesForExtruder(self, key: str, extruder_index: str) -> List[str]:
|
||||||
result = []
|
if self._global_container_stack is None:
|
||||||
|
return []
|
||||||
|
|
||||||
|
result = [] # type: List[str]
|
||||||
extruder_stack = ExtruderManager.getInstance().getExtruderStack(extruder_index)
|
extruder_stack = ExtruderManager.getInstance().getExtruderStack(extruder_index)
|
||||||
if not extruder_stack:
|
if not extruder_stack:
|
||||||
Logger.log("w", "Unable to find extruder for current machine with index %s", extruder_index)
|
Logger.log("w", "Unable to find extruder for current machine with index %s", extruder_index)
|
||||||
@ -73,16 +82,16 @@ class SettingInheritanceManager(QObject):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
@pyqtSlot(str)
|
@pyqtSlot(str)
|
||||||
def manualRemoveOverride(self, key):
|
def manualRemoveOverride(self, key: str) -> None:
|
||||||
if key in self._settings_with_inheritance_warning:
|
if key in self._settings_with_inheritance_warning:
|
||||||
self._settings_with_inheritance_warning.remove(key)
|
self._settings_with_inheritance_warning.remove(key)
|
||||||
self.settingsWithIntheritanceChanged.emit()
|
self.settingsWithIntheritanceChanged.emit()
|
||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def forceUpdate(self):
|
def forceUpdate(self) -> None:
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
def _onActiveExtruderChanged(self):
|
def _onActiveExtruderChanged(self) -> None:
|
||||||
new_active_stack = ExtruderManager.getInstance().getActiveExtruderStack()
|
new_active_stack = ExtruderManager.getInstance().getActiveExtruderStack()
|
||||||
if not new_active_stack:
|
if not new_active_stack:
|
||||||
self._active_container_stack = None
|
self._active_container_stack = None
|
||||||
@ -94,13 +103,14 @@ class SettingInheritanceManager(QObject):
|
|||||||
self._active_container_stack.containersChanged.disconnect(self._onContainersChanged)
|
self._active_container_stack.containersChanged.disconnect(self._onContainersChanged)
|
||||||
|
|
||||||
self._active_container_stack = new_active_stack
|
self._active_container_stack = new_active_stack
|
||||||
self._active_container_stack.propertyChanged.connect(self._onPropertyChanged)
|
if self._active_container_stack is not None:
|
||||||
self._active_container_stack.containersChanged.connect(self._onContainersChanged)
|
self._active_container_stack.propertyChanged.connect(self._onPropertyChanged)
|
||||||
|
self._active_container_stack.containersChanged.connect(self._onContainersChanged)
|
||||||
self._update() # Ensure that the settings_with_inheritance_warning list is populated.
|
self._update() # Ensure that the settings_with_inheritance_warning list is populated.
|
||||||
|
|
||||||
def _onPropertyChanged(self, key, property_name):
|
def _onPropertyChanged(self, key: str, property_name: str) -> None:
|
||||||
if (property_name == "value" or property_name == "enabled") and self._global_container_stack:
|
if (property_name == "value" or property_name == "enabled") and self._global_container_stack:
|
||||||
definitions = self._global_container_stack.definition.findDefinitions(key = key)
|
definitions = self._global_container_stack.definition.findDefinitions(key = key) # type: List["SettingDefinition"]
|
||||||
if not definitions:
|
if not definitions:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -139,7 +149,7 @@ class SettingInheritanceManager(QObject):
|
|||||||
if settings_with_inheritance_warning_changed:
|
if settings_with_inheritance_warning_changed:
|
||||||
self.settingsWithIntheritanceChanged.emit()
|
self.settingsWithIntheritanceChanged.emit()
|
||||||
|
|
||||||
def _recursiveCheck(self, definition):
|
def _recursiveCheck(self, definition: "SettingDefinition") -> bool:
|
||||||
for child in definition.children:
|
for child in definition.children:
|
||||||
if child.key in self._settings_with_inheritance_warning:
|
if child.key in self._settings_with_inheritance_warning:
|
||||||
return True
|
return True
|
||||||
@ -149,7 +159,7 @@ class SettingInheritanceManager(QObject):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
@pyqtProperty("QVariantList", notify = settingsWithIntheritanceChanged)
|
@pyqtProperty("QVariantList", notify = settingsWithIntheritanceChanged)
|
||||||
def settingsWithInheritanceWarning(self):
|
def settingsWithInheritanceWarning(self) -> List[str]:
|
||||||
return self._settings_with_inheritance_warning
|
return self._settings_with_inheritance_warning
|
||||||
|
|
||||||
## Check if a setting has an inheritance function that is overwritten
|
## Check if a setting has an inheritance function that is overwritten
|
||||||
@ -157,9 +167,14 @@ class SettingInheritanceManager(QObject):
|
|||||||
has_setting_function = False
|
has_setting_function = False
|
||||||
if not stack:
|
if not stack:
|
||||||
stack = self._active_container_stack
|
stack = self._active_container_stack
|
||||||
if not stack: #No active container stack yet!
|
if not stack: # No active container stack yet!
|
||||||
return False
|
return False
|
||||||
containers = [] # type: List[ContainerInterface]
|
|
||||||
|
if self._active_container_stack is None:
|
||||||
|
return False
|
||||||
|
all_keys = self._active_container_stack.getAllKeys()
|
||||||
|
|
||||||
|
containers = [] # type: List[ContainerInterface]
|
||||||
|
|
||||||
## Check if the setting has a user state. If not, it is never overwritten.
|
## Check if the setting has a user state. If not, it is never overwritten.
|
||||||
has_user_state = stack.getProperty(key, "state") == InstanceState.User
|
has_user_state = stack.getProperty(key, "state") == InstanceState.User
|
||||||
@ -190,8 +205,8 @@ class SettingInheritanceManager(QObject):
|
|||||||
has_setting_function = isinstance(value, SettingFunction)
|
has_setting_function = isinstance(value, SettingFunction)
|
||||||
if has_setting_function:
|
if has_setting_function:
|
||||||
for setting_key in value.getUsedSettingKeys():
|
for setting_key in value.getUsedSettingKeys():
|
||||||
if setting_key in self._active_container_stack.getAllKeys():
|
if setting_key in all_keys:
|
||||||
break # We found an actual setting. So has_setting_function can remain true
|
break # We found an actual setting. So has_setting_function can remain true
|
||||||
else:
|
else:
|
||||||
# All of the setting_keys turned out to not be setting keys at all!
|
# All of the setting_keys turned out to not be setting keys at all!
|
||||||
# This can happen due enum keys also being marked as settings.
|
# This can happen due enum keys also being marked as settings.
|
||||||
@ -205,7 +220,7 @@ class SettingInheritanceManager(QObject):
|
|||||||
break # There is a setting function somewhere, stop looking deeper.
|
break # There is a setting function somewhere, stop looking deeper.
|
||||||
return has_setting_function and has_non_function_value
|
return has_setting_function and has_non_function_value
|
||||||
|
|
||||||
def _update(self):
|
def _update(self) -> None:
|
||||||
self._settings_with_inheritance_warning = [] # Reset previous data.
|
self._settings_with_inheritance_warning = [] # Reset previous data.
|
||||||
|
|
||||||
# Make sure that the GlobalStack is not None. sometimes the globalContainerChanged signal gets here late.
|
# Make sure that the GlobalStack is not None. sometimes the globalContainerChanged signal gets here late.
|
||||||
@ -226,7 +241,7 @@ class SettingInheritanceManager(QObject):
|
|||||||
# Notify others that things have changed.
|
# Notify others that things have changed.
|
||||||
self.settingsWithIntheritanceChanged.emit()
|
self.settingsWithIntheritanceChanged.emit()
|
||||||
|
|
||||||
def _onGlobalContainerChanged(self):
|
def _onGlobalContainerChanged(self) -> None:
|
||||||
if self._global_container_stack:
|
if self._global_container_stack:
|
||||||
self._global_container_stack.propertyChanged.disconnect(self._onPropertyChanged)
|
self._global_container_stack.propertyChanged.disconnect(self._onPropertyChanged)
|
||||||
self._global_container_stack.containersChanged.disconnect(self._onContainersChanged)
|
self._global_container_stack.containersChanged.disconnect(self._onContainersChanged)
|
||||||
|
@ -3918,6 +3918,48 @@
|
|||||||
"settable_per_mesh": false,
|
"settable_per_mesh": false,
|
||||||
"settable_per_extruder": true
|
"settable_per_extruder": true
|
||||||
},
|
},
|
||||||
|
"support_brim_enable":
|
||||||
|
{
|
||||||
|
"label": "Enable Support Brim",
|
||||||
|
"description": "Generate a brim within the support infill regions of the first layer. This brim is printed underneath the support, not around it. Enabling this setting increases the adhesion of support to the build plate.",
|
||||||
|
"type": "bool",
|
||||||
|
"default_value": false,
|
||||||
|
"enabled": "support_enable or support_tree_enable",
|
||||||
|
"limit_to_extruder": "support_infill_extruder_nr",
|
||||||
|
"settable_per_mesh": false,
|
||||||
|
"settable_per_extruder": true
|
||||||
|
},
|
||||||
|
"support_brim_width":
|
||||||
|
{
|
||||||
|
"label": "Support Brim Width",
|
||||||
|
"description": "The width of the brim to print underneath the support. A larger brim enhances adhesion to the build plate, at the cost of some extra material.",
|
||||||
|
"type": "float",
|
||||||
|
"unit": "mm",
|
||||||
|
"default_value": 8.0,
|
||||||
|
"minimum_value": "0.0",
|
||||||
|
"maximum_value_warning": "50.0",
|
||||||
|
"enabled": "support_enable",
|
||||||
|
"settable_per_mesh": false,
|
||||||
|
"settable_per_extruder": true,
|
||||||
|
"limit_to_extruder": "support_infill_extruder_nr",
|
||||||
|
"children":
|
||||||
|
{
|
||||||
|
"support_brim_line_count":
|
||||||
|
{
|
||||||
|
"label": "Support Brim Line Count",
|
||||||
|
"description": "The number of lines used for the support brim. More brim lines enhance adhesion to the build plate, at the cost of some extra material.",
|
||||||
|
"type": "int",
|
||||||
|
"default_value": 20,
|
||||||
|
"minimum_value": "0",
|
||||||
|
"maximum_value_warning": "50 / skirt_brim_line_width",
|
||||||
|
"value": "math.ceil(support_brim_width / (skirt_brim_line_width * initial_layer_line_width_factor / 100.0))",
|
||||||
|
"enabled": "support_enable",
|
||||||
|
"settable_per_mesh": false,
|
||||||
|
"settable_per_extruder": true,
|
||||||
|
"limit_to_extruder": "support_infill_extruder_nr"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"support_z_distance":
|
"support_z_distance":
|
||||||
{
|
{
|
||||||
"label": "Support Z Distance",
|
"label": "Support Z Distance",
|
||||||
@ -4568,6 +4610,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"brim_replaces_support":
|
||||||
|
{
|
||||||
|
"label": "Brim Replaces Support",
|
||||||
|
"description": "Enforce brim to be printed around the model even if that space would otherwise be occupied by support. This replaces some regions of the first layer of support by brim regions.",
|
||||||
|
"type": "bool",
|
||||||
|
"default_value": true,
|
||||||
|
"enabled": "resolveOrValue('adhesion_type') == 'brim' and support_enable",
|
||||||
|
"settable_per_mesh": false,
|
||||||
|
"settable_per_extruder": true,
|
||||||
|
"limit_to_extruder": "adhesion_extruder_nr"
|
||||||
|
},
|
||||||
"brim_outside_only":
|
"brim_outside_only":
|
||||||
{
|
{
|
||||||
"label": "Brim Only on Outside",
|
"label": "Brim Only on Outside",
|
||||||
|
@ -86,7 +86,7 @@ Item {
|
|||||||
printJobTextfield.focus = false;
|
printJobTextfield.focus = false;
|
||||||
}
|
}
|
||||||
validator: RegExpValidator {
|
validator: RegExpValidator {
|
||||||
regExp: /^[^\\ \/ \*\?\|\[\]]*$/
|
regExp: /^[^\\\/\*\?\|\[\]]*$/
|
||||||
}
|
}
|
||||||
style: TextFieldStyle{
|
style: TextFieldStyle{
|
||||||
textColor: UM.Theme.getColor("text_scene");
|
textColor: UM.Theme.getColor("text_scene");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user