mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-14 03:35:57 +08:00
Merge branch '2.3' of https://github.com/Ultimaker/Cura into 2.3
This commit is contained in:
commit
8c2a8944e8
@ -107,7 +107,6 @@ class PlatformPhysics:
|
|||||||
continue # Other node is already moving, wait for next pass.
|
continue # Other node is already moving, wait for next pass.
|
||||||
|
|
||||||
overlap = (0, 0) # Start loop with no overlap
|
overlap = (0, 0) # Start loop with no overlap
|
||||||
move_vector = move_vector.set(x=overlap[0] * self._move_factor, z=overlap[1] * self._move_factor)
|
|
||||||
current_overlap_checks = 0
|
current_overlap_checks = 0
|
||||||
# Continue to check the overlap until we no longer find one.
|
# Continue to check the overlap until we no longer find one.
|
||||||
while overlap and current_overlap_checks < self._max_overlap_checks:
|
while overlap and current_overlap_checks < self._max_overlap_checks:
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
# Copyright (c) 2015 Ultimaker B.V.
|
# Copyright (c) 2015 Ultimaker B.V.
|
||||||
# Cura is released under the terms of the AGPLv3 or higher.
|
# Cura is released under the terms of the AGPLv3 or higher.
|
||||||
|
import configparser
|
||||||
|
|
||||||
import os.path
|
from UM import PluginRegistry
|
||||||
|
|
||||||
from UM.Logger import Logger
|
from UM.Logger import Logger
|
||||||
from UM.Settings.InstanceContainer import InstanceContainer # The new profile to make.
|
from UM.Settings.InstanceContainer import InstanceContainer # The new profile to make.
|
||||||
from cura.ProfileReader import ProfileReader
|
from cura.ProfileReader import ProfileReader
|
||||||
@ -28,21 +28,75 @@ class CuraProfileReader(ProfileReader):
|
|||||||
def read(self, file_name):
|
def read(self, file_name):
|
||||||
try:
|
try:
|
||||||
archive = zipfile.ZipFile(file_name, "r")
|
archive = zipfile.ZipFile(file_name, "r")
|
||||||
except Exception:
|
results = []
|
||||||
# zipfile doesn't give proper exceptions, so we can only catch broad ones
|
for profile_id in archive.namelist():
|
||||||
|
with archive.open(profile_id) as f:
|
||||||
|
serialized = f.read()
|
||||||
|
profile = self._loadProfile(serialized.decode("utf-8"), profile_id)
|
||||||
|
if profile is not None:
|
||||||
|
results.append(profile)
|
||||||
|
return results
|
||||||
|
|
||||||
|
except zipfile.BadZipFile:
|
||||||
|
# It must be an older profile from Cura 2.1.
|
||||||
|
with open(file_name, encoding="utf-8") as fhandle:
|
||||||
|
serialized = fhandle.read()
|
||||||
|
return [self._loadProfile(serialized, profile_id) for serialized, profile_id in self._upgradeProfile(serialized, file_name)]
|
||||||
|
|
||||||
|
## Convert a profile from an old Cura to this Cura if needed.
|
||||||
|
#
|
||||||
|
# \param serialized \type{str} The profile data to convert in the serialized on-disk format.
|
||||||
|
# \param profile_id \type{str} The name of the profile.
|
||||||
|
# \return \type{List[Tuple[str,str]]} List of serialized profile strings and matching profile names.
|
||||||
|
def _upgradeProfile(self, serialized, profile_id):
|
||||||
|
parser = configparser.ConfigParser(interpolation=None)
|
||||||
|
parser.read_string(serialized)
|
||||||
|
|
||||||
|
if not "general" in parser:
|
||||||
|
Logger.log('w', "Missing required section 'general'.")
|
||||||
|
return None
|
||||||
|
if not "version" in parser["general"]:
|
||||||
|
Logger.log('w', "Missing required 'version' property")
|
||||||
|
return None
|
||||||
|
|
||||||
|
version = int(parser["general"]["version"])
|
||||||
|
if InstanceContainer.Version != version:
|
||||||
|
name = parser["general"]["name"]
|
||||||
|
return self._upgradeProfileVersion(serialized, name, version)
|
||||||
|
else:
|
||||||
|
return [(serialized, profile_id)]
|
||||||
|
|
||||||
|
## Load a profile from a serialized string.
|
||||||
|
#
|
||||||
|
# \param serialized \type{str} The profile data to read.
|
||||||
|
# \param profile_id \type{str} The name of the profile.
|
||||||
|
# \return \type{InstanceContainer|None}
|
||||||
|
def _loadProfile(self, serialized, profile_id):
|
||||||
|
# Create an empty profile.
|
||||||
|
profile = InstanceContainer(profile_id)
|
||||||
|
profile.addMetaDataEntry("type", "quality_changes")
|
||||||
|
try:
|
||||||
|
profile.deserialize(serialized)
|
||||||
|
except Exception as e: # Parsing error. This is not a (valid) Cura profile then.
|
||||||
|
Logger.log("e", "Error while trying to parse profile: %s", str(e))
|
||||||
|
return None
|
||||||
|
return profile
|
||||||
|
|
||||||
|
## Upgrade a serialized profile to the current profile format.
|
||||||
|
#
|
||||||
|
# \param serialized \type{str} The profile data to convert.
|
||||||
|
# \param profile_id \type{str} The name of the profile.
|
||||||
|
# \param source_version \type{int} The profile version of 'serialized'.
|
||||||
|
# \return \type{List[Tuple[str,str]]} List of serialized profile strings and matching profile names.
|
||||||
|
def _upgradeProfileVersion(self, serialized, profile_id, source_version):
|
||||||
|
converter_plugins = PluginRegistry.getInstance().getAllMetaData(filter={"version_upgrade": {} }, active_only=True)
|
||||||
|
|
||||||
|
source_format = ("profile", source_version)
|
||||||
|
profile_convert_funcs = [plugin["version_upgrade"][source_format][2] for plugin in converter_plugins
|
||||||
|
if source_format in plugin["version_upgrade"] and plugin["version_upgrade"][source_format][1] == InstanceContainer.Version]
|
||||||
|
|
||||||
|
if not profile_convert_funcs:
|
||||||
return []
|
return []
|
||||||
results = []
|
|
||||||
for profile_id in archive.namelist():
|
filenames, outputs = profile_convert_funcs[0](serialized, profile_id)
|
||||||
# Create an empty profile.
|
return list(zip(outputs, filenames))
|
||||||
profile = InstanceContainer(profile_id)
|
|
||||||
profile.addMetaDataEntry("type", "quality_changes")
|
|
||||||
serialized = ""
|
|
||||||
with archive.open(profile_id) as f:
|
|
||||||
serialized = f.read()
|
|
||||||
try:
|
|
||||||
profile.deserialize(serialized.decode("utf-8") )
|
|
||||||
except Exception as e: # Parsing error. This is not a (valid) Cura profile then.
|
|
||||||
Logger.log("e", "Error while trying to parse profile: %s", str(e))
|
|
||||||
continue
|
|
||||||
results.append(profile)
|
|
||||||
return results
|
|
||||||
|
@ -70,7 +70,8 @@
|
|||||||
"magic_spiralize": "spiralize",
|
"magic_spiralize": "spiralize",
|
||||||
"prime_tower_enable": "wipe_tower",
|
"prime_tower_enable": "wipe_tower",
|
||||||
"prime_tower_size": "math.sqrt(float(wipe_tower_volume) / float(layer_height))",
|
"prime_tower_size": "math.sqrt(float(wipe_tower_volume) / float(layer_height))",
|
||||||
"ooze_shield_enabled": "ooze_shield"
|
"ooze_shield_enabled": "ooze_shield",
|
||||||
|
"skin_overlap": "fill_overlap"
|
||||||
},
|
},
|
||||||
|
|
||||||
"defaults": {
|
"defaults": {
|
||||||
|
@ -69,7 +69,7 @@ class PerObjectSettingVisibilityHandler(UM.Settings.Models.SettingVisibilityHand
|
|||||||
stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = ExtruderManager.getInstance().extruderIds[stack_nr])[0]
|
stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = ExtruderManager.getInstance().extruderIds[stack_nr])[0]
|
||||||
else:
|
else:
|
||||||
stack = UM.Application.getInstance().getGlobalContainerStack()
|
stack = UM.Application.getInstance().getGlobalContainerStack()
|
||||||
new_instance.setProperty("value", stack.getProperty(item, "value"))
|
new_instance.setProperty("value", stack.getRawProperty(item, "value"))
|
||||||
new_instance.resetState() # Ensure that the state is not seen as a user state.
|
new_instance.resetState() # Ensure that the state is not seen as a user state.
|
||||||
settings.addInstance(new_instance)
|
settings.addInstance(new_instance)
|
||||||
visibility_changed = True
|
visibility_changed = True
|
||||||
|
@ -279,6 +279,8 @@ class VersionUpgrade21to22(VersionUpgrade):
|
|||||||
elif key in _setting_name_translations:
|
elif key in _setting_name_translations:
|
||||||
del settings[key]
|
del settings[key]
|
||||||
settings[_setting_name_translations[key]] = value
|
settings[_setting_name_translations[key]] = value
|
||||||
|
if "infill_overlap" in settings: # New setting, added in 2.3
|
||||||
|
settings["skin_overlap"] = settings["infill_overlap"]
|
||||||
return settings
|
return settings
|
||||||
|
|
||||||
## Translates a setting name for the change from Cura 2.1 to 2.2.
|
## Translates a setting name for the change from Cura 2.1 to 2.2.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user