mirror of
https://github.com/Ultimaker/Cura.git
synced 2025-07-23 14:44:13 -06:00
Add version upgrade that adds empty intent profile to the stacks
CURA-6534
This commit is contained in:
parent
a1bbb46555
commit
7cc4ac741c
6 changed files with 114 additions and 0 deletions
|
@ -197,6 +197,7 @@ class CuraApplication(QtApplication):
|
|||
self.empty_container = None # type: EmptyInstanceContainer
|
||||
self.empty_definition_changes_container = None # type: EmptyInstanceContainer
|
||||
self.empty_variant_container = None # type: EmptyInstanceContainer
|
||||
self.empty_intent_container = None # type: EmptyInstanceContainer
|
||||
self.empty_material_container = None # type: EmptyInstanceContainer
|
||||
self.empty_quality_container = None # type: EmptyInstanceContainer
|
||||
self.empty_quality_changes_container = None # type: EmptyInstanceContainer
|
||||
|
@ -433,6 +434,9 @@ class CuraApplication(QtApplication):
|
|||
self._container_registry.addContainer(cura.Settings.cura_empty_instance_containers.empty_variant_container)
|
||||
self.empty_variant_container = cura.Settings.cura_empty_instance_containers.empty_variant_container
|
||||
|
||||
self._container_registry.addContainer(cura.Settings.cura_empty_instance_containers.empty_intent_container)
|
||||
self.empty_intent_container = cura.Settings.cura_empty_instance_containers.empty_intent_container
|
||||
|
||||
self._container_registry.addContainer(cura.Settings.cura_empty_instance_containers.empty_material_container)
|
||||
self.empty_material_container = cura.Settings.cura_empty_instance_containers.empty_material_container
|
||||
|
||||
|
|
|
@ -42,6 +42,12 @@ empty_quality_changes_container.setMetaDataEntry("id", EMPTY_QUALITY_CHANGES_CON
|
|||
empty_quality_changes_container.setMetaDataEntry("type", "quality_changes")
|
||||
empty_quality_changes_container.setMetaDataEntry("quality_type", "not_supported")
|
||||
|
||||
# Empty intent
|
||||
EMPTY_INTENT_CONTAINER_ID = "empty_intent"
|
||||
empty_intent_container = copy.deepcopy(empty_container)
|
||||
empty_intent_container.setMetaDataEntry("id", EMPTY_INTENT_CONTAINER_ID)
|
||||
empty_intent_container.setMetaDataEntry("type", "intent")
|
||||
|
||||
|
||||
# All empty container IDs set
|
||||
ALL_EMPTY_CONTAINER_ID_SET = {
|
||||
|
@ -51,6 +57,7 @@ ALL_EMPTY_CONTAINER_ID_SET = {
|
|||
EMPTY_MATERIAL_CONTAINER_ID,
|
||||
EMPTY_QUALITY_CONTAINER_ID,
|
||||
EMPTY_QUALITY_CHANGES_CONTAINER_ID,
|
||||
EMPTY_INTENT_CONTAINER_ID
|
||||
}
|
||||
|
||||
|
||||
|
@ -73,4 +80,6 @@ __all__ = ["EMPTY_CONTAINER_ID",
|
|||
"empty_quality_container",
|
||||
"ALL_EMPTY_CONTAINER_ID_SET",
|
||||
"isEmptyContainer",
|
||||
"EMPTY_INTENT_CONTAINER_ID",
|
||||
"empty_intent_container"
|
||||
]
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
## Upgrades configurations from the state they were in at version 4.1 to the
|
||||
# state they should be in at version 4.2.
|
||||
import configparser
|
||||
import io
|
||||
from typing import Tuple, List
|
||||
|
||||
from UM.VersionUpgrade import VersionUpgrade
|
||||
|
||||
|
||||
class VersionUpgrade41to42(VersionUpgrade):
|
||||
|
||||
def getCfgVersion(self, serialised: str) -> int:
|
||||
parser = configparser.ConfigParser(interpolation = None)
|
||||
parser.read_string(serialised)
|
||||
format_version = int(parser.get("general", "version")) #Explicitly give an exception when this fails. That means that the file format is not recognised.
|
||||
setting_version = int(parser.get("metadata", "setting_version", fallback = "0"))
|
||||
return format_version * 1000000 + setting_version
|
||||
|
||||
## Upgrades stacks to have the new version number.
|
||||
def upgradeStack(self, serialized: str, filename: str) -> Tuple[List[str], List[str]]:
|
||||
parser = configparser.ConfigParser(interpolation=None)
|
||||
parser.read_string(serialized)
|
||||
|
||||
# We should only have 6 levels when we start.
|
||||
assert "7" not in parser["containers"]
|
||||
|
||||
# Update version number.
|
||||
parser["general"]["version"] = "5"
|
||||
|
||||
# We added the intent container in Cura 4.2. This means that all other containers move one step down.
|
||||
parser["containers"]["7"] = parser["containers"]["6"]
|
||||
parser["containers"]["6"] = parser["containers"]["5"]
|
||||
parser["containers"]["5"] = parser["containers"]["4"]
|
||||
parser["containers"]["4"] = parser["containers"]["3"]
|
||||
parser["containers"]["3"] = parser["containers"]["2"]
|
||||
parser["containers"]["2"] = "empty_intent"
|
||||
|
||||
result = io.StringIO()
|
||||
parser.write(result)
|
||||
|
||||
return [filename], [result.getvalue()]
|
||||
|
34
plugins/VersionUpgrade/VersionUpgrade41to42/__init__.py
Normal file
34
plugins/VersionUpgrade/VersionUpgrade41to42/__init__.py
Normal file
|
@ -0,0 +1,34 @@
|
|||
# Copyright (c) 2019 Ultimaker B.V.
|
||||
# Cura is released under the terms of the LGPLv3 or higher.
|
||||
|
||||
from typing import Any, Dict, TYPE_CHECKING
|
||||
|
||||
from . import VersionUpgrade41to42
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from UM.Application import Application
|
||||
|
||||
upgrade = VersionUpgrade41to42.VersionUpgrade41to42()
|
||||
|
||||
def getMetaData() -> Dict[str, Any]:
|
||||
return {
|
||||
"version_upgrade": {
|
||||
# From To Upgrade function
|
||||
("machine_stack", 4000007): ("machine_stack", 5000007, upgrade.upgradeStack),
|
||||
("extruder_train", 4000007): ("extruder_train", 5000007, upgrade.upgradeStack)
|
||||
},
|
||||
"sources": {
|
||||
"machine_stack": {
|
||||
"get_version": upgrade.getCfgVersion,
|
||||
"location": {"./machine_instances"}
|
||||
},
|
||||
"extruder_train": {
|
||||
"get_version": upgrade.getCfgVersion,
|
||||
"location": {"./extruders"}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def register(app: "Application") -> Dict[str, Any]:
|
||||
return {"version_upgrade": upgrade}
|
8
plugins/VersionUpgrade/VersionUpgrade41to42/plugin.json
Normal file
8
plugins/VersionUpgrade/VersionUpgrade41to42/plugin.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"name": "Version Upgrade 4.1 to 4.2",
|
||||
"author": "Ultimaker B.V.",
|
||||
"version": "1.0.0",
|
||||
"description": "Upgrades configurations from Cura 4.1 to Cura 4.2.",
|
||||
"api": "6.0",
|
||||
"i18n-catalog": "cura"
|
||||
}
|
|
@ -764,6 +764,23 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"VersionUpgrade41to42": {
|
||||
"package_info": {
|
||||
"package_id": "VersionUpgrade41to42",
|
||||
"package_type": "plugin",
|
||||
"display_name": "Version Upgrade 4.1 to 4.2",
|
||||
"description": "Upgrades configurations from Cura 4.1 to Cura 4.2.",
|
||||
"package_version": "1.0.0",
|
||||
"sdk_version": "6.0.0",
|
||||
"website": "https://ultimaker.com",
|
||||
"author": {
|
||||
"author_id": "UltimakerPackages",
|
||||
"display_name": "Ultimaker B.V.",
|
||||
"email": "plugins@ultimaker.com",
|
||||
"website": "https://ultimaker.com"
|
||||
}
|
||||
}
|
||||
},
|
||||
"X3DReader": {
|
||||
"package_info": {
|
||||
"package_id": "X3DReader",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue