mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-07-06 07:45:11 +08:00
Store intent category in metadata of quality_changes as well
This is necessary in order to restore it properly. Contributes to issue CURA_6600.
This commit is contained in:
parent
f6089ed627
commit
2b96543cd3
@ -167,9 +167,11 @@ class QualityManagementModel(ListModel):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
extruder_stack = None
|
extruder_stack = None
|
||||||
|
intent_category = None
|
||||||
if stack.getMetaDataEntry("position") is not None:
|
if stack.getMetaDataEntry("position") is not None:
|
||||||
extruder_stack = stack
|
extruder_stack = stack
|
||||||
new_changes = self._createQualityChanges(quality_container.getMetaDataEntry("quality_type"), unique_name, global_stack, extruder_stack)
|
intent_category = stack.intent.getMetaDataEntry("intent_category")
|
||||||
|
new_changes = self._createQualityChanges(quality_container.getMetaDataEntry("quality_type"), intent_category, unique_name, global_stack, extruder_stack)
|
||||||
container_manager._performMerge(new_changes, quality_changes_container, clear_settings = False)
|
container_manager._performMerge(new_changes, quality_changes_container, clear_settings = False)
|
||||||
container_manager._performMerge(new_changes, stack.userChanges)
|
container_manager._performMerge(new_changes, stack.userChanges)
|
||||||
|
|
||||||
@ -177,11 +179,12 @@ class QualityManagementModel(ListModel):
|
|||||||
|
|
||||||
## Create a quality changes container with the given set-up.
|
## Create a quality changes container with the given set-up.
|
||||||
# \param quality_type The quality type of the new container.
|
# \param quality_type The quality type of the new container.
|
||||||
|
# \param intent_category The intent category of the new container.
|
||||||
# \param new_name The name of the container. This name must be unique.
|
# \param new_name The name of the container. This name must be unique.
|
||||||
# \param machine The global stack to create the profile for.
|
# \param machine The global stack to create the profile for.
|
||||||
# \param extruder_stack The extruder stack to create the profile for. If
|
# \param extruder_stack The extruder stack to create the profile for. If
|
||||||
# not provided, only a global container will be created.
|
# not provided, only a global container will be created.
|
||||||
def _createQualityChanges(self, quality_type: str, new_name: str, machine: "GlobalStack", extruder_stack: Optional["ExtruderStack"]) -> "InstanceContainer":
|
def _createQualityChanges(self, quality_type: str, intent_category: Optional[str], new_name: str, machine: "GlobalStack", extruder_stack: Optional["ExtruderStack"]) -> "InstanceContainer":
|
||||||
container_registry = cura.CuraApplication.CuraApplication.getInstance().getContainerRegistry()
|
container_registry = cura.CuraApplication.CuraApplication.getInstance().getContainerRegistry()
|
||||||
base_id = machine.definition.getId() if extruder_stack is None else extruder_stack.getId()
|
base_id = machine.definition.getId() if extruder_stack is None else extruder_stack.getId()
|
||||||
new_id = base_id + "_" + new_name
|
new_id = base_id + "_" + new_name
|
||||||
@ -193,6 +196,8 @@ class QualityManagementModel(ListModel):
|
|||||||
quality_changes.setName(new_name)
|
quality_changes.setName(new_name)
|
||||||
quality_changes.setMetaDataEntry("type", "quality_changes")
|
quality_changes.setMetaDataEntry("type", "quality_changes")
|
||||||
quality_changes.setMetaDataEntry("quality_type", quality_type)
|
quality_changes.setMetaDataEntry("quality_type", quality_type)
|
||||||
|
if intent_category is not None:
|
||||||
|
quality_changes.setMetaDataEntry("intent_category", intent_category)
|
||||||
|
|
||||||
# If we are creating a container for an extruder, ensure we add that to the container.
|
# If we are creating a container for an extruder, ensure we add that to the container.
|
||||||
if extruder_stack is not None:
|
if extruder_stack is not None:
|
||||||
|
@ -294,7 +294,9 @@ class ContainerManager(QObject):
|
|||||||
quality_changes.setName(current_quality_changes_name)
|
quality_changes.setName(current_quality_changes_name)
|
||||||
quality_changes.setMetaDataEntry("type", "quality_changes")
|
quality_changes.setMetaDataEntry("type", "quality_changes")
|
||||||
quality_changes.setMetaDataEntry("quality_type", current_quality_type)
|
quality_changes.setMetaDataEntry("quality_type", current_quality_type)
|
||||||
quality_changes.setMetaDataEntry("position", stack.getMetaDataEntry("position"))
|
if stack.getMetaDataEntry("position") is not None: # Extruder stacks.
|
||||||
|
quality_changes.setMetaDataEntry("position", stack.getMetaDataEntry("position"))
|
||||||
|
quality_changes.setMetaDataEntry("intent_category", stack.quality.getMetaDataEntry("intent_category", "default"))
|
||||||
quality_changes.setMetaDataEntry("setting_version", application.SettingVersion)
|
quality_changes.setMetaDataEntry("setting_version", application.SettingVersion)
|
||||||
quality_changes.setDefinition(machine_definition_id)
|
quality_changes.setDefinition(machine_definition_id)
|
||||||
container_registry.addContainer(quality_changes)
|
container_registry.addContainer(quality_changes)
|
||||||
|
@ -269,7 +269,6 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
profile.setMetaDataEntry("type", "quality_changes")
|
profile.setMetaDataEntry("type", "quality_changes")
|
||||||
profile.setMetaDataEntry("definition", expected_machine_definition)
|
profile.setMetaDataEntry("definition", expected_machine_definition)
|
||||||
profile.setMetaDataEntry("quality_type", quality_type)
|
profile.setMetaDataEntry("quality_type", quality_type)
|
||||||
profile.setMetaDataEntry("position", "0")
|
|
||||||
profile.setDirty(True)
|
profile.setDirty(True)
|
||||||
if idx == 0:
|
if idx == 0:
|
||||||
# Move all per-extruder settings to the first extruder's quality_changes
|
# Move all per-extruder settings to the first extruder's quality_changes
|
||||||
@ -609,6 +608,7 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
extruder_quality_changes_container.setMetaDataEntry("setting_version", application.SettingVersion)
|
extruder_quality_changes_container.setMetaDataEntry("setting_version", application.SettingVersion)
|
||||||
extruder_quality_changes_container.setMetaDataEntry("position", extruder_definition.getMetaDataEntry("position"))
|
extruder_quality_changes_container.setMetaDataEntry("position", extruder_definition.getMetaDataEntry("position"))
|
||||||
extruder_quality_changes_container.setMetaDataEntry("quality_type", machine_quality_changes.getMetaDataEntry("quality_type"))
|
extruder_quality_changes_container.setMetaDataEntry("quality_type", machine_quality_changes.getMetaDataEntry("quality_type"))
|
||||||
|
extruder_quality_changes_container.setMetaDataEntry("intent_category", "default") # Intent categories weren't a thing back then.
|
||||||
extruder_quality_changes_container.setDefinition(machine_quality_changes.getDefinition().getId())
|
extruder_quality_changes_container.setDefinition(machine_quality_changes.getDefinition().getId())
|
||||||
|
|
||||||
self.addContainer(extruder_quality_changes_container)
|
self.addContainer(extruder_quality_changes_container)
|
||||||
|
@ -41,6 +41,7 @@ empty_quality_changes_container = copy.deepcopy(empty_container)
|
|||||||
empty_quality_changes_container.setMetaDataEntry("id", EMPTY_QUALITY_CHANGES_CONTAINER_ID)
|
empty_quality_changes_container.setMetaDataEntry("id", EMPTY_QUALITY_CHANGES_CONTAINER_ID)
|
||||||
empty_quality_changes_container.setMetaDataEntry("type", "quality_changes")
|
empty_quality_changes_container.setMetaDataEntry("type", "quality_changes")
|
||||||
empty_quality_changes_container.setMetaDataEntry("quality_type", "not_supported")
|
empty_quality_changes_container.setMetaDataEntry("quality_type", "not_supported")
|
||||||
|
empty_quality_changes_container.setMetaDataEntry("intent_category", "not_supported")
|
||||||
|
|
||||||
# Empty intent
|
# Empty intent
|
||||||
EMPTY_INTENT_CONTAINER_ID = "empty_intent"
|
EMPTY_INTENT_CONTAINER_ID = "empty_intent"
|
||||||
|
@ -760,6 +760,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
|
|
||||||
quality_changes_info = self._machine_info.quality_changes_info
|
quality_changes_info = self._machine_info.quality_changes_info
|
||||||
quality_changes_quality_type = quality_changes_info.global_info.parser["metadata"]["quality_type"]
|
quality_changes_quality_type = quality_changes_info.global_info.parser["metadata"]["quality_type"]
|
||||||
|
quality_changes_intent_category_per_extruder = {position: info.parser["metadata"].get("intent_category", "default") for position, info in quality_changes_info.extruder_info_dict.items()}
|
||||||
|
|
||||||
quality_changes_name = quality_changes_info.name
|
quality_changes_name = quality_changes_info.name
|
||||||
create_new = self._resolve_strategies.get("quality_changes") != "override"
|
create_new = self._resolve_strategies.get("quality_changes") != "override"
|
||||||
@ -770,9 +771,11 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
quality_changes_name = self._container_registry.uniqueName(quality_changes_name)
|
quality_changes_name = self._container_registry.uniqueName(quality_changes_name)
|
||||||
for position, container_info in container_info_dict.items():
|
for position, container_info in container_info_dict.items():
|
||||||
extruder_stack = None
|
extruder_stack = None
|
||||||
|
intent_category = None # type: Optional[str]
|
||||||
if position is not None:
|
if position is not None:
|
||||||
extruder_stack = global_stack.extruders[position]
|
extruder_stack = global_stack.extruders[position]
|
||||||
container = self._createNewQualityChanges(quality_changes_quality_type, quality_changes_name, global_stack, extruder_stack)
|
intent_category = quality_changes_intent_category_per_extruder[position]
|
||||||
|
container = self._createNewQualityChanges(quality_changes_quality_type, intent_category, quality_changes_name, global_stack, extruder_stack)
|
||||||
container_info.container = container
|
container_info.container = container
|
||||||
self._container_registry.addContainer(container)
|
self._container_registry.addContainer(container)
|
||||||
|
|
||||||
@ -801,8 +804,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
if not global_stack.extruders:
|
if not global_stack.extruders:
|
||||||
ExtruderManager.getInstance().fixSingleExtrusionMachineExtruderDefinition(global_stack)
|
ExtruderManager.getInstance().fixSingleExtrusionMachineExtruderDefinition(global_stack)
|
||||||
extruder_stack = global_stack.extruders["0"]
|
extruder_stack = global_stack.extruders["0"]
|
||||||
|
intent_category = quality_changes_intent_category_per_extruder["0"]
|
||||||
|
|
||||||
container = self._createNewQualityChanges(quality_changes_quality_type, quality_changes_name, global_stack, extruder_stack)
|
container = self._createNewQualityChanges(quality_changes_quality_type, intent_category, quality_changes_name, global_stack, extruder_stack)
|
||||||
container_info.container = container
|
container_info.container = container
|
||||||
self._container_registry.addContainer(container)
|
self._container_registry.addContainer(container)
|
||||||
|
|
||||||
@ -829,7 +833,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
|
|
||||||
if container_info.container is None:
|
if container_info.container is None:
|
||||||
extruder_stack = global_stack.extruders[position]
|
extruder_stack = global_stack.extruders[position]
|
||||||
container = self._createNewQualityChanges(quality_changes_quality_type, quality_changes_name, global_stack, extruder_stack)
|
intent_category = quality_changes_intent_category_per_extruder[position]
|
||||||
|
container = self._createNewQualityChanges(quality_changes_quality_type, intent_category, quality_changes_name, global_stack, extruder_stack)
|
||||||
container_info.container = container
|
container_info.container = container
|
||||||
self._container_registry.addContainer(container)
|
self._container_registry.addContainer(container)
|
||||||
|
|
||||||
@ -842,6 +847,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
#
|
#
|
||||||
# This will then later be filled with the appropriate data.
|
# This will then later be filled with the appropriate data.
|
||||||
# \param quality_type The quality type of the new profile.
|
# \param quality_type The quality type of the new profile.
|
||||||
|
# \param intent_category The intent category of the new profile.
|
||||||
# \param name The name for the profile. This will later be made unique so
|
# \param name The name for the profile. This will later be made unique so
|
||||||
# it doesn't need to be unique yet.
|
# it doesn't need to be unique yet.
|
||||||
# \param global_stack The global stack showing the configuration that the
|
# \param global_stack The global stack showing the configuration that the
|
||||||
@ -849,7 +855,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
# \param extruder_stack The extruder stack showing the configuration that
|
# \param extruder_stack The extruder stack showing the configuration that
|
||||||
# the profile should be created for. If this is None, it will be created
|
# the profile should be created for. If this is None, it will be created
|
||||||
# for the global stack.
|
# for the global stack.
|
||||||
def _createNewQualityChanges(self, quality_type: str, name: str, global_stack: GlobalStack, extruder_stack: Optional[ExtruderStack]) -> InstanceContainer:
|
def _createNewQualityChanges(self, quality_type: str, intent_category: Optional[str], name: str, global_stack: GlobalStack, extruder_stack: Optional[ExtruderStack]) -> InstanceContainer:
|
||||||
container_registry = CuraApplication.getInstance().getContainerRegistry()
|
container_registry = CuraApplication.getInstance().getContainerRegistry()
|
||||||
base_id = global_stack.definition.getId() if extruder_stack is None else extruder_stack.getId()
|
base_id = global_stack.definition.getId() if extruder_stack is None else extruder_stack.getId()
|
||||||
new_id = base_id + "_" + name
|
new_id = base_id + "_" + name
|
||||||
@ -861,6 +867,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
quality_changes.setName(name)
|
quality_changes.setName(name)
|
||||||
quality_changes.setMetaDataEntry("type", "quality_changes")
|
quality_changes.setMetaDataEntry("type", "quality_changes")
|
||||||
quality_changes.setMetaDataEntry("quality_type", quality_type)
|
quality_changes.setMetaDataEntry("quality_type", quality_type)
|
||||||
|
if intent_category is not None:
|
||||||
|
quality_changes.setMetaDataEntry("intent_category", intent_category)
|
||||||
|
|
||||||
# If we are creating a container for an extruder, ensure we add that to the container.
|
# If we are creating a container for an extruder, ensure we add that to the container.
|
||||||
if extruder_stack is not None:
|
if extruder_stack is not None:
|
||||||
|
@ -131,6 +131,8 @@ class GCodeWriter(MeshWriter):
|
|||||||
container_with_profile.setName(quality_name)
|
container_with_profile.setName(quality_name)
|
||||||
container_with_profile.setMetaDataEntry("type", "quality_changes")
|
container_with_profile.setMetaDataEntry("type", "quality_changes")
|
||||||
container_with_profile.setMetaDataEntry("quality_type", quality_type)
|
container_with_profile.setMetaDataEntry("quality_type", quality_type)
|
||||||
|
if stack.getMetaDataEntry("position") is not None: # For extruder stacks, the quality changes should include an intent category.
|
||||||
|
container_with_profile.setMetaDataEntry("intent_category", stack.intent.getMetaDataEntry("intent_category", "default"))
|
||||||
container_with_profile.setDefinition(machine_definition_id_for_quality)
|
container_with_profile.setDefinition(machine_definition_id_for_quality)
|
||||||
|
|
||||||
flat_global_container = self._createFlattenedContainerInstance(stack.userChanges, container_with_profile)
|
flat_global_container = self._createFlattenedContainerInstance(stack.userChanges, container_with_profile)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user