From b84c93fc00047f0291dcc4f9ee1f80b9d9d33a4d Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 5 Oct 2023 22:26:06 +0000 Subject: [PATCH] Switch gz-gui plugins to use implptr Signed-off-by: Michael Carroll --- include/gz/gui/Dialog.hh | 1 - include/gz/gui/MainWindow.hh | 5 -- src/MainWindow.cc | 2 +- src/PlottingInterface.cc | 2 +- src/plugins/camera_fps/CameraFps.cc | 5 +- src/plugins/camera_fps/CameraFps.hh | 5 +- src/plugins/camera_tracking/CameraTracking.cc | 54 ++++++------- src/plugins/camera_tracking/CameraTracking.hh | 5 +- src/plugins/grid_config/GridConfig.cc | 4 +- src/plugins/grid_config/GridConfig.hh | 11 +-- src/plugins/image_display/ImageDisplay.cc | 4 +- src/plugins/image_display/ImageDisplay.hh | 13 +++- .../InteractiveViewControl.cc | 26 +++---- .../InteractiveViewControl.hh | 4 +- src/plugins/key_publisher/KeyPublisher.cc | 6 +- src/plugins/key_publisher/KeyPublisher.hh | 5 +- src/plugins/marker_manager/MarkerManager.cc | 40 +++++----- src/plugins/marker_manager/MarkerManager.hh | 5 +- .../minimal_scene/MinimalSceneRhiVulkan.cc | 76 +++++++------------ .../minimal_scene/MinimalSceneRhiVulkan.hh | 13 +--- src/plugins/navsat_map/NavSatMap.cc | 6 +- src/plugins/navsat_map/NavSatMap.hh | 4 +- src/plugins/plotting/TransportPlotting.cc | 12 ++- src/plugins/plotting/TransportPlotting.hh | 8 +- src/plugins/point_cloud/PointCloud.cc | 11 +-- src/plugins/point_cloud/PointCloud.hh | 6 +- src/plugins/publisher/Publisher.cc | 5 +- src/plugins/publisher/Publisher.hh | 11 ++- src/plugins/screenshot/Screenshot.cc | 5 +- src/plugins/screenshot/Screenshot.hh | 6 +- src/plugins/shutdown_button/ShutdownButton.hh | 2 +- src/plugins/tape_measure/TapeMeasure.cc | 5 +- src/plugins/tape_measure/TapeMeasure.hh | 8 +- src/plugins/teleop/Teleop.cc | 5 +- src/plugins/teleop/Teleop.hh | 13 ++-- src/plugins/topic_echo/TopicEcho.cc | 7 +- src/plugins/topic_echo/TopicEcho.hh | 9 +-- src/plugins/topic_viewer/TopicViewer.cc | 70 +++++++++-------- src/plugins/topic_viewer/TopicViewer.hh | 4 +- .../TransportSceneManager.cc | 49 ++++++------ .../TransportSceneManager.hh | 15 ++-- src/plugins/world_control/WorldControl.cc | 6 +- src/plugins/world_control/WorldControl.hh | 14 ++-- src/plugins/world_stats/WorldStats.cc | 5 +- src/plugins/world_stats/WorldStats.hh | 42 ++++++++++ 45 files changed, 323 insertions(+), 291 deletions(-) diff --git a/include/gz/gui/Dialog.hh b/include/gz/gui/Dialog.hh index 43ba6c132..b46d286a4 100644 --- a/include/gz/gui/Dialog.hh +++ b/include/gz/gui/Dialog.hh @@ -85,6 +85,5 @@ namespace gz::gui /// \brief Private data pointer GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; -}; } // namespace gz::gui #endif // GZ_GUI_DIALOG_HH_ diff --git a/include/gz/gui/MainWindow.hh b/include/gz/gui/MainWindow.hh index afa604195..54597ac0f 100644 --- a/include/gz/gui/MainWindow.hh +++ b/include/gz/gui/MainWindow.hh @@ -667,9 +667,4 @@ namespace gz::gui std::string plugins{""}; }; } // namespace gz::gui - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - #endif // GZ_GUI_MAINWINDOW_HH_ diff --git a/src/MainWindow.cc b/src/MainWindow.cc index df1e0fe5f..ad075b466 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -85,7 +85,7 @@ class MainWindow::Implementation public: std::string controlService{"/server_control"}; /// \brief Communication node - public: gz::transport::Node node; + public: gz::transport::Node node {gz::transport::NodeOptions()}; }; ///////////////////////////////////////////////// diff --git a/src/PlottingInterface.cc b/src/PlottingInterface.cc index 079ec1101..1ac0af2f5 100644 --- a/src/PlottingInterface.cc +++ b/src/PlottingInterface.cc @@ -70,7 +70,7 @@ class Topic::Implementation class Transport::Implementation { /// \brief Node for Commincation - public: gz::transport::Node node; + public: gz::transport::Node node {gz::transport::NodeOptions()}; /// \brief subscribed topics public: std::map topics; diff --git a/src/plugins/camera_fps/CameraFps.cc b/src/plugins/camera_fps/CameraFps.cc index 4bc3d2b0a..6dc385b31 100644 --- a/src/plugins/camera_fps/CameraFps.cc +++ b/src/plugins/camera_fps/CameraFps.cc @@ -15,6 +15,7 @@ * */ +#include #include #include @@ -32,7 +33,7 @@ namespace gz::gui::plugins { /// \brief Private data class for CameraFps -class CameraFpsPrivate +class CameraFps::Implementation { /// \brief Previous camera update time public: std::optional @@ -82,7 +83,7 @@ void CameraFps::OnRender() ///////////////////////////////////////////////// CameraFps::CameraFps() - : dataPtr(new CameraFpsPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } diff --git a/src/plugins/camera_fps/CameraFps.hh b/src/plugins/camera_fps/CameraFps.hh index fb33d7f7f..c8a5ab07e 100644 --- a/src/plugins/camera_fps/CameraFps.hh +++ b/src/plugins/camera_fps/CameraFps.hh @@ -18,14 +18,13 @@ #ifndef GZ_GUI_PLUGINS_CAMERAFPS_HH_ #define GZ_GUI_PLUGINS_CAMERAFPS_HH_ +#include #include #include "gz/gui/Plugin.hh" namespace gz::gui::plugins { - class CameraFpsPrivate; - /// \brief This plugin displays the GUI camera's Framerate Per Second (FPS) class CameraFps : public Plugin { @@ -68,7 +67,7 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/camera_tracking/CameraTracking.cc b/src/plugins/camera_tracking/CameraTracking.cc index 172bb6e05..6f514edd6 100644 --- a/src/plugins/camera_tracking/CameraTracking.cc +++ b/src/plugins/camera_tracking/CameraTracking.cc @@ -15,6 +15,7 @@ * */ +#include #include #include @@ -44,7 +45,7 @@ namespace gz::gui::plugins { /// \brief Private data class for CameraTracking -class CameraTrackingPrivate +class CameraTracking::Implementation { /// \brief Perform rendering calls in the rendering thread. public: void OnRender(); @@ -159,7 +160,7 @@ class CameraTrackingPrivate }; ///////////////////////////////////////////////// -void CameraTrackingPrivate::Initialize() +void CameraTracking::Implementation::Initialize() { // Attach to the first camera we find for (unsigned int i = 0; i < scene->NodeCount(); ++i) @@ -169,7 +170,7 @@ void CameraTrackingPrivate::Initialize() if (cam) { this->camera = cam; - gzdbg << "CameraTrackingPrivate plugin is moving camera [" + gzdbg << "CameraTracking plugin is moving camera [" << this->camera->Name() << "]" << std::endl; break; } @@ -183,14 +184,14 @@ void CameraTrackingPrivate::Initialize() // move to this->moveToService = "/gui/move_to"; this->node.Advertise(this->moveToService, - &CameraTrackingPrivate::OnMoveTo, this); + &Implementation::OnMoveTo, this); gzmsg << "Move to service on [" << this->moveToService << "]" << std::endl; // follow this->followService = "/gui/follow"; this->node.Advertise(this->followService, - &CameraTrackingPrivate::OnFollow, this); + &Implementation::OnFollow, this); gzmsg << "Follow service on [" << this->followService << "]" << std::endl; @@ -198,7 +199,7 @@ void CameraTrackingPrivate::Initialize() this->moveToPoseService = "/gui/move_to/pose"; this->node.Advertise(this->moveToPoseService, - &CameraTrackingPrivate::OnMoveToPose, this); + &Implementation::OnMoveToPose, this); gzmsg << "Move to pose service on [" << this->moveToPoseService << "]" << std::endl; @@ -209,16 +210,16 @@ void CameraTrackingPrivate::Initialize() gzmsg << "Camera pose topic advertised on [" << this->cameraPoseTopic << "]" << std::endl; - // follow offset - this->followOffsetService = "/gui/follow/offset"; - this->node.Advertise(this->followOffsetService, - &CameraTrackingPrivate::OnFollowOffset, this); - gzmsg << "Follow offset service on [" - << this->followOffsetService << "]" << std::endl; + // follow offset + this->followOffsetService = "/gui/follow/offset"; + this->node.Advertise(this->followOffsetService, + &Implementation::OnFollowOffset, this); + gzmsg << "Follow offset service on [" + << this->followOffsetService << "]" << std::endl; } ///////////////////////////////////////////////// -bool CameraTrackingPrivate::OnMoveTo(const msgs::StringMsg &_msg, +bool CameraTracking::Implementation::OnMoveTo(const msgs::StringMsg &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -229,7 +230,7 @@ bool CameraTrackingPrivate::OnMoveTo(const msgs::StringMsg &_msg, } ///////////////////////////////////////////////// -bool CameraTrackingPrivate::OnFollow(const msgs::StringMsg &_msg, +bool CameraTracking::Implementation::OnFollow(const msgs::StringMsg &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -240,19 +241,19 @@ bool CameraTrackingPrivate::OnFollow(const msgs::StringMsg &_msg, } ///////////////////////////////////////////////// -void CameraTrackingPrivate::OnMoveToComplete() +void CameraTracking::Implementation::OnMoveToComplete() { this->moveToTarget.clear(); } ///////////////////////////////////////////////// -void CameraTrackingPrivate::OnMoveToPoseComplete() +void CameraTracking::Implementation::OnMoveToPoseComplete() { this->moveToPoseValue.reset(); } ///////////////////////////////////////////////// -bool CameraTrackingPrivate::OnFollowOffset(const msgs::Vector3d &_msg, +bool CameraTracking::Implementation::OnFollowOffset(const msgs::Vector3d &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -267,7 +268,7 @@ bool CameraTrackingPrivate::OnFollowOffset(const msgs::Vector3d &_msg, } ///////////////////////////////////////////////// -bool CameraTrackingPrivate::OnMoveToPose(const msgs::GUICamera &_msg, +bool CameraTracking::Implementation::OnMoveToPose(const msgs::GUICamera &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -294,7 +295,7 @@ bool CameraTrackingPrivate::OnMoveToPose(const msgs::GUICamera &_msg, } ///////////////////////////////////////////////// -void CameraTrackingPrivate::OnRender() +void CameraTracking::Implementation::OnRender() { std::lock_guard lock(this->mutex); @@ -312,7 +313,7 @@ void CameraTrackingPrivate::OnRender() // Move To { - GZ_PROFILE("CameraTrackingPrivate::OnRender MoveTo"); + GZ_PROFILE("CameraTracking::Implementation::OnRender MoveTo"); if (!this->moveToTarget.empty()) { if (this->moveToHelper.Idle()) @@ -322,7 +323,7 @@ void CameraTrackingPrivate::OnRender() if (target) { this->moveToHelper.MoveTo(this->camera, target, 0.5, - std::bind(&CameraTrackingPrivate::OnMoveToComplete, this)); + std::bind(&Implementation::OnMoveToComplete, this)); this->prevMoveToTime = std::chrono::system_clock::now(); } else @@ -344,14 +345,14 @@ void CameraTrackingPrivate::OnRender() // Move to pose { - GZ_PROFILE("CameraTrackingPrivate::OnRender MoveToPose"); + GZ_PROFILE("CameraTracking::Implementation::OnRender MoveToPose"); if (this->moveToPoseValue) { if (this->moveToHelper.Idle()) { this->moveToHelper.MoveTo(this->camera, *(this->moveToPoseValue), - 0.5, std::bind(&CameraTrackingPrivate::OnMoveToPoseComplete, this)); + 0.5, std::bind(&Implementation::OnMoveToPoseComplete, this)); this->prevMoveToTime = std::chrono::system_clock::now(); } else @@ -366,7 +367,7 @@ void CameraTrackingPrivate::OnRender() // Follow { - GZ_PROFILE("CameraTrackingPrivate::OnRender Follow"); + GZ_PROFILE("CameraTracking::Implementation::OnRender Follow"); // reset follow mode if target node got removed if (!this->followTarget.empty()) { @@ -430,7 +431,7 @@ void CameraTrackingPrivate::OnRender() ///////////////////////////////////////////////// CameraTracking::CameraTracking() - : dataPtr(new CameraTrackingPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { this->dataPtr->timer = new QTimer(this); this->connect(this->dataPtr->timer, &QTimer::timeout, [=]() @@ -461,7 +462,8 @@ void CameraTracking::LoadConfig(const tinyxml2::XMLElement *) } ///////////////////////////////////////////////// -void CameraTrackingPrivate::HandleKeyRelease(events::KeyReleaseOnScene *_e) +void CameraTracking::Implementation::HandleKeyRelease( + events::KeyReleaseOnScene *_e) { if (_e->Key().Key() == Qt::Key_Escape) { diff --git a/src/plugins/camera_tracking/CameraTracking.hh b/src/plugins/camera_tracking/CameraTracking.hh index 68176e2c5..df4601001 100644 --- a/src/plugins/camera_tracking/CameraTracking.hh +++ b/src/plugins/camera_tracking/CameraTracking.hh @@ -18,14 +18,13 @@ #ifndef GZ_GUI_PLUGINS_CAMERATRACKING_HH_ #define GZ_GUI_PLUGINS_CAMERATRACKING_HH_ +#include #include #include "gz/gui/Plugin.hh" namespace gz::gui::plugins { - class CameraTrackingPrivate; - /// \brief This plugin provides camera tracking capabilities such as "move to" /// and "follow". /// @@ -58,7 +57,7 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/grid_config/GridConfig.cc b/src/plugins/grid_config/GridConfig.cc index d7d0d5717..ec1fe6da0 100644 --- a/src/plugins/grid_config/GridConfig.cc +++ b/src/plugins/grid_config/GridConfig.cc @@ -52,7 +52,7 @@ namespace gz::gui math::Color color{math::Color(0.7f, 0.7f, 0.7f, 1.0f)}; }; - class GridConfigPrivate + class GridConfig::Implementation { /// \brief List of grid names. public: QStringList nameList; @@ -84,7 +84,7 @@ namespace gz::gui ///////////////////////////////////////////////// GridConfig::GridConfig() - : dataPtr(std::make_unique()) + : dataPtr(gz::utils::MakeUniqueImpl()) { } diff --git a/src/plugins/grid_config/GridConfig.hh b/src/plugins/grid_config/GridConfig.hh index ae11fcab5..9f75c6b8f 100644 --- a/src/plugins/grid_config/GridConfig.hh +++ b/src/plugins/grid_config/GridConfig.hh @@ -22,7 +22,9 @@ #include -namespace gz::gui +#include + +namespace gz::gui::plugins { class GridConfigPrivate; @@ -139,8 +141,7 @@ namespace gz::gui /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; -} // namespace gz::gui - -#endif // GZ_GUI_GRIDCONFIG_HH_ +} // namespace gz::gui::plugins +#endif // GZ_GUI_PLUGINS_GRIDCONFIG_HH_ diff --git a/src/plugins/image_display/ImageDisplay.cc b/src/plugins/image_display/ImageDisplay.cc index 3bab60d7d..85c648d23 100644 --- a/src/plugins/image_display/ImageDisplay.cc +++ b/src/plugins/image_display/ImageDisplay.cc @@ -35,7 +35,7 @@ namespace gz::gui::plugins { -class ImageDisplayPrivate +class ImageDisplay::Implementation { /// \brief List of topics publishing image messages. public: QStringList topicList; @@ -55,7 +55,7 @@ class ImageDisplayPrivate ///////////////////////////////////////////////// ImageDisplay::ImageDisplay() - : dataPtr(new ImageDisplayPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } diff --git a/src/plugins/image_display/ImageDisplay.hh b/src/plugins/image_display/ImageDisplay.hh index c5a3aa8e3..e66b417c5 100644 --- a/src/plugins/image_display/ImageDisplay.hh +++ b/src/plugins/image_display/ImageDisplay.hh @@ -36,10 +36,10 @@ #include "gz/gui/Plugin.hh" +#include + namespace gz::gui::plugins { - class ImageDisplayPrivate; - class ImageProvider : public QQuickImageProvider { public: ImageProvider() @@ -128,9 +128,16 @@ namespace gz::gui::plugins /// \param[in] _msg New image private: void OnImageMsg(const gz::msgs::Image &_msg); + /// \brief Callback in main thread when image changes + private slots: void ProcessImage(); + + /// \brief Subscriber callback when new image is received + /// \param[in] _msg New image + private: void OnImageMsg(const gz::msgs::Image &_msg); + /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.cc b/src/plugins/interactive_view_control/InteractiveViewControl.cc index 718a9e456..916722dbb 100644 --- a/src/plugins/interactive_view_control/InteractiveViewControl.cc +++ b/src/plugins/interactive_view_control/InteractiveViewControl.cc @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -46,7 +47,7 @@ namespace gz::gui::plugins { /// \brief Private data class for InteractiveViewControl -class InteractiveViewControlPrivate +class InteractiveViewControl::Implementation { /// \brief Perform rendering calls in the rendering thread. public: void OnRender(); @@ -147,7 +148,7 @@ class InteractiveViewControlPrivate }; ///////////////////////////////////////////////// -void InteractiveViewControlPrivate::OnRender() +void InteractiveViewControl::Implementation::OnRender() { if (!this->scene) { @@ -315,7 +316,7 @@ void InteractiveViewControlPrivate::OnRender() } ///////////////////////////////////////////////// -void InteractiveViewControlPrivate::UpdateReferenceVisual() +void InteractiveViewControl::Implementation::UpdateReferenceVisual() { if (!this->refVisual || !this->enableRefVisual) return; @@ -331,8 +332,8 @@ void InteractiveViewControlPrivate::UpdateReferenceVisual() } ///////////////////////////////////////////////// -bool InteractiveViewControlPrivate::OnViewControl(const msgs::StringMsg &_msg, - msgs::Boolean &_res) +bool InteractiveViewControl::Implementation::OnViewControl( + const msgs::StringMsg &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -355,8 +356,8 @@ bool InteractiveViewControlPrivate::OnViewControl(const msgs::StringMsg &_msg, } ///////////////////////////////////////////////// -bool InteractiveViewControlPrivate::OnReferenceVisual(const msgs::Boolean &_msg, - msgs::Boolean &_res) +bool InteractiveViewControl::Implementation::OnReferenceVisual( + const msgs::Boolean &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); this->enableRefVisual = _msg.data(); @@ -366,7 +367,7 @@ bool InteractiveViewControlPrivate::OnReferenceVisual(const msgs::Boolean &_msg, } ///////////////////////////////////////////////// -bool InteractiveViewControlPrivate::OnViewControlSensitivity( +bool InteractiveViewControl::Implementation::OnViewControlSensitivity( const msgs::Double &_msg, msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -387,7 +388,7 @@ bool InteractiveViewControlPrivate::OnViewControlSensitivity( ///////////////////////////////////////////////// InteractiveViewControl::InteractiveViewControl() - : dataPtr(std::make_unique()) + : dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -404,7 +405,7 @@ void InteractiveViewControl::LoadConfig( // camera view control mode this->dataPtr->cameraViewControlService = "/gui/camera/view_control"; this->dataPtr->node.Advertise(this->dataPtr->cameraViewControlService, - &InteractiveViewControlPrivate::OnViewControl, this->dataPtr.get()); + &Implementation::OnViewControl, this->dataPtr.get()); gzmsg << "Camera view controller topic advertised on [" << this->dataPtr->cameraViewControlService << "]" << std::endl; @@ -412,7 +413,7 @@ void InteractiveViewControl::LoadConfig( this->dataPtr->cameraRefVisualService = "/gui/camera/view_control/reference_visual"; this->dataPtr->node.Advertise(this->dataPtr->cameraRefVisualService, - &InteractiveViewControlPrivate::OnReferenceVisual, this->dataPtr.get()); + &Implementation::OnReferenceVisual, this->dataPtr.get()); gzmsg << "Camera reference visual topic advertised on [" << this->dataPtr->cameraRefVisualService << "]" << std::endl; @@ -421,7 +422,7 @@ void InteractiveViewControl::LoadConfig( "/gui/camera/view_control/sensitivity"; this->dataPtr->node.Advertise( this->dataPtr->cameraViewControlSensitivityService, - &InteractiveViewControlPrivate::OnViewControlSensitivity, + &Implementation::OnViewControlSensitivity, this->dataPtr.get()); gzmsg << "Camera view control sensitivity advertised on [" << this->dataPtr->cameraViewControlSensitivityService << "]" @@ -501,7 +502,6 @@ bool InteractiveViewControl::eventFilter(QObject *_obj, QEvent *_event) return QObject::eventFilter(_obj, _event); } } // namespace gz::gui::plugins - // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::InteractiveViewControl, gz::gui::Plugin) diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.hh b/src/plugins/interactive_view_control/InteractiveViewControl.hh index 67e986505..033d28d35 100644 --- a/src/plugins/interactive_view_control/InteractiveViewControl.hh +++ b/src/plugins/interactive_view_control/InteractiveViewControl.hh @@ -22,6 +22,8 @@ #include "gz/gui/Plugin.hh" +#include + namespace gz::gui::plugins { class InteractiveViewControlPrivate; @@ -64,7 +66,7 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/key_publisher/KeyPublisher.cc b/src/plugins/key_publisher/KeyPublisher.cc index 3c9eecc89..23c0821b0 100644 --- a/src/plugins/key_publisher/KeyPublisher.cc +++ b/src/plugins/key_publisher/KeyPublisher.cc @@ -17,6 +17,7 @@ #include +#include #include #include @@ -27,7 +28,7 @@ namespace gz::gui { -class KeyPublisherPrivate +class KeyPublisher::Implementation { /// \brief Node for communication public: gz::transport::Node node; @@ -49,7 +50,8 @@ class KeyPublisherPrivate }; ///////////////////////////////////////////////// -KeyPublisher::KeyPublisher(): dataPtr(new KeyPublisherPrivate) +KeyPublisher::KeyPublisher(): + dataPtr(gz::utils::MakeUniqueImpl()) { // Advertise publisher node this->dataPtr->pub = this->dataPtr->node.Advertise diff --git a/src/plugins/key_publisher/KeyPublisher.hh b/src/plugins/key_publisher/KeyPublisher.hh index dc350b672..7802d02e7 100644 --- a/src/plugins/key_publisher/KeyPublisher.hh +++ b/src/plugins/key_publisher/KeyPublisher.hh @@ -33,12 +33,11 @@ #include #include +#include #include namespace gz::gui { - class KeyPublisherPrivate; - /// \brief Publish keyboard stokes to "keyboard/keypress" topic. /// /// ## Configuration @@ -64,7 +63,7 @@ namespace gz::gui /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui diff --git a/src/plugins/marker_manager/MarkerManager.cc b/src/plugins/marker_manager/MarkerManager.cc index c78d5d990..811e86435 100644 --- a/src/plugins/marker_manager/MarkerManager.cc +++ b/src/plugins/marker_manager/MarkerManager.cc @@ -52,7 +52,7 @@ namespace gz::gui::plugins { /// \brief Private data class for MarkerManager -class MarkerManagerPrivate +class MarkerManager::Implementation { /// \brief Update markers based on msgs received public: void OnRender(); @@ -123,7 +123,7 @@ class MarkerManagerPrivate std::map> visuals; /// \brief Gazebo node - public: gz::transport::Node node; + public: gz::transport::Node node {gz::transport::NodeOptions()}; /// \brief Topic name for the marker service public: std::string topicName = "/marker"; @@ -143,7 +143,7 @@ class MarkerManagerPrivate }; ///////////////////////////////////////////////// -void MarkerManagerPrivate::Initialize() +void MarkerManager::Implementation::Initialize() { if (!this->scene) { @@ -160,7 +160,7 @@ void MarkerManagerPrivate::Initialize() // Advertise the list service if (!this->node.Advertise(this->topicName + "/list", - &MarkerManagerPrivate::OnList, this)) + &Implementation::OnList, this)) { gzerr << "Unable to advertise to the " << this->topicName << "/list service.\n"; @@ -170,7 +170,7 @@ void MarkerManagerPrivate::Initialize() // Advertise to the marker service if (!this->node.Advertise(this->topicName, - &MarkerManagerPrivate::OnMarkerMsg, this)) + &Implementation::OnMarkerMsg, this)) { gzerr << "Unable to advertise to the " << this->topicName << " service.\n"; @@ -180,7 +180,7 @@ void MarkerManagerPrivate::Initialize() // Advertise to the marker_array service if (!this->node.Advertise(this->topicName + "_array", - &MarkerManagerPrivate::OnMarkerMsgArray, this)) + &Implementation::OnMarkerMsgArray, this)) { gzerr << "Unable to advertise to the " << this->topicName << "_array service.\n"; @@ -190,7 +190,7 @@ void MarkerManagerPrivate::Initialize() } ///////////////////////////////////////////////// -void MarkerManagerPrivate::OnRender() +void MarkerManager::Implementation::OnRender() { if (!this->scene) { @@ -246,7 +246,7 @@ void MarkerManagerPrivate::OnRender() } ///////////////////////////////////////////////// -bool MarkerManagerPrivate::OnList(gz::msgs::Marker_V &_rep) +bool MarkerManager::Implementation::OnList(gz::msgs::Marker_V &_rep) { std::lock_guard lock(this->mutex); _rep.clear_marker(); @@ -266,14 +266,14 @@ bool MarkerManagerPrivate::OnList(gz::msgs::Marker_V &_rep) } ///////////////////////////////////////////////// -void MarkerManagerPrivate::OnMarkerMsg(const gz::msgs::Marker &_req) +void MarkerManager::Implementation::OnMarkerMsg(const gz::msgs::Marker &_req) { std::lock_guard lock(this->mutex); this->markerMsgs.push_back(_req); } ///////////////////////////////////////////////// -bool MarkerManagerPrivate::OnMarkerMsgArray( +bool MarkerManager::Implementation::OnMarkerMsgArray( const gz::msgs::Marker_V&_req, gz::msgs::Boolean &_res) { std::lock_guard lock(this->mutex); @@ -284,7 +284,7 @@ bool MarkerManagerPrivate::OnMarkerMsgArray( } ////////////////////////////////////////////////// -bool MarkerManagerPrivate::ProcessMarkerMsg(const gz::msgs::Marker &_msg) +bool MarkerManager::Implementation::ProcessMarkerMsg(const gz::msgs::Marker &_msg) { // Get the namespace, if it exists. Otherwise, use the global namespace std::string ns; @@ -450,7 +450,7 @@ bool MarkerManagerPrivate::ProcessMarkerMsg(const gz::msgs::Marker &_msg) } ///////////////////////////////////////////////// -void MarkerManagerPrivate::SetVisual(const gz::msgs::Marker &_msg, +void MarkerManager::Implementation::SetVisual(const gz::msgs::Marker &_msg, const rendering::VisualPtr &_visualPtr) { // Set Visual Scale @@ -500,7 +500,7 @@ void MarkerManagerPrivate::SetVisual(const gz::msgs::Marker &_msg, } ///////////////////////////////////////////////// -void MarkerManagerPrivate::SetMarker(const gz::msgs::Marker &_msg, +void MarkerManager::Implementation::SetMarker(const gz::msgs::Marker &_msg, const rendering::MarkerPtr &_markerPtr) { _markerPtr->SetLayer(_msg.layer()); @@ -560,8 +560,8 @@ void MarkerManagerPrivate::SetMarker(const gz::msgs::Marker &_msg, } ///////////////////////////////////////////////// -rendering::MaterialPtr MarkerManagerPrivate::MsgToMaterial( - const gz::msgs::Marker &_msg) +rendering::MaterialPtr +MarkerManager::Implementation::MsgToMaterial(const gz::msgs::Marker &_msg) { rendering::MaterialPtr material = this->scene->CreateMaterial(); @@ -595,8 +595,8 @@ rendering::MaterialPtr MarkerManagerPrivate::MsgToMaterial( } ///////////////////////////////////////////////// -gz::rendering::MarkerType MarkerManagerPrivate::MsgToType( - const gz::msgs::Marker &_msg) +gz::rendering::MarkerType +MarkerManager::Implementation::MsgToType(const gz::msgs::Marker &_msg) { gz::msgs::Marker_Type marker = this->msg.type(); if (marker != _msg.type() && _msg.type() != gz::msgs::Marker::NONE) @@ -636,7 +636,7 @@ gz::rendering::MarkerType MarkerManagerPrivate::MsgToType( } ///////////////////////////////////////////////// -void MarkerManagerPrivate::OnWorldStatsMsg( +void MarkerManager::Implementation::OnWorldStatsMsg( const gz::msgs::WorldStatistics &_msg) { std::lock_guard lock(this->mutex); @@ -659,7 +659,7 @@ void MarkerManagerPrivate::OnWorldStatsMsg( ///////////////////////////////////////////////// MarkerManager::MarkerManager() - : dataPtr(new MarkerManagerPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -740,7 +740,7 @@ void MarkerManager::LoadConfig(const tinyxml2::XMLElement * _pluginElem) { // Subscribe to world_stats if (!this->dataPtr->node.Subscribe(statsTopic, - &MarkerManagerPrivate::OnWorldStatsMsg, this->dataPtr.get())) + &Implementation::OnWorldStatsMsg, this->dataPtr.get())) { gzerr << "Failed to subscribe to [" << statsTopic << "]" << std::endl; } diff --git a/src/plugins/marker_manager/MarkerManager.hh b/src/plugins/marker_manager/MarkerManager.hh index 704fb78c2..eae92d485 100644 --- a/src/plugins/marker_manager/MarkerManager.hh +++ b/src/plugins/marker_manager/MarkerManager.hh @@ -18,14 +18,13 @@ #ifndef GZ_GUI_PLUGINS_MARKERMANAGER_HH_ #define GZ_GUI_PLUGINS_MARKERMANAGER_HH_ +#include #include #include "gz/gui/Plugin.hh" namespace gz::gui::plugins { - class MarkerManagerPrivate; - /// \brief This plugin will be in charge of handling the markers in the /// scene. It will allow to add, modify or remove markers. /// @@ -56,7 +55,7 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc b/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc index b9f0cbbe0..9352a7a56 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc +++ b/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc @@ -36,42 +36,31 @@ #include ///////////////////////////////////////////////// -namespace gz +namespace gz::gui::plugins { -namespace gui +class GzCameraTextureRhiVulkanPrivate { -namespace plugins -{ - class GzCameraTextureRhiVulkanPrivate - { - public: VkImage textureId = 0; - }; - - class RenderThreadRhiVulkanPrivate - { - public: GzRenderer *renderer = nullptr; - public: void *texturePtr = nullptr; - public: QOffscreenSurface *surface = nullptr; - }; + public: VkImage textureId = 0; +}; - class TextureNodeRhiVulkanPrivate - { - public: VkImage textureId = 0; - public: VkImage newTextureId = 0; - public: std::weak_ptr lastCamera; - public: QSize size {0, 0}; - public: QSize newSize {0, 0}; - public: QMutex mutex; - public: QSGTexture *texture = nullptr; - public: QQuickWindow *window = nullptr; - }; -} -} -} +class RenderThreadRhiVulkanPrivate +{ + public: GzRenderer *renderer = nullptr; + public: void *texturePtr = nullptr; + public: QOffscreenSurface *surface = nullptr; +}; -using namespace gz; -using namespace gui; -using namespace plugins; +class TextureNodeRhiVulkanPrivate +{ + public: VkImage textureId = 0; + public: VkImage newTextureId = 0; + public: std::weak_ptr lastCamera; + public: QSize size {0, 0}; + public: QSize newSize {0, 0}; + public: QMutex mutex; + public: QSGTexture *texture = nullptr; + public: QQuickWindow *window = nullptr; +}; ///////////////////////////////////////////////// GzCameraTextureRhiVulkan::~GzCameraTextureRhiVulkan() = default; @@ -121,7 +110,7 @@ std::string RenderThreadRhiVulkan::Initialize() return loadingError; } - return std::string(); + return {}; } ///////////////////////////////////////////////// @@ -169,7 +158,7 @@ void RenderThreadRhiVulkan::ShutDown() this->dataPtr->texturePtr = nullptr; // Schedule this to be deleted only after we're done cleaning up - if (this->dataPtr->surface) + if (this->dataPtr->surface != nullptr) { this->dataPtr->surface->deleteLater(); } @@ -184,16 +173,11 @@ TextureNodeRhiVulkan::~TextureNodeRhiVulkan() ///////////////////////////////////////////////// TextureNodeRhiVulkan::TextureNodeRhiVulkan(QQuickWindow *_window, - rendering::CameraPtr & -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) - _camera -#endif - ) : + rendering::CameraPtr &_camera): dataPtr(std::make_unique()) { this->dataPtr->window = _window; -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) // It says Metal but it also works for Vulkan in the exact same way _camera->RenderTextureMetalId(&this->dataPtr->textureId); this->dataPtr->lastCamera = _camera; @@ -204,7 +188,6 @@ TextureNodeRhiVulkan::TextureNodeRhiVulkan(QQuickWindow *_window, 0, // QSize(static_cast(_camera->ImageWidth()), static_cast(_camera->ImageHeight()))); -#endif } ///////////////////////////////////////////////// @@ -216,7 +199,7 @@ QSGTexture *TextureNodeRhiVulkan::Texture() const ///////////////////////////////////////////////// bool TextureNodeRhiVulkan::HasNewTexture() const { - return (this->dataPtr->newTextureId != 0); + return (this->dataPtr->newTextureId != nullptr); } ///////////////////////////////////////////////// @@ -235,7 +218,7 @@ void TextureNodeRhiVulkan::PrepareNode() this->dataPtr->mutex.lock(); this->dataPtr->newTextureId = this->dataPtr->textureId; this->dataPtr->newSize = this->dataPtr->size; - this->dataPtr->textureId = 0; + this->dataPtr->textureId = nullptr; this->dataPtr->mutex.unlock(); // Required: PrepareForExternalSampling ensures the texture is ready to @@ -244,19 +227,18 @@ void TextureNodeRhiVulkan::PrepareNode() auto lastCamera = this->dataPtr->lastCamera.lock(); lastCamera->PrepareForExternalSampling(); - if (this->dataPtr->newTextureId) + if (this->dataPtr->newTextureId != nullptr) { delete this->dataPtr->texture; this->dataPtr->texture = nullptr; -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) this->dataPtr->texture = this->dataPtr->window->createTextureFromNativeObject( QQuickWindow::NativeObjectTexture, static_cast(&this->dataPtr->newTextureId), VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, this->dataPtr->newSize); -#endif } } -#endif +} // namespace gz::gui::plugins +#endif // HAVE_QT_VULKAN diff --git a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.hh b/src/plugins/minimal_scene/MinimalSceneRhiVulkan.hh index b211e4005..ab89019ca 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.hh +++ b/src/plugins/minimal_scene/MinimalSceneRhiVulkan.hh @@ -28,12 +28,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) -namespace gz -{ -namespace gui -{ -namespace plugins +namespace gz::gui::plugins { /// \brief Private data for GzCameraTextureRhiVulkan class GzCameraTextureRhiVulkanPrivate; @@ -138,10 +133,6 @@ namespace plugins /// \internal Pointer to private data private: std::unique_ptr dataPtr; }; -} -} -} - -#endif +} // namespace gz::gui::plugins #endif diff --git a/src/plugins/navsat_map/NavSatMap.cc b/src/plugins/navsat_map/NavSatMap.cc index 2d0ade70c..86333c373 100644 --- a/src/plugins/navsat_map/NavSatMap.cc +++ b/src/plugins/navsat_map/NavSatMap.cc @@ -31,7 +31,7 @@ namespace gz::gui::plugins { -class NavSatMapPrivate +class NavSatMap::Implementation { /// \brief List of topics publishing navSat messages. public: QStringList topicList; @@ -48,7 +48,7 @@ class NavSatMapPrivate ///////////////////////////////////////////////// NavSatMap::NavSatMap() - : dataPtr(new NavSatMapPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -78,7 +78,7 @@ void NavSatMap::LoadConfig(const tinyxml2::XMLElement *_pluginElem) if (topic.empty() && !topicPicker) { gzwarn << "Can't hide topic picker without a default topic." << std::endl; - topicPicker = true; + topicPicker = true; } this->PluginItem()->setProperty("showPicker", topicPicker); diff --git a/src/plugins/navsat_map/NavSatMap.hh b/src/plugins/navsat_map/NavSatMap.hh index 565b96374..fc21a8791 100644 --- a/src/plugins/navsat_map/NavSatMap.hh +++ b/src/plugins/navsat_map/NavSatMap.hh @@ -88,8 +88,8 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - }; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) +}; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_NAVSAT_MAP_HH_ diff --git a/src/plugins/plotting/TransportPlotting.cc b/src/plugins/plotting/TransportPlotting.cc index 57b53dfb6..771d51b96 100644 --- a/src/plugins/plotting/TransportPlotting.cc +++ b/src/plugins/plotting/TransportPlotting.cc @@ -15,10 +15,14 @@ * */ #include +#include #include "TransportPlotting.hh" namespace gz::gui::plugins { +////////////////////////////////////////// +TransportPlotting::TransportPlotting() = default; + ////////////////////////////////////////// TransportPlotting::~TransportPlotting() = default; @@ -28,14 +32,8 @@ void TransportPlotting::LoadConfig(const tinyxml2::XMLElement *) if (this->title.empty()) this->title = "Transport plotting"; } - -////////////////////////////////////////// -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 cc1887915..d987c6f7a 100644 --- a/src/plugins/plotting/TransportPlotting.hh +++ b/src/plugins/plotting/TransportPlotting.hh @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -36,15 +37,10 @@ class TransportPlotting : public gz::gui::Plugin public: TransportPlotting(); /// \brief Destructor - public: ~TransportPlotting(); + public: ~TransportPlotting() override; // Documentation inherited public: void LoadConfig(const tinyxml2::XMLElement *) override; - - /// \brief Interface with the UI to Handle Transport Plotting - GZ_UTILS_WARN_IGNORE__DLL_INTERFACE_MISSING - private: std::unique_ptr dataPtr; - GZ_UTILS_WARN_RESUME__DLL_INTERFACE_MISSING }; } // namespace gz::gui::plugins diff --git a/src/plugins/point_cloud/PointCloud.cc b/src/plugins/point_cloud/PointCloud.cc index e19830dbc..6bd01665e 100644 --- a/src/plugins/point_cloud/PointCloud.cc +++ b/src/plugins/point_cloud/PointCloud.cc @@ -21,6 +21,7 @@ #include "gz/msgs/pointcloud_packed.pb.h" #include +#include #include #include #include @@ -46,7 +47,7 @@ namespace gz::gui::plugins { /// \brief Private data class for PointCloud -class PointCloudPrivate +class PointCloud::Implementation { /// \brief Makes a request to populate the scene with markers public: void PublishMarkers(); @@ -55,7 +56,7 @@ class PointCloudPrivate public: void ClearMarkers(); /// \brief Transport node - public: gz::transport::Node node; + public: gz::transport::Node node {gz::transport::NodeOptions()}; /// \brief Name of topic for PointCloudPacked public: std::string pointCloudTopic{""}; @@ -99,7 +100,7 @@ class PointCloudPrivate ///////////////////////////////////////////////// PointCloud::PointCloud() - : dataPtr(std::make_unique()) + : dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -353,7 +354,7 @@ void PointCloud::OnFloatVService( } ////////////////////////////////////////////////// -void PointCloudPrivate::PublishMarkers() +void PointCloud::Implementation::PublishMarkers() { GZ_PROFILE("PointCloud::PublishMarkers"); @@ -432,7 +433,7 @@ void PointCloudPrivate::PublishMarkers() } ////////////////////////////////////////////////// -void PointCloudPrivate::ClearMarkers() +void PointCloud::Implementation::ClearMarkers() { if (this->pointCloudTopic.empty()) return; diff --git a/src/plugins/point_cloud/PointCloud.hh b/src/plugins/point_cloud/PointCloud.hh index 2b5a9f8da..29dfee2dd 100644 --- a/src/plugins/point_cloud/PointCloud.hh +++ b/src/plugins/point_cloud/PointCloud.hh @@ -25,10 +25,10 @@ #include "gz/gui/Plugin.hh" +#include + namespace gz::gui::plugins { - class PointCloudPrivate; - /// \brief Visualize `gz::msgs::PointCloudPacked` messages in a 3D /// scene. /// @@ -232,7 +232,7 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/publisher/Publisher.cc b/src/plugins/publisher/Publisher.cc index bbaa72477..cbcf4ce9f 100644 --- a/src/plugins/publisher/Publisher.cc +++ b/src/plugins/publisher/Publisher.cc @@ -15,6 +15,7 @@ * */ +#include #include #include #include @@ -25,7 +26,7 @@ namespace gz::gui::plugins { -class PublisherPrivate +class Publisher::Implementation { /// \brief Message type public: QString msgType = "gz.msgs.StringMsg"; @@ -51,7 +52,7 @@ class PublisherPrivate ///////////////////////////////////////////////// Publisher::Publisher() - : dataPtr(new PublisherPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } diff --git a/src/plugins/publisher/Publisher.hh b/src/plugins/publisher/Publisher.hh index 83cad8641..6385c34da 100644 --- a/src/plugins/publisher/Publisher.hh +++ b/src/plugins/publisher/Publisher.hh @@ -21,6 +21,7 @@ #include #include "gz/gui/Plugin.hh" +#include #ifndef _WIN32 # define Publisher_EXPORTS_API @@ -34,7 +35,13 @@ namespace gz::gui::plugins { - class PublisherPrivate; +/// \brief Widget which publishes a custom Gazebo Transport message. +/// +/// ## Configuration +/// This plugin doesn't accept any custom configuration. +class Publisher_EXPORTS_API Publisher : public Plugin +{ + Q_OBJECT /// \brief Widget which publishes a custom Gazebo Transport message. /// @@ -141,7 +148,7 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/screenshot/Screenshot.cc b/src/plugins/screenshot/Screenshot.cc index 9a7e57b16..a14387516 100644 --- a/src/plugins/screenshot/Screenshot.cc +++ b/src/plugins/screenshot/Screenshot.cc @@ -16,6 +16,7 @@ */ #include "Screenshot.hh" +#include #include #include @@ -34,7 +35,7 @@ namespace gz::gui::plugins { -class ScreenshotPrivate +class Screenshot::Implementation { /// \brief Node for communication public: gz::transport::Node node; @@ -57,7 +58,7 @@ class ScreenshotPrivate ///////////////////////////////////////////////// Screenshot::Screenshot() - : dataPtr(std::make_unique()) + : dataPtr(gz::utils::MakeUniqueImpl()) { std::string home; common::env(GZ_HOMEDIR, home); diff --git a/src/plugins/screenshot/Screenshot.hh b/src/plugins/screenshot/Screenshot.hh index ace58577f..1f73a8f16 100644 --- a/src/plugins/screenshot/Screenshot.hh +++ b/src/plugins/screenshot/Screenshot.hh @@ -26,10 +26,10 @@ #include "gz/gui/qt.h" #include "gz/gui/Plugin.hh" +#include + namespace gz::gui::plugins { - class ScreenshotPrivate; - /// \brief Provides a button and a transport service for taking a screenshot /// of current 3D scene. /// @@ -118,7 +118,7 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/shutdown_button/ShutdownButton.hh b/src/plugins/shutdown_button/ShutdownButton.hh index 91b0ed9cc..ba5021b56 100644 --- a/src/plugins/shutdown_button/ShutdownButton.hh +++ b/src/plugins/shutdown_button/ShutdownButton.hh @@ -41,7 +41,7 @@ namespace gz::gui::plugins public: ShutdownButton(); /// \brief Destructor - public: virtual ~ShutdownButton(); + public: virtual ~ShutdownButton() override; // Documentation inherited public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; diff --git a/src/plugins/tape_measure/TapeMeasure.cc b/src/plugins/tape_measure/TapeMeasure.cc index 9ac357a56..d3fa44917 100644 --- a/src/plugins/tape_measure/TapeMeasure.cc +++ b/src/plugins/tape_measure/TapeMeasure.cc @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -35,7 +36,7 @@ namespace gz::gui { -class TapeMeasurePrivate +class TapeMeasure::Implementation { /// \brief Gazebo communication node. public: transport::Node node; @@ -90,7 +91,7 @@ class TapeMeasurePrivate ///////////////////////////////////////////////// TapeMeasure::TapeMeasure() - : dataPtr(std::make_unique()) + : dataPtr(gz::utils::MakeUniqueImpl()) { } diff --git a/src/plugins/tape_measure/TapeMeasure.hh b/src/plugins/tape_measure/TapeMeasure.hh index 90e5ab119..85b4f8723 100644 --- a/src/plugins/tape_measure/TapeMeasure.hh +++ b/src/plugins/tape_measure/TapeMeasure.hh @@ -18,6 +18,7 @@ #ifndef GZ_GUI_TAPEMEASURE_HH_ #define GZ_GUI_TAPEMEASURE_HH_ +#include #include #include @@ -26,8 +27,6 @@ namespace gz::gui { - class TapeMeasurePrivate; - /// \brief Provides buttons for the tape measure tool. class TapeMeasure : public gz::gui::Plugin { @@ -96,8 +95,7 @@ namespace gz::gui /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui - -#endif // GZ_GUI_TAPEMEASURE_HH_ +#endif // GZ_GUI_PLUGINS_TAPEMEASURE_HH_ diff --git a/src/plugins/teleop/Teleop.cc b/src/plugins/teleop/Teleop.cc index 29bfd0ba1..ccc12f6ac 100644 --- a/src/plugins/teleop/Teleop.cc +++ b/src/plugins/teleop/Teleop.cc @@ -15,6 +15,7 @@ * */ +#include #include #include @@ -50,7 +51,7 @@ enum class KeyYaw{ namespace gz::gui::plugins { -class TeleopPrivate +class Teleop::Implementation { /// \brief Node for communication. public: gz::transport::Node node; @@ -102,7 +103,7 @@ class TeleopPrivate }; ///////////////////////////////////////////////// -Teleop::Teleop(): dataPtr(std::make_unique()) +Teleop::Teleop(): dataPtr(gz::utils::MakeUniqueImpl()) { // Initialize publisher using default topic. this->dataPtr->cmdVelPub = transport::Node::Publisher(); diff --git a/src/plugins/teleop/Teleop.hh b/src/plugins/teleop/Teleop.hh index 6bab0107b..596084e29 100644 --- a/src/plugins/teleop/Teleop.hh +++ b/src/plugins/teleop/Teleop.hh @@ -20,10 +20,10 @@ #include -#include - #include #include +#include +#include #ifndef _WIN32 # define Teleop_EXPORTS_API @@ -37,8 +37,6 @@ namespace gz::gui::plugins { - class TeleopPrivate; - /// \brief Publish teleop stokes to a user selected topic, /// or to '/cmd_vel' if no topic is selected. /// Buttons, the keyboard or sliders can be used to move a @@ -85,10 +83,10 @@ namespace gz::gui::plugins public: Teleop(); /// \brief Destructor - public: virtual ~Teleop(); + public: ~Teleop() override; // Documentation inherited. - public: virtual void LoadConfig(const tinyxml2::XMLElement *) override; + public: void LoadConfig(const tinyxml2::XMLElement *) override; /// \brief Filters events of type 'keypress' and 'keyrelease'. protected: bool eventFilter(QObject *_obj, QEvent *_event) override; @@ -155,8 +153,7 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; - + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/topic_echo/TopicEcho.cc b/src/plugins/topic_echo/TopicEcho.cc index 405cc57f2..e91c28478 100644 --- a/src/plugins/topic_echo/TopicEcho.cc +++ b/src/plugins/topic_echo/TopicEcho.cc @@ -15,6 +15,7 @@ * */ +#include #include #include #include @@ -25,13 +26,13 @@ namespace gz::gui::plugins { -class TopicEchoPrivate +class TopicEcho::Implementation { /// \brief Topic public: QString topic{"/echo"}; /// \brief A list of text data. - public: QStringListModel msgList; + public: QStringListModel msgList {nullptr}; /// \brief Size of the text buffer. The size is the number of /// messages. @@ -49,7 +50,7 @@ class TopicEchoPrivate ///////////////////////////////////////////////// TopicEcho::TopicEcho() - : dataPtr(new TopicEchoPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { // Connect model App()->Engine()->rootContext()->setContextProperty("TopicEchoMsgList", diff --git a/src/plugins/topic_echo/TopicEcho.hh b/src/plugins/topic_echo/TopicEcho.hh index 16f93e4e9..5ffd5d358 100644 --- a/src/plugins/topic_echo/TopicEcho.hh +++ b/src/plugins/topic_echo/TopicEcho.hh @@ -40,11 +40,10 @@ #include #include "gz/gui/Plugin.hh" +#include namespace gz::gui::plugins { - class TopicEchoPrivate; - /// \brief Echo messages coming through a Gazebo Transport topic. /// /// ## Configuration @@ -73,10 +72,10 @@ namespace gz::gui::plugins public: TopicEcho(); /// \brief Destructor - public: virtual ~TopicEcho(); + public: ~TopicEcho() override; // Documentation inherited - public: virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem); + public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; /// \brief Get the topic as a string, for example /// '/echo' @@ -124,7 +123,7 @@ namespace gz::gui::plugins /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/topic_viewer/TopicViewer.cc b/src/plugins/topic_viewer/TopicViewer.cc index 2082ca5fd..edbecae45 100644 --- a/src/plugins/topic_viewer/TopicViewer.cc +++ b/src/plugins/topic_viewer/TopicViewer.cc @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -34,17 +35,20 @@ #include "TopicViewer.hh" -#define NAME_KEY "name" -#define TYPE_KEY "type" -#define TOPIC_KEY "topic" -#define PATH_KEY "path" -#define PLOT_KEY "plottable" - -#define NAME_ROLE 51 -#define TYPE_ROLE 52 -#define TOPIC_ROLE 53 -#define PATH_ROLE 54 -#define PLOT_ROLE 55 +namespace +{ +constexpr const char * NAME_KEY = "name"; +constexpr const char * TYPE_KEY = "type"; +constexpr const char * TOPIC_KEY = "topic"; +constexpr const char * PATH_KEY = "path"; +constexpr const char * PLOT_KEY = "plottable"; + +constexpr uint8_t NAME_ROLE = 51; +constexpr uint8_t TYPE_ROLE = 52; +constexpr uint8_t TOPIC_ROLE = 53; +constexpr uint8_t PATH_ROLE = 54; +constexpr uint8_t PLOT_ROLE = 55; +} // namespace namespace gz::gui::plugins { @@ -56,26 +60,27 @@ class TopicsModel : public QStandardItemModel /// \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; + return + { + {NAME_ROLE, NAME_KEY}, + {TYPE_ROLE, TYPE_KEY}, + {TOPIC_ROLE, TOPIC_KEY}, + {PATH_ROLE, PATH_KEY}, + {PLOT_ROLE, PLOT_KEY}, + }; } }; -class TopicViewerPrivate +class TopicViewer::Implementation { /// \brief Node for Commincation public: gz::transport::Node node; /// \brief Model to create it from the available topics and messages - public: TopicsModel *model; + public: TopicsModel *model {nullptr}; /// \brief Timer to update the model and keep track of its changes - public: QTimer *timer; + public: QTimer *timer {nullptr}; /// \brief topic: msgType map to keep track of the model current topics public: std::map currentTopics; @@ -139,7 +144,8 @@ class TopicViewerPrivate public: std::vector plotableTypes; }; -TopicViewer::TopicViewer() : dataPtr(new TopicViewerPrivate) +TopicViewer::TopicViewer() + : dataPtr(gz::utils::MakeUniqueImpl()) { using namespace google::protobuf; this->dataPtr->plotableTypes.push_back(FieldDescriptor::Type::TYPE_DOUBLE); @@ -177,7 +183,7 @@ QStandardItemModel *TopicViewer::Model() } ////////////////////////////////////////////////// -void TopicViewerPrivate::CreateModel() +void TopicViewer::Implementation::CreateModel() { this->model = new TopicsModel(); @@ -198,7 +204,7 @@ void TopicViewerPrivate::CreateModel() } ////////////////////////////////////////////////// -void TopicViewerPrivate::AddTopic(const std::string &_topic, +void TopicViewer::Implementation::AddTopic(const std::string &_topic, const std::string &_msg) { QStandardItem *topicItem = this->FactoryItem(_topic, _msg); @@ -213,7 +219,7 @@ void TopicViewerPrivate::AddTopic(const std::string &_topic, } ////////////////////////////////////////////////// -void TopicViewerPrivate::AddField(QStandardItem *_parentItem, +void TopicViewer::Implementation::AddField(QStandardItem *_parentItem, const std::string &_msgName, const std::string &_msgType) { @@ -275,7 +281,7 @@ void TopicViewerPrivate::AddField(QStandardItem *_parentItem, } ////////////////////////////////////////////////// -QStandardItem *TopicViewerPrivate::FactoryItem(const std::string &_name, +QStandardItem *TopicViewer::Implementation::FactoryItem(const std::string &_name, const std::string &_type, const std::string &_path, const std::string &_topic) @@ -297,7 +303,7 @@ QStandardItem *TopicViewerPrivate::FactoryItem(const std::string &_name, } ////////////////////////////////////////////////// -void TopicViewerPrivate::SetItemTopic(QStandardItem *_item) +void TopicViewer::Implementation::SetItemTopic(QStandardItem *_item) { std::string topic = this->TopicName(_item); QVariant Topic(QString::fromStdString(topic)); @@ -305,7 +311,7 @@ void TopicViewerPrivate::SetItemTopic(QStandardItem *_item) } ////////////////////////////////////////////////// -void TopicViewerPrivate::SetItemPath(QStandardItem *_item) +void TopicViewer::Implementation::SetItemPath(QStandardItem *_item) { std::string path = this->ItemPath(_item); QVariant Path(QString::fromStdString(path)); @@ -313,7 +319,8 @@ void TopicViewerPrivate::SetItemPath(QStandardItem *_item) } ////////////////////////////////////////////////// -std::string TopicViewerPrivate::TopicName(const QStandardItem *_item) const +std::string TopicViewer::Implementation::TopicName( + const QStandardItem *_item) const { QStandardItem *parent = _item->parent(); @@ -328,7 +335,8 @@ std::string TopicViewerPrivate::TopicName(const QStandardItem *_item) const } ////////////////////////////////////////////////// -std::string TopicViewerPrivate::ItemPath(const QStandardItem *_item) const +std::string TopicViewer::Implementation::ItemPath( + const QStandardItem *_item) const { std::deque path; while (_item) @@ -353,7 +361,7 @@ std::string TopicViewerPrivate::ItemPath(const QStandardItem *_item) const } ///////////////////////////////////////////////// -bool TopicViewerPrivate::IsPlotable( +bool TopicViewer::Implementation::IsPlotable( const google::protobuf::FieldDescriptor::Type &_type) { return std::find(this->plotableTypes.begin(), this->plotableTypes.end(), diff --git a/src/plugins/topic_viewer/TopicViewer.hh b/src/plugins/topic_viewer/TopicViewer.hh index d2ca70233..a53d2fded 100644 --- a/src/plugins/topic_viewer/TopicViewer.hh +++ b/src/plugins/topic_viewer/TopicViewer.hh @@ -21,6 +21,7 @@ #include #include +#include #ifndef _WIN32 # define TopicViewer_EXPORTS_API @@ -35,7 +36,6 @@ namespace gz::gui::plugins { class TopicsModel; - class TopicViewerPrivate; /// \brief a Plugin to view the topics and their msgs & fields /// Field's informations can be passed by dragging them via the UI @@ -60,7 +60,7 @@ namespace gz::gui::plugins public slots: void UpdateModel(); /// \brief Pointer to private data. - private: std:: unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.cc b/src/plugins/transport_scene_manager/TransportSceneManager.cc index 735ed5ee8..267baa6cf 100644 --- a/src/plugins/transport_scene_manager/TransportSceneManager.cc +++ b/src/plugins/transport_scene_manager/TransportSceneManager.cc @@ -16,6 +16,7 @@ */ #include +#include #include #include #include @@ -57,7 +58,7 @@ namespace gz::gui::plugins { /// \brief Private data class for TransportSceneManager -class TransportSceneManagerPrivate +class TransportSceneManager::Implementation { /// \brief Make the scene service request and populate the scene public: void Request(); @@ -176,7 +177,7 @@ class TransportSceneManagerPrivate ///////////////////////////////////////////////// TransportSceneManager::TransportSceneManager() - : dataPtr(new TransportSceneManagerPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -252,12 +253,12 @@ void TransportSceneManager::LoadConfig(const tinyxml2::XMLElement *_pluginElem) } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::InitializeTransport() +void TransportSceneManager::Implementation::InitializeTransport() { this->Request(); if (!this->node.Subscribe(this->poseTopic, - &TransportSceneManagerPrivate::OnPoseVMsg, this)) + &Implementation::OnPoseVMsg, this)) { gzerr << "Error subscribing to pose topic: " << this->poseTopic << std::endl; @@ -269,7 +270,7 @@ void TransportSceneManagerPrivate::InitializeTransport() } if (!this->node.Subscribe(this->deletionTopic, - &TransportSceneManagerPrivate::OnDeletionMsg, this)) + &Implementation::OnDeletionMsg, this)) { gzerr << "Error subscribing to deletion topic: " << this->deletionTopic << std::endl; @@ -281,7 +282,7 @@ void TransportSceneManagerPrivate::InitializeTransport() } if (!this->node.Subscribe(this->sceneTopic, - &TransportSceneManagerPrivate::OnSceneMsg, this)) + &Implementation::OnSceneMsg, this)) { gzerr << "Error subscribing to scene topic: " << this->sceneTopic << std::endl; @@ -308,7 +309,7 @@ bool TransportSceneManager::eventFilter(QObject *_obj, QEvent *_event) } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::Request() +void TransportSceneManager::Implementation::Request() { // wait for the service to be advertized std::vector publishers; @@ -324,7 +325,7 @@ void TransportSceneManagerPrivate::Request() } if (publishers.empty() || !this->node.Request(this->service, - &TransportSceneManagerPrivate::OnSceneSrvMsg, this)) + &Implementation::OnSceneSrvMsg, this)) { gzerr << "Error making service request to [" << this->service << "]" << std::endl; @@ -332,7 +333,7 @@ void TransportSceneManagerPrivate::Request() } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::OnPoseVMsg(const msgs::Pose_V &_msg) +void TransportSceneManager::Implementation::OnPoseVMsg(const msgs::Pose_V &_msg) { std::lock_guard lock(this->msgMutex); for (int i = 0; i < _msg.pose_size(); ++i) @@ -351,7 +352,8 @@ void TransportSceneManagerPrivate::OnPoseVMsg(const msgs::Pose_V &_msg) } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::OnDeletionMsg(const msgs::UInt32_V &_msg) +void TransportSceneManager::Implementation::OnDeletionMsg( + const msgs::UInt32_V &_msg) { std::lock_guard lock(this->msgMutex); std::copy(_msg.data().begin(), _msg.data().end(), @@ -359,7 +361,7 @@ void TransportSceneManagerPrivate::OnDeletionMsg(const msgs::UInt32_V &_msg) } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::OnRender() +void TransportSceneManager::Implementation::OnRender() { if (nullptr == this->scene) { @@ -368,7 +370,7 @@ void TransportSceneManagerPrivate::OnRender() return; this->initializeTransport = std::thread( - &TransportSceneManagerPrivate::InitializeTransport, this); + &Implementation::InitializeTransport, this); } std::lock_guard lock(this->msgMutex); @@ -430,15 +432,15 @@ void TransportSceneManagerPrivate::OnRender() } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::OnSceneMsg(const msgs::Scene &_msg) +void TransportSceneManager::Implementation::OnSceneMsg(const msgs::Scene &_msg) { std::lock_guard lock(this->msgMutex); this->sceneMsgs.push_back(_msg); } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::OnSceneSrvMsg(const msgs::Scene &_msg, - const bool result) +void TransportSceneManager::Implementation::OnSceneSrvMsg( + const msgs::Scene &_msg, const bool result) { if (!result) { @@ -454,7 +456,7 @@ void TransportSceneManagerPrivate::OnSceneSrvMsg(const msgs::Scene &_msg, } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::LoadScene(const msgs::Scene &_msg) +void TransportSceneManager::Implementation::LoadScene(const msgs::Scene &_msg) { rendering::VisualPtr rootVis = this->scene->RootVisual(); @@ -487,7 +489,7 @@ void TransportSceneManagerPrivate::LoadScene(const msgs::Scene &_msg) } ///////////////////////////////////////////////// -rendering::VisualPtr TransportSceneManagerPrivate::LoadModel( +rendering::VisualPtr TransportSceneManager::Implementation::LoadModel( const msgs::Model &_msg) { rendering::VisualPtr modelVis; @@ -529,7 +531,7 @@ rendering::VisualPtr TransportSceneManagerPrivate::LoadModel( } ///////////////////////////////////////////////// -rendering::VisualPtr TransportSceneManagerPrivate::LoadLink( +rendering::VisualPtr TransportSceneManager::Implementation::LoadLink( const msgs::Link &_msg) { rendering::VisualPtr linkVis; @@ -570,7 +572,7 @@ rendering::VisualPtr TransportSceneManagerPrivate::LoadLink( } ///////////////////////////////////////////////// -rendering::VisualPtr TransportSceneManagerPrivate::LoadVisual( +rendering::VisualPtr TransportSceneManager::Implementation::LoadVisual( const msgs::Visual &_msg) { if (!_msg.has_geometry()) @@ -674,7 +676,7 @@ rendering::VisualPtr TransportSceneManagerPrivate::LoadVisual( } ///////////////////////////////////////////////// -rendering::GeometryPtr TransportSceneManagerPrivate::LoadGeometry( +rendering::GeometryPtr TransportSceneManager::Implementation::LoadGeometry( const msgs::Geometry &_msg, math::Vector3d &_scale, math::Pose3d &_localPose) { @@ -767,7 +769,7 @@ rendering::GeometryPtr TransportSceneManagerPrivate::LoadGeometry( } ///////////////////////////////////////////////// -rendering::MaterialPtr TransportSceneManagerPrivate::LoadMaterial( +rendering::MaterialPtr TransportSceneManager::Implementation::LoadMaterial( const msgs::Material &_msg) { rendering::MaterialPtr material = this->scene->CreateMaterial(); @@ -792,7 +794,7 @@ rendering::MaterialPtr TransportSceneManagerPrivate::LoadMaterial( } ///////////////////////////////////////////////// -rendering::LightPtr TransportSceneManagerPrivate::LoadLight( +rendering::LightPtr TransportSceneManager::Implementation::LoadLight( const msgs::Light &_msg) { rendering::LightPtr light; @@ -848,7 +850,8 @@ rendering::LightPtr TransportSceneManagerPrivate::LoadLight( } ///////////////////////////////////////////////// -void TransportSceneManagerPrivate::DeleteEntity(const unsigned int _entity) +void TransportSceneManager::Implementation::DeleteEntity( + const unsigned int _entity) { if (this->visuals.find(_entity) != this->visuals.end()) { diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.hh b/src/plugins/transport_scene_manager/TransportSceneManager.hh index bc33a01df..faab9fdc4 100644 --- a/src/plugins/transport_scene_manager/TransportSceneManager.hh +++ b/src/plugins/transport_scene_manager/TransportSceneManager.hh @@ -22,10 +22,10 @@ #include "gz/gui/Plugin.hh" +#include + namespace gz::gui::plugins { - class TransportSceneManagerPrivate; - /// \brief Provides a Gazebo Transport interface to /// `gz::gui::plugins::MinimalScene`. /// @@ -46,19 +46,18 @@ namespace gz::gui::plugins /// \brief Constructor public: TransportSceneManager(); - /// \brief Destructor - public: virtual ~TransportSceneManager(); + /// \brief Destructor + public: ~TransportSceneManager() override; - // Documentation inherited - public: virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem) - override; + // Documentation inherited + public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; // Documentation inherited private: bool eventFilter(QObject *_obj, QEvent *_event) override; /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/world_control/WorldControl.cc b/src/plugins/world_control/WorldControl.cc index bea4bced0..86095179c 100644 --- a/src/plugins/world_control/WorldControl.cc +++ b/src/plugins/world_control/WorldControl.cc @@ -35,7 +35,7 @@ namespace gz::gui::plugins { -class WorldControlPrivate +class WorldControl::Implementation { /// \brief Send the world control event or call the control service. /// \param[in] _msg Message to send. @@ -71,7 +71,7 @@ class WorldControlPrivate ///////////////////////////////////////////////// WorldControl::WorldControl() - : dataPtr(new WorldControlPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -327,7 +327,7 @@ void WorldControl::OnStep() } ///////////////////////////////////////////////// -void WorldControlPrivate::SendEventMsg(const msgs::WorldControl &_msg) +void WorldControl::Implementation::SendEventMsg(const msgs::WorldControl &_msg) { if (this->useEvent) { diff --git a/src/plugins/world_control/WorldControl.hh b/src/plugins/world_control/WorldControl.hh index 486bfc5e6..fda902b3f 100644 --- a/src/plugins/world_control/WorldControl.hh +++ b/src/plugins/world_control/WorldControl.hh @@ -24,6 +24,8 @@ #include "gz/gui/Plugin.hh" +#include + #ifndef _WIN32 # define WorldControl_EXPORTS_API #else @@ -36,8 +38,6 @@ namespace gz::gui::plugins { - class WorldControlPrivate; - /// \brief This plugin provides a world control panel which may have a /// play / pause and step buttons. /// @@ -63,11 +63,11 @@ namespace gz::gui::plugins /// \brief Constructor public: WorldControl(); - /// \brief Destructor - public: virtual ~WorldControl(); + /// \brief Destructor + public: ~WorldControl() override; - // Documentation inherited - public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem); + // Documentation inherited + public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; /// \brief Callback in main thread when diagnostics come in public slots: void ProcessMsg(); @@ -101,7 +101,7 @@ namespace gz::gui::plugins private: void OnWorldStatsMsg(const gz::msgs::WorldStatistics &_msg); // Private data - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui::plugins diff --git a/src/plugins/world_stats/WorldStats.cc b/src/plugins/world_stats/WorldStats.cc index c598b7253..96c2ecead 100644 --- a/src/plugins/world_stats/WorldStats.cc +++ b/src/plugins/world_stats/WorldStats.cc @@ -26,12 +26,13 @@ #include #include #include +#include #include "gz/gui/Helpers.hh" namespace gz::gui::plugins { -class WorldStatsPrivate +class WorldStats::Implementation { /// \brief Message holding latest world statistics public: gz::msgs::WorldStatistics msg; @@ -65,7 +66,7 @@ class WorldStatsPrivate ///////////////////////////////////////////////// WorldStats::WorldStats() - : dataPtr(new WorldStatsPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { } diff --git a/src/plugins/world_stats/WorldStats.hh b/src/plugins/world_stats/WorldStats.hh index deda05ad1..1f839920e 100644 --- a/src/plugins/world_stats/WorldStats.hh +++ b/src/plugins/world_stats/WorldStats.hh @@ -25,6 +25,8 @@ #include "gz/gui/Export.hh" #include "gz/gui/Plugin.hh" +#include + #ifndef _WIN32 # define WorldStats_EXPORTS_API #else @@ -37,6 +39,7 @@ namespace gz::gui::plugins { +<<<<<<< HEAD class WorldStatsPrivate; /// \brief This plugin provides a time panel which may display: @@ -62,6 +65,31 @@ namespace gz::gui::plugins class WorldStats_EXPORTS_API WorldStats: public gz::gui::Plugin { Q_OBJECT +======= +/// \brief This plugin provides a time panel which may display: +/// * Simulation time +/// * Real time +/// * Real time factor +/// * Iterations +/// +/// ## Configuration +/// +/// * \ : Set to true to display a sim time widget, false by +/// default. +/// * \ : True to display a real time widget, false by default. +/// * \ : True to display a real time factor widget, +/// false by default. +/// * \ : True to display an iterations widget, false by default. +/// * \ : Topic to receive world statistics, optional. If not present, +/// the plugin will attempt to create a topic with the main +/// window's `worldName` property. +/// +/// If no elements are filled for the plugin, all properties will be +/// displayed. +class WorldStats_EXPORTS_API WorldStats: public gz::gui::Plugin +{ + Q_OBJECT +>>>>>>> 27490228 (Remaining plugins to use implptr) /// \brief Real time factor Q_PROPERTY( @@ -98,11 +126,19 @@ namespace gz::gui::plugins /// \brief Constructor public: WorldStats(); +<<<<<<< HEAD /// \brief Destructor public: virtual ~WorldStats(); // Documentation inherited public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem); +======= + /// \brief Destructor + public: ~WorldStats() override; + + // Documentation inherited + public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; +>>>>>>> 27490228 (Remaining plugins to use implptr) /// \brief Callback in main thread when diagnostics come in public slots: void ProcessMsg(); @@ -154,9 +190,15 @@ namespace gz::gui::plugins /// \brief Subscriber callback when new world statistics are received private: void OnWorldStatsMsg(const gz::msgs::WorldStatistics &_msg); +<<<<<<< HEAD // Private data private: std::unique_ptr dataPtr; }; +======= + // Private data + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) +}; +>>>>>>> 27490228 (Remaining plugins to use implptr) } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_WORLDSTATS_HH_