Revert "Revert "Merge branch '4.7' of github.com:Ultimaker/Cura into 4.7""

This reverts commit 28f4d8513d.
The original revert was to revert an accidental merge from master to 4.7. This now reverts the revert on Master, so that we still have those changes on Master.
This commit is contained in:
Ghostkeeper 2020-08-20 16:35:52 +02:00
parent a757dc7fa0
commit 9ea418c0a1
No known key found for this signature in database
GPG key ID: D2A8871EE34EC59A
12 changed files with 278 additions and 143 deletions

View file

@ -133,12 +133,10 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# In Cura 2.5 and 2.6, the empty profiles used to have those long names
self._old_empty_profile_id_dict = {"empty_%s" % k: "empty" for k in ["material", "variant"]}
self._is_same_machine_type = False
self._old_new_materials = {} # type: Dict[str, str]
self._machine_info = None
def _clearState(self):
self._is_same_machine_type = False
self._id_mapping = {}
self._old_new_materials = {}
self._machine_info = None
@ -229,6 +227,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
# Read definition containers
#
machine_definition_id = None
updatable_machines = []
machine_definition_container_count = 0
extruder_definition_container_count = 0
definition_container_files = [name for name in cura_file_names if name.endswith(self._definition_container_suffix)]
@ -245,6 +244,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
definition_container_type = definition_container.get("type")
if definition_container_type == "machine":
machine_definition_id = container_id
machine_definition_containers = self._container_registry.findDefinitionContainers(id = machine_definition_id)
if machine_definition_containers:
updatable_machines = [machine for machine in self._container_registry.findContainerStacks(type = "machine") if machine.definition == machine_definition_containers[0]]
machine_type = definition_container["name"]
variant_type_name = definition_container.get("variants_name", variant_type_name)
@ -386,8 +388,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
machine_definition_id = id_list[7]
stacks = self._container_registry.findContainerStacks(name = machine_name, type = "machine")
self._is_same_machine_type = True
existing_global_stack = None
global_stack = None
if stacks:
global_stack = stacks[0]
@ -400,7 +402,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
if global_stack.getContainer(index).getId() != container_id:
machine_conflict = True
break
self._is_same_machine_type = global_stack.definition.getId() == machine_definition_id
if updatable_machines and not containers_found_dict["machine"]:
containers_found_dict["machine"] = True
# Get quality type
parser = ConfigParser(interpolation = None)
@ -485,7 +489,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
if intent_id not in ("empty", "empty_intent"):
extruder_info.intent_info = instance_container_info_dict[intent_id]
if not machine_conflict and containers_found_dict["machine"]:
if not machine_conflict and containers_found_dict["machine"] and global_stack:
if int(position) >= len(global_stack.extruderList):
continue
@ -558,9 +562,6 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
self._machine_info.custom_quality_name = quality_name
self._machine_info.intent_category = intent_category
if machine_conflict and not self._is_same_machine_type:
machine_conflict = False
is_printer_group = False
if machine_conflict:
group_name = existing_global_stack.getMetaDataEntry("group_name")
@ -581,6 +582,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
self._dialog.setNumSettingsOverriddenByQualityChanges(num_settings_overridden_by_quality_changes)
self._dialog.setNumUserSettings(num_user_settings)
self._dialog.setActiveMode(active_mode)
self._dialog.setUpdatableMachines(updatable_machines)
self._dialog.setMachineName(machine_name)
self._dialog.setMaterialLabels(material_labels)
self._dialog.setMachineType(machine_type)
@ -661,8 +663,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
application.expandedCategoriesChanged.emit() # Notify the GUI of the change
# If a machine with the same name is of a different type, always create a new one.
if not self._is_same_machine_type or self._resolve_strategies["machine"] != "override":
# If there are no machines of the same type, create a new machine.
if self._resolve_strategies["machine"] != "override" or self._dialog.updatableMachinesModel.count <= 1:
# We need to create a new machine
machine_name = self._container_registry.uniqueName(self._machine_info.name)
@ -677,10 +679,12 @@ class ThreeMFWorkspaceReader(WorkspaceReader):
self._container_registry.addContainer(global_stack)
else:
# Find the machine
global_stacks = self._container_registry.findContainerStacks(name = self._machine_info.name, type = "machine")
# Find the machine which will be overridden
global_stacks = self._container_registry.findContainerStacks(id = self._dialog.getMachineToOverride(), type = "machine")
if not global_stacks:
message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tag <filename>!", "Project file <filename>{0}</filename> is made using profiles that are unknown to this version of Ultimaker Cura.", file_name))
message = Message(i18n_catalog.i18nc("@info:error Don't translate the XML tag <filename>!",
"Project file <filename>{0}</filename> is made using profiles that"
" are unknown to this version of Ultimaker Cura.", file_name))
message.show()
self.setWorkspaceName("")
return [], {}