Merge pull request #4048 from Ultimaker/CURA-5408-material-profiles

CURA-5408 weight for materials + bug fixes
This commit is contained in:
Lipu Fei 2018-07-13 07:54:58 +02:00 committed by GitHub
commit a0c3767184
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 75 deletions

View file

@ -103,7 +103,6 @@ TabView
onYes:
{
Cura.ContainerManager.setContainerProperty(base.containerId, "material_diameter", "value", new_diameter_value);
base.setMetaDataEntry("approximate_diameter", old_approximate_diameter_value, getApproximateDiameter(new_diameter_value).toString());
base.setMetaDataEntry("properties/diameter", properties.diameter, new_diameter_value);
}
@ -230,7 +229,7 @@ TabView
{
// This does not use a SettingPropertyProvider, because we need to make the change to all containers
// which derive from the same base_file
var old_diameter = Cura.ContainerManager.getContainerProperty(base.containerId, "material_diameter", "value").toString();
var old_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties/diameter");
var old_approximate_diameter = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "approximate_diameter");
var new_approximate_diameter = getApproximateDiameter(value);
if (new_approximate_diameter != Cura.ExtruderManager.getActiveExtruderStack().approximateMaterialDiameter)
@ -242,7 +241,6 @@ TabView
confirmDiameterChangeDialog.open()
}
else {
Cura.ContainerManager.setContainerProperty(base.containerId, "material_diameter", "value", value);
base.setMetaDataEntry("approximate_diameter", old_approximate_diameter, getApproximateDiameter(value).toString());
base.setMetaDataEntry("properties/diameter", properties.diameter, value);
}
@ -271,7 +269,7 @@ TabView
{
id: spoolWeightSpinBox
width: scrollView.columnWidth
value: base.getMaterialPreferenceValue(properties.guid, "spool_weight")
value: base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"))
suffix: " g"
stepSize: 100
decimals: 0
@ -468,7 +466,7 @@ TabView
}
if(!spoolWeight)
{
spoolWeight = base.getMaterialPreferenceValue(properties.guid, "spool_weight");
spoolWeight = base.getMaterialPreferenceValue(properties.guid, "spool_weight", Cura.ContainerManager.getContainerMetaDataEntry(properties.container_id, "properties/weight"));
}
if (diameter == 0 || density == 0 || spoolWeight == 0)
@ -517,21 +515,34 @@ TabView
// value has not changed
return;
}
materialPreferenceValues[material_guid][entry_name] = new_value;
if (entry_name in materialPreferenceValues[material_guid] && new_value.toString() == 0)
{
// no need to store a 0, that's the default, so remove it
materialPreferenceValues[material_guid].delete(entry_name);
if (!(materialPreferenceValues[material_guid]))
{
// remove empty map
materialPreferenceValues.delete(material_guid);
}
}
if (new_value.toString() != 0)
{
// store new value
materialPreferenceValues[material_guid][entry_name] = new_value;
}
// store preference
UM.Preferences.setValue("cura/material_settings", JSON.stringify(materialPreferenceValues));
}
function getMaterialPreferenceValue(material_guid, entry_name)
function getMaterialPreferenceValue(material_guid, entry_name, default_value)
{
if(material_guid in materialPreferenceValues && entry_name in materialPreferenceValues[material_guid])
{
return materialPreferenceValues[material_guid][entry_name];
}
var material_weight = Cura.ContainerManager.getContainerMetaDataEntry(base.containerId, "properties", "weight");
return material_weight || 0;
default_value = default_value | 0;
return default_value;
}
// update the display name of the material

View file

@ -486,6 +486,7 @@ Item
materialProperties.name = currentItem.name ? currentItem.name : "Unknown";
materialProperties.guid = currentItem.guid;
materialProperties.container_id = currentItem.container_id;
materialProperties.brand = currentItem.brand ? currentItem.brand : "Unknown";
materialProperties.material = currentItem.material ? currentItem.material : "Unknown";
@ -543,6 +544,7 @@ Item
id: materialProperties
property string guid: "00000000-0000-0000-0000-000000000000"
property string container_id: "Unknown";
property string name: "Unknown";
property string profile_type: "Unknown";
property string brand: "Unknown";