Browse Source

Merge remote-tracking branch 'origin/master' into CURA-6863_duplicated_material_oddness

Lipu Fei 5 years ago
parent
commit
8b913f4009

+ 0 - 1
cura/Machines/MachineErrorChecker.py

@@ -58,7 +58,6 @@ class MachineErrorChecker(QObject):
 
         # Whenever the machine settings get changed, we schedule an error check.
         self._machine_manager.globalContainerChanged.connect(self.startErrorCheck)
-        self._machine_manager.globalValueChanged.connect(self.startErrorCheck)
 
         self._onMachineChanged()
 

+ 2 - 2
cura/Machines/MachineNode.py

@@ -85,9 +85,9 @@ class MachineNode(ContainerNode):
                 continue
             quality_groups[quality_type] = QualityGroup(name = global_quality_node.getMetaDataEntry("name", "Unnamed profile"), quality_type = quality_type)
             quality_groups[quality_type].node_for_global = global_quality_node
-            for extruder, qualities_per_type in enumerate(qualities_per_type_per_extruder):
+            for extruder_position, qualities_per_type in enumerate(qualities_per_type_per_extruder):
                 if quality_type in qualities_per_type:
-                    quality_groups[quality_type].nodes_for_extruders[extruder] = qualities_per_type[quality_type]
+                    quality_groups[quality_type].setExtruderNode(extruder_position, qualities_per_type[quality_type])
 
         available_quality_types = set(quality_groups.keys())
         for extruder_nr, qualities_per_type in enumerate(qualities_per_type_per_extruder):

+ 1 - 1
cura/Machines/VariantNode.py

@@ -83,7 +83,7 @@ class VariantNode(ContainerNode):
                 return material_node
         # First fallback: Choose any material with matching diameter.
         for material_node in self.materials.values():
-            if approximate_diameter == int(material_node.getMetaDataEntry("approximate_diameter")):
+            if material_node.getMetaDataEntry("approximate_diameter") and approximate_diameter == int(material_node.getMetaDataEntry("approximate_diameter")):
                 return material_node
         fallback = next(iter(self.materials.values()))  # Should only happen with empty material node.
         Logger.log("w", "Could not find preferred material {preferred_material} with diameter {diameter} for variant {variant_id}, falling back to {fallback}.".format(

+ 8 - 0
cura/PrinterOutput/Models/MaterialOutputModel.py

@@ -34,3 +34,11 @@ class MaterialOutputModel(QObject):
     @pyqtProperty(str, constant = True)
     def name(self) -> str:
         return self._name
+
+    def __eq__(self, other):
+        if self is other:
+            return True
+        if type(other) is not MaterialOutputModel:
+            return False
+
+        return self.guid == other.guid and self.type == other.type and self.brand == other.brand and self.color == other.color and self.name == other.name

+ 8 - 0
cura/Settings/GlobalStack.py

@@ -131,6 +131,14 @@ class GlobalStack(CuraContainerStack):
             return "machine_stack"
         return configuration_type
 
+    def getIntentCategory(self) -> str:
+        intent_category = "default"
+        for extruder in self.extruderList:
+            category = extruder.intent.getMetaDataEntry("intent_category", "default")
+            if category != "default" and category != intent_category:
+                intent_category = category
+        return intent_category
+
     def getBuildplateName(self) -> Optional[str]:
         name = None
         if self.variant.getId() != "empty_variant":

+ 12 - 30
cura/Settings/MachineManager.py

@@ -95,7 +95,6 @@ class MachineManager(QObject):
         extruder_manager.activeExtruderChanged.connect(self.activeQualityChanged)
 
         self.globalContainerChanged.connect(self.activeStackChanged)
-        self.globalValueChanged.connect(self.activeStackValueChanged)
         ExtruderManager.getInstance().activeExtruderChanged.connect(self.activeStackChanged)
         self.activeStackChanged.connect(self.activeStackValueChanged)
 
@@ -143,7 +142,6 @@ class MachineManager(QObject):
     activeStackChanged = pyqtSignal()  # Emitted whenever the active stack is changed (ie: when changing between extruders, changing a profile, but not when changing a value)
     extruderChanged = pyqtSignal()
 
-    globalValueChanged = pyqtSignal()  # Emitted whenever a value inside global container is changed.
     activeStackValueChanged = pyqtSignal()  # Emitted whenever a value inside the active stack is changed.
     activeStackValidationChanged = pyqtSignal()  # Emitted whenever a validation inside active container is changed
     stacksValidationChanged = pyqtSignal()  # Emitted whenever a validation is changed
@@ -156,7 +154,6 @@ class MachineManager(QObject):
     printerConnectedStatusChanged = pyqtSignal() # Emitted every time the active machine change or the outputdevices change
 
     rootMaterialChanged = pyqtSignal()
-    discoveredPrintersChanged = pyqtSignal()
 
     def setInitialActiveMachine(self) -> None:
         active_machine_id = self._application.getPreferences().getValue("cura/active_machine")
@@ -182,9 +179,11 @@ class MachineManager(QObject):
 
         # Create the configuration model with the current data in Cura
         self._current_printer_configuration.printerType = self._global_container_stack.definition.getName()
-        self._current_printer_configuration.extruderConfigurations = []
-        for extruder in self._global_container_stack.extruderList:
-            extruder_configuration = ExtruderConfigurationModel()
+
+        if len(self._current_printer_configuration.extruderConfigurations) != len(self._global_container_stack.extruderList):
+            self._current_printer_configuration.extruderConfigurations = [ExtruderConfigurationModel() for extruder in self._global_container_stack.extruderList]
+
+        for extruder, extruder_configuration in zip(self._global_container_stack.extruderList, self._current_printer_configuration.extruderConfigurations):
             # For compare just the GUID is needed at this moment
             mat_type = extruder.material.getMetaDataEntry("material") if extruder.material != empty_material_container else None
             mat_guid = extruder.material.getMetaDataEntry("GUID") if extruder.material != empty_material_container else None
@@ -196,7 +195,6 @@ class MachineManager(QObject):
             extruder_configuration.position = int(extruder.getMetaDataEntry("position"))
             extruder_configuration.material = material_model
             extruder_configuration.hotendID = extruder.variant.getName() if extruder.variant != empty_variant_container else None
-            self._current_printer_configuration.extruderConfigurations.append(extruder_configuration)
 
         # An empty build plate configuration from the network printer is presented as an empty string, so use "" for an
         # empty build plate.
@@ -619,7 +617,10 @@ class MachineManager(QObject):
         global_container_stack = cura.CuraApplication.CuraApplication.getInstance().getGlobalContainerStack()
         if not global_container_stack:
             return False
-        return Util.parseBool(global_container_stack.quality.getMetaDataEntry("is_experimental", False))
+        active_quality_group = self.activeQualityGroup()
+        if active_quality_group is None:
+            return False
+        return active_quality_group.is_experimental
 
     @pyqtProperty(str, notify = activeIntentChanged)
     def activeIntentCategory(self) -> str:
@@ -627,13 +628,7 @@ class MachineManager(QObject):
 
         if not global_container_stack:
             return ""
-        intent_category = "default"
-        for extruder in global_container_stack.extruderList:
-            category = extruder.intent.getMetaDataEntry("intent_category", "default")
-            if category != "default" and category != intent_category:
-                intent_category = category
-
-        return intent_category
+        return global_container_stack.getIntentCategory()
 
     # Provies a list of extruder positions that have a different intent from the active one.
     @pyqtProperty("QStringList", notify=activeIntentChanged)
@@ -1111,21 +1106,6 @@ class MachineManager(QObject):
     def currentRootMaterialId(self) -> Dict[str, str]:
         return self._current_root_material_id
 
-    ##  Return the variant names in the extruder stack(s).
-    ##  For the variant in the global stack, use activeVariantBuildplateName
-    @pyqtProperty("QVariant", notify = activeVariantChanged)
-    def activeVariantNames(self) -> Dict[str, str]:
-        result = {}
-
-        active_stacks = ExtruderManager.getInstance().getActiveExtruderStacks()
-        for stack in active_stacks:
-            variant_container = stack.variant
-            position = stack.getMetaDataEntry("position")
-            if variant_container and variant_container != empty_variant_container:
-                result[position] = variant_container.getName()
-
-        return result
-
     # Sets all quality and quality_changes containers to empty_quality and empty_quality_changes containers
     # for all stacks in the currently active machine.
     #
@@ -1452,6 +1432,8 @@ class MachineManager(QObject):
                 else:
                     machine_node = ContainerTree.getInstance().machines.get(self._global_container_stack.definition.getId())
                     variant_node = machine_node.variants.get(extruder_configuration.hotendID)
+                    if variant_node is None:
+                        continue
                     self._setVariantNode(position, variant_node)
 
                     # Find the material profile that the printer has stored.

+ 10 - 10
plugins/AMFReader/AMFReader.py

@@ -1,4 +1,4 @@
-# Copyright (c) 2019 fieldOfView
+# Copyright (c) 2019 fieldOfView, Ultimaker B.V.
 # Cura is released under the terms of the LGPLv3 or higher.
 
 # This AMF parser is based on the AMF parser in legacy cura:
@@ -39,9 +39,9 @@ class AMFReader(MeshReader):
 
         MimeTypeDatabase.addMimeType(
             MimeType(
-                name="application/x-amf",
-                comment="AMF",
-                suffixes=["amf"]
+                name = "application/x-amf",
+                comment = "AMF",
+                suffixes = ["amf"]
             )
         )
 
@@ -94,7 +94,7 @@ class AMFReader(MeshReader):
                                 if t.tag == "x":
                                     v[0] = float(t.text) * scale
                                 elif t.tag == "y":
-                                    v[2] = float(t.text) * scale
+                                    v[2] = -float(t.text) * scale
                                 elif t.tag == "z":
                                     v[1] = float(t.text) * scale
                             amf_mesh_vertices.append(v)
@@ -114,7 +114,7 @@ class AMFReader(MeshReader):
                                 f[2] = int(t.text)
                         indices.append(f)
 
-                    mesh = trimesh.base.Trimesh(vertices=numpy.array(amf_mesh_vertices, dtype=numpy.float32), faces=numpy.array(indices, dtype=numpy.int32))
+                    mesh = trimesh.base.Trimesh(vertices = numpy.array(amf_mesh_vertices, dtype = numpy.float32), faces = numpy.array(indices, dtype = numpy.int32))
                     mesh.merge_vertices()
                     mesh.remove_unreferenced_vertices()
                     mesh.fix_normals()
@@ -123,7 +123,7 @@ class AMFReader(MeshReader):
                     new_node = CuraSceneNode()
                     new_node.setSelectable(True)
                     new_node.setMeshData(mesh_data)
-                    new_node.setName(base_name if len(nodes)==0 else "%s %d" % (base_name, len(nodes)))
+                    new_node.setName(base_name if len(nodes) == 0 else "%s %d" % (base_name, len(nodes)))
                     new_node.addDecorator(BuildPlateDecorator(CuraApplication.getInstance().getMultiBuildPlateModel().activeBuildPlate))
                     new_node.addDecorator(SliceableObjectDecorator())
 
@@ -165,9 +165,9 @@ class AMFReader(MeshReader):
             indices.append(face)
             face_count += 1
 
-        vertices = numpy.asarray(vertices, dtype=numpy.float32)
-        indices = numpy.asarray(indices, dtype=numpy.int32)
+        vertices = numpy.asarray(vertices, dtype = numpy.float32)
+        indices = numpy.asarray(indices, dtype = numpy.int32)
         normals = calculateNormalsFromIndexedVertices(vertices, indices, face_count)
 
-        mesh_data = MeshData(vertices=vertices, indices=indices, normals=normals)
+        mesh_data = MeshData(vertices = vertices, indices = indices, normals = normals)
         return mesh_data

+ 1 - 1
plugins/CuraEngineBackend/CuraEngineBackend.py

@@ -400,7 +400,7 @@ class CuraEngineBackend(QObject, Backend):
                 self.setState(BackendState.NotStarted)
 
         if job.getResult() == StartJobResult.ObjectsWithDisabledExtruder:
-            self._error_message = Message(catalog.i18nc("@info:status", "Unable to slice because there are objects associated with disabled Extruder %s." % job.getMessage()),
+            self._error_message = Message(catalog.i18nc("@info:status", "Unable to slice because there are objects associated with disabled Extruder %s.") % job.getMessage(),
                                           title = catalog.i18nc("@info:title", "Unable to slice"))
             self._error_message.show()
             self.setState(BackendState.Error)

+ 1 - 0
plugins/SliceInfoPlugin/SliceInfo.py

@@ -174,6 +174,7 @@ class SliceInfo(QObject, Extension):
                 extruder_dict["extruder_settings"] = extruder_settings
                 data["extruders"].append(extruder_dict)
 
+            data["intent_category"] = global_stack.getIntentCategory()
             data["quality_profile"] = global_stack.quality.getMetaData().get("quality_type")
 
             data["user_modified_setting_keys"] = self._getUserModifiedSettingKeys()

+ 1 - 0
plugins/SliceInfoPlugin/example_data.html

@@ -4,6 +4,7 @@
     <b>Operating System:</b> Windows 10<br/>
     <b>Language:</b> en_US<br/>
     <b>Machine Type:</b> Ultimaker S5<br/>
+    <b>Intent Profile:</b> Default<br/>
     <b>Quality Profile:</b> Fast<br/>
     <b>Using Custom Settings:</b> No
 

Some files were not shown because too many files changed in this diff