mirror of
https://git.mirrors.martin98.com/https://github.com/Ultimaker/Cura
synced 2025-04-22 05:39:37 +08:00
Add tooltips to the head polygon fields
This commit is contained in:
parent
4705ada6ef
commit
cb7b845a32
@ -215,48 +215,52 @@ Cura.MachineAction
|
|||||||
{
|
{
|
||||||
text: catalog.i18nc("@label", "X min")
|
text: catalog.i18nc("@label", "X min")
|
||||||
}
|
}
|
||||||
TextField
|
Loader
|
||||||
{
|
{
|
||||||
id: printheadXMinField
|
id: printheadXMinField
|
||||||
text: getHeadPolygonCoord("x", "min")
|
sourceComponent: headPolygonTextField
|
||||||
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
|
property string axis: "x"
|
||||||
onEditingFinished: setHeadPolygon()
|
property string side: "min"
|
||||||
|
property string tooltip: catalog.i18nc("@tooltip", "Distance from the left of the printhead to the center of the nozzle. Used to prevent colissions between the print and the printhead.")
|
||||||
}
|
}
|
||||||
|
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@label", "Y min")
|
text: catalog.i18nc("@label", "Y min")
|
||||||
}
|
}
|
||||||
TextField
|
Loader
|
||||||
{
|
{
|
||||||
id: printheadYMinField
|
id: printheadYMinField
|
||||||
text: getHeadPolygonCoord("y", "min")
|
sourceComponent: headPolygonTextField
|
||||||
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
|
property string axis: "y"
|
||||||
onEditingFinished: setHeadPolygon()
|
property string side: "min"
|
||||||
|
property string tooltip: catalog.i18nc("@tooltip", "Distance from the front of the printhead to the center of the nozzle. Used to prevent colissions between the print and the printhead.")
|
||||||
}
|
}
|
||||||
|
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@label", "X max")
|
text: catalog.i18nc("@label", "X max")
|
||||||
}
|
}
|
||||||
TextField
|
Loader
|
||||||
{
|
{
|
||||||
id: printheadXMaxField
|
id: printheadXMaxField
|
||||||
text: getHeadPolygonCoord("x", "max")
|
sourceComponent: headPolygonTextField
|
||||||
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
|
property string axis: "x"
|
||||||
onEditingFinished: setHeadPolygon()
|
property string side: "max"
|
||||||
|
property string tooltip: catalog.i18nc("@tooltip", "Distance from the right of the printhead to the center of the nozzle. Used to prevent colissions between the print and the printhead.")
|
||||||
}
|
}
|
||||||
|
|
||||||
Label
|
Label
|
||||||
{
|
{
|
||||||
text: catalog.i18nc("@label", "Y max")
|
text: catalog.i18nc("@label", "Y max")
|
||||||
}
|
}
|
||||||
TextField
|
Loader
|
||||||
{
|
{
|
||||||
id: printheadYMaxField
|
id: printheadYMaxField
|
||||||
text: getHeadPolygonCoord("y", "max")
|
sourceComponent: headPolygonTextField
|
||||||
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
|
property string axis: "y"
|
||||||
onEditingFinished: setHeadPolygon()
|
property string side: "max"
|
||||||
|
property string tooltip: catalog.i18nc("@tooltip", "Distance from the rear of the printhead to the center of the nozzle. Used to prevent colissions between the print and the printhead.")
|
||||||
}
|
}
|
||||||
|
|
||||||
Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
|
Item { width: UM.Theme.getSize("default_margin").width; height: UM.Theme.getSize("default_margin").height }
|
||||||
@ -376,36 +380,6 @@ Cura.MachineAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getHeadPolygonCoord(axis, minMax)
|
|
||||||
{
|
|
||||||
var polygon = JSON.parse(machineHeadPolygonProvider.properties.value);
|
|
||||||
var item = (axis == "x") ? 0 : 1
|
|
||||||
var result = polygon[0][item];
|
|
||||||
for(var i = 1; i < polygon.length; i++) {
|
|
||||||
if (minMax == "min") {
|
|
||||||
result = Math.min(result, polygon[i][item]);
|
|
||||||
} else {
|
|
||||||
result = Math.max(result, polygon[i][item]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Math.abs(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setHeadPolygon()
|
|
||||||
{
|
|
||||||
var polygon = [];
|
|
||||||
polygon.push([-parseFloat(printheadXMinField.text), parseFloat(printheadYMaxField.text)]);
|
|
||||||
polygon.push([-parseFloat(printheadXMinField.text),-parseFloat(printheadYMinField.text)]);
|
|
||||||
polygon.push([ parseFloat(printheadXMaxField.text), parseFloat(printheadYMaxField.text)]);
|
|
||||||
polygon.push([ parseFloat(printheadXMaxField.text),-parseFloat(printheadYMinField.text)]);
|
|
||||||
var polygon_string = JSON.stringify(polygon);
|
|
||||||
if(polygon != machineHeadPolygonProvider.properties.value)
|
|
||||||
{
|
|
||||||
machineHeadPolygonProvider.setPropertyValue("value", polygon_string);
|
|
||||||
manager.forceUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -794,6 +768,75 @@ Cura.MachineAction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component
|
||||||
|
{
|
||||||
|
id: headPolygonTextField
|
||||||
|
UM.TooltipArea
|
||||||
|
{
|
||||||
|
height: textField.height
|
||||||
|
width: textField.width
|
||||||
|
text: tooltip
|
||||||
|
|
||||||
|
TextField
|
||||||
|
{
|
||||||
|
id: textField
|
||||||
|
text:
|
||||||
|
{
|
||||||
|
var polygon = JSON.parse(machineHeadPolygonProvider.properties.value);
|
||||||
|
var item = (axis == "x") ? 0 : 1
|
||||||
|
var result = polygon[0][item];
|
||||||
|
for(var i = 1; i < polygon.length; i++) {
|
||||||
|
if (side == "min") {
|
||||||
|
result = Math.min(result, polygon[i][item]);
|
||||||
|
} else {
|
||||||
|
result = Math.max(result, polygon[i][item]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result = Math.abs(result);
|
||||||
|
printHeadPolygon[axis][side] = result;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
validator: RegExpValidator { regExp: /[0-9\.]{0,6}/ }
|
||||||
|
onEditingFinished:
|
||||||
|
{
|
||||||
|
printHeadPolygon[axis][side] = parseFloat(textField.text);
|
||||||
|
var polygon = [];
|
||||||
|
polygon.push([-printHeadPolygon["x"]["min"], printHeadPolygon["y"]["max"]]);
|
||||||
|
polygon.push([-printHeadPolygon["x"]["min"],-printHeadPolygon["y"]["min"]]);
|
||||||
|
polygon.push([ printHeadPolygon["x"]["max"], printHeadPolygon["y"]["max"]]);
|
||||||
|
polygon.push([ printHeadPolygon["x"]["max"],-printHeadPolygon["y"]["mìn"]]);
|
||||||
|
var polygon_string = JSON.stringify(polygon);
|
||||||
|
if(polygon_string != machineHeadPolygonProvider.properties.value)
|
||||||
|
{
|
||||||
|
machineHeadPolygonProvider.setPropertyValue("value", polygon_string);
|
||||||
|
manager.forceUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Label
|
||||||
|
{
|
||||||
|
text: catalog.i18nc("@label", "mm")
|
||||||
|
anchors.right: textField.right
|
||||||
|
anchors.rightMargin: y - textField.y
|
||||||
|
anchors.verticalCenter: textField.verticalCenter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
property var printHeadPolygon:
|
||||||
|
{
|
||||||
|
"x": {
|
||||||
|
"min": 0,
|
||||||
|
"max": 0,
|
||||||
|
},
|
||||||
|
"y": {
|
||||||
|
"min": 0,
|
||||||
|
"max": 0,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
UM.SettingPropertyProvider
|
UM.SettingPropertyProvider
|
||||||
{
|
{
|
||||||
id: machineExtruderCountProvider
|
id: machineExtruderCountProvider
|
||||||
|
Loading…
x
Reference in New Issue
Block a user