From 3b85f5768478debda745f576c471c7dc5770dc03 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Wed, 16 Feb 2022 09:37:03 +0100 Subject: [PATCH 1/7] Allow to turn on/off lights Signed-off-by: ahcorde --- src/Conversions.cc | 27 +++++++++++ .../component_inspector/ComponentInspector.cc | 29 +++++++++++- .../component_inspector/ComponentInspector.hh | 2 +- .../ComponentInspector.qml | 6 ++- src/gui/plugins/component_inspector/Light.qml | 45 ++++++++++++++++++- src/rendering/RenderUtil.cc | 34 ++++++++++++-- src/systems/user_commands/UserCommands.cc | 21 +++++++++ 7 files changed, 154 insertions(+), 10 deletions(-) diff --git a/src/Conversions.cc b/src/Conversions.cc index a71ef0aafb..a2709d6527 100644 --- a/src/Conversions.cc +++ b/src/Conversions.cc @@ -568,6 +568,14 @@ msgs::Light ignition::gazebo::convert(const sdf::Light &_in) out.set_spot_inner_angle(_in.SpotInnerAngle().Radian()); out.set_spot_outer_angle(_in.SpotOuterAngle().Radian()); out.set_spot_falloff(_in.SpotFalloff()); + + // todo(anyone) Use the field isLightOn in light.proto from + // Garden on. + auto header = out.mutable_header()->add_data(); + header->set_key("isLightOn"); + std::string *value = header->add_value(); + *value = std::to_string(_in.LightOn()); + if (_in.Type() == sdf::LightType::POINT) out.set_type(msgs::Light_LightType_POINT); else if (_in.Type() == sdf::LightType::SPOT) @@ -597,6 +605,25 @@ sdf::Light ignition::gazebo::convert(const msgs::Light &_in) out.SetSpotInnerAngle(math::Angle(_in.spot_inner_angle())); out.SetSpotOuterAngle(math::Angle(_in.spot_outer_angle())); out.SetSpotFalloff(_in.spot_falloff()); + + // todo(anyone) Use the field isLightOn in light.proto from + // Garden on. + bool isLightOn = true; + for (int i = 0; i < _in.header().data_size(); ++i) + { + for (int j = 0; + j < _in.header().data(i).value_size(); ++j) + { + if (_in.header().data(i).key() == + "isLightOn") + { + isLightOn = ignition::math::parseInt( + _in.header().data(i).value(0)); + } + } + } + out.SetLightOn(isLightOn); + if (_in.type() == msgs::Light_LightType_POINT) out.SetType(sdf::LightType::POINT); else if (_in.type() == msgs::Light_LightType_SPOT) diff --git a/src/gui/plugins/component_inspector/ComponentInspector.cc b/src/gui/plugins/component_inspector/ComponentInspector.cc index f2c31ec06f..2ebf5f68e5 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.cc +++ b/src/gui/plugins/component_inspector/ComponentInspector.cc @@ -153,6 +153,21 @@ void ignition::gazebo::setData(QStandardItem *_item, const msgs::Light &_data) lightType = 2; } + bool isLightOn = true; + for (int i = 0; i < _data.header().data_size(); ++i) + { + for (int j = 0; + j < _data.header().data(i).value_size(); ++j) + { + if (_data.header().data(i).key() == + "isLightOn") + { + isLightOn = ignition::math::parseInt( + _data.header().data(i).value(0)); + } + } + } + _item->setData(QString("Light"), ComponentsModel::RoleNames().key("dataType")); _item->setData(QList({ @@ -176,7 +191,8 @@ void ignition::gazebo::setData(QStandardItem *_item, const msgs::Light &_data) QVariant(_data.spot_outer_angle()), QVariant(_data.spot_falloff()), QVariant(_data.intensity()), - QVariant(lightType) + QVariant(lightType), + QVariant(isLightOn) }), ComponentsModel::RoleNames().key("data")); } @@ -989,7 +1005,8 @@ void ComponentInspector::OnLight( double _attRange, double _attLinear, double _attConstant, double _attQuadratic, bool _castShadows, double _directionX, double _directionY, double _directionZ, double _innerAngle, - double _outerAngle, double _falloff, double _intensity, int _type) + double _outerAngle, double _falloff, double _intensity, int _type, + bool _isLightOn) { std::function cb = [](const ignition::msgs::Boolean &/*_rep*/, const bool _result) @@ -999,6 +1016,14 @@ void ComponentInspector::OnLight( }; ignition::msgs::Light req; + + // todo(anyone) Use the field isLightOn in light.proto from + // Garden on. + auto header = req.mutable_header()->add_data(); + header->set_key("isLightOn"); + std::string *value = header->add_value(); + *value = std::to_string(_isLightOn); + req.set_name(this->dataPtr->entityName); req.set_id(this->dataPtr->entity); ignition::msgs::Set(req.mutable_diffuse(), diff --git a/src/gui/plugins/component_inspector/ComponentInspector.hh b/src/gui/plugins/component_inspector/ComponentInspector.hh index 9229a24188..4a166b1baf 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.hh +++ b/src/gui/plugins/component_inspector/ComponentInspector.hh @@ -259,7 +259,7 @@ namespace gazebo double _attLinear, double _attConstant, double _attQuadratic, bool _castShadows, double _directionX, double _directionY, double _directionZ, double _innerAngle, double _outerAngle, - double _falloff, double _intensity, int _type); + double _falloff, double _intensity, int _type, bool _isLightOn); /// \brief Callback in Qt thread when physics' properties change. /// \param[in] _stepSize step size diff --git a/src/gui/plugins/component_inspector/ComponentInspector.qml b/src/gui/plugins/component_inspector/ComponentInspector.qml index 545e46d538..c9f68bd1e4 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.qml +++ b/src/gui/plugins/component_inspector/ComponentInspector.qml @@ -101,12 +101,14 @@ Rectangle { _rDiffuse, _gDiffuse, _bDiffuse, _aDiffuse, _attRange, _attLinear, _attConstant, _attQuadratic, _castShadows, _directionX, _directionY, _directionZ, - _innerAngle, _outerAngle, _falloff, _intensity, _type) { + _innerAngle, _outerAngle, _falloff, _intensity, _type, + _isLightOn) { ComponentInspector.OnLight(_rSpecular, _gSpecular, _bSpecular, _aSpecular, _rDiffuse, _gDiffuse, _bDiffuse, _aDiffuse, _attRange, _attLinear, _attConstant, _attQuadratic, _castShadows, _directionX, _directionY, _directionZ, - _innerAngle, _outerAngle, _falloff, _intensity, _type) + _innerAngle, _outerAngle, _falloff, _intensity, _type, + _isLightOn) } /* diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index 98cf143e82..9fc209ac61 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -99,6 +99,9 @@ Rectangle { // Loaded item for intensity property var intensityItem: {} + // Loaded item for isLightOn + property var isLightOnItem: {} + // Send new light data to C++ function sendLight() { // TODO(anyone) There's a loss of precision when these values get to C++ @@ -123,7 +126,8 @@ Rectangle { outerAngleItem.value, falloffItem.value, intensityItem.value, - model.data[20] + model.data[20], + isLightOnItem.checked ); } @@ -285,6 +289,45 @@ Rectangle { id: grid width: parent.width + RowLayout { + Rectangle { + color: "transparent" + height: 40 + Layout.preferredWidth: isOnText.width + indentation*3 + Loader { + id: isLightOn + width: iconWidth + height: iconHeight + y:10 + sourceComponent: plotIcon + } + Component.onCompleted: isLightOn.item.componentInfo = "is light on ?" + + Text { + id : isOnText + text: ' Turn on/off' + leftPadding: 5 + color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" + font.pointSize: 12 + anchors.centerIn: parent + } + } + Item { + Layout.fillWidth: true + height: 40 + + Loader { + id: inOnLoader + anchors.fill: parent + property double numberValue: model.data[21] + sourceComponent: ignSwitch + onLoaded: { + isLightOnItem = inOnLoader.item + } + } + } + } + RowLayout { Rectangle { color: "transparent" diff --git a/src/rendering/RenderUtil.cc b/src/rendering/RenderUtil.cc index 35c347cd33..cef69cfbc3 100644 --- a/src/rendering/RenderUtil.cc +++ b/src/rendering/RenderUtil.cc @@ -2131,11 +2131,37 @@ void RenderUtilPrivate::UpdateLights( auto l = std::dynamic_pointer_cast(node); if (l) { - if (!ignition::math::equal( - l->Intensity(), - static_cast(light.second.intensity()))) + // todo(anyone) Use the field isLightOn in light.proto from + // Garden on. + bool isLightOn = true; + for (int i = 0; i < light.second.header().data_size(); ++i) + { + for (int j = 0; + j < light.second.header().data(i).value_size(); ++j) + { + if (light.second.header().data(i).key() == + "isLightOn") + { + isLightOn = ignition::math::parseInt( + light.second.header().data(i).value(0)); + } + } + } + + // const auto lightOnOff = _entityLightsOn.at(light.first); + + if (isLightOn) + { + if (!ignition::math::equal( + l->Intensity(), + static_cast(light.second.intensity()))) + { + l->SetIntensity(light.second.intensity()); + } + } + else { - l->SetIntensity(light.second.intensity()); + l->SetIntensity(0); } if (light.second.has_diffuse()) { diff --git a/src/systems/user_commands/UserCommands.cc b/src/systems/user_commands/UserCommands.cc index 079245773c..65e4d5f334 100644 --- a/src/systems/user_commands/UserCommands.cc +++ b/src/systems/user_commands/UserCommands.cc @@ -159,7 +159,28 @@ class LightCommand : public UserCommandBase public: std::function lightEql { [](const msgs::Light &_a, const msgs::Light &_b) { + // todo(anyone) Use the field isLightOn in light.proto from + // Garden on. + auto getIsLightOn = [](const msgs::Light &_light) -> bool + { + bool isLightOn = true; + for (int i = 0; i < _light.header().data_size(); ++i) + { + for (int j = 0; + j < _light.header().data(i).value_size(); ++j) + { + if (_light.header().data(i).key() == + "isLightOn") + { + isLightOn = ignition::math::parseInt( + _light.header().data(i).value(0)); + } + } + } + return isLightOn; + }; return + getIsLightOn(_a) == getIsLightOn(_b) && _a.type() == _b.type() && _a.name() == _b.name() && math::equal( From 56b6b55cf136852ec782ff65aeb99766bebf28eb Mon Sep 17 00:00:00 2001 From: ahcorde Date: Wed, 16 Feb 2022 18:26:11 +0100 Subject: [PATCH 2/7] feedback Signed-off-by: ahcorde --- src/gui/plugins/component_inspector/Light.qml | 7 ------- src/rendering/RenderUtil.cc | 2 -- 2 files changed, 9 deletions(-) diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index 9fc209ac61..6b3969dc72 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -294,13 +294,6 @@ Rectangle { color: "transparent" height: 40 Layout.preferredWidth: isOnText.width + indentation*3 - Loader { - id: isLightOn - width: iconWidth - height: iconHeight - y:10 - sourceComponent: plotIcon - } Component.onCompleted: isLightOn.item.componentInfo = "is light on ?" Text { diff --git a/src/rendering/RenderUtil.cc b/src/rendering/RenderUtil.cc index cef69cfbc3..d822ab4217 100644 --- a/src/rendering/RenderUtil.cc +++ b/src/rendering/RenderUtil.cc @@ -2148,8 +2148,6 @@ void RenderUtilPrivate::UpdateLights( } } - // const auto lightOnOff = _entityLightsOn.at(light.first); - if (isLightOn) { if (!ignition::math::equal( From 1ee3ec59262cecdb2bab027965cc2274a8ed3e38 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Thu, 24 Feb 2022 22:20:52 +0100 Subject: [PATCH 3/7] make linters happy Signed-off-by: ahcorde --- src/Conversions.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Conversions.cc b/src/Conversions.cc index a2709d6527..fd85b46df6 100644 --- a/src/Conversions.cc +++ b/src/Conversions.cc @@ -623,7 +623,7 @@ sdf::Light ignition::gazebo::convert(const msgs::Light &_in) } } out.SetLightOn(isLightOn); - + if (_in.type() == msgs::Light_LightType_POINT) out.SetType(sdf::LightType::POINT); else if (_in.type() == msgs::Light_LightType_SPOT) From 08f534a7d6b703ef1709998c439ffaf19d80b785 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Fri, 11 Mar 2022 19:03:25 +0100 Subject: [PATCH 4/7] Toggle Light visuals Signed-off-by: ahcorde --- examples/worlds/lights.sdf | 1 + src/Conversions.cc | 41 +++++++++++++++--- .../component_inspector/ComponentInspector.cc | 43 +++++++++++++++---- .../component_inspector/ComponentInspector.hh | 5 ++- .../ComponentInspector.qml | 4 +- src/gui/plugins/component_inspector/Light.qml | 37 +++++++++++++++- src/rendering/RenderUtil.cc | 24 +++++++++++ src/rendering/SceneManager.cc | 3 ++ src/systems/user_commands/UserCommands.cc | 22 ++++++++++ 9 files changed, 161 insertions(+), 19 deletions(-) diff --git a/examples/worlds/lights.sdf b/examples/worlds/lights.sdf index f1910f0ac7..61d2d92fd1 100644 --- a/examples/worlds/lights.sdf +++ b/examples/worlds/lights.sdf @@ -52,6 +52,7 @@ 0.01 false + false diff --git a/src/Conversions.cc b/src/Conversions.cc index fd85b46df6..33da669453 100644 --- a/src/Conversions.cc +++ b/src/Conversions.cc @@ -569,12 +569,23 @@ msgs::Light ignition::gazebo::convert(const sdf::Light &_in) out.set_spot_outer_angle(_in.SpotOuterAngle().Radian()); out.set_spot_falloff(_in.SpotFalloff()); - // todo(anyone) Use the field isLightOn in light.proto from - // Garden on. - auto header = out.mutable_header()->add_data(); - header->set_key("isLightOn"); - std::string *value = header->add_value(); - *value = std::to_string(_in.LightOn()); + { + // todo(anyone) Use the field isLightOn in light.proto from + // Garden on. + auto header = out.mutable_header()->add_data(); + header->set_key("isLightOn"); + std::string *value = header->add_value(); + *value = std::to_string(_in.LightOn()); + } + + { + // todo(anyone) Use the field visualize_visual in light.proto from + // Garden on. + auto header = out.mutable_header()->add_data(); + header->set_key("visualizeVisual"); + std::string *value = header->add_value(); + *value = std::to_string(_in.Visualize()); + } if (_in.Type() == sdf::LightType::POINT) out.set_type(msgs::Light_LightType_POINT); @@ -606,6 +617,24 @@ sdf::Light ignition::gazebo::convert(const msgs::Light &_in) out.SetSpotOuterAngle(math::Angle(_in.spot_outer_angle())); out.SetSpotFalloff(_in.spot_falloff()); + // todo(anyone) Use the field isLightOn in light.proto from + // Garden on. + bool visualizeVisual = true; + for (int i = 0; i < _in.header().data_size(); ++i) + { + for (int j = 0; + j < _in.header().data(i).value_size(); ++j) + { + if (_in.header().data(i).key() == + "visualizeVisual") + { + visualizeVisual = ignition::math::parseInt( + _in.header().data(i).value(0)); + } + } + } + out.SetVisualize(visualizeVisual); + // todo(anyone) Use the field isLightOn in light.proto from // Garden on. bool isLightOn = true; diff --git a/src/gui/plugins/component_inspector/ComponentInspector.cc b/src/gui/plugins/component_inspector/ComponentInspector.cc index 2ebf5f68e5..c4706062fe 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.cc +++ b/src/gui/plugins/component_inspector/ComponentInspector.cc @@ -153,6 +153,21 @@ void ignition::gazebo::setData(QStandardItem *_item, const msgs::Light &_data) lightType = 2; } + bool visualizeVisual = true; + for (int i = 0; i < _data.header().data_size(); ++i) + { + for (int j = 0; + j < _data.header().data(i).value_size(); ++j) + { + if (_data.header().data(i).key() == + "visualizeVisual") + { + visualizeVisual = ignition::math::parseInt( + _data.header().data(i).value(0)); + } + } + } + bool isLightOn = true; for (int i = 0; i < _data.header().data_size(); ++i) { @@ -192,7 +207,8 @@ void ignition::gazebo::setData(QStandardItem *_item, const msgs::Light &_data) QVariant(_data.spot_falloff()), QVariant(_data.intensity()), QVariant(lightType), - QVariant(isLightOn) + QVariant(isLightOn), + QVariant(visualizeVisual) }), ComponentsModel::RoleNames().key("data")); } @@ -1006,7 +1022,7 @@ void ComponentInspector::OnLight( double _attQuadratic, bool _castShadows, double _directionX, double _directionY, double _directionZ, double _innerAngle, double _outerAngle, double _falloff, double _intensity, int _type, - bool _isLightOn) + bool _isLightOn, bool _visualizeVisual) { std::function cb = [](const ignition::msgs::Boolean &/*_rep*/, const bool _result) @@ -1016,13 +1032,22 @@ void ComponentInspector::OnLight( }; ignition::msgs::Light req; - - // todo(anyone) Use the field isLightOn in light.proto from - // Garden on. - auto header = req.mutable_header()->add_data(); - header->set_key("isLightOn"); - std::string *value = header->add_value(); - *value = std::to_string(_isLightOn); + { + // todo(anyone) Use the field isLightOn in light.proto from + // Garden on. + auto header = req.mutable_header()->add_data(); + header->set_key("isLightOn"); + std::string *value = header->add_value(); + *value = std::to_string(_isLightOn); + } + { + // todo(anyone) Use the field visualize_visual in light.proto from + // Garden on. + auto header = req.mutable_header()->add_data(); + header->set_key("visualizeVisual"); + std::string *value = header->add_value(); + *value = std::to_string(_visualizeVisual); + } req.set_name(this->dataPtr->entityName); req.set_id(this->dataPtr->entity); diff --git a/src/gui/plugins/component_inspector/ComponentInspector.hh b/src/gui/plugins/component_inspector/ComponentInspector.hh index 4a166b1baf..54a6659a70 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.hh +++ b/src/gui/plugins/component_inspector/ComponentInspector.hh @@ -252,6 +252,8 @@ namespace gazebo /// \param[in] _falloff Falloff of the spotlight /// \param[in] _intensity Intensity of the light /// \param[in] _type light type + /// \param[in] _isLightOn is light on + /// \param[in] _visualizeVisual is visual enabled public: Q_INVOKABLE void OnLight( double _rSpecular, double _gSpecular, double _bSpecular, double _aSpecular, double _rDiffuse, double _gDiffuse, @@ -259,7 +261,8 @@ namespace gazebo double _attLinear, double _attConstant, double _attQuadratic, bool _castShadows, double _directionX, double _directionY, double _directionZ, double _innerAngle, double _outerAngle, - double _falloff, double _intensity, int _type, bool _isLightOn); + double _falloff, double _intensity, int _type, bool _isLightOn, + bool _visualizeVisual); /// \brief Callback in Qt thread when physics' properties change. /// \param[in] _stepSize step size diff --git a/src/gui/plugins/component_inspector/ComponentInspector.qml b/src/gui/plugins/component_inspector/ComponentInspector.qml index c9f68bd1e4..9e94025b16 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.qml +++ b/src/gui/plugins/component_inspector/ComponentInspector.qml @@ -102,13 +102,13 @@ Rectangle { _attRange, _attLinear, _attConstant, _attQuadratic, _castShadows, _directionX, _directionY, _directionZ, _innerAngle, _outerAngle, _falloff, _intensity, _type, - _isLightOn) { + _isLightOn, _visualizeVisual) { ComponentInspector.OnLight(_rSpecular, _gSpecular, _bSpecular, _aSpecular, _rDiffuse, _gDiffuse, _bDiffuse, _aDiffuse, _attRange, _attLinear, _attConstant, _attQuadratic, _castShadows, _directionX, _directionY, _directionZ, _innerAngle, _outerAngle, _falloff, _intensity, _type, - _isLightOn) + _isLightOn, _visualizeVisual) } /* diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index 6b3969dc72..a18bc7c0c8 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -102,6 +102,9 @@ Rectangle { // Loaded item for isLightOn property var isLightOnItem: {} + // Loaded item for visualizeVisuals + property var visualizeVisualItem: {} + // Send new light data to C++ function sendLight() { // TODO(anyone) There's a loss of precision when these values get to C++ @@ -127,7 +130,8 @@ Rectangle { falloffItem.value, intensityItem.value, model.data[20], - isLightOnItem.checked + isLightOnItem.checked, + visualizeVisualItem.checked ); } @@ -289,6 +293,37 @@ Rectangle { id: grid width: parent.width + RowLayout { + Rectangle { + color: "transparent" + height: 40 + Layout.preferredWidth: visualizeVisualText.width + indentation*3 + + Text { + id : visualizeVisualText + text: ' Visualize visual enabled' + leftPadding: 5 + color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" + font.pointSize: 12 + anchors.centerIn: parent + } + } + Item { + Layout.fillWidth: true + height: 40 + + Loader { + id: visualizeVisualLoader + anchors.fill: parent + property double numberValue: model.data[22] + sourceComponent: ignSwitch + onLoaded: { + visualizeVisualItem = visualizeVisualLoader.item + } + } + } + } + RowLayout { Rectangle { color: "transparent" diff --git a/src/rendering/RenderUtil.cc b/src/rendering/RenderUtil.cc index d822ab4217..76b4e7f0b1 100644 --- a/src/rendering/RenderUtil.cc +++ b/src/rendering/RenderUtil.cc @@ -279,6 +279,7 @@ class ignition::gazebo::RenderUtilPrivate lightEql { [](const sdf::Light &_a, const sdf::Light &_b) { return + _a.Visualize() == _b.Visualize() && _a.Type() == _b.Type() && _a.Name() == _b.Name() && _a.Diffuse() == _b.Diffuse() && @@ -2131,6 +2132,29 @@ void RenderUtilPrivate::UpdateLights( auto l = std::dynamic_pointer_cast(node); if (l) { + // todo(anyone) Use the field visualize_visual in light.proto from + // Garden on. + bool visualizeVisual = true; + for (int i = 0; i < light.second.header().data_size(); ++i) + { + for (int j = 0; + j < light.second.header().data(i).value_size(); ++j) + { + if (light.second.header().data(i).key() == + "visualizeVisual") + { + visualizeVisual = ignition::math::parseInt( + light.second.header().data(i).value(0)); + } + } + } + + rendering::VisualPtr lightVisual = + this->sceneManager.VisualById( + this->matchLightWithVisuals[light.first]); + if (lightVisual) + lightVisual->SetVisible(visualizeVisual); + // todo(anyone) Use the field isLightOn in light.proto from // Garden on. bool isLightOn = true; diff --git a/src/rendering/SceneManager.cc b/src/rendering/SceneManager.cc index fe334bad2a..79893983f2 100644 --- a/src/rendering/SceneManager.cc +++ b/src/rendering/SceneManager.cc @@ -1066,6 +1066,9 @@ rendering::VisualPtr SceneManager::CreateLightVisual(Entity _id, lightVisual->SetInnerAngle(_light.SpotInnerAngle().Radian()); lightVisual->SetOuterAngle(_light.SpotOuterAngle().Radian()); } + + lightVisual->SetVisible(_light.Visualize()); + rendering::VisualPtr lightVis = std::dynamic_pointer_cast( lightVisual); lightVis->SetUserData("gazebo-entity", static_cast(_id)); diff --git a/src/systems/user_commands/UserCommands.cc b/src/systems/user_commands/UserCommands.cc index 65e4d5f334..2e4ed3864f 100644 --- a/src/systems/user_commands/UserCommands.cc +++ b/src/systems/user_commands/UserCommands.cc @@ -159,6 +159,27 @@ class LightCommand : public UserCommandBase public: std::function lightEql { [](const msgs::Light &_a, const msgs::Light &_b) { + // todo(anyone) Use the field isLightOn in light.proto from + // Garden on. + auto getVisualizeVisual = [](const msgs::Light &_light) -> bool + { + bool visualizeVisual = true; + for (int i = 0; i < _light.header().data_size(); ++i) + { + for (int j = 0; + j < _light.header().data(i).value_size(); ++j) + { + if (_light.header().data(i).key() == + "visualizeVisual") + { + visualizeVisual = ignition::math::parseInt( + _light.header().data(i).value(0)); + } + } + } + return visualizeVisual; + }; + // todo(anyone) Use the field isLightOn in light.proto from // Garden on. auto getIsLightOn = [](const msgs::Light &_light) -> bool @@ -180,6 +201,7 @@ class LightCommand : public UserCommandBase return isLightOn; }; return + getVisualizeVisual(_a) == getVisualizeVisual(_b) && getIsLightOn(_a) == getIsLightOn(_b) && _a.type() == _b.type() && _a.name() == _b.name() && From 2936623b32377ef6ed4810fbd8363c405c792914 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Mon, 14 Mar 2022 11:16:07 +0100 Subject: [PATCH 5/7] Added Feedback Signed-off-by: ahcorde --- src/Conversions.cc | 4 ++-- src/gui/plugins/component_inspector/ComponentInspector.cc | 2 +- src/gui/plugins/component_inspector/ComponentInspector.hh | 1 + src/gui/plugins/component_inspector/Light.qml | 2 +- src/rendering/RenderUtil.cc | 2 +- src/systems/user_commands/UserCommands.cc | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Conversions.cc b/src/Conversions.cc index fd85b46df6..aafd9213f7 100644 --- a/src/Conversions.cc +++ b/src/Conversions.cc @@ -569,7 +569,7 @@ msgs::Light ignition::gazebo::convert(const sdf::Light &_in) out.set_spot_outer_angle(_in.SpotOuterAngle().Radian()); out.set_spot_falloff(_in.SpotFalloff()); - // todo(anyone) Use the field isLightOn in light.proto from + // todo(ahcorde) Use the field is_light_off in light.proto from // Garden on. auto header = out.mutable_header()->add_data(); header->set_key("isLightOn"); @@ -606,7 +606,7 @@ sdf::Light ignition::gazebo::convert(const msgs::Light &_in) out.SetSpotOuterAngle(math::Angle(_in.spot_outer_angle())); out.SetSpotFalloff(_in.spot_falloff()); - // todo(anyone) Use the field isLightOn in light.proto from + // todo(ahcorde) Use the field is_light_off in light.proto from // Garden on. bool isLightOn = true; for (int i = 0; i < _in.header().data_size(); ++i) diff --git a/src/gui/plugins/component_inspector/ComponentInspector.cc b/src/gui/plugins/component_inspector/ComponentInspector.cc index 2ebf5f68e5..f16712ce73 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.cc +++ b/src/gui/plugins/component_inspector/ComponentInspector.cc @@ -1017,7 +1017,7 @@ void ComponentInspector::OnLight( ignition::msgs::Light req; - // todo(anyone) Use the field isLightOn in light.proto from + // todo(ahcorde) Use the field is_light_off in light.proto from // Garden on. auto header = req.mutable_header()->add_data(); header->set_key("isLightOn"); diff --git a/src/gui/plugins/component_inspector/ComponentInspector.hh b/src/gui/plugins/component_inspector/ComponentInspector.hh index 4a166b1baf..0590aa31c7 100644 --- a/src/gui/plugins/component_inspector/ComponentInspector.hh +++ b/src/gui/plugins/component_inspector/ComponentInspector.hh @@ -252,6 +252,7 @@ namespace gazebo /// \param[in] _falloff Falloff of the spotlight /// \param[in] _intensity Intensity of the light /// \param[in] _type light type + /// \param[in] _isLightOn is light on public: Q_INVOKABLE void OnLight( double _rSpecular, double _gSpecular, double _bSpecular, double _aSpecular, double _rDiffuse, double _gDiffuse, diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index 6b3969dc72..b336f31d12 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -310,7 +310,7 @@ Rectangle { height: 40 Loader { - id: inOnLoader + id: isOnLoader anchors.fill: parent property double numberValue: model.data[21] sourceComponent: ignSwitch diff --git a/src/rendering/RenderUtil.cc b/src/rendering/RenderUtil.cc index d822ab4217..15e7bdfd43 100644 --- a/src/rendering/RenderUtil.cc +++ b/src/rendering/RenderUtil.cc @@ -2131,7 +2131,7 @@ void RenderUtilPrivate::UpdateLights( auto l = std::dynamic_pointer_cast(node); if (l) { - // todo(anyone) Use the field isLightOn in light.proto from + // todo(ahcorde) Use the field is_light_off in light.proto from // Garden on. bool isLightOn = true; for (int i = 0; i < light.second.header().data_size(); ++i) diff --git a/src/systems/user_commands/UserCommands.cc b/src/systems/user_commands/UserCommands.cc index 65e4d5f334..1bd29a7d96 100644 --- a/src/systems/user_commands/UserCommands.cc +++ b/src/systems/user_commands/UserCommands.cc @@ -159,7 +159,7 @@ class LightCommand : public UserCommandBase public: std::function lightEql { [](const msgs::Light &_a, const msgs::Light &_b) { - // todo(anyone) Use the field isLightOn in light.proto from + // todo(ahcorde) Use the field is_light_off in light.proto from // Garden on. auto getIsLightOn = [](const msgs::Light &_light) -> bool { From 58c447c696767e8a2edc49fb1c58726721cfc2b3 Mon Sep 17 00:00:00 2001 From: ahcorde Date: Mon, 14 Mar 2022 11:45:15 +0100 Subject: [PATCH 6/7] Fix qml Signed-off-by: ahcorde --- src/gui/plugins/component_inspector/Light.qml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index b336f31d12..f051feb2b3 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -294,7 +294,6 @@ Rectangle { color: "transparent" height: 40 Layout.preferredWidth: isOnText.width + indentation*3 - Component.onCompleted: isLightOn.item.componentInfo = "is light on ?" Text { id : isOnText @@ -315,7 +314,7 @@ Rectangle { property double numberValue: model.data[21] sourceComponent: ignSwitch onLoaded: { - isLightOnItem = inOnLoader.item + isLightOnItem = isOnLoader.item } } } From 394c7570551e2ee7a3ebfc49a3a8ebfd2a8ea0ad Mon Sep 17 00:00:00 2001 From: ahcorde Date: Mon, 14 Mar 2022 11:52:20 +0100 Subject: [PATCH 7/7] Added feedback Signed-off-by: ahcorde --- src/gui/plugins/component_inspector/Light.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/plugins/component_inspector/Light.qml b/src/gui/plugins/component_inspector/Light.qml index 798b0b7f9c..b32da765a3 100644 --- a/src/gui/plugins/component_inspector/Light.qml +++ b/src/gui/plugins/component_inspector/Light.qml @@ -301,7 +301,7 @@ Rectangle { Text { id : visualizeVisualText - text: ' Visualize visual enabled' + text: ' View gizmo' leftPadding: 5 color: Material.theme == Material.Light ? "#444444" : "#bbbbbb" font.pointSize: 12