Merge branch 'master' of github.com:Ultimaker/Cura

This commit is contained in:
Jaime van Kessel 2016-09-28 09:37:07 +02:00
commit 603a0a10d6
3 changed files with 61 additions and 26 deletions

View File

@ -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.Scene.SceneNodeDecorator import SceneNodeDecorator
from UM.Application import Application from UM.Application import Application
from cura.Settings.ExtruderManager import ExtruderManager from cura.Settings.ExtruderManager import ExtruderManager
@ -196,9 +199,16 @@ class ConvexHullDecorator(SceneNodeDecorator):
# First, calculate the normal convex hull around the points # First, calculate the normal convex hull around the points
convex_hull = hull.getConvexHull() convex_hull = hull.getConvexHull()
# Then, do a Minkowski hull with a simple 1x1 quad to outset and round the normal convex hull. #Then, offset the convex hull with the horizontal expansion value, since that is always added to the mesh.
# This is done because of rounding errors. #Use a minimum of 0.5mm to outset and round the normal convex hull if there is no horizontal expansion, because of edge cases.
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))) 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 # Store the result in the cache
self._2d_convex_hull_mesh = mesh self._2d_convex_hull_mesh = mesh
@ -228,7 +238,6 @@ class ConvexHullDecorator(SceneNodeDecorator):
# Compensate for raft/skirt/brim # Compensate for raft/skirt/brim
# Add extra margin depending on adhesion type # Add extra margin depending on adhesion type
adhesion_type = self._global_stack.getProperty("adhesion_type", "value") adhesion_type = self._global_stack.getProperty("adhesion_type", "value")
extra_margin = 0
if adhesion_type == "raft": if adhesion_type == "raft":
extra_margin = max(0, self._getSettingProperty("raft_margin", "value")) extra_margin = max(0, self._getSettingProperty("raft_margin", "value"))
@ -237,7 +246,9 @@ class ConvexHullDecorator(SceneNodeDecorator):
elif adhesion_type == "skirt": elif adhesion_type == "skirt":
extra_margin = max( extra_margin = max(
0, self._getSettingProperty("skirt_gap", "value") + 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 # adjust head_and_fans with extra margin
if extra_margin > 0: if extra_margin > 0:
@ -285,17 +296,24 @@ class ConvexHullDecorator(SceneNodeDecorator):
## Private convenience function to get a setting from the correct extruder (as defined by limit_to_extruder property). ## 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"): 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: if not multi_extrusion:
return self._global_stack.getProperty(setting_key, property) return self._global_stack.getProperty(setting_key, property)
extruder_index = self._global_stack.getProperty(setting_key, "limit_to_extruder") extruder_index = self._global_stack.getProperty(setting_key, "limit_to_extruder")
if extruder_index == "-1": # If extruder index is -1 use global instead if extruder_index == "-1": #No limit_to_extruder.
return self._global_stack.getProperty(setting_key, property) 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)] extruder_stack_id = ExtruderManager.getInstance().extruderIds[str(extruder_index)]
stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id=extruder_stack_id)[0] stack = UM.Settings.ContainerRegistry.getInstance().findContainerStacks(id = extruder_stack_id)[0]
return stack.getProperty(setting_key, property) return stack.getProperty(setting_key, property)
## Returns true if node is a descendent or the same as the root node. ## Returns true if node is a descendent or the same as the root node.

View File

@ -539,8 +539,10 @@ class MachineManager(QObject):
containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = material_id) containers = UM.Settings.ContainerRegistry.getInstance().findInstanceContainers(id = material_id)
if not containers or not self._active_container_stack: if not containers or not self._active_container_stack:
return return
material_container = containers[0]
Logger.log("d", "Attempting to change the active material to %s", material_id) 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_material = self._active_container_stack.findContainer({"type": "material"})
old_quality = self._active_container_stack.findContainer({"type": "quality"}) old_quality = self._active_container_stack.findContainer({"type": "quality"})
old_quality_changes = self._active_container_stack.findContainer({"type": "quality_changes"}) old_quality_changes = self._active_container_stack.findContainer({"type": "quality_changes"})
@ -555,26 +557,37 @@ class MachineManager(QObject):
old_material.nameChanged.disconnect(self._onMaterialNameChanged) old_material.nameChanged.disconnect(self._onMaterialNameChanged)
material_index = self._active_container_stack.getContainerIndex(old_material) 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", message = Message(catalog.i18nc("@info:status",
"The selected material is imcompatible with the selected machine or configuration.")) "The selected material is imcompatible with the selected machine or configuration."))
message.show() message.show()
if old_quality: new_quality_id = old_quality.getId()
quality_type = old_quality.getMetaDataEntry("quality_type")
if old_quality_changes: if old_quality_changes:
new_quality = self._updateQualityChangesContainer( quality_type = old_quality_changes.getMetaDataEntry("quality_type")
old_quality.getMetaDataEntry("quality_type"), new_quality_id = old_quality_changes.getId()
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])
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) @pyqtSlot(str)
def setActiveVariant(self, variant_id): def setActiveVariant(self, variant_id):

View File

@ -161,6 +161,10 @@ Rectangle
visible: showProgress; visible: showProgress;
indeterminate: indeterminate:
{ {
if (!printerConnected)
{
return true;
}
switch(Cura.MachineManager.printerOutputDevices[0].jobState) switch(Cura.MachineManager.printerOutputDevices[0].jobState)
{ {
case "pausing": case "pausing":