From 384618b5c4db9192e1f0d8e3fae1f220d63c15c3 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Thu, 7 Jun 2018 15:49:00 +0200 Subject: [PATCH 1/5] Fix branded materials model binding CURA-5336 When the global stack gets changed, the model should update itself so it refers to the correct extruder stack. --- cura/Machines/Models/BrandMaterialsModel.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/cura/Machines/Models/BrandMaterialsModel.py b/cura/Machines/Models/BrandMaterialsModel.py index f6c9a14632..236f105d12 100644 --- a/cura/Machines/Models/BrandMaterialsModel.py +++ b/cura/Machines/Models/BrandMaterialsModel.py @@ -47,22 +47,38 @@ class BrandMaterialsModel(ListModel): self.addRoleName(self.MaterialsRole, "materials") self._extruder_position = 0 + self._extruder_stack = None from cura.CuraApplication import CuraApplication self._machine_manager = CuraApplication.getInstance().getMachineManager() self._extruder_manager = CuraApplication.getInstance().getExtruderManager() self._material_manager = CuraApplication.getInstance().getMaterialManager() + self._machine_manager.globalContainerChanged.connect(self._updateExtruderStack) self._machine_manager.activeStackChanged.connect(self._update) #Update when switching machines. self._material_manager.materialsUpdated.connect(self._update) #Update when the list of materials changes. self._update() + def _updateExtruderStack(self): + global_stack = self._machine_manager.activeMachine + if global_stack is None: + return + + if self._extruder_stack is not None: + self._extruder_stack.pyqtContainersChanged.disconnect(self._update) + self._extruder_stack = global_stack.extruders.get(str(self._extruder_position)) + if self._extruder_stack is not None: + self._extruder_stack.pyqtContainersChanged.connect(self._update) + # Force update the model when the extruder stack changes + self._update() + def setExtruderPosition(self, position: int): - if self._extruder_position != position: + if self._extruder_stack is None or self._extruder_position != position: self._extruder_position = position + self._updateExtruderStack() self.extruderPositionChanged.emit() - @pyqtProperty(int, fset = setExtruderPosition, notify = extruderPositionChanged) + @pyqtProperty(int, fset=setExtruderPosition, notify=extruderPositionChanged) def extruderPosition(self) -> int: return self._extruder_position From b55d2eda4f684f5707b6693d189d282956d77340 Mon Sep 17 00:00:00 2001 From: Ghostkeeper Date: Mon, 11 Jun 2018 09:14:48 +0200 Subject: [PATCH 2/5] Remove Polish translation option The translator said he won't be maintaining this language any more. Someone else can pick it up now if he wants to, but we'll disable the language until it is complete again. Contributes to issue CURA-5451. --- resources/qml/Preferences/GeneralPage.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/qml/Preferences/GeneralPage.qml b/resources/qml/Preferences/GeneralPage.qml index 7841c7d506..5de74ac3a8 100644 --- a/resources/qml/Preferences/GeneralPage.qml +++ b/resources/qml/Preferences/GeneralPage.qml @@ -170,7 +170,7 @@ UM.PreferencesPage append({ text: "日本語", code: "ja_JP" }) append({ text: "한국어", code: "ko_KR" }) append({ text: "Nederlands", code: "nl_NL" }) - append({ text: "Polski", code: "pl_PL" }) + //Polish is disabled for being incomplete: append({ text: "Polski", code: "pl_PL" }) append({ text: "Português do Brasil", code: "pt_BR" }) append({ text: "Português", code: "pt_PT" }) append({ text: "Русский", code: "ru_RU" }) From dc1e36d726a4ea5a3f865ffc93170ff453687fa1 Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 8 Jun 2018 11:21:17 +0200 Subject: [PATCH 3/5] CURA-5444 Always create the instance of the material even if it is not compatible, otherwise it will never show as incompatible if the material profile doesn't define hotends in the machine. --- .../XmlMaterialProfile/XmlMaterialProfile.py | 49 ++++++++++--------- plugins/XmlMaterialProfile/product_to_id.json | 1 + 2 files changed, 26 insertions(+), 24 deletions(-) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index 148471fb6d..241ec2a711 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -632,35 +632,36 @@ class XmlMaterialProfile(InstanceContainer): machine_manufacturer = identifier.get("manufacturer", definition.get("manufacturer", "Unknown")) #If the XML material doesn't specify a manufacturer, use the one in the actual printer definition. - if machine_compatibility: - new_material_id = self.getId() + "_" + machine_id + # Always create the instance of the material even if it is not compatible, otherwise it will never + # show as incompatible if the material profile doesn't define hotends in the machine - CURA-5444 + new_material_id = self.getId() + "_" + machine_id - # The child or derived material container may already exist. This can happen when a material in a - # project file and the a material in Cura have the same ID. - # In the case if a derived material already exists, override that material container because if - # the data in the parent material has been changed, the derived ones should be updated too. - if ContainerRegistry.getInstance().isLoaded(new_material_id): - new_material = ContainerRegistry.getInstance().findContainers(id = new_material_id)[0] - is_new_material = False - else: - new_material = XmlMaterialProfile(new_material_id) - is_new_material = True + # The child or derived material container may already exist. This can happen when a material in a + # project file and the a material in Cura have the same ID. + # In the case if a derived material already exists, override that material container because if + # the data in the parent material has been changed, the derived ones should be updated too. + if ContainerRegistry.getInstance().isLoaded(new_material_id): + new_material = ContainerRegistry.getInstance().findContainers(id = new_material_id)[0] + is_new_material = False + else: + new_material = XmlMaterialProfile(new_material_id) + is_new_material = True - new_material.setMetaData(copy.deepcopy(self.getMetaData())) - new_material.getMetaData()["id"] = new_material_id - new_material.getMetaData()["name"] = self.getName() - new_material.setDefinition(machine_id) - # Don't use setMetadata, as that overrides it for all materials with same base file - new_material.getMetaData()["compatible"] = machine_compatibility - new_material.getMetaData()["machine_manufacturer"] = machine_manufacturer - new_material.getMetaData()["definition"] = machine_id + new_material.setMetaData(copy.deepcopy(self.getMetaData())) + new_material.getMetaData()["id"] = new_material_id + new_material.getMetaData()["name"] = self.getName() + new_material.setDefinition(machine_id) + # Don't use setMetadata, as that overrides it for all materials with same base file + new_material.getMetaData()["compatible"] = machine_compatibility + new_material.getMetaData()["machine_manufacturer"] = machine_manufacturer + new_material.getMetaData()["definition"] = machine_id - new_material.setCachedValues(cached_machine_setting_properties) + new_material.setCachedValues(cached_machine_setting_properties) - new_material._dirty = False + new_material._dirty = False - if is_new_material: - containers_to_add.append(new_material) + if is_new_material: + containers_to_add.append(new_material) # Find the buildplates compatibility buildplates = machine.iterfind("./um:buildplate", self.__namespaces) diff --git a/plugins/XmlMaterialProfile/product_to_id.json b/plugins/XmlMaterialProfile/product_to_id.json index d6b8f3bade..3e7ce9311f 100644 --- a/plugins/XmlMaterialProfile/product_to_id.json +++ b/plugins/XmlMaterialProfile/product_to_id.json @@ -8,5 +8,6 @@ "Ultimaker 3 Extended": "ultimaker3_extended", "Ultimaker Original": "ultimaker_original", "Ultimaker Original+": "ultimaker_original_plus", + "Ultimaker Original Dual Extrusion": "ultimaker_original_dual", "IMADE3D JellyBOX": "imade3d_jellybox" } \ No newline at end of file From 8c9939e797886e214dc17db793e111ab66ecb17c Mon Sep 17 00:00:00 2001 From: Diego Prado Gesto Date: Fri, 8 Jun 2018 12:03:46 +0200 Subject: [PATCH 4/5] CURA-5444 Also get the metadata even if the material was marked as not compatible. --- .../XmlMaterialProfile/XmlMaterialProfile.py | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index 241ec2a711..4985c2fd87 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -872,22 +872,23 @@ class XmlMaterialProfile(InstanceContainer): machine_manufacturer = identifier.get("manufacturer", definition_metadata.get("manufacturer", "Unknown")) #If the XML material doesn't specify a manufacturer, use the one in the actual printer definition. - if machine_compatibility: - new_material_id = container_id + "_" + machine_id + # Always create the instance of the material even if it is not compatible, otherwise it will never + # show as incompatible if the material profile doesn't define hotends in the machine - CURA-5444 + new_material_id = container_id + "_" + machine_id - # Do not look for existing container/container metadata with the same ID although they may exist. - # In project loading and perhaps some other places, we only want to get information (metadata) - # from a file without changing the current state of the system. If we overwrite the existing - # metadata here, deserializeMetadata() will not be safe for retrieving information. - new_material_metadata = {} + # Do not look for existing container/container metadata with the same ID although they may exist. + # In project loading and perhaps some other places, we only want to get information (metadata) + # from a file without changing the current state of the system. If we overwrite the existing + # metadata here, deserializeMetadata() will not be safe for retrieving information. + new_material_metadata = {} - new_material_metadata.update(base_metadata) - new_material_metadata["id"] = new_material_id - new_material_metadata["compatible"] = machine_compatibility - new_material_metadata["machine_manufacturer"] = machine_manufacturer - new_material_metadata["definition"] = machine_id + new_material_metadata.update(base_metadata) + new_material_metadata["id"] = new_material_id + new_material_metadata["compatible"] = machine_compatibility + new_material_metadata["machine_manufacturer"] = machine_manufacturer + new_material_metadata["definition"] = machine_id - result_metadata.append(new_material_metadata) + result_metadata.append(new_material_metadata) buildplates = machine.iterfind("./um:buildplate", cls.__namespaces) buildplate_map = {} From 310a99fba70b67253af482fa09ad7fe1e59679d3 Mon Sep 17 00:00:00 2001 From: Lipu Fei Date: Mon, 11 Jun 2018 11:31:28 +0200 Subject: [PATCH 5/5] Fix deepcopy in SettingOverrideDecorator Obvious mistake... --- cura/Settings/SettingOverrideDecorator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Settings/SettingOverrideDecorator.py b/cura/Settings/SettingOverrideDecorator.py index a662027d8f..27ae1d69f0 100644 --- a/cura/Settings/SettingOverrideDecorator.py +++ b/cura/Settings/SettingOverrideDecorator.py @@ -63,7 +63,7 @@ class SettingOverrideDecorator(SceneNodeDecorator): instance_container = copy.deepcopy(self._stack.getContainer(0), memo) # A unique name must be added, or replaceContainer will not replace it - instance_container.setMetaDataEntry("id", self._generateUniqueName) + instance_container.setMetaDataEntry("id", self._generateUniqueName()) ## Set the copied instance as the first (and only) instance container of the stack. deep_copy._stack.replaceContainer(0, instance_container)