diff --git a/plugins/3MFReader/ThreeMFWorkspaceReader.py b/plugins/3MFReader/ThreeMFWorkspaceReader.py index 1454dc9a47..b4de6c0736 100644 --- a/plugins/3MFReader/ThreeMFWorkspaceReader.py +++ b/plugins/3MFReader/ThreeMFWorkspaceReader.py @@ -54,7 +54,10 @@ class ThreeMFWorkspaceReader(WorkspaceReader): else: 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/")] @@ -76,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() @@ -95,6 +113,7 @@ class ThreeMFWorkspaceReader(WorkspaceReader): quality_name = "" quality_type = "" num_settings_overriden_by_quality_changes = 0 # How many settings are changed by the quality changes + num_user_settings = 0 for instance_container_file in instance_container_files: container_id = self._stripFileToId(instance_container_file) instance_container = InstanceContainer(container_id) @@ -117,6 +136,8 @@ class ThreeMFWorkspaceReader(WorkspaceReader): if quality_name == "": quality_name = instance_container.getName() quality_type = instance_container.getName() + elif container_type == "user": + num_user_settings += len(instance_container._instances) Job.yieldThread() num_visible_settings = 0 try: @@ -142,9 +163,11 @@ class ThreeMFWorkspaceReader(WorkspaceReader): self._dialog.setQualityName(quality_name) self._dialog.setQualityType(quality_type) self._dialog.setNumSettingsOverridenByQualityChanges(num_settings_overriden_by_quality_changes) + self._dialog.setNumUserSettings(num_user_settings) 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 e3425078e7..ec2509252b 100644 --- a/plugins/3MFReader/WorkspaceDialog.py +++ b/plugins/3MFReader/WorkspaceDialog.py @@ -36,11 +36,13 @@ class WorkspaceDialog(QObject): self._has_machine_conflict = False self._has_material_conflict = False self._num_visible_settings = 0 + self._num_user_settings = 0 self._active_mode = "" self._quality_name = "" 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 @@ -55,6 +57,24 @@ class WorkspaceDialog(QObject): machineNameChanged = pyqtSignal() 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 + self.numVisibleSettingsChanged.emit() + + @pyqtProperty(int, notify=numUserSettingsChanged) + def numUserSettings(self): + return self._num_user_settings @pyqtProperty(bool, notify=objectsOnPlateChanged) def hasObjectsOnPlate(self): diff --git a/plugins/3MFReader/WorkspaceDialog.qml b/plugins/3MFReader/WorkspaceDialog.qml index fa69bc08c7..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 { @@ -168,7 +183,23 @@ UM.Dialog Row { width: parent.width - height: childrenRect.height + height: manager.numUserSettings != 0 ? childrenRect.height : 0 + Label + { + text: catalog.i18nc("@action:label", "Not in profile") + width: parent.width / 3 + } + Label + { + text: catalog.i18nc("@action:label", "%1 override(s)").arg(manager.numUserSettings) + width: parent.width / 3 + } + visible: manager.numUserSettings != 0 + } + Row + { + width: parent.width + height: manager.numSettingsOverridenByQualityChanges != 0 ? childrenRect.height : 0 Label { text: catalog.i18nc("@action:label", "Derivative from") diff --git a/plugins/USBPrinting/USBPrinterOutputDevice.py b/plugins/USBPrinting/USBPrinterOutputDevice.py index 61e0a479f3..e344caee1d 100644 --- a/plugins/USBPrinting/USBPrinterOutputDevice.py +++ b/plugins/USBPrinting/USBPrinterOutputDevice.py @@ -313,6 +313,7 @@ class USBPrinterOutputDevice(PrinterOutputDevice): if self._serial is None: try: self._serial = serial.Serial(str(self._serial_port), baud_rate, timeout = 3, writeTimeout = 10000) + time.sleep(10) except serial.SerialException: Logger.log("d", "Could not open port %s" % self._serial_port) continue