mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 20:45:54 +08:00
Merge branch '3.1'
This commit is contained in:
commit
17a25f98a4
@ -431,19 +431,25 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
extruder_stack.addMetaDataEntry("position", extruder_definition.getMetaDataEntry("position"))
|
extruder_stack.addMetaDataEntry("position", extruder_definition.getMetaDataEntry("position"))
|
||||||
extruder_stack.setNextStack(machine)
|
extruder_stack.setNextStack(machine)
|
||||||
|
|
||||||
|
# create empty user changes container otherwise
|
||||||
|
user_container = InstanceContainer(extruder_stack.id + "_user")
|
||||||
|
user_container.addMetaDataEntry("type", "user")
|
||||||
|
user_container.addMetaDataEntry("machine", extruder_stack.getId())
|
||||||
|
from cura.CuraApplication import CuraApplication
|
||||||
|
user_container.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
|
||||||
|
user_container.setDefinition(extruder_definition)
|
||||||
|
|
||||||
if machine.userChanges:
|
if machine.userChanges:
|
||||||
# set existing user changes if found
|
# for the newly created extruder stack, we need to move all "per-extruder" settings to the user changes
|
||||||
extruder_stack.setUserChanges(machine.userChanges)
|
# container to the extruder stack.
|
||||||
else:
|
for user_setting_key in machine.userChanges.getAllKeys():
|
||||||
# create empty user changes container otherwise
|
settable_per_extruder = machine.getProperty(user_setting_key, "settable_per_extruder")
|
||||||
user_container = InstanceContainer(extruder_stack.id + "_user")
|
if settable_per_extruder:
|
||||||
user_container.addMetaDataEntry("type", "user")
|
user_container.addInstance(machine.userChanges.getInstance(user_setting_key))
|
||||||
user_container.addMetaDataEntry("machine", extruder_stack.getId())
|
machine.userChanges.removeInstance(user_setting_key, postpone_emit = True)
|
||||||
from cura.CuraApplication import CuraApplication
|
|
||||||
user_container.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
|
extruder_stack.setUserChanges(user_container)
|
||||||
user_container.setDefinition(extruder_definition)
|
self.addContainer(user_container)
|
||||||
extruder_stack.setUserChanges(user_container)
|
|
||||||
self.addContainer(user_container)
|
|
||||||
|
|
||||||
variant_id = "default"
|
variant_id = "default"
|
||||||
if machine.variant.getId() not in ("empty", "empty_variant"):
|
if machine.variant.getId() not in ("empty", "empty_variant"):
|
||||||
|
@ -108,7 +108,7 @@ class CuraStackBuilder:
|
|||||||
user_container.addMetaDataEntry("extruder", new_stack_id)
|
user_container.addMetaDataEntry("extruder", new_stack_id)
|
||||||
from cura.CuraApplication import CuraApplication
|
from cura.CuraApplication import CuraApplication
|
||||||
user_container.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
|
user_container.addMetaDataEntry("setting_version", CuraApplication.SettingVersion)
|
||||||
user_container.setDefinition(machine_definition)
|
user_container.setDefinition(definition)
|
||||||
|
|
||||||
stack.setUserChanges(user_container)
|
stack.setUserChanges(user_container)
|
||||||
|
|
||||||
|
@ -772,7 +772,6 @@ class MachineManager(QObject):
|
|||||||
quality_manager.getWholeMachineDefinition(material_container.getDefinition()),
|
quality_manager.getWholeMachineDefinition(material_container.getDefinition()),
|
||||||
[material_container])
|
[material_container])
|
||||||
|
|
||||||
|
|
||||||
if not candidate_quality or isinstance(candidate_quality, type(self._empty_quality_changes_container)):
|
if not candidate_quality or isinstance(candidate_quality, type(self._empty_quality_changes_container)):
|
||||||
Logger.log("d", "Attempting to find fallback quality")
|
Logger.log("d", "Attempting to find fallback quality")
|
||||||
# Fall back to a quality (which must be compatible with all other extruders)
|
# Fall back to a quality (which must be compatible with all other extruders)
|
||||||
|
@ -13,6 +13,7 @@ from UM.Settings.ContainerRegistry import ContainerRegistry
|
|||||||
from UM.MimeTypeDatabase import MimeTypeDatabase
|
from UM.MimeTypeDatabase import MimeTypeDatabase
|
||||||
from UM.Job import Job
|
from UM.Job import Job
|
||||||
from UM.Preferences import Preferences
|
from UM.Preferences import Preferences
|
||||||
|
from UM.Util import parseBool
|
||||||
from .WorkspaceDialog import WorkspaceDialog
|
from .WorkspaceDialog import WorkspaceDialog
|
||||||
|
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
@ -768,6 +769,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
self._container_registry.removeContainer(container.getId())
|
self._container_registry.removeContainer(container.getId())
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
# Check quality profiles to make sure that if one stack has the "not supported" quality profile,
|
# Check quality profiles to make sure that if one stack has the "not supported" quality profile,
|
||||||
# all others should have the same.
|
# all others should have the same.
|
||||||
#
|
#
|
||||||
@ -782,56 +784,67 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
#
|
#
|
||||||
has_not_supported = False
|
has_not_supported = False
|
||||||
for stack in [global_stack] + extruder_stacks:
|
for stack in [global_stack] + extruder_stacks:
|
||||||
if stack.quality.getId() == "empty_quality":
|
if stack.quality.getId() in ("empty", "empty_quality"):
|
||||||
has_not_supported = True
|
has_not_supported = True
|
||||||
break
|
break
|
||||||
|
available_quality = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_stack,
|
||||||
|
extruder_stacks)
|
||||||
if not has_not_supported:
|
if not has_not_supported:
|
||||||
available_quality = QualityManager.getInstance().findAllUsableQualitiesForMachineAndExtruders(global_stack, extruder_stacks)
|
|
||||||
has_not_supported = not available_quality
|
has_not_supported = not available_quality
|
||||||
|
|
||||||
|
quality_has_been_changed = False
|
||||||
|
|
||||||
if has_not_supported:
|
if has_not_supported:
|
||||||
empty_quality_container = self._container_registry.findInstanceContainers(id = "empty_quality")[0]
|
empty_quality_container = self._container_registry.findInstanceContainers(id = "empty_quality")[0]
|
||||||
for stack in [global_stack] + extruder_stacks:
|
for stack in [global_stack] + extruder_stacks:
|
||||||
stack.replaceContainer(_ContainerIndexes.Quality, empty_quality_container)
|
stack.replaceContainer(_ContainerIndexes.Quality, empty_quality_container)
|
||||||
|
empty_quality_changes_container = self._container_registry.findInstanceContainers(id = "empty_quality_changes")[0]
|
||||||
|
for stack in [global_stack] + extruder_stacks:
|
||||||
|
stack.replaceContainer(_ContainerIndexes.QualityChanges, empty_quality_changes_container)
|
||||||
|
quality_has_been_changed = True
|
||||||
|
|
||||||
# Fix quality:
|
else:
|
||||||
# The quality specified in an old project file can be wrong, for example, for UM2, it should be "um2_normal"
|
empty_quality_changes_container = self._container_registry.findInstanceContainers(id="empty_quality_changes")[0]
|
||||||
# but instead it was "normal". This should be fixed by setting it to the correct quality.
|
|
||||||
# Note that this only seems to happen on single-extrusion machines on the global stack, so we only apply the
|
# The machine in the project has non-empty quality and there are usable qualities for this machine.
|
||||||
# fix for that
|
# We need to check if the current quality_type is still usable for this machine, if not, then the quality
|
||||||
quality = global_stack.quality
|
# will be reset to the "preferred quality" if present, otherwise "normal".
|
||||||
if quality.getId() not in ("empty", "empty_quality"):
|
available_quality_types = [q.getMetaDataEntry("quality_type") for q in available_quality]
|
||||||
quality_type = quality.getMetaDataEntry("quality_type")
|
|
||||||
quality_containers = self._container_registry.findInstanceContainers(definition = global_stack.definition.getId(),
|
if global_stack.quality.getMetaDataEntry("quality_type") not in available_quality_types:
|
||||||
|
quality_has_been_changed = True
|
||||||
|
|
||||||
|
# find the preferred quality
|
||||||
|
preferred_quality_id = global_stack.getMetaDataEntry("preferred_quality", None)
|
||||||
|
if preferred_quality_id is not None:
|
||||||
|
definition_id = global_stack.definition.getId()
|
||||||
|
if not parseBool(global_stack.getMetaDataEntry("has_machine_quality", "False")):
|
||||||
|
definition_id = "fdmprinter"
|
||||||
|
|
||||||
|
containers = self._container_registry.findInstanceContainers(id = preferred_quality_id,
|
||||||
type = "quality",
|
type = "quality",
|
||||||
quality_type = quality_type)
|
definition = definition_id)
|
||||||
quality_containers = [q for q in quality_containers if q.getMetaDataEntry("material", "") == ""]
|
containers = [c for c in containers if not c.getMetaDataEntry("material", "")]
|
||||||
if quality_containers:
|
if containers:
|
||||||
global_stack.quality = quality_containers[0]
|
global_stack.quality = containers[0]
|
||||||
else:
|
global_stack.qualityChanges = empty_quality_changes_container
|
||||||
# look for "fdmprinter" qualities if the machine-specific qualities cannot be found
|
# also find the quality containers for the extruders
|
||||||
quality_containers = self._container_registry.findInstanceContainers(definition = "fdmprinter",
|
for extruder_stack in extruder_stacks:
|
||||||
type = "quality",
|
search_criteria = {"id": preferred_quality_id,
|
||||||
quality_type = quality_type)
|
"type": "quality",
|
||||||
quality_containers = [q for q in quality_containers if q.getMetaDataEntry("material", "") == ""]
|
"definition": definition_id}
|
||||||
if quality_containers:
|
if global_stack.getMetaDataEntry("has_machine_materials") and extruder_stack.material.getId() not in ("empty", "empty_material"):
|
||||||
global_stack.quality = quality_containers[0]
|
search_criteria["material"] = extruder_stack.material.getId()
|
||||||
else:
|
containers = self._container_registry.findInstanceContainers(**search_criteria)
|
||||||
# the quality_type of the quality profile cannot be found.
|
if containers:
|
||||||
# this can happen if a quality_type has been removed in a newer version, for example:
|
extruder_stack.quality = containers[0]
|
||||||
# "extra_coarse" is removed from 2.7 to 3.0
|
extruder_stack.qualityChanges = empty_quality_changes_container
|
||||||
# in this case, the quality will be reset to "normal"
|
else:
|
||||||
quality_containers = self._container_registry.findInstanceContainers(
|
Logger.log("e", "Cannot find preferred quality for extruder [%s].", extruder_stack.getId())
|
||||||
definition = global_stack.definition.getId(),
|
|
||||||
type = "quality",
|
|
||||||
quality_type = "normal")
|
|
||||||
quality_containers = [q for q in quality_containers if q.getMetaDataEntry("material", "") == ""]
|
|
||||||
if quality_containers:
|
|
||||||
global_stack.quality = quality_containers[0]
|
|
||||||
else:
|
else:
|
||||||
# This should not happen!
|
# we cannot find the preferred quality. THIS SHOULD NOT HAPPEN
|
||||||
Logger.log("e", "Cannot find quality normal for global stack [%s] [%s]",
|
Logger.log("e", "Cannot find the preferred quality for machine [%s]", global_stack.getId())
|
||||||
global_stack.getId(), global_stack.definition.getId())
|
|
||||||
global_stack.quality = self._container_registry.findInstanceContainers(id = "empty_quality")[0]
|
|
||||||
|
|
||||||
# Replacing the old containers if resolve is "new".
|
# Replacing the old containers if resolve is "new".
|
||||||
# When resolve is "new", some containers will get renamed, so all the other containers that reference to those
|
# When resolve is "new", some containers will get renamed, so all the other containers that reference to those
|
||||||
@ -855,7 +868,11 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
global_stack.userChanges = container
|
global_stack.userChanges = container
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for changes_container_type in ("quality_changes", "definition_changes"):
|
changes_container_types = ("quality_changes", "definition_changes")
|
||||||
|
if quality_has_been_changed:
|
||||||
|
# DO NOT replace quality_changes if the current quality_type is not supported
|
||||||
|
changes_container_types = ("definition_changes",)
|
||||||
|
for changes_container_type in changes_container_types:
|
||||||
if self._resolve_strategies[changes_container_type] == "new":
|
if self._resolve_strategies[changes_container_type] == "new":
|
||||||
# Quality changes needs to get a new ID, added to registry and to the right stacks
|
# Quality changes needs to get a new ID, added to registry and to the right stacks
|
||||||
for each_changes_container in quality_and_definition_changes_instance_containers:
|
for each_changes_container in quality_and_definition_changes_instance_containers:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user