From a7135a0f5fea764b442734a87e2dba07f333d376 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 16 Dec 2016 10:38:30 +0100 Subject: [PATCH] Added machine type to load menu CURA-1263 --- plugins/3MFReader/ThreeMFWorkspaceReader.py | 18 ++++++++++++++++++ plugins/3MFReader/WorkspaceDialog.py | 10 ++++++++++ plugins/3MFReader/WorkspaceDialog.qml | 15 +++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 4a5300f9f0..b4de6c0736 100644 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -55,7 +55,9 @@ class ThreeMFWorkspaceReader(WorkspaceReader): Logger.log("w", "Could not find reader that was able to read the scene data for 3MF workspace") return WorkspaceReader.PreReadResult.failed + machine_name = "" + machine_type = "" # Check if there are any conflicts, so we can ask the user. archive = zipfile.ZipFile(file_name, "r") cura_file_names = [name for name in archive.namelist() if name.startswith("Cura/")] @@ -77,6 +79,21 @@ class ThreeMFWorkspaceReader(WorkspaceReader): machine_conflict = True Job.yieldThread() + definition_container_files = [name for name in cura_file_names if name.endswith(self._definition_container_suffix)] + for definition_container_file in definition_container_files: + container_id = self._stripFileToId(definition_container_file) + definitions = self._container_registry.findDefinitionContainers(id=container_id) + + if not definitions: + definition_container = DefinitionContainer(container_id) + definition_container.deserialize(archive.open(definition_container_file).read().decode("utf-8")) + if definition_container.getMetaDataEntry("type") != "extruder": + machine_type = definition_container.getName() + else: + if definitions[0].getMetaDataEntry("type") != "extruder": + machine_type = definitions[0].getName() + Job.yieldThread() + material_labels = [] material_conflict = False xml_material_profile = self._getXmlProfileClass() @@ -150,6 +167,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): self._dialog.setActiveMode(active_mode) self._dialog.setMachineName(machine_name) self._dialog.setMaterialLabels(material_labels) + self._dialog.setMachineType(machine_type) self._dialog.setHasObjectsOnPlate(Application.getInstance().getPlatformActivity) self._dialog.show() diff --git a/plugins/3MFReader/WorkspaceDialog.py b/plugins/3MFReader/WorkspaceDialog.py index f8bec06dd4..ec2509252b 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -42,6 +42,7 @@ class WorkspaceDialog(QObject): self._num_settings_overriden_by_quality_changes = 0 self._quality_type = "" self._machine_name = "" + self._machine_type = "" self._material_labels = [] self._objects_on_plate = False @@ -57,6 +58,15 @@ class WorkspaceDialog(QObject): materialLabelsChanged = pyqtSignal() objectsOnPlateChanged = pyqtSignal() numUserSettingsChanged = pyqtSignal() + machineTypeChanged = pyqtSignal() + + @pyqtProperty(str, notify=machineTypeChanged) + def machineType(self): + return self._machine_type + + def setMachineType(self, machine_type): + self._machine_type = machine_type + self.machineTypeChanged.emit() def setNumUserSettings(self, num_user_settings): self._num_user_settings = num_user_settings diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index f9e5a02f8e..3d30d17d25 100644 --- a/plugins/3MFReader/WorkspaceDialog.qml +++ b/plugins/3MFReader/WorkspaceDialog.qml @@ -82,6 +82,21 @@ UM.Dialog text: catalog.i18nc("@action:label", "Printer settings") font.bold: true } + Row + { + width: parent.width + height: childrenRect.height + Label + { + text: catalog.i18nc("@action:label", "Type") + width: parent.width / 3 + } + Label + { + text: manager.machineType + width: parent.width / 3 + } + } Row {