mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-05-12 05:39:01 +08:00
Merge branch '3.1' of https://github.com/Ultimaker/Cura into 3.1
This commit is contained in:
commit
f0dca021d8
@ -20,6 +20,8 @@ For crashes and similar issues, please attach the following information:
|
|||||||
|
|
||||||
If the Cura user interface still starts, you can also reach this directory from the application menu in Help -> Show settings folder
|
If the Cura user interface still starts, you can also reach this directory from the application menu in Help -> Show settings folder
|
||||||
|
|
||||||
|
For additional support, you could also ask in the #cura channel on FreeNode IRC. For help with development, there is also the #cura-dev channel.
|
||||||
|
|
||||||
Dependencies
|
Dependencies
|
||||||
------------
|
------------
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
import re
|
import re
|
||||||
|
import configparser
|
||||||
|
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
|
|
||||||
@ -19,6 +20,7 @@ from UM.Message import Message
|
|||||||
from UM.Platform import Platform
|
from UM.Platform import Platform
|
||||||
from UM.PluginRegistry import PluginRegistry # For getting the possible profile writers to write with.
|
from UM.PluginRegistry import PluginRegistry # For getting the possible profile writers to write with.
|
||||||
from UM.Util import parseBool
|
from UM.Util import parseBool
|
||||||
|
from UM.Resources import Resources
|
||||||
|
|
||||||
from . import ExtruderStack
|
from . import ExtruderStack
|
||||||
from . import GlobalStack
|
from . import GlobalStack
|
||||||
@ -444,21 +446,84 @@ class CuraContainerRegistry(ContainerRegistry):
|
|||||||
self.addContainer(user_container)
|
self.addContainer(user_container)
|
||||||
|
|
||||||
variant_id = "default"
|
variant_id = "default"
|
||||||
if machine.variant.getId() != "empty_variant":
|
if machine.variant.getId() not in ("empty", "empty_variant"):
|
||||||
variant_id = machine.variant.getId()
|
variant_id = machine.variant.getId()
|
||||||
|
else:
|
||||||
|
variant_id = "empty_variant"
|
||||||
extruder_stack.setVariantById(variant_id)
|
extruder_stack.setVariantById(variant_id)
|
||||||
extruder_stack.setMaterialById("default")
|
|
||||||
extruder_stack.setQualityById("default")
|
material_id = "default"
|
||||||
if machine.qualityChanges.getId() != "empty_quality_changes":
|
if machine.material.getId() not in ("empty", "empty_material"):
|
||||||
|
# TODO: find the ID that's suitable for this extruder
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
material_id = "empty_material"
|
||||||
|
extruder_stack.setMaterialById(material_id)
|
||||||
|
|
||||||
|
quality_id = "default"
|
||||||
|
if machine.quality.getId() not in ("empty", "empty_quality"):
|
||||||
|
# TODO: find the ID that's suitable for this extruder
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
quality_id = "empty_quality"
|
||||||
|
extruder_stack.setQualityById(quality_id)
|
||||||
|
|
||||||
|
if machine.qualityChanges.getId() not in ("empty", "empty_quality_changes"):
|
||||||
extruder_quality_changes_container = self.findInstanceContainers(name = machine.qualityChanges.getName(), extruder = extruder_id)
|
extruder_quality_changes_container = self.findInstanceContainers(name = machine.qualityChanges.getName(), extruder = extruder_id)
|
||||||
if extruder_quality_changes_container:
|
if extruder_quality_changes_container:
|
||||||
quality_changes_id = extruder_quality_changes_container[0].getId()
|
extruder_quality_changes_container = extruder_quality_changes_container[0]
|
||||||
|
quality_changes_id = extruder_quality_changes_container.getId()
|
||||||
extruder_stack.setQualityChangesById(quality_changes_id)
|
extruder_stack.setQualityChangesById(quality_changes_id)
|
||||||
|
else:
|
||||||
|
# Some extruder quality_changes containers can be created at runtime as files in the qualities
|
||||||
|
# folder. Those files won't be loaded in the registry immediately. So we also need to search
|
||||||
|
# the folder to see if the quality_changes exists.
|
||||||
|
extruder_quality_changes_container = self._findQualityChangesContainerInCuraFolder(machine.qualityChanges.getName())
|
||||||
|
if extruder_quality_changes_container:
|
||||||
|
quality_changes_id = extruder_quality_changes_container.getId()
|
||||||
|
extruder_stack.setQualityChangesById(quality_changes_id)
|
||||||
|
|
||||||
|
if not extruder_quality_changes_container:
|
||||||
|
Logger.log("w", "Could not find quality_changes named [%s] for extruder [%s]",
|
||||||
|
machine.qualityChanges.getName(), extruder_stack.getId())
|
||||||
|
|
||||||
self.addContainer(extruder_stack)
|
self.addContainer(extruder_stack)
|
||||||
|
|
||||||
return extruder_stack
|
return extruder_stack
|
||||||
|
|
||||||
|
def _findQualityChangesContainerInCuraFolder(self, name):
|
||||||
|
quality_changes_dir = Resources.getPath(CuraApplication.ResourceTypes.QualityInstanceContainer)
|
||||||
|
|
||||||
|
instance_container = None
|
||||||
|
|
||||||
|
for item in os.listdir(quality_changes_dir):
|
||||||
|
file_path = os.path.join(quality_changes_dir, item)
|
||||||
|
if not os.path.isfile(file_path):
|
||||||
|
continue
|
||||||
|
|
||||||
|
parser = configparser.ConfigParser()
|
||||||
|
try:
|
||||||
|
parser.read([file_path])
|
||||||
|
except:
|
||||||
|
# skip, it is not a valid stack file
|
||||||
|
continue
|
||||||
|
|
||||||
|
if not parser.has_option("general", "name"):
|
||||||
|
continue
|
||||||
|
|
||||||
|
if parser["general"]["name"] == name:
|
||||||
|
# load the container
|
||||||
|
container_id = os.path.basename(file_path).replace(".inst.cfg", "")
|
||||||
|
|
||||||
|
instance_container = InstanceContainer(container_id)
|
||||||
|
with open(file_path, "r") as f:
|
||||||
|
serialized = f.read()
|
||||||
|
instance_container.deserialize(serialized, file_path)
|
||||||
|
self.addContainer(instance_container)
|
||||||
|
break
|
||||||
|
|
||||||
|
return instance_container
|
||||||
|
|
||||||
# Fix the extruders that were upgraded to ExtruderStack instances during addContainer.
|
# Fix the extruders that were upgraded to ExtruderStack instances during addContainer.
|
||||||
# The stacks are now responsible for setting the next stack on deserialize. However,
|
# The stacks are now responsible for setting the next stack on deserialize. However,
|
||||||
# due to problems with loading order, some stacks may not have the proper next stack
|
# due to problems with loading order, some stacks may not have the proper next stack
|
||||||
|
@ -41,9 +41,20 @@ class CuraContainerStack(ContainerStack):
|
|||||||
def __init__(self, container_id: str, *args, **kwargs):
|
def __init__(self, container_id: str, *args, **kwargs):
|
||||||
super().__init__(container_id, *args, **kwargs)
|
super().__init__(container_id, *args, **kwargs)
|
||||||
|
|
||||||
self._empty_instance_container = ContainerRegistry.getInstance().getEmptyInstanceContainer()
|
self._container_registry = ContainerRegistry.getInstance()
|
||||||
|
|
||||||
|
self._empty_instance_container = self._container_registry.getEmptyInstanceContainer()
|
||||||
|
|
||||||
|
self._empty_quality_changes = self._container_registry.findInstanceContainers(id = "empty_quality_changes")[0]
|
||||||
|
self._empty_quality = self._container_registry.findInstanceContainers(id = "empty_quality")[0]
|
||||||
|
self._empty_material = self._container_registry.findInstanceContainers(id = "empty_material")[0]
|
||||||
|
self._empty_variant = self._container_registry.findInstanceContainers(id = "empty_variant")[0]
|
||||||
|
|
||||||
self._containers = [self._empty_instance_container for i in range(len(_ContainerIndexes.IndexTypeMap))]
|
self._containers = [self._empty_instance_container for i in range(len(_ContainerIndexes.IndexTypeMap))]
|
||||||
|
self._containers[_ContainerIndexes.QualityChanges] = self._empty_quality_changes
|
||||||
|
self._containers[_ContainerIndexes.Quality] = self._empty_quality
|
||||||
|
self._containers[_ContainerIndexes.Material] = self._empty_material
|
||||||
|
self._containers[_ContainerIndexes.Variant] = self._empty_variant
|
||||||
|
|
||||||
self.containersChanged.connect(self._onContainersChanged)
|
self.containersChanged.connect(self._onContainersChanged)
|
||||||
|
|
||||||
@ -348,8 +359,8 @@ class CuraContainerStack(ContainerStack):
|
|||||||
#
|
#
|
||||||
# \throws InvalidContainerStackError Raised when no definition can be found for the stack.
|
# \throws InvalidContainerStackError Raised when no definition can be found for the stack.
|
||||||
@override(ContainerStack)
|
@override(ContainerStack)
|
||||||
def deserialize(self, contents: str) -> None:
|
def deserialize(self, contents: str, file_name: Optional[str] = None) -> None:
|
||||||
super().deserialize(contents)
|
super().deserialize(contents, file_name)
|
||||||
|
|
||||||
new_containers = self._containers.copy()
|
new_containers = self._containers.copy()
|
||||||
while len(new_containers) < len(_ContainerIndexes.IndexTypeMap):
|
while len(new_containers) < len(_ContainerIndexes.IndexTypeMap):
|
||||||
@ -456,7 +467,7 @@ class CuraContainerStack(ContainerStack):
|
|||||||
else:
|
else:
|
||||||
search_criteria["definition"] = "fdmprinter"
|
search_criteria["definition"] = "fdmprinter"
|
||||||
|
|
||||||
if self.material != self._empty_instance_container:
|
if self.material != self._empty_material:
|
||||||
search_criteria["name"] = self.material.name
|
search_criteria["name"] = self.material.name
|
||||||
else:
|
else:
|
||||||
preferred_material = definition.getMetaDataEntry("preferred_material")
|
preferred_material = definition.getMetaDataEntry("preferred_material")
|
||||||
@ -503,7 +514,7 @@ class CuraContainerStack(ContainerStack):
|
|||||||
else:
|
else:
|
||||||
search_criteria["definition"] = "fdmprinter"
|
search_criteria["definition"] = "fdmprinter"
|
||||||
|
|
||||||
if self.quality != self._empty_instance_container:
|
if self.quality != self._empty_quality:
|
||||||
search_criteria["name"] = self.quality.name
|
search_criteria["name"] = self.quality.name
|
||||||
else:
|
else:
|
||||||
preferred_quality = definition.getMetaDataEntry("preferred_quality")
|
preferred_quality = definition.getMetaDataEntry("preferred_quality")
|
||||||
|
@ -92,8 +92,8 @@ class ExtruderStack(CuraContainerStack):
|
|||||||
return self.getNextStack()._getMachineDefinition()
|
return self.getNextStack()._getMachineDefinition()
|
||||||
|
|
||||||
@override(CuraContainerStack)
|
@override(CuraContainerStack)
|
||||||
def deserialize(self, contents: str) -> None:
|
def deserialize(self, contents: str, file_name: Optional[str] = None) -> None:
|
||||||
super().deserialize(contents)
|
super().deserialize(contents, file_name)
|
||||||
stacks = ContainerRegistry.getInstance().findContainerStacks(id=self.getMetaDataEntry("machine", ""))
|
stacks = ContainerRegistry.getInstance().findContainerStacks(id=self.getMetaDataEntry("machine", ""))
|
||||||
if stacks:
|
if stacks:
|
||||||
self.setNextStack(stacks[0])
|
self.setNextStack(stacks[0])
|
||||||
|
@ -18,4 +18,8 @@ class MaterialsModel(InstanceContainersModel):
|
|||||||
# \param container The container whose metadata was changed.
|
# \param container The container whose metadata was changed.
|
||||||
def _onContainerMetaDataChanged(self, container):
|
def _onContainerMetaDataChanged(self, container):
|
||||||
if container.getMetaDataEntry("type") == "material": #Only need to update if a material was changed.
|
if container.getMetaDataEntry("type") == "material": #Only need to update if a material was changed.
|
||||||
self._update()
|
self._update()
|
||||||
|
|
||||||
|
def _onContainerChanged(self, container):
|
||||||
|
if container.getMetaDataEntry("type", "") == "material":
|
||||||
|
super()._onContainerChanged(container)
|
||||||
|
@ -152,7 +152,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
|
|
||||||
if not definitions:
|
if not definitions:
|
||||||
definition_container = DefinitionContainer(container_id)
|
definition_container = DefinitionContainer(container_id)
|
||||||
definition_container.deserialize(archive.open(each_definition_container_file).read().decode("utf-8"))
|
definition_container.deserialize(archive.open(each_definition_container_file).read().decode("utf-8"),
|
||||||
|
file_name = each_definition_container_file)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
definition_container = definitions[0]
|
definition_container = definitions[0]
|
||||||
@ -208,7 +209,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
instance_container = InstanceContainer(container_id)
|
instance_container = InstanceContainer(container_id)
|
||||||
|
|
||||||
# Deserialize InstanceContainer by converting read data from bytes to string
|
# Deserialize InstanceContainer by converting read data from bytes to string
|
||||||
instance_container.deserialize(archive.open(each_instance_container_file).read().decode("utf-8"))
|
instance_container.deserialize(archive.open(each_instance_container_file).read().decode("utf-8"),
|
||||||
|
file_name = each_instance_container_file)
|
||||||
instance_container_list.append(instance_container)
|
instance_container_list.append(instance_container)
|
||||||
|
|
||||||
container_type = instance_container.getMetaDataEntry("type")
|
container_type = instance_container.getMetaDataEntry("type")
|
||||||
@ -378,7 +380,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
return WorkspaceReader.PreReadResult.accepted
|
return WorkspaceReader.PreReadResult.accepted
|
||||||
|
|
||||||
## Overrides an ExtruderStack in the given GlobalStack and returns the new ExtruderStack.
|
## Overrides an ExtruderStack in the given GlobalStack and returns the new ExtruderStack.
|
||||||
def _overrideExtruderStack(self, global_stack, extruder_file_content):
|
def _overrideExtruderStack(self, global_stack, extruder_file_content, extruder_stack_file):
|
||||||
# Get extruder position first
|
# Get extruder position first
|
||||||
extruder_config = configparser.ConfigParser()
|
extruder_config = configparser.ConfigParser()
|
||||||
extruder_config.read_string(extruder_file_content)
|
extruder_config.read_string(extruder_file_content)
|
||||||
@ -394,7 +396,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
# Override the given extruder stack
|
# Override the given extruder stack
|
||||||
extruder_stack.deserialize(extruder_file_content)
|
extruder_stack.deserialize(extruder_file_content, file_name = extruder_stack_file)
|
||||||
|
|
||||||
# return the new ExtruderStack
|
# return the new ExtruderStack
|
||||||
return extruder_stack
|
return extruder_stack
|
||||||
@ -484,7 +486,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
definitions = self._container_registry.findDefinitionContainers(id = container_id)
|
definitions = self._container_registry.findDefinitionContainers(id = container_id)
|
||||||
if not definitions:
|
if not definitions:
|
||||||
definition_container = DefinitionContainer(container_id)
|
definition_container = DefinitionContainer(container_id)
|
||||||
definition_container.deserialize(archive.open(definition_container_file).read().decode("utf-8"))
|
definition_container.deserialize(archive.open(definition_container_file).read().decode("utf-8"),
|
||||||
|
file_name = definition_container_file)
|
||||||
self._container_registry.addContainer(definition_container)
|
self._container_registry.addContainer(definition_container)
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
@ -502,18 +505,21 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
|
|
||||||
if not materials:
|
if not materials:
|
||||||
material_container = xml_material_profile(container_id)
|
material_container = xml_material_profile(container_id)
|
||||||
material_container.deserialize(archive.open(material_container_file).read().decode("utf-8"))
|
material_container.deserialize(archive.open(material_container_file).read().decode("utf-8"),
|
||||||
|
file_name = material_container_file)
|
||||||
containers_to_add.append(material_container)
|
containers_to_add.append(material_container)
|
||||||
else:
|
else:
|
||||||
material_container = materials[0]
|
material_container = materials[0]
|
||||||
if not material_container.isReadOnly(): # Only create new materials if they are not read only.
|
if not material_container.isReadOnly(): # Only create new materials if they are not read only.
|
||||||
if self._resolve_strategies["material"] == "override":
|
if self._resolve_strategies["material"] == "override":
|
||||||
material_container.deserialize(archive.open(material_container_file).read().decode("utf-8"))
|
material_container.deserialize(archive.open(material_container_file).read().decode("utf-8"),
|
||||||
|
file_name = material_container_file)
|
||||||
elif self._resolve_strategies["material"] == "new":
|
elif self._resolve_strategies["material"] == "new":
|
||||||
# Note that we *must* deserialize it with a new ID, as multiple containers will be
|
# Note that we *must* deserialize it with a new ID, as multiple containers will be
|
||||||
# auto created & added.
|
# auto created & added.
|
||||||
material_container = xml_material_profile(self.getNewId(container_id))
|
material_container = xml_material_profile(self.getNewId(container_id))
|
||||||
material_container.deserialize(archive.open(material_container_file).read().decode("utf-8"))
|
material_container.deserialize(archive.open(material_container_file).read().decode("utf-8"),
|
||||||
|
file_name = material_container_file)
|
||||||
containers_to_add.append(material_container)
|
containers_to_add.append(material_container)
|
||||||
|
|
||||||
material_containers.append(material_container)
|
material_containers.append(material_container)
|
||||||
@ -540,7 +546,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
instance_container = InstanceContainer(container_id)
|
instance_container = InstanceContainer(container_id)
|
||||||
|
|
||||||
# Deserialize InstanceContainer by converting read data from bytes to string
|
# Deserialize InstanceContainer by converting read data from bytes to string
|
||||||
instance_container.deserialize(serialized)
|
instance_container.deserialize(serialized, file_name = instance_container_file)
|
||||||
container_type = instance_container.getMetaDataEntry("type")
|
container_type = instance_container.getMetaDataEntry("type")
|
||||||
Job.yieldThread()
|
Job.yieldThread()
|
||||||
|
|
||||||
@ -562,7 +568,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
else:
|
else:
|
||||||
if self._resolve_strategies["machine"] == "override" or self._resolve_strategies["machine"] is None:
|
if self._resolve_strategies["machine"] == "override" or self._resolve_strategies["machine"] is None:
|
||||||
instance_container = user_containers[0]
|
instance_container = user_containers[0]
|
||||||
instance_container.deserialize(archive.open(instance_container_file).read().decode("utf-8"))
|
instance_container.deserialize(archive.open(instance_container_file).read().decode("utf-8"),
|
||||||
|
file_name = instance_container_file)
|
||||||
instance_container.setDirty(True)
|
instance_container.setDirty(True)
|
||||||
elif self._resolve_strategies["machine"] == "new":
|
elif self._resolve_strategies["machine"] == "new":
|
||||||
# The machine is going to get a spiffy new name, so ensure that the id's of user settings match.
|
# The machine is going to get a spiffy new name, so ensure that the id's of user settings match.
|
||||||
@ -595,7 +602,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
# selected strategy.
|
# selected strategy.
|
||||||
if self._resolve_strategies[container_type] == "override":
|
if self._resolve_strategies[container_type] == "override":
|
||||||
instance_container = changes_containers[0]
|
instance_container = changes_containers[0]
|
||||||
instance_container.deserialize(archive.open(instance_container_file).read().decode("utf-8"))
|
instance_container.deserialize(archive.open(instance_container_file).read().decode("utf-8"),
|
||||||
|
file_name = instance_container_file)
|
||||||
instance_container.setDirty(True)
|
instance_container.setDirty(True)
|
||||||
|
|
||||||
elif self._resolve_strategies[container_type] == "new":
|
elif self._resolve_strategies[container_type] == "new":
|
||||||
@ -656,7 +664,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
# There is a machine, check if it has authentication data. If so, keep that data.
|
# There is a machine, check if it has authentication data. If so, keep that data.
|
||||||
network_authentication_id = container_stacks[0].getMetaDataEntry("network_authentication_id")
|
network_authentication_id = container_stacks[0].getMetaDataEntry("network_authentication_id")
|
||||||
network_authentication_key = container_stacks[0].getMetaDataEntry("network_authentication_key")
|
network_authentication_key = container_stacks[0].getMetaDataEntry("network_authentication_key")
|
||||||
container_stacks[0].deserialize(archive.open(global_stack_file).read().decode("utf-8"))
|
container_stacks[0].deserialize(archive.open(global_stack_file).read().decode("utf-8"),
|
||||||
|
file_name = global_stack_file)
|
||||||
if network_authentication_id:
|
if network_authentication_id:
|
||||||
container_stacks[0].addMetaDataEntry("network_authentication_id", network_authentication_id)
|
container_stacks[0].addMetaDataEntry("network_authentication_id", network_authentication_id)
|
||||||
if network_authentication_key:
|
if network_authentication_key:
|
||||||
@ -666,7 +675,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
# create a new global stack
|
# create a new global stack
|
||||||
stack = GlobalStack(global_stack_id_new)
|
stack = GlobalStack(global_stack_id_new)
|
||||||
# Deserialize stack by converting read data from bytes to string
|
# Deserialize stack by converting read data from bytes to string
|
||||||
stack.deserialize(archive.open(global_stack_file).read().decode("utf-8"))
|
stack.deserialize(archive.open(global_stack_file).read().decode("utf-8"),
|
||||||
|
file_name = global_stack_file)
|
||||||
|
|
||||||
# Ensure a unique ID and name
|
# Ensure a unique ID and name
|
||||||
stack._id = global_stack_id_new
|
stack._id = global_stack_id_new
|
||||||
@ -706,7 +716,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
if self._resolve_strategies["machine"] == "override":
|
if self._resolve_strategies["machine"] == "override":
|
||||||
if global_stack.getProperty("machine_extruder_count", "value") > 1:
|
if global_stack.getProperty("machine_extruder_count", "value") > 1:
|
||||||
# deserialize new extruder stack over the current ones (if any)
|
# deserialize new extruder stack over the current ones (if any)
|
||||||
stack = self._overrideExtruderStack(global_stack, extruder_file_content)
|
stack = self._overrideExtruderStack(global_stack, extruder_file_content, extruder_stack_file)
|
||||||
if stack is None:
|
if stack is None:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@ -726,7 +736,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
extruder_config.write(tmp_string_io)
|
extruder_config.write(tmp_string_io)
|
||||||
extruder_file_content = tmp_string_io.getvalue()
|
extruder_file_content = tmp_string_io.getvalue()
|
||||||
|
|
||||||
stack.deserialize(extruder_file_content)
|
stack.deserialize(extruder_file_content, file_name = extruder_stack_file)
|
||||||
|
|
||||||
# Ensure a unique ID and name
|
# Ensure a unique ID and name
|
||||||
stack._id = new_id
|
stack._id = new_id
|
||||||
@ -780,6 +790,36 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
|
|||||||
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)
|
||||||
|
|
||||||
|
# Fix quality:
|
||||||
|
# The quality specified in an old project file can be wrong, for example, for UM2, it should be "um2_normal"
|
||||||
|
# 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
|
||||||
|
# fix for that
|
||||||
|
quality = global_stack.quality
|
||||||
|
if quality.getId() not in ("empty", "empty_quality"):
|
||||||
|
quality_type = quality.getMetaDataEntry("quality_type")
|
||||||
|
quality_containers = self._container_registry.findInstanceContainers(definition = global_stack.definition.getId(),
|
||||||
|
type = "quality",
|
||||||
|
quality_type = quality_type)
|
||||||
|
if quality_containers:
|
||||||
|
global_stack.quality = quality_containers[0]
|
||||||
|
else:
|
||||||
|
# the quality_type of the quality profile cannot be found.
|
||||||
|
# this can happen if a quality_type has been removed in a newer version, for example:
|
||||||
|
# "extra_coarse" is removed from 2.7 to 3.0
|
||||||
|
# in this case, the quality will be reset to "normal"
|
||||||
|
quality_containers = self._container_registry.findInstanceContainers(
|
||||||
|
definition = global_stack.definition.getId(),
|
||||||
|
type = "quality",
|
||||||
|
quality_type = "normal")
|
||||||
|
if quality_containers:
|
||||||
|
global_stack.quality = quality_containers[0]
|
||||||
|
else:
|
||||||
|
# This should not happen!
|
||||||
|
Logger.log("e", "Cannot find quality normal for global stack [%s] [%s]",
|
||||||
|
global_stack.getId(), global_stack.definition.getId())
|
||||||
|
global_stack.quality = self._container_registry.findInstanceContainers(id = "empty_quality")
|
||||||
|
|
||||||
# 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
|
||||||
# MUST get updated too.
|
# MUST get updated too.
|
||||||
|
@ -116,7 +116,10 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|||||||
all_quality_changes = self._getSingleExtrusionMachineQualityChanges(parser)
|
all_quality_changes = self._getSingleExtrusionMachineQualityChanges(parser)
|
||||||
# Note that DO NOT!!! use the quality_changes returned from _getSingleExtrusionMachineQualityChanges().
|
# Note that DO NOT!!! use the quality_changes returned from _getSingleExtrusionMachineQualityChanges().
|
||||||
# Those are loaded from the hard drive which are original files that haven't been upgraded yet.
|
# Those are loaded from the hard drive which are original files that haven't been upgraded yet.
|
||||||
if len(all_quality_changes) == 1 and not parser.has_option("metadata", "extruder"):
|
# NOTE 2: The number can be 0 or 1 depends on whether you are loading it from the qualities folder or
|
||||||
|
# from a project file. When you load from a project file, the custom profile may not be in cura
|
||||||
|
# yet, so you will get 0.
|
||||||
|
if len(all_quality_changes) <= 1 and not parser.has_option("metadata", "extruder"):
|
||||||
self._createExtruderQualityChangesForSingleExtrusionMachine(filename, parser)
|
self._createExtruderQualityChangesForSingleExtrusionMachine(filename, parser)
|
||||||
|
|
||||||
# Update version numbers
|
# Update version numbers
|
||||||
@ -199,7 +202,7 @@ class VersionUpgrade30to31(VersionUpgrade):
|
|||||||
|
|
||||||
def _createExtruderQualityChangesForSingleExtrusionMachine(self, filename, global_quality_changes):
|
def _createExtruderQualityChangesForSingleExtrusionMachine(self, filename, global_quality_changes):
|
||||||
suffix = "_" + quote_plus(global_quality_changes["general"]["name"].lower())
|
suffix = "_" + quote_plus(global_quality_changes["general"]["name"].lower())
|
||||||
machine_name = filename.strip("." + os.sep).replace(suffix, "")
|
machine_name = os.path.os.path.basename(filename).replace(".inst.cfg", "").replace(suffix, "")
|
||||||
new_filename = machine_name + "_" + "fdmextruder" + suffix
|
new_filename = machine_name + "_" + "fdmextruder" + suffix
|
||||||
|
|
||||||
extruder_quality_changes_parser = configparser.ConfigParser()
|
extruder_quality_changes_parser = configparser.ConfigParser()
|
||||||
|
@ -422,11 +422,11 @@ class XmlMaterialProfile(InstanceContainer):
|
|||||||
return version * 1000000 + setting_version
|
return version * 1000000 + setting_version
|
||||||
|
|
||||||
## Overridden from InstanceContainer
|
## Overridden from InstanceContainer
|
||||||
def deserialize(self, serialized):
|
def deserialize(self, serialized, file_name = None):
|
||||||
containers_to_add = []
|
containers_to_add = []
|
||||||
# update the serialized data first
|
# update the serialized data first
|
||||||
from UM.Settings.Interfaces import ContainerInterface
|
from UM.Settings.Interfaces import ContainerInterface
|
||||||
serialized = ContainerInterface.deserialize(self, serialized)
|
serialized = ContainerInterface.deserialize(self, serialized, file_name)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
data = ET.fromstring(serialized)
|
data = ET.fromstring(serialized)
|
||||||
|
@ -322,7 +322,6 @@ UM.ManagementPage
|
|||||||
{
|
{
|
||||||
messageDialog.icon = StandardIcon.Information
|
messageDialog.icon = StandardIcon.Information
|
||||||
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Successfully imported material <filename>%1</filename>").arg(fileUrl)
|
messageDialog.text = catalog.i18nc("@info:status Don't translate the XML tag <filename>!", "Successfully imported material <filename>%1</filename>").arg(fileUrl)
|
||||||
currentItem = base.model.getItem(base.objectList.currentIndex)
|
|
||||||
}
|
}
|
||||||
else if(result.status == "duplicate")
|
else if(result.status == "duplicate")
|
||||||
{
|
{
|
||||||
|
@ -228,6 +228,8 @@ Rectangle
|
|||||||
|
|
||||||
spacing: 2
|
spacing: 2
|
||||||
|
|
||||||
|
visible: !base.monitoringPrint
|
||||||
|
|
||||||
anchors {
|
anchors {
|
||||||
verticalCenter: base.verticalCenter
|
verticalCenter: base.verticalCenter
|
||||||
right: viewModeButton.right
|
right: viewModeButton.right
|
||||||
|
Loading…
x
Reference in New Issue
Block a user