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

This commit is contained in:
Jack Ha 2016-09-15 15:30:16 +02:00
commit effddcbc5e
8 changed files with 102 additions and 55 deletions

View File

@ -22,6 +22,8 @@ catalog = i18nCatalog("cura")
import numpy
import copy
import UM.Settings.ContainerRegistry
# Setting for clearance around the prime
PRIME_CLEARANCE = 10
@ -81,10 +83,6 @@ class BuildVolume(SceneNode):
Application.getInstance().globalContainerStackChanged.connect(self._onGlobalContainerStackChanged)
self._onGlobalContainerStackChanged()
self._active_extruder_stack = None
ExtruderManager.getInstance().activeExtruderChanged.connect(self._onActiveExtruderStackChanged)
self._onActiveExtruderStackChanged()
self._has_errors = False
def setWidth(self, width):
@ -215,11 +213,7 @@ class BuildVolume(SceneNode):
minimum = Vector(min_w, min_h - 1.0, min_d),
maximum = Vector(max_w, max_h - self._raft_thickness, max_d))
bed_adhesion_size = 0.0
container_stack = Application.getInstance().getGlobalContainerStack()
if container_stack:
bed_adhesion_size = self._getBedAdhesionSize(container_stack)
bed_adhesion_size = self._getBedAdhesionSize()
# As this works better for UM machines, we only add the disallowed_area_size for the z direction.
# This is probably wrong in all other cases. TODO!
@ -264,11 +258,17 @@ class BuildVolume(SceneNode):
def _onGlobalContainerStackChanged(self):
if self._global_container_stack:
self._global_container_stack.propertyChanged.disconnect(self._onSettingPropertyChanged)
extruders = ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId())
for extruder in extruders:
extruder.propertyChanged.disconnect(self._onSettingPropertyChanged)
self._global_container_stack = Application.getInstance().getGlobalContainerStack()
if self._global_container_stack:
self._global_container_stack.propertyChanged.connect(self._onSettingPropertyChanged)
extruders = ExtruderManager.getInstance().getMachineExtruders(self._global_container_stack.getId())
for extruder in extruders:
extruder.propertyChanged.connect(self._onSettingPropertyChanged)
self._width = self._global_container_stack.getProperty("machine_width", "value")
machine_height = self._global_container_stack.getProperty("machine_height", "value")
@ -285,13 +285,6 @@ class BuildVolume(SceneNode):
self.rebuild()
def _onActiveExtruderStackChanged(self):
if self._active_extruder_stack:
self._active_extruder_stack.propertyChanged.disconnect(self._onSettingPropertyChanged)
self._active_extruder_stack = ExtruderManager.getInstance().getActiveExtruderStack()
if self._active_extruder_stack:
self._active_extruder_stack.propertyChanged.connect(self._onSettingPropertyChanged)
def _onSettingPropertyChanged(self, setting_key, property_name):
if property_name != "value":
return
@ -364,7 +357,7 @@ class BuildVolume(SceneNode):
[prime_x - PRIME_CLEARANCE, prime_y + PRIME_CLEARANCE],
])
bed_adhesion_size = self._getBedAdhesionSize(self._global_container_stack)
bed_adhesion_size = self._getBedAdhesionSize()
if disallowed_areas:
# Extend every area already in the disallowed_areas with the skirt size.
@ -425,8 +418,26 @@ class BuildVolume(SceneNode):
self._has_errors = collision
self._disallowed_areas = areas
## 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_container_stack.getProperty("machine_extruder_count", "value") > 1
if not multi_extrusion:
return self._global_container_stack.getProperty(setting_key, property)
extruder_index = self._global_container_stack.getProperty(setting_key, "limit_to_extruder")
if extruder_index == "-1": # If extruder index is -1 use global instead
return self._global_container_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)
## Convenience function to calculate the size of the bed adhesion in directions x, y.
def _getBedAdhesionSize(self, container_stack):
def _getBedAdhesionSize(self):
if not self._global_container_stack:
return 0
container_stack = self._global_container_stack
skirt_size = 0.0
# If we are printing one at a time, we need to add the bed adhesion size to the disallowed areas of the objects
@ -435,13 +446,13 @@ class BuildVolume(SceneNode):
adhesion_type = container_stack.getProperty("adhesion_type", "value")
if adhesion_type == "skirt":
skirt_distance = container_stack.getProperty("skirt_gap", "value")
skirt_line_count = container_stack.getProperty("skirt_line_count", "value")
skirt_size = skirt_distance + (skirt_line_count * container_stack.getProperty("skirt_brim_line_width", "value"))
skirt_distance = self._getSettingProperty("skirt_gap", "value")
skirt_line_count = self._getSettingProperty("skirt_line_count", "value")
skirt_size = skirt_distance + (skirt_line_count * self._getSettingProperty("skirt_brim_line_width", "value"))
elif adhesion_type == "brim":
skirt_size = container_stack.getProperty("brim_line_count", "value") * container_stack.getProperty("skirt_brim_line_width", "value")
skirt_size = self._getSettingProperty("brim_line_count", "value") * self._getSettingProperty("skirt_brim_line_width", "value")
elif adhesion_type == "raft":
skirt_size = container_stack.getProperty("raft_margin", "value")
skirt_size = self._getSettingProperty("raft_margin", "value")
if container_stack.getProperty("draft_shield_enabled", "value"):
skirt_size += container_stack.getProperty("draft_shield_dist", "value")

