Fixes for custom FMD printer material diameter upgrade and storage - CURA-4835

This commit is contained in:
ChrisTerBeke 2018-01-22 17:18:09 +01:00
parent e17fbb0db2
commit 129f9cc16c
3 changed files with 97 additions and 76 deletions

View file

@ -3,6 +3,7 @@
from typing import Any, TYPE_CHECKING, Optional
from UM.Application import Application
from UM.Decorators import override
from UM.MimeTypeDatabase import MimeType, MimeTypeDatabase
from UM.Settings.ContainerStack import ContainerStack
@ -60,6 +61,12 @@ class ExtruderStack(CuraContainerStack):
for key in keys_to_copy:
# Since material_diameter is not on the extruder definition, we need to add it here
# WARNING: this might be very dangerous and should be refactored ASAP!
definition = stack.getSettingDefinition(key)
if definition:
self.definition.addDefinition(definition)
# Only copy the value when this extruder doesn't have the value.
if self.definitionChanges.hasProperty(key, "value"):
continue
@ -75,6 +82,11 @@ class ExtruderStack(CuraContainerStack):
self.definitionChanges.addInstance(new_instance)
self.definitionChanges.setDirty(True)
# Make sure the material diameter is up to date for the extruder stack.
if key == "material_diameter":
position = self.getMetaDataEntry("position", "0")
Application.getInstance().getExtruderManager().updateMaterialForDiameter(position)
# 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