diff --git a/cura/ConvexHullDecorator.py b/cura/ConvexHullDecorator.py index 4397251b6e..d1f3f07c4b 100644 --- a/cura/ConvexHullDecorator.py +++ b/cura/ConvexHullDecorator.py @@ -1,3 +1,6 @@ +# Copyright (c) 2016 Ultimaker B.V. +# Cura is released under the terms of the AGPLv3 or higher. + from UM.Scene.SceneNodeDecorator import SceneNodeDecorator from UM.Application import Application from cura.Settings.ExtruderManager import ExtruderManager @@ -196,9 +199,16 @@ class ConvexHullDecorator(SceneNodeDecorator): # First, calculate the normal convex hull around the points convex_hull = hull.getConvexHull() - # Then, do a Minkowski hull with a simple 1x1 quad to outset and round the normal convex hull. - # This is done because of rounding errors. - rounded_hull = convex_hull.getMinkowskiHull(Polygon(numpy.array([[-0.5, -0.5], [-0.5, 0.5], [0.5, 0.5], [0.5, -0.5]], numpy.float32))) + #Then, offset the convex hull with the horizontal expansion value, since that is always added to the mesh. + #Use a minimum of 0.5mm to outset and round the normal convex hull if there is no horizontal expansion, because of edge cases. + horizontal_expansion = max(0.5, self._getSettingProperty("xy_offset", "value")) + expansion_polygon = Polygon(numpy.array([ + [-horizontal_expansion, -horizontal_expansion], + [-horizontal_expansion, horizontal_expansion], + [horizontal_expansion, horizontal_expansion], + [horizontal_expansion, -horizontal_expansion] + ], numpy.float32)) + rounded_hull = convex_hull.getMinkowskiHull(expansion_polygon) # Store the result in the cache self._2d_convex_hull_mesh = mesh @@ -228,7 +238,6 @@ class ConvexHullDecorator(SceneNodeDecorator): # Compensate for raft/skirt/brim # Add extra margin depending on adhesion type adhesion_type = self._global_stack.getProperty("adhesion_type", "value") - extra_margin = 0 if adhesion_type == "raft": extra_margin = max(0, self._getSettingProperty("raft_margin", "value")) @@ -237,7 +246,9 @@ class ConvexHullDecorator(SceneNodeDecorator): elif adhesion_type == "skirt": extra_margin = max( 0, self._getSettingProperty("skirt_gap", "value") + - self._getSettingPropertyy("skirt_line_count", "value") * self._getSettingProperty("skirt_brim_line_width", "value")) + self._getSettingProperty("skirt_line_count", "value") * self._getSettingProperty("skirt_brim_line_width", "value")) + else: + raise Exception("Unknown bed adhesion type. Did you forget to update the convex hull calculations for your new bed adhesion type?") # adjust head_and_fans with extra margin if extra_margin > 0: @@ -285,18 +296,25 @@ class ConvexHullDecorator(SceneNodeDecorator): ## Private convenience function to get a setting from the correct extruder (as defined by limit_to_extruder property). def _getSettingProperty(self, setting_key, property="value"): - multi_extrusion = self._global_stack.getProperty("machine_extruder_count", "value") > 1 + per_mesh_stack = self._node.callDecoration("getStack") + if per_mesh_stack: + return per_mesh_stack.getProperty(setting_key, property) + multi_extrusion = self._global_stack.getProperty("machine_extruder_count", "value") > 1 if not multi_extrusion: return self._global_stack.getProperty(setting_key, property) extruder_index = self._global_stack.getProperty(setting_key, "limit_to_extruder") - if extruder_index == "-1": # If extruder index is -1 use global instead - return self._global_stack.getProperty(setting_key, property) - - extruder_stack_id = ExtruderManager.getInstance().extruderIds[str(extruder_index)] - stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id=extruder_stack_id)[0] - return stack.getProperty(setting_key, property) + if extruder_index == "-1": #No limit_to_extruder. + extruder_stack_id = self._node.callDecoration("getActiveExtruder") + if not extruder_stack_id: #Decoration doesn't exist. + extruder_stack_id = ExtruderManager.getInstance().extruderIds["0"] + extruder_stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = extruder_stack_id)[0] + return extruder_stack.getProperty(setting_key, property) + else: #Limit_to_extruder is set. Use that one. + extruder_stack_id = ExtruderManager.getInstance().extruderIds[str(extruder_index)] + stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = extruder_stack_id)[0] + return stack.getProperty(setting_key, property) ## Returns true if node is a descendent or the same as the root node. def __isDescendant(self, root, node): diff --git a/cura/Settings/MachineManager.py b/cura/Settings/MachineManager.py index 9c15d33e52..4569e51098 100644 --- a/cura/Settings/MachineManager.py +++ b/cura/Settings/MachineManager.py @@ -539,8 +539,10 @@ class MachineManager(QObject): containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = material_id) if not containers or not self._active_container_stack: return + material_container = containers[0] + Logger.log("d", "Attempting to change the active material to %s", material_id) - old_variant = self._active_container_stack.findContainer({"type": "variant"}) + old_material = self._active_container_stack.findContainer({"type": "material"}) old_quality = self._active_container_stack.findContainer({"type": "quality"}) old_quality_changes = self._active_container_stack.findContainer({"type": "quality_changes"}) @@ -555,26 +557,37 @@ class MachineManager(QObject): old_material.nameChanged.disconnect(self._onMaterialNameChanged) material_index = self._active_container_stack.getContainerIndex(old_material) - self._active_container_stack.replaceContainer(material_index, containers[0]) + self._active_container_stack.replaceContainer(material_index, material_container) - containers[0].nameChanged.connect(self._onMaterialNameChanged) + material_container.nameChanged.connect(self._onMaterialNameChanged) - if containers[0].getMetaDataEntry("compatible") == False: + if material_container.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"), - preferred_quality_changes_name = old_quality_changes.getMetaDataEntry("name")) - else: - new_quality = self._updateQualityContainer(self._global_container_stack.getBottom(), old_variant, containers[0], old_quality.getName()) - else: - new_quality = self._updateQualityContainer(self._global_container_stack.getBottom(), old_variant, containers[0]) + new_quality_id = old_quality.getId() + quality_type = old_quality.getMetaDataEntry("quality_type") + if old_quality_changes: + quality_type = old_quality_changes.getMetaDataEntry("quality_type") + new_quality_id = old_quality_changes.getId() - self.setActiveQuality(new_quality.getId()) + # See if the requested quality type is available in the new situation. + machine_definition = self._active_container_stack.getBottom() + quality_manager = QualityManager.getInstance() + candidate_qualities = quality_manager.findQualityByQualityType(quality_type, + quality_manager.getWholeMachineDefinition(machine_definition), + [material_container]) + if not candidate_qualities: + # Fall back to normal quality + new_quality_id = quality_manager.findQualityByQualityType("normal", + quality_manager.getWholeMachineDefinition(machine_definition), + [material_container])[0].getId() + else: + if not old_quality_changes: + new_quality_id = candidate_qualities[0].getId() + + self.setActiveQuality(new_quality_id) @pyqtSlot(str) def setActiveVariant(self, variant_id): diff --git a/resources/qml/MonitorButton.qml b/resources/qml/MonitorButton.qml index 607d0a24ca..83d8b4bfc9 100644 --- a/resources/qml/MonitorButton.qml +++ b/resources/qml/MonitorButton.qml @@ -161,6 +161,10 @@ Rectangle visible: showProgress; indeterminate: { + if (!printerConnected) + { + return true; + } switch(Cura.MachineManager.printerOutputDevices[0].jobState) { case "pausing":