From 0828d4f1cab5f1934e121b224f2b1cb5a200d017 Mon Sep 17 00:00:00 2001 From: fieldOfView Date: Thu, 8 Sep 2016 21:11:08 +0200 Subject: [PATCH 01/11] Fix dirty flag of incompatible_materials --- plugins/XmlMaterialProfile/XmlMaterialProfile.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index be8f5146c9..caae447ec3 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -507,7 +507,9 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): # Change the type of this container so it is not shown as an option in menus. # This uses InstanceContainer.setMetaDataEntry because otherwise all containers that # share this basefile are also updated. + dirty = self.isDirty() super().setMetaDataEntry("type", "incompatible_material") + super().setDirty(dirty) # reset dirty flag after setMetaDataEntry def _addSettingElement(self, builder, instance): try: From d34f54a3c723687afa82d7ae1431f574ff81b82b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Sep 2016 10:29:16 +0200 Subject: [PATCH 02/11] Right type is now returned if metadata entry is not found CURA-2242 --- cura/Settings/ContainerManager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index 27a9bd90dd..08d638033b 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -172,7 +172,7 @@ class ContainerManager(QObject): containers = self._container_registry.findContainers(None, id=container_id) if not containers: UM.Logger.log("w", "Could not get metadata of container %s because it was not found.", container_id) - return False + return "" result = containers[0].getMetaDataEntry(entry_name) if result: From 97700373982f03982e9f1fd07dfd54b2f3118f2c Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Sep 2016 11:44:41 +0200 Subject: [PATCH 03/11] If setting is false, it will still return false (instead of empty string) CURA-2271 --- cura/Settings/ContainerManager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cura/Settings/ContainerManager.py b/cura/Settings/ContainerManager.py index f5b94cfc7a..f7ea9bd416 100644 --- a/cura/Settings/ContainerManager.py +++ b/cura/Settings/ContainerManager.py @@ -175,8 +175,8 @@ class ContainerManager(QObject): return "" result = containers[0].getMetaDataEntry(entry_name) - if result: - return result + if result is not None: + return str(result) else: return "" From e0b6e31056028780d2a92d4d322e74b768da3904 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Sep 2016 11:48:01 +0200 Subject: [PATCH 04/11] Added way to mark toolbutton as error aswell CURA-2271 --- resources/themes/cura/styles.qml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/resources/themes/cura/styles.qml b/resources/themes/cura/styles.qml index 91a512b6db..96bbf03a45 100644 --- a/resources/themes/cura/styles.qml +++ b/resources/themes/cura/styles.qml @@ -15,7 +15,11 @@ QtObject { { if(control.enabled) { - if(control.valueWarning) + if(control.valueError) + { + return Theme.getColor("setting_validation_error"); + } + else if(control.valueWarning) { return Theme.getColor("setting_validation_warning"); } else From d68f6a4e9a2bb01e4fe1cd6f086aa7c1705ecf87 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Sep 2016 11:57:34 +0200 Subject: [PATCH 05/11] Instead of discarding a profile if it's not compatible, we mark it as such. The old approach was far to naive. We actually have 3 states; - Supported (we have a profile) - Not supported (Don't have a profile) - Don't do this, lest you awaken the Old Gods (Error) In case 1 and 3 we now do have a profile. CURA-2271 --- plugins/XmlMaterialProfile/XmlMaterialProfile.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index caae447ec3..fa5f4bf33b 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -428,8 +428,8 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): for identifier in identifiers: machine_id = self.__product_id_map.get(identifier.get("product"), None) if machine_id is None: - Logger.log("w", "Cannot create material for unknown machine %s", identifier.get("product")) - continue + # Lets try again with some naive heuristics. + machine_id = identifier.get("product").replace(" ", "").lower() definitions = UM.Settings.ContainerRegistry.getInstance().findDefinitionContainers(id = machine_id) if not definitions: @@ -454,6 +454,7 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): UM.Settings.ContainerRegistry.getInstance().addContainer(new_material) + hotends = machine.iterfind("./um:hotend", self.__namespaces) for hotend in hotends: hotend_id = hotend.get("id") @@ -482,14 +483,12 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): else: Logger.log("d", "Unsupported material setting %s", key) - if not hotend_compatibility: - continue - new_hotend_material = XmlMaterialProfile(self.id + "_" + machine_id + "_" + hotend_id.replace(" ", "_")) new_hotend_material.setName(self.getName()) new_hotend_material.setMetaData(copy.deepcopy(self.getMetaData())) new_hotend_material.setDefinition(definition) new_hotend_material.addMetaDataEntry("variant", variant_containers[0].id) + new_hotend_material.addMetaDataEntry("compatible", hotend_compatibility) for key, value in global_setting_values.items(): new_hotend_material.setProperty(key, "value", value, definition) From ec587eb0dd76aa88178c6f923e94c08ab09b0ae2 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Sep 2016 11:59:55 +0200 Subject: [PATCH 06/11] If a combination material does not like the setup, we now mark it in red. CURA-2271 --- resources/qml/SidebarHeader.qml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/resources/qml/SidebarHeader.qml b/resources/qml/SidebarHeader.qml index c9c0e722eb..6f9338d23c 100644 --- a/resources/qml/SidebarHeader.qml +++ b/resources/qml/SidebarHeader.qml @@ -232,6 +232,19 @@ Column text: Cura.MachineManager.activeMaterialName tooltip: Cura.MachineManager.activeMaterialName visible: Cura.MachineManager.hasMaterials + property var valueError: + { + var data = Cura.ContainerManager.getContainerMetaDataEntry(Cura.MachineManager.activeMaterialId, "compatible") + print(data) + if(data == "" || data == "True") + { + return false + } + if(data == "False") + { + return true + } + } enabled: !extrudersList.visible || base.currentExtruderIndex > -1 height: UM.Theme.getSize("setting_control").height From 2441275f2972db33a34fc2d19851ad64e3575d39 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Sep 2016 12:57:50 +0200 Subject: [PATCH 07/11] Added message when incompatbile material is selected CURA-2271 --- cura/Settings/MachineManager.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 0849786320..1324f3ab60 100644 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -531,6 +531,12 @@ class MachineManager(QObject): containers[0].nameChanged.connect(self._onMaterialNameChanged) + if containers[0].getMetaDataEntry("compatible") == False: + message = Message(catalog.i18nc("@info:status", + "The selected material is imcompatible with the selected machine or configuration.")) + message.show() + + if old_quality: if old_quality_changes: new_quality = self._updateQualityChangesContainer(old_quality.getMetaDataEntry("quality_type"), old_quality_changes.getMetaDataEntry("name")) From 677d6556fbde47971fb7b4da8112b7d4d1f0312b Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Sep 2016 13:02:19 +0200 Subject: [PATCH 08/11] Refuse to slice when material is mismatched CURA-2271 --- plugins/CuraEngineBackend/StartSliceJob.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/CuraEngineBackend/StartSliceJob.py b/plugins/CuraEngineBackend/StartSliceJob.py index fc26bd086b..efc36e6150 100644 --- a/plugins/CuraEngineBackend/StartSliceJob.py +++ b/plugins/CuraEngineBackend/StartSliceJob.py @@ -82,6 +82,13 @@ class StartSliceJob(Job): self.setResult(StartJobResult.SettingError) return + for extruder_stack in cura.Settings.ExtruderManager.getInstance().getMachineExtruders(stack.getId()): + material = extruder_stack.findContainer({"type": "material"}) + if material: + if material.getMetaDataEntry("compatible") == False: + self.setResult(StartJobResult.SettingError) + return + # Don't slice if there is a per object setting with an error value. for node in DepthFirstIterator(self._scene.getRoot()): if type(node) is not SceneNode or not node.isSelectable(): From f81a5fe3017d37106ad3d96f26d152f151a7f133 Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Sep 2016 13:09:15 +0200 Subject: [PATCH 09/11] Removed very annoying message spam CURA-2159 --- plugins/XmlMaterialProfile/XmlMaterialProfile.py | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index fa5f4bf33b..1679e8f30d 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -83,7 +83,6 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): # machine / variant combination: only changes for itself. def serialize(self): if self._read_only: - Logger.log("w", "Serializing read-only container [%s], probably a programming error." % self.id) return registry = UM.Settings.ContainerRegistry.getInstance() From c2341f7cd275fca76c3d978637f03f3143caf73d Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Sep 2016 13:23:22 +0200 Subject: [PATCH 10/11] Upgrade profile function now returns empty list if something went wrong. Fixes CURA-1493 --- plugins/CuraProfileReader/CuraProfileReader.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/CuraProfileReader/CuraProfileReader.py b/plugins/CuraProfileReader/CuraProfileReader.py index 2bccb8e3cb..d1be5b59a8 100644 --- a/plugins/CuraProfileReader/CuraProfileReader.py +++ b/plugins/CuraProfileReader/CuraProfileReader.py @@ -54,10 +54,10 @@ class CuraProfileReader(ProfileReader): if not "general" in parser: Logger.log("w", "Missing required section 'general'.") - return None + return [] if not "version" in parser["general"]: Logger.log("w", "Missing required 'version' property") - return None + return [] version = int(parser["general"]["version"]) if InstanceContainer.Version != version: From f6c1a46d22310a7f396884296030a3f5ed13b7ae Mon Sep 17 00:00:00 2001 From: Jaime van Kessel Date: Fri, 9 Sep 2016 13:28:12 +0200 Subject: [PATCH 11/11] Remove commented out code CURA-2234 --- cura/BuildVolume.py | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cura/BuildVolume.py b/cura/BuildVolume.py index a25604d165..91aa5a176d 100644 --- a/cura/BuildVolume.py +++ b/cura/BuildVolume.py @@ -338,13 +338,6 @@ class BuildVolume(SceneNode): prime_tower_x = self._global_container_stack.getProperty("prime_tower_position_x", "value") - machine_width / 2 prime_tower_y = - self._global_container_stack.getProperty("prime_tower_position_y", "value") + machine_depth / 2 - '''disallowed_areas.append([ - [prime_tower_x - prime_tower_size, prime_tower_y - prime_tower_size], - [prime_tower_x, prime_tower_y - prime_tower_size], - [prime_tower_x, prime_tower_y], - [prime_tower_x - prime_tower_size, prime_tower_y], - ])''' - self._prime_tower_area = Polygon([ [prime_tower_x - prime_tower_size, prime_tower_y - prime_tower_size], [prime_tower_x, prime_tower_y - prime_tower_size],