Get build plate shape options from the fdmprinter definition

This commit is contained in:
fieldOfView 2016-11-29 10:54:48 +01:00
parent ff0f63eb94
commit 86383b2be0

View File

@ -137,11 +137,32 @@ Cura.MachineAction
id: shapesModel id: shapesModel
Component.onCompleted: Component.onCompleted:
{ {
shapesModel.append({ text: catalog.i18nc("@option:build plate shape", "Rectangular"), value: "rectangular" }); // Options come in as a string-representation of an OrderedDict
shapesModel.append({ text: catalog.i18nc("@option:build plate shape", "Elliptic"), value: "elliptic" }); var options = machineShapeProvider.properties.options.match(/^OrderedDict\(\[\((.*)\)\]\)$/);
shapeComboBox.currentIndex = machineShapeProvider.properties.value != shapesModel.get(1).value ? 0 : 1 if(options)
{
options = options[1].split("), (")
for(var i = 0; i < options.length; i++)
{
var option = options[i].substring(1, options[i].length - 1).split("', '")
shapesModel.append({text: option[1], value: option[0]});
}
}
} }
} }
currentIndex:
{
var currentValue = machineShapeProvider.properties.value;
var index = 0;
for(var i = 0; i < shapesModel.count; i++)
{
if(shapesModel.get(i).value == currentValue) {
index = i;
break;
}
}
return index
}
onActivated: onActivated:
{ {
machineShapeProvider.setPropertyValue("value", shapesModel.get(index).value); machineShapeProvider.setPropertyValue("value", shapesModel.get(index).value);
@ -467,7 +488,7 @@ Cura.MachineAction
containerStackId: Cura.MachineManager.activeMachineId containerStackId: Cura.MachineManager.activeMachineId
key: "machine_shape" key: "machine_shape"
watchedProperties: [ "value" ] watchedProperties: [ "value", "options" ]
storeIndex: manager.containerIndex storeIndex: manager.containerIndex
} }