Fix material_diameter copy over for Extruders

CURA-4835
This commit is contained in:
Lipu Fei 2018-01-19 12:30:04 +01:00
parent c7071c18dd
commit 7c85db4a18
2 changed files with 35 additions and 15 deletions

View file

@ -407,6 +407,12 @@ class ExtruderManager(QObject):
extruder_train.setNextStack(global_stack)
extruders_changed = True
# FIX: We have to remove those settings here because we know that those values have been copied to all
# the extruders at this point.
for key in ("material_diameter", "machine_nozzle_size"):
if global_stack.definitionChanges.hasProperty(key, "value"):
global_stack.definitionChanges.removeInstance(key, postpone_emit = True)
if extruders_changed:
self.extrudersChanged.emit(global_stack_id)
self.extrudersAdded.emit()

View file

@ -18,10 +18,6 @@ if TYPE_CHECKING:
from cura.Settings.GlobalStack import GlobalStack
_EXTRUDER_SPECIFIC_DEFINITION_CHANGES_SETTINGS = ["machine_nozzle_size",
"material_diameter"]
## Represents an Extruder and its related containers.
#
#
@ -53,8 +49,21 @@ class ExtruderStack(CuraContainerStack):
# when we are upgrading a definition_changes container file, there is NO guarantee that other files such as
# machine an extruder stack files are upgraded before this, so we cannot read those files assuming they are in
# the latest format.
#
# MORE:
# For single-extrusion machines, nozzle size is saved in the global stack, so the nozzle size value should be
# carried to the first extruder.
# For material diameter, it was supposed to be applied to all extruders, so its value should be copied to all
# extruders.
#
keys_to_copy = ["material_diameter"] # material diameter will be copied to all extruders
if self.getMetaDataEntry("position") == "0":
for key in _EXTRUDER_SPECIFIC_DEFINITION_CHANGES_SETTINGS:
keys_to_copy.append("machine_nozzle_size")
for key in keys_to_copy:
# Only copy the value when this extruder doesn't have the value.
if self.definitionChanges.hasProperty(key, "value"):
continue
setting_value = stack.definitionChanges.getProperty(key, "value")
if setting_value is None:
continue
@ -66,7 +75,12 @@ class ExtruderStack(CuraContainerStack):
self.definitionChanges.addInstance(new_instance)
self.definitionChanges.setDirty(True)
stack.definitionChanges.removeInstance(key, postpone_emit = True)
# NOTE: We cannot remove the setting from the global stack's definition changes container because for
# material diameter, it needs to be applied to all extruders, but here we don't know how many extruders
# a machine actually has and how many extruders has already been loaded for that machine, so we have to
# keep this setting for any remaining extruders that haven't been loaded yet.
#
# Those settings will be removed in ExtruderManager which knows all those info.
@override(ContainerStack)
def getNextStack(self) -> Optional["GlobalStack"]: