From 6d79e5832ea9501f106c9b777e403c5a4c489c85 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 26 Oct 2022 15:45:42 +0800 Subject: [PATCH 1/8] Adds a basic unit test for PointCloud functionality This PR adds a very trivial (happy path) unit test for PointCloud functionality. Hopefully, I will get more time to add more functionality to this test over time. TODOS: * Check behaviour with NaNs * Check mismatched float and pointcloud sizes * Check malformed point cloud. Signed-off-by: Arjo Chakravarty --- test/integration/point_cloud.cc | 206 ++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100644 test/integration/point_cloud.cc diff --git a/test/integration/point_cloud.cc b/test/integration/point_cloud.cc new file mode 100644 index 000000000..0d8ff111d --- /dev/null +++ b/test/integration/point_cloud.cc @@ -0,0 +1,206 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "test_config.hh" // NOLINT(build/include) +#include "gz/gui/Application.hh" +#include "gz/gui/GuiEvents.hh" +#include "gz/gui/MainWindow.hh" +#include "gz/gui/Plugin.hh" + +int g_argc = 1; +char* g_argv[] = +{ + reinterpret_cast(const_cast("./PointCloud_TEST")), +}; + +using namespace std::chrono_literals; + +using namespace gz; +using namespace gui; + +class PointCloudTestFixture : public ::testing::Test +{ + + public: + gz::transport::Node node; + rendering::ScenePtr scene; + gz::transport::Node::Publisher pointcloudPub; + gz::transport::Node::Publisher flatPub; + gz::msgs::PointCloudPacked pcMsg; + gz::msgs::Float_V flatMsg; + std::atomic receivedMsg; + + PointCloudTestFixture() + { + // Periodic world statistics + this->pointcloudPub = this->node.Advertise( + "/point_cloud"); + this->flatPub = this->node.Advertise("/flat"); + + this->InitMockData(); + + this->node.Advertise("/marker", + &PointCloudTestFixture::OnMarkerMsg, this); + this->receivedMsg = false; + } + + public: void InitMockData() + { + + gz::msgs::InitPointCloudPacked(pcMsg, "some_frame", true, + {{"xyz", gz::msgs::PointCloudPacked::Field::FLOAT32}}); + + int numberOfPoints{1000}; + unsigned int dataSize{numberOfPoints * pcMsg.point_step()}; + pcMsg.mutable_data()->resize(dataSize); + pcMsg.set_height(1); + pcMsg.set_width(1000); + + // Populate messages + gz::msgs::PointCloudPackedIterator xIter(pcMsg, "x"); + gz::msgs::PointCloudPackedIterator yIter(pcMsg, "y"); + gz::msgs::PointCloudPackedIterator zIter(pcMsg, "z"); + + for (float x = 0.0, y = 0.0, z = 0.0; + xIter != xIter.End(); + ++xIter, ++yIter, ++zIter) + { + *xIter = x; + *yIter = y; + *zIter = z; + flatMsg.add_data(x); + + x += 1.0; + if (x > 9) + { + x = 0.0; + y += 1.0; + } + if (y > 9) + { + y = 0.0; + z += 1.0; + } + } + } + + public: void Publish() + { + this->pointcloudPub.Publish(pcMsg); + this->flatPub.Publish(flatMsg); + } + + /// \brief Callback that receives marker messages. + /// \param[in] _req The marker message. + public: void OnMarkerMsg(const gz::msgs::Marker &_req) + { + if (_req.action() == gz::msgs::Marker::DELETE_ALL) + { + // TODO(arjo129): Don't clear all markers only one marker. + } + else if (_req.action() == gz::msgs::Marker::ADD_MODIFY) + { + EXPECT_EQ(_req.id(), 1); + EXPECT_EQ(_req.ns(), "/point_cloud/flat"); + EXPECT_EQ(_req.type(), gz::msgs::Marker::POINTS); + EXPECT_EQ(_req.visibility(), gz::msgs::Marker::GUI); + if (_req.point().size() != 0) + { + // We might recieve empty packets as the sending process + // is asynchronuous + EXPECT_EQ(_req.point().size(), this->flatMsg.data().size()); + EXPECT_EQ(_req.materials().size(), this->flatMsg.data().size()); + this->receivedMsg = true; + } + } + else + { + EXPECT_TRUE(false); + } + } +}; + +///////////////////////////////////////////////// +TEST_F(PointCloudTestFixture, + GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(PointCloudTestFixture)) +{ + common::Console::SetVerbosity(4); + + // Load the plugin + Application app(g_argc, g_argv); + app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); + // Load plugin + const char *pluginStr = + "" + "/point_cloud" + "/flat" + ""; + + tinyxml2::XMLDocument pluginDoc; + EXPECT_EQ(tinyxml2::XML_SUCCESS, pluginDoc.Parse(pluginStr)); + + EXPECT_TRUE(app.LoadPlugin("PointCloud", + pluginDoc.FirstChildElement("plugin"))); + + // Get main window + auto window = app.findChild(); + ASSERT_NE(window, nullptr); + + // Get plugin + auto plugins = window->findChildren(); + EXPECT_EQ(plugins.size(), 1); + + // Show, but don't exec, so we don't block + window->QuickWindow()->show(); + + + this->Publish(); + + int sleep = 0; + int maxSleep = 30; + while (sleep < maxSleep) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + QCoreApplication::processEvents(); + this->Publish(); + sleep++; + } + + EXPECT_TRUE(this->receivedMsg); + + // Cleanup + plugins.clear(); +} From 40e553da8565a08c8ee8efab74741d26bb04e807 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 26 Oct 2022 16:22:45 +0800 Subject: [PATCH 2/8] Address feedback Signed-off-by: Arjo Chakravarty --- test/integration/point_cloud.cc | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/test/integration/point_cloud.cc b/test/integration/point_cloud.cc index 0d8ff111d..a3fe7a777 100644 --- a/test/integration/point_cloud.cc +++ b/test/integration/point_cloud.cc @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021 Open Source Robotics Foundation + * Copyright (C) 2022 Open Source Robotics Foundation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,11 +18,11 @@ #include #include -#include +#include #include #include -#include #include +#include #include #include @@ -53,7 +53,6 @@ using namespace gui; class PointCloudTestFixture : public ::testing::Test { - public: gz::transport::Node node; rendering::ScenePtr scene; @@ -79,7 +78,6 @@ class PointCloudTestFixture : public ::testing::Test public: void InitMockData() { - gz::msgs::InitPointCloudPacked(pcMsg, "some_frame", true, {{"xyz", gz::msgs::PointCloudPacked::Field::FLOAT32}}); @@ -139,7 +137,7 @@ class PointCloudTestFixture : public ::testing::Test EXPECT_EQ(_req.visibility(), gz::msgs::Marker::GUI); if (_req.point().size() != 0) { - // We might recieve empty packets as the sending process + // We might receive empty packets as the sending process // is asynchronuous EXPECT_EQ(_req.point().size(), this->flatMsg.data().size()); EXPECT_EQ(_req.materials().size(), this->flatMsg.data().size()); @@ -161,7 +159,8 @@ TEST_F(PointCloudTestFixture, // Load the plugin Application app(g_argc, g_argv); - app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); + app.AddPluginPath( + common::joinPaths(std::string(PROJECT_BINARY_PATH), "lib")); // Load plugin const char *pluginStr = "" @@ -186,7 +185,6 @@ TEST_F(PointCloudTestFixture, // Show, but don't exec, so we don't block window->QuickWindow()->show(); - this->Publish(); int sleep = 0; From 9a1f57301acffca9107f842d5a7e97c8b7d5fe4d Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 20 Dec 2022 21:13:07 +0800 Subject: [PATCH 3/8] Address PR feedback Signed-off-by: Arjo Chakravarty --- src/plugins/point_cloud/PointCloud_TEST.cc | 146 ++++++++++++++- test/integration/point_cloud.cc | 204 --------------------- 2 files changed, 142 insertions(+), 208 deletions(-) delete mode 100644 test/integration/point_cloud.cc diff --git a/src/plugins/point_cloud/PointCloud_TEST.cc b/src/plugins/point_cloud/PointCloud_TEST.cc index 5fee2ecf3..73aebb38c 100644 --- a/src/plugins/point_cloud/PointCloud_TEST.cc +++ b/src/plugins/point_cloud/PointCloud_TEST.cc @@ -18,15 +18,23 @@ #include #include +#include + #include #include +#include +#include +#include +#include +#include +#include #include #include "test_config.hh" // NOLINT(build/include) #include "gz/gui/Application.hh" +#include "gz/gui/GuiEvents.hh" #include "gz/gui/MainWindow.hh" #include "gz/gui/Plugin.hh" -#include "PointCloud.hh" int g_argc = 1; char* g_argv[] = @@ -34,19 +42,132 @@ char* g_argv[] = reinterpret_cast(const_cast("./PointCloud_TEST")), }; +using namespace std::chrono_literals; + using namespace gz; using namespace gui; +class PointCloudTestFixture : public ::testing::Test +{ + public: + transport::Node node; + rendering::ScenePtr scene; + transport::Node::Publisher pointcloudPub; + transport::Node::Publisher flatPub; + msgs::PointCloudPacked pcMsg; + msgs::Float_V flatMsg; + std::atomic receivedMsg; + + PointCloudTestFixture() + { + this->pointcloudPub = this->node.Advertise( + "/point_cloud"); + this->flatPub = this->node.Advertise("/flat"); + + this->InitMockData(); + + this->node.Advertise("/marker", + &PointCloudTestFixture::OnMarkerMsg, this); + this->receivedMsg = false; + } + + public: void InitMockData() + { + msgs::InitPointCloudPacked(this->pcMsg, "some_frame", true, + {{"xyz", msgs::PointCloudPacked::Field::FLOAT32}}); + + int numberOfPoints{1000}; + unsigned int dataSize{numberOfPoints * this->pcMsg.point_step()}; + this->pcMsg.mutable_data()->resize(dataSize); + this->pcMsg.set_height(1); + this->pcMsg.set_width(1000); + + // Populate messages + msgs::PointCloudPackedIterator xIter(this->pcMsg, "x"); + msgs::PointCloudPackedIterator yIter(this->pcMsg, "y"); + msgs::PointCloudPackedIterator zIter(this->pcMsg, "z"); + + for (float x = 0.0, y = 0.0, z = 0.0; + xIter != xIter.End(); + ++xIter, ++yIter, ++zIter) + { + *xIter = x; + *yIter = y; + *zIter = z; + flatMsg.add_data(x); + + x += 1.0; + if (x > 9) + { + x = 0.0; + y += 1.0; + } + if (y > 9) + { + y = 0.0; + z += 1.0; + } + } + } + + public: void Publish() + { + this->pointcloudPub.Publish(this->pcMsg); + this->flatPub.Publish(this->flatMsg); + } + + /// \brief Callback that receives marker messages. + /// \param[in] _req The marker message. + public: void OnMarkerMsg(const msgs::Marker &_req) + { + if (_req.action() == msgs::Marker::ADD_MODIFY) + { + EXPECT_EQ(_req.id(), 1); + EXPECT_EQ(_req.ns(), "/point_cloud/flat"); + EXPECT_EQ(_req.type(), msgs::Marker::POINTS); + EXPECT_EQ(_req.visibility(), msgs::Marker::GUI); + if (_req.point().size() != 0) + { + // We might receive empty packets as the sending process + // is asynchronuous + EXPECT_EQ(_req.point().size(), this->flatMsg.data().size()); + EXPECT_EQ(_req.materials().size(), this->flatMsg.data().size()); + this->receivedMsg = true; + } + } + else if(_req.action() == gz::msgs::Marker::DELETE_ALL) + { + // Do nothing. Its ok to clear the screen. + } + else + { + ADD_FAILURE(); + } + } +}; + ///////////////////////////////////////////////// -TEST(PointCloudTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(PointCloud)) +TEST_F(PointCloudTestFixture, + GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(PointCloudTestFixture)) { common::Console::SetVerbosity(4); // Load the plugin Application app(g_argc, g_argv); - app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); + app.AddPluginPath( + common::joinPaths(std::string(PROJECT_BINARY_PATH), "lib")); + // Load plugin + const char *pluginStr = + "" + "/point_cloud" + "/flat" + ""; - EXPECT_TRUE(app.LoadPlugin("PointCloud")); + tinyxml2::XMLDocument pluginDoc; + EXPECT_EQ(tinyxml2::XML_SUCCESS, pluginDoc.Parse(pluginStr)); + + EXPECT_TRUE(app.LoadPlugin("PointCloud", + pluginDoc.FirstChildElement("plugin"))); // Get main window auto window = app.findChild(); @@ -56,6 +177,23 @@ TEST(PointCloudTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(PointCloud)) auto plugins = window->findChildren(); EXPECT_EQ(plugins.size(), 1); + // Show, but don't exec, so we don't block + window->QuickWindow()->show(); + + this->Publish(); + + int sleep = 0; + int maxSleep = 30; + while (sleep < maxSleep && !this->receivedMsg) + { + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + QCoreApplication::processEvents(); + this->Publish(); + sleep++; + } + + EXPECT_TRUE(this->receivedMsg); + // Cleanup plugins.clear(); } diff --git a/test/integration/point_cloud.cc b/test/integration/point_cloud.cc deleted file mode 100644 index a3fe7a777..000000000 --- a/test/integration/point_cloud.cc +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (C) 2022 Open Source Robotics Foundation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * -*/ - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "test_config.hh" // NOLINT(build/include) -#include "gz/gui/Application.hh" -#include "gz/gui/GuiEvents.hh" -#include "gz/gui/MainWindow.hh" -#include "gz/gui/Plugin.hh" - -int g_argc = 1; -char* g_argv[] = -{ - reinterpret_cast(const_cast("./PointCloud_TEST")), -}; - -using namespace std::chrono_literals; - -using namespace gz; -using namespace gui; - -class PointCloudTestFixture : public ::testing::Test -{ - public: - gz::transport::Node node; - rendering::ScenePtr scene; - gz::transport::Node::Publisher pointcloudPub; - gz::transport::Node::Publisher flatPub; - gz::msgs::PointCloudPacked pcMsg; - gz::msgs::Float_V flatMsg; - std::atomic receivedMsg; - - PointCloudTestFixture() - { - // Periodic world statistics - this->pointcloudPub = this->node.Advertise( - "/point_cloud"); - this->flatPub = this->node.Advertise("/flat"); - - this->InitMockData(); - - this->node.Advertise("/marker", - &PointCloudTestFixture::OnMarkerMsg, this); - this->receivedMsg = false; - } - - public: void InitMockData() - { - gz::msgs::InitPointCloudPacked(pcMsg, "some_frame", true, - {{"xyz", gz::msgs::PointCloudPacked::Field::FLOAT32}}); - - int numberOfPoints{1000}; - unsigned int dataSize{numberOfPoints * pcMsg.point_step()}; - pcMsg.mutable_data()->resize(dataSize); - pcMsg.set_height(1); - pcMsg.set_width(1000); - - // Populate messages - gz::msgs::PointCloudPackedIterator xIter(pcMsg, "x"); - gz::msgs::PointCloudPackedIterator yIter(pcMsg, "y"); - gz::msgs::PointCloudPackedIterator zIter(pcMsg, "z"); - - for (float x = 0.0, y = 0.0, z = 0.0; - xIter != xIter.End(); - ++xIter, ++yIter, ++zIter) - { - *xIter = x; - *yIter = y; - *zIter = z; - flatMsg.add_data(x); - - x += 1.0; - if (x > 9) - { - x = 0.0; - y += 1.0; - } - if (y > 9) - { - y = 0.0; - z += 1.0; - } - } - } - - public: void Publish() - { - this->pointcloudPub.Publish(pcMsg); - this->flatPub.Publish(flatMsg); - } - - /// \brief Callback that receives marker messages. - /// \param[in] _req The marker message. - public: void OnMarkerMsg(const gz::msgs::Marker &_req) - { - if (_req.action() == gz::msgs::Marker::DELETE_ALL) - { - // TODO(arjo129): Don't clear all markers only one marker. - } - else if (_req.action() == gz::msgs::Marker::ADD_MODIFY) - { - EXPECT_EQ(_req.id(), 1); - EXPECT_EQ(_req.ns(), "/point_cloud/flat"); - EXPECT_EQ(_req.type(), gz::msgs::Marker::POINTS); - EXPECT_EQ(_req.visibility(), gz::msgs::Marker::GUI); - if (_req.point().size() != 0) - { - // We might receive empty packets as the sending process - // is asynchronuous - EXPECT_EQ(_req.point().size(), this->flatMsg.data().size()); - EXPECT_EQ(_req.materials().size(), this->flatMsg.data().size()); - this->receivedMsg = true; - } - } - else - { - EXPECT_TRUE(false); - } - } -}; - -///////////////////////////////////////////////// -TEST_F(PointCloudTestFixture, - GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(PointCloudTestFixture)) -{ - common::Console::SetVerbosity(4); - - // Load the plugin - Application app(g_argc, g_argv); - app.AddPluginPath( - common::joinPaths(std::string(PROJECT_BINARY_PATH), "lib")); - // Load plugin - const char *pluginStr = - "" - "/point_cloud" - "/flat" - ""; - - tinyxml2::XMLDocument pluginDoc; - EXPECT_EQ(tinyxml2::XML_SUCCESS, pluginDoc.Parse(pluginStr)); - - EXPECT_TRUE(app.LoadPlugin("PointCloud", - pluginDoc.FirstChildElement("plugin"))); - - // Get main window - auto window = app.findChild(); - ASSERT_NE(window, nullptr); - - // Get plugin - auto plugins = window->findChildren(); - EXPECT_EQ(plugins.size(), 1); - - // Show, but don't exec, so we don't block - window->QuickWindow()->show(); - - this->Publish(); - - int sleep = 0; - int maxSleep = 30; - while (sleep < maxSleep) - { - std::this_thread::sleep_for(std::chrono::milliseconds(100)); - QCoreApplication::processEvents(); - this->Publish(); - sleep++; - } - - EXPECT_TRUE(this->receivedMsg); - - // Cleanup - plugins.clear(); -} From 3e929bf746b8981e5bec8dd1e6378fd8800b73b8 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Tue, 20 Dec 2022 21:24:08 +0800 Subject: [PATCH 4/8] Style Signed-off-by: Arjo Chakravarty --- src/plugins/point_cloud/PointCloud_TEST.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/point_cloud/PointCloud_TEST.cc b/src/plugins/point_cloud/PointCloud_TEST.cc index 73aebb38c..446bbb4b4 100644 --- a/src/plugins/point_cloud/PointCloud_TEST.cc +++ b/src/plugins/point_cloud/PointCloud_TEST.cc @@ -19,11 +19,11 @@ #include #include +#include +#include #include #include -#include -#include #include #include #include From 81ea36ce077025b50549d4b6a48629180d6d677d Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Wed, 21 Dec 2022 08:46:06 +0800 Subject: [PATCH 5/8] Address PR Feedback Signed-off-by: Arjo Chakravarty --- src/plugins/point_cloud/PointCloud_TEST.cc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/plugins/point_cloud/PointCloud_TEST.cc b/src/plugins/point_cloud/PointCloud_TEST.cc index 446bbb4b4..943ae0e64 100644 --- a/src/plugins/point_cloud/PointCloud_TEST.cc +++ b/src/plugins/point_cloud/PointCloud_TEST.cc @@ -24,15 +24,11 @@ #include #include -#include -#include -#include #include #include #include "test_config.hh" // NOLINT(build/include) #include "gz/gui/Application.hh" -#include "gz/gui/GuiEvents.hh" #include "gz/gui/MainWindow.hh" #include "gz/gui/Plugin.hh" @@ -42,8 +38,6 @@ char* g_argv[] = reinterpret_cast(const_cast("./PointCloud_TEST")), }; -using namespace std::chrono_literals; - using namespace gz; using namespace gui; @@ -51,7 +45,6 @@ class PointCloudTestFixture : public ::testing::Test { public: transport::Node node; - rendering::ScenePtr scene; transport::Node::Publisher pointcloudPub; transport::Node::Publisher flatPub; msgs::PointCloudPacked pcMsg; @@ -135,14 +128,12 @@ class PointCloudTestFixture : public ::testing::Test this->receivedMsg = true; } } - else if(_req.action() == gz::msgs::Marker::DELETE_ALL) - { - // Do nothing. Its ok to clear the screen. - } - else + else if (_req.action() != msgs::Marker::DELETE_ALL) { + // if DELETE_ALL, its ok to clear the screen. Otherwise fail ADD_FAILURE(); } + } }; @@ -184,14 +175,13 @@ TEST_F(PointCloudTestFixture, int sleep = 0; int maxSleep = 30; - while (sleep < maxSleep && !this->receivedMsg) + while (!this->receivedMsg && sleep < maxSleep) { + this->Publish(); std::this_thread::sleep_for(std::chrono::milliseconds(100)); QCoreApplication::processEvents(); - this->Publish(); - sleep++; + ++sleep; } - EXPECT_TRUE(this->receivedMsg); // Cleanup From c1f232bf5eaf8ab3b7865eeb809cb9899905b614 Mon Sep 17 00:00:00 2001 From: Arjo Chakravarty Date: Thu, 22 Dec 2022 11:35:36 +0800 Subject: [PATCH 6/8] Test actual values Signed-off-by: Arjo Chakravarty --- src/plugins/point_cloud/PointCloud_TEST.cc | 46 ++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/src/plugins/point_cloud/PointCloud_TEST.cc b/src/plugins/point_cloud/PointCloud_TEST.cc index 943ae0e64..2b840d8aa 100644 --- a/src/plugins/point_cloud/PointCloud_TEST.cc +++ b/src/plugins/point_cloud/PointCloud_TEST.cc @@ -103,12 +103,21 @@ class PointCloudTestFixture : public ::testing::Test } } + /// \brief Publish pointcloud packed data public: void Publish() { this->pointcloudPub.Publish(this->pcMsg); this->flatPub.Publish(this->flatMsg); } + /// \brief Color for minimum value + public: const math::Color minColor{1.0f, 0.0f, 0.0f, 1.0f}; + + /// \brief Color for maximum value + public: const math::Color maxColor{0.0f, 1.0f, 0.0f, 1.0f}; + + public: bool indexRecieved[10][10][10] = {false}; + /// \brief Callback that receives marker messages. /// \param[in] _req The marker message. public: void OnMarkerMsg(const msgs::Marker &_req) @@ -125,6 +134,43 @@ class PointCloudTestFixture : public ::testing::Test // is asynchronuous EXPECT_EQ(_req.point().size(), this->flatMsg.data().size()); EXPECT_EQ(_req.materials().size(), this->flatMsg.data().size()); + + auto dR = maxColor.R() - minColor.R(); + auto dG = maxColor.G() - minColor.G(); + auto dB = maxColor.B() - minColor.B(); + auto dA = maxColor.A() - minColor.A(); + + for (std::size_t idx = 0; idx < _req.point().size(); idx++) + { + // Check color correctness + EXPECT_NEAR(dR * (_req.point()[idx].x() / 9) + minColor.R(), + _req.materials()[idx].diffuse().r(), 1e-3); + EXPECT_NEAR(dG * (_req.point()[idx].x() / 9) + minColor.G(), + _req.materials()[idx].diffuse().g(), 1e-3); + EXPECT_NEAR(dB * (_req.point()[idx].x() / 9) + minColor.B(), + _req.materials()[idx].diffuse().b(), 1e-3); + EXPECT_NEAR(dA * (_req.point()[idx].x() / 9) + minColor.A(), + _req.materials()[idx].diffuse().a(), 1e-3); + + std::size_t x = round(_req.point()[idx].x()); + std::size_t y = round(_req.point()[idx].y()); + std::size_t z = round(_req.point()[idx].z()); + + // Mark this voxel as occupied + this->indexRecieved[x][y][z] = true; + } + + // Check all points in the point cloud have been populated. + for (std::size_t i = 0; i < 10; i++) + { + for (std::size_t j = 0; j < 10; j++) + { + for (std::size_t k = 0; k < 10; k++) + { + EXPECT_TRUE(this->indexRecieved[i][j][k]); + } + } + } this->receivedMsg = true; } } From 9c5e3b6c7d23cfb55663017b611b9b24ba35b507 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Mon, 28 Aug 2023 20:56:23 +0000 Subject: [PATCH 7/8] fix warning Signed-off-by: Ian Chen --- src/plugins/point_cloud/PointCloud_TEST.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/plugins/point_cloud/PointCloud_TEST.cc b/src/plugins/point_cloud/PointCloud_TEST.cc index 2b840d8aa..f06072683 100644 --- a/src/plugins/point_cloud/PointCloud_TEST.cc +++ b/src/plugins/point_cloud/PointCloud_TEST.cc @@ -140,7 +140,7 @@ class PointCloudTestFixture : public ::testing::Test auto dB = maxColor.B() - minColor.B(); auto dA = maxColor.A() - minColor.A(); - for (std::size_t idx = 0; idx < _req.point().size(); idx++) + for (int idx = 0; idx < _req.point().size(); idx++) { // Check color correctness EXPECT_NEAR(dR * (_req.point()[idx].x() / 9) + minColor.R(), From 8dae03714df70df5d8bbcec1eaa8f02335c91dbf Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 2 Nov 2023 09:07:23 -0700 Subject: [PATCH 8/8] Tidy namespaces (#590) Signed-off-by: Michael Carroll --- .../custom_context_menu/CustomContext.cc | 9 +- .../custom_context_menu/CustomContext.hh | 22 +- .../dialog_from_plugin/DialogFromPlugin.cc | 9 +- .../dialog_from_plugin/DialogFromPlugin.hh | 22 +- examples/plugin/gz_components/GzComponents.cc | 2 +- examples/plugin/gz_components/GzComponents.hh | 18 +- examples/plugin/hello_plugin/HelloPlugin.cc | 9 +- examples/plugin/hello_plugin/HelloPlugin.hh | 38 ++-- examples/plugin/multiple_qml/MultipleQml.cc | 9 +- examples/plugin/multiple_qml/MultipleQml.hh | 28 +-- .../standalone/custom_drawer/custom_drawer.cc | 3 +- .../standalone/custom_drawer/custom_drawer.hh | 31 ++- include/gz/gui/Application.hh | 9 +- include/gz/gui/Conversions.hh | 17 +- include/gz/gui/Dialog.hh | 9 +- include/gz/gui/DragDropModel.hh | 9 +- include/gz/gui/Enums.hh | 9 +- include/gz/gui/GuiEvents.hh | 11 +- include/gz/gui/Helpers.hh | 9 +- include/gz/gui/MainWindow.hh | 9 +- include/gz/gui/PlottingInterface.hh | 11 +- include/gz/gui/Plugin.hh | 9 +- include/gz/gui/SearchModel.hh | 9 +- include/gz/gui/config.hh.in | 2 +- include/gz/gui/gz.hh | 2 +- include/gz/gui/qt.h | 1 - src/Application.cc | 76 +++---- src/Conversions.cc | 22 +- src/Dialog.cc | 24 +-- src/DragDropModel.cc | 7 +- src/GuiEvents.cc | 47 ++-- src/Helpers.cc | 21 +- src/MainWindow.cc | 78 +++---- src/PlottingInterface.cc | 22 +- src/Plugin.cc | 15 +- src/SearchModel.cc | 7 +- src/plugins/camera_fps/CameraFps.cc | 15 +- src/plugins/camera_fps/CameraFps.hh | 13 +- src/plugins/camera_tracking/CameraTracking.cc | 15 +- src/plugins/camera_tracking/CameraTracking.hh | 13 +- src/plugins/grid_config/GridConfig.cc | 11 +- src/plugins/grid_config/GridConfig.hh | 9 +- src/plugins/image_display/ImageDisplay.cc | 44 ++-- src/plugins/image_display/ImageDisplay.hh | 12 +- .../InteractiveViewControl.cc | 11 +- .../InteractiveViewControl.hh | 12 +- src/plugins/key_publisher/KeyPublisher.cc | 52 ++--- src/plugins/key_publisher/KeyPublisher.hh | 9 +- src/plugins/marker_manager/MarkerManager.cc | 15 +- src/plugins/marker_manager/MarkerManager.hh | 13 +- src/plugins/minimal_scene/MinimalScene.cc | 11 +- src/plugins/minimal_scene/MinimalScene.hh | 12 +- src/plugins/minimal_scene/MinimalSceneRhi.cc | 7 +- src/plugins/minimal_scene/MinimalSceneRhi.hh | 12 +- .../minimal_scene/MinimalSceneRhiMetal.hh | 12 +- .../minimal_scene/MinimalSceneRhiOpenGL.cc | 14 +- .../minimal_scene/MinimalSceneRhiOpenGL.hh | 12 +- src/plugins/navsat_map/NavSatMap.cc | 40 ++-- src/plugins/navsat_map/NavSatMap.hh | 16 +- src/plugins/plotting/TransportPlotting.cc | 13 +- src/plugins/plotting/TransportPlotting.hh | 14 +- src/plugins/point_cloud/PointCloud.cc | 14 +- src/plugins/point_cloud/PointCloud.hh | 13 +- src/plugins/publisher/Publisher.cc | 56 ++--- src/plugins/publisher/Publisher.hh | 12 +- src/plugins/screenshot/Screenshot.cc | 49 ++--- src/plugins/screenshot/Screenshot.hh | 13 +- src/plugins/shutdown_button/ShutdownButton.cc | 15 +- src/plugins/shutdown_button/ShutdownButton.hh | 12 +- src/plugins/tape_measure/TapeMeasure.cc | 88 ++++---- src/plugins/tape_measure/TapeMeasure.hh | 10 +- src/plugins/teleop/Teleop.cc | 131 ++++++------ src/plugins/teleop/Teleop.hh | 12 +- src/plugins/topic_echo/TopicEcho.cc | 55 ++--- src/plugins/topic_echo/TopicEcho.hh | 12 +- src/plugins/topic_viewer/TopicViewer.cc | 201 ++++++++---------- src/plugins/topic_viewer/TopicViewer.hh | 15 +- .../TransportSceneManager.cc | 11 +- .../TransportSceneManager.hh | 12 +- src/plugins/world_control/WorldControl.cc | 72 +++---- src/plugins/world_control/WorldControl.hh | 12 +- .../WorldControlEventListener.cc | 6 +- .../WorldControlEventListener.hh | 9 +- src/plugins/world_stats/WorldStats.cc | 68 +++--- src/plugins/world_stats/WorldStats.hh | 12 +- 85 files changed, 779 insertions(+), 1173 deletions(-) diff --git a/examples/plugin/custom_context_menu/CustomContext.cc b/examples/plugin/custom_context_menu/CustomContext.cc index 4aeeb5809..5d0b87acd 100644 --- a/examples/plugin/custom_context_menu/CustomContext.cc +++ b/examples/plugin/custom_context_menu/CustomContext.cc @@ -20,12 +20,9 @@ #include "CustomContext.hh" -using namespace gz; -using namespace gui; - ///////////////////////////////////////////////// CustomContext::CustomContext() - : Plugin() + : gz::gui::Plugin() { } @@ -35,5 +32,5 @@ CustomContext::~CustomContext() } // Register this plugin -GZ_ADD_PLUGIN(gz::gui::CustomContext, - gz::gui::Plugin); +GZ_ADD_PLUGIN(CustomContext, + gz::gui::Plugin); diff --git a/examples/plugin/custom_context_menu/CustomContext.hh b/examples/plugin/custom_context_menu/CustomContext.hh index e87989f5b..af3139871 100644 --- a/examples/plugin/custom_context_menu/CustomContext.hh +++ b/examples/plugin/custom_context_menu/CustomContext.hh @@ -23,21 +23,15 @@ #include #endif -namespace gz +class CustomContext : public gz::gui::Plugin { - namespace gui - { - class CustomContext : public Plugin - { - Q_OBJECT + Q_OBJECT - /// \brief Constructor - public: CustomContext(); + /// \brief Constructor + public: CustomContext(); - /// \brief Destructor - public: virtual ~CustomContext(); - }; - } -} + /// \brief Destructor + public: virtual ~CustomContext(); +}; -#endif +#endif // GZ_GUI_CUSTOMCONTEXTPLUGIN_HH_ diff --git a/examples/plugin/dialog_from_plugin/DialogFromPlugin.cc b/examples/plugin/dialog_from_plugin/DialogFromPlugin.cc index 019a81a4d..d6696097a 100644 --- a/examples/plugin/dialog_from_plugin/DialogFromPlugin.cc +++ b/examples/plugin/dialog_from_plugin/DialogFromPlugin.cc @@ -20,12 +20,9 @@ #include "DialogFromPlugin.hh" -using namespace gz; -using namespace gui; - ///////////////////////////////////////////////// DialogFromPlugin::DialogFromPlugin() - : Plugin() + : gz::gui::Plugin() { } @@ -35,5 +32,5 @@ DialogFromPlugin::~DialogFromPlugin() } // Register this plugin -GZ_ADD_PLUGIN(gz::gui::DialogFromPlugin, - gz::gui::Plugin); +GZ_ADD_PLUGIN(DialogFromPlugin, + gz::gui::Plugin); diff --git a/examples/plugin/dialog_from_plugin/DialogFromPlugin.hh b/examples/plugin/dialog_from_plugin/DialogFromPlugin.hh index e800d7732..8dd80bc89 100644 --- a/examples/plugin/dialog_from_plugin/DialogFromPlugin.hh +++ b/examples/plugin/dialog_from_plugin/DialogFromPlugin.hh @@ -23,21 +23,15 @@ #include #endif -namespace gz +class DialogFromPlugin : public gz::gui::Plugin { - namespace gui - { - class DialogFromPlugin : public Plugin - { - Q_OBJECT + Q_OBJECT - /// \brief Constructor - public: DialogFromPlugin(); + /// \brief Constructor + public: DialogFromPlugin(); - /// \brief Destructor - public: virtual ~DialogFromPlugin(); - }; - } -} + /// \brief Destructor + public: virtual ~DialogFromPlugin(); +}; -#endif +#endif // GZ_GUI_DIALOGFROMPLUGIN_HH_ diff --git a/examples/plugin/gz_components/GzComponents.cc b/examples/plugin/gz_components/GzComponents.cc index dbf993863..9a9b6f147 100644 --- a/examples/plugin/gz_components/GzComponents.cc +++ b/examples/plugin/gz_components/GzComponents.cc @@ -19,5 +19,5 @@ #include "GzComponents.hh" // Register this plugin -GZ_ADD_PLUGIN(gz::gui::GzComponents, +GZ_ADD_PLUGIN(GzComponents, gz::gui::Plugin); diff --git a/examples/plugin/gz_components/GzComponents.hh b/examples/plugin/gz_components/GzComponents.hh index 6137c87b2..e7f0c97fa 100644 --- a/examples/plugin/gz_components/GzComponents.hh +++ b/examples/plugin/gz_components/GzComponents.hh @@ -20,18 +20,12 @@ #include -namespace gz +class GzComponents : public gz::gui::Plugin { - namespace gui - { - class GzComponents : public Plugin - { - Q_OBJECT + Q_OBJECT - /// \brief Constructor - public: GzComponents() = default; - }; - } -} + /// \brief Constructor + public: GzComponents() = default; +}; -#endif +#endif // GZ_GUI_EXAMPLES_PLUGIN_GZCOMPONENTS_HH_ diff --git a/examples/plugin/hello_plugin/HelloPlugin.cc b/examples/plugin/hello_plugin/HelloPlugin.cc index c95fa0516..04763025f 100644 --- a/examples/plugin/hello_plugin/HelloPlugin.cc +++ b/examples/plugin/hello_plugin/HelloPlugin.cc @@ -20,12 +20,9 @@ #include "HelloPlugin.hh" -using namespace gz; -using namespace gui; - ///////////////////////////////////////////////// HelloPlugin::HelloPlugin() - : Plugin() + : gz::gui::Plugin() { } @@ -53,5 +50,5 @@ void HelloPlugin::OnButton() } // Register this plugin -GZ_ADD_PLUGIN(gz::gui::HelloPlugin, - gz::gui::Plugin); +GZ_ADD_PLUGIN(HelloPlugin, + gz::gui::Plugin); diff --git a/examples/plugin/hello_plugin/HelloPlugin.hh b/examples/plugin/hello_plugin/HelloPlugin.hh index 4e545be2a..504d15e6c 100644 --- a/examples/plugin/hello_plugin/HelloPlugin.hh +++ b/examples/plugin/hello_plugin/HelloPlugin.hh @@ -23,32 +23,26 @@ #include #include -namespace gz +class HelloPlugin : public gz::gui::Plugin { - namespace gui - { - class HelloPlugin : public Plugin - { - Q_OBJECT + Q_OBJECT - /// \brief Constructor - public: HelloPlugin(); + /// \brief Constructor + public: HelloPlugin(); - /// \brief Destructor - public: virtual ~HelloPlugin(); + /// \brief Destructor + public: virtual ~HelloPlugin(); - /// \brief Called by Gazebo GUI when plugin is instantiated. - /// \param[in] _pluginElem XML configuration for this plugin. - public: virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem) - override; + /// \brief Called by Gazebo GUI when plugin is instantiated. + /// \param[in] _pluginElem XML configuration for this plugin. + public: virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem) + override; - /// \brief Callback trigged when the button is pressed. - protected slots: void OnButton(); + /// \brief Callback trigged when the button is pressed. + protected slots: void OnButton(); - /// \brief Message to be printed when button is pressed. - private: std::string message{"Hello, plugin!"}; - }; - } -} + /// \brief Message to be printed when button is pressed. + private: std::string message{"Hello, plugin!"}; +}; -#endif +#endif // GZ_GUI_HELLOPLUGIN_HH_ diff --git a/examples/plugin/multiple_qml/MultipleQml.cc b/examples/plugin/multiple_qml/MultipleQml.cc index 72f2c599f..d85b73a64 100644 --- a/examples/plugin/multiple_qml/MultipleQml.cc +++ b/examples/plugin/multiple_qml/MultipleQml.cc @@ -20,12 +20,9 @@ #include "MultipleQml.hh" -using namespace gz; -using namespace gui; - ///////////////////////////////////////////////// MultipleQml::MultipleQml() - : Plugin() + : gz::gui::Plugin() { } @@ -41,5 +38,5 @@ void MultipleQml::OnButton(const QString &_text) } // Register this plugin -GZ_ADD_PLUGIN(gz::gui::MultipleQml, - gz::gui::Plugin); +GZ_ADD_PLUGIN(MultipleQml, + gz::gui::Plugin); diff --git a/examples/plugin/multiple_qml/MultipleQml.hh b/examples/plugin/multiple_qml/MultipleQml.hh index ae0d9114f..63733dfac 100644 --- a/examples/plugin/multiple_qml/MultipleQml.hh +++ b/examples/plugin/multiple_qml/MultipleQml.hh @@ -23,25 +23,19 @@ #include #endif -namespace gz +class MultipleQml : public gz::gui::Plugin { - namespace gui - { - class MultipleQml : public Plugin - { - Q_OBJECT + Q_OBJECT - /// \brief Constructor - public: MultipleQml(); + /// \brief Constructor + public: MultipleQml(); - /// \brief Destructor - public: virtual ~MultipleQml(); + /// \brief Destructor + public: virtual ~MultipleQml(); - /// \brief Callback trigged when the button is pressed. - /// \param[in] _text Button text. - protected slots: void OnButton(const QString &_text); - }; - } -} + /// \brief Callback trigged when the button is pressed. + /// \param[in] _text Button text. + protected slots: void OnButton(const QString &_text); +}; -#endif +#endif // GZ_GUI_EXAMPLES_PLUGINS_MULTIPLEQML_HH_ diff --git a/examples/standalone/custom_drawer/custom_drawer.cc b/examples/standalone/custom_drawer/custom_drawer.cc index af975095b..07add6798 100644 --- a/examples/standalone/custom_drawer/custom_drawer.cc +++ b/examples/standalone/custom_drawer/custom_drawer.cc @@ -37,7 +37,7 @@ int main(int _argc, char **_argv) app.LoadConfig("../custom_drawer.config"); // Let QML files use CustomActions' functions and properties - gz::gui::CustomActions actions; + CustomActions actions; auto context = new QQmlContext(app.Engine()->rootContext()); context->setContextProperty("CustomActions", &actions); @@ -65,4 +65,3 @@ int main(int _argc, char **_argv) return 0; } - diff --git a/examples/standalone/custom_drawer/custom_drawer.hh b/examples/standalone/custom_drawer/custom_drawer.hh index e062afa69..5d6344ba4 100644 --- a/examples/standalone/custom_drawer/custom_drawer.hh +++ b/examples/standalone/custom_drawer/custom_drawer.hh @@ -24,25 +24,18 @@ #include #endif -namespace gz +/// \brief Object holding actions which can be triggered from the custom +/// drawer. +class CustomActions : public QObject { - namespace gui - { - /// \brief Object holding actions which can be triggered from the custom - /// drawer. - class CustomActions : public QObject - { - Q_OBJECT - - /// \brief Demonstrates a C++ function which can be called from the - /// drawer's QML code. - public: Q_INVOKABLE void cppActionFromQml() const - { - std::cout << "C++ action called from QML" << std::endl; - } - }; - } -} + Q_OBJECT -#endif + /// \brief Demonstrates a C++ function which can be called from the + /// drawer's QML code. + public: Q_INVOKABLE void cppActionFromQml() const + { + std::cout << "C++ action called from QML" << std::endl; + } +}; +#endif //GZ_GUI_EXAMPLES_STANDALONE_CUSTOMDRAWER_HH_ diff --git a/include/gz/gui/Application.hh b/include/gz/gui/Application.hh index c5e73f9a5..85df18399 100644 --- a/include/gz/gui/Application.hh +++ b/include/gz/gui/Application.hh @@ -37,10 +37,8 @@ namespace tinyxml2 class XMLElement; } -namespace gz +namespace gz::gui { - namespace gui - { class ApplicationPrivate; class Dialog; class MainWindow; @@ -214,11 +212,10 @@ namespace gz /// \return Pointer to running application, or nullptr if none is running. GZ_GUI_VISIBLE Application *App(); - } -} +} // namespace gz::gui #ifdef _MSC_VER #pragma warning(pop) #endif -#endif +#endif // GZ_GUI_APPLICATION_HH_ diff --git a/include/gz/gui/Conversions.hh b/include/gz/gui/Conversions.hh index 5ea10f116..44f1dd80d 100644 --- a/include/gz/gui/Conversions.hh +++ b/include/gz/gui/Conversions.hh @@ -27,15 +27,13 @@ #include "gz/gui/qt.h" #include "gz/gui/Export.hh" -namespace gz +namespace gz::common { - namespace common - { - class MouseEvent; - } + class MouseEvent; +} - namespace gui - { +namespace gz::gui +{ /// \brief Return the equivalent Qt color /// \param[in] _color Gazebo color to convert /// \return Qt color value @@ -95,6 +93,5 @@ namespace gz /// \return Gazebo key event GZ_GUI_VISIBLE common::KeyEvent convert(const QKeyEvent &_e); - } -} -#endif +} // namespace gz::gui +#endif // GZ_GUI_CONVERSIONS_HH_ diff --git a/include/gz/gui/Dialog.hh b/include/gz/gui/Dialog.hh index 2719c32f3..17261f485 100644 --- a/include/gz/gui/Dialog.hh +++ b/include/gz/gui/Dialog.hh @@ -31,10 +31,8 @@ #pragma warning(disable: 4251) #endif -namespace gz +namespace gz::gui { - namespace gui - { class DialogPrivate; /// \brief Gui plugin @@ -94,11 +92,10 @@ namespace gz /// \brief Private data pointer private: std::unique_ptr dataPtr; }; - } -} +} // namespace gz::gui #ifdef _MSC_VER #pragma warning(pop) #endif -#endif +#endif // GZ_GUI_DIALOG_HH_ diff --git a/include/gz/gui/DragDropModel.hh b/include/gz/gui/DragDropModel.hh index b4ffa0271..cacd688f4 100644 --- a/include/gz/gui/DragDropModel.hh +++ b/include/gz/gui/DragDropModel.hh @@ -20,9 +20,7 @@ #include "gz/gui/Export.hh" #include "gz/gui/qt.h" -namespace gz -{ -namespace gui +namespace gz::gui { /// \brief Customized item model so that we can pass along an URI query as /// MIME information during a drag-drop. @@ -33,6 +31,5 @@ namespace gui /// \return Mime data for the selected items. public: QMimeData *mimeData(const QModelIndexList &_indexes) const; }; -} -} -#endif +} // namespaced gz::gui +#endif // GZ_GUI_DRAGDROPMODEL_HH_ diff --git a/include/gz/gui/Enums.hh b/include/gz/gui/Enums.hh index b612fe6ea..43d8a2e76 100644 --- a/include/gz/gui/Enums.hh +++ b/include/gz/gui/Enums.hh @@ -20,9 +20,7 @@ #include "gz/gui/qt.h" -namespace gz -{ -namespace gui +namespace gz::gui { /// \brief Data roles enum DataRole @@ -81,6 +79,5 @@ namespace gui /// \brief Portable document format (PDF) PDFFile }; -} -} -#endif +} // namespace gz::gui +#endif // GZ_GUI_ENUMS_HH_ diff --git a/include/gz/gui/GuiEvents.hh b/include/gz/gui/GuiEvents.hh index fb5cf2efe..d7727df2b 100644 --- a/include/gz/gui/GuiEvents.hh +++ b/include/gz/gui/GuiEvents.hh @@ -32,13 +32,8 @@ #include "gz/gui/Export.hh" -namespace gz +namespace gz::gui::events { - namespace gui - { - /// \brief Namespace for all events. - namespace events - { /// User defined events should start from QEvent::MaxUser and /// count down to avoid collision with gz-sim events @@ -486,8 +481,6 @@ namespace gz /// \brief Private data pointer GZ_UTILS_IMPL_PTR(dataPtr) }; - } - } -} +} // namespace gz::gui::events #endif // GZ_GUI_GUIEVENTS_HH_ diff --git a/include/gz/gui/Helpers.hh b/include/gz/gui/Helpers.hh index 33c5a405d..e5fac0810 100644 --- a/include/gz/gui/Helpers.hh +++ b/include/gz/gui/Helpers.hh @@ -22,10 +22,8 @@ #include "gz/gui/Enums.hh" #include "gz/gui/Export.hh" -namespace gz +namespace gz::gui { - namespace gui - { /// \brief Create a human readable key, capitalizing the first letter /// and removing characters like "_". /// \param[in] _key Non-human-readable key. @@ -121,6 +119,5 @@ namespace gz } return nullptr; } - } -} -#endif +} // namespace gz::gui +#endif // GZ_GUI_HELPERS_HH_ diff --git a/include/gz/gui/MainWindow.hh b/include/gz/gui/MainWindow.hh index 766b43e59..ca1baac2e 100644 --- a/include/gz/gui/MainWindow.hh +++ b/include/gz/gui/MainWindow.hh @@ -35,10 +35,8 @@ #pragma warning(disable: 4251) #endif -namespace gz +namespace gz::gui { - namespace gui - { Q_NAMESPACE class MainWindowPrivate; struct WindowConfig; @@ -676,11 +674,10 @@ namespace gz /// \brief Concatenation of all plugin configurations. std::string plugins{""}; }; - } -} +} // namespace gz::gui #ifdef _MSC_VER #pragma warning(pop) #endif -#endif +#endif // GZ_GUI_MAINWINDOW_HH_ diff --git a/include/gz/gui/PlottingInterface.hh b/include/gz/gui/PlottingInterface.hh index 2953d8c25..4ffa76838 100644 --- a/include/gz/gui/PlottingInterface.hh +++ b/include/gz/gui/PlottingInterface.hh @@ -38,9 +38,7 @@ #include "gz/gui/Export.hh" -namespace gz -{ -namespace gui +namespace gz::gui { class PlotDataPrivate; @@ -332,8 +330,5 @@ class GZ_GUI_VISIBLE PlottingInterface : public QObject /// \brief Private data member. private: std::unique_ptr dataPtr; }; - -} -} - -#endif +} // namespace gz::gui +#endif // GZ_GUI_PLOTTINGINTERFACE_HH_ diff --git a/include/gz/gui/Plugin.hh b/include/gz/gui/Plugin.hh index ede6220be..a70fd3dfc 100644 --- a/include/gz/gui/Plugin.hh +++ b/include/gz/gui/Plugin.hh @@ -31,10 +31,8 @@ #pragma warning(disable: 4251) #endif -namespace gz +namespace gz::gui { - namespace gui - { class PluginPrivate; /// \brief Base class for Gazebo GUI plugins. @@ -143,11 +141,10 @@ namespace gz /// \brief Pointer to private data private: std::unique_ptr dataPtr; }; - } -} +} // namespace gz::gui #ifdef _MSC_VER #pragma warning(pop) #endif -#endif +#endif // GZ_GUI_PLUGIN_HH_ diff --git a/include/gz/gui/SearchModel.hh b/include/gz/gui/SearchModel.hh index 02996911b..62adb291a 100644 --- a/include/gz/gui/SearchModel.hh +++ b/include/gz/gui/SearchModel.hh @@ -20,9 +20,7 @@ #include "gz/gui/Export.hh" #include "gz/gui/qt.h" -namespace gz -{ -namespace gui +namespace gz::gui { /// \brief Customize the proxy model to display search results. /// @@ -89,6 +87,5 @@ namespace gui /// \brief Full search string. public: QString search; }; -} -} -#endif +} // namespace gz::gui +#endif // GZ_GUI_SEARCHMODEL_HH_ diff --git a/include/gz/gui/config.hh.in b/include/gz/gui/config.hh.in index 6737ef44b..4916a4f02 100644 --- a/include/gz/gui/config.hh.in +++ b/include/gz/gui/config.hh.in @@ -32,4 +32,4 @@ #define GZ_GUI_PLUGIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins" -#endif +#endif // GZ_GUI_CONFIG_HH_ diff --git a/include/gz/gui/gz.hh b/include/gz/gui/gz.hh index 58b3aa66f..d753317d5 100644 --- a/include/gz/gui/gz.hh +++ b/include/gz/gui/gz.hh @@ -43,4 +43,4 @@ extern "C" GZ_GUI_VISIBLE void cmdEmptyWindow(); /// \param[in] _filename Path to a QSS file. extern "C" GZ_GUI_VISIBLE void cmdSetStyleFromFile(const char *_filename); -#endif +#endif // GZ_GUI_GZ_HH_ diff --git a/include/gz/gui/qt.h b/include/gz/gui/qt.h index 3da834cec..56970995a 100644 --- a/include/gz/gui/qt.h +++ b/include/gz/gui/qt.h @@ -42,5 +42,4 @@ #include #include - #endif // GZ_GUI_QT_H_ diff --git a/src/Application.cc b/src/Application.cc index eb63208b9..aa20ad15c 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -36,58 +36,51 @@ #include "gz/transport/TopicUtils.hh" -namespace gz +namespace gz::gui { - namespace gui - { - class ApplicationPrivate - { - /// \brief QML engine - public: QQmlApplicationEngine *engine{nullptr}; - - /// \brief Pointer to main window - public: MainWindow *mainWin{nullptr}; +class ApplicationPrivate +{ + /// \brief QML engine + public: QQmlApplicationEngine *engine{nullptr}; - /// \brief Vector of pointers to dialogs - public: std::vector dialogs; + /// \brief Pointer to main window + public: MainWindow *mainWin{nullptr}; - /// \brief Queue of plugins which should be added to the window - public: std::queue> pluginsToAdd; + /// \brief Vector of pointers to dialogs + public: std::vector dialogs; - /// \brief Vector of pointers to plugins already added, we hang on to - /// these until it is ok to unload the plugin's shared library. - public: std::vector> pluginsAdded; + /// \brief Queue of plugins which should be added to the window + public: std::queue> pluginsToAdd; - /// \brief Deprecated environment variable which holds paths to look for - /// plugins - public: std::string pluginPathEnvDeprecated = "IGN_GUI_PLUGIN_PATH"; + /// \brief Vector of pointers to plugins already added, we hang on to + /// these until it is ok to unload the plugin's shared library. + public: std::vector> pluginsAdded; - /// \brief Environment variable which holds paths to look for plugins - public: std::string pluginPathEnv = "GZ_GUI_PLUGIN_PATH"; + /// \brief Deprecated environment variable which holds paths to look for + /// plugins + public: std::string pluginPathEnvDeprecated = "IGN_GUI_PLUGIN_PATH"; - /// \brief Vector of paths to look for plugins - public: std::vector pluginPaths; + /// \brief Environment variable which holds paths to look for plugins + public: std::string pluginPathEnv = "GZ_GUI_PLUGIN_PATH"; - /// \brief Holds a configuration which may be applied to mainWin once it - /// is created by calling applyConfig(). It's no longer needed and - /// should not be used after that. - public: WindowConfig windowConfig; + /// \brief Vector of paths to look for plugins + public: std::vector pluginPaths; - /// \brief The path containing the default configuration file. - public: std::string defaultConfigPath; + /// \brief Holds a configuration which may be applied to mainWin once it + /// is created by calling applyConfig(). It's no longer needed and + /// should not be used after that. + public: WindowConfig windowConfig; - public: common::SignalHandler signalHandler; + /// \brief The path containing the default configuration file. + public: std::string defaultConfigPath; - /// \brief QT message handler that pipes qt messages into our console - /// system. - public: static void MessageHandler(QtMsgType _type, - const QMessageLogContext &_context, const QString &_msg); - }; - } -} + public: common::SignalHandler signalHandler; -using namespace gz; -using namespace gui; + /// \brief QT message handler that pipes qt messages into our console + /// system. + public: static void MessageHandler(QtMsgType _type, + const QMessageLogContext &_context, const QString &_msg); +}; ///////////////////////////////////////////////// Application::Application(int &_argc, char **_argv, const WindowType _type) @@ -214,7 +207,7 @@ QQmlApplicationEngine *Application::Engine() const } ///////////////////////////////////////////////// -Application *gz::gui::App() +Application *App() { return qobject_cast(qGuiApp); } @@ -868,3 +861,4 @@ void ApplicationPrivate::MessageHandler(QtMsgType _type, break; } } +} // namespace gz::gui diff --git a/src/Conversions.cc b/src/Conversions.cc index 3464ef7b2..6e2d6c292 100644 --- a/src/Conversions.cc +++ b/src/Conversions.cc @@ -21,8 +21,10 @@ #include "gz/gui/Conversions.hh" +namespace gz::gui +{ ////////////////////////////////////////////////// -QColor gz::gui::convert(const gz::math::Color &_color) +QColor convert(const gz::math::Color &_color) { return QColor(_color.R()*255.0, _color.G()*255.0, @@ -31,7 +33,7 @@ QColor gz::gui::convert(const gz::math::Color &_color) } ////////////////////////////////////////////////// -gz::math::Color gz::gui::convert(const QColor &_color) +gz::math::Color convert(const QColor &_color) { return gz::math::Color(_color.red() / 255.0, _color.green() / 255.0, @@ -40,31 +42,31 @@ gz::math::Color gz::gui::convert(const QColor &_color) } ////////////////////////////////////////////////// -QPointF gz::gui::convert(const gz::math::Vector2d &_pt) +QPointF convert(const gz::math::Vector2d &_pt) { return QPointF(_pt.X(), _pt.Y()); } ////////////////////////////////////////////////// -gz::math::Vector2d gz::gui::convert(const QPointF &_pt) +gz::math::Vector2d convert(const QPointF &_pt) { return gz::math::Vector2d(_pt.x(), _pt.y()); } ////////////////////////////////////////////////// -QVector3D gz::gui::convert(const gz::math::Vector3d &_vec) +QVector3D convert(const gz::math::Vector3d &_vec) { return QVector3D(_vec.X(), _vec.Y(), _vec.Z()); } ////////////////////////////////////////////////// -gz::math::Vector3d gz::gui::convert(const QVector3D &_vec) +gz::math::Vector3d convert(const QVector3D &_vec) { return gz::math::Vector3d(_vec.x(), _vec.y(), _vec.z()); } ////////////////////////////////////////////////// -gz::common::MouseEvent gz::gui::convert(const QMouseEvent &_e) +gz::common::MouseEvent convert(const QMouseEvent &_e) { common::MouseEvent event; event.SetPos(_e.pos().x(), _e.pos().y()); @@ -115,7 +117,7 @@ gz::common::MouseEvent gz::gui::convert(const QMouseEvent &_e) } ////////////////////////////////////////////////// -gz::common::MouseEvent gz::gui::convert(const QWheelEvent &_e) +gz::common::MouseEvent convert(const QWheelEvent &_e) { common::MouseEvent event; @@ -152,7 +154,7 @@ gz::common::MouseEvent gz::gui::convert(const QWheelEvent &_e) } ////////////////////////////////////////////////// -gz::common::KeyEvent gz::gui::convert(const QKeyEvent &_e) +gz::common::KeyEvent convert(const QKeyEvent &_e) { common::KeyEvent event; event.SetKey(_e.key()); @@ -177,4 +179,4 @@ gz::common::KeyEvent gz::gui::convert(const QKeyEvent &_e) return event; } - +} // namespace gz::gui diff --git a/src/Dialog.cc b/src/Dialog.cc index becaea62b..91a8b169c 100644 --- a/src/Dialog.cc +++ b/src/Dialog.cc @@ -21,20 +21,13 @@ #include "gz/gui/Application.hh" #include "gz/gui/Dialog.hh" -namespace gz +namespace gz::gui { - namespace gui - { - class DialogPrivate - { - /// \brief Pointer to quick window - public: QQuickWindow *quickWindow{nullptr}; - }; - } -} - -using namespace gz; -using namespace gui; +class DialogPrivate +{ + /// \brief Pointer to quick window + public: QQuickWindow *quickWindow{nullptr}; +}; ///////////////////////////////////////////////// Dialog::Dialog() @@ -57,9 +50,7 @@ Dialog::Dialog() } ///////////////////////////////////////////////// -Dialog::~Dialog() -{ -} +Dialog::~Dialog() = default; ///////////////////////////////////////////////// QQuickWindow *Dialog::QuickWindow() const @@ -176,3 +167,4 @@ std::string Dialog::ReadConfigAttribute(const std::string &_path, return std::string(); } +} // namespace gz::gui diff --git a/src/DragDropModel.cc b/src/DragDropModel.cc index 73a645c0d..9c1623634 100644 --- a/src/DragDropModel.cc +++ b/src/DragDropModel.cc @@ -18,9 +18,8 @@ #include "gz/gui/Enums.hh" #include "gz/gui/DragDropModel.hh" -using namespace gz; -using namespace gui; - +namespace gz::gui +{ ///////////////////////////////////////////////// QMimeData *DragDropModel::mimeData(const QModelIndexList &_indexes) const { @@ -39,4 +38,4 @@ QMimeData *DragDropModel::mimeData(const QModelIndexList &_indexes) const return curMimeData; } - +} // namespace gz::gui diff --git a/src/GuiEvents.cc b/src/GuiEvents.cc index 053e306c4..15b94ce9c 100644 --- a/src/GuiEvents.cc +++ b/src/GuiEvents.cc @@ -17,7 +17,9 @@ #include "gz/gui/GuiEvents.hh" -class gz::gui::events::SnapIntervals::Implementation +namespace gz::gui::events +{ +class SnapIntervals::Implementation { /// \brief XYZ snapping values in meters, these values must be positive. public: math::Vector3d xyz; @@ -31,85 +33,85 @@ class gz::gui::events::SnapIntervals::Implementation public: math::Vector3d scale; }; -class gz::gui::events::SpawnFromDescription::Implementation +class SpawnFromDescription::Implementation { /// \brief The string of the resource to be spawned. public: std::string description; }; -class gz::gui::events::SpawnFromPath::Implementation +class SpawnFromPath::Implementation { /// \brief The path of file to be previewed. public: std::string filePath; }; -class gz::gui::events::HoverToScene::Implementation +class HoverToScene::Implementation { /// \brief The 3D point over which the user is hovering. public: math::Vector3d point; }; -class gz::gui::events::HoverOnScene::Implementation +class HoverOnScene::Implementation { /// \brief The 2D point over which the user is hovering. public: common::MouseEvent mouse; }; -class gz::gui::events::LeftClickToScene::Implementation +class LeftClickToScene::Implementation { /// \brief The 3D point that the user clicked within the scene. public: math::Vector3d point; }; -class gz::gui::events::RightClickToScene::Implementation +class RightClickToScene::Implementation { /// \brief The 3D point that the user clicked within the scene. public: math::Vector3d point; }; -class gz::gui::events::DropdownMenuEnabled::Implementation +class DropdownMenuEnabled::Implementation { /// \brief The boolean indicating whether the menu is disabled or not /// for this event. public: bool menuEnabled; }; -class gz::gui::events::LeftClickOnScene::Implementation +class LeftClickOnScene::Implementation { /// \brief Mouse event public: common::MouseEvent mouse; }; -class gz::gui::events::RightClickOnScene::Implementation +class RightClickOnScene::Implementation { /// \brief Mouse event public: common::MouseEvent mouse; }; -class gz::gui::events::BlockOrbit::Implementation +class BlockOrbit::Implementation { public: bool block; }; -class gz::gui::events::KeyReleaseOnScene::Implementation +class KeyReleaseOnScene::Implementation { /// \brief Key event public: common::KeyEvent key; }; -class gz::gui::events::KeyPressOnScene::Implementation +class KeyPressOnScene::Implementation { /// \brief Key event public: common::KeyEvent key; }; -class gz::gui::events::SpawnCloneFromName::Implementation +class SpawnCloneFromName::Implementation { /// \brief The name of the resource to be cloned public: std::string name; }; -class gz::gui::events::DropOnScene::Implementation +class DropOnScene::Implementation { /// \brief The name of the dropped thing public: std::string dropText; @@ -118,38 +120,34 @@ class gz::gui::events::DropOnScene::Implementation public: gz::math::Vector2i mouse; }; -class gz::gui::events::ScrollOnScene::Implementation +class ScrollOnScene::Implementation { /// \brief Mouse event with scroll information. public: common::MouseEvent mouse; }; -class gz::gui::events::DragOnScene::Implementation +class DragOnScene::Implementation { /// \brief Mouse event with drag information. public: common::MouseEvent mouse; }; -class gz::gui::events::MousePressOnScene::Implementation +class MousePressOnScene::Implementation { /// \brief Mouse event with press information. public: common::MouseEvent mouse; }; -class gz::gui::events::WorldControl::Implementation +class WorldControl::Implementation { /// \brief WorldControl information. public: msgs::WorldControl worldControl; }; -class gz::gui::events::PreRender::Implementation +class PreRender::Implementation { }; -using namespace gz; -using namespace gui; -using namespace events; - ///////////////////////////////////////////////// SnapIntervals::SnapIntervals( const math::Vector3d &_xyz, @@ -430,3 +428,4 @@ PreRender::PreRender() : QEvent(kType), dataPtr(utils::MakeImpl()) { } +} // namespace gz::gui::events diff --git a/src/Helpers.cc b/src/Helpers.cc index 52c93a36d..657c3eca3 100644 --- a/src/Helpers.cc +++ b/src/Helpers.cc @@ -25,8 +25,10 @@ #include "gz/gui/Helpers.hh" #include "gz/gui/MainWindow.hh" +namespace gz::gui +{ ///////////////////////////////////////////////// -std::string gz::gui::humanReadable(const std::string &_key) +std::string humanReadable(const std::string &_key) { std::string humanKey = _key; humanKey[0] = toupper(humanKey[0]); @@ -35,7 +37,7 @@ std::string gz::gui::humanReadable(const std::string &_key) } ///////////////////////////////////////////////// -std::string gz::gui::unitFromKey(const std::string &_key, +std::string unitFromKey(const std::string &_key, const std::string &_type) { if (_key == "pos" || _key == "length" || _key == "min_depth") @@ -110,7 +112,7 @@ std::string gz::gui::unitFromKey(const std::string &_key, } ///////////////////////////////////////////////// -void gz::gui::rangeFromKey(const std::string &_key, double &_min, +void rangeFromKey(const std::string &_key, double &_min, double &_max) { // Maximum range by default @@ -139,19 +141,19 @@ void gz::gui::rangeFromKey(const std::string &_key, double &_min, } ///////////////////////////////////////////////// -gz::gui::StringType gz::gui::stringTypeFromKey( +StringType stringTypeFromKey( const std::string &_key) { if (_key == "innerxml") { - return gz::gui::StringType::PLAIN_TEXT; + return StringType::PLAIN_TEXT; } return StringType::LINE; } ///////////////////////////////////////////////// -std::string gz::gui::uniqueFilePath(const std::string &_pathAndName, +std::string uniqueFilePath(const std::string &_pathAndName, const std::string &_extension) { std::string result = _pathAndName + "." + _extension; @@ -168,7 +170,7 @@ std::string gz::gui::uniqueFilePath(const std::string &_pathAndName, } ///////////////////////////////////////////////// -QStringList gz::gui::worldNames() +QStringList worldNames() { auto win = App()->findChild(); if (nullptr == win) @@ -182,7 +184,7 @@ QStringList gz::gui::worldNames() } ///////////////////////////////////////////////// -std::string gz::gui::renderEngineName() +std::string renderEngineName() { auto win = App()->findChild(); if (nullptr == win) @@ -196,7 +198,8 @@ std::string gz::gui::renderEngineName() } ///////////////////////////////////////////////// -const QString gz::gui::qmlQrcImportPath() +const QString qmlQrcImportPath() { return "qrc:/gz-gui-qml/"; } +} // namespace gz::gui diff --git a/src/MainWindow.cc b/src/MainWindow.cc index c90d09a7a..3d2b98194 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -29,60 +29,53 @@ #include "gz/msgs/server_control.pb.h" #include "gz/transport/Node.hh" -namespace gz +namespace gz::gui { - namespace gui - { - class MainWindowPrivate - { - /// \brief Number of plugins on the window - public: int pluginCount{0}; +class MainWindowPrivate +{ + /// \brief Number of plugins on the window + public: int pluginCount{0}; - /// \brief Pointer to quick window - public: QQuickWindow *quickWindow{nullptr}; + /// \brief Pointer to quick window + public: QQuickWindow *quickWindow{nullptr}; - /// \brief Configuration for this window. - public: WindowConfig windowConfig; + /// \brief Configuration for this window. + public: WindowConfig windowConfig; - /// \brief Counts the times the window has been painted - public: unsigned int paintCount{0}; + /// \brief Counts the times the window has been painted + public: unsigned int paintCount{0}; - /// \brief Minimum number of paint events to consider the window to be - /// fully initialized. - public: const unsigned int paintCountMin{20}; + /// \brief Minimum number of paint events to consider the window to be + /// fully initialized. + public: const unsigned int paintCountMin{20}; - /// \brief The action executed when GUI is closed without prompt. - public: ExitAction defaultExitAction{ExitAction::CLOSE_GUI}; + /// \brief The action executed when GUI is closed without prompt. + public: ExitAction defaultExitAction{ExitAction::CLOSE_GUI}; - /// \brief Show the confirmation dialog on exit - public: bool showDialogOnExit{false}; + /// \brief Show the confirmation dialog on exit + public: bool showDialogOnExit{false}; - /// \brief Text of the prompt in the confirmation dialog on exit - public: QString dialogOnExitText; + /// \brief Text of the prompt in the confirmation dialog on exit + public: QString dialogOnExitText; - /// \brief Show "shutdown" button in exit dialog - public: bool exitDialogShowShutdown{false}; + /// \brief Show "shutdown" button in exit dialog + public: bool exitDialogShowShutdown{false}; - /// \brief Show "Close GUI" button in exit dialog - public: bool exitDialogShowCloseGui{true}; + /// \brief Show "Close GUI" button in exit dialog + public: bool exitDialogShowCloseGui{true}; - /// \brief Text of "shutdown" button in exit dialog - public: QString exitDialogShutdownText; + /// \brief Text of "shutdown" button in exit dialog + public: QString exitDialogShutdownText; - /// \brief Text of "Close GUI" button in exit dialog - public: QString exitDialogCloseGuiText; + /// \brief Text of "Close GUI" button in exit dialog + public: QString exitDialogCloseGuiText; - /// \brief Service to send server control requests - public: std::string controlService{"/server_control"}; + /// \brief Service to send server control requests + public: std::string controlService{"/server_control"}; - /// \brief Communication node - public: gz::transport::Node node; - }; - } -} - -using namespace gz; -using namespace gui; + /// \brief Communication node + public: gz::transport::Node node; +}; /// \brief Strip last component from a path. /// \return Original path without its last component. @@ -122,9 +115,7 @@ MainWindow::MainWindow() } ///////////////////////////////////////////////// -MainWindow::~MainWindow() -{ -} +MainWindow::~MainWindow() = default; ///////////////////////////////////////////////// QStringList MainWindow::PluginListModel() const @@ -1038,3 +1029,4 @@ void MainWindow::SetServerControlService(const std::string &_service) { this->dataPtr->controlService = _service; } +} // namespace gz::gui diff --git a/src/PlottingInterface.cc b/src/PlottingInterface.cc index ae158f2b7..cf125e31c 100644 --- a/src/PlottingInterface.cc +++ b/src/PlottingInterface.cc @@ -29,9 +29,7 @@ // 1/60 Period like the GuiSystem frequency (60Hz) #define MAX_PERIOD_DIFF (0.0166666667) -namespace gz -{ -namespace gui +namespace gz::gui { class PlotDataPrivate { @@ -45,7 +43,6 @@ class PlotDataPrivate public: std::set charts; }; - class TopicPrivate { /// \brief Check the plotable types and get data from reflection @@ -80,7 +77,7 @@ class TransportPrivate class PlottingIfacePrivate { /// \brief Responsible for transport messages and topics - public: Transport transport; + public: gui::Transport transport; /// \brief Plotting time pointer to give access to topics to read it public: std::shared_ptr plottingTimeRef = std::make_shared(); @@ -92,12 +89,6 @@ class PlottingIfacePrivate public: QTimer timer; }; -} -} - -using namespace gz; -using namespace gui; - ////////////////////////////////////////////////////// PlotData::PlotData() : dataPtr(std::make_unique()) @@ -106,9 +97,7 @@ PlotData::PlotData() : } ////////////////////////////////////////////////////// -PlotData::~PlotData() -{ -} +PlotData::~PlotData() = default; ////////////////////////////////////////////////////// void PlotData::SetValue(const double _value) @@ -505,9 +494,7 @@ PlottingInterface::PlottingInterface() : QObject(), } ////////////////////////////////////////////////////// -PlottingInterface::~PlottingInterface() -{ -} +PlottingInterface::~PlottingInterface() = default; ////////////////////////////////////////////////////// void PlottingInterface::unsubscribe(int _chart, @@ -677,3 +664,4 @@ bool PlottingInterface::exportCSV(QString _path, int _chart, } return true; } +} // namespace gz::gui diff --git a/src/Plugin.cc b/src/Plugin.cc index 9760db493..8dc4bdfc5 100644 --- a/src/Plugin.cc +++ b/src/Plugin.cc @@ -23,6 +23,8 @@ #include "gz/gui/MainWindow.hh" #include "gz/gui/Plugin.hh" +namespace +{ /// \brief Used to store information about anchors set by the user. struct Anchors { @@ -36,7 +38,7 @@ struct Anchors }; /// \brief Set of all possible lines. -static const std::unordered_set kAnchorLineSet{ +const std::unordered_set kAnchorLineSet{ "top", "bottom", "left", @@ -46,12 +48,15 @@ static const std::unordered_set kAnchorLineSet{ "baseline"}; /// \brief Properties which shouldn't be saved or loaded -static const std::unordered_set kIgnoredProps{ +const std::unordered_set kIgnoredProps{ "objectName", "pluginName", "anchored"}; +} // namespace -class gz::gui::PluginPrivate +namespace gz::gui +{ +class PluginPrivate { /// \brief Set this to true if the plugin should be deleted as soon as it has /// a parent. @@ -80,9 +85,6 @@ class gz::gui::PluginPrivate public: Anchors anchors; }; -using namespace gz; -using namespace gui; - ///////////////////////////////////////////////// Plugin::Plugin() : dataPtr(new PluginPrivate) { @@ -595,3 +597,4 @@ void Plugin::ApplyAnchors() } this->CardItem()->setProperty("anchored", true); } +} // namespace gz::gui diff --git a/src/SearchModel.cc b/src/SearchModel.cc index 3ccf2bbe3..6a41d93b1 100644 --- a/src/SearchModel.cc +++ b/src/SearchModel.cc @@ -20,9 +20,8 @@ #include "gz/gui/Enums.hh" #include "gz/gui/SearchModel.hh" -using namespace gz; -using namespace gui; - +namespace gz::gui +{ ///////////////////////////////////////////////// bool SearchModel::filterAcceptsRow(const int _srcRow, const QModelIndex &_srcParent) const @@ -155,4 +154,4 @@ void SearchModel::SetSearch(const QString &_search) // TopicsStats this->layoutChanged(); } - +} // namespace gz::gui diff --git a/src/plugins/camera_fps/CameraFps.cc b/src/plugins/camera_fps/CameraFps.cc index 9758ee5ff..4bc3d2b0a 100644 --- a/src/plugins/camera_fps/CameraFps.cc +++ b/src/plugins/camera_fps/CameraFps.cc @@ -29,8 +29,10 @@ #include "CameraFps.hh" +namespace gz::gui::plugins +{ /// \brief Private data class for CameraFps -class gz::gui::plugins::CameraFpsPrivate +class CameraFpsPrivate { /// \brief Previous camera update time public: std::optional @@ -50,10 +52,6 @@ class gz::gui::plugins::CameraFpsPrivate public: QString cameraFPSValue; }; -using namespace gz; -using namespace gui; -using namespace plugins; - ///////////////////////////////////////////////// void CameraFps::OnRender() { @@ -84,14 +82,12 @@ void CameraFps::OnRender() ///////////////////////////////////////////////// CameraFps::CameraFps() - : Plugin(), dataPtr(new CameraFpsPrivate) + : dataPtr(new CameraFpsPrivate) { } ///////////////////////////////////////////////// -CameraFps::~CameraFps() -{ -} +CameraFps::~CameraFps() = default; ///////////////////////////////////////////////// void CameraFps::LoadConfig(const tinyxml2::XMLElement *) @@ -125,6 +121,7 @@ void CameraFps::SetCameraFpsValue(const QString &_value) this->dataPtr->cameraFPSValue = _value; this->CameraFpsValueChanged(); } +} // namespace gz::gui::plugins // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::CameraFps, diff --git a/src/plugins/camera_fps/CameraFps.hh b/src/plugins/camera_fps/CameraFps.hh index 9cbb7b6d1..fb33d7f7f 100644 --- a/src/plugins/camera_fps/CameraFps.hh +++ b/src/plugins/camera_fps/CameraFps.hh @@ -22,11 +22,7 @@ #include "gz/gui/Plugin.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class CameraFpsPrivate; @@ -74,7 +70,6 @@ namespace plugins /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} -} -#endif +} // namespace gz::gui::plugins + +#endif // GZ_GUI_PLUGINS_CAMERAFPS_HH_ diff --git a/src/plugins/camera_tracking/CameraTracking.cc b/src/plugins/camera_tracking/CameraTracking.cc index 88f183972..99e526e03 100644 --- a/src/plugins/camera_tracking/CameraTracking.cc +++ b/src/plugins/camera_tracking/CameraTracking.cc @@ -38,8 +38,10 @@ #include "CameraTracking.hh" +namespace gz::gui::plugins +{ /// \brief Private data class for CameraTracking -class gz::gui::plugins::CameraTrackingPrivate +class CameraTrackingPrivate { /// \brief Perform rendering calls in the rendering thread. public: void OnRender(); @@ -153,10 +155,6 @@ class gz::gui::plugins::CameraTrackingPrivate public: QTimer *timer{nullptr}; }; -using namespace gz; -using namespace gui; -using namespace plugins; - ///////////////////////////////////////////////// void CameraTrackingPrivate::Initialize() { @@ -429,7 +427,7 @@ void CameraTrackingPrivate::OnRender() ///////////////////////////////////////////////// CameraTracking::CameraTracking() - : Plugin(), dataPtr(new CameraTrackingPrivate) + : dataPtr(new CameraTrackingPrivate) { this->dataPtr->timer = new QTimer(this); this->connect(this->dataPtr->timer, &QTimer::timeout, [=]() @@ -448,9 +446,7 @@ CameraTracking::CameraTracking() } ///////////////////////////////////////////////// -CameraTracking::~CameraTracking() -{ -} +CameraTracking::~CameraTracking() = default; ///////////////////////////////////////////////// void CameraTracking::LoadConfig(const tinyxml2::XMLElement *) @@ -494,6 +490,7 @@ bool CameraTracking::eventFilter(QObject *_obj, QEvent *_event) // Standard event processing return QObject::eventFilter(_obj, _event); } +} // namespace gz::gui::plugins // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::CameraTracking, diff --git a/src/plugins/camera_tracking/CameraTracking.hh b/src/plugins/camera_tracking/CameraTracking.hh index 2e2b38904..68176e2c5 100644 --- a/src/plugins/camera_tracking/CameraTracking.hh +++ b/src/plugins/camera_tracking/CameraTracking.hh @@ -22,11 +22,7 @@ #include "gz/gui/Plugin.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class CameraTrackingPrivate; @@ -64,7 +60,6 @@ namespace plugins /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} -} -#endif +} // namespace gz::gui::plugins + +#endif // GZ_GUI_PLUGINS_CAMERATRACKING_HH_ diff --git a/src/plugins/grid_config/GridConfig.cc b/src/plugins/grid_config/GridConfig.cc index 6a7ce375c..d7d0d5717 100644 --- a/src/plugins/grid_config/GridConfig.cc +++ b/src/plugins/grid_config/GridConfig.cc @@ -81,14 +81,10 @@ namespace gz::gui /// \brief Visible state bool visible{true}; }; -} - -using namespace gz; -using namespace gui; ///////////////////////////////////////////////// GridConfig::GridConfig() - : gz::gui::Plugin(), dataPtr(std::make_unique()) + : dataPtr(std::make_unique()) { } @@ -409,7 +405,8 @@ void GridConfig::RefreshList() this->OnName(this->dataPtr->nameList.at(0)); this->NameListChanged(); } +} // namespace gz::gui // Register this plugin -GZ_ADD_PLUGIN(GridConfig, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::GridConfig, + gz::gui::Plugin) diff --git a/src/plugins/grid_config/GridConfig.hh b/src/plugins/grid_config/GridConfig.hh index aa951f1c9..ae11fcab5 100644 --- a/src/plugins/grid_config/GridConfig.hh +++ b/src/plugins/grid_config/GridConfig.hh @@ -22,9 +22,7 @@ #include -namespace gz -{ -namespace gui +namespace gz::gui { class GridConfigPrivate; @@ -143,7 +141,6 @@ namespace gui /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} +} // namespace gz::gui -#endif +#endif // GZ_GUI_GRIDCONFIG_HH_ diff --git a/src/plugins/image_display/ImageDisplay.cc b/src/plugins/image_display/ImageDisplay.cc index 59fb0ec86..20c7730e5 100644 --- a/src/plugins/image_display/ImageDisplay.cc +++ b/src/plugins/image_display/ImageDisplay.cc @@ -33,40 +33,29 @@ #include "gz/gui/Application.hh" #include "gz/gui/MainWindow.hh" -namespace gz +namespace gz::gui::plugins { -namespace gui +class ImageDisplayPrivate { -namespace plugins -{ - class ImageDisplayPrivate - { - /// \brief List of topics publishing image messages. - public: QStringList topicList; - - /// \brief Holds data to set as the next image - public: msgs::Image imageMsg; + /// \brief List of topics publishing image messages. + public: QStringList topicList; - /// \brief Node for communication. - public: transport::Node node; + /// \brief Holds data to set as the next image + public: msgs::Image imageMsg; - /// \brief Mutex for accessing image data - public: std::recursive_mutex imageMutex; + /// \brief Node for communication. + public: transport::Node node; - /// \brief To provide images for QML. - public: ImageProvider *provider{nullptr}; - }; -} -} -} + /// \brief Mutex for accessing image data + public: std::recursive_mutex imageMutex; -using namespace gz; -using namespace gui; -using namespace plugins; + /// \brief To provide images for QML. + public: ImageProvider *provider{nullptr}; +}; ///////////////////////////////////////////////// ImageDisplay::ImageDisplay() - : Plugin(), dataPtr(new ImageDisplayPrivate) + : dataPtr(new ImageDisplayPrivate) { } @@ -273,7 +262,8 @@ void ImageDisplay::SetTopicList(const QStringList &_topicList) this->dataPtr->topicList = _topicList; this->TopicListChanged(); } +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(ImageDisplay, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::plugins::ImageDisplay, + gz::gui::Plugin) diff --git a/src/plugins/image_display/ImageDisplay.hh b/src/plugins/image_display/ImageDisplay.hh index 838757a02..c5a3aa8e3 100644 --- a/src/plugins/image_display/ImageDisplay.hh +++ b/src/plugins/image_display/ImageDisplay.hh @@ -36,11 +36,7 @@ #include "gz/gui/Plugin.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class ImageDisplayPrivate; @@ -136,8 +132,6 @@ namespace plugins /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_IMAGEDISPLAY_HH_ diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.cc b/src/plugins/interactive_view_control/InteractiveViewControl.cc index 1f1785b69..718a9e456 100644 --- a/src/plugins/interactive_view_control/InteractiveViewControl.cc +++ b/src/plugins/interactive_view_control/InteractiveViewControl.cc @@ -43,8 +43,10 @@ #include "InteractiveViewControl.hh" +namespace gz::gui::plugins +{ /// \brief Private data class for InteractiveViewControl -class gz::gui::plugins::InteractiveViewControlPrivate +class InteractiveViewControlPrivate { /// \brief Perform rendering calls in the rendering thread. public: void OnRender(); @@ -144,10 +146,6 @@ class gz::gui::plugins::InteractiveViewControlPrivate public: double viewControlSensitivity = 1.0; }; -using namespace gz; -using namespace gui; -using namespace plugins; - ///////////////////////////////////////////////// void InteractiveViewControlPrivate::OnRender() { @@ -389,7 +387,7 @@ bool InteractiveViewControlPrivate::OnViewControlSensitivity( ///////////////////////////////////////////////// InteractiveViewControl::InteractiveViewControl() - : Plugin(), dataPtr(std::make_unique()) + : dataPtr(std::make_unique()) { } @@ -502,6 +500,7 @@ bool InteractiveViewControl::eventFilter(QObject *_obj, QEvent *_event) // Standard event processing return QObject::eventFilter(_obj, _event); } +} // namespace gz::gui::plugins // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::InteractiveViewControl, diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.hh b/src/plugins/interactive_view_control/InteractiveViewControl.hh index fdde25292..67e986505 100644 --- a/src/plugins/interactive_view_control/InteractiveViewControl.hh +++ b/src/plugins/interactive_view_control/InteractiveViewControl.hh @@ -22,11 +22,7 @@ #include "gz/gui/Plugin.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class InteractiveViewControlPrivate; @@ -70,8 +66,6 @@ namespace plugins /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_INTERACTIVEVIEWCONTROL_HH_ diff --git a/src/plugins/key_publisher/KeyPublisher.cc b/src/plugins/key_publisher/KeyPublisher.cc index 81c6c8e78..3c9eecc89 100644 --- a/src/plugins/key_publisher/KeyPublisher.cc +++ b/src/plugins/key_publisher/KeyPublisher.cc @@ -25,38 +25,31 @@ #include "KeyPublisher.hh" -namespace gz +namespace gz::gui { -namespace gui +class KeyPublisherPrivate { - class KeyPublisherPrivate - { - /// \brief Node for communication - public: gz::transport::Node node; - - /// \brief Publisher - public: gz::transport::Node::Publisher pub; + /// \brief Node for communication + public: gz::transport::Node node; - /// \brief Topic - public: std::string topic = "keyboard/keypress"; + /// \brief Publisher + public: gz::transport::Node::Publisher pub; - /// \brief Publish keyboard strokes - /// \param[in] key_press Pointer to the keyevent - public: void KeyPub(QKeyEvent *_keyPress) - { - gz::msgs::Int32 Msg; - Msg.set_data(_keyPress->key()); - pub.Publish(Msg); - } - }; -} -} + /// \brief Topic + public: std::string topic = "keyboard/keypress"; -using namespace gz; -using namespace gui; + /// \brief Publish keyboard strokes + /// \param[in] key_press Pointer to the keyevent + public: void KeyPub(QKeyEvent *_keyPress) + { + gz::msgs::Int32 Msg; + Msg.set_data(_keyPress->key()); + pub.Publish(Msg); + } +}; ///////////////////////////////////////////////// -KeyPublisher::KeyPublisher(): Plugin(), dataPtr(new KeyPublisherPrivate) +KeyPublisher::KeyPublisher(): dataPtr(new KeyPublisherPrivate) { // Advertise publisher node this->dataPtr->pub = this->dataPtr->node.Advertise @@ -64,9 +57,7 @@ KeyPublisher::KeyPublisher(): Plugin(), dataPtr(new KeyPublisherPrivate) } ///////////////////////////////////////////////// -KeyPublisher::~KeyPublisher() -{ -} +KeyPublisher::~KeyPublisher() = default; ///////////////////////////////////////////////// void KeyPublisher::LoadConfig(const tinyxml2::XMLElement *) @@ -88,7 +79,8 @@ bool KeyPublisher::eventFilter(QObject *_obj, QEvent *_event) } return QObject::eventFilter(_obj, _event); } +} // namespace gz::gui // Register this plugin -GZ_ADD_PLUGIN(KeyPublisher, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::KeyPublisher, + gz::gui::Plugin) diff --git a/src/plugins/key_publisher/KeyPublisher.hh b/src/plugins/key_publisher/KeyPublisher.hh index c6e0d5d31..dc350b672 100644 --- a/src/plugins/key_publisher/KeyPublisher.hh +++ b/src/plugins/key_publisher/KeyPublisher.hh @@ -35,9 +35,7 @@ #include #include -namespace gz -{ -namespace gui +namespace gz::gui { class KeyPublisherPrivate; @@ -68,7 +66,6 @@ namespace gui /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} +} // namespace gz::gui -#endif +#endif // GZ_GUI_PLUGINS_KEYPUBLISHER_HH_ diff --git a/src/plugins/marker_manager/MarkerManager.cc b/src/plugins/marker_manager/MarkerManager.cc index 379efa725..864029582 100644 --- a/src/plugins/marker_manager/MarkerManager.cc +++ b/src/plugins/marker_manager/MarkerManager.cc @@ -49,8 +49,10 @@ #include "MarkerManager.hh" +namespace gz::gui::plugins +{ /// \brief Private data class for MarkerManager -class gz::gui::plugins::MarkerManagerPrivate +class MarkerManagerPrivate { /// \brief Update markers based on msgs received public: void OnRender(); @@ -140,10 +142,6 @@ class gz::gui::plugins::MarkerManagerPrivate public: bool warnOnActionFailure{true}; }; -using namespace gz; -using namespace gui; -using namespace plugins; - ///////////////////////////////////////////////// void MarkerManagerPrivate::Initialize() { @@ -661,14 +659,12 @@ void MarkerManagerPrivate::OnWorldStatsMsg( ///////////////////////////////////////////////// MarkerManager::MarkerManager() - : Plugin(), dataPtr(new MarkerManagerPrivate) + : dataPtr(new MarkerManagerPrivate) { } ///////////////////////////////////////////////// -MarkerManager::~MarkerManager() -{ -} +MarkerManager::~MarkerManager() = default; ///////////////////////////////////////////////// void MarkerManager::LoadConfig(const tinyxml2::XMLElement * _pluginElem) @@ -777,6 +773,7 @@ bool MarkerManager::eventFilter(QObject *_obj, QEvent *_event) // Standard event processing return QObject::eventFilter(_obj, _event); } +} // namespace gz::gui::plugins // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::MarkerManager, diff --git a/src/plugins/marker_manager/MarkerManager.hh b/src/plugins/marker_manager/MarkerManager.hh index e47369dcd..704fb78c2 100644 --- a/src/plugins/marker_manager/MarkerManager.hh +++ b/src/plugins/marker_manager/MarkerManager.hh @@ -22,11 +22,7 @@ #include "gz/gui/Plugin.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class MarkerManagerPrivate; @@ -62,7 +58,6 @@ namespace plugins /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} -} -#endif +} // namespace gz::gui::plugins + +#endif // GZ_GUI_PLUGINS_MARKERMANAGER_HH_ diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index 443390844..ce64802b5 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -52,8 +52,10 @@ Q_DECLARE_METATYPE(gz::gui::plugins::RenderSync*) +namespace gz::gui::plugins +{ /// \brief Private data class for GzRenderer -class gz::gui::plugins::GzRenderer::Implementation +class GzRenderer::Implementation { /// \brief Flag to indicate if mouse event is dirty public: bool mouseDirty{false}; @@ -145,7 +147,7 @@ class gz::gui::plugins::GzRenderer::Implementation /// /// For more info see /// https://github.com/gazebosim/gz-rendering/issues/304 -class gz::gui::plugins::RenderSync +class RenderSync { /// \brief Cond. variable to synchronize rendering on specific events /// (e.g. texture resize) or for debugging (e.g. keep @@ -230,10 +232,6 @@ class gz::gui::plugins::MinimalScene::Implementation { }; -using namespace gz; -using namespace gui; -using namespace plugins; - QList RenderWindowItem::Implementation::threads; ///////////////////////////////////////////////// @@ -1471,6 +1469,7 @@ void MinimalScene::SetLoadingError(const QString &_loadingError) this->loadingError = _loadingError; this->LoadingErrorChanged(); } +} // namespace gz::gui::plugins // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::MinimalScene, diff --git a/src/plugins/minimal_scene/MinimalScene.hh b/src/plugins/minimal_scene/MinimalScene.hh index 67a88592d..c6cd85607 100644 --- a/src/plugins/minimal_scene/MinimalScene.hh +++ b/src/plugins/minimal_scene/MinimalScene.hh @@ -33,11 +33,7 @@ #include "MinimalSceneRhi.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { /// \brief Creates a Gazebo rendering scene and user camera. /// It is possible to orbit the camera around the scene with @@ -483,8 +479,6 @@ namespace plugins /// \brief Pointer to render interface to handle OpenGL/Metal compatibility private: std::unique_ptr rhi; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_MINIMALSCENE_HH_ diff --git a/src/plugins/minimal_scene/MinimalSceneRhi.cc b/src/plugins/minimal_scene/MinimalSceneRhi.cc index e2c506512..32a4498cb 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhi.cc +++ b/src/plugins/minimal_scene/MinimalSceneRhi.cc @@ -17,10 +17,8 @@ #include "MinimalSceneRhi.hh" -using namespace gz; -using namespace gui; -using namespace plugins; - +namespace gz::gui::plugins +{ ///////////////////////////////////////////////// GzCameraTextureRhi::~GzCameraTextureRhi() = default; @@ -53,3 +51,4 @@ void RenderThreadRhi::SetContext(QOpenGLContext *) //NOLINT ///////////////////////////////////////////////// TextureNodeRhi::~TextureNodeRhi() = default; +} // namespace gz::gui::plugins diff --git a/src/plugins/minimal_scene/MinimalSceneRhi.hh b/src/plugins/minimal_scene/MinimalSceneRhi.hh index ac67a574d..baff5395c 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhi.hh +++ b/src/plugins/minimal_scene/MinimalSceneRhi.hh @@ -26,11 +26,7 @@ #include #include -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { /// \brief Render interface class to handle OpenGL / Metal compatibility /// of camera textures in GzRenderer @@ -125,8 +121,6 @@ namespace plugins /// pending texture public: virtual void PrepareNode() = 0; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_MINIMALSCENE_MINIMALSCENERHI_HH_ diff --git a/src/plugins/minimal_scene/MinimalSceneRhiMetal.hh b/src/plugins/minimal_scene/MinimalSceneRhiMetal.hh index 106149e1a..65c0e3938 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiMetal.hh +++ b/src/plugins/minimal_scene/MinimalSceneRhiMetal.hh @@ -28,11 +28,7 @@ #include #include -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { /// \brief Private data for GzCameraTextureRhiMetal class GzCameraTextureRhiMetalPrivate; @@ -129,8 +125,6 @@ namespace plugins /// \internal Pointer to private data private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_MINIMALSCENE_MINIMALSCENERHIMETAL_HH_ diff --git a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc index c196aef2c..1309c13e4 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc +++ b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc @@ -30,11 +30,7 @@ #include ///////////////////////////////////////////////// -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class GzCameraTextureRhiOpenGLPrivate { @@ -59,13 +55,6 @@ namespace plugins public: QSGTexture *texture = nullptr; public: QQuickWindow *window = nullptr; }; -} -} -} - -using namespace gz; -using namespace gui; -using namespace plugins; ///////////////////////////////////////////////// GzCameraTextureRhiOpenGL::~GzCameraTextureRhiOpenGL() = default; @@ -291,3 +280,4 @@ void TextureNodeRhiOpenGL::PrepareNode() #endif } } +} // namespace gz::gui::plugins diff --git a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.hh b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.hh index 754cfa318..03d67a2e7 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.hh +++ b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.hh @@ -28,11 +28,7 @@ #include #include -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { /// \brief Private data for GzCameraTextureRhiOpenGL class GzCameraTextureRhiOpenGLPrivate; @@ -141,8 +137,6 @@ namespace plugins /// \internal Pointer to private data private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_MINIMALSCENE_MINIMALSCENERHIOPENGL_HH_ diff --git a/src/plugins/navsat_map/NavSatMap.cc b/src/plugins/navsat_map/NavSatMap.cc index 80684c1a9..78f3e5327 100644 --- a/src/plugins/navsat_map/NavSatMap.cc +++ b/src/plugins/navsat_map/NavSatMap.cc @@ -29,44 +29,31 @@ #include "gz/gui/Application.hh" -namespace gz +namespace gz::gui::plugins { -namespace gui +class NavSatMapPrivate { -namespace plugins -{ - class NavSatMapPrivate - { - /// \brief List of topics publishing navSat messages. - public: QStringList topicList; + /// \brief List of topics publishing navSat messages. + public: QStringList topicList; - /// \brief Holds data to set as the next navSat - public: msgs::NavSat navSatMsg; + /// \brief Holds data to set as the next navSat + public: msgs::NavSat navSatMsg; - /// \brief Node for communication. - public: transport::Node node; - - /// \brief Mutex for accessing navSat data - public: std::recursive_mutex navSatMutex; - }; -} -} -} + /// \brief Node for communication. + public: transport::Node node; -using namespace gz; -using namespace gui; -using namespace plugins; + /// \brief Mutex for accessing navSat data + public: std::recursive_mutex navSatMutex; +}; ///////////////////////////////////////////////// NavSatMap::NavSatMap() - : Plugin(), dataPtr(new NavSatMapPrivate) + : dataPtr(new NavSatMapPrivate) { } ///////////////////////////////////////////////// -NavSatMap::~NavSatMap() -{ -} +NavSatMap::~NavSatMap() = default; ///////////////////////////////////////////////// void NavSatMap::LoadConfig(const tinyxml2::XMLElement *_pluginElem) @@ -185,6 +172,7 @@ void NavSatMap::SetTopicList(const QStringList &_topicList) this->dataPtr->topicList = _topicList; this->TopicListChanged(); } +} // namespace gz::gui::plugins // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::NavSatMap, diff --git a/src/plugins/navsat_map/NavSatMap.hh b/src/plugins/navsat_map/NavSatMap.hh index 91e924172..565b96374 100644 --- a/src/plugins/navsat_map/NavSatMap.hh +++ b/src/plugins/navsat_map/NavSatMap.hh @@ -15,8 +15,8 @@ * */ -#ifndef GZ_GUI_PLUGINS_IMAGEDISPLAY_HH_ -#define GZ_GUI_PLUGINS_IMAGEDISPLAY_HH_ +#ifndef GZ_GUI_PLUGINS_NAVSAT_MAP_HH_ +#define GZ_GUI_PLUGINS_NAVSAT_MAP_HH_ #include @@ -24,11 +24,7 @@ #include "gz/gui/Plugin.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class NavSatMapPrivate; @@ -94,8 +90,6 @@ namespace plugins /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_NAVSAT_MAP_HH_ diff --git a/src/plugins/plotting/TransportPlotting.cc b/src/plugins/plotting/TransportPlotting.cc index 220d85a1b..57b53dfb6 100644 --- a/src/plugins/plotting/TransportPlotting.cc +++ b/src/plugins/plotting/TransportPlotting.cc @@ -17,13 +17,10 @@ #include #include "TransportPlotting.hh" -using namespace gz; -using namespace gui; -using namespace plugins; - -TransportPlotting::~TransportPlotting() +namespace gz::gui::plugins { -} +////////////////////////////////////////// +TransportPlotting::~TransportPlotting() = default; ////////////////////////////////////////// void TransportPlotting::LoadConfig(const tinyxml2::XMLElement *) @@ -33,12 +30,12 @@ void TransportPlotting::LoadConfig(const tinyxml2::XMLElement *) } ////////////////////////////////////////// -TransportPlotting::TransportPlotting() : Plugin(), +TransportPlotting::TransportPlotting() : dataPtr(new PlottingInterface) { } +} // namespace gz::gui::plugins // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::TransportPlotting, gz::gui::Plugin) - diff --git a/src/plugins/plotting/TransportPlotting.hh b/src/plugins/plotting/TransportPlotting.hh index ab502cf6c..cc1887915 100644 --- a/src/plugins/plotting/TransportPlotting.hh +++ b/src/plugins/plotting/TransportPlotting.hh @@ -14,6 +14,7 @@ * limitations under the License. * */ + #ifndef GZ_GUI_PLUGINS_TRANSPORTPLOTTING_HH_ #define GZ_GUI_PLUGINS_TRANSPORTPLOTTING_HH_ @@ -23,13 +24,8 @@ #include -namespace gz -{ -namespace gui +namespace gz::gui::plugins { -namespace plugins -{ - /// \brief Plots fields from Gazebo Transport topics. /// Fields can be dragged from the Topic Viewer or the Component Inspector. class TransportPlotting : public gz::gui::Plugin @@ -50,8 +46,6 @@ class TransportPlotting : public gz::gui::Plugin private: std::unique_ptr dataPtr; GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; +} // namespace gz::gui::plugins -} -} -} -#endif +#endif // GZ_GUI_PLUGINS_TRANSPORTPLOTTING_HH_ diff --git a/src/plugins/point_cloud/PointCloud.cc b/src/plugins/point_cloud/PointCloud.cc index f5a27cbf8..34c184e4e 100644 --- a/src/plugins/point_cloud/PointCloud.cc +++ b/src/plugins/point_cloud/PointCloud.cc @@ -40,8 +40,10 @@ #include "PointCloud.hh" +namespace gz::gui::plugins +{ /// \brief Private data class for PointCloud -class gz::gui::plugins::PointCloudPrivate +class PointCloudPrivate { /// \brief Makes a request to populate the scene with markers public: void PublishMarkers(); @@ -92,14 +94,9 @@ class gz::gui::plugins::PointCloudPrivate public: bool showing{true}; }; -using namespace gz; -using namespace gui; -using namespace plugins; - ///////////////////////////////////////////////// PointCloud::PointCloud() - : gz::gui::Plugin(), - dataPtr(std::make_unique()) + : dataPtr(std::make_unique()) { } @@ -516,7 +513,8 @@ void PointCloud::SetPointSize(float _pointSize) this->PointSizeChanged(); this->dataPtr->PublishMarkers(); } +} // namespace gz::gui::plugins // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::PointCloud, - gz::gui::Plugin) + gz::gui::Plugin) diff --git a/src/plugins/point_cloud/PointCloud.hh b/src/plugins/point_cloud/PointCloud.hh index 0cb2f2dea..2b5a9f8da 100644 --- a/src/plugins/point_cloud/PointCloud.hh +++ b/src/plugins/point_cloud/PointCloud.hh @@ -25,11 +25,7 @@ #include "gz/gui/Plugin.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class PointCloudPrivate; @@ -238,7 +234,6 @@ namespace plugins /// \brief Pointer to private data private: std::unique_ptr dataPtr; }; -} -} -} -#endif +} // namespace gz::gui::plugins + +#endif // GZ_GUI_PLUGINS_POINTCLOUD_HH_ diff --git a/src/plugins/publisher/Publisher.cc b/src/plugins/publisher/Publisher.cc index 7a81d7580..bbaa72477 100644 --- a/src/plugins/publisher/Publisher.cc +++ b/src/plugins/publisher/Publisher.cc @@ -23,53 +23,40 @@ #include "Publisher.hh" -namespace gz +namespace gz::gui::plugins { -namespace gui +class PublisherPrivate { -namespace plugins -{ - class PublisherPrivate - { - /// \brief Message type - public: QString msgType = "gz.msgs.StringMsg"; + /// \brief Message type + public: QString msgType = "gz.msgs.StringMsg"; - /// \brief Message contents - public: QString msgData = "data: \"Hello\""; + /// \brief Message contents + public: QString msgData = "data: \"Hello\""; - /// \brief Topic - public: QString topic = "/echo"; + /// \brief Topic + public: QString topic = "/echo"; - /// \brief Frequency - public: double frequency = 1.0; + /// \brief Frequency + public: double frequency = 1.0; - /// \brief Timer to keep publishing - public: QTimer *timer; + /// \brief Timer to keep publishing + public: QTimer *timer; - /// \brief Node for communication - public: gz::transport::Node node; - - /// \brief Publisher - public: gz::transport::Node::Publisher pub; - }; -} -} -} + /// \brief Node for communication + public: gz::transport::Node node; -using namespace gz; -using namespace gui; -using namespace plugins; + /// \brief Publisher + public: gz::transport::Node::Publisher pub; +}; ///////////////////////////////////////////////// Publisher::Publisher() - : Plugin(), dataPtr(new PublisherPrivate) + : dataPtr(new PublisherPrivate) { } ///////////////////////////////////////////////// -Publisher::~Publisher() -{ -} +Publisher::~Publisher() = default; ///////////////////////////////////////////////// void Publisher::LoadConfig(const tinyxml2::XMLElement *_pluginElem) @@ -206,7 +193,8 @@ void Publisher::SetFrequency(const double _frequency) this->dataPtr->frequency = _frequency; this->FrequencyChanged(); } +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(Publisher, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::plugins::Publisher, + gz::gui::Plugin) diff --git a/src/plugins/publisher/Publisher.hh b/src/plugins/publisher/Publisher.hh index db193c88b..83cad8641 100644 --- a/src/plugins/publisher/Publisher.hh +++ b/src/plugins/publisher/Publisher.hh @@ -32,11 +32,7 @@ # endif #endif -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class PublisherPrivate; @@ -147,8 +143,6 @@ namespace plugins /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_PUBLISHER_HH_ diff --git a/src/plugins/screenshot/Screenshot.cc b/src/plugins/screenshot/Screenshot.cc index d30677a8f..9a7e57b16 100644 --- a/src/plugins/screenshot/Screenshot.cc +++ b/src/plugins/screenshot/Screenshot.cc @@ -32,44 +32,32 @@ #include "gz/gui/GuiEvents.hh" #include "gz/gui/MainWindow.hh" -namespace gz +namespace gz::gui::plugins { -namespace gui +class ScreenshotPrivate { -namespace plugins -{ - class ScreenshotPrivate - { - /// \brief Node for communication - public: gz::transport::Node node; - - /// \brief Screenshot service name - public: std::string screenshotService; + /// \brief Node for communication + public: gz::transport::Node node; - /// \brief Directory to save screenshots - public: std::string directory; + /// \brief Screenshot service name + public: std::string screenshotService; - /// \brief Whether a screenshot has been requested but not processed yet. - public: bool dirty{false}; + /// \brief Directory to save screenshots + public: std::string directory; - /// \brief Pointer to the user camera. - public: gz::rendering::CameraPtr userCamera{nullptr}; + /// \brief Whether a screenshot has been requested but not processed yet. + public: bool dirty{false}; - /// \brief Saved screenshot filepath - public: QString savedScreenshotPath = ""; - }; -} -} -} + /// \brief Pointer to the user camera. + public: gz::rendering::CameraPtr userCamera{nullptr}; -using namespace gz; -using namespace gui; -using namespace plugins; + /// \brief Saved screenshot filepath + public: QString savedScreenshotPath = ""; +}; ///////////////////////////////////////////////// Screenshot::Screenshot() - : gui::Plugin(), - dataPtr(std::make_unique()) + : dataPtr(std::make_unique()) { std::string home; common::env(GZ_HOMEDIR, home); @@ -226,7 +214,8 @@ void Screenshot::SetSavedScreenshotPath(const QString &_filename) this->SavedScreenshotPathChanged(); this->savedScreenshot(); } +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(Screenshot, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::plugins::Screenshot, + gz::gui::Plugin) diff --git a/src/plugins/screenshot/Screenshot.hh b/src/plugins/screenshot/Screenshot.hh index a055b87c3..ace58577f 100644 --- a/src/plugins/screenshot/Screenshot.hh +++ b/src/plugins/screenshot/Screenshot.hh @@ -14,6 +14,7 @@ * limitations under the License. * */ + #ifndef GZ_GUI_PLUGINS_SCREENSHOT_HH_ #define GZ_GUI_PLUGINS_SCREENSHOT_HH_ @@ -25,11 +26,7 @@ #include "gz/gui/qt.h" #include "gz/gui/Plugin.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class ScreenshotPrivate; @@ -123,8 +120,6 @@ namespace plugins /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_SCREENSHOT_HH_ diff --git a/src/plugins/shutdown_button/ShutdownButton.cc b/src/plugins/shutdown_button/ShutdownButton.cc index eadabbb11..e0df417fd 100644 --- a/src/plugins/shutdown_button/ShutdownButton.cc +++ b/src/plugins/shutdown_button/ShutdownButton.cc @@ -22,14 +22,10 @@ #include "gz/gui/Application.hh" #include "gz/gui/MainWindow.hh" -using namespace gz; -using namespace gui; -using namespace plugins; - -///////////////////////////////////////////////// -ShutdownButton::ShutdownButton() : Plugin() +namespace gz::gui::plugins { -} +///////////////////////////////////////////////// +ShutdownButton::ShutdownButton() = default; ///////////////////////////////////////////////// ShutdownButton::~ShutdownButton() = default; @@ -47,7 +43,8 @@ void ShutdownButton::OnStop() { gui::App()->findChild()->QuickWindow()->close(); } +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(ShutdownButton, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::plugins::ShutdownButton, + gz::gui::Plugin) diff --git a/src/plugins/shutdown_button/ShutdownButton.hh b/src/plugins/shutdown_button/ShutdownButton.hh index 7af124b2f..91b0ed9cc 100644 --- a/src/plugins/shutdown_button/ShutdownButton.hh +++ b/src/plugins/shutdown_button/ShutdownButton.hh @@ -30,11 +30,7 @@ # endif #endif -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { /// \brief This plugin provides a shutdown button. class ShutdownButton_EXPORTS_API ShutdownButton: public gz::gui::Plugin @@ -53,8 +49,6 @@ namespace plugins /// \brief Callback in Qt thread when close button is clicked. public slots: void OnStop(); }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_SHUTDOWNBUTTON_HH_ diff --git a/src/plugins/tape_measure/TapeMeasure.cc b/src/plugins/tape_measure/TapeMeasure.cc index f73b655c3..9ac357a56 100644 --- a/src/plugins/tape_measure/TapeMeasure.cc +++ b/src/plugins/tape_measure/TapeMeasure.cc @@ -35,67 +35,62 @@ namespace gz::gui { - class TapeMeasurePrivate - { - /// \brief Gazebo communication node. - public: transport::Node node; - - /// \brief True if currently measuring, else false. - public: bool measure = false; +class TapeMeasurePrivate +{ + /// \brief Gazebo communication node. + public: transport::Node node; - /// \brief The id of the start point marker. - public: const int kStartPointId = 1; + /// \brief True if currently measuring, else false. + public: bool measure = false; - /// \brief The id of the end point marker. - public: const int kEndPointId = 2; + /// \brief The id of the start point marker. + public: const int kStartPointId = 1; - /// \brief The id of the line marker. - public: const int kLineId = 3; + /// \brief The id of the end point marker. + public: const int kEndPointId = 2; - /// \brief The id of the start or end point marker that is currently - /// being placed. This is primarily used to track the state machine of - /// the plugin. - public: int currentId = kStartPointId; + /// \brief The id of the line marker. + public: const int kLineId = 3; - /// \brief The location of the placed starting point of the tape measure - /// tool, only set when the user clicks to set the point. - public: gz::math::Vector3d startPoint = - gz::math::Vector3d::Zero; + /// \brief The id of the start or end point marker that is currently + /// being placed. This is primarily used to track the state machine of + /// the plugin. + public: int currentId = kStartPointId; - /// \brief The location of the placed ending point of the tape measure - /// tool, only set when the user clicks to set the point. - public: gz::math::Vector3d endPoint = gz::math::Vector3d::Zero; + /// \brief The location of the placed starting point of the tape measure + /// tool, only set when the user clicks to set the point. + public: gz::math::Vector3d startPoint = + gz::math::Vector3d::Zero; - /// \brief The color to set the marker when hovering the mouse over the - /// scene. - public: gz::math::Color - hoverColor{gz::math::Color(0.2f, 0.2f, 0.2f, 0.5f)}; + /// \brief The location of the placed ending point of the tape measure + /// tool, only set when the user clicks to set the point. + public: gz::math::Vector3d endPoint = gz::math::Vector3d::Zero; - /// \brief The color to draw the marker when the user clicks to confirm - /// its location. - public: gz::math::Color - drawColor{gz::math::Color(0.2f, 0.2f, 0.2f, 1.0f)}; + /// \brief The color to set the marker when hovering the mouse over the + /// scene. + public: gz::math::Color + hoverColor{gz::math::Color(0.2f, 0.2f, 0.2f, 0.5f)}; - /// \brief A set of the currently placed markers. Used to make sure a - /// non-existent marker is not deleted. - public: std::unordered_set placedMarkers; + /// \brief The color to draw the marker when the user clicks to confirm + /// its location. + public: gz::math::Color + drawColor{gz::math::Color(0.2f, 0.2f, 0.2f, 1.0f)}; - /// \brief The current distance between the two points. This distance - /// is updated as the user hovers the end point as well. - public: double distance = 0.0; + /// \brief A set of the currently placed markers. Used to make sure a + /// non-existent marker is not deleted. + public: std::unordered_set placedMarkers; - /// \brief The namespace that the markers for this plugin are placed in. - public: std::string ns = "tape_measure"; - }; -} + /// \brief The current distance between the two points. This distance + /// is updated as the user hovers the end point as well. + public: double distance = 0.0; -using namespace gz; -using namespace gui; + /// \brief The namespace that the markers for this plugin are placed in. + public: std::string ns = "tape_measure"; +}; ///////////////////////////////////////////////// TapeMeasure::TapeMeasure() - : gz::gui::Plugin(), - dataPtr(std::make_unique()) + : dataPtr(std::make_unique()) { } @@ -326,6 +321,7 @@ bool TapeMeasure::eventFilter(QObject *_obj, QEvent *_event) return QObject::eventFilter(_obj, _event); } +} // namespace gz::gui // Register this plugin GZ_ADD_PLUGIN(gz::gui::TapeMeasure, diff --git a/src/plugins/tape_measure/TapeMeasure.hh b/src/plugins/tape_measure/TapeMeasure.hh index 86bb4cce3..90e5ab119 100644 --- a/src/plugins/tape_measure/TapeMeasure.hh +++ b/src/plugins/tape_measure/TapeMeasure.hh @@ -14,6 +14,7 @@ * limitations under the License. * */ + #ifndef GZ_GUI_TAPEMEASURE_HH_ #define GZ_GUI_TAPEMEASURE_HH_ @@ -23,9 +24,7 @@ #include #include -namespace gz -{ -namespace gui +namespace gz::gui { class TapeMeasurePrivate; @@ -99,7 +98,6 @@ namespace gui /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} +} // namespace gz::gui -#endif +#endif // GZ_GUI_TAPEMEASURE_HH_ diff --git a/src/plugins/teleop/Teleop.cc b/src/plugins/teleop/Teleop.cc index 4736b260d..29bfd0ba1 100644 --- a/src/plugins/teleop/Teleop.cc +++ b/src/plugins/teleop/Teleop.cc @@ -27,90 +27,82 @@ #include #include -namespace gz +namespace { -namespace gui +enum class KeyForward{ + kForward, + kBackward, + kStop, +}; + +enum class KeyVertical{ + kUp, + kDown, + kStop, +}; + +enum class KeyYaw{ + kLeft, + kRight, + kStop, +}; +} // namespace + +namespace gz::gui::plugins { -namespace plugins +class TeleopPrivate { - enum class KeyForward{ - kForward, - kBackward, - kStop, - }; - - enum class KeyVertical{ - kUp, - kDown, - kStop, - }; - - enum class KeyYaw{ - kLeft, - kRight, - kStop, - }; - - class TeleopPrivate - { - /// \brief Node for communication. - public: gz::transport::Node node; - - /// \brief Topic. Set '/cmd_vel' as default. - public: std::string topic = "/cmd_vel"; + /// \brief Node for communication. + public: gz::transport::Node node; - /// \brief Publisher. - public: gz::transport::Node::Publisher cmdVelPub; + /// \brief Topic. Set '/cmd_vel' as default. + public: std::string topic = "/cmd_vel"; - /// \brief Maximum forward velocity in m/s. GUI buttons and key presses - /// will use this velocity. Sliders will scale up to this value. - public: double maxForwardVel = 1.0; + /// \brief Publisher. + public: gz::transport::Node::Publisher cmdVelPub; - /// \brief Maximum vertical velocity in m/s. GUI buttons and key presses - /// will use this velocity. Sliders will scale up to this value. - public: double maxVerticalVel = 1.0; + /// \brief Maximum forward velocity in m/s. GUI buttons and key presses + /// will use this velocity. Sliders will scale up to this value. + public: double maxForwardVel = 1.0; - /// \brief Maximum yaw velocity in rad/s. GUI buttons and key presses - /// will use this velocity. Sliders will scale up to this value. - public: double maxYawVel = 0.5; + /// \brief Maximum vertical velocity in m/s. GUI buttons and key presses + /// will use this velocity. Sliders will scale up to this value. + public: double maxVerticalVel = 1.0; - /// \brief Forward scale to multiply by maxForwardVel, in the [-1, 1] range. - /// Negative values go backwards, zero stops movement in the forward axis. - public: int forwardKeyScale = 0; + /// \brief Maximum yaw velocity in rad/s. GUI buttons and key presses + /// will use this velocity. Sliders will scale up to this value. + public: double maxYawVel = 0.5; - /// \brief Vertical scale to multiply by maxVerticalVel, in the [-1, 1] - /// range. Negative values go down, zero stops movement in the vertical - /// axis. - public: int verticalKeyScale = 0; + /// \brief Forward scale to multiply by maxForwardVel, in the [-1, 1] range. + /// Negative values go backwards, zero stops movement in the forward axis. + public: int forwardKeyScale = 0; - /// \brief Yaw scale to multiply by maxYawVel, in the [-1, 1] range. - /// Negative values rotate clockwise when looking from above, zero stops - /// movement in the yaw axis. - public: int yawKeyScale = 0; + /// \brief Vertical scale to multiply by maxVerticalVel, in the [-1, 1] + /// range. Negative values go down, zero stops movement in the vertical + /// axis. + public: int verticalKeyScale = 0; - /// \brief Forward state set by keyboard input. - public: KeyForward forwardKeyState = KeyForward::kStop; + /// \brief Yaw scale to multiply by maxYawVel, in the [-1, 1] range. + /// Negative values rotate clockwise when looking from above, zero stops + /// movement in the yaw axis. + public: int yawKeyScale = 0; - /// \brief Vertical state set by keyboard input. - public: KeyVertical verticalKeyState = KeyVertical::kStop; + /// \brief Forward state set by keyboard input. + public: KeyForward forwardKeyState = KeyForward::kStop; - /// \brief Yaw state set by keyboard input. - public: KeyYaw yawKeyState = KeyYaw::kStop; + /// \brief Vertical state set by keyboard input. + public: KeyVertical verticalKeyState = KeyVertical::kStop; - /// \brief Indicates if the keyboard is enabled or - /// disabled. - public: bool keyEnable = false; - }; -} -} -} + /// \brief Yaw state set by keyboard input. + public: KeyYaw yawKeyState = KeyYaw::kStop; -using namespace gz; -using namespace gui; -using namespace plugins; + /// \brief Indicates if the keyboard is enabled or + /// disabled. + public: bool keyEnable = false; +}; ///////////////////////////////////////////////// -Teleop::Teleop(): Plugin(), dataPtr(std::make_unique()) +Teleop::Teleop(): dataPtr(std::make_unique()) { // Initialize publisher using default topic. this->dataPtr->cmdVelPub = transport::Node::Publisher(); @@ -324,7 +316,8 @@ void Teleop::SetKeyScale() KeyYaw::kLeft ? 1 : this->dataPtr->yawKeyState == KeyYaw::kRight ? -1 : 0; } +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(Teleop, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::plugins::Teleop, + gz::gui::Plugin) diff --git a/src/plugins/teleop/Teleop.hh b/src/plugins/teleop/Teleop.hh index fd3ecaeb2..6bab0107b 100644 --- a/src/plugins/teleop/Teleop.hh +++ b/src/plugins/teleop/Teleop.hh @@ -35,11 +35,7 @@ # endif #endif -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class TeleopPrivate; @@ -162,8 +158,6 @@ namespace plugins private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_TELEOP_HH_ diff --git a/src/plugins/topic_echo/TopicEcho.cc b/src/plugins/topic_echo/TopicEcho.cc index 79265bc5e..405cc57f2 100644 --- a/src/plugins/topic_echo/TopicEcho.cc +++ b/src/plugins/topic_echo/TopicEcho.cc @@ -23,44 +23,33 @@ #include "gz/gui/Application.hh" #include "TopicEcho.hh" -namespace gz +namespace gz::gui::plugins { -namespace gui +class TopicEchoPrivate { -namespace plugins -{ - class TopicEchoPrivate - { - /// \brief Topic - public: QString topic{"/echo"}; + /// \brief Topic + public: QString topic{"/echo"}; - /// \brief A list of text data. - public: QStringListModel msgList; + /// \brief A list of text data. + public: QStringListModel msgList; - /// \brief Size of the text buffer. The size is the number of - /// messages. - public: unsigned int buffer{10u}; + /// \brief Size of the text buffer. The size is the number of + /// messages. + public: unsigned int buffer{10u}; - /// \brief Flag used to pause message parsing. - public: bool paused{false}; + /// \brief Flag used to pause message parsing. + public: bool paused{false}; - /// \brief Mutex to protect message buffer. - public: std::mutex mutex; + /// \brief Mutex to protect message buffer. + public: std::mutex mutex; - /// \brief Node for communication - public: gz::transport::Node node; - }; -} -} -} - -using namespace gz; -using namespace gui; -using namespace plugins; + /// \brief Node for communication + public: gz::transport::Node node; +}; ///////////////////////////////////////////////// TopicEcho::TopicEcho() - : Plugin(), dataPtr(new TopicEchoPrivate) + : dataPtr(new TopicEchoPrivate) { // Connect model App()->Engine()->rootContext()->setContextProperty("TopicEchoMsgList", @@ -68,9 +57,7 @@ TopicEcho::TopicEcho() } ///////////////////////////////////////////////// -TopicEcho::~TopicEcho() -{ -} +TopicEcho::~TopicEcho() = default; ///////////////////////////////////////////////// void TopicEcho::LoadConfig(const tinyxml2::XMLElement * /*_pluginElem*/) @@ -176,8 +163,8 @@ void TopicEcho::SetPaused(const bool &_paused) this->dataPtr->paused = _paused; this->PausedChanged(); } +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(TopicEcho, - gui::Plugin) - +GZ_ADD_PLUGIN(gz::gui::plugins::TopicEcho, + gz::gui::Plugin) diff --git a/src/plugins/topic_echo/TopicEcho.hh b/src/plugins/topic_echo/TopicEcho.hh index c711a08b4..16f93e4e9 100644 --- a/src/plugins/topic_echo/TopicEcho.hh +++ b/src/plugins/topic_echo/TopicEcho.hh @@ -41,11 +41,7 @@ #include "gz/gui/Plugin.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class TopicEchoPrivate; @@ -130,8 +126,6 @@ namespace plugins /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_TOPICECHO_HH_ diff --git a/src/plugins/topic_viewer/TopicViewer.cc b/src/plugins/topic_viewer/TopicViewer.cc index 6064fa998..4d1283610 100644 --- a/src/plugins/topic_viewer/TopicViewer.cc +++ b/src/plugins/topic_viewer/TopicViewer.cc @@ -46,111 +46,100 @@ #define PATH_ROLE 54 #define PLOT_ROLE 55 -namespace gz +namespace gz::gui::plugins { -namespace gui +/// \brief Model for the Topics and their Msgs and Fields +/// a tree model that represents the topics tree with its Msgs +/// Childeren and each msg node has its own fileds/msgs childeren +class TopicsModel : public QStandardItemModel { -namespace plugins -{ - /// \brief Model for the Topics and their Msgs and Fields - /// a tree model that represents the topics tree with its Msgs - /// Childeren and each msg node has its own fileds/msgs childeren - class TopicsModel : public QStandardItemModel + /// \brief roles and names of the model + public: QHash roleNames() const override { - /// \brief roles and names of the model - public: QHash roleNames() const override - { - QHash roles; - roles[NAME_ROLE] = NAME_KEY; - roles[TYPE_ROLE] = TYPE_KEY; - roles[TOPIC_ROLE] = TOPIC_KEY; - roles[PATH_ROLE] = PATH_KEY; - roles[PLOT_ROLE] = PLOT_KEY; - return roles; - } - }; - - class TopicViewerPrivate - { - /// \brief Node for Commincation - public: gz::transport::Node node; - - /// \brief Model to create it from the available topics and messages - public: TopicsModel *model; - - /// \brief Timer to update the model and keep track of its changes - public: QTimer *timer; - - /// \brief topic: msgType map to keep track of the model current topics - public: std::map currentTopics; - - /// \brief Create the fields model - public: void CreateModel(); - - /// \brief add a topic to the model - /// \param[in] _topic topic name to be displayed - /// \param[in] _msg topic's msg type - public: void AddTopic(const std::string &_topic, - const std::string &_msg); - - /// \brief add a field/msg child to that parent item - /// \param[in] _parentItem a parent for the added field/msg - /// \param[in] _msgName the displayed name of the field/msg - /// \param[in] _msgType field/msg type - public: void AddField(QStandardItem *_parentItem, - const std::string &_msgName, - const std::string &_msgType); - - /// \brief factory method for creating an item - /// \param[in] _name the display name - /// \param[in] _type type of the field of the item - /// \param[in] _path a set of concatenate strings of parent msgs - /// names that lead to that field, starting from the most parent - /// ex : if we have [Collision]msg contains [pose]msg contains [position] - /// msg contains [x,y,z] fields, so the path of x = "pose-position-x" - /// \param[in] _topic the name of the most parent item - /// \return the created Item - public: QStandardItem *FactoryItem(const std::string &_name, - const std::string &_type, - const std::string &_path = "", - const std::string &_topic = ""); - - /// \brief set the topic role name of the item with the most - /// topic parent of that field item - /// \param[in] _item item ref to set its topic - public: void SetItemTopic(QStandardItem *_item); - - /// \brief set the path/ID of the givin item starting from - /// the most topic parent to the field itself - /// \param[in] _item item ref to set its path - public: void SetItemPath(QStandardItem *_item); - - /// \brief get the topic name of selected item - /// \param[in] _item ref to the item to get its parent topic - public: std::string TopicName(const QStandardItem *_item) const; - - /// \brief full path starting from topic name till the msg name - /// \param[in] _index index of the QStanadardItem - /// \return string with all elements separated by '/' - public: std::string ItemPath(const QStandardItem *_item) const; - - /// \brief check if the type is supported in the plotting types - /// \param[in] _type the msg type to check if it is supported - public: bool IsPlotable( - const google::protobuf::FieldDescriptor::Type &_type); - - /// \brief supported types for plotting - public: std::vector plotableTypes; - }; -} -} -} - -using namespace gz; -using namespace gui; -using namespace plugins; + QHash roles; + roles[NAME_ROLE] = NAME_KEY; + roles[TYPE_ROLE] = TYPE_KEY; + roles[TOPIC_ROLE] = TOPIC_KEY; + roles[PATH_ROLE] = PATH_KEY; + roles[PLOT_ROLE] = PLOT_KEY; + return roles; + } +}; -TopicViewer::TopicViewer() : Plugin(), dataPtr(new TopicViewerPrivate) +class TopicViewerPrivate +{ + /// \brief Node for Commincation + public: gz::transport::Node node; + + /// \brief Model to create it from the available topics and messages + public: TopicsModel *model; + + /// \brief Timer to update the model and keep track of its changes + public: QTimer *timer; + + /// \brief topic: msgType map to keep track of the model current topics + public: std::map currentTopics; + + /// \brief Create the fields model + public: void CreateModel(); + + /// \brief add a topic to the model + /// \param[in] _topic topic name to be displayed + /// \param[in] _msg topic's msg type + public: void AddTopic(const std::string &_topic, + const std::string &_msg); + + /// \brief add a field/msg child to that parent item + /// \param[in] _parentItem a parent for the added field/msg + /// \param[in] _msgName the displayed name of the field/msg + /// \param[in] _msgType field/msg type + public: void AddField(QStandardItem *_parentItem, + const std::string &_msgName, + const std::string &_msgType); + + /// \brief factory method for creating an item + /// \param[in] _name the display name + /// \param[in] _type type of the field of the item + /// \param[in] _path a set of concatenate strings of parent msgs + /// names that lead to that field, starting from the most parent + /// ex : if we have [Collision]msg contains [pose]msg contains [position] + /// msg contains [x,y,z] fields, so the path of x = "pose-position-x" + /// \param[in] _topic the name of the most parent item + /// \return the created Item + public: QStandardItem *FactoryItem(const std::string &_name, + const std::string &_type, + const std::string &_path = "", + const std::string &_topic = ""); + + /// \brief set the topic role name of the item with the most + /// topic parent of that field item + /// \param[in] _item item ref to set its topic + public: void SetItemTopic(QStandardItem *_item); + + /// \brief set the path/ID of the givin item starting from + /// the most topic parent to the field itself + /// \param[in] _item item ref to set its path + public: void SetItemPath(QStandardItem *_item); + + /// \brief get the topic name of selected item + /// \param[in] _item ref to the item to get its parent topic + public: std::string TopicName(const QStandardItem *_item) const; + + /// \brief full path starting from topic name till the msg name + /// \param[in] _index index of the QStanadardItem + /// \return string with all elements separated by '/' + public: std::string ItemPath(const QStandardItem *_item) const; + + /// \brief check if the type is supported in the plotting types + /// \param[in] _type the msg type to check if it is supported + public: bool IsPlotable( + const google::protobuf::FieldDescriptor::Type &_type); + + /// \brief supported types for plotting + public: std::vector plotableTypes; +}; + +TopicViewer::TopicViewer() : dataPtr(new TopicViewerPrivate) { using namespace google::protobuf; this->dataPtr->plotableTypes.push_back(FieldDescriptor::Type::TYPE_DOUBLE); @@ -172,9 +161,7 @@ TopicViewer::TopicViewer() : Plugin(), dataPtr(new TopicViewerPrivate) } ////////////////////////////////////////////////// -TopicViewer::~TopicViewer() -{ -} +TopicViewer::~TopicViewer() = default; ////////////////////////////////////////////////// void TopicViewer::LoadConfig(const tinyxml2::XMLElement *) @@ -422,8 +409,8 @@ void TopicViewer::UpdateModel() } } } - +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(TopicViewer, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::plugins::TopicViewer, + gz::gui::Plugin) diff --git a/src/plugins/topic_viewer/TopicViewer.hh b/src/plugins/topic_viewer/TopicViewer.hh index a8839bbbf..d2ca70233 100644 --- a/src/plugins/topic_viewer/TopicViewer.hh +++ b/src/plugins/topic_viewer/TopicViewer.hh @@ -14,6 +14,10 @@ * limitations under the License. * */ + +#ifndef GZ_GUI_PLUGINS_TOPICVIEWER_HH_ +#define GZ_GUI_PLUGINS_TOPICVIEWER_HH_ + #include #include @@ -28,11 +32,7 @@ # endif #endif -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class TopicsModel; class TopicViewerPrivate; @@ -62,7 +62,6 @@ namespace plugins /// \brief Pointer to private data. private: std:: unique_ptr dataPtr; }; +} // namespace gz::gui::plugins -} -} -} +#endif // GZ_GUI_PLUGINS_TOPICVIEWER_HH_ diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.cc b/src/plugins/transport_scene_manager/TransportSceneManager.cc index a8157dd55..735ed5ee8 100644 --- a/src/plugins/transport_scene_manager/TransportSceneManager.cc +++ b/src/plugins/transport_scene_manager/TransportSceneManager.cc @@ -54,8 +54,10 @@ #include "TransportSceneManager.hh" +namespace gz::gui::plugins +{ /// \brief Private data class for TransportSceneManager -class gz::gui::plugins::TransportSceneManagerPrivate +class TransportSceneManagerPrivate { /// \brief Make the scene service request and populate the scene public: void Request(); @@ -172,13 +174,9 @@ class gz::gui::plugins::TransportSceneManagerPrivate public: std::thread initializeTransport; }; -using namespace gz; -using namespace gui; -using namespace plugins; - ///////////////////////////////////////////////// TransportSceneManager::TransportSceneManager() - : Plugin(), dataPtr(new TransportSceneManagerPrivate) + : dataPtr(new TransportSceneManagerPrivate) { } @@ -871,6 +869,7 @@ void TransportSceneManagerPrivate::DeleteEntity(const unsigned int _entity) this->lights.erase(_entity); } } +} // namespace gz::gui::plugins // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::TransportSceneManager, diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.hh b/src/plugins/transport_scene_manager/TransportSceneManager.hh index d69ec624b..bc33a01df 100644 --- a/src/plugins/transport_scene_manager/TransportSceneManager.hh +++ b/src/plugins/transport_scene_manager/TransportSceneManager.hh @@ -22,11 +22,7 @@ #include "gz/gui/Plugin.hh" -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class TransportSceneManagerPrivate; @@ -64,8 +60,6 @@ namespace plugins /// \brief Pointer to private data. private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_TRANSPORTSCENEMANAGER_HH_ diff --git a/src/plugins/world_control/WorldControl.cc b/src/plugins/world_control/WorldControl.cc index 4568ce2a1..a1e7d4ab8 100644 --- a/src/plugins/world_control/WorldControl.cc +++ b/src/plugins/world_control/WorldControl.cc @@ -33,63 +33,50 @@ #include "gz/gui/GuiEvents.hh" #include "gz/gui/MainWindow.hh" -namespace gz +namespace gz::gui::plugins { -namespace gui +class WorldControlPrivate { -namespace plugins -{ - class WorldControlPrivate - { - /// \brief Send the world control event or call the control service. - /// \param[in] _msg Message to send. - public: void SendEventMsg(const gz::msgs::WorldControl &_msg); + /// \brief Send the world control event or call the control service. + /// \param[in] _msg Message to send. + public: void SendEventMsg(const gz::msgs::WorldControl &_msg); - /// \brief Message holding latest world statistics - public: gz::msgs::WorldStatistics msg; + /// \brief Message holding latest world statistics + public: gz::msgs::WorldStatistics msg; - /// \brief Service to send world control requests - public: std::string controlService; + /// \brief Service to send world control requests + public: std::string controlService; - /// \brief Mutex to protect msg - public: std::recursive_mutex mutex; + /// \brief Mutex to protect msg + public: std::recursive_mutex mutex; - /// \brief Communication node - public: gz::transport::Node node; + /// \brief Communication node + public: gz::transport::Node node; - /// \brief The multi step value - public: unsigned int multiStep = 1u; + /// \brief The multi step value + public: unsigned int multiStep = 1u; - /// \brief True for paused - public: bool pause{true}; + /// \brief True for paused + public: bool pause{true}; - /// \brief The paused state of the most recently received world stats msg - /// (true for paused) - public: bool lastStatsMsgPaused{true}; - - /// \brief Whether server communication should occur through an event (true) - /// or service (false). The service option is used by default for - /// gz-gui6, and should be changed to use the event by default in gz-gui7. - public: bool useEvent{false}; - }; -} -} -} + /// \brief The paused state of the most recently received world stats msg + /// (true for paused) + public: bool lastStatsMsgPaused{true}; -using namespace gz; -using namespace gui; -using namespace plugins; + /// \brief Whether server communication should occur through an event (true) + /// or service (false). The service option is used by default for + /// gz-gui6, and should be changed to use the event by default in gz-gui7. + public: bool useEvent{false}; +}; ///////////////////////////////////////////////// WorldControl::WorldControl() - : Plugin(), dataPtr(new WorldControlPrivate) + : dataPtr(new WorldControlPrivate) { } ///////////////////////////////////////////////// -WorldControl::~WorldControl() -{ -} +WorldControl::~WorldControl() = default; ///////////////////////////////////////////////// void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) @@ -358,7 +345,8 @@ void WorldControlPrivate::SendEventMsg(const msgs::WorldControl &_msg) this->node.Request(this->controlService, _msg, cb); } } +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(WorldControl, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::plugins::WorldControl, + gz::gui::Plugin) diff --git a/src/plugins/world_control/WorldControl.hh b/src/plugins/world_control/WorldControl.hh index 3b6fa11a3..486bfc5e6 100644 --- a/src/plugins/world_control/WorldControl.hh +++ b/src/plugins/world_control/WorldControl.hh @@ -34,11 +34,7 @@ # endif #endif -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class WorldControlPrivate; @@ -107,8 +103,6 @@ namespace plugins // Private data private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_WORLDCONTROL_HH_ diff --git a/src/plugins/world_control/WorldControlEventListener.cc b/src/plugins/world_control/WorldControlEventListener.cc index c091122f5..3be0cec05 100644 --- a/src/plugins/world_control/WorldControlEventListener.cc +++ b/src/plugins/world_control/WorldControlEventListener.cc @@ -17,9 +17,8 @@ #include "WorldControlEventListener.hh" -using namespace gz; -using namespace gui; - +namespace gz::gui +{ WorldControlEventListener::WorldControlEventListener() { gz::gui::App()->findChild< @@ -48,3 +47,4 @@ bool WorldControlEventListener::eventFilter(QObject *_obj, QEvent *_event) // Standard event processing return QObject::eventFilter(_obj, _event); } +} diff --git a/src/plugins/world_control/WorldControlEventListener.hh b/src/plugins/world_control/WorldControlEventListener.hh index 00719b94d..5ac7a514f 100644 --- a/src/plugins/world_control/WorldControlEventListener.hh +++ b/src/plugins/world_control/WorldControlEventListener.hh @@ -23,9 +23,7 @@ #include "gz/gui/MainWindow.hh" #include "gz/gui/qt.h" -namespace gz -{ -namespace gui +namespace gz::gui { /// \brief Helper class for testing listening to events emitted by the /// WorldControl plugin. This is used for testing the event behavior of @@ -55,7 +53,6 @@ namespace gui /// \brief Whether a reset event has been received (true) or not (false) public: bool listenedToReset{false}; }; -} -} +} // namespace gz::gui -#endif +#endif // GZ_GUI_WORLDCONTROLEVENTLISTENER_HH_ diff --git a/src/plugins/world_stats/WorldStats.cc b/src/plugins/world_stats/WorldStats.cc index 86be0aafa..c598b7253 100644 --- a/src/plugins/world_stats/WorldStats.cc +++ b/src/plugins/world_stats/WorldStats.cc @@ -29,61 +29,48 @@ #include "gz/gui/Helpers.hh" -namespace gz +namespace gz::gui::plugins { -namespace gui +class WorldStatsPrivate { -namespace plugins -{ - class WorldStatsPrivate - { - /// \brief Message holding latest world statistics - public: gz::msgs::WorldStatistics msg; + /// \brief Message holding latest world statistics + public: gz::msgs::WorldStatistics msg; - /// \brief Mutex to protect msg - public: std::recursive_mutex mutex; + /// \brief Mutex to protect msg + public: std::recursive_mutex mutex; - /// \brief Communication node - public: gz::transport::Node node; + /// \brief Communication node + public: gz::transport::Node node; - /// \brief Holds real time factor - public: QString realTimeFactor; + /// \brief Holds real time factor + public: QString realTimeFactor; - /// \brief Holds sim time - public: QString simTime; + /// \brief Holds sim time + public: QString simTime; - /// \brief Holds real time - public: QString realTime; + /// \brief Holds real time + public: QString realTime; - /// \brief Holds iterations - public: QString iterations; + /// \brief Holds iterations + public: QString iterations; - /// \brief Time delayed version if simTime used for computing a low-pass - /// filtered RTF - public: std::optional simTimeDelayed; - - /// \brief Time delayed version if realTime used for computing a low-pass - /// filtered RTF - public: std::optional realTimeDelayed; - }; -} -} -} + /// \brief Time delayed version if simTime used for computing a low-pass + /// filtered RTF + public: std::optional simTimeDelayed; -using namespace gz; -using namespace gui; -using namespace plugins; + /// \brief Time delayed version if realTime used for computing a low-pass + /// filtered RTF + public: std::optional realTimeDelayed; +}; ///////////////////////////////////////////////// WorldStats::WorldStats() - : Plugin(), dataPtr(new WorldStatsPrivate) + : dataPtr(new WorldStatsPrivate) { } ///////////////////////////////////////////////// -WorldStats::~WorldStats() -{ -} +WorldStats::~WorldStats() = default; ///////////////////////////////////////////////// void WorldStats::LoadConfig(const tinyxml2::XMLElement *_pluginElem) @@ -341,7 +328,8 @@ void WorldStats::SetIterations(const QString &_iterations) this->dataPtr->iterations = _iterations; this->IterationsChanged(); } +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(WorldStats, - gui::Plugin) +GZ_ADD_PLUGIN(gz::gui::plugins::WorldStats, + gz::gui::Plugin) diff --git a/src/plugins/world_stats/WorldStats.hh b/src/plugins/world_stats/WorldStats.hh index 958f855b3..deda05ad1 100644 --- a/src/plugins/world_stats/WorldStats.hh +++ b/src/plugins/world_stats/WorldStats.hh @@ -35,11 +35,7 @@ # endif #endif -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { class WorldStatsPrivate; @@ -161,8 +157,6 @@ namespace plugins // Private data private: std::unique_ptr dataPtr; }; -} -} -} +} // namespace gz::gui::plugins -#endif +#endif // GZ_GUI_PLUGINS_WORLDSTATS_HH_