mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-08-12 06:19:05 +08:00
Merge pull request #6380 from Ultimaker/CURA-6690_printhead_negative_values
Cura 6690 printhead negative values
This commit is contained in:
commit
03866d0d07
@ -208,6 +208,7 @@ Item
|
|||||||
axisName: "x"
|
axisName: "x"
|
||||||
axisMinOrMax: "min"
|
axisMinOrMax: "min"
|
||||||
allowNegativeValue: true
|
allowNegativeValue: true
|
||||||
|
allowPositiveValue: false
|
||||||
|
|
||||||
forceUpdateOnChangeFunction: forceUpdateFunction
|
forceUpdateOnChangeFunction: forceUpdateFunction
|
||||||
}
|
}
|
||||||
@ -227,6 +228,7 @@ Item
|
|||||||
axisName: "y"
|
axisName: "y"
|
||||||
axisMinOrMax: "min"
|
axisMinOrMax: "min"
|
||||||
allowNegativeValue: true
|
allowNegativeValue: true
|
||||||
|
allowPositiveValue: false
|
||||||
|
|
||||||
forceUpdateOnChangeFunction: forceUpdateFunction
|
forceUpdateOnChangeFunction: forceUpdateFunction
|
||||||
}
|
}
|
||||||
@ -245,7 +247,8 @@ Item
|
|||||||
|
|
||||||
axisName: "x"
|
axisName: "x"
|
||||||
axisMinOrMax: "max"
|
axisMinOrMax: "max"
|
||||||
allowNegativeValue: true
|
allowNegativeValue: false
|
||||||
|
allowPositiveValue: true
|
||||||
|
|
||||||
forceUpdateOnChangeFunction: forceUpdateFunction
|
forceUpdateOnChangeFunction: forceUpdateFunction
|
||||||
}
|
}
|
||||||
@ -266,7 +269,8 @@ Item
|
|||||||
|
|
||||||
axisName: "y"
|
axisName: "y"
|
||||||
axisMinOrMax: "max"
|
axisMinOrMax: "max"
|
||||||
allowNegativeValue: true
|
allowNegativeValue: false
|
||||||
|
allowPositiveValue: true
|
||||||
|
|
||||||
forceUpdateOnChangeFunction: forceUpdateFunction
|
forceUpdateOnChangeFunction: forceUpdateFunction
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ UM.TooltipArea
|
|||||||
property alias labelWidth: fieldLabel.width
|
property alias labelWidth: fieldLabel.width
|
||||||
property alias unitText: unitLabel.text
|
property alias unitText: unitLabel.text
|
||||||
|
|
||||||
|
property alias textField: textFieldWithUnit
|
||||||
property alias valueText: textFieldWithUnit.text
|
property alias valueText: textFieldWithUnit.text
|
||||||
property alias valueValidator: textFieldWithUnit.validator
|
property alias valueValidator: textFieldWithUnit.validator
|
||||||
property alias editingFinishedFunction: textFieldWithUnit.editingFinishedFunction
|
property alias editingFinishedFunction: textFieldWithUnit.editingFinishedFunction
|
||||||
@ -43,6 +44,8 @@ UM.TooltipArea
|
|||||||
|
|
||||||
// whether negative value is allowed. This affects the validation of the input field.
|
// whether negative value is allowed. This affects the validation of the input field.
|
||||||
property bool allowNegativeValue: false
|
property bool allowNegativeValue: false
|
||||||
|
// whether positive value is allowed. This affects the validation of the input field.
|
||||||
|
property bool allowPositiveValue: true
|
||||||
|
|
||||||
// callback functions
|
// callback functions
|
||||||
property var afterOnEditingFinishedFunction: dummy_func
|
property var afterOnEditingFinishedFunction: dummy_func
|
||||||
@ -153,7 +156,13 @@ UM.TooltipArea
|
|||||||
const value = propertyProvider.properties.value
|
const value = propertyProvider.properties.value
|
||||||
return value ? value : ""
|
return value ? value : ""
|
||||||
}
|
}
|
||||||
validator: RegExpValidator { regExp: allowNegativeValue ? /-?[0-9\.,]{0,6}/ : /[0-9\.,]{0,6}/ }
|
validator: DoubleValidator
|
||||||
|
{
|
||||||
|
bottom: allowNegativeValue ? Number.NEGATIVE_INFINITY : 0
|
||||||
|
top: allowPositiveValue ? Number.POSITIVE_INFINITY : 0
|
||||||
|
decimals: 6
|
||||||
|
notation: DoubleValidator.StandardNotation
|
||||||
|
}
|
||||||
|
|
||||||
onEditingFinished: editingFinishedFunction()
|
onEditingFinished: editingFinishedFunction()
|
||||||
|
|
||||||
|
@ -43,31 +43,48 @@ NumericTextFieldWithUnit
|
|||||||
{
|
{
|
||||||
result = func(result, polygon[i][item])
|
result = func(result, polygon[i][item])
|
||||||
}
|
}
|
||||||
result = Math.abs(result)
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
valueValidator: RegExpValidator { regExp: /[0-9\.,]{0,6}/ }
|
valueValidator: DoubleValidator {
|
||||||
|
bottom: allowNegativeValue ? Number.NEGATIVE_INFINITY : 0
|
||||||
|
top: allowPositiveValue ? Number.POSITIVE_INFINITY : 0
|
||||||
|
decimals: 6
|
||||||
|
notation: DoubleValidator.StandardNotation
|
||||||
|
}
|
||||||
|
|
||||||
valueText: axisValue
|
valueText: axisValue
|
||||||
|
|
||||||
|
Connections
|
||||||
|
{
|
||||||
|
target: textField
|
||||||
|
onActiveFocusChanged:
|
||||||
|
{
|
||||||
|
// When this text field loses focus and the entered text is not valid, make sure to recreate the binding to
|
||||||
|
// show the correct value.
|
||||||
|
if (!textField.activeFocus && !textField.acceptableInput)
|
||||||
|
{
|
||||||
|
valueText = axisValue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
editingFinishedFunction: function()
|
editingFinishedFunction: function()
|
||||||
{
|
{
|
||||||
var polygon = JSON.parse(propertyProvider.properties.value)
|
var polygon = JSON.parse(propertyProvider.properties.value)
|
||||||
|
|
||||||
var newValue = parseFloat(valueText.replace(',', '.'))
|
var newValue = parseFloat(valueText.replace(',', '.'))
|
||||||
|
|
||||||
if (axisName == "x") // x min/x max
|
if (axisName == "x") // x min/x max
|
||||||
{
|
{
|
||||||
var start_i1 = (axisMinOrMax == "min") ? 0 : 2
|
var start_i1 = (axisMinOrMax == "min") ? 0 : 2
|
||||||
var factor = (axisMinOrMax == "min") ? -1 : 1
|
polygon[start_i1][0] = newValue
|
||||||
polygon[start_i1][0] = newValue * factor
|
polygon[start_i1 + 1][0] = newValue
|
||||||
polygon[start_i1 + 1][0] = newValue * factor
|
|
||||||
}
|
}
|
||||||
else // y min/y max
|
else // y min/y max
|
||||||
{
|
{
|
||||||
var start_i1 = (axisMinOrMax == "min") ? 1 : 0
|
var start_i1 = (axisMinOrMax == "min") ? 1 : 0
|
||||||
var factor = (axisMinOrMax == "min") ? -1 : 1
|
polygon[start_i1][1] = newValue
|
||||||
polygon[start_i1][1] = newValue * factor
|
polygon[start_i1 + 2][1] = newValue
|
||||||
polygon[start_i1 + 2][1] = newValue * factor
|
|
||||||
}
|
}
|
||||||
var polygon_string = JSON.stringify(polygon)
|
var polygon_string = JSON.stringify(polygon)
|
||||||
if (polygon_string != propertyProvider.properties.value)
|
if (polygon_string != propertyProvider.properties.value)
|
||||||
@ -75,5 +92,8 @@ NumericTextFieldWithUnit
|
|||||||
propertyProvider.setPropertyValue("value", polygon_string)
|
propertyProvider.setPropertyValue("value", polygon_string)
|
||||||
forceUpdateOnChangeFunction()
|
forceUpdateOnChangeFunction()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Recreate the binding to show the correct value.
|
||||||
|
valueText = axisValue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user