Fix quality_changes for single-extrusion machines

CURA-4839

- Add newly created quality_changes container to ContainerRegistry
- If an extruder is created by CuraContainerRegistry, in project
  loading, do not try to override extruder's quality changes.
This commit is contained in:
Lipu Fei 2018-01-19 15:05:05 +01:00
parent e7a19bcce5
commit b92ebadfd0
2 changed files with 25 additions and 19 deletions

View file

@ -562,8 +562,8 @@ class CuraContainerRegistry(ContainerRegistry):
extruder_stack.setQualityChangesById(quality_changes_id) extruder_stack.setQualityChangesById(quality_changes_id)
else: else:
# if we still cannot find a quality changes container for the extruder, create a new one # if we still cannot find a quality changes container for the extruder, create a new one
container_id = self.uniqueName(extruder_stack.getId() + "_user")
container_name = machine.qualityChanges.getName() container_name = machine.qualityChanges.getName()
container_id = self.uniqueName(extruder_stack.getId() + "_qc_" + container_name)
extruder_quality_changes_container = InstanceContainer(container_id) extruder_quality_changes_container = InstanceContainer(container_id)
extruder_quality_changes_container.setName(container_name) extruder_quality_changes_container.setName(container_name)
extruder_quality_changes_container.addMetaDataEntry("type", "quality_changes") extruder_quality_changes_container.addMetaDataEntry("type", "quality_changes")
@ -572,6 +572,9 @@ class CuraContainerRegistry(ContainerRegistry):
extruder_quality_changes_container.addMetaDataEntry("quality_type", machine.qualityChanges.getMetaDataEntry("quality_type")) extruder_quality_changes_container.addMetaDataEntry("quality_type", machine.qualityChanges.getMetaDataEntry("quality_type"))
extruder_quality_changes_container.setDefinition(machine.qualityChanges.getDefinition().getId()) extruder_quality_changes_container.setDefinition(machine.qualityChanges.getDefinition().getId())
self.addContainer(extruder_quality_changes_container)
extruder_stack.qualityChanges = extruder_quality_changes_container
if not extruder_quality_changes_container: if not extruder_quality_changes_container:
Logger.log("w", "Could not find quality_changes named [%s] for extruder [%s]", Logger.log("w", "Could not find quality_changes named [%s] for extruder [%s]",
machine.qualityChanges.getName(), extruder_stack.getId()) machine.qualityChanges.getName(), extruder_stack.getId())

View file

@ -703,6 +703,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
return return
# load extruder stack files # load extruder stack files
has_extruder_stack_files = len(extruder_stack_files) > 0
try: try:
for extruder_stack_file in extruder_stack_files: for extruder_stack_file in extruder_stack_files:
container_id = self._stripFileToId(extruder_stack_file) container_id = self._stripFileToId(extruder_stack_file)
@ -946,6 +947,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
continue continue
# Replace the quality/definition changes container if it's in one of the ExtruderStacks # Replace the quality/definition changes container if it's in one of the ExtruderStacks
# Only apply the change if we have loaded extruder stacks from the project
if has_extruder_stack_files:
for each_extruder_stack in extruder_stacks: for each_extruder_stack in extruder_stacks:
changes_container = None changes_container = None
if changes_container_type == "quality_changes": if changes_container_type == "quality_changes":