View File

@ -1,9 +1,11 @@
from UM.Scene.SceneNodeDecorator import SceneNodeDecorator
from UM.Application import Application
from cura.Settings.ExtruderManager import ExtruderManager
from UM.Math.Polygon import Polygon
from . import ConvexHullNode
import UM.Settings.ContainerRegistry
import numpy
## The convex hull decorator is a scene node decorator that adds the convex hull functionality to a scene node.
@ -227,18 +229,15 @@ class ConvexHullDecorator(SceneNodeDecorator):
# Add extra margin depending on adhesion type
adhesion_type = self._global_stack.getProperty("adhesion_type", "value")
extra_margin = 0
machine_head_coords = numpy.array(
self._global_stack.getProperty("machine_head_with_fans_polygon", "value"),
numpy.float32)
if adhesion_type == "raft":
extra_margin = max(0, self._global_stack.getProperty("raft_margin", "value"))
extra_margin = max(0, self._getSettingProperty("raft_margin", "value"))
elif adhesion_type == "brim":
extra_margin = max(0, self._global_stack.getProperty("brim_line_count", "value") * self._global_stack.getProperty("skirt_brim_line_width", "value"))
extra_margin = max(0, self._getSettingProperty("brim_line_count", "value") * self._getSettingProperty("skirt_brim_line_width", "value"))
elif adhesion_type == "skirt":
extra_margin = max(
0, self._global_stack.getProperty("skirt_gap", "value") +
self._global_stack.getProperty("skirt_line_count", "value") * self._global_stack.getProperty("skirt_brim_line_width", "value"))
0, self._getSettingProperty("skirt_gap", "value") +
self._getSettingPropertyy("skirt_line_count", "value") * self._getSettingProperty("skirt_brim_line_width", "value"))
# adjust head_and_fans with extra margin
if extra_margin > 0:
@ -268,6 +267,9 @@ class ConvexHullDecorator(SceneNodeDecorator):
if self._global_stack:
self._global_stack.propertyChanged.disconnect(self._onSettingValueChanged)
self._global_stack.containersChanged.disconnect(self._onChanged)
extruders = ExtruderManager.getInstance().getMachineExtruders(self._global_stack.getId())
for extruder in extruders:
extruder.propertyChanged.disconnect(self._onSettingValueChanged)
self._global_stack = Application.getInstance().getGlobalContainerStack()
@ -275,8 +277,27 @@ class ConvexHullDecorator(SceneNodeDecorator):
self._global_stack.propertyChanged.connect(self._onSettingValueChanged)
self._global_stack.containersChanged.connect(self._onChanged)
extruders = ExtruderManager.getInstance().getMachineExtruders(self._global_stack.getId())
for extruder in extruders:
extruder.propertyChanged.connect(self._onSettingValueChanged)
self._onChanged()
## 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
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)
## Returns true if node is a descendent or the same as the root node.
def __isDescendant(self, root, node):
if node is None:

View File

@ -77,7 +77,7 @@ Cura.MachineAction
{
id: buildAreaWidthField
text: machineWidthProvider.properties.value
validator: RegExpValidator { regExp: /[0-9]{0,6}/ }
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
onEditingFinished: { machineWidthProvider.setPropertyValue("value", text); manager.forceUpdate() }
}
Label
@ -93,7 +93,7 @@ Cura.MachineAction
{
id: buildAreaDepthField
text: machineDepthProvider.properties.value
validator: RegExpValidator { regExp: /[0-9]{0,6}/ }
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
onEditingFinished: { machineDepthProvider.setPropertyValue("value", text); manager.forceUpdate() }
}
Label
@ -109,7 +109,7 @@ Cura.MachineAction
{
id: buildAreaHeightField
text: machineHeightProvider.properties.value
validator: RegExpValidator { regExp: /[0-9]{0,6}/ }
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
onEditingFinished: { machineHeightProvider.setPropertyValue("value", text); manager.forceUpdate() }
}
Label
@ -182,7 +182,7 @@ Cura.MachineAction
{
id: printheadXMinField
text: getHeadPolygonCoord("x", "min")
validator: RegExpValidator { regExp: /[0-9]{0,6}/ }
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
onEditingFinished: setHeadPolygon()
}
Label
@ -198,7 +198,7 @@ Cura.MachineAction
{
id: printheadYMinField
text: getHeadPolygonCoord("y", "min")
validator: RegExpValidator { regExp: /[0-9]{0,6}/ }
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
onEditingFinished: setHeadPolygon()
}
Label
@ -214,7 +214,7 @@ Cura.MachineAction
{
id: printheadXMaxField
text: getHeadPolygonCoord("x", "max")
validator: RegExpValidator { regExp: /[0-9]{0,6}/ }
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
onEditingFinished: setHeadPolygon()
}
Label
@ -230,7 +230,7 @@ Cura.MachineAction
{
id: printheadYMaxField
text: getHeadPolygonCoord("y", "max")
validator: RegExpValidator { regExp: /[0-9]{0,6}/ }
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
onEditingFinished: setHeadPolygon()
}
Label

View File

@ -130,6 +130,7 @@ _setting_name_translations = {
"remove_overlapping_walls_enabled": "travel_compensate_overlapping_walls_enabled",
"remove_overlapping_walls_x_enabled": "travel_compensate_overlapping_walls_x_enabled",
"retraction_hop": "retraction_hop_enabled",
"skin_overlap": "infill_overlap",
"skirt_line_width": "skirt_brim_line_width",
"skirt_minimal_length": "skirt_brim_minimal_length",
"skirt_speed": "skirt_brim_speed",
@ -390,17 +391,18 @@ class VersionUpgrade21to22(VersionUpgrade):
# \return The same dictionary.
@staticmethod
def translateSettings(settings):
new_settings = {}
for key, value in settings.items():
if key in _removed_settings:
del settings[key]
elif key == "retraction_combing": #Combing was made into an enum instead of a boolean.
settings[key] = "off" if (value == "False") else "all"
elif key in _setting_name_translations:
del settings[key]
settings[_setting_name_translations[key]] = value
if "infill_overlap" in settings: # New setting, added in 2.3
settings["skin_overlap"] = settings["infill_overlap"]
return settings
continue
if key == "retraction_combing": #Combing was made into an enum instead of a boolean.
new_settings[key] = "off" if (value == "False") else "all"
continue
if key in _setting_name_translations:
new_settings[_setting_name_translations[key]] = value
continue
new_settings[key] = value
return new_settings
## Translates a setting name for the change from Cura 2.1 to 2.2.
#

View File

@ -140,7 +140,7 @@ UM.MainWindow
Instantiator
{
model: Cura.ExtrudersModel { }
model: Cura.ExtrudersModel { simpleNames: true }
Menu {
title: model.name
visible: machineExtruderCount.properties.value > 1
@ -641,8 +641,7 @@ UM.MainWindow
//: File open dialog title
title: catalog.i18nc("@title:window","Open file")
modality: UM.Application.platform == "linux" ? Qt.NonModal : Qt.WindowModal;
//TODO: Support multiple file selection, workaround bug in KDE file dialog
//selectMultiple: true
selectMultiple: true
nameFilters: UM.MeshFileHandler.supportedReadFileTypes;
folder: CuraApplication.getDefaultPath("dialog_load_path")
onAccepted:
@ -653,7 +652,12 @@ UM.MainWindow
folder = f;
CuraApplication.setDefaultPath("dialog_load_path", folder);
UM.MeshFileHandler.readLocalFile(fileUrl)
for(var i in fileUrls)
{
UM.MeshFileHandler.readLocalFile(fileUrls[i])
}
var meshName = backgroundItem.getMeshName(fileUrl.toString())
backgroundItem.hasMesh(decodeURIComponent(meshName))
}

View File

@ -20,8 +20,12 @@ Menu
id: automaticMaterial
text:
{
var materialName = Cura.MachineManager.printerOutputDevices[0].materialNames[extruderIndex];
return catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg(materialName);
if(printerConnected && Cura.MachineManager.printerOutputDevices[0].materialNames.length > extruderIndex)
{
var materialName = Cura.MachineManager.printerOutputDevices[0].materialNames[extruderIndex];
return catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg(materialName);
}
return "";
}
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].materialNames.length > extruderIndex
onTriggered:

View File

@ -20,8 +20,12 @@ Menu
id: automaticNozzle
text:
{
var nozzleName = Cura.MachineManager.printerOutputDevices[0].hotendIds[extruderIndex];
return catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg(nozzleName);
if(printerConnected && Cura.MachineManager.printerOutputDevices[0].hotendIds.length > extruderIndex)
{
var nozzleName = Cura.MachineManager.printerOutputDevices[0].hotendIds[extruderIndex];
return catalog.i18nc("@title:menuitem %1 is the value from the printer", "Automatic: %1").arg(nozzleName);
}
return "";
}
visible: printerConnected && Cura.MachineManager.printerOutputDevices[0].hotendIds.length > extruderIndex
onTriggered:

View File

@ -207,6 +207,7 @@ UM.ManagementPage
anchors.topMargin: UM.Theme.getSize("default_margin").width
spacing: UM.Theme.getSize("default_margin").width
visible: base.currentItem && base.currentItem.id == Cura.MachineManager.activeMachineId
Component.onCompleted:
{