mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-08-03 20:13:56 -06:00
Fix material update upon extruder-compatible diameter change
CURA-5834 Material models and the material container on an extruder need to be updated when the extruder's compatible diameter gets changes.
This commit is contained in:
parent
ea10d5e608
commit
97e6354c13
6 changed files with 59 additions and 20 deletions
|
@ -365,7 +365,7 @@ class MaterialManager(QObject):
|
||||||
nozzle_name = None
|
nozzle_name = None
|
||||||
if extruder_stack.variant.getId() != "empty_variant":
|
if extruder_stack.variant.getId() != "empty_variant":
|
||||||
nozzle_name = extruder_stack.variant.getName()
|
nozzle_name = extruder_stack.variant.getName()
|
||||||
diameter = extruder_stack.approximateMaterialDiameter
|
diameter = extruder_stack.getApproximateMaterialDiameter()
|
||||||
|
|
||||||
# Fetch the available materials (ContainerNode) for the current active machine and extruder setup.
|
# Fetch the available materials (ContainerNode) for the current active machine and extruder setup.
|
||||||
return self.getAvailableMaterials(machine.definition, nozzle_name, buildplate_name, diameter)
|
return self.getAvailableMaterials(machine.definition, nozzle_name, buildplate_name, diameter)
|
||||||
|
@ -478,12 +478,22 @@ class MaterialManager(QObject):
|
||||||
|
|
||||||
buildplate_name = global_stack.getBuildplateName()
|
buildplate_name = global_stack.getBuildplateName()
|
||||||
machine_definition = global_stack.definition
|
machine_definition = global_stack.definition
|
||||||
if extruder_definition is None:
|
|
||||||
extruder_definition = global_stack.extruders[position].definition
|
|
||||||
|
|
||||||
if extruder_definition and parseBool(global_stack.getMetaDataEntry("has_materials", False)):
|
# The extruder-compatible material diameter in the extruder definition may not be the correct value because
|
||||||
# At this point the extruder_definition is not None
|
# the user can change it in the definition_changes container.
|
||||||
material_diameter = extruder_definition.getProperty("material_diameter", "value")
|
if extruder_definition is None:
|
||||||
|
extruder_stack_or_definition = global_stack.extruders[position]
|
||||||
|
is_extruder_stack = True
|
||||||
|
else:
|
||||||
|
extruder_stack_or_definition = extruder_definition
|
||||||
|
is_extruder_stack = False
|
||||||
|
|
||||||
|
if extruder_stack_or_definition and parseBool(global_stack.getMetaDataEntry("has_materials", False)):
|
||||||
|
if is_extruder_stack:
|
||||||
|
material_diameter = extruder_stack_or_definition.getComptabileMaterialDiameter()
|
||||||
|
else:
|
||||||
|
material_diameter = extruder_stack_or_definition.getProperty("material_diameter", "value")
|
||||||
|
|
||||||
if isinstance(material_diameter, SettingFunction):
|
if isinstance(material_diameter, SettingFunction):
|
||||||
material_diameter = material_diameter(global_stack)
|
material_diameter = material_diameter(global_stack)
|
||||||
approximate_material_diameter = str(round(material_diameter))
|
approximate_material_diameter = str(round(material_diameter))
|
||||||
|
|
|
@ -64,9 +64,11 @@ class BaseMaterialsModel(ListModel):
|
||||||
|
|
||||||
if self._extruder_stack is not None:
|
if self._extruder_stack is not None:
|
||||||
self._extruder_stack.pyqtContainersChanged.disconnect(self._update)
|
self._extruder_stack.pyqtContainersChanged.disconnect(self._update)
|
||||||
|
self._extruder_stack.approximateMaterialDiameterChanged.disconnect(self._update)
|
||||||
self._extruder_stack = global_stack.extruders.get(str(self._extruder_position))
|
self._extruder_stack = global_stack.extruders.get(str(self._extruder_position))
|
||||||
if self._extruder_stack is not None:
|
if self._extruder_stack is not None:
|
||||||
self._extruder_stack.pyqtContainersChanged.connect(self._update)
|
self._extruder_stack.pyqtContainersChanged.connect(self._update)
|
||||||
|
self._extruder_stack.approximateMaterialDiameterChanged.connect(self._update)
|
||||||
# Force update the model when the extruder stack changes
|
# Force update the model when the extruder stack changes
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ class CuraStackBuilder:
|
||||||
|
|
||||||
# get material container for extruders
|
# get material container for extruders
|
||||||
material_container = application.empty_material_container
|
material_container = application.empty_material_container
|
||||||
material_node = material_manager.getDefaultMaterial(global_stack, extruder_position, extruder_variant_name,
|
material_node = material_manager.getDefaultMaterial(global_stack, str(extruder_position), extruder_variant_name,
|
||||||
extruder_definition = extruder_definition)
|
extruder_definition = extruder_definition)
|
||||||
if material_node and material_node.getContainer():
|
if material_node and material_node.getContainer():
|
||||||
material_container = material_node.getContainer()
|
material_container = material_node.getContainer()
|
||||||
|
|
|
@ -65,16 +65,33 @@ class ExtruderStack(CuraContainerStack):
|
||||||
def getLoadingPriority(cls) -> int:
|
def getLoadingPriority(cls) -> int:
|
||||||
return 3
|
return 3
|
||||||
|
|
||||||
|
compatibleMaterialDiameterChanged = pyqtSignal()
|
||||||
|
|
||||||
## Return the filament diameter that the machine requires.
|
## Return the filament diameter that the machine requires.
|
||||||
#
|
#
|
||||||
# If the machine has no requirement for the diameter, -1 is returned.
|
# If the machine has no requirement for the diameter, -1 is returned.
|
||||||
# \return The filament diameter for the printer
|
# \return The filament diameter for the printer
|
||||||
@property
|
def getComptabileMaterialDiameter(self) -> float:
|
||||||
def comptabileMaterialDiameter(self) -> float:
|
|
||||||
context = PropertyEvaluationContext(self)
|
context = PropertyEvaluationContext(self)
|
||||||
context.context["evaluate_from_container_index"] = _ContainerIndexes.Variant
|
context.context["evaluate_from_container_index"] = _ContainerIndexes.Variant
|
||||||
|
|
||||||
return self.getProperty("material_diameter", "value", context = context)
|
return float(self.getProperty("material_diameter", "value", context = context))
|
||||||
|
|
||||||
|
def setCompatibleMaterialDiameter(self, value: float) -> None:
|
||||||
|
old_approximate_diameter = self.getApproximateMaterialDiameter()
|
||||||
|
if self.getComptabileMaterialDiameter() != value:
|
||||||
|
self.definitionChanges.setProperty("material_diameter", "value", value)
|
||||||
|
self.compatibleMaterialDiameterChanged.emit()
|
||||||
|
|
||||||
|
# Emit approximate diameter changed signal if needed
|
||||||
|
if old_approximate_diameter != self.getApproximateMaterialDiameter():
|
||||||
|
self.approximateMaterialDiameterChanged.emit()
|
||||||
|
|
||||||
|
compatibleMaterialDiameter = pyqtProperty(float, fset = setCompatibleMaterialDiameter,
|
||||||
|
fget = getComptabileMaterialDiameter,
|
||||||
|
notify = compatibleMaterialDiameterChanged)
|
||||||
|
|
||||||
|
approximateMaterialDiameterChanged = pyqtSignal()
|
||||||
|
|
||||||
## Return the approximate filament diameter that the machine requires.
|
## Return the approximate filament diameter that the machine requires.
|
||||||
#
|
#
|
||||||
|
@ -84,9 +101,11 @@ class ExtruderStack(CuraContainerStack):
|
||||||
# If the machine has no requirement for the diameter, -1 is returned.
|
# If the machine has no requirement for the diameter, -1 is returned.
|
||||||
#
|
#
|
||||||
# \return The approximate filament diameter for the printer
|
# \return The approximate filament diameter for the printer
|
||||||
@pyqtProperty(float)
|
def getApproximateMaterialDiameter(self) -> float:
|
||||||
def approximateMaterialDiameter(self) -> float:
|
return round(self.getComptabileMaterialDiameter())
|
||||||
return round(float(self.comptabileMaterialDiameter))
|
|
||||||
|
approximateMaterialDiameter = pyqtProperty(float, fget = getApproximateMaterialDiameter,
|
||||||
|
notify = approximateMaterialDiameterChanged)
|
||||||
|
|
||||||
## Overridden from ContainerStack
|
## Overridden from ContainerStack
|
||||||
#
|
#
|
||||||
|
|
|
@ -1276,11 +1276,7 @@ class MachineManager(QObject):
|
||||||
if extruder.variant.getId() != self._empty_variant_container.getId():
|
if extruder.variant.getId() != self._empty_variant_container.getId():
|
||||||
current_nozzle_name = extruder.variant.getMetaDataEntry("name")
|
current_nozzle_name = extruder.variant.getMetaDataEntry("name")
|
||||||
|
|
||||||
from UM.Settings.Interfaces import PropertyEvaluationContext
|
material_diameter = extruder.getComptabileMaterialDiameter()
|
||||||
from cura.Settings.CuraContainerStack import _ContainerIndexes
|
|
||||||
context = PropertyEvaluationContext(extruder)
|
|
||||||
context.context["evaluate_from_container_index"] = _ContainerIndexes.DefinitionChanges
|
|
||||||
material_diameter = extruder.getProperty("material_diameter", "value", context)
|
|
||||||
candidate_materials = self._material_manager.getAvailableMaterials(
|
candidate_materials = self._material_manager.getAvailableMaterials(
|
||||||
self._global_container_stack.definition,
|
self._global_container_stack.definition,
|
||||||
current_nozzle_name,
|
current_nozzle_name,
|
||||||
|
@ -1415,7 +1411,7 @@ class MachineManager(QObject):
|
||||||
position = str(position)
|
position = str(position)
|
||||||
extruder_stack = self._global_container_stack.extruders[position]
|
extruder_stack = self._global_container_stack.extruders[position]
|
||||||
nozzle_name = extruder_stack.variant.getName()
|
nozzle_name = extruder_stack.variant.getName()
|
||||||
material_diameter = extruder_stack.approximateMaterialDiameter
|
material_diameter = extruder_stack.getApproximateMaterialDiameter()
|
||||||
material_node = self._material_manager.getMaterialNode(machine_definition_id, nozzle_name, buildplate_name,
|
material_node = self._material_manager.getMaterialNode(machine_definition_id, nozzle_name, buildplate_name,
|
||||||
material_diameter, root_material_id)
|
material_diameter, root_material_id)
|
||||||
self.setMaterial(position, material_node)
|
self.setMaterial(position, material_node)
|
||||||
|
|
|
@ -408,6 +408,10 @@ Cura.MachineAction
|
||||||
manager.updateMaterialForDiameter(settingsTabs.currentIndex - 1);
|
manager.updateMaterialForDiameter(settingsTabs.currentIndex - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function setValueFunction(value)
|
||||||
|
{
|
||||||
|
Cura.MachineManager.activeStack.compatibleMaterialDiameter = value;
|
||||||
|
}
|
||||||
property bool isExtruderSetting: true
|
property bool isExtruderSetting: true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,6 +568,7 @@ Cura.MachineAction
|
||||||
property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false : forceUpdateOnChange
|
property bool _forceUpdateOnChange: (typeof(forceUpdateOnChange) === 'undefined') ? false : forceUpdateOnChange
|
||||||
property string _label: (typeof(label) === 'undefined') ? "" : label
|
property string _label: (typeof(label) === 'undefined') ? "" : label
|
||||||
property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
|
property string _tooltip: (typeof(tooltip) === 'undefined') ? propertyProvider.properties.description : tooltip
|
||||||
|
property var _setValueFunction: (typeof(setValueFunction) === 'undefined') ? undefined : setValueFunction
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
{
|
{
|
||||||
|
@ -616,7 +621,14 @@ Cura.MachineAction
|
||||||
{
|
{
|
||||||
if (propertyProvider && text != propertyProvider.properties.value)
|
if (propertyProvider && text != propertyProvider.properties.value)
|
||||||
{
|
{
|
||||||
propertyProvider.setPropertyValue("value", text);
|
if (_setValueFunction !== undefined)
|
||||||
|
{
|
||||||
|
_setValueFunction(text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
propertyProvider.setPropertyValue("value", text);
|
||||||
|
}
|
||||||
if(_forceUpdateOnChange)
|
if(_forceUpdateOnChange)
|
||||||
{
|
{
|
||||||
manager.forceUpdate();
|
manager.forceUpdate();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue