From 9e567c4c5a70049f370547ae836da02f9bd2b016 Mon Sep 17 00:00:00 2001 From: youhy Date: Tue, 7 Jun 2022 11:57:55 -0700 Subject: [PATCH 01/15] gzcolor for Material.qml ambient Signed-off-by: youhy --- .../plugins/component_inspector/Material.qml | 117 +++++------------- 1 file changed, 31 insertions(+), 86 deletions(-) diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index a7d82cc6c8..79dd3ea396 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -232,97 +232,42 @@ Rectangle { Layout.column: 6 } - // Ambient - Text { - text: " Ambient" - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - Layout.row: 2 - Layout.column: 1 + Loader { + id: ambientLoader + source: "GzColor.qml" } - // Ambient color dialog - Button { - id: ambientButton - Layout.row: 2 - Layout.column: 2 - ToolTip.text: "Open color dialog" - ToolTip.visible: hovered - ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval - background: Rectangle { - implicitWidth: 40 - implicitHeight: 40 - radius: 5 - border.color: getButtonColor(0, false) - border.width: 2 - color: getButtonColor(0, true) - } - onClicked: { - sendMaterialColor("ambient", getButtonColor(0, true)) - } + + Binding { + target : ambientLoader.item + property : "colorName" + value: "TestName" } - // Ambient red - Item { - Layout.row: 2 - Layout.column: 3 - Layout.fillWidth: true - height: 40 - Loader { - id: rAmbientLoader - anchors.fill: parent - property double numberValue: model.data[0] - sourceComponent: spinBoxMaterialColor - onLoaded: { - rAmbientItem = rAmbientLoader.item - } - } + + Binding { + target : ambientLoader.item + property : "r" + value: model.data[0] } - // Ambient green - Item { - Layout.row: 2 - Layout.column: 4 - Layout.fillWidth: true - height: 40 - Loader { - id: gAmbientLoader - anchors.fill: parent - property double numberValue: model.data[1] - sourceComponent: spinBoxMaterialColor - onLoaded: { - gAmbientItem = gAmbientLoader.item - } - } + Binding { + target : ambientLoader.item + property : "g" + value: model.data[1] } - // Ambient blue - Item { - Layout.row: 2 - Layout.column: 5 - Layout.fillWidth: true - height: 40 - Loader { - id: bAmbientLoader - anchors.fill: parent - property double numberValue: model.data[2] - sourceComponent: spinBoxMaterialColor - onLoaded: { - bAmbientItem = bAmbientLoader.item - } - } + Binding { + target : ambientLoader.item + property : "b" + value: model.data[2] + } + Binding { + target : ambientLoader.item + property : "a" + value: model.data[3] + } + + Connections { + target : ambientLoader.item + onColorSet: sendMaterialColor("ambient", getButtonColor(0, true)) } - // Ambient alpha - Item { - Layout.row: 2 - Layout.column: 6 - Layout.fillWidth: true - height: 40 - Loader { - id: aAmbientLoader - anchors.fill: parent - property double numberValue: model.data[3] - sourceComponent: spinBoxMaterialColor - onLoaded: { - aAmbientItem = aAmbientLoader.item - } - } - } // end Ambient // Diffuse Text { From a881432ae8a971709e5d52011ad519a8aade65bd Mon Sep 17 00:00:00 2001 From: youhy Date: Wed, 8 Jun 2022 08:08:55 -0700 Subject: [PATCH 02/15] Ambient Loader Signed-off-by: youhy --- .../plugins/component_inspector/Material.qml | 129 ++++++++---------- 1 file changed, 55 insertions(+), 74 deletions(-) diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index 79dd3ea396..fb914abd83 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -40,10 +40,10 @@ Rectangle { property int iconHeight: 20 // Loaded items for ambient red, green, blue, alpha - property var rAmbientItem: {} - property var gAmbientItem: {} - property var bAmbientItem: {} - property var aAmbientItem: {} + property double rAmbientItem + property double gAmbientItem + property double bAmbientItem + property double aAmbientItem // Loaded items for diffuse red, green, blue, alpha property var rDiffuseItem: {} @@ -66,10 +66,10 @@ Rectangle { // send new material color data to C++ function sendMaterialColor(_type, _currColor) { componentInspector.onMaterialColor( - rAmbientItem.value, - gAmbientItem.value, - bAmbientItem.value, - aAmbientItem.value, + rAmbientItem, + gAmbientItem, + bAmbientItem, + aAmbientItem, rDiffuseItem.value, gDiffuseItem.value, bDiffuseItem.value, @@ -130,6 +130,14 @@ Rectangle { } } + Component { + id: colorMaterial + GzColor { + id: gzcolor + textVisible: false + } + } + Column { anchors.fill: parent @@ -202,74 +210,46 @@ Rectangle { width: parent.width columns: 6 - // rgba headers - Text { - text: "Red " - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - Layout.row: 1 - Layout.column: 3 - } - Text { - text: "Green" - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - Layout.row: 1 - Layout.column: 4 - } - Text { - text: "Blue " - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - Layout.row: 1 - Layout.column: 5 - } - Text { - text: "Alpha" - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - Layout.row: 1 - Layout.column: 6 - } - - Loader { - id: ambientLoader - source: "GzColor.qml" - } - - Binding { - target : ambientLoader.item - property : "colorName" - value: "TestName" - } - - Binding { - target : ambientLoader.item - property : "r" - value: model.data[0] - } - Binding { - target : ambientLoader.item - property : "g" - value: model.data[1] - } - Binding { - target : ambientLoader.item - property : "b" - value: model.data[2] - } - Binding { - target : ambientLoader.item - property : "a" - value: model.data[3] - } - - Connections { - target : ambientLoader.item - onColorSet: sendMaterialColor("ambient", getButtonColor(0, true)) + // Ambient + Item { + Layout.row: 0 + Layout.columnSpan: 6 + Layout.fillWidth: true + height: 70 + Loader { + id: ambientLoader + anchors.fill: parent + sourceComponent: colorMaterial + onLoaded: { + rAmbientItem = ambientLoader.item.r + gAmbientItem = ambientLoader.item.g + bAmbientItem = ambientLoader.item.b + aAmbientItem = ambientLoader.item.a * 255.0 + } + } + Binding { + target: ambientLoader.item + property: "textVisible" + value: true + } + Binding { + target: ambientLoader.item + property: "colorName" + value: "Ambient" + } + Connections { + target : ambientLoader.item + onColorSet: { + rAmbientItem = ambientLoader.item.r + gAmbientItem = ambientLoader.item.g + bAmbientItem = ambientLoader.item.b + aAmbientItem = ambientLoader.item.a * 255.0 + sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) + } + } } - // Diffuse +// Diffuse Text { text: " Diffuse" color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" @@ -344,6 +324,7 @@ Rectangle { } } } + // Diffuse alpha Item { Layout.row: 3 From f0cee51030578e5f38f6b3b8aa0d291786f916e3 Mon Sep 17 00:00:00 2001 From: youhy Date: Wed, 8 Jun 2022 15:28:44 -0700 Subject: [PATCH 03/15] replace Light with common widget GzColor Signed-off-by: youhy --- src/gui/plugins/component_inspector/Light.qml | 473 ++++-------------- 1 file changed, 95 insertions(+), 378 deletions(-) diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index 081b88972d..97a1f4cf27 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -39,29 +39,17 @@ Rectangle { property int iconWidth: 20 property int iconHeight: 20 - // Loaded item for specular red - property var rSpecularItem: {} - - // Loaded item for specular green - property var gSpecularItem: {} - - // Loaded item for specular blue - property var bSpecularItem: {} - - // Loaded item for specular alpha - property var aSpecularItem: {} + // Loaded item for specular RGBA + property double rSpecularItem + property double gSpecularItem + property double bSpecularItem + property double aSpecularItem // Loaded item for diffuse red - property var rDiffuseItem: {} - - // Loaded item for diffuse green - property var gDiffuseItem: {} - - // Loaded item for diffuse blue - property var bDiffuseItem: {} - - // Loaded item for diffuse alpha - property var aDiffuseItem: {} + property double rDiffuseItem + property double gDiffuseItem + property double bDiffuseItem + property double aDiffuseItem // Loaded item for attenuation range property var attRangeItem: {} @@ -109,14 +97,14 @@ Rectangle { function sendLight() { // TODO(anyone) There's a loss of precision when these values get to C++ componentInspector.onLight( - rSpecularItem.value, - gSpecularItem.value, - bSpecularItem.value, - aSpecularItem.value, - rDiffuseItem.value, - gDiffuseItem.value, - bDiffuseItem.value, - aDiffuseItem.value, + 1.0 * rSpecularItem / 255.0, + 1.0 * gSpecularItem / 255.0, + 1.0 * bSpecularItem / 255.0, + aSpecularItem, + 1.0 * rDiffuseItem / 255.0, + 1.0 * gDiffuseItem / 255.0, + 1.0 * bDiffuseItem / 255.0, + aDiffuseItem, attRangeItem.value, attLinearItem.value, attConstantItem.value, @@ -143,6 +131,7 @@ Rectangle { /** * Used to create a spin box */ + // TODO remove this Component { id: sliderZeroOne Slider { @@ -158,6 +147,14 @@ Rectangle { } } + Component { + id: colorMaterial + GzColor { + id: gzcolor + textVisible: false + } + } + Component { id: ignSwitch Switch { @@ -356,360 +353,80 @@ Rectangle { } } } - RowLayout { - Layout.alignment : Qt.AlignLeft - Text { - text: " Specular" - color: "dimgrey" - width: margin + indentation - } - } - RowLayout { - Rectangle { - color: "transparent" - height: 40 - Layout.preferredWidth: rSpecularText.width + indentation*3 - Loader { - id: loaderSpecularR - width: iconWidth - height: iconHeight - y:10 - sourceComponent: plotIcon - } - Component.onCompleted: loaderSpecularR.item.componentInfo = "specularR" - - Text { - id : rSpecularText - text: ' R' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - anchors.centerIn: parent - } - } - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: rSpecularLoader - anchors.fill: parent - property double numberValue: model.data[0] - sourceComponent: sliderZeroOne - onLoaded: { - rSpecularItem = rSpecularLoader.item - } - } - } - Rectangle { - color: "transparent" - height: 40 - Layout.preferredWidth: gSpecularText.width + indentation*3 - Loader { - id: loaderSpecularG - width: iconWidth - height: iconHeight - y:10 - sourceComponent: plotIcon - } - Component.onCompleted: loaderSpecularG.item.componentInfo = "specularG" - Text { - id : gSpecularText - text: ' G' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - anchors.centerIn: parent - } - } - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: gSpecularLoader - anchors.fill: parent - property double numberValue: model.data[1] - sourceComponent: sliderZeroOne - onLoaded: { - gSpecularItem = gSpecularLoader.item - } - } - } - } - RowLayout { - Rectangle { - color: "transparent" - height: 40 - Layout.preferredWidth: bSpecularText.width + indentation*3 - Loader { - id: loaderSpecularB - width: iconWidth - height: iconHeight - y:10 - sourceComponent: plotIcon - } - Component.onCompleted: loaderSpecularB.item.componentInfo = "specularB" - - Text { - id : bSpecularText - text: ' B' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - anchors.centerIn: parent - } - } - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: bSpecularLoader - anchors.fill: parent - property double numberValue: model.data[2] - sourceComponent: sliderZeroOne - onLoaded: { - bSpecularItem = bSpecularLoader.item - } - } - } - Rectangle { - color: "transparent" - height: 40 - Layout.preferredWidth: aSpecularText.width + indentation*3 - Loader { - id: loaderSpecularA - width: iconWidth - height: iconHeight - y:10 - sourceComponent: plotIcon - } - Component.onCompleted: loaderSpecularA.item.componentInfo = "specularA" - - Text { - id : aSpecularText - text: ' A' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - anchors.centerIn: parent - } - } - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: aSpecularLoader - anchors.fill: parent - property double numberValue: model.data[3] - sourceComponent: sliderZeroOne - onLoaded: { - aSpecularItem = aSpecularLoader.item - } - } - } - } - RowLayout { - Layout.alignment: Qt.AlignHCenter - Button { - Layout.alignment: Qt.AlignHCenter - id: specularColor - text: qsTr("Specular Color") - onClicked: colorDialog.open() - ColorDialog { - id: colorDialog - title: "Choose a specular color" - visible: false - onAccepted: { - rSpecularLoader.item.value = colorDialog.color.r - gSpecularLoader.item.value = colorDialog.color.g - bSpecularLoader.item.value = colorDialog.color.b - aSpecularLoader.item.value = colorDialog.color.a - sendLight() - colorDialog.close() - } - onRejected: { - colorDialog.close() - } - } - } - } - RowLayout { - Text { - Layout.columnSpan: 6 - text: " Diffuse" - color: "dimgrey" - width: margin + indentation - } + // Specular + Item { + Layout.row: 0 + Layout.columnSpan: 6 + Layout.fillWidth: true + height: 70 + Loader { + id: specularLoader + anchors.fill: parent + sourceComponent: colorMaterial + onLoaded: { + specularLoader.item.r = model.data[0] * 255 + specularLoader.item.g = model.data[1] * 255 + specularLoader.item.b = model.data[2] * 255 + specularLoader.item.a = model.data[3] + rSpecularItem: specularLoader.item.r + gSpecularItem: specularLoader.item.g + bSpecularItem: specularLoader.item.b + aSpecularItem: specularLoader.item.a + } + } + Binding { + target: specularLoader.item + property: "textVisible" + value: true + } + Binding { + target: specularLoader.item + property: "colorName" + value: "Specular" + } + Connections { + target: specularLoader.item + onColorSet: { + sendLight() + } + } } - RowLayout { - Rectangle { - color: "transparent" - height: 40 - Layout.preferredWidth: rDiffuseText.width + indentation*3 - Loader { - id: loaderDiffuseR - width: iconWidth - height: iconHeight - y:10 - sourceComponent: plotIcon - } - Component.onCompleted: loaderDiffuseR.item.componentInfo = "diffuseR" - - Text { - id : rDiffuseText - text: ' R' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - anchors.centerIn: parent - } - } - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: rDiffuseLoader - anchors.fill: parent - property double numberValue: model.data[4] - sourceComponent: sliderZeroOne - onLoaded: { - rDiffuseItem = rDiffuseLoader.item - } - } - } - Rectangle { - color: "transparent" - height: 40 - Layout.preferredWidth: gDiffuseText.width + indentation*3 - Loader { - id: loaderDiffuseG - width: iconWidth - height: iconHeight - y:10 - sourceComponent: plotIcon - } - Component.onCompleted: loaderDiffuseG.item.componentInfo = "diffuseG" - Text { - id : gDiffuseText - text: ' G' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - anchors.centerIn: parent - } - } - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: gDiffuseLoader - anchors.fill: parent - property double numberValue: model.data[5] - sourceComponent: sliderZeroOne - onLoaded: { - gDiffuseItem = gDiffuseLoader.item - } - } - } + // Diffuse + Item { + Layout.row: 0 + Layout.columnSpan: 6 + Layout.fillWidth: true + height: 70 + Loader { + id: diffuseLoader + anchors.fill: parent + sourceComponent: colorMaterial + onLoaded: { + diffuseLoader.item.r = model.data[4] * 255 + diffuseLoader.item.g = model.data[5] * 255 + diffuseLoader.item.b = model.data[6] * 255 + diffuseLoader.item.a = model.data[7] + rDiffuseItem: diffuseLoader.item.r + gDiffuseItem: diffuseLoader.item.g + bDiffuseItem: diffuseLoader.item.b + aDiffuseItem: diffuseLoader.item.a + } + } + Binding { + target: diffuseLoader.item + property: "colorName" + value: "Diffuse" + } + Connections { + target: diffuseLoader.item + onColorSet: { + sendLight() + } + } } - RowLayout { - Rectangle { - color: "transparent" - height: 40 - Layout.preferredWidth: bDiffuseText.width + indentation*3 - Loader { - id: loaderDiffuseB - width: iconWidth - height: iconHeight - y:10 - sourceComponent: plotIcon - } - Component.onCompleted: loaderDiffuseB.item.componentInfo = "diffuseB" - Text { - id : bDiffuseText - text: ' B' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - anchors.centerIn: parent - } - } - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: bDiffuseLoader - anchors.fill: parent - property double numberValue: model.data[6] - sourceComponent: sliderZeroOne - onLoaded: { - bDiffuseItem = bDiffuseLoader.item - } - } - } - Rectangle { - color: "transparent" - height: 40 - Layout.preferredWidth: aDiffuseText.width + indentation*3 - Loader { - id: loaderDiffuseA - width: iconWidth - height: iconHeight - y:10 - sourceComponent: plotIcon - } - Component.onCompleted: loaderDiffuseA.item.componentInfo = "diffuseA" - - Text { - id : aDiffuseText - text: ' A' - leftPadding: 5 - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - font.pointSize: 12 - anchors.centerIn: parent - } - } - Item { - Layout.fillWidth: true - height: 40 - Loader { - id: aDiffuseLoader - anchors.fill: parent - property double numberValue: model.data[7] - sourceComponent: sliderZeroOne - onLoaded: { - aDiffuseItem = aDiffuseLoader.item - } - } - } - } - RowLayout { - Layout.alignment: Qt.AlignHCenter - Button { - Layout.alignment: Qt.AlignHCenter - id: diffuseColor - text: qsTr("Diffuse Color") - onClicked: colorDialogDiffuse.open() - ColorDialog { - id: colorDialogDiffuse - title: "Choose a diffuse color" - visible: false - onAccepted: { - rDiffuseLoader.item.value = colorDialogDiffuse.color.r - gDiffuseLoader.item.value = colorDialogDiffuse.color.g - bDiffuseLoader.item.value = colorDialogDiffuse.color.b - aDiffuseLoader.item.value = colorDialogDiffuse.color.a - sendLight() - colorDialogDiffuse.close() - } - onRejected: { - colorDialogDiffuse.close() - } - } - } - } RowLayout { Text { Layout.columnSpan: 6 From b2ef5121571a9ca10aed98ff8779ed12b68b0094 Mon Sep 17 00:00:00 2001 From: youhy Date: Fri, 10 Jun 2022 08:15:41 -0700 Subject: [PATCH 04/15] Diffuse, Specular, and Emissive Loader Signed-off-by: youhy --- .../plugins/component_inspector/Material.qml | 375 +++++------------- 1 file changed, 100 insertions(+), 275 deletions(-) diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index fb914abd83..130ec51486 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -46,22 +46,22 @@ Rectangle { property double aAmbientItem // Loaded items for diffuse red, green, blue, alpha - property var rDiffuseItem: {} - property var gDiffuseItem: {} - property var bDiffuseItem: {} - property var aDiffuseItem: {} + property double rDiffuseItem + property double gDiffuseItem + property double bDiffuseItem + property double aDiffuseItem // Loaded items for specular red, green, blue, alpha - property var rSpecularItem: {} - property var gSpecularItem: {} - property var bSpecularItem: {} - property var aSpecularItem: {} + property double rSpecularItem + property double gSpecularItem + property double bSpecularItem + property double aSpecularItem // Loaded items for emissive red, green, blue, alpha - property var rEmissiveItem: {} - property var gEmissiveItem: {} - property var bEmissiveItem: {} - property var aEmissiveItem: {} + property double rEmissiveItem + property double gEmissiveItem + property double bEmissiveItem + property double aEmissiveItem // send new material color data to C++ function sendMaterialColor(_type, _currColor) { @@ -69,19 +69,19 @@ Rectangle { rAmbientItem, gAmbientItem, bAmbientItem, - aAmbientItem, - rDiffuseItem.value, - gDiffuseItem.value, - bDiffuseItem.value, - aDiffuseItem.value, - rSpecularItem.value, - gSpecularItem.value, - bSpecularItem.value, - aSpecularItem.value, - rEmissiveItem.value, - gEmissiveItem.value, - bEmissiveItem.value, - aEmissiveItem.value, + 1.0 * aAmbientItem * 255.0, + rDiffuseItem, + gDiffuseItem, + bDiffuseItem, + 1.0 * aDiffuseItem * 255.0, + rSpecularItem, + gSpecularItem, + bSpecularItem, + 1.0 * aSpecularItem * 255.0, + rEmissiveItem, + gEmissiveItem, + bEmissiveItem, + 1.0 * aEmissiveItem * 255.0, _type, _currColor ); @@ -221,10 +221,14 @@ Rectangle { anchors.fill: parent sourceComponent: colorMaterial onLoaded: { - rAmbientItem = ambientLoader.item.r - gAmbientItem = ambientLoader.item.g - bAmbientItem = ambientLoader.item.b - aAmbientItem = ambientLoader.item.a * 255.0 + ambientLoader.item.r = model.data[0] + ambientLoader.item.g = model.data[1] + ambientLoader.item.b = model.data[2] + ambientLoader.item.a = model.data[3] / 255.0 + rAmbientItem: ambientLoader.item.r + gAmbientItem: ambientLoader.item.g + bAmbientItem: ambientLoader.item.b + aAmbientItem: ambientLoader.item.a } } Binding { @@ -240,290 +244,111 @@ Rectangle { Connections { target : ambientLoader.item onColorSet: { - rAmbientItem = ambientLoader.item.r - gAmbientItem = ambientLoader.item.g - bAmbientItem = ambientLoader.item.b - aAmbientItem = ambientLoader.item.a * 255.0 sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } } -// Diffuse - Text { - text: " Diffuse" - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - Layout.row: 3 - Layout.column: 1 - } - // Diffuse color dialog - Button { - id: diffuseButton - Layout.row: 3 - Layout.column: 2 - ToolTip.text: "Open color dialog" - ToolTip.visible: hovered - ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval - background: Rectangle { - implicitWidth: 40 - implicitHeight: 40 - radius: 5 - border.color: getButtonColor(4, false) - border.width: 2 - color: getButtonColor(4, true) - } - onClicked: { - sendMaterialColor("diffuse", getButtonColor(4, true)) - } - } - // Diffuse red + // Diffuse Item { - Layout.row: 3 - Layout.column: 3 + Layout.row: 1 + Layout.columnSpan: 6 Layout.fillWidth: true - height: 40 + height: 70 Loader { - id: rDiffuseLoader + id: diffuseLoader anchors.fill: parent - property double numberValue: model.data[4] - sourceComponent: spinBoxMaterialColor + sourceComponent: colorMaterial onLoaded: { - rDiffuseItem = rDiffuseLoader.item + diffuseLoader.item.r = model.data[4] + diffuseLoader.item.g = model.data[5] + diffuseLoader.item.b = model.data[6] + diffuseLoader.item.a = model.data[7] / 255.0 + rDiffuseItem: diffuseLoader.item.r + gDiffuseItem: diffuseLoader.item.g + bDiffuseItem: diffuseLoader.item.b + aDiffuseItem: diffuseLoader.item.a } } - } - // Diffuse green - Item { - Layout.row: 3 - Layout.column: 4 - Layout.fillWidth: true - height: 40 - Loader { - id: gDiffuseLoader - anchors.fill: parent - property double numberValue: model.data[5] - sourceComponent: spinBoxMaterialColor - onLoaded: { - gDiffuseItem = gDiffuseLoader.item - } + Binding { + target: diffuseLoader.item + property: "colorName" + value: "Diffuse " } - } - // Diffuse blue - Item { - Layout.row: 3 - Layout.column: 5 - Layout.fillWidth: true - height: 40 - Loader { - id: bDiffuseLoader - anchors.fill: parent - property double numberValue: model.data[6] - sourceComponent: spinBoxMaterialColor - onLoaded: { - bDiffuseItem = bDiffuseLoader.item + Connections { + target : diffuseLoader.item + onColorSet: { + sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } - } + } } - // Diffuse alpha - Item { - Layout.row: 3 - Layout.column: 6 - Layout.fillWidth: true - height: 40 - Loader { - id: aDiffuseLoader - anchors.fill: parent - property double numberValue: model.data[7] - sourceComponent: spinBoxMaterialColor - onLoaded: { - aDiffuseItem = aDiffuseLoader.item - } - } - } // end Diffuse - // Specular - Text { - text: " Specular" - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - Layout.row: 4 - Layout.column: 1 - } - // Specular color dialog - Button { - id: specularButton - Layout.row: 4 - Layout.column: 2 - ToolTip.text: "Open color dialog" - ToolTip.visible: hovered - ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval - background: Rectangle { - implicitWidth: 40 - implicitHeight: 40 - radius: 5 - border.color: getButtonColor(8, false) - border.width: 2 - color: getButtonColor(8, true) - } - onClicked: { - sendMaterialColor("specular", getButtonColor(8, true)) - } - } - // Specular red Item { - Layout.row: 4 - Layout.column: 3 + Layout.row: 2 + Layout.columnSpan: 6 Layout.fillWidth: true - height: 40 + height: 70 Loader { - id: rSpecularLoader + id: specularLoader anchors.fill: parent - property double numberValue: model.data[8] - sourceComponent: spinBoxMaterialColor + sourceComponent: colorMaterial onLoaded: { - rSpecularItem = rSpecularLoader.item + specularLoader.item.r = model.data[8] + specularLoader.item.g = model.data[9] + specularLoader.item.b = model.data[10] + specularLoader.item.a = model.data[11] / 255.0 + rSpecularItem: specularLoader.item.r + gSpecularItem: specularLoader.item.g + bSpecularItem: specularLoader.item.b + aSpecularItem: specularLoader.item.a } } - } - // Specular green - Item { - Layout.row: 4 - Layout.column: 4 - Layout.fillWidth: true - height: 40 - Loader { - id: gSpecularLoader - anchors.fill: parent - property double numberValue: model.data[9] - sourceComponent: spinBoxMaterialColor - onLoaded: { - gSpecularItem = gSpecularLoader.item - } + Binding { + target: specularLoader.item + property: "colorName" + value: "Specular" } - } - // Specular blue - Item { - Layout.row: 4 - Layout.column: 5 - Layout.fillWidth: true - height: 40 - Loader { - id: bSpecularLoader - anchors.fill: parent - property double numberValue: model.data[10] - sourceComponent: spinBoxMaterialColor - onLoaded: { - bSpecularItem = bSpecularLoader.item + Connections { + target : specularLoader.item + onColorSet: { + sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } - } + } } - // Specular alpha - Item { - Layout.row: 4 - Layout.column: 6 - Layout.fillWidth: true - height: 40 - Loader { - id: aSpecularLoader - anchors.fill: parent - property double numberValue: model.data[11] - sourceComponent: spinBoxMaterialColor - onLoaded: { - aSpecularItem = aSpecularLoader.item - } - } - } // end Specular // Emissive - Text { - text: " Emissive" - color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" - Layout.row: 5 - Layout.column: 1 - } - // Emissive color dialog - Button { - id: emissiveButton - Layout.row: 5 - Layout.column: 2 - ToolTip.text: "Open color dialog" - ToolTip.visible: hovered - ToolTip.delay: Qt.styleHints.mousePressAndHoldInterval - background: Rectangle { - implicitWidth: 40 - implicitHeight: 40 - radius: 5 - border.color: getButtonColor(12, false) - border.width: 2 - color: getButtonColor(12, true) - } - onClicked: { - sendMaterialColor("emissive", getButtonColor(12, true)) - } - } - // Emissive red Item { - Layout.row: 5 - Layout.column: 3 - Layout.fillWidth: true - height: 40 - Loader { - id: rEmissiveLoader - anchors.fill: parent - property double numberValue: model.data[12] - sourceComponent: spinBoxMaterialColor - onLoaded: { - rEmissiveItem = rEmissiveLoader.item - } - } - } - // Emissive green - Item { - Layout.row: 5 - Layout.column: 4 + Layout.row: 3 + Layout.columnSpan: 6 Layout.fillWidth: true - height: 40 + height: 70 Loader { - id: gEmissiveLoader + id: emissiveLoader anchors.fill: parent - property double numberValue: model.data[13] - sourceComponent: spinBoxMaterialColor + sourceComponent: colorMaterial onLoaded: { - gEmissiveItem = gEmissiveLoader.item + emissiveLoader.item.r = model.data[12] + emissiveLoader.item.g = model.data[13] + emissiveLoader.item.b = model.data[14] + emissiveLoader.item.a = model.data[15] / 255.0 + rEmissiveItem: emissiveLoader.item.r + gEmissiveItem: emissiveLoader.item.g + bEmissiveItem: emissiveLoader.item.b + aEmissiveItem: emissiveLoader.item.a } } - } - // Emissive blue - Item { - Layout.row: 5 - Layout.column: 5 - Layout.fillWidth: true - height: 40 - Loader { - id: bEmissiveLoader - anchors.fill: parent - property double numberValue: model.data[14] - sourceComponent: spinBoxMaterialColor - onLoaded: { - bEmissiveItem = bEmissiveLoader.item - } + Binding { + target: emissiveLoader.item + property: "colorName" + value: "Emissive" } - } - // Emissive alpha - Item { - Layout.row: 5 - Layout.column: 6 - Layout.fillWidth: true - height: 40 - Loader { - id: aEmissiveLoader - anchors.fill: parent - property double numberValue: model.data[15] - sourceComponent: spinBoxMaterialColor - onLoaded: { - aEmissiveItem = aEmissiveLoader.item + Connections { + target : emissiveLoader.item + onColorSet: { + sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } - } + } } // end Emissive } // end GridLayout } // end ColumnLayout (id: grid) From 54a946511a760ebde8a322ad593a41092eae020c Mon Sep 17 00:00:00 2001 From: youhy Date: Fri, 10 Jun 2022 12:35:29 -0700 Subject: [PATCH 05/15] spinbox value bind to property Signed-off-by: youhy --- .../plugins/component_inspector/Material.qml | 48 +++++++------------ 1 file changed, 16 insertions(+), 32 deletions(-) diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index 130ec51486..5120c7f84d 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -40,28 +40,28 @@ Rectangle { property int iconHeight: 20 // Loaded items for ambient red, green, blue, alpha - property double rAmbientItem - property double gAmbientItem - property double bAmbientItem - property double aAmbientItem + property double rAmbientItem: ambientLoader.item.r + property double gAmbientItem: ambientLoader.item.g + property double bAmbientItem: ambientLoader.item.b + property double aAmbientItem: ambientLoader.item.a // Loaded items for diffuse red, green, blue, alpha - property double rDiffuseItem - property double gDiffuseItem - property double bDiffuseItem - property double aDiffuseItem + property double rDiffuseItem: diffuseLoader.item.r + property double gDiffuseItem: diffuseLoader.item.g + property double bDiffuseItem: diffuseLoader.item.b + property double aDiffuseItem: diffuseLoader.item.a // Loaded items for specular red, green, blue, alpha - property double rSpecularItem - property double gSpecularItem - property double bSpecularItem - property double aSpecularItem + property double rSpecularItem: specularLoader.item.r + property double gSpecularItem: specularLoader.item.g + property double bSpecularItem: specularLoader.item.b + property double aSpecularItem: specularLoader.item.a // Loaded items for emissive red, green, blue, alpha - property double rEmissiveItem - property double gEmissiveItem - property double bEmissiveItem - property double aEmissiveItem + property double rEmissiveItem: emissiveLoader.item.r + property double gEmissiveItem: emissiveLoader.item.g + property double bEmissiveItem: emissiveLoader.item.b + property double aEmissiveItem: emissiveLoader.item.a // send new material color data to C++ function sendMaterialColor(_type, _currColor) { @@ -225,10 +225,6 @@ Rectangle { ambientLoader.item.g = model.data[1] ambientLoader.item.b = model.data[2] ambientLoader.item.a = model.data[3] / 255.0 - rAmbientItem: ambientLoader.item.r - gAmbientItem: ambientLoader.item.g - bAmbientItem: ambientLoader.item.b - aAmbientItem: ambientLoader.item.a } } Binding { @@ -264,10 +260,6 @@ Rectangle { diffuseLoader.item.g = model.data[5] diffuseLoader.item.b = model.data[6] diffuseLoader.item.a = model.data[7] / 255.0 - rDiffuseItem: diffuseLoader.item.r - gDiffuseItem: diffuseLoader.item.g - bDiffuseItem: diffuseLoader.item.b - aDiffuseItem: diffuseLoader.item.a } } Binding { @@ -298,10 +290,6 @@ Rectangle { specularLoader.item.g = model.data[9] specularLoader.item.b = model.data[10] specularLoader.item.a = model.data[11] / 255.0 - rSpecularItem: specularLoader.item.r - gSpecularItem: specularLoader.item.g - bSpecularItem: specularLoader.item.b - aSpecularItem: specularLoader.item.a } } Binding { @@ -332,10 +320,6 @@ Rectangle { emissiveLoader.item.g = model.data[13] emissiveLoader.item.b = model.data[14] emissiveLoader.item.a = model.data[15] / 255.0 - rEmissiveItem: emissiveLoader.item.r - gEmissiveItem: emissiveLoader.item.g - bEmissiveItem: emissiveLoader.item.b - aEmissiveItem: emissiveLoader.item.a } } Binding { From ddbb980db3f85a8a6e69c19a9f1f7794dc70fc2a Mon Sep 17 00:00:00 2001 From: youhy Date: Mon, 13 Jun 2022 08:40:36 -0700 Subject: [PATCH 06/15] change rgba property to bind Signed-off-by: youhy --- .../plugins/component_inspector/Material.qml | 104 ++++++++++++++---- 1 file changed, 80 insertions(+), 24 deletions(-) diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index 5120c7f84d..83bb895cb7 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -220,12 +220,6 @@ Rectangle { id: ambientLoader anchors.fill: parent sourceComponent: colorMaterial - onLoaded: { - ambientLoader.item.r = model.data[0] - ambientLoader.item.g = model.data[1] - ambientLoader.item.b = model.data[2] - ambientLoader.item.a = model.data[3] / 255.0 - } } Binding { target: ambientLoader.item @@ -237,6 +231,26 @@ Rectangle { property: "colorName" value: "Ambient" } + Binding { + target: ambientLoader.item + property: "r" + value: model.data[0] + } + Binding { + target: ambientLoader.item + property: "g" + value: model.data[1] + } + Binding { + target: ambientLoader.item + property: "b" + value: model.data[2] + } + Binding { + target: ambientLoader.item + property: "a" + value: model.data[3] / 255.0 + } Connections { target : ambientLoader.item onColorSet: { @@ -255,18 +269,32 @@ Rectangle { id: diffuseLoader anchors.fill: parent sourceComponent: colorMaterial - onLoaded: { - diffuseLoader.item.r = model.data[4] - diffuseLoader.item.g = model.data[5] - diffuseLoader.item.b = model.data[6] - diffuseLoader.item.a = model.data[7] / 255.0 - } } Binding { target: diffuseLoader.item property: "colorName" value: "Diffuse " } + Binding { + target: diffuseLoader.item + property: "r" + value: model.data[4] + } + Binding { + target: diffuseLoader.item + property: "g" + value: model.data[5] + } + Binding { + target: diffuseLoader.item + property: "b" + value: model.data[6] + } + Binding { + target: diffuseLoader.item + property: "a" + value: model.data[7] / 255.0 + } Connections { target : diffuseLoader.item onColorSet: { @@ -285,18 +313,32 @@ Rectangle { id: specularLoader anchors.fill: parent sourceComponent: colorMaterial - onLoaded: { - specularLoader.item.r = model.data[8] - specularLoader.item.g = model.data[9] - specularLoader.item.b = model.data[10] - specularLoader.item.a = model.data[11] / 255.0 - } } Binding { target: specularLoader.item property: "colorName" value: "Specular" } + Binding { + target: specularLoader.item + property: "r" + value: model.data[8] + } + Binding { + target: specularLoader.item + property: "g" + value: model.data[9] + } + Binding { + target: specularLoader.item + property: "b" + value: model.data[10] + } + Binding { + target: specularLoader.item + property: "a" + value: model.data[11] / 255.0 + } Connections { target : specularLoader.item onColorSet: { @@ -315,18 +357,32 @@ Rectangle { id: emissiveLoader anchors.fill: parent sourceComponent: colorMaterial - onLoaded: { - emissiveLoader.item.r = model.data[12] - emissiveLoader.item.g = model.data[13] - emissiveLoader.item.b = model.data[14] - emissiveLoader.item.a = model.data[15] / 255.0 - } } Binding { target: emissiveLoader.item property: "colorName" value: "Emissive" } + Binding { + target: emissiveLoader.item + property: "r" + value: model.data[12] + } + Binding { + target: emissiveLoader.item + property: "g" + value: model.data[13] + } + Binding { + target: emissiveLoader.item + property: "b" + value: model.data[14] + } + Binding { + target: emissiveLoader.item + property: "a" + value: model.data[15] / 255.0 + } Connections { target : emissiveLoader.item onColorSet: { From 59d6386ca2cfcd16105b8a269558f289b918ceb9 Mon Sep 17 00:00:00 2001 From: youhy Date: Tue, 14 Jun 2022 14:27:55 -0700 Subject: [PATCH 07/15] update lights.qml to new GzColor Signed-off-by: youhy --- src/gui/plugins/component_inspector/Light.qml | 201 ++++++++++++------ 1 file changed, 131 insertions(+), 70 deletions(-) diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index 97a1f4cf27..cd4c0f43a3 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -151,7 +151,7 @@ Rectangle { id: colorMaterial GzColor { id: gzcolor - textVisible: false + onColorSet: sendLight() } } @@ -354,79 +354,140 @@ Rectangle { } } - // Specular - Item { - Layout.row: 0 - Layout.columnSpan: 6 - Layout.fillWidth: true - height: 70 - Loader { - id: specularLoader - anchors.fill: parent - sourceComponent: colorMaterial - onLoaded: { - specularLoader.item.r = model.data[0] * 255 - specularLoader.item.g = model.data[1] * 255 - specularLoader.item.b = model.data[2] * 255 - specularLoader.item.a = model.data[3] - rSpecularItem: specularLoader.item.r - gSpecularItem: specularLoader.item.g - bSpecularItem: specularLoader.item.b - aSpecularItem: specularLoader.item.a - } - } - Binding { - target: specularLoader.item - property: "textVisible" - value: true - } - Binding { - target: specularLoader.item - property: "colorName" - value: "Specular" - } - Connections { - target: specularLoader.item - onColorSet: { - sendLight() - } - } + RowLayout { + // Color + Text { + Layout.columnSpan: 6 + text: "Color" + color: "dimgrey" + font.bold: true + } } - // Diffuse - Item { - Layout.row: 0 - Layout.columnSpan: 6 - Layout.fillWidth: true - height: 70 - Loader { - id: diffuseLoader - anchors.fill: parent - sourceComponent: colorMaterial - onLoaded: { - diffuseLoader.item.r = model.data[4] * 255 - diffuseLoader.item.g = model.data[5] * 255 - diffuseLoader.item.b = model.data[6] * 255 - diffuseLoader.item.a = model.data[7] - rDiffuseItem: diffuseLoader.item.r - gDiffuseItem: diffuseLoader.item.g - bDiffuseItem: diffuseLoader.item.b - aDiffuseItem: diffuseLoader.item.a - } - } - Binding { - target: diffuseLoader.item - property: "colorName" - value: "Diffuse" - } - Connections { - target: diffuseLoader.item - onColorSet: { - sendLight() - } - } + RowLayout { + Rectangle { + color: "transparent" + height: 50 + Layout.preferredWidth: specularText.width + indentation*3 + + Text { + id : specularText + Layout.columnSpan: 2 + text: ' Specular' + leftPadding: 5 + color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" + font.pointSize: 12 + anchors.centerIn: parent + } + } + + // Specular + Item { + Layout.fillWidth: true + Layout.bottomMargin: 10 + height: 40 + Loader { + id: specularLoader + anchors.fill: parent + sourceComponent: colorMaterial + onLoaded: { + rSpecularItem: specularLoader.item.r + gSpecularItem: specularLoader.item.g + bSpecularItem: specularLoader.item.b + aSpecularItem: specularLoader.item.a + } + } + Binding { + target: specularLoader.item + property: "r" + value: model.data[0] * 255 + } + Binding { + target: specularLoader.item + property: "g" + value: model.data[1] * 255 + } + Binding { + target: specularLoader.item + property: "b" + value: model.data[2] * 255 + } + Binding { + target: specularLoader.item + property: "a" + value: model.data[3] + } + Connections { + target: specularLoader.item + onColorSet: { + sendLight() + } + } + } + + // Diffuse + Rectangle { + color: "transparent" + height: 50 + Layout.preferredWidth: diffuseText.width + indentation*3 + + Text { + id : diffuseText + Layout.columnSpan: 2 + text: ' Diffuse' + leftPadding: 5 + color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" + font.pointSize: 12 + anchors.centerIn: parent + } + } + + // Specular + Item { + Layout.fillWidth: true + Layout.bottomMargin: 10 + height: 40 + Loader { + id: diffuseLoader + anchors.fill: parent + sourceComponent: colorMaterial + onLoaded: { + rDiffuseItem: diffuseLoader.item.r + gDiffuseItem: diffuseLoader.item.g + bDiffuseItem: diffuseLoader.item.b + aDiffuseItem: diffuseLoader.item.a + } + } + Binding { + target: diffuseLoader.item + property: "r" + value: model.data[4] * 255 + } + Binding { + target: diffuseLoader.item + property: "g" + value: model.data[5] * 255 + } + Binding { + target: diffuseLoader.item + property: "b" + value: model.data[6] * 255 + } + Binding { + target: diffuseLoader.item + property: "a" + value: model.data[7] + } + Connections { + target: diffuseLoader.item + onColorSet: { + sendLight() + } + } + } } + RowLayout { Text { Layout.columnSpan: 6 From 13c799f232b13a666e9acf9b619b1b07263d4922 Mon Sep 17 00:00:00 2001 From: youhy Date: Wed, 15 Jun 2022 13:59:54 -0700 Subject: [PATCH 08/15] fix Lights.qml switch bug and update Material.qml to new gzcolor Signed-off-by: youhy --- src/gui/plugins/component_inspector/Light.qml | 39 ++--- .../plugins/component_inspector/Material.qml | 151 ++++++++++++------ 2 files changed, 114 insertions(+), 76 deletions(-) diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index cd4c0f43a3..1c0e5e6608 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -40,16 +40,16 @@ Rectangle { property int iconHeight: 20 // Loaded item for specular RGBA - property double rSpecularItem - property double gSpecularItem - property double bSpecularItem - property double aSpecularItem + property double rSpecularItem: specularLoader.item.r + property double gSpecularItem: specularLoader.item.g + property double bSpecularItem: specularLoader.item.b + property double aSpecularItem: specularLoader.item.a // Loaded item for diffuse red - property double rDiffuseItem - property double gDiffuseItem - property double bDiffuseItem - property double aDiffuseItem + property double rDiffuseItem: diffuseLoader.item.r + property double gDiffuseItem: diffuseLoader.item.g + property double bDiffuseItem: diffuseLoader.item.b + property double aDiffuseItem: diffuseLoader.item.a // Loaded item for attenuation range property var attRangeItem: {} @@ -363,8 +363,9 @@ Rectangle { font.bold: true } } - - RowLayout { + + RowLayout { + // Specular Rectangle { color: "transparent" height: 50 @@ -390,12 +391,6 @@ Rectangle { id: specularLoader anchors.fill: parent sourceComponent: colorMaterial - onLoaded: { - rSpecularItem: specularLoader.item.r - gSpecularItem: specularLoader.item.g - bSpecularItem: specularLoader.item.b - aSpecularItem: specularLoader.item.a - } } Binding { target: specularLoader.item @@ -422,7 +417,7 @@ Rectangle { onColorSet: { sendLight() } - } + } } // Diffuse @@ -442,7 +437,7 @@ Rectangle { } } - // Specular + // Diffuse Item { Layout.fillWidth: true Layout.bottomMargin: 10 @@ -451,12 +446,6 @@ Rectangle { id: diffuseLoader anchors.fill: parent sourceComponent: colorMaterial - onLoaded: { - rDiffuseItem: diffuseLoader.item.r - gDiffuseItem: diffuseLoader.item.g - bDiffuseItem: diffuseLoader.item.b - aDiffuseItem: diffuseLoader.item.a - } } Binding { target: diffuseLoader.item @@ -483,7 +472,7 @@ Rectangle { onColorSet: { sendLight() } - } + } } } diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index 83bb895cb7..8fa13c3261 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -134,7 +134,7 @@ Rectangle { id: colorMaterial GzColor { id: gzcolor - textVisible: false + onColorSet: sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } @@ -206,31 +206,45 @@ Rectangle { width: parent.width spacing: 20 - GridLayout { - width: parent.width - columns: 6 + + RowLayout { + // Color + Text { + Layout.columnSpan: 6 + text: "Color" + color: "dimgrey" + font.bold: true + } + } + + RowLayout { + // Ambient + Rectangle { + color: "transparent" + height: 50 + Layout.preferredWidth: ambientText.width + indentation*3 + + Text { + id : ambientText + Layout.columnSpan: 2 + text: ' Ambient' + leftPadding: 5 + color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" + font.pointSize: 12 + anchors.centerIn: parent + } + } // Ambient Item { - Layout.row: 0 - Layout.columnSpan: 6 Layout.fillWidth: true - height: 70 + Layout.bottomMargin: 10 + height: 40 Loader { id: ambientLoader anchors.fill: parent sourceComponent: colorMaterial } - Binding { - target: ambientLoader.item - property: "textVisible" - value: true - } - Binding { - target: ambientLoader.item - property: "colorName" - value: "Ambient" - } Binding { target: ambientLoader.item property: "r" @@ -252,29 +266,40 @@ Rectangle { value: model.data[3] / 255.0 } Connections { - target : ambientLoader.item + target: ambientLoader.item onColorSet: { sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } - } + } + } + + // Diffuse + Rectangle { + color: "transparent" + height: 50 + Layout.preferredWidth: diffuseText.width + indentation*3 + + Text { + id : diffuseText + Layout.columnSpan: 2 + text: ' Diffuse' + leftPadding: 5 + color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" + font.pointSize: 12 + anchors.centerIn: parent + } } // Diffuse Item { - Layout.row: 1 - Layout.columnSpan: 6 Layout.fillWidth: true - height: 70 + Layout.bottomMargin: 10 + height: 40 Loader { id: diffuseLoader anchors.fill: parent sourceComponent: colorMaterial } - Binding { - target: diffuseLoader.item - property: "colorName" - value: "Diffuse " - } Binding { target: diffuseLoader.item property: "r" @@ -296,29 +321,42 @@ Rectangle { value: model.data[7] / 255.0 } Connections { - target : diffuseLoader.item + target: diffuseLoader.item onColorSet: { sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } - } + } + } + } + + RowLayout { + // Specular + Rectangle { + color: "transparent" + height: 50 + Layout.preferredWidth: specularText.width + indentation*3 + + Text { + id : specularText + Layout.columnSpan: 2 + text: ' Specular' + leftPadding: 5 + color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" + font.pointSize: 12 + anchors.centerIn: parent + } } // Specular Item { - Layout.row: 2 - Layout.columnSpan: 6 Layout.fillWidth: true - height: 70 + Layout.bottomMargin: 10 + height: 40 Loader { id: specularLoader anchors.fill: parent sourceComponent: colorMaterial } - Binding { - target: specularLoader.item - property: "colorName" - value: "Specular" - } Binding { target: specularLoader.item property: "r" @@ -340,29 +378,40 @@ Rectangle { value: model.data[11] / 255.0 } Connections { - target : specularLoader.item + target: specularLoader.item onColorSet: { sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } - } + } + } + + // Emissive + Rectangle { + color: "transparent" + height: 50 + Layout.preferredWidth: emissiveText.width + indentation*3 + + Text { + id : emissiveText + Layout.columnSpan: 2 + text: 'Emissive' + leftPadding: 5 + color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" + font.pointSize: 12 + anchors.centerIn: parent + } } // Emissive Item { - Layout.row: 3 - Layout.columnSpan: 6 Layout.fillWidth: true - height: 70 + Layout.bottomMargin: 10 + height: 40 Loader { id: emissiveLoader anchors.fill: parent sourceComponent: colorMaterial } - Binding { - target: emissiveLoader.item - property: "colorName" - value: "Emissive" - } Binding { target: emissiveLoader.item property: "r" @@ -384,13 +433,13 @@ Rectangle { value: model.data[15] / 255.0 } Connections { - target : emissiveLoader.item + target: emissiveLoader.item onColorSet: { sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } - } - } // end Emissive - } // end GridLayout + } + } + } // end RowLayout } // end ColumnLayout (id: grid) } // Rectangle (id: content) } From 476dde4b8e80f763f132f2ee6ec86ebf70a2487f Mon Sep 17 00:00:00 2001 From: youhy Date: Sun, 7 Aug 2022 13:28:09 -0700 Subject: [PATCH 09/15] codecheck Signed-off-by: youhy --- src/gui/plugins/component_inspector/Light.qml | 15 ++++++------- .../plugins/component_inspector/Material.qml | 22 +++++++++---------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index 1c0e5e6608..56f0aee6f1 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -148,8 +148,8 @@ Rectangle { } Component { - id: colorMaterial - GzColor { + id: colorMaterial + GzColor { id: gzcolor onColorSet: sendLight() } @@ -363,7 +363,7 @@ Rectangle { font.bold: true } } - + RowLayout { // Specular Rectangle { @@ -412,9 +412,9 @@ Rectangle { property: "a" value: model.data[3] } - Connections { + Connections { target: specularLoader.item - onColorSet: { + onColorSet: { sendLight() } } @@ -467,16 +467,15 @@ Rectangle { property: "a" value: model.data[7] } - Connections { + Connections { target: diffuseLoader.item - onColorSet: { + onColorSet: { sendLight() } } } } - RowLayout { Text { Layout.columnSpan: 6 diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index 8fa13c3261..633703031f 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -131,10 +131,10 @@ Rectangle { } Component { - id: colorMaterial - GzColor { + id: colorMaterial + GzColor { id: gzcolor - onColorSet: sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) + onColorSet: sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } @@ -265,9 +265,9 @@ Rectangle { property: "a" value: model.data[3] / 255.0 } - Connections { + Connections { target: ambientLoader.item - onColorSet: { + onColorSet: { sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } @@ -320,9 +320,9 @@ Rectangle { property: "a" value: model.data[7] / 255.0 } - Connections { + Connections { target: diffuseLoader.item - onColorSet: { + onColorSet: { sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } @@ -377,9 +377,9 @@ Rectangle { property: "a" value: model.data[11] / 255.0 } - Connections { + Connections { target: specularLoader.item - onColorSet: { + onColorSet: { sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } @@ -432,9 +432,9 @@ Rectangle { property: "a" value: model.data[15] / 255.0 } - Connections { + Connections { target: emissiveLoader.item - onColorSet: { + onColorSet: { sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } From 454e17cf906193b99fcd9a2ea920739383b50854 Mon Sep 17 00:00:00 2001 From: youhy Date: Mon, 8 Aug 2022 09:21:48 -0700 Subject: [PATCH 10/15] update to new gzcolor Signed-off-by: youhy --- src/gui/plugins/component_inspector/Light.qml | 132 ++++++------------ 1 file changed, 40 insertions(+), 92 deletions(-) diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index 56f0aee6f1..51fb23ef73 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -40,16 +40,16 @@ Rectangle { property int iconHeight: 20 // Loaded item for specular RGBA - property double rSpecularItem: specularLoader.item.r - property double gSpecularItem: specularLoader.item.g - property double bSpecularItem: specularLoader.item.b - property double aSpecularItem: specularLoader.item.a + property double rSpecularValue: model.data[0] + property double gSpecularValue: model.data[1] + property double bSpecularValue: model.data[2] + property double aSpecularValue: model.data[3] // Loaded item for diffuse red - property double rDiffuseItem: diffuseLoader.item.r - property double gDiffuseItem: diffuseLoader.item.g - property double bDiffuseItem: diffuseLoader.item.b - property double aDiffuseItem: diffuseLoader.item.a + property double rDiffuseValue: model.data[4] + property double gDiffuseValue: model.data[5] + property double bDiffuseValue: model.data[6] + property double aDiffuseValue: model.data[7] // Loaded item for attenuation range property var attRangeItem: {} @@ -97,14 +97,14 @@ Rectangle { function sendLight() { // TODO(anyone) There's a loss of precision when these values get to C++ componentInspector.onLight( - 1.0 * rSpecularItem / 255.0, - 1.0 * gSpecularItem / 255.0, - 1.0 * bSpecularItem / 255.0, - aSpecularItem, - 1.0 * rDiffuseItem / 255.0, - 1.0 * gDiffuseItem / 255.0, - 1.0 * bDiffuseItem / 255.0, - aDiffuseItem, + rSpecularValue, + gSpecularValue, + bSpecularValue, + aSpecularValue, + rDiffuseValue, + gDiffuseValue, + bDiffuseValue, + aDiffuseValue, attRangeItem.value, attLinearItem.value, attConstantItem.value, @@ -147,14 +147,6 @@ Rectangle { } } - Component { - id: colorMaterial - GzColor { - id: gzcolor - onColorSet: sendLight() - } - } - Component { id: ignSwitch Switch { @@ -383,40 +375,18 @@ Rectangle { } // Specular - Item { - Layout.fillWidth: true - Layout.bottomMargin: 10 - height: 40 - Loader { - id: specularLoader - anchors.fill: parent - sourceComponent: colorMaterial - } - Binding { - target: specularLoader.item - property: "r" - value: model.data[0] * 255 - } - Binding { - target: specularLoader.item - property: "g" - value: model.data[1] * 255 - } - Binding { - target: specularLoader.item - property: "b" - value: model.data[2] * 255 - } - Binding { - target: specularLoader.item - property: "a" - value: model.data[3] - } - Connections { - target: specularLoader.item - onColorSet: { - sendLight() - } + GzColor { + id: gzColorSpecular + r: model.data[0] + g: model.data[1] + b: model.data[2] + a: model.data[3] + onGzColorSet: { + rSpecularValue = r + gSpecularValue = g + bSpecularValue = b + aSpecularValue = a + sendLight() } } @@ -438,40 +408,18 @@ Rectangle { } // Diffuse - Item { - Layout.fillWidth: true - Layout.bottomMargin: 10 - height: 40 - Loader { - id: diffuseLoader - anchors.fill: parent - sourceComponent: colorMaterial - } - Binding { - target: diffuseLoader.item - property: "r" - value: model.data[4] * 255 - } - Binding { - target: diffuseLoader.item - property: "g" - value: model.data[5] * 255 - } - Binding { - target: diffuseLoader.item - property: "b" - value: model.data[6] * 255 - } - Binding { - target: diffuseLoader.item - property: "a" - value: model.data[7] - } - Connections { - target: diffuseLoader.item - onColorSet: { - sendLight() - } + GzColor { + id: gzColorDiffuse + r: model.data[4] + g: model.data[5] + b: model.data[6] + a: model.data[7] + onGzColorSet: { + rDiffuseValue = r + gDiffuseValue = g + bDiffuseValue = b + aDiffuseValue = a + sendLight() } } } From 34dd66fb4a7dd136ed584ee9af5e718cfcb43c6b Mon Sep 17 00:00:00 2001 From: youhy Date: Mon, 8 Aug 2022 13:29:39 -0700 Subject: [PATCH 11/15] update material.qml to the new common widget color Signed-off-by: youhy --- .../component_inspector/ComponentInspector.cc | 44 +++--- .../plugins/component_inspector/Material.qml | 130 +++++++++--------- 2 files changed, 86 insertions(+), 88 deletions(-) diff --git a/src/gui/plugins/component_inspector/ComponentInspector.cc b/src/gui/plugins/component_inspector/ComponentInspector.cc index 4185b826fb..e7a2fac751 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.cc +++ b/src/gui/plugins/component_inspector/ComponentInspector.cc @@ -318,22 +318,22 @@ void ignition::gazebo::setData(QStandardItem *_item, _item->setData(QString("Material"), ComponentsModel::RoleNames().key("dataType")); _item->setData(QList({ - QVariant(_data.Ambient().R() * 255), - QVariant(_data.Ambient().G() * 255), - QVariant(_data.Ambient().B() * 255), - QVariant(_data.Ambient().A() * 255), - QVariant(_data.Diffuse().R() * 255), - QVariant(_data.Diffuse().G() * 255), - QVariant(_data.Diffuse().B() * 255), - QVariant(_data.Diffuse().A() * 255), - QVariant(_data.Specular().R() * 255), - QVariant(_data.Specular().G() * 255), - QVariant(_data.Specular().B() * 255), - QVariant(_data.Specular().A() * 255), - QVariant(_data.Emissive().R() * 255), - QVariant(_data.Emissive().G() * 255), - QVariant(_data.Emissive().B() * 255), - QVariant(_data.Emissive().A() * 255) + QVariant(_data.Ambient().R()), + QVariant(_data.Ambient().G()), + QVariant(_data.Ambient().B()), + QVariant(_data.Ambient().A()), + QVariant(_data.Diffuse().R()), + QVariant(_data.Diffuse().G()), + QVariant(_data.Diffuse().B()), + QVariant(_data.Diffuse().A()), + QVariant(_data.Specular().R()), + QVariant(_data.Specular().G()), + QVariant(_data.Specular().B()), + QVariant(_data.Specular().A()), + QVariant(_data.Emissive().R()), + QVariant(_data.Emissive().G()), + QVariant(_data.Emissive().B()), + QVariant(_data.Emissive().A()) }), ComponentsModel::RoleNames().key("data")); // TODO(anyone) Only shows colors of material, @@ -1189,17 +1189,13 @@ void ComponentInspector::OnMaterialColor( req.set_id(this->dataPtr->entity); msgs::Set(req.mutable_material()->mutable_ambient(), - math::Color(_rAmbient / 255.0, _gAmbient / 255.0, - _bAmbient / 255.0, _aAmbient / 255.0)); + math::Color(_rAmbient, _gAmbient,_bAmbient, _aAmbient)); msgs::Set(req.mutable_material()->mutable_diffuse(), - math::Color(_rDiffuse / 255.0, _gDiffuse / 255.0, - _bDiffuse / 255.0, _aDiffuse / 255.0)); + math::Color(_rDiffuse, _gDiffuse,_bDiffuse, _aDiffuse)); msgs::Set(req.mutable_material()->mutable_specular(), - math::Color(_rSpecular / 255.0, _gSpecular / 255.0, - _bSpecular / 255.0, _aSpecular / 255.0)); + math::Color(_rSpecular, _gSpecular, _bSpecular, _aSpecular)); msgs::Set(req.mutable_material()->mutable_emissive(), - math::Color(_rEmissive / 255.0, _gEmissive / 255.0, - _bEmissive / 255.0, _aEmissive / 255.0)); + math::Color(_rEmissive, _gEmissive,_bEmissive, _aEmissive)); auto materialCmdService = "/world/" + this->dataPtr->worldName + "/visual_config"; diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index 633703031f..23ab81455d 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -40,48 +40,52 @@ Rectangle { property int iconHeight: 20 // Loaded items for ambient red, green, blue, alpha - property double rAmbientItem: ambientLoader.item.r - property double gAmbientItem: ambientLoader.item.g - property double bAmbientItem: ambientLoader.item.b - property double aAmbientItem: ambientLoader.item.a + property double rAmbientItem: model.data[0] + property double gAmbientItem: model.data[1] + property double bAmbientItem: model.data[2] + property double aAmbientItem: model.data[3] // Loaded items for diffuse red, green, blue, alpha - property double rDiffuseItem: diffuseLoader.item.r - property double gDiffuseItem: diffuseLoader.item.g - property double bDiffuseItem: diffuseLoader.item.b - property double aDiffuseItem: diffuseLoader.item.a + property double rDiffuseItem: model.data[4] + property double gDiffuseItem: model.data[5] + property double bDiffuseItem: model.data[6] + property double aDiffuseItem: model.data[7] // Loaded items for specular red, green, blue, alpha - property double rSpecularItem: specularLoader.item.r - property double gSpecularItem: specularLoader.item.g - property double bSpecularItem: specularLoader.item.b - property double aSpecularItem: specularLoader.item.a + property double rSpecularItem: model.data[8] + property double gSpecularItem: model.data[9] + property double bSpecularItem: model.data[10] + property double aSpecularItem: model.data[11] // Loaded items for emissive red, green, blue, alpha - property double rEmissiveItem: emissiveLoader.item.r - property double gEmissiveItem: emissiveLoader.item.g - property double bEmissiveItem: emissiveLoader.item.b - property double aEmissiveItem: emissiveLoader.item.a + property double rEmissiveItem: model.data[12] + property double gEmissiveItem: model.data[13] + property double bEmissiveItem: model.data[14] + property double aEmissiveItem: model.data[15] // send new material color data to C++ function sendMaterialColor(_type, _currColor) { + // console.log(rAmbientItem, + // gAmbientItem, + // bAmbientItem, + // aAmbientItem, + // rDiffuseItem, + // gDiffuseItem, + // bDiffuseItem, + // aDiffuseItem, + // rSpecularItem, + // gSpecularItem, + // bSpecularItem, + // aSpecularItem, + // rEmissiveItem, + // gEmissiveItem, + // bEmissiveItem, + // aEmissiveItem) componentInspector.onMaterialColor( - rAmbientItem, - gAmbientItem, - bAmbientItem, - 1.0 * aAmbientItem * 255.0, - rDiffuseItem, - gDiffuseItem, - bDiffuseItem, - 1.0 * aDiffuseItem * 255.0, - rSpecularItem, - gSpecularItem, - bSpecularItem, - 1.0 * aSpecularItem * 255.0, - rEmissiveItem, - gEmissiveItem, - bEmissiveItem, - 1.0 * aEmissiveItem * 255.0, + rAmbientItem, gAmbientItem, bAmbientItem, aAmbientItem, + rDiffuseItem, gDiffuseItem, bDiffuseItem, aDiffuseItem, + rSpecularItem, gSpecularItem, bSpecularItem, aSpecularItem, + rEmissiveItem, gEmissiveItem, bEmissiveItem, aEmissiveItem, _type, _currColor ); @@ -114,30 +118,12 @@ Rectangle { font.family: "Roboto" } - // Used to create rgba spin boxes Component { - id: spinBoxMaterialColor - IgnSpinBox { - id: writableSpin - value: writableSpin.activeFocus ? writableSpin.value : numberValue - minimumValue: 0 - maximumValue: 255 - decimals: 0 - onEditingFinished: { - // sending empty params to not open color dialog - sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) - } + id: gzcolor + GzColor { } } - Component { - id: colorMaterial - GzColor { - id: gzcolor - onColorSet: sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) - } - } - Column { anchors.fill: parent @@ -243,7 +229,7 @@ Rectangle { Loader { id: ambientLoader anchors.fill: parent - sourceComponent: colorMaterial + sourceComponent: gzcolor } Binding { target: ambientLoader.item @@ -263,11 +249,15 @@ Rectangle { Binding { target: ambientLoader.item property: "a" - value: model.data[3] / 255.0 + value: model.data[3] } Connections { target: ambientLoader.item - onColorSet: { + onGzColorSet: { + rAmbientItem = ambientLoader.item.r + gAmbientItem = ambientLoader.item.g + bAmbientItem = ambientLoader.item.b + aAmbientItem = ambientLoader.item.a sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } @@ -298,7 +288,7 @@ Rectangle { Loader { id: diffuseLoader anchors.fill: parent - sourceComponent: colorMaterial + sourceComponent: gzcolor } Binding { target: diffuseLoader.item @@ -318,11 +308,15 @@ Rectangle { Binding { target: diffuseLoader.item property: "a" - value: model.data[7] / 255.0 + value: model.data[7] } Connections { target: diffuseLoader.item - onColorSet: { + onGzColorSet: { + rDiffuseItem = diffuseLoader.item.r + gDiffuseItem = diffuseLoader.item.g + bDiffuseItem = diffuseLoader.item.b + aDiffuseItem = diffuseLoader.item.a sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } @@ -355,7 +349,7 @@ Rectangle { Loader { id: specularLoader anchors.fill: parent - sourceComponent: colorMaterial + sourceComponent: gzcolor } Binding { target: specularLoader.item @@ -375,11 +369,15 @@ Rectangle { Binding { target: specularLoader.item property: "a" - value: model.data[11] / 255.0 + value: model.data[11] } Connections { target: specularLoader.item - onColorSet: { + onGzColorSet: { + rSpecularItem = specularLoader.item.r + gSpecularItem = specularLoader.item.g + bSpecularItem = specularLoader.item.b + aSpecularItem = specularLoader.item.a sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } @@ -410,7 +408,7 @@ Rectangle { Loader { id: emissiveLoader anchors.fill: parent - sourceComponent: colorMaterial + sourceComponent: gzcolor } Binding { target: emissiveLoader.item @@ -430,11 +428,15 @@ Rectangle { Binding { target: emissiveLoader.item property: "a" - value: model.data[15] / 255.0 + value: model.data[15] } Connections { target: emissiveLoader.item - onColorSet: { + onGzColorSet: { + rEmissiveItem = emissiveLoader.item.r + gEmissiveItem = emissiveLoader.item.g + bEmissiveItem = emissiveLoader.item.b + aEmissiveItem = emissiveLoader.item.a sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) } } From 86fdeecd60f53cf2c3c69d2116e8d9fb0ac72b4b Mon Sep 17 00:00:00 2001 From: Jenn Nguyen Date: Thu, 11 Aug 2022 09:52:38 -0700 Subject: [PATCH 12/15] removed unneeded code Signed-off-by: Jenn Nguyen --- .../component_inspector/ComponentInspector.cc | 50 +------------------ .../plugins/component_inspector/Material.qml | 13 +++-- 2 files changed, 7 insertions(+), 56 deletions(-) diff --git a/src/gui/plugins/component_inspector/ComponentInspector.cc b/src/gui/plugins/component_inspector/ComponentInspector.cc index e7a2fac751..d5ad91efaf 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.cc +++ b/src/gui/plugins/component_inspector/ComponentInspector.cc @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include @@ -1128,55 +1127,8 @@ void ComponentInspector::OnMaterialColor( double _rDiffuse, double _gDiffuse, double _bDiffuse, double _aDiffuse, double _rSpecular, double _gSpecular, double _bSpecular, double _aSpecular, double _rEmissive, double _gEmissive, double _bEmissive, double _aEmissive, - QString _type, QColor _currColor) + QString /*_type*/, QColor /*_currColor*/) { - // when type is not empty, open qt color dialog - std::string type = _type.toStdString(); - if (!type.empty()) - { - QColor newColor = QColorDialog::getColor( - _currColor, nullptr, "Pick a color", - {QColorDialog::DontUseNativeDialog, QColorDialog::ShowAlphaChannel}); - - // returns if the user hits cancel - if (!newColor.isValid()) - return; - - if (type == "ambient") - { - _rAmbient = newColor.red(); - _gAmbient = newColor.green(); - _bAmbient = newColor.blue(); - _aAmbient = newColor.alpha(); - } - else if (type == "diffuse") - { - _rDiffuse = newColor.red(); - _gDiffuse = newColor.green(); - _bDiffuse = newColor.blue(); - _aDiffuse = newColor.alpha(); - } - else if (type == "specular") - { - _rSpecular = newColor.red(); - _gSpecular = newColor.green(); - _bSpecular = newColor.blue(); - _aSpecular = newColor.alpha(); - } - else if (type == "emissive") - { - _rEmissive = newColor.red(); - _gEmissive = newColor.green(); - _bEmissive = newColor.blue(); - _aEmissive = newColor.alpha(); - } - else - { - ignerr << "Invalid material type: " << type << std::endl; - return; - } - } - std::function cb = [](const ignition::msgs::Boolean &/*_rep*/, const bool _result) { diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index 23ab81455d..0363d4ff8c 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -64,7 +64,7 @@ Rectangle { property double aEmissiveItem: model.data[15] // send new material color data to C++ - function sendMaterialColor(_type, _currColor) { + function sendMaterialColor() { // console.log(rAmbientItem, // gAmbientItem, // bAmbientItem, @@ -86,8 +86,7 @@ Rectangle { rDiffuseItem, gDiffuseItem, bDiffuseItem, aDiffuseItem, rSpecularItem, gSpecularItem, bSpecularItem, aSpecularItem, rEmissiveItem, gEmissiveItem, bEmissiveItem, aEmissiveItem, - _type, - _currColor + "", Qt.rgba(0, 0, 0, 0) // dummy placeholders (no longer needed) ); } @@ -258,7 +257,7 @@ Rectangle { gAmbientItem = ambientLoader.item.g bAmbientItem = ambientLoader.item.b aAmbientItem = ambientLoader.item.a - sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) + sendMaterialColor() } } } @@ -317,7 +316,7 @@ Rectangle { gDiffuseItem = diffuseLoader.item.g bDiffuseItem = diffuseLoader.item.b aDiffuseItem = diffuseLoader.item.a - sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) + sendMaterialColor() } } } @@ -378,7 +377,7 @@ Rectangle { gSpecularItem = specularLoader.item.g bSpecularItem = specularLoader.item.b aSpecularItem = specularLoader.item.a - sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) + sendMaterialColor() } } } @@ -437,7 +436,7 @@ Rectangle { gEmissiveItem = emissiveLoader.item.g bEmissiveItem = emissiveLoader.item.b aEmissiveItem = emissiveLoader.item.a - sendMaterialColor("", Qt.rgba(0, 0, 0, 0)) + sendMaterialColor() } } } From c27b76e79723be2fb36e580e8f944358293c07db Mon Sep 17 00:00:00 2001 From: Jenn Nguyen Date: Thu, 11 Aug 2022 10:02:24 -0700 Subject: [PATCH 13/15] codecheck Signed-off-by: Jenn Nguyen --- .../component_inspector/ComponentInspector.cc | 6 +++--- src/gui/plugins/component_inspector/Material.qml | 16 ---------------- 2 files changed, 3 insertions(+), 19 deletions(-) diff --git a/src/gui/plugins/component_inspector/ComponentInspector.cc b/src/gui/plugins/component_inspector/ComponentInspector.cc index d5ad91efaf..d235fce439 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.cc +++ b/src/gui/plugins/component_inspector/ComponentInspector.cc @@ -1141,13 +1141,13 @@ void ComponentInspector::OnMaterialColor( req.set_id(this->dataPtr->entity); msgs::Set(req.mutable_material()->mutable_ambient(), - math::Color(_rAmbient, _gAmbient,_bAmbient, _aAmbient)); + math::Color(_rAmbient, _gAmbient, _bAmbient, _aAmbient)); msgs::Set(req.mutable_material()->mutable_diffuse(), - math::Color(_rDiffuse, _gDiffuse,_bDiffuse, _aDiffuse)); + math::Color(_rDiffuse, _gDiffuse, _bDiffuse, _aDiffuse)); msgs::Set(req.mutable_material()->mutable_specular(), math::Color(_rSpecular, _gSpecular, _bSpecular, _aSpecular)); msgs::Set(req.mutable_material()->mutable_emissive(), - math::Color(_rEmissive, _gEmissive,_bEmissive, _aEmissive)); + math::Color(_rEmissive, _gEmissive, _bEmissive, _aEmissive)); auto materialCmdService = "/world/" + this->dataPtr->worldName + "/visual_config"; diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index 0363d4ff8c..a2d86192a9 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -65,22 +65,6 @@ Rectangle { // send new material color data to C++ function sendMaterialColor() { - // console.log(rAmbientItem, - // gAmbientItem, - // bAmbientItem, - // aAmbientItem, - // rDiffuseItem, - // gDiffuseItem, - // bDiffuseItem, - // aDiffuseItem, - // rSpecularItem, - // gSpecularItem, - // bSpecularItem, - // aSpecularItem, - // rEmissiveItem, - // gEmissiveItem, - // bEmissiveItem, - // aEmissiveItem) componentInspector.onMaterialColor( rAmbientItem, gAmbientItem, bAmbientItem, aAmbientItem, rDiffuseItem, gDiffuseItem, bDiffuseItem, aDiffuseItem, From 84d202d8a52e8d5dab10dee3479064ad29961b76 Mon Sep 17 00:00:00 2001 From: youhy Date: Thu, 11 Aug 2022 14:24:22 -0700 Subject: [PATCH 14/15] slightly adjust format Signed-off-by: youhy --- src/gui/plugins/component_inspector/Light.qml | 6 ++++-- src/gui/plugins/component_inspector/Material.qml | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index 51fb23ef73..92cd24f3ba 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -131,7 +131,6 @@ Rectangle { /** * Used to create a spin box */ - // TODO remove this Component { id: sliderZeroOne Slider { @@ -350,7 +349,7 @@ Rectangle { // Color Text { Layout.columnSpan: 6 - text: "Color" + text: " Color" color: "dimgrey" font.bold: true } @@ -426,10 +425,13 @@ Rectangle { RowLayout { Text { + Layout.topMargin: 10 + Layout.bottomMargin: 10 Layout.columnSpan: 6 text: " Attenuation" color: "dimgrey" width: margin + indentation + font.bold: true } } RowLayout { diff --git a/src/gui/plugins/component_inspector/Material.qml b/src/gui/plugins/component_inspector/Material.qml index a2d86192a9..5f281b0585 100644 --- a/src/gui/plugins/component_inspector/Material.qml +++ b/src/gui/plugins/component_inspector/Material.qml @@ -179,8 +179,9 @@ Rectangle { RowLayout { // Color Text { + Layout.topMargin: 10 Layout.columnSpan: 6 - text: "Color" + text: " Color" color: "dimgrey" font.bold: true } From 7b52abffa5bfc5bc8ad6ccb3fdb8e8f3b6b234bf Mon Sep 17 00:00:00 2001 From: youhy Date: Tue, 16 Aug 2022 13:10:36 -0700 Subject: [PATCH 15/15] add spacing on the left Signed-off-by: youhy --- src/gui/plugins/component_inspector/Light.qml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index bcb6ec5f06..f58211db50 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -209,7 +209,8 @@ Rectangle { Rectangle { id: content property bool show: false - width: parent.width + x: 10 + width: parent.width - 10 height: show ? grid.height : 0 clip: true color: "transparent" @@ -589,6 +590,7 @@ Rectangle { text: " Direction" color: "dimgrey" width: margin + indentation + font.bold: true } } RowLayout { @@ -712,6 +714,7 @@ Rectangle { text: " Spot features" color: "dimgrey" width: margin + indentation + font.bold: true } } RowLayout {