From 6f8dc68aa2c48aaddc556e48ee462529b56cc3e1 Mon Sep 17 00:00:00 2001 From: youhy Date: Tue, 21 Jun 2022 15:50:33 -0700 Subject: [PATCH 1/8] Implement Pose3d with common widget pose Signed-off-by: youhy --- .../plugins/component_inspector/Pose3d.qml | 257 ++---------------- 1 file changed, 27 insertions(+), 230 deletions(-) diff --git a/src/gui/plugins/component_inspector/Pose3d.qml b/src/gui/plugins/component_inspector/Pose3d.qml index 3574a13b34..8f2e4d1f77 100644 --- a/src/gui/plugins/component_inspector/Pose3d.qml +++ b/src/gui/plugins/component_inspector/Pose3d.qml @@ -25,7 +25,7 @@ import "qrc:/qml" // Item displaying 3D pose information. Rectangle { - height: header.height + content.height + height: header.height + gzPose.height width: componentInspector.width color: index % 2 == 0 ? lightGrey : darkGrey @@ -35,85 +35,19 @@ Rectangle { // Horizontal margins property int margin: 5 - // Maximum spinbox value - property double spinMax: 1000000 - - // Read-only / write - property bool readOnly: { - var isModel = entityType == "model" - return !(isModel) || nestedModel - } - - // Loaded item for X - property var xItem: {} - - // Loaded item for Y - property var yItem: {} - - // Loaded item for Z - property var zItem: {} - - // Loaded item for roll - property var rollItem: {} - - // Loaded item for pitch - property var pitchItem: {} - - // Loaded item for yaw - property var yawItem: {} - // Send new pose to C++ function sendPose() { // TODO(anyone) There's a loss of precision when these values get to C++ Pose3dImpl.OnPose( - xItem.value, - yItem.value, - zItem.value, - rollItem.value, - pitchItem.value, - yawItem.value + gzPose.xItem.value, + gzPose.yItem.value, + gzPose.zItem.value, + gzPose.rollItem.value, + gzPose.pitchItem.value, + gzPose.yawItem.value ); } - FontMetrics { - id: fontMetrics - font.family: "Roboto" - } - - /** - * Used to create a spin box - */ - Component { - id: writableNumber - IgnSpinBox { - id: writableSpin - value: writableSpin.activeFocus ? writableSpin.value : numberValue - minimumValue: -spinMax - maximumValue: spinMax - decimals: getDecimals(writableSpin.width) - onEditingFinished: { - sendPose() - } - } - } - - /** - * Used to create a read-only number - */ - Component { - id: readOnlyNumber - Text { - id: numberText - anchors.fill: parent - horizontalAlignment: Text.AlignRight - verticalAlignment: Text.AlignVCenter - text: { - var decimals = getDecimals(numberText.width) - return numberValue.toFixed(decimals) - } - } - } - Column { anchors.fill: parent @@ -135,7 +69,7 @@ Rectangle { sourceSize.width: indentation fillMode: Image.Pad Layout.alignment : Qt.AlignVCenter - source: content.show ? + source: gzPose.show ? "qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png" } TypeHeader { @@ -150,7 +84,9 @@ Rectangle { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - content.show = !content.show + gzPose.show = !gzPose.show + // console.log(model.data[0], model.data[1], model.data[2], model.data[3], model.data[4], model.data[5]) + // console.log(gzPose.xItem, gzPose.yItem, gzPose.zItem, gzPose.rollItem, gzPose.pitchItem, gzPose.yawItem) } onEntered: { header.color = highlightColor @@ -162,164 +98,25 @@ Rectangle { } // Content - Rectangle { - id: content - property bool show: false + GzPose { + id: gzPose width: parent.width - height: show ? grid.height : 0 - clip: true - color: "transparent" - Behavior on height { - NumberAnimation { - duration: 200; - easing.type: Easing.InOutQuad - } + readOnly: { + var isModel = entityType == "model" + return !(isModel) || nestedModel } - GridLayout { - id: grid - width: parent.width - columns: 6 - - // Left spacer - Item { - Layout.rowSpan: 3 - width: margin + indentation - } - - Text { - text: 'X (m)' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - } - - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: xLoader - anchors.fill: parent - property double numberValue: model.data[0] - sourceComponent: readOnly ? readOnlyNumber : writableNumber - onLoaded: { - xItem = xLoader.item - } - } - } - - Text { - text: 'Roll (rad)' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - } - - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: rollLoader - anchors.fill: parent - property double numberValue: model.data[3] - sourceComponent: readOnly ? readOnlyNumber : writableNumber - onLoaded: { - rollItem = rollLoader.item - } - } - } - - // Right spacer - Item { - Layout.rowSpan: 3 - width: margin - } - - Text { - text: 'Y (m)' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - } - - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: yLoader - anchors.fill: parent - property double numberValue: model.data[1] - sourceComponent: readOnly ? readOnlyNumber : writableNumber - onLoaded: { - yItem = yLoader.item - } - } - } - - Text { - text: 'Pitch (rad)' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - } - - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: pitchLoader - anchors.fill: parent - property double numberValue: model.data[4] - sourceComponent: readOnly ? readOnlyNumber : writableNumber - onLoaded: { - pitchItem = pitchLoader.item - } - } - } - - Text { - text: 'Z (m)' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - } - - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: zLoader - anchors.fill: parent - property double numberValue: model.data[2] - sourceComponent: readOnly ? readOnlyNumber : writableNumber - onLoaded: { - zItem = zLoader.item - } - } - } + xModelValue: model.data[0] + yModelValue: model.data[1] + zModelValue: model.data[2] + rollModelValue: model.data[3] + pitchModelValue: model.data[4] + yawModelValue: model.data[5] - Text { - text: 'Yaw (rad)' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - } - - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: yawLoader - anchors.fill: parent - property double numberValue: model.data[5] - sourceComponent: readOnly ? readOnlyNumber : writableNumber - onLoaded: { - yawItem = yawLoader.item - } - } - } + onPoseSet: { + sendPose() } - } - } -} + } // end gzPose + } // end Column +} // end Rectangle From 8f4e806e696c1c3a4270d08e00639d67af94f18b Mon Sep 17 00:00:00 2001 From: youhy Date: Wed, 22 Jun 2022 16:11:05 -0700 Subject: [PATCH 2/8] debug setup Signed-off-by: youhy --- .../plugins/component_inspector/Pose3d.qml | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/gui/plugins/component_inspector/Pose3d.qml b/src/gui/plugins/component_inspector/Pose3d.qml index 8f2e4d1f77..80064e341e 100644 --- a/src/gui/plugins/component_inspector/Pose3d.qml +++ b/src/gui/plugins/component_inspector/Pose3d.qml @@ -25,7 +25,7 @@ import "qrc:/qml" // Item displaying 3D pose information. Rectangle { - height: header.height + gzPose.height + height: header.height + gzPoseContent.height width: componentInspector.width color: index % 2 == 0 ? lightGrey : darkGrey @@ -39,13 +39,21 @@ Rectangle { function sendPose() { // TODO(anyone) There's a loss of precision when these values get to C++ Pose3dImpl.OnPose( - gzPose.xItem.value, - gzPose.yItem.value, - gzPose.zItem.value, - gzPose.rollItem.value, - gzPose.pitchItem.value, - gzPose.yawItem.value + gzPoseContent.xItem.value, + gzPoseContent.yItem.value, + gzPoseContent.zItem.value, + gzPoseContent.rollItem.value, + gzPoseContent.pitchItem.value, + gzPoseContent.yawItem.value ); + console.log( + gzPoseContent.xItem.value, + gzPoseContent.yItem.value, + gzPoseContent.zItem.value, + gzPoseContent.rollItem.value, + gzPoseContent.pitchItem.value, + gzPoseContent.yawItem.value + ) } Column { @@ -69,7 +77,7 @@ Rectangle { sourceSize.width: indentation fillMode: Image.Pad Layout.alignment : Qt.AlignVCenter - source: gzPose.show ? + source: gzPoseContent.show ? "qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png" } TypeHeader { @@ -84,9 +92,7 @@ Rectangle { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - gzPose.show = !gzPose.show - // console.log(model.data[0], model.data[1], model.data[2], model.data[3], model.data[4], model.data[5]) - // console.log(gzPose.xItem, gzPose.yItem, gzPose.zItem, gzPose.rollItem, gzPose.pitchItem, gzPose.yawItem) + gzPoseContent.show = !gzPoseContent.show } onEntered: { header.color = highlightColor @@ -99,7 +105,7 @@ Rectangle { // Content GzPose { - id: gzPose + id: gzPoseContent width: parent.width readOnly: { @@ -114,9 +120,13 @@ Rectangle { pitchModelValue: model.data[4] yawModelValue: model.data[5] - onPoseSet: { + onGzPoseSet: { sendPose() } - } // end gzPose + + onShowChanged: { + console.log("bool var show changed") + } + } // end gzPoseContent } // end Column } // end Rectangle From 3d25dddfe4649b8741d5ee6f2ffe4dad7bb2be5b Mon Sep 17 00:00:00 2001 From: youhy Date: Fri, 24 Jun 2022 15:29:57 -0700 Subject: [PATCH 3/8] add parameters to signal gzPoseSet Signed-off-by: youhy --- .../plugins/component_inspector/Pose3d.qml | 24 ++++--------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/src/gui/plugins/component_inspector/Pose3d.qml b/src/gui/plugins/component_inspector/Pose3d.qml index 80064e341e..747f2b6f54 100644 --- a/src/gui/plugins/component_inspector/Pose3d.qml +++ b/src/gui/plugins/component_inspector/Pose3d.qml @@ -15,7 +15,6 @@ * */ import QtQuick 2.9 -import QtQuick.Controls 1.4 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.1 import QtQuick.Layouts 1.3 @@ -36,24 +35,9 @@ Rectangle { property int margin: 5 // Send new pose to C++ - function sendPose() { + function sendPose(x, y, z, roll, pitch, yaw) { // TODO(anyone) There's a loss of precision when these values get to C++ - Pose3dImpl.OnPose( - gzPoseContent.xItem.value, - gzPoseContent.yItem.value, - gzPoseContent.zItem.value, - gzPoseContent.rollItem.value, - gzPoseContent.pitchItem.value, - gzPoseContent.yawItem.value - ); - console.log( - gzPoseContent.xItem.value, - gzPoseContent.yItem.value, - gzPoseContent.zItem.value, - gzPoseContent.rollItem.value, - gzPoseContent.pitchItem.value, - gzPoseContent.yawItem.value - ) + Pose3dImpl.OnPose(x, y, z, roll, pitch, yaw); } Column { @@ -120,8 +104,8 @@ Rectangle { pitchModelValue: model.data[4] yawModelValue: model.data[5] - onGzPoseSet: { - sendPose() + onGzPoseSet: (x, y, z, roll, pitch, yaw) => { + sendPose(x, y, z, roll, pitch, yaw) } onShowChanged: { From a790fa93f12b4a69c97d3f96bd774dbb0a1e13ed Mon Sep 17 00:00:00 2001 From: Jenn Nguyen Date: Mon, 27 Jun 2022 13:20:47 -0400 Subject: [PATCH 4/8] qml fix for bionic Signed-off-by: Jenn Nguyen --- src/gui/plugins/component_inspector/Pose3d.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/plugins/component_inspector/Pose3d.qml b/src/gui/plugins/component_inspector/Pose3d.qml index 747f2b6f54..8dd018f4e1 100644 --- a/src/gui/plugins/component_inspector/Pose3d.qml +++ b/src/gui/plugins/component_inspector/Pose3d.qml @@ -104,7 +104,7 @@ Rectangle { pitchModelValue: model.data[4] yawModelValue: model.data[5] - onGzPoseSet: (x, y, z, roll, pitch, yaw) => { + onGzPoseSet: { sendPose(x, y, z, roll, pitch, yaw) } From 78279d431c52ad4ef98ae497ba6ad750bb3454d5 Mon Sep 17 00:00:00 2001 From: youhy Date: Wed, 29 Jun 2022 13:37:04 -0700 Subject: [PATCH 5/8] change some variables' names Signed-off-by: youhy --- .../plugins/component_inspector/Pose3d.qml | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/gui/plugins/component_inspector/Pose3d.qml b/src/gui/plugins/component_inspector/Pose3d.qml index 8dd018f4e1..4d0a9b199b 100644 --- a/src/gui/plugins/component_inspector/Pose3d.qml +++ b/src/gui/plugins/component_inspector/Pose3d.qml @@ -97,20 +97,21 @@ Rectangle { return !(isModel) || nestedModel } - xModelValue: model.data[0] - yModelValue: model.data[1] - zModelValue: model.data[2] - rollModelValue: model.data[3] - pitchModelValue: model.data[4] - yawModelValue: model.data[5] + xValue: model.data[0] + yValue: model.data[1] + zValue: model.data[2] + rollValue: model.data[3] + pitchValue: model.data[4] + yawValue: model.data[5] onGzPoseSet: { - sendPose(x, y, z, roll, pitch, yaw) + // _x, _y, _z, _roll, _pitch, _yaw are parameters of signal gzPoseSet + sendPose(_x, _y, _z, _roll, _pitch, _yaw) } - onShowChanged: { - console.log("bool var show changed") - } + // By default it is closed + show: false + } // end gzPoseContent } // end Column } // end Rectangle From 06fd7453540a3991f2c3a3272df2e24b025f42ec Mon Sep 17 00:00:00 2001 From: youhy Date: Tue, 5 Jul 2022 13:44:54 -0700 Subject: [PATCH 6/8] add spacer Signed-off-by: youhy --- .../plugins/component_inspector/Pose3d.qml | 62 ++++++++++++------- 1 file changed, 41 insertions(+), 21 deletions(-) diff --git a/src/gui/plugins/component_inspector/Pose3d.qml b/src/gui/plugins/component_inspector/Pose3d.qml index 4d0a9b199b..22fce83e19 100644 --- a/src/gui/plugins/component_inspector/Pose3d.qml +++ b/src/gui/plugins/component_inspector/Pose3d.qml @@ -86,32 +86,52 @@ Rectangle { } } } - - // Content - GzPose { - id: gzPoseContent + Rectangle { + id: content + color: "transparent" width: parent.width + height: gzPoseContent.height + RowLayout { + id: gzPoseRow + width: parent.width - readOnly: { - var isModel = entityType == "model" - return !(isModel) || nestedModel - } + // Left spacer + Item { + Layout.preferredWidth: margin + indentation + } - xValue: model.data[0] - yValue: model.data[1] - zValue: model.data[2] - rollValue: model.data[3] - pitchValue: model.data[4] - yawValue: model.data[5] + // Content + GzPose { + id: gzPoseContent + Layout.fillWidth: true - onGzPoseSet: { - // _x, _y, _z, _roll, _pitch, _yaw are parameters of signal gzPoseSet - sendPose(_x, _y, _z, _roll, _pitch, _yaw) - } + readOnly: { + var isModel = entityType == "model" + return !(isModel) || nestedModel + } + + xValue: model.data[0] + yValue: model.data[1] + zValue: model.data[2] + rollValue: model.data[3] + pitchValue: model.data[4] + yawValue: model.data[5] + + onGzPoseSet: { + // _x, _y, _z, _roll, _pitch, _yaw are parameters of signal gzPoseSet + sendPose(_x, _y, _z, _roll, _pitch, _yaw) + } - // By default it is closed - show: false + // By default it is closed + show: false - } // end gzPoseContent + } // end gzPoseContent + + // Right spacer + Item { + Layout.preferredWidth: margin + } + } // end RowLayout + } // end Rectangle } // end Column } // end Rectangle From e5323a90589ed0ffbc431bfa255ce1285f7860eb Mon Sep 17 00:00:00 2001 From: youhy Date: Thu, 7 Jul 2022 08:39:04 -0700 Subject: [PATCH 7/8] remove unused id Signed-off-by: youhy --- src/gui/plugins/component_inspector/Pose3d.qml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/gui/plugins/component_inspector/Pose3d.qml b/src/gui/plugins/component_inspector/Pose3d.qml index 22fce83e19..f10ab61aac 100644 --- a/src/gui/plugins/component_inspector/Pose3d.qml +++ b/src/gui/plugins/component_inspector/Pose3d.qml @@ -61,7 +61,7 @@ Rectangle { sourceSize.width: indentation fillMode: Image.Pad Layout.alignment : Qt.AlignVCenter - source: gzPoseContent.show ? + source: gzPoseContent.expand ? "qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png" } TypeHeader { @@ -76,7 +76,7 @@ Rectangle { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - gzPoseContent.show = !gzPoseContent.show + gzPoseContent.expand = !gzPoseContent.expand } onEntered: { header.color = highlightColor @@ -87,7 +87,6 @@ Rectangle { } } Rectangle { - id: content color: "transparent" width: parent.width height: gzPoseContent.height @@ -123,7 +122,7 @@ Rectangle { } // By default it is closed - show: false + expand: false } // end gzPoseContent From f33621e3ea269bd01c1712374c3c2ebd2b219e85 Mon Sep 17 00:00:00 2001 From: youhy Date: Thu, 7 Jul 2022 12:22:04 -0700 Subject: [PATCH 8/8] change id of GzPose Signed-off-by: youhy --- src/gui/plugins/component_inspector/Pose3d.qml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/gui/plugins/component_inspector/Pose3d.qml b/src/gui/plugins/component_inspector/Pose3d.qml index f10ab61aac..bfb48b4b56 100644 --- a/src/gui/plugins/component_inspector/Pose3d.qml +++ b/src/gui/plugins/component_inspector/Pose3d.qml @@ -24,7 +24,7 @@ import "qrc:/qml" // Item displaying 3D pose information. Rectangle { - height: header.height + gzPoseContent.height + height: header.height + gzPoseInstance.height width: componentInspector.width color: index % 2 == 0 ? lightGrey : darkGrey @@ -61,7 +61,7 @@ Rectangle { sourceSize.width: indentation fillMode: Image.Pad Layout.alignment : Qt.AlignVCenter - source: gzPoseContent.expand ? + source: gzPoseInstance.expand ? "qrc:/Gazebo/images/minus.png" : "qrc:/Gazebo/images/plus.png" } TypeHeader { @@ -76,7 +76,7 @@ Rectangle { hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: { - gzPoseContent.expand = !gzPoseContent.expand + gzPoseInstance.expand = !gzPoseInstance.expand } onEntered: { header.color = highlightColor @@ -89,7 +89,7 @@ Rectangle { Rectangle { color: "transparent" width: parent.width - height: gzPoseContent.height + height: gzPoseInstance.height RowLayout { id: gzPoseRow width: parent.width @@ -101,7 +101,7 @@ Rectangle { // Content GzPose { - id: gzPoseContent + id: gzPoseInstance Layout.fillWidth: true readOnly: { @@ -124,7 +124,7 @@ Rectangle { // By default it is closed expand: false - } // end gzPoseContent + } // end gzPoseInstance // Right spacer Item {