Merge branch '2.3'

This commit is contained in:
fieldOfView 2016-09-01 14:18:13 +02:00
commit 85fc680994
9 changed files with 89 additions and 42 deletions

View File

@ -303,7 +303,7 @@ class BuildVolume(SceneNode):
machine_depth = self._global_container_stack.getProperty("machine_depth", "value") machine_depth = self._global_container_stack.getProperty("machine_depth", "value")
# Add prime tower location as disallowed area. # Add prime tower location as disallowed area.
if self._global_container_stack.getProperty("prime_tower_enable", "value"): if self._global_container_stack.getProperty("prime_tower_enable", "value") == True:
prime_tower_size = self._global_container_stack.getProperty("prime_tower_size", "value") prime_tower_size = self._global_container_stack.getProperty("prime_tower_size", "value")
prime_tower_x = self._global_container_stack.getProperty("prime_tower_position_x", "value") - machine_width / 2 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 prime_tower_y = - self._global_container_stack.getProperty("prime_tower_position_y", "value") + machine_depth / 2

View File

@ -423,8 +423,8 @@ class ContainerManager(QObject):
# stack and clear the user settings. # stack and clear the user settings.
# #
# \return \type{bool} True if the operation was successfully, False if not. # \return \type{bool} True if the operation was successfully, False if not.
@pyqtSlot(result = bool) @pyqtSlot(str, result = bool)
def createQualityChanges(self): def createQualityChanges(self, base_name):
global_stack = UM.Application.getInstance().getGlobalContainerStack() global_stack = UM.Application.getInstance().getGlobalContainerStack()
if not global_stack: if not global_stack:
return False return False
@ -436,7 +436,9 @@ class ContainerManager(QObject):
self._machine_manager.blurSettings.emit() self._machine_manager.blurSettings.emit()
unique_name = self._container_registry.uniqueName(active_quality_name) if base_name is None:
base_name = active_quality_name
unique_name = self._container_registry.uniqueName(base_name)
# Go through the active stacks and create quality_changes containers from the user containers. # Go through the active stacks and create quality_changes containers from the user containers.
for stack in cura.Settings.ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks(): for stack in cura.Settings.ExtruderManager.getInstance().getActiveGlobalAndExtruderStacks():
@ -540,8 +542,8 @@ class ContainerManager(QObject):
# \param quality_name The name of the quality to duplicate. # \param quality_name The name of the quality to duplicate.
# #
# \return A string containing the name of the duplicated containers, or an empty string if it failed. # \return A string containing the name of the duplicated containers, or an empty string if it failed.
@pyqtSlot(str, result = str) @pyqtSlot(str, str, result = str)
def duplicateQualityOrQualityChanges(self, quality_name): def duplicateQualityOrQualityChanges(self, quality_name, base_name):
global_stack = UM.Application.getInstance().getGlobalContainerStack() global_stack = UM.Application.getInstance().getGlobalContainerStack()
if not global_stack or not quality_name: if not global_stack or not quality_name:
return "" return ""
@ -551,7 +553,10 @@ class ContainerManager(QObject):
UM.Logger.log("d", "Unable to duplicate the quality %s, because it doesn't exist.", quality_name) UM.Logger.log("d", "Unable to duplicate the quality %s, because it doesn't exist.", quality_name)
return "" return ""
new_name = self._container_registry.uniqueName(quality_name) if base_name is None:
base_name = quality_name
new_name = self._container_registry.uniqueName(base_name)
container_type = containers[0].getMetaDataEntry("type") container_type = containers[0].getMetaDataEntry("type")
if container_type == "quality": if container_type == "quality":

View File

@ -838,15 +838,16 @@ class MachineManager(QObject):
# that are assigned to the parents of this material profile. # that are assigned to the parents of this material profile.
try: try:
inherited_files = material_container.getInheritedFiles() inherited_files = material_container.getInheritedFiles()
if inherited_files:
for inherited_file in inherited_files:
# Extract the ID from the path we used to load the file.
search_criteria["material"] = os.path.basename(inherited_file).split(".")[0]
containers = container_registry.findInstanceContainers(**search_criteria)
if containers:
return containers[0]
except AttributeError: # Material_container does not support inheritance. except AttributeError: # Material_container does not support inheritance.
pass inherited_files = []
if inherited_files:
for inherited_file in inherited_files:
# Extract the ID from the path we used to load the file.
search_criteria["material"] = os.path.basename(inherited_file).split(".")[0]
containers = container_registry.findInstanceContainers(**search_criteria)
if containers:
return containers[0]
# We still weren't able to find a quality for this specific material. # We still weren't able to find a quality for this specific material.
# Try to find qualities for a generic version of the material. # Try to find qualities for a generic version of the material.

View File

@ -182,7 +182,6 @@ class QualitySettingsModel(UM.Qt.ListModel.ListModel):
# If a setting is settable per extruder (not global) and we're looking at global tab, don't show this value. # If a setting is settable per extruder (not global) and we're looking at global tab, don't show this value.
if self._extruder_id == "" and settable_per_extruder: if self._extruder_id == "" and settable_per_extruder:
continue continue
items.append({ items.append({
"key": definition.key, "key": definition.key,
"label": definition.label, "label": definition.label,

View File

@ -86,7 +86,7 @@ class LayerView(View):
if not self._ghost_shader: if not self._ghost_shader:
self._ghost_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "color.shader")) self._ghost_shader = OpenGL.getInstance().createShaderProgram(Resources.getPath(Resources.Shaders, "color.shader"))
self._ghost_shader.setUniformValue("u_color", Color(0, 0, 0, 72)) self._ghost_shader.setUniformValue("u_color", Color(0, 0, 0, 64))
for node in DepthFirstIterator(scene.getRoot()): for node in DepthFirstIterator(scene.getRoot()):
# We do not want to render ConvexHullNode as it conflicts with the bottom layers. # We do not want to render ConvexHullNode as it conflicts with the bottom layers.
@ -98,10 +98,10 @@ class LayerView(View):
if node.getMeshData() and node.isVisible(): if node.getMeshData() and node.isVisible():
renderer.queueNode(node, renderer.queueNode(node,
shader = self._ghost_shader, shader = self._ghost_shader,
state_setup_callback = lambda gl: gl.glDepthMask(gl.GL_FALSE), type = RenderBatch.RenderType.Transparent )
state_teardown_callback = lambda gl: gl.glDepthMask(gl.GL_TRUE)
)
for node in DepthFirstIterator(scene.getRoot()):
if type(node) is SceneNode:
if node.getMeshData() and node.isVisible(): if node.getMeshData() and node.isVisible():
layer_data = node.callDecoration("getLayerData") layer_data = node.callDecoration("getLayerData")
if not layer_data: if not layer_data:

View File

@ -463,7 +463,7 @@ UM.MainWindow
target: Cura.Actions.addProfile target: Cura.Actions.addProfile
onTriggered: onTriggered:
{ {
Cura.ContainerManager.createQualityChanges(); Cura.ContainerManager.createQualityChanges(null);
preferences.setPage(4); preferences.setPage(4);
preferences.show(); preferences.show();

View File

@ -129,6 +129,7 @@ UM.ManagementPage
enabled: base.currentItem != null && base.currentItem.id != Cura.MachineManager.activeMaterialId enabled: base.currentItem != null && base.currentItem.id != Cura.MachineManager.activeMaterialId
onClicked: Cura.MachineManager.setActiveMaterial(base.currentItem.id) onClicked: Cura.MachineManager.setActiveMaterial(base.currentItem.id)
}, },
/* // apparently visible does not work on OS X
Button Button
{ {
text: catalog.i18nc("@action:button", "Duplicate"); text: catalog.i18nc("@action:button", "Duplicate");
@ -151,7 +152,9 @@ UM.ManagementPage
Cura.MachineManager.setActiveMaterial(material_id) Cura.MachineManager.setActiveMaterial(material_id)
} }
visible: false;
}, },
*/
Button Button
{ {
text: catalog.i18nc("@action:button", "Remove"); text: catalog.i18nc("@action:button", "Remove");
@ -159,12 +162,15 @@ UM.ManagementPage
enabled: base.currentItem != null && !base.currentItem.readOnly && !Cura.ContainerManager.isContainerUsed(base.currentItem.id) enabled: base.currentItem != null && !base.currentItem.readOnly && !Cura.ContainerManager.isContainerUsed(base.currentItem.id)
onClicked: confirmDialog.open() onClicked: confirmDialog.open()
}, },
/* // apparently visible does not work on OS X
Button Button
{ {
text: catalog.i18nc("@action:button", "Import"); text: catalog.i18nc("@action:button", "Import");
iconName: "document-import"; iconName: "document-import";
onClicked: importDialog.open(); onClicked: importDialog.open();
visible: false;
}, },
*/
Button Button
{ {
text: catalog.i18nc("@action:button", "Export") text: catalog.i18nc("@action:button", "Export")

View File

@ -61,6 +61,10 @@ UM.ManagementPage
return -1; return -1;
} }
function canCreateProfile() {
return base.currentItem && (base.currentItem.id == Cura.MachineManager.activeQualityId) && Cura.MachineManager.hasUserSettings;
}
buttons: [ buttons: [
Button Button
{ {
@ -69,26 +73,39 @@ UM.ManagementPage
enabled: base.currentItem != null ? base.currentItem.id != Cura.MachineManager.activeQualityId : false; enabled: base.currentItem != null ? base.currentItem.id != Cura.MachineManager.activeQualityId : false;
onClicked: Cura.MachineManager.setActiveQuality(base.currentItem.id) onClicked: Cura.MachineManager.setActiveQuality(base.currentItem.id)
}, },
// Create button
Button Button
{ {
text: base.currentItem && (base.currentItem.id == Cura.MachineManager.activeQualityId) && Cura.MachineManager.hasUserSettings ? catalog.i18nc("@label", "Create") : catalog.i18nc("@label", "Duplicate") text: catalog.i18nc("@label", "Create")
enabled: base.canCreateProfile()
visible: base.canCreateProfile()
iconName: "list-add"; iconName: "list-add";
onClicked: onClicked:
{ {
var selectedContainer; newNameDialog.object = base.currentItem != null ? base.currentItem.name : "";
if (base.currentItem.id == Cura.MachineManager.activeQualityId && Cura.MachineManager.hasUserSettings) { newNameDialog.open();
selectedContainer = Cura.ContainerManager.createQualityChanges(); newNameDialog.selectText();
} else {
selectedContainer = Cura.ContainerManager.duplicateQualityOrQualityChanges(base.currentItem.name);
}
base.selectContainer(selectedContainer);
renameDialog.removeWhenRejected = true;
renameDialog.open();
renameDialog.selectText();
} }
}, },
// Duplicate button
Button
{
text: catalog.i18nc("@label", "Duplicate")
enabled: ! base.canCreateProfile()
visible: ! base.canCreateProfile()
iconName: "list-add";
onClicked:
{
newDuplicateNameDialog.object = base.currentItem.name;
newDuplicateNameDialog.open();
newDuplicateNameDialog.selectText();
}
},
Button Button
{ {
text: catalog.i18nc("@action:button", "Remove"); text: catalog.i18nc("@action:button", "Remove");
@ -103,7 +120,6 @@ UM.ManagementPage
enabled: base.currentItem != null ? !base.currentItem.readOnly : false; enabled: base.currentItem != null ? !base.currentItem.readOnly : false;
onClicked: onClicked:
{ {
renameDialog.removeWhenRejected = false;
renameDialog.open(); renameDialog.open();
renameDialog.selectText(); renameDialog.selectText();
} }
@ -212,7 +228,7 @@ UM.ManagementPage
{ {
title: catalog.i18nc("@title:tab", "Global Settings"); title: catalog.i18nc("@title:tab", "Global Settings");
quality: base.currentItem != null ? base.currentItem.id : ""; quality: base.currentItem != null ? base.currentItem.id : "";
material: Cura.MachineManager.allActiveMaterialIds.global ? Cura.MachineManager.allActiveMaterialIds.global : "" material: Cura.MachineManager.allActiveMaterialIds[Cura.MachineManager.activeMachineId]
} }
Repeater Repeater
@ -249,24 +265,44 @@ UM.ManagementPage
objectList.currentIndex = -1 //Reset selection. objectList.currentIndex = -1 //Reset selection.
} }
} }
UM.RenameDialog UM.RenameDialog
{ {
id: renameDialog; id: renameDialog;
object: base.currentItem != null ? base.currentItem.name : "" object: base.currentItem != null ? base.currentItem.name : ""
property bool removeWhenRejected: false
onAccepted: onAccepted:
{ {
Cura.ContainerManager.renameQualityChanges(base.currentItem.name, newName) Cura.ContainerManager.renameQualityChanges(base.currentItem.name, newName)
objectList.currentIndex = -1 //Reset selection. objectList.currentIndex = -1 //Reset selection.
} }
onRejected: }
// Dialog to request a name when creating a new profile
UM.RenameDialog
{
id: newNameDialog;
object: "<new name>";
onAccepted:
{ {
if(removeWhenRejected) var selectedContainer = Cura.ContainerManager.createQualityChanges(newName);
{ base.selectContainer(selectedContainer);
Cura.ContainerManager.removeQualityChanges(base.currentItem.name) objectList.currentIndex = -1 //Reset selection.
}
} }
} }
// Dialog to request a name when duplicating a new profile
UM.RenameDialog
{
id: newDuplicateNameDialog;
object: "<new name>";
onAccepted:
{
var selectedContainer = Cura.ContainerManager.duplicateQualityOrQualityChanges(base.currentItem.name, newName);
base.selectContainer(selectedContainer);
objectList.currentIndex = -1 //Reset selection.
}
}
MessageDialog MessageDialog
{ {
id: messageDialog id: messageDialog

View File

@ -246,8 +246,8 @@ Item {
// This ensures that the value in any of the deeper containers need not be removed, which is // This ensures that the value in any of the deeper containers need not be removed, which is
// needed for the reset button (which deletes the top value) to correctly go back to profile // needed for the reset button (which deletes the top value) to correctly go back to profile
// defaults. // defaults.
propertyProvider.setPropertyValue("state", "InstanceState.Calculated")
propertyProvider.setPropertyValue("value", propertyProvider.getPropertyValue("value", last_entry)) propertyProvider.setPropertyValue("value", propertyProvider.getPropertyValue("value", last_entry))
propertyProvider.setPropertyValue("state", "InstanceState.Calculated")
} }
} }