Checked all divisions (again..) and multiplications on rounding errors

CURA-4941
This commit is contained in:
Mark 2018-02-10 12:45:36 +01:00
parent b52bf6decf
commit 461da709ff
16 changed files with 38 additions and 38 deletions

View file

@ -70,8 +70,8 @@ Cura.MachineAction
anchors.top: pageTitle.bottom anchors.top: pageTitle.bottom
anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.topMargin: UM.Theme.getSize("default_margin").height
property real columnWidth: ((width - 3 * UM.Theme.getSize("default_margin").width) / 2) | 0 property real columnWidth: Math.floor((width - 3 * UM.Theme.getSize("default_margin").width) / 2)
property real labelColumnWidth: columnWidth * 0.5 property real labelColumnWidth: Math.floor(columnWidth / 2)
Tab Tab
{ {

View file

@ -461,7 +461,7 @@ Item
visible: viewSettings.show_feedrate_gradient visible: viewSettings.show_feedrate_gradient
anchors.left: parent.right anchors.left: parent.right
height: parent.width height: parent.width
width: UM.Theme.getSize("layerview_row").height * 1.5 width: Math.floor(UM.Theme.getSize("layerview_row").height * 1.5)
border.width: UM.Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("lining") border.color: UM.Theme.getColor("lining")
transform: Rotation {origin.x: 0; origin.y: 0; angle: 90} transform: Rotation {origin.x: 0; origin.y: 0; angle: 90}
@ -492,7 +492,7 @@ Item
visible: viewSettings.show_thickness_gradient visible: viewSettings.show_thickness_gradient
anchors.left: parent.right anchors.left: parent.right
height: parent.width height: parent.width
width: UM.Theme.getSize("layerview_row").height * 1.5 width: Math.floor(UM.Theme.getSize("layerview_row").height * 1.5)
border.width: UM.Theme.getSize("default_lining").width border.width: UM.Theme.getSize("default_lining").width
border.color: UM.Theme.getColor("lining") border.color: UM.Theme.getColor("lining")
transform: Rotation {origin.x: 0; origin.y: 0; angle: 90} transform: Rotation {origin.x: 0; origin.y: 0; angle: 90}

View file

@ -59,8 +59,8 @@ UM.ManagementPage
anchors.right: parent.right anchors.right: parent.right
Rectangle Rectangle
{ {
width: (parent.height * 0.8) | 0 width: Math.floor(parent.height * 0.8)
height: (parent.height * 0.8) | 0 height: Math.floor(parent.height * 0.8)
color: model.metadata.color_code color: model.metadata.color_code
border.color: isCurrentItem ? palette.highlightedText : palette.text; border.color: isCurrentItem ? palette.highlightedText : palette.text;
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter

View file

@ -187,8 +187,8 @@ Button
id: settingsButton id: settingsButton
visible: base.hovered || settingsButton.hovered visible: base.hovered || settingsButton.hovered
height: base.height * 0.6 height: Math.floor(base.height * 0.6)
width: base.height * 0.6 width: Math.floor(base.height * 0.6)
anchors { anchors {
right: inheritButton.visible ? inheritButton.left : parent.right right: inheritButton.visible ? inheritButton.left : parent.right

View file

@ -68,7 +68,7 @@ SettingItem
{ {
id: downArrow id: downArrow
x: control.width - width - control.rightPadding x: control.width - width - control.rightPadding
y: control.topPadding + (control.availableHeight - height) / 2 y: control.topPadding + Math.floor((control.availableHeight - height) / 2)
source: UM.Theme.getIcon("arrow_bottom") source: UM.Theme.getIcon("arrow_bottom")
width: UM.Theme.getSize("standard_arrow").width width: UM.Theme.getSize("standard_arrow").width

View file

@ -108,7 +108,7 @@ Item {
id: label; id: label;
anchors.left: parent.left; anchors.left: parent.left;
anchors.leftMargin: doDepthIndentation ? (UM.Theme.getSize("section_icon_column").width + 5) + ((definition.depth - 1) * UM.Theme.getSize("setting_control_depth_margin").width) : 0 anchors.leftMargin: doDepthIndentation ? Math.floor((UM.Theme.getSize("section_icon_column").width + 5) + ((definition.depth - 1) * UM.Theme.getSize("setting_control_depth_margin").width)) : 0
anchors.right: settingControls.left; anchors.right: settingControls.left;
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter

View file

@ -204,7 +204,7 @@ Item
iconSource: UM.Theme.getIcon("cross1") iconSource: UM.Theme.getIcon("cross1")
visible: findingSettings visible: findingSettings
height: parent.height * 0.4 height: Math.floor(parent.height * 0.4)
width: visible ? height : 0 width: visible ? height : 0
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
@ -388,7 +388,7 @@ Item
contextMenu.provider = provider contextMenu.provider = provider
contextMenu.popup(); contextMenu.popup();
} }
onShowTooltip: base.showTooltip(delegate, { x: -UM.Theme.getSize("default_arrow").width, y: delegate.height / 2 }, text) onShowTooltip: base.showTooltip(delegate, { x: -UM.Theme.getSize("default_arrow").width, y: Math.floor(delegate.height / 2) }, text)
onHideTooltip: base.hideTooltip() onHideTooltip: base.hideTooltip()
onShowAllHiddenInheritedSettings: onShowAllHiddenInheritedSettings:
{ {

View file

@ -171,7 +171,7 @@ Rectangle
id: control id: control
height: settingsModeSelection.height height: settingsModeSelection.height
width: Math.floor(0.5 * parent.width) width: Math.floor(parent.width / 2)
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: model.index * Math.floor(settingsModeSelection.width / 2) anchors.leftMargin: model.index * Math.floor(settingsModeSelection.width / 2)

View file

@ -257,7 +257,7 @@ Column
visible: Cura.MachineManager.hasMaterials visible: Cura.MachineManager.hasMaterials
enabled: !extrudersList.visible || base.currentExtruderIndex > -1 enabled: !extrudersList.visible || base.currentExtruderIndex > -1
height: UM.Theme.getSize("setting_control").height height: UM.Theme.getSize("setting_control").height
width: parent.width * 0.7 + UM.Theme.getSize("sidebar_margin").width width: Math.floor(parent.width * 0.7) + UM.Theme.getSize("sidebar_margin").width
anchors.right: parent.right anchors.right: parent.right
style: UM.Theme.styles.sidebar_header_button style: UM.Theme.styles.sidebar_header_button
activeFocusOnPress: true; activeFocusOnPress: true;

View file

@ -146,16 +146,16 @@ Item
} }
function calculateSliderStepWidth (totalTicks) { function calculateSliderStepWidth (totalTicks) {
qualityModel.qualitySliderStepWidth = totalTicks != 0 ? (base.width * 0.55) / (totalTicks) : 0 qualityModel.qualitySliderStepWidth = totalTicks != 0 ? Math.floor((base.width * 0.55) / (totalTicks)) : 0
} }
function calculateSliderMargins (availableMin, availableMax, totalTicks) { function calculateSliderMargins (availableMin, availableMax, totalTicks) {
if (availableMin == -1 || (availableMin == 0 && availableMax == 0)) { if (availableMin == -1 || (availableMin == 0 && availableMax == 0)) {
qualityModel.qualitySliderMarginRight = base.width * 0.55 qualityModel.qualitySliderMarginRight = Math.floor(base.width * 0.55)
} else if (availableMin == availableMax) { } else if (availableMin == availableMax) {
qualityModel.qualitySliderMarginRight = (totalTicks - availableMin) * qualitySliderStepWidth qualityModel.qualitySliderMarginRight = Math.floor((totalTicks - availableMin) * qualitySliderStepWidth)
} else { } else {
qualityModel.qualitySliderMarginRight = (totalTicks - availableMax) * qualitySliderStepWidth qualityModel.qualitySliderMarginRight = Math.floor((totalTicks - availableMax) * qualitySliderStepWidth)
} }
} }
@ -236,7 +236,7 @@ Item
Item Item
{ {
id: speedSlider id: speedSlider
width: base.width * 0.55 width: Math.floor(base.width * 0.55)
height: UM.Theme.getSize("sidebar_margin").height height: UM.Theme.getSize("sidebar_margin").height
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
@ -246,7 +246,7 @@ Item
Rectangle Rectangle
{ {
id: groovechildrect id: groovechildrect
width: base.width * 0.55 width: Math.floor(base.width * 0.55)
height: 2 * screenScaleFactor height: 2 * screenScaleFactor
color: UM.Theme.getColor("quality_slider_unavailable") color: UM.Theme.getColor("quality_slider_unavailable")
anchors.verticalCenter: qualitySlider.verticalCenter anchors.verticalCenter: qualitySlider.verticalCenter
@ -266,7 +266,7 @@ Item
width: 1 * screenScaleFactor width: 1 * screenScaleFactor
height: 6 * screenScaleFactor height: 6 * screenScaleFactor
y: 0 y: 0
x: qualityModel.qualitySliderStepWidth * index x: Math.floor(qualityModel.qualitySliderStepWidth * index)
} }
} }
@ -362,7 +362,7 @@ Item
text: catalog.i18nc("@label", "Print Speed") text: catalog.i18nc("@label", "Print Speed")
font: UM.Theme.getFont("default") font: UM.Theme.getFont("default")
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
width: parseInt(UM.Theme.getSize("sidebar").width * 0.35) width: Math.floor(UM.Theme.getSize("sidebar").width * 0.35)
elide: Text.ElideRight elide: Text.ElideRight
} }
@ -438,7 +438,7 @@ Item
anchors.topMargin: UM.Theme.getSize("sidebar_margin").height * 2 anchors.topMargin: UM.Theme.getSize("sidebar_margin").height * 2
anchors.left: parent.left anchors.left: parent.left
width: parseInt(UM.Theme.getSize("sidebar").width * .45 - UM.Theme.getSize("sidebar_margin").width) width: Math.floor(UM.Theme.getSize("sidebar").width * .45) - UM.Theme.getSize("sidebar_margin").width
Label Label
{ {
@ -448,7 +448,7 @@ Item
color: UM.Theme.getColor("text") color: UM.Theme.getColor("text")
anchors.top: parent.top anchors.top: parent.top
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height * 1.7) anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 1.7)
anchors.left: parent.left anchors.left: parent.left
anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width anchors.leftMargin: UM.Theme.getSize("sidebar_margin").width
} }
@ -459,7 +459,7 @@ Item
id: infillCellRight id: infillCellRight
height: infillSlider.height + UM.Theme.getSize("sidebar_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("sidebar_margin").height) height: infillSlider.height + UM.Theme.getSize("sidebar_margin").height + enableGradualInfillCheckBox.visible * (enableGradualInfillCheckBox.height + UM.Theme.getSize("sidebar_margin").height)
width: parseInt(UM.Theme.getSize("sidebar").width * .55) width: Math.floor(UM.Theme.getSize("sidebar").width * .55)
anchors.left: infillCellLeft.right anchors.left: infillCellLeft.right
anchors.top: infillCellLeft.top anchors.top: infillCellLeft.top
@ -737,7 +737,7 @@ Item
visible: enableSupportCheckBox.visible visible: enableSupportCheckBox.visible
anchors.top: infillCellRight.bottom anchors.top: infillCellRight.bottom
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height * 1.5) anchors.topMargin: Math.floor(UM.Theme.getSize("sidebar_margin").height * 1.5)
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.right: infillCellLeft.right anchors.right: infillCellLeft.right
@ -823,7 +823,7 @@ Item
anchors.topMargin: ((supportEnabled.properties.value === "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("sidebar_margin").height : 0 anchors.topMargin: ((supportEnabled.properties.value === "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("sidebar_margin").height : 0
anchors.left: infillCellRight.left anchors.left: infillCellRight.left
width: UM.Theme.getSize("sidebar").width * .55 width: Math.floor(UM.Theme.getSize("sidebar").width * .55)
height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0 height: ((supportEnabled.properties.value == "True") && (machineExtruderCount.properties.value > 1)) ? UM.Theme.getSize("setting_control").height : 0
Behavior on height { NumberAnimation { duration: 100 } } Behavior on height { NumberAnimation { duration: 100 } }
@ -952,7 +952,7 @@ Item
{ {
id: tipsCell id: tipsCell
anchors.top: adhesionCheckBox.visible ? adhesionCheckBox.bottom : (enableSupportCheckBox.visible ? supportExtruderCombobox.bottom : infillCellRight.bottom) anchors.top: adhesionCheckBox.visible ? adhesionCheckBox.bottom : (enableSupportCheckBox.visible ? supportExtruderCombobox.bottom : infillCellRight.bottom)
anchors.topMargin: parseInt(UM.Theme.getSize("sidebar_margin").height * 2) anchors.topMargin: UM.Theme.getSize("sidebar_margin").height * 2
anchors.left: parent.left anchors.left: parent.left
width: parent.width width: parent.width
height: tipsText.contentHeight * tipsText.lineCount height: tipsText.contentHeight * tipsText.lineCount

View file

@ -219,7 +219,7 @@ Rectangle
anchors.topMargin: UM.Theme.getSize("default_margin").height anchors.topMargin: UM.Theme.getSize("default_margin").height
anchors.right: viewModeButton.right anchors.right: viewModeButton.right
property var buttonTarget: Qt.point(viewModeButton.x + viewModeButton.width / 2, viewModeButton.y + viewModeButton.height / 2) property var buttonTarget: Qt.point(viewModeButton.x + Math.floor(viewModeButton.width / 2), viewModeButton.y + Math.floor(viewModeButton.height / 2))
height: childrenRect.height height: childrenRect.height
width: childrenRect.width width: childrenRect.width

View file

@ -121,13 +121,13 @@ QtObject {
Item Item
{ {
anchors.centerIn: parent anchors.centerIn: parent
width: textLabel.width + icon.width + Theme.getSize("default_margin").width / 2 width: textLabel.width + icon.width + Math.floor(Theme.getSize("default_margin").width / 2)
Label Label
{ {
id: textLabel id: textLabel
text: control.text text: control.text
anchors.right: icon.visible ? icon.left : parent.right anchors.right: icon.visible ? icon.left : parent.right
anchors.rightMargin: icon.visible ? Theme.getSize("default_margin").width / 2 : 0 anchors.rightMargin: icon.visible ? Math.floor(Theme.getSize("default_margin").width / 2) : 0
anchors.verticalCenter: parent.verticalCenter; anchors.verticalCenter: parent.verticalCenter;
font: control.checked ? UM.Theme.getFont("large") : UM.Theme.getFont("large_nonbold") font: control.checked ? UM.Theme.getFont("large") : UM.Theme.getFont("large_nonbold")
color: color:
@ -329,9 +329,9 @@ QtObject {
UM.RecolorImage { UM.RecolorImage {
id: tool_button_arrow id: tool_button_arrow
anchors.right: parent.right; anchors.right: parent.right;
anchors.rightMargin: (Theme.getSize("button").width - Theme.getSize("button_icon").width) / 4 anchors.rightMargin: (Theme.getSize("button").width - Math.floor(Theme.getSize("button_icon").width) / 4)
anchors.bottom: parent.bottom; anchors.bottom: parent.bottom;
anchors.bottomMargin: (Theme.getSize("button").height - Theme.getSize("button_icon").height) / 4 anchors.bottomMargin: (Theme.getSize("button").height - Math.floor(Theme.getSize("button_icon").height) / 4)
width: Theme.getSize("standard_arrow").width width: Theme.getSize("standard_arrow").width
height: Theme.getSize("standard_arrow").height height: Theme.getSize("standard_arrow").height
sourceSize.width: width sourceSize.width: width
@ -669,7 +669,7 @@ QtObject {
id: category_arrow id: category_arrow
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
anchors.right: parent.right anchors.right: parent.right
anchors.rightMargin: Theme.getSize("default_margin").width * 3 - width / 2 anchors.rightMargin: Theme.getSize("default_margin").width * 3 - Math.floor(width / 2)
width: Theme.getSize("standard_arrow").width width: Theme.getSize("standard_arrow").width
height: Theme.getSize("standard_arrow").height height: Theme.getSize("standard_arrow").height
sourceSize.width: width sourceSize.width: width