CURA-4303 finish infill slider, images, gradual checkbox, bindings

This commit is contained in:
ChrisTerBeke 2017-09-18 15:15:59 +02:00
parent e8df185261
commit 9553235b42

View File

@ -397,24 +397,26 @@ Item
} }
// //
// NEW Infill // Infill
// //
Item Item
{ {
id: newInfillCellLeft id: infillCellLeft
anchors.top: speedLabel.top anchors.top: speedLabel.top
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height * 1.2 anchors.topMargin: UM.Theme.getSize("sidebar_margin").height * 1.2 // FIXME better margin value
anchors.left: parent.left anchors.left: parent.left
width: UM.Theme.getSize("sidebar").width * .45 - UM.Theme.getSize("sidebar_margin").width width: UM.Theme.getSize("sidebar").width * .45 - UM.Theme.getSize("sidebar_margin").width
height: UM.Theme.getSize("sidebar_margin").height height: UM.Theme.getSize("sidebar_margin").height
Text Text
{ {
id: newInfillLabel id: infillLabel
//: Infill selection label text: catalog.i18nc("@label", "Infill")
text: catalog.i18nc("@label", "Infill"); font: UM.Theme.getFont("default")
font: UM.Theme.getFont("default"); color: UM.Theme.getColor("text")
color: UM.Theme.getColor("text");
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.left: parent.left anchors.left: parent.left
@ -424,65 +426,81 @@ Item
Item Item
{ {
id: newInfillCellRight id: infillCellRight
height: UM.Theme.getSize("sidebar_margin").height height: infillSlider.height + enableGradualInfillCheckBox.height + (UM.Theme.getSize("sidebar_margin").height * 2)
width: UM.Theme.getSize("sidebar").width * .55 width: UM.Theme.getSize("sidebar").width * .55
anchors.left: newInfillCellLeft.right anchors.left: infillCellLeft.right
anchors.top: newInfillCellLeft.top anchors.top: infillCellLeft.top
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
Text Text {
{
id: selectedInfillRateText id: selectedInfillRateText
anchors.top: parent.top anchors.top: parent.top
anchors.left: infillSlider.left anchors.left: infillSlider.left
anchors.leftMargin: (infillSlider.value / infillSlider.stepSize) * (infillSlider.width / (infillSlider.maximumValue / infillSlider.stepSize)) - 9 anchors.leftMargin: (infillSlider.value / infillSlider.stepSize) * (infillSlider.width / (infillSlider.maximumValue / infillSlider.stepSize)) - 10
anchors.right: parent.right anchors.right: parent.right
height: UM.Theme.getSize("sidebar_margin").height / 10
text: "10%" text: infillSlider.value + "%"
horizontalAlignment: Text.AlignLeft horizontalAlignment: Text.AlignLeft
color: infillSlider.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
} }
Slider Slider
{ {
id: infillSlider id: infillSlider
anchors.top: selectedInfillRateText.bottom anchors.top: selectedInfillRateText.bottom
anchors.left: parent.left anchors.left: parent.left + UM.Theme.getSize("sidebar_margin").widt
height: UM.Theme.getSize("sidebar_margin").height * 5
height: UM.Theme.getSize("sidebar_margin").height
width: infillCellRight.width - infillIcon.width - UM.Theme.getSize("sidebar_margin").width
minimumValue: 0 minimumValue: 0
maximumValue: 100 maximumValue: 100
stepSize: 5 stepSize: 10
tickmarksEnabled: true tickmarksEnabled: true
// disable slider when gradual support is enabled
enabled: parseInt(infillSteps.properties.value) == 0
// set initial value from stack
value: parseInt(infillDensity.properties.value)
onValueChanged: {
infillDensity.setPropertyValue("value", infillSlider.value)
}
style: SliderStyle style: SliderStyle
{ {
groove: Rectangle { groove: Rectangle {
id: groove id: groove
implicitWidth: 200 implicitWidth: 200
implicitHeight: 2 implicitHeight: 2
color: "gray" color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
radius: 1 radius: 1
} }
handle: Item
{ handle: Item {
Rectangle { Rectangle {
id: handleButton id: handleButton
anchors.centerIn: parent anchors.centerIn: parent
color: control.hovered ? UM.Theme.getColor("quality_slider_handle_hover") : UM.Theme.getColor("quality_slider_handle") color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
implicitWidth: 10 implicitWidth: 10
implicitHeight: 10 implicitHeight: 10
radius: 10 radius: 10
} }
} }
tickmarks: Repeater { tickmarks: Repeater {
id: repeater id: repeater
model: control.maximumValue / control.stepSize + 1 model: control.maximumValue / control.stepSize + 1
Rectangle { Rectangle {
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: UM.Theme.getColor("quality_slider_available") color: control.enabled ? UM.Theme.getColor("quality_slider_available") : UM.Theme.getColor("quality_slider_unavailable")
width: 1 width: 1
height: 6 height: 6
y: 0 y: 0
@ -491,242 +509,161 @@ Item
} }
} }
} }
}
// Item
// Infill
//
Item
{
id: infillCellLeft
anchors.top: newInfillCellRight.bottom
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height * 1.2
anchors.left: parent.left
width: UM.Theme.getSize("sidebar").width * .45 - UM.Theme.getSize("sidebar_margin").width
height: childrenRect.height
Text
{ {
id: infillLabel width: (infillCellRight.width / 5) - (UM.Theme.getSize("sidebar_margin").width)
//: Infill selection label height: width
text: catalog.i18nc("@label", "Infill");
font: UM.Theme.getFont("default");
color: UM.Theme.getColor("text");
anchors.top: parent.top
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
}
}
Row anchors.right: infillCellRight.right
{ anchors.top: infillSlider.top
id: infillCellRight
height: childrenRect.height; // we loop over all density icons and only show the one that has the current density and steps
width: UM.Theme.getSize("sidebar").width * .55 Repeater
spacing: UM.Theme.getSize("sidebar_margin").width
anchors.left: infillCellLeft.right
anchors.top: infillCellLeft.top
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
Repeater
{
id: infillListView
property int activeIndex:
{ {
for(var i = 0; i < infillModel.count; ++i) id: infillIconList
{ model: infillModel
var density = parseInt(infillDensity.properties.value);
var steps = parseInt(infillSteps.properties.value); property int activeIndex: {
if(density > infillModel.get(i).percentageMin && density <= infillModel.get(i).percentageMax && steps > infillModel.get(i).stepsMin && steps <= infillModel.get(i).stepsMax) for (var i = 0; i < infillModel.count; i++) {
{ var density = parseInt(infillDensity.properties.value)
return i; var steps = parseInt(infillSteps.properties.value)
var infillModelItem = infillModel.get(i)
if (density >= infillModelItem.percentageMin
&& density <= infillModelItem.percentageMax
&& steps >= infillModelItem.stepsMin
&& steps <= infillModelItem.stepsMax){
return i
}
} }
return -1
} }
return -1; Item {
} anchors.fill: parent
model: infillModel;
Item Rectangle {
{
width: childrenRect.width;
height: childrenRect.height;
Rectangle
{
id: infillIconLining
width: (infillCellRight.width - ((infillModel.count - 1) * UM.Theme.getSize("sidebar_margin").width)) / (infillModel.count);
height: width
border.color:
{
if(!base.settingsEnabled)
{
return UM.Theme.getColor("setting_control_disabled_border")
}
else if(infillListView.activeIndex == index)
{
return UM.Theme.getColor("setting_control_selected")
}
else if(infillMouseArea.containsMouse)
{
return UM.Theme.getColor("setting_control_border_highlight")
}
return UM.Theme.getColor("setting_control_border")
}
border.width: UM.Theme.getSize("default_lining").width
color:
{
if(infillListView.activeIndex == index)
{
if(!base.settingsEnabled)
{
return UM.Theme.getColor("setting_control_disabled_text")
}
return UM.Theme.getColor("setting_control_selected")
}
return "transparent"
}
UM.RecolorImage
{
id: infillIcon
anchors.fill: parent;
anchors.margins: 2
sourceSize.width: width
sourceSize.height: width
source: UM.Theme.getIcon(model.icon);
color: {
if(infillListView.activeIndex == index)
{
return UM.Theme.getColor("text_emphasis")
}
if(!base.settingsEnabled)
{
return UM.Theme.getColor("setting_control_disabled_text")
}
return UM.Theme.getColor("setting_control_disabled_text")
}
}
MouseArea
{
id: infillMouseArea
anchors.fill: parent anchors.fill: parent
hoverEnabled: true visible: infillIconList.activeIndex == index
enabled: base.settingsEnabled
onClicked: { UM.RecolorImage {
if (infillListView.activeIndex != index) id: infillIcon
{ anchors.fill: parent
infillDensity.setPropertyValue("value", model.percentage) sourceSize.width: width
infillSteps.setPropertyValue("value", model.steps) sourceSize.height: width
} source: UM.Theme.getIcon(model.icon)
} color: UM.Theme.getColor("quality_slider_available")
onEntered:
{
base.showTooltip(infillCellRight, Qt.point(-infillCellRight.x, 0), model.text);
}
onExited:
{
base.hideTooltip();
} }
} }
} }
Text
{
id: infillLabel
width: (infillCellRight.width - ((infillModel.count - 1) * UM.Theme.getSize("sidebar_margin").width)) / (infillModel.count);
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
wrapMode: Text.WordWrap
font: UM.Theme.getFont("default")
anchors.top: infillIconLining.bottom
anchors.horizontalCenter: infillIconLining.horizontalCenter
color: infillListView.activeIndex == index ? UM.Theme.getColor("setting_control_text") : UM.Theme.getColor("setting_control_border")
text: name
}
} }
} }
// Gradual Support Infill Checkbox
CheckBox {
id: enableGradualInfillCheckBox
property alias _hovered: enableGradualInfillMouseArea.containsMouse
anchors.top: infillSlider.bottom
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.left: infillCellRight.left
style: UM.Theme.styles.checkbox
enabled: base.settingsEnabled
checked: parseInt(infillSteps.properties.value) > 0
MouseArea {
id: enableGradualInfillMouseArea
anchors.fill: parent
hoverEnabled: true
enabled: true
onClicked: {
infillSteps.setPropertyValue("value", (parseInt(infillSteps.properties.value) == 0) ? 5 : 0)
infillDensity.setPropertyValue("value", 90)
}
onEntered: {
base.showTooltip(enableGradualInfillCheckBox, Qt.point(-infillCellRight.x, 0),
catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top."))
}
onExited: {
base.hideTooltip()
}
}
Text {
id: gradualInfillLabel
anchors.left: enableGradualInfillCheckBox.right
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width / 2 // FIXME better margin value
text: catalog.i18nc("@label", "Enable gradual")
font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text")
}
}
// Infill list model for mapping icon
ListModel ListModel
{ {
id: infillModel id: infillModel
Component.onCompleted: Component.onCompleted:
{ {
infillModel.append({ infillModel.append({
name: catalog.i18nc("@label", "0%"),
percentage: 0,
steps: 0,
percentageMin: -1, percentageMin: -1,
percentageMax: 0, percentageMax: 0,
stepsMin: -1, stepsMin: -1,
stepsMax: 0, stepsMax: 0,
text: catalog.i18nc("@label", "Empty infill will leave your model hollow with low strength."),
icon: "hollow" icon: "hollow"
}) })
infillModel.append({ infillModel.append({
name: catalog.i18nc("@label", "20%"),
percentage: 20,
steps: 0,
percentageMin: 0, percentageMin: 0,
percentageMax: 30, percentageMax: 40,
stepsMin: -1, stepsMin: -1,
stepsMax: 0, stepsMax: 0,
text: catalog.i18nc("@label", "Light (20%) infill will give your model an average strength."),
icon: "sparse" icon: "sparse"
}) })
infillModel.append({ infillModel.append({
name: catalog.i18nc("@label", "50%"), percentageMin: 40,
percentage: 50, percentageMax: 89,
steps: 0,
percentageMin: 30,
percentageMax: 70,
stepsMin: -1, stepsMin: -1,
stepsMax: 0, stepsMax: 0,
text: catalog.i18nc("@label", "Dense (50%) infill will give your model an above average strength."),
icon: "dense" icon: "dense"
}) })
infillModel.append({ infillModel.append({
name: catalog.i18nc("@label", "100%"), percentageMin: 90,
percentage: 100,
steps: 0,
percentageMin: 70,
percentageMax: 9999999999, percentageMax: 9999999999,
stepsMin: -1, stepsMin: -1,
stepsMax: 0, stepsMax: 0,
text: catalog.i18nc("@label", "Solid (100%) infill will make your model completely solid."),
icon: "solid" icon: "solid"
}) })
infillModel.append({ infillModel.append({
name: catalog.i18nc("@label", "Gradual"),
percentage: 90,
steps: 5,
percentageMin: 0, percentageMin: 0,
percentageMax: 9999999999, percentageMax: 9999999999,
stepsMin: 0, stepsMin: 1,
stepsMax: 9999999999, stepsMax: 9999999999,
infill_layer_height: 1.5,
text: catalog.i18nc("@label", "Gradual infill will gradually increase the amount of infill towards the top."),
icon: "gradual" icon: "gradual"
}) })
} }
} }
} }
//
// Enable support
//
Text Text
{ {
id: enableSupportLabel id: enableSupportLabel
visible: enableSupportCheckBox.visible visible: enableSupportCheckBox.visible
anchors.top: infillCellRight.bottom
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
anchors.verticalCenter: enableSupportCheckBox.verticalCenter anchors.verticalCenter: enableSupportCheckBox.verticalCenter
text: catalog.i18nc("@label", "Generate Support"); text: catalog.i18nc("@label", "Generate Support");
font: UM.Theme.getFont("default"); font: UM.Theme.getFont("default");
color: UM.Theme.getColor("text"); color: UM.Theme.getColor("text");
@ -942,7 +879,6 @@ Item
anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width anchors.rightMargin: UM.Theme.getSize("sidebar_margin").width
anchors.top: parent.top anchors.top: parent.top
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
//: Tips label
text: catalog.i18nc("@label", "Need help improving your prints?<br>Read the <a href='%1'>Ultimaker Troubleshooting Guides</a>").arg("https://ultimaker.com/en/troubleshooting") text: catalog.i18nc("@label", "Need help improving your prints?<br>Read the <a href='%1'>Ultimaker Troubleshooting Guides</a>").arg("https://ultimaker.com/en/troubleshooting")
font: UM.Theme.getFont("default"); font: UM.Theme.getFont("default");
color: UM.Theme.getColor("text"); color: UM.Theme.getColor("text");
@ -961,35 +897,9 @@ Item
storeIndex: 0 storeIndex: 0
} }
Binding
{
target: infillDensity
property: "containerStackId"
value:
{
var activeMachineId = Cura.MachineManager.activeMachineId;
if (machineExtruderCount.properties.value > 1)
{
var infillExtruderNr = parseInt(infillExtruderNumber.properties.value);
if (infillExtruderNr >= 0)
{
activeMachineId = ExtruderManager.extruderIds[infillExtruderNumber.properties.value];
}
else if (ExtruderManager.activeExtruderStackId)
{
activeMachineId = ExtruderManager.activeExtruderStackId;
}
}
infillSteps.containerStackId = activeMachineId;
return activeMachineId;
}
}
UM.SettingPropertyProvider UM.SettingPropertyProvider
{ {
id: infillDensity id: infillDensity
containerStackId: Cura.MachineManager.activeStackId containerStackId: Cura.MachineManager.activeStackId
key: "infill_sparse_density" key: "infill_sparse_density"
watchedProperties: [ "value" ] watchedProperties: [ "value" ]
@ -999,10 +909,9 @@ Item
UM.SettingPropertyProvider UM.SettingPropertyProvider
{ {
id: infillSteps id: infillSteps
containerStackId: Cura.MachineManager.activeStackId containerStackId: Cura.MachineManager.activeStackId
key: "gradual_infill_steps" key: "gradual_infill_steps"
watchedProperties: [ "value" ] watchedProperties: ["value"]
storeIndex: 0 storeIndex: 0
} }