Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace color and pose for GridConfig with GzColor and GzPose #463

Merged
merged 5 commits into from
Aug 17, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
236 changes: 41 additions & 195 deletions src/plugins/grid_config/GridConfig.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,9 @@ GridLayout {
anchors.leftMargin: 10
anchors.rightMargin: 10

// Get number of decimal digits based on a widget's width
// TODO(chapulina) Move this to a common place so all widgets can use it
function getDecimals(_width) {
if (_width <= 80)
return 2;
else if (_width <= 100)
return 4;
return 6;
// Dummy item for using getDecimals()
IgnHelpers {
id: ignhelper
AzulRadio marked this conversation as resolved.
Show resolved Hide resolved
}

Connections {
Expand All @@ -46,16 +41,16 @@ GridLayout {
horizontalCellCount.value = _hCellCount;
verticalCellCount.value = _vCellCount;
cellLength.value = _cellLength;
x.value = _pos.x;
y.value = _pos.y;
z.value = _pos.z;
roll.value = _rot.x;
pitch.value = _rot.y;
yaw.value = _rot.z;
r.value = _color.r;
g.value = _color.g;
b.value = _color.b;
a.value = _color.a;
gzPoseInstance.xValue = _pos.x;
gzPoseInstance.yValue = _pos.y;
gzPoseInstance.zValue = _pos.z;
gzPoseInstance.rollValue = _rot.x;
gzPoseInstance.pitchValue = _rot.y;
gzPoseInstance.yawValue = _rot.z;
gzColorGrid.r = _color.r;
gzColorGrid.g = _color.g;
gzColorGrid.b = _color.b;
gzColorGrid.a = _color.a;
}
}

Expand Down Expand Up @@ -161,7 +156,7 @@ GridLayout {
maximumValue: Number.MAX_VALUE
minimumValue: 0.0000001
value: 1.00
decimals: getDecimals(cellLength.width)
decimals: ignhelper.getDecimals(cellLength.width)
stepSize: 0.01
onEditingFinished: GridConfig.UpdateCellLength(cellLength.value)
}
Expand All @@ -182,100 +177,25 @@ GridLayout {
font.bold: true
}

Text {
text: "X"
color: "dimgrey"
}

IgnSpinBox {
Layout.fillWidth: true
id: x
value: 0.00
maximumValue: Number.MAX_VALUE
minimumValue: -Number.MAX_VALUE
decimals: getDecimals(x.width)
stepSize: 0.01
onEditingFinished: GridConfig.SetPose(x.value, y.value, z.value, roll.value, pitch.value, yaw.value)
}

Text {
text: "Roll"
color: "dimgrey"
}

IgnSpinBox {
Layout.fillWidth: true
id: roll
maximumValue: 6.28
minimumValue: 0.00
value: 0.00
decimals: getDecimals(roll.width)
stepSize: 0.01
onEditingFinished: GridConfig.SetPose(x.value, y.value, z.value, roll.value, pitch.value, yaw.value)
}

Text {
text: "Y"
color: "dimgrey"
}

IgnSpinBox {
Layout.fillWidth: true
id: y
value: 0.00
maximumValue: Number.MAX_VALUE
minimumValue: -Number.MAX_VALUE
decimals: getDecimals(y.width)
stepSize: 0.01
onEditingFinished: GridConfig.SetPose(x.value, y.value, z.value, roll.value, pitch.value, yaw.value)
}

Text {
text: "Pitch"
color: "dimgrey"
}

IgnSpinBox {
Layout.fillWidth: true
id: pitch
maximumValue: 6.28
minimumValue: 0.00
value: 0.00
decimals: getDecimals(pitch.width)
stepSize: 0.01
onEditingFinished: GridConfig.SetPose(x.value, y.value, z.value, roll.value, pitch.value, yaw.value)
}

Text {
text: "Z"
color: "dimgrey"
}

IgnSpinBox {
Layout.fillWidth: true
id: z
value: 0.00
maximumValue: Number.MAX_VALUE
minimumValue: -Number.MAX_VALUE
decimals: getDecimals(z.width)
stepSize: 0.01
onEditingFinished: GridConfig.SetPose(x.value, y.value, z.value, roll.value, pitch.value, yaw.value)
}

Text {
text: "Yaw"
color: "dimgrey"
}

IgnSpinBox {
GzPose {
id: gzPoseInstance
Layout.columnSpan: 4
Layout.fillWidth: true
id: yaw
maximumValue: 6.28
minimumValue: 0.00
value: 0.00
decimals: getDecimals(yaw.width)
stepSize: 0.01
onEditingFinished: GridConfig.SetPose(x.value, y.value, z.value, roll.value, pitch.value, yaw.value)
readOnly: false
xValue: 0.00
yValue: 0.00
zValue: 0.00
rollValue: 0.00
pitchValue: 0.00
yawValue: 0.00

onGzPoseSet: {
// _x, _y, _z, _roll, _pitch, _yaw are parameters of signal gzPoseSet
// from gz-gui GzPose.qml
GridConfig.SetPose(_x, _y, _z, _roll, _pitch, _yaw)
}
AzulRadio marked this conversation as resolved.
Show resolved Hide resolved
expand: true
gzPlotEnabled: false
}

Text {
Expand All @@ -286,92 +206,18 @@ GridLayout {
}

Text {
text: "R"
color: "dimgrey"
}

IgnSpinBox {
Layout.fillWidth: true
id: r
maximumValue: 1.00
minimumValue: 0.00
value: 0.7
stepSize: 0.01
decimals: getDecimals(r.width)
onEditingFinished: GridConfig.SetColor(r.value, g.value, b.value, a.value)
}

Text {
text: "G"
color: "dimgrey"
}

IgnSpinBox {
Layout.fillWidth: true
id: g
maximumValue: 1.00
minimumValue: 0.00
value: 0.7
stepSize: 0.01
decimals: getDecimals(g.width)
onEditingFinished: GridConfig.SetColor(r.value, g.value, b.value, a.value)
}

Text {
text: "B"
color: "dimgrey"
}

IgnSpinBox {
Layout.fillWidth: true
id: b
maximumValue: 1.00
minimumValue: 0.00
value: 0.7
stepSize: 0.01
decimals: getDecimals(b.width)
onEditingFinished: GridConfig.SetColor(r.value, g.value, b.value, a.value)
}

Text {
text: "A"
Layout.columnSpan: 2
color: "dimgrey"
text: "Grid Color"
}

IgnSpinBox {
Layout.fillWidth: true
id: a
maximumValue: 1.00
minimumValue: 0.00
value: 1.0
stepSize: 0.01
decimals: getDecimals(a.width)
onEditingFinished: GridConfig.SetColor(r.value, g.value, b.value, a.value)
}

Button {
Layout.alignment: Qt.AlignHCenter
Layout.columnSpan: 4
id: color
text: qsTr("Custom Color")
onClicked: colorDialog.open()

ColorDialog {
id: colorDialog
title: "Choose a grid color"
visible: false
onAccepted: {
r.value = colorDialog.color.r
g.value = colorDialog.color.g
b.value = colorDialog.color.b
a.value = colorDialog.color.a
GridConfig.SetColor(colorDialog.color.r, colorDialog.color.g, colorDialog.color.b, colorDialog.color.a)
colorDialog.close()
}
onRejected: {
colorDialog.close()
}
}
GzColor {
id: gzColorGrid
Layout.columnSpan: 2
Layout.alignment: Qt.AlignRight
Layout.bottomMargin: 5
AzulRadio marked this conversation as resolved.
Show resolved Hide resolved
Layout.rightMargin: 20
onGzColorSet: GridConfig.SetColor(gzColorGrid.r, gzColorGrid.g, gzColorGrid.b, gzColorGrid.a)
}

// Bottom spacer
AzulRadio marked this conversation as resolved.
Show resolved Hide resolved
Expand Down