mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-25 07:33:57 -06:00
Fix selecting quality_changes profiles for extruders
Now that containers in a quality_changes set don't share a common name, the quality_changes containers for extruders have a metadata entry "global_profile" pointing to the global quality_changes container id. Contributes to CURA-2478 and CURA-2484
This commit is contained in:
parent
e7da471199
commit
e1d70ed4b6
4 changed files with 28 additions and 4 deletions
|
@ -42,7 +42,12 @@ class QualityManager:
|
|||
# \return the matching quality changes containers \type{List[ContainerInstance]}
|
||||
def findQualityChangesByName(self, quality_changes_name, machine_definition=None):
|
||||
criteria = {"type": "quality_changes", "name": quality_changes_name}
|
||||
return self._getFilteredContainersForStack(machine_definition, [], **criteria)
|
||||
result = self._getFilteredContainersForStack(machine_definition, [], **criteria)
|
||||
|
||||
criteria = {"type": "quality_changes", "global_profile": quality_changes_name}
|
||||
result.extend(self._getFilteredContainersForStack(machine_definition, [], **criteria))
|
||||
|
||||
return result
|
||||
|
||||
## Fetch the list of available quality types for this combination of machine definition and materials.
|
||||
#
|
||||
|
|
|
@ -467,6 +467,8 @@ class ContainerManager(QObject):
|
|||
base_name = active_quality_name
|
||||
unique_name = self._container_registry.uniqueName(base_name)
|
||||
|
||||
global_changes = None
|
||||
|
||||
# Go through the active stacks and create quality_changes containers from the user containers.
|
||||
for stack in cura.Settings.ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks():
|
||||
user_container = stack.getTop()
|
||||
|
@ -482,6 +484,11 @@ class ContainerManager(QObject):
|
|||
extruder_id)
|
||||
self._performMerge(new_changes, user_container)
|
||||
|
||||
if stack is global_stack:
|
||||
global_changes = new_changes
|
||||
else:
|
||||
new_changes.setMetaDataEntry("global_profile", global_changes.getId())
|
||||
|
||||
self._container_registry.addContainer(new_changes)
|
||||
stack.replaceContainer(stack.getContainerIndex(quality_changes_container), new_changes)
|
||||
|
||||
|
@ -628,8 +635,9 @@ class ContainerManager(QObject):
|
|||
new_change_instances = []
|
||||
|
||||
# Handle the global stack first.
|
||||
new_changes = self._createQualityChanges(quality_container, new_name, machine_definition, None)
|
||||
new_change_instances.append(new_changes)
|
||||
global_changes = self._createQualityChanges(quality_container, new_name, machine_definition, None)
|
||||
new_changes.addMetaDataEntry("global_profile", global_changes.getId())
|
||||
new_change_instances.append(global_changes)
|
||||
self._container_registry.addContainer(new_changes)
|
||||
|
||||
# Handle the extruders if present.
|
||||
|
@ -638,6 +646,7 @@ class ContainerManager(QObject):
|
|||
for key in extruders:
|
||||
value = extruders[key]
|
||||
new_changes = self._createQualityChanges(quality_container, new_name, machine_definition, value)
|
||||
new_changes.addMetaDataEntry("global_profile", global_changes.getId())
|
||||
new_change_instances.append(new_changes)
|
||||
self._container_registry.addContainer(new_changes)
|
||||
|
||||
|
@ -646,10 +655,16 @@ class ContainerManager(QObject):
|
|||
# Duplicate a quality changes container
|
||||
def _duplicateQualityChangesForMachineType(self, quality_changes_name, base_name, machine_definition):
|
||||
new_change_instances = []
|
||||
profile_index = -1
|
||||
global_changes_id = ""
|
||||
for container in QualityManager.getInstance().findQualityChangesByName(quality_changes_name,
|
||||
machine_definition):
|
||||
new_unique_id = self._createUniqueId(container.getId(), base_name)
|
||||
new_container = container.duplicate(new_unique_id, base_name)
|
||||
if profile_index >= 0:
|
||||
new_changes.setMetaDataEntry("global_profile", global_changes_id)
|
||||
else:
|
||||
global_changes_id = new_unique_id
|
||||
new_change_instances.append(new_container)
|
||||
self._container_registry.addContainer(new_container)
|
||||
|
||||
|
|
|
@ -171,6 +171,10 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||
profile.setMetaDataEntry("extruder", extruder_id)
|
||||
else:
|
||||
profile.addMetaDataEntry("extruder", extruder_id)
|
||||
if "global_profile" in profile.getMetaData():
|
||||
profile.setMetaDataEntry("global_profile", global_profile.getId())
|
||||
else:
|
||||
profile.addMetaDataEntry("global_profile", global_profile.getId())
|
||||
elif profile_index == 0:
|
||||
# Importing a multiextrusion profile into a single extrusion machine; merge 1st extruder profile into global profile
|
||||
profile._id = self.uniqueName("temporary_profile")
|
||||
|
|
|
@ -462,7 +462,7 @@ class MachineManager(QObject):
|
|||
@pyqtProperty(str, notify=activeQualityChanged)
|
||||
def activeQualityName(self):
|
||||
if self._active_container_stack:
|
||||
quality = self._active_container_stack.findContainer({"type": "quality_changes"})
|
||||
quality = self._global_container_stack.findContainer({"type": "quality_changes"})
|
||||
if quality and quality != self._empty_quality_changes_container:
|
||||
return quality.getName()
|
||||
quality = self._active_container_stack.findContainer({"type": "quality"})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue