Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'cura/Settings/ExtruderStack.py')
-rw-r--r--cura/Settings/ExtruderStack.py80
1 files changed, 44 insertions, 36 deletions
diff --git a/cura/Settings/ExtruderStack.py b/cura/Settings/ExtruderStack.py
index 5d4b3e38b1..2a9838c671 100644
--- a/cura/Settings/ExtruderStack.py
+++ b/cura/Settings/ExtruderStack.py
@@ -22,10 +22,9 @@ if TYPE_CHECKING:
from cura.Settings.GlobalStack import GlobalStack
-## Represents an Extruder and its related containers.
-#
-#
class ExtruderStack(CuraContainerStack):
+ """Represents an Extruder and its related containers."""
+
def __init__(self, container_id: str) -> None:
super().__init__(container_id)
@@ -33,20 +32,21 @@ class ExtruderStack(CuraContainerStack):
self.propertiesChanged.connect(self._onPropertiesChanged)
+ self.setDirty(False)
+
enabledChanged = pyqtSignal()
- ## Overridden from ContainerStack
- #
- # This will set the next stack and ensure that we register this stack as an extruder.
@override(ContainerStack)
def setNextStack(self, stack: CuraContainerStack, connect_signals: bool = True) -> None:
+ """Overridden from ContainerStack
+
+ This will set the next stack and ensure that we register this stack as an extruder.
+ """
+
super().setNextStack(stack)
stack.addExtruder(self)
self.setMetaDataEntry("machine", stack.id)
- # For backward compatibility: Register the extruder with the Extruder Manager
- ExtruderManager.getInstance().registerExtruder(self, stack.id)
-
@override(ContainerStack)
def getNextStack(self) -> Optional["GlobalStack"]:
return super().getNextStack()
@@ -71,11 +71,13 @@ class ExtruderStack(CuraContainerStack):
compatibleMaterialDiameterChanged = pyqtSignal()
- ## Return the filament diameter that the machine requires.
- #
- # If the machine has no requirement for the diameter, -1 is returned.
- # \return The filament diameter for the printer
def getCompatibleMaterialDiameter(self) -> float:
+ """Return the filament diameter that the machine requires.
+
+ If the machine has no requirement for the diameter, -1 is returned.
+ :return: The filament diameter for the printer
+ """
+
context = PropertyEvaluationContext(self)
context.context["evaluate_from_container_index"] = _ContainerIndexes.Variant
@@ -97,41 +99,45 @@ class ExtruderStack(CuraContainerStack):
approximateMaterialDiameterChanged = pyqtSignal()
- ## Return the approximate filament diameter that the machine requires.
- #
- # The approximate material diameter is the material diameter rounded to
- # the nearest millimetre.
- #
- # If the machine has no requirement for the diameter, -1 is returned.
- #
- # \return The approximate filament diameter for the printer
def getApproximateMaterialDiameter(self) -> float:
+ """Return the approximate filament diameter that the machine requires.
+
+ The approximate material diameter is the material diameter rounded to
+ the nearest millimetre.
+
+ If the machine has no requirement for the diameter, -1 is returned.
+
+ :return: The approximate filament diameter for the printer
+ """
+
return round(self.getCompatibleMaterialDiameter())
approximateMaterialDiameter = pyqtProperty(float, fget = getApproximateMaterialDiameter,
notify = approximateMaterialDiameterChanged)
- ## Overridden from ContainerStack
- #
- # It will perform a few extra checks when trying to get properties.
- #
- # The two extra checks it currently does is to ensure a next stack is set and to bypass
- # the extruder when the property is not settable per extruder.
- #
- # \throws Exceptions.NoGlobalStackError Raised when trying to get a property from an extruder without
- # having a next stack set.
@override(ContainerStack)
def getProperty(self, key: str, property_name: str, context: Optional[PropertyEvaluationContext] = None) -> Any:
+ """Overridden from ContainerStack
+
+ It will perform a few extra checks when trying to get properties.
+
+ The two extra checks it currently does is to ensure a next stack is set and to bypass
+ the extruder when the property is not settable per extruder.
+
+ :throws Exceptions.NoGlobalStackError Raised when trying to get a property from an extruder without
+ having a next stack set.
+ """
+
if not self._next_stack:
raise Exceptions.NoGlobalStackError("Extruder {id} is missing the next stack!".format(id = self.id))
- if context is None:
- context = PropertyEvaluationContext()
- context.pushContainer(self)
+ if context:
+ context.pushContainer(self)
if not super().getProperty(key, "settable_per_extruder", context):
result = self.getNextStack().getProperty(key, property_name, context)
- context.popContainer()
+ if context:
+ context.popContainer()
return result
limit_to_extruder = super().getProperty(key, "limit_to_extruder", context)
@@ -144,13 +150,15 @@ class ExtruderStack(CuraContainerStack):
try:
result = self.getNextStack().extruderList[int(limit_to_extruder)].getProperty(key, property_name, context)
if result is not None:
- context.popContainer()
+ if context:
+ context.popContainer()
return result
except IndexError:
pass
result = super().getProperty(key, property_name, context)
- context.popContainer()
+ if context:
+ context.popContainer()
return result
@override(CuraContainerStack)