From 4f98aa309042bdaeeea19471dce1bf45c61a63e6 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 5 Oct 2023 22:21:38 +0000 Subject: [PATCH 01/33] Change main gui classes to implptr Signed-off-by: Michael Carroll --- include/gz/gui/Application.hh | 15 ++------------- include/gz/gui/Dialog.hh | 17 +++-------------- include/gz/gui/MainWindow.hh | 12 ++---------- include/gz/gui/PlottingInterface.hh | 19 +++++++------------ include/gz/gui/Plugin.hh | 25 ++++--------------------- src/Application.cc | 6 +++--- src/Dialog.cc | 5 +++-- src/MainWindow.cc | 26 ++++++++++++++------------ src/PlottingInterface.cc | 25 ++++++++++++++----------- src/Plugin.cc | 16 ++++++++++++++-- 10 files changed, 66 insertions(+), 100 deletions(-) diff --git a/include/gz/gui/Application.hh b/include/gz/gui/Application.hh index 75f14bdcf..0397372ed 100644 --- a/include/gz/gui/Application.hh +++ b/include/gz/gui/Application.hh @@ -25,12 +25,7 @@ #include "gz/gui/qt.h" #include "gz/gui/Export.hh" -#ifdef _WIN32 -// Disable warning C4251 which is triggered by -// std::unique_ptr -#pragma warning(push) -#pragma warning(disable: 4251) -#endif +#include namespace tinyxml2 { @@ -39,7 +34,6 @@ namespace tinyxml2 namespace gz::gui { - class ApplicationPrivate; class Dialog; class MainWindow; class Plugin; @@ -208,7 +202,7 @@ namespace gz::gui /// \internal /// \brief Private data pointer - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; /// \brief Get current running application, this is a cast of qGuiApp. @@ -216,9 +210,4 @@ namespace gz::gui GZ_GUI_VISIBLE Application *App(); } // namespace gz::gui - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - #endif // GZ_GUI_APPLICATION_HH_ diff --git a/include/gz/gui/Dialog.hh b/include/gz/gui/Dialog.hh index 17261f485..43ba6c132 100644 --- a/include/gz/gui/Dialog.hh +++ b/include/gz/gui/Dialog.hh @@ -24,17 +24,10 @@ #include "gz/gui/qt.h" #include "gz/gui/Export.hh" -#ifdef _WIN32 -// Disable warning C4251 which is triggered by -// std::unique_ptr -#pragma warning(push) -#pragma warning(disable: 4251) -#endif +#include namespace gz::gui { - class DialogPrivate; - /// \brief Gui plugin class GZ_GUI_VISIBLE Dialog : public QObject { @@ -90,12 +83,8 @@ namespace gz::gui /// \internal /// \brief Private data pointer - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; +}; } // namespace gz::gui - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - #endif // GZ_GUI_DIALOG_HH_ diff --git a/include/gz/gui/MainWindow.hh b/include/gz/gui/MainWindow.hh index ca1baac2e..afa604195 100644 --- a/include/gz/gui/MainWindow.hh +++ b/include/gz/gui/MainWindow.hh @@ -28,17 +28,9 @@ #include "gz/gui/qt.h" #include "gz/gui/Export.hh" -#ifdef _WIN32 -// Disable warning C4251 which is triggered by -// std::unique_ptr -#pragma warning(push) -#pragma warning(disable: 4251) -#endif - namespace gz::gui { Q_NAMESPACE - class MainWindowPrivate; struct WindowConfig; /// \brief The action executed when GUI is closed without prompt. @@ -583,8 +575,8 @@ namespace gz::gui /// \internal /// \brief Private data pointer - private: std::unique_ptr dataPtr; - }; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) +}; /// \brief Holds configurations related to a MainWindow. struct GZ_GUI_VISIBLE WindowConfig diff --git a/include/gz/gui/PlottingInterface.hh b/include/gz/gui/PlottingInterface.hh index 4ffa76838..85b7ae2e5 100644 --- a/include/gz/gui/PlottingInterface.hh +++ b/include/gz/gui/PlottingInterface.hh @@ -38,10 +38,10 @@ #include "gz/gui/Export.hh" +#include + namespace gz::gui { -class PlotDataPrivate; - /// \brief Plot Data containter to hold value and registered charts /// Can be a Field or a PlotComponent /// Used by PlottingInterface and Gazebo Plotting @@ -85,11 +85,9 @@ class GZ_GUI_VISIBLE PlotData public: std::set &Charts(); /// \brief Private data member. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; -class TopicPrivate; - /// \brief Plotting Topic to handle published topics & their registered fields class GZ_GUI_VISIBLE Topic : public QObject { @@ -149,11 +147,9 @@ class GZ_GUI_VISIBLE Topic : public QObject public: void SetPlottingTimeRef(const std::shared_ptr &_time); /// \brief Private data member. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; -class TransportPrivate; - /// \brief Handle transport topics subscribing for one object (Chart) class GZ_GUI_VISIBLE Transport : public QObject { @@ -203,12 +199,11 @@ class GZ_GUI_VISIBLE Transport : public QObject /// \param[in] _y y coordinates of the plot point signals: void plot(int _chart, QString _fieldID, double _x, double _y); + private: /// \brief Private data member. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; -class PlottingIfacePrivate; - /// \brief Plotting Interface /// Responsible for plotting transport msgs-fields /// Used by TransportPlotting Plugin & GazeboPlotting Plugin @@ -328,7 +323,7 @@ class GZ_GUI_VISIBLE PlottingInterface : public QObject public slots: void UpdateTime(); /// \brief Private data member. - private: std::unique_ptr dataPtr; + private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui #endif // GZ_GUI_PLOTTINGINTERFACE_HH_ diff --git a/include/gz/gui/Plugin.hh b/include/gz/gui/Plugin.hh index 518ef2f0c..f1a3b6d0f 100644 --- a/include/gz/gui/Plugin.hh +++ b/include/gz/gui/Plugin.hh @@ -18,26 +18,18 @@ #define GZ_GUI_PLUGIN_HH_ #include +#include #include #include #include "gz/gui/qt.h" #include "gz/gui/Export.hh" -#ifdef _WIN32 -// Disable warning C4251 which is triggered by -// std::unique_ptr -#pragma warning(push) -#pragma warning(disable: 4251) -#endif - namespace gz::gui { /// \brief Namespace for all plugins namespace plugins {} - class PluginPrivate; - /// \brief Base class for Gazebo GUI plugins. /// /// When inheriting from this plugin, the following are assumed: @@ -102,15 +94,11 @@ namespace gz::gui /// /// \sa Load /// \param[in] _pluginElem Element containing configuration - protected: virtual void LoadConfig( - const tinyxml2::XMLElement *_pluginElem) - { - (void)_pluginElem; - } + protected: virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem); /// \brief Get title /// \return Plugin title. - public: virtual std::string Title() const {return this->title;} + public: virtual std::string Title() const; /// \brief Get the value of the the `delete_later` element from the /// configuration file, which defaults to false. @@ -142,12 +130,7 @@ namespace gz::gui /// \internal /// \brief Pointer to private data - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - #endif // GZ_GUI_PLUGIN_HH_ diff --git a/src/Application.cc b/src/Application.cc index 6031e4c30..d6a3fb290 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -39,7 +39,7 @@ namespace gz::gui { -class ApplicationPrivate +class Application::Implementation { /// \brief QML engine public: QQmlApplicationEngine *engine{nullptr}; @@ -91,7 +91,7 @@ enum class GZ_COMMON_HIDDEN AvailableAPIs Application::Application(int &_argc, char **_argv, const WindowType _type, const char *_renderEngineGuiApiBackend) : QApplication(_argc, _argv), - dataPtr(new ApplicationPrivate) + dataPtr(gz::utils::MakeUniqueImpl()) { gzdbg << "Initializing application." << std::endl; @@ -880,7 +880,7 @@ void Application::RemovePlugin(std::shared_ptr _plugin) } ////////////////////////////////////////////////// -void ApplicationPrivate::MessageHandler(QtMsgType _type, +void Application::Implementation::MessageHandler(QtMsgType _type, const QMessageLogContext &_context, const QString &_msg) { std::string msg = "[QT] " + _msg.toStdString(); diff --git a/src/Dialog.cc b/src/Dialog.cc index 91a8b169c..7701c2cfd 100644 --- a/src/Dialog.cc +++ b/src/Dialog.cc @@ -18,12 +18,13 @@ #include #include +#include #include "gz/gui/Application.hh" #include "gz/gui/Dialog.hh" namespace gz::gui { -class DialogPrivate +class Dialog::Implementation { /// \brief Pointer to quick window public: QQuickWindow *quickWindow{nullptr}; @@ -31,7 +32,7 @@ class DialogPrivate ///////////////////////////////////////////////// Dialog::Dialog() - : dataPtr(new DialogPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { // Load QML and keep pointer to generated QQuickWindow std::string qmlFile("qrc:qml/StandaloneDialog.qml"); diff --git a/src/MainWindow.cc b/src/MainWindow.cc index 234591ae2..df1e0fe5f 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -16,6 +16,7 @@ */ #include +#include #include #include @@ -29,11 +30,21 @@ #include "gz/msgs/server_control.pb.h" #include "gz/transport/Node.hh" +namespace { +/// \brief Strip last component from a path. +/// \return Original path without its last component. +/// \ToDo: Move this function to common::Filesystem +std::string dirName(const std::string &_path) +{ + std::size_t found = _path.find_last_of("/\\"); + return _path.substr(0, found); +} +} // namespace + namespace gz::gui { -class MainWindowPrivate +class MainWindow::Implementation { - /// \brief Number of plugins on the window public: int pluginCount{0}; /// \brief Pointer to quick window @@ -77,18 +88,9 @@ class MainWindowPrivate public: gz::transport::Node node; }; -/// \brief Strip last component from a path. -/// \return Original path without its last component. -/// \ToDo: Move this function to common::Filesystem -std::string dirName(const std::string &_path) -{ - std::size_t found = _path.find_last_of("/\\"); - return _path.substr(0, found); -} - ///////////////////////////////////////////////// MainWindow::MainWindow() - : dataPtr(new MainWindowPrivate) + : dataPtr(gz::utils::MakeUniqueImpl()) { // Expose the ExitAction enum to QML via ExitAction 1.0 module qRegisterMetaType("ExitAction"); diff --git a/src/PlottingInterface.cc b/src/PlottingInterface.cc index cf125e31c..079ec1101 100644 --- a/src/PlottingInterface.cc +++ b/src/PlottingInterface.cc @@ -25,13 +25,15 @@ #include "gz/gui/PlottingInterface.hh" #include "gz/gui/Application.hh" +#include + #define DEFAULT_TIME (INT_MIN) // 1/60 Period like the GuiSystem frequency (60Hz) #define MAX_PERIOD_DIFF (0.0166666667) namespace gz::gui { -class PlotDataPrivate +class PlotData::Implementation { /// \brief Value of that field public: double value; @@ -43,7 +45,7 @@ class PlotDataPrivate public: std::set charts; }; -class TopicPrivate +class Topic::Implementation { /// \brief Check the plotable types and get data from reflection /// \param[in] _msg Message to get data from @@ -65,7 +67,7 @@ class TopicPrivate public: std::map fields; }; -class TransportPrivate +class Transport::Implementation { /// \brief Node for Commincation public: gz::transport::Node node; @@ -74,7 +76,7 @@ class TransportPrivate public: std::map topics; }; -class PlottingIfacePrivate +class PlottingInterface::Implementation { /// \brief Responsible for transport messages and topics public: gui::Transport transport; @@ -86,12 +88,12 @@ class PlottingIfacePrivate public: int timeout; /// \brief timer to update the plotting each time step - public: QTimer timer; + public: QTimer timer {nullptr}; }; ////////////////////////////////////////////////////// PlotData::PlotData() : - dataPtr(std::make_unique()) + dataPtr(gz::utils::MakeUniqueImpl()) { this->dataPtr->value = 0; } @@ -150,8 +152,8 @@ std::set &PlotData::Charts() } ////////////////////////////////////////////////////// -Topic::Topic(const std::string &_name) : QObject(), - dataPtr(std::make_unique()) +Topic::Topic(const std::string &_name): + dataPtr(gz::utils::MakeUniqueImpl()) { this->dataPtr->name = _name; } @@ -361,7 +363,7 @@ void Topic::SetPlottingTimeRef(const std::shared_ptr &_timeRef) } ////////////////////////////////////////////////////// -double TopicPrivate::FieldData(const google::protobuf::Message &_msg, +double Topic::Implementation::FieldData(const google::protobuf::Message &_msg, const google::protobuf::FieldDescriptor *_field) { using namespace google::protobuf; @@ -390,7 +392,8 @@ double TopicPrivate::FieldData(const google::protobuf::Message &_msg, } //////////////////////////////////////////// -Transport::Transport() : dataPtr(std::make_unique()) +Transport::Transport(): + dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -481,7 +484,7 @@ void Transport::UnsubscribeOutdatedTopics() ////////////////////////////////////////////////////// PlottingInterface::PlottingInterface() : QObject(), - dataPtr(std::make_unique()) + dataPtr(gz::utils::MakeUniqueImpl()) { connect(&this->dataPtr->transport, SIGNAL(plot(int, QString, double, double)), this, diff --git a/src/Plugin.cc b/src/Plugin.cc index fdb7ca746..2f9e7855d 100644 --- a/src/Plugin.cc +++ b/src/Plugin.cc @@ -15,6 +15,7 @@ * */ +#include #include #include @@ -56,7 +57,7 @@ const std::unordered_set kIgnoredProps{ namespace gz::gui { -class PluginPrivate +class Plugin::Implementation { /// \brief Set this to true if the plugin should be deleted as soon as it has /// a parent. @@ -86,7 +87,7 @@ class PluginPrivate }; ///////////////////////////////////////////////// -Plugin::Plugin() : dataPtr(new PluginPrivate) +Plugin::Plugin() : dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -517,6 +518,17 @@ void Plugin::PostParentChanges() } } +///////////////////////////////////////////////// +void Plugin::LoadConfig(const tinyxml2::XMLElement *_pluginElem) +{ + (void) _pluginElem; +} + +///////////////////////////////////////////////// +std::string Plugin::Title() const { + return this->title; +} + ///////////////////////////////////////////////// void Plugin::ApplyAnchors() { From ed63b7bbe1f77120bb4c576c8db60de4f9bb9607 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 5 Oct 2023 22:26:06 +0000 Subject: [PATCH 02/33] Switch gz-gui plugins to use implptr Signed-off-by: Michael Carroll --- include/gz/gui/Dialog.hh | 1 - include/gz/gui/MainWindow.hh | 8 +- include/gz/gui/PlottingInterface.hh | 1 + 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 | 8 +- src/plugins/grid_config/GridConfig.hh | 11 +-- src/plugins/image_display/ImageDisplay.cc | 4 +- src/plugins/image_display/ImageDisplay.hh | 7 +- .../InteractiveViewControl.cc | 26 +++---- .../InteractiveViewControl.hh | 4 +- src/plugins/key_publisher/KeyPublisher.cc | 12 +-- src/plugins/key_publisher/KeyPublisher.hh | 9 +-- .../key_publisher/KeyPublisher_TEST.cc | 15 ++-- 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 | 5 +- 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 | 11 +-- src/plugins/tape_measure/TapeMeasure.hh | 12 ++- 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 | 10 +-- 47 files changed, 295 insertions(+), 318 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..2ae1c0e89 100644 --- a/include/gz/gui/MainWindow.hh +++ b/include/gz/gui/MainWindow.hh @@ -575,8 +575,9 @@ namespace gz::gui /// \internal /// \brief Private data pointer + /// Private is necessary here for the Qt MOC private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) -}; + }; /// \brief Holds configurations related to a MainWindow. struct GZ_GUI_VISIBLE WindowConfig @@ -667,9 +668,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/include/gz/gui/PlottingInterface.hh b/include/gz/gui/PlottingInterface.hh index 85b7ae2e5..5b719fc5d 100644 --- a/include/gz/gui/PlottingInterface.hh +++ b/include/gz/gui/PlottingInterface.hh @@ -323,6 +323,7 @@ class GZ_GUI_VISIBLE PlottingInterface : public QObject public slots: void UpdateTime(); /// \brief Private data member. + /// Private is necessary here for the Qt MOC private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; } // namespace gz::gui 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..e6bb9a0ae 100644 --- a/src/plugins/grid_config/GridConfig.cc +++ b/src/plugins/grid_config/GridConfig.cc @@ -32,7 +32,7 @@ #include "GridConfig.hh" -namespace gz::gui +namespace gz::gui::plugins { struct GridParam { @@ -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()) { } @@ -408,5 +408,5 @@ void GridConfig::RefreshList() } // namespace gz::gui // Register this plugin -GZ_ADD_PLUGIN(gz::gui::GridConfig, +GZ_ADD_PLUGIN(gz::gui::plugins::GridConfig, gz::gui::Plugin) 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..4e3ec1e82 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() @@ -121,7 +121,6 @@ namespace gz::gui::plugins /// \brief Notify that a new image has been received. signals: void newImage(); - /// \brief Callback in main thread when image changes private slots: void ProcessImage(); /// \brief Subscriber callback when new image is received @@ -130,7 +129,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/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..72d736234 100644 --- a/src/plugins/key_publisher/KeyPublisher.cc +++ b/src/plugins/key_publisher/KeyPublisher.cc @@ -17,6 +17,7 @@ #include +#include #include #include @@ -25,9 +26,9 @@ #include "KeyPublisher.hh" -namespace gz::gui +namespace gz::gui::plugins { -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 @@ -79,8 +81,8 @@ bool KeyPublisher::eventFilter(QObject *_obj, QEvent *_event) } return QObject::eventFilter(_obj, _event); } -} // namespace gz::gui +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(gz::gui::KeyPublisher, +GZ_ADD_PLUGIN(gz::gui::plugins::KeyPublisher, gz::gui::Plugin) diff --git a/src/plugins/key_publisher/KeyPublisher.hh b/src/plugins/key_publisher/KeyPublisher.hh index dc350b672..fbb4b945b 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 +namespace gz::gui::plugins { - class KeyPublisherPrivate; - /// \brief Publish keyboard stokes to "keyboard/keypress" topic. /// /// ## Configuration @@ -64,8 +63,8 @@ namespace gz::gui /// \internal /// \brief Pointer to private data. - private: std::unique_ptr dataPtr; + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; -} // namespace gz::gui +} // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_KEYPUBLISHER_HH_ diff --git a/src/plugins/key_publisher/KeyPublisher_TEST.cc b/src/plugins/key_publisher/KeyPublisher_TEST.cc index abb2ec7db..545b3d46f 100644 --- a/src/plugins/key_publisher/KeyPublisher_TEST.cc +++ b/src/plugins/key_publisher/KeyPublisher_TEST.cc @@ -30,24 +30,25 @@ #include "KeyPublisher.hh" +using Application = gz::gui::Application; +using KeyPublisher = gz::gui::plugins::KeyPublisher; +using MainWindow = gz::gui::MainWindow; + int g_argc = 1; char* g_argv[] = { reinterpret_cast(const_cast("./KeyPublisher_TEST")), }; -using namespace gz; -using namespace gui; - class KeyPublisherTest : public ::testing::Test { // Set up function. protected: void SetUp() override { - common::Console::SetVerbosity(4); + gz::common::Console::SetVerbosity(4); this->app.AddPluginPath( - common::joinPaths(std::string(PROJECT_BINARY_PATH), "lib")); + gz::common::joinPaths(std::string(PROJECT_BINARY_PATH), "lib")); // Load plugin EXPECT_TRUE(this->app.LoadPlugin("KeyPublisher")); @@ -75,7 +76,7 @@ class KeyPublisherTest : public ::testing::Test } // Callback function to verify key message was sent correctly - protected: void VerifyKeypressCb(const msgs::Int32 &_msg) + protected: void VerifyKeypressCb(const gz::msgs::Int32 &_msg) { this->received = true; EXPECT_EQ(_msg.data(), this->currentKey); @@ -113,7 +114,7 @@ class KeyPublisherTest : public ::testing::Test // Checks if a new key has been received. protected: bool received = false; - protected: transport::Node node; + protected: gz::transport::Node node; // Current key protected: int currentKey = 0; 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..64bf816f5 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,8 +35,6 @@ namespace gz::gui::plugins { - class PublisherPrivate; - /// \brief Widget which publishes a custom Gazebo Transport message. /// /// ## Configuration @@ -141,7 +140,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..d5d5736d7 100644 --- a/src/plugins/tape_measure/TapeMeasure.cc +++ b/src/plugins/tape_measure/TapeMeasure.cc @@ -17,6 +17,7 @@ #include +#include #include #include #include @@ -33,9 +34,9 @@ #include "TapeMeasure.hh" -namespace gz::gui +namespace gz::gui::plugins { -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()) { } @@ -321,8 +322,8 @@ bool TapeMeasure::eventFilter(QObject *_obj, QEvent *_event) return QObject::eventFilter(_obj, _event); } -} // namespace gz::gui +} // namespace gz::gui::plugins // Register this plugin -GZ_ADD_PLUGIN(gz::gui::TapeMeasure, +GZ_ADD_PLUGIN(gz::gui::plugins::TapeMeasure, gz::gui::Plugin) diff --git a/src/plugins/tape_measure/TapeMeasure.hh b/src/plugins/tape_measure/TapeMeasure.hh index 90e5ab119..6552844bf 100644 --- a/src/plugins/tape_measure/TapeMeasure.hh +++ b/src/plugins/tape_measure/TapeMeasure.hh @@ -18,16 +18,15 @@ #ifndef GZ_GUI_TAPEMEASURE_HH_ #define GZ_GUI_TAPEMEASURE_HH_ +#include #include #include #include #include -namespace gz::gui +namespace gz::gui::plugins { - 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_ +} // namespace gz::gui::plugins +#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..07a42721e 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,8 +39,6 @@ namespace gz::gui::plugins { - class WorldStatsPrivate; - /// \brief This plugin provides a time panel which may display: /// * Simulation time /// * Real time @@ -99,10 +99,10 @@ namespace gz::gui::plugins public: WorldStats(); /// \brief Destructor - public: virtual ~WorldStats(); + public: ~WorldStats() override; // Documentation inherited - public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem); + public: void LoadConfig(const tinyxml2::XMLElement *_pluginElem) override; /// \brief Callback in main thread when diagnostics come in public slots: void ProcessMsg(); @@ -155,7 +155,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 From 2052269925be5d0bc21ee055665bf678c5a9ea45 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 7 Nov 2023 22:48:59 +0000 Subject: [PATCH 03/33] First pass at level1 clazy checks for qt Signed-off-by: Michael Carroll --- include/gz/gui/MainWindow.hh | 2 +- src/Application.cc | 58 +++--- src/Application_TEST.cc | 4 +- src/Helpers_TEST.cc | 4 +- src/MainWindow.cc | 52 +++--- src/MainWindow_TEST.cc | 11 +- src/PlottingInterface.cc | 46 ++--- src/Plugin.cc | 69 ++++---- src/Plugin_TEST.cc | 27 ++- src/SearchModel.cc | 4 +- src/plugins/camera_fps/CameraFps.cc | 2 +- src/plugins/camera_tracking/CameraTracking.cc | 2 +- src/plugins/grid_config/GridConfig.cc | 6 +- src/plugins/image_display/ImageDisplay.cc | 14 +- src/plugins/marker_manager/MarkerManager.cc | 11 +- src/plugins/minimal_scene/MinimalScene.cc | 4 +- src/plugins/minimal_scene/MinimalScene.hh | 166 +++++++++--------- src/plugins/navsat_map/NavSatMap.cc | 12 +- src/plugins/point_cloud/PointCloud.cc | 26 +-- src/plugins/publisher/Publisher.cc | 14 +- src/plugins/screenshot/Screenshot.cc | 10 +- src/plugins/tape_measure/TapeMeasure.cc | 6 +- src/plugins/teleop/Teleop.cc | 12 +- src/plugins/topic_echo/TopicEcho.cc | 6 +- src/plugins/topic_echo/TopicEcho_TEST.cc | 14 +- src/plugins/topic_viewer/TopicViewer.cc | 6 +- src/plugins/world_control/WorldControl.cc | 20 +-- src/plugins/world_stats/WorldStats.cc | 8 +- test/integration/transport_scene_manager.cc | 2 +- 29 files changed, 309 insertions(+), 309 deletions(-) diff --git a/include/gz/gui/MainWindow.hh b/include/gz/gui/MainWindow.hh index 2ae1c0e89..72e6d4d29 100644 --- a/include/gz/gui/MainWindow.hh +++ b/include/gz/gui/MainWindow.hh @@ -409,7 +409,7 @@ namespace gz::gui /// \brief Get the action performed when GUI closes without prompt. /// \return The action. - public: Q_INVOKABLE ExitAction DefaultExitAction() const; + public: Q_INVOKABLE gz::gui::ExitAction DefaultExitAction() const; /// \brief Set the action performed when GUI closes without prompt. /// \param[in] _defaultExitAction The action. diff --git a/src/Application.cc b/src/Application.cc index d6a3fb290..87201de81 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -331,7 +331,7 @@ bool Application::LoadConfig(const std::string &_config) if (!configPathEnv.empty()) { std::vector parentPaths = common::Split(configPathEnv, ':'); - for (auto parentPath : parentPaths) + for (const auto &parentPath : parentPaths) { std::string tempPath = common::joinPaths(parentPath, configFull); if (common::exists(tempPath)) @@ -364,12 +364,12 @@ bool Application::LoadConfig(const std::string &_config) // Clear all previous plugins auto plugins = this->dataPtr->mainWin->findChildren(); - for (auto plugin : plugins) + for (auto *plugin : plugins) { auto pluginName = plugin->CardItem()->objectName(); this->RemovePlugin(pluginName.toStdString()); } - if (this->dataPtr->pluginsAdded.size() > 0) + if (!this->dataPtr->pluginsAdded.empty()) { gzerr << "The plugin list was not properly cleaned up." << std::endl; } @@ -377,10 +377,11 @@ bool Application::LoadConfig(const std::string &_config) // Process each plugin bool successful = true; - for (auto pluginElem = doc.FirstChildElement("plugin"); pluginElem != nullptr; - pluginElem = pluginElem->NextSiblingElement("plugin")) + for (auto *pluginElem = doc.FirstChildElement("plugin"); + pluginElem != nullptr; + pluginElem = pluginElem->NextSiblingElement("plugin")) { - auto filename = pluginElem->Attribute("filename"); + const auto *filename = pluginElem->Attribute("filename"); if (!this->LoadPlugin(filename, pluginElem)) { successful = false; @@ -393,7 +394,7 @@ bool Application::LoadConfig(const std::string &_config) } // Process window properties - if (auto winElem = doc.FirstChildElement("window")) + if (auto *winElem = doc.FirstChildElement("window")) { gzdbg << "Loading window config" << std::endl; @@ -407,7 +408,7 @@ bool Application::LoadConfig(const std::string &_config) this->dataPtr->windowConfig.MergeFromXML(std::string(printer.CStr())); // Closing behavior. - if (auto defaultExitActionElem = + if (auto *defaultExitActionElem = winElem->FirstChildElement("default_exit_action")) { ExitAction action{ExitAction::CLOSE_GUI}; @@ -426,43 +427,43 @@ bool Application::LoadConfig(const std::string &_config) } // Dialog on exit - if (auto dialogOnExitElem = winElem->FirstChildElement("dialog_on_exit")) + if (auto *dialogOnExitElem = winElem->FirstChildElement("dialog_on_exit")) { bool showDialogOnExit{false}; dialogOnExitElem->QueryBoolText(&showDialogOnExit); this->dataPtr->mainWin->SetShowDialogOnExit(showDialogOnExit); } - if (auto dialogOnExitOptionsElem = + if (auto *dialogOnExitOptionsElem = winElem->FirstChildElement("dialog_on_exit_options")) { - if (auto promptElem = + if (auto *promptElem = dialogOnExitOptionsElem->FirstChildElement("prompt_text")) { this->dataPtr->mainWin->SetDialogOnExitText( QString::fromStdString(promptElem->GetText())); } - if (auto showShutdownElem = + if (auto *showShutdownElem = dialogOnExitOptionsElem->FirstChildElement("show_shutdown_button")) { bool showShutdownButton{false}; showShutdownElem->QueryBoolText(&showShutdownButton); this->dataPtr->mainWin->SetExitDialogShowShutdown(showShutdownButton); } - if (auto showCloseGuiElem = + if (auto *showCloseGuiElem = dialogOnExitOptionsElem->FirstChildElement("show_close_gui_button")) { bool showCloseGuiButton{false}; showCloseGuiElem->QueryBoolText(&showCloseGuiButton); this->dataPtr->mainWin->SetExitDialogShowCloseGui(showCloseGuiButton); } - if (auto shutdownTextElem = + if (auto *shutdownTextElem = dialogOnExitOptionsElem->FirstChildElement("shutdown_button_text")) { this->dataPtr->mainWin->SetExitDialogShutdownText( QString::fromStdString(shutdownTextElem->GetText())); } - if (auto closeGuiTextElem = + if (auto *closeGuiTextElem = dialogOnExitOptionsElem->FirstChildElement("close_gui_button_text")) { this->dataPtr->mainWin->SetExitDialogCloseGuiText( @@ -472,7 +473,7 @@ bool Application::LoadConfig(const std::string &_config) // Server control service topic std::string serverControlService{"/server_control"}; - auto serverControlElem = + auto *serverControlElem = winElem->FirstChildElement("server_control_service"); if (nullptr != serverControlElem && nullptr != serverControlElem->GetText()) { @@ -563,7 +564,7 @@ bool Application::LoadPlugin(const std::string &_filename, // gz::gui::Plugin interface plugin::PluginPtr commonPlugin; std::shared_ptr plugin{nullptr}; - for (auto pluginName : pluginNames) + for (const auto &pluginName : pluginNames) { commonPlugin = pluginLoader.Instantiate(pluginName); if (!commonPlugin) @@ -580,7 +581,7 @@ bool Application::LoadPlugin(const std::string &_filename, "] : couldn't instantiate plugin on path [" << pathToLib << "]. Tried plugin names: " << std::endl; - for (auto pluginName : pluginNames) + for (const auto &pluginName : pluginNames) { gzerr << " * " << pluginName << std::endl; } @@ -620,7 +621,7 @@ bool Application::LoadPlugin(const std::string &_filename, else this->InitializeDialogs(); - this->PluginAdded(plugin->CardItem()->objectName()); + emit this->PluginAdded(plugin->CardItem()->objectName()); gzmsg << "Loaded plugin [" << _filename << "] from path [" << pathToLib << "]" << std::endl; @@ -633,7 +634,7 @@ std::shared_ptr Application::PluginByName( { for (auto &plugin : this->dataPtr->pluginsAdded) { - auto cardItem = plugin->CardItem(); + auto *cardItem = plugin->CardItem(); if (!cardItem) continue; @@ -683,7 +684,7 @@ bool Application::AddPluginsToWindow() return false; // Get main window background item - auto bgItem = this->dataPtr->mainWin->QuickWindow() + auto *bgItem = this->dataPtr->mainWin->QuickWindow() ->findChild("background"); if (!this->dataPtr->pluginsToAdd.empty() && !bgItem) { @@ -705,7 +706,7 @@ bool Application::AddPluginsToWindow() continue; } - auto cardItem = plugin->CardItem(); + auto *cardItem = plugin->CardItem(); if (!cardItem) continue; @@ -714,7 +715,7 @@ bool Application::AddPluginsToWindow() QMetaObject::invokeMethod(bgItem, "addSplitItem", Q_RETURN_ARG(QVariant, splitName)); - auto splitItem = bgItem->findChild( + auto *splitItem = bgItem->findChild( splitName.toString()); if (!splitItem) { @@ -755,12 +756,12 @@ bool Application::InitializeDialogs() this->dataPtr->pluginsToAdd.pop(); // Create card - auto cardItem = plugin->CardItem(); + auto *cardItem = plugin->CardItem(); if (!cardItem) continue; // Create dialog - auto dialog = new Dialog(); + auto *dialog = new Dialog(); if (!dialog || !dialog->QuickWindow()) continue; @@ -787,10 +788,7 @@ bool Application::InitializeDialogs() gzdbg << "Initialized dialog [" << title.toStdString() << "]" << std::endl; } - if (this->dataPtr->pluginsAdded.empty()) - return false; - - return true; + return !this->dataPtr->pluginsAdded.empty(); } ///////////////////////////////////////////////// @@ -844,7 +842,7 @@ std::vector>> ps.push_back(plugin); } - plugins.push_back(std::make_pair(path, ps)); + plugins.emplace_back(path, ps); } return plugins; diff --git a/src/Application_TEST.cc b/src/Application_TEST.cc index c3f3faefb..f23ce8ab0 100644 --- a/src/Application_TEST.cc +++ b/src/Application_TEST.cc @@ -336,7 +336,7 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) // Close dialog after some time auto closed = false; - QTimer::singleShot(300, [&] { + QTimer::singleShot(300, &app, [&] { auto ds = app.allWindows(); // The main dialog - some systems return more, not sure why @@ -371,7 +371,7 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) // Close dialogs after some time auto closed = false; - QTimer::singleShot(300, [&] { + QTimer::singleShot(300, &app, [&] { auto ds = app.allWindows(); // 2 dialog - some systems return more, not sure why diff --git a/src/Helpers_TEST.cc b/src/Helpers_TEST.cc index 4556cf7fa..e99f48bf4 100644 --- a/src/Helpers_TEST.cc +++ b/src/Helpers_TEST.cc @@ -171,8 +171,8 @@ TEST(HelpersTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(worldNames)) // Has names EXPECT_FALSE(worldNames().empty()); ASSERT_EQ(2, worldNames().size()); - EXPECT_EQ("banana", worldNames()[0]); - EXPECT_EQ("grape", worldNames()[1]); + EXPECT_EQ("banana", worldNames().at(0)); + EXPECT_EQ("grape", worldNames().at(1)); mainWindow->setProperty("worldNames", QStringList()); diff --git a/src/MainWindow.cc b/src/MainWindow.cc index ad075b466..bff0186a9 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -148,7 +148,7 @@ QStringList MainWindow::PluginListModel() const } // Error - for (auto plugin : this->dataPtr->windowConfig.showPlugins) + for (const auto &plugin : this->dataPtr->windowConfig.showPlugins) { if (!pluginNames.contains(QString::fromStdString(plugin))) { @@ -241,14 +241,14 @@ void MainWindow::SaveConfig(const std::string &_path) { std::string str = "Unable to open file: " + _path; str += ".\nCheck file permissions."; - this->notify(QString::fromStdString(str)); + emit this->notify(QString::fromStdString(str)); } else out << this->dataPtr->windowConfig.XMLString(); std::string msg("Saved configuration to " + _path + ""); - this->notify(QString::fromStdString(msg)); + emit this->notify(QString::fromStdString(msg)); gzmsg << msg << std::endl; } @@ -330,7 +330,7 @@ bool MainWindow::ApplyConfig(const WindowConfig &_config) this->dataPtr->windowConfig = _config; // Notify view - this->configChanged(); + emit this->configChanged(); return true; } @@ -701,7 +701,7 @@ int MainWindow::PluginCount() const void MainWindow::SetPluginCount(const int _pluginCount) { this->dataPtr->pluginCount = _pluginCount; - this->PluginCountChanged(); + emit this->PluginCountChanged(); } ///////////////////////////////////////////////// @@ -714,7 +714,7 @@ QString MainWindow::MaterialTheme() const void MainWindow::SetMaterialTheme(const QString &_materialTheme) { this->dataPtr->windowConfig.materialTheme = _materialTheme.toStdString(); - this->MaterialThemeChanged(); + emit this->MaterialThemeChanged(); } ///////////////////////////////////////////////// @@ -727,7 +727,7 @@ QString MainWindow::MaterialPrimary() const void MainWindow::SetMaterialPrimary(const QString &_materialPrimary) { this->dataPtr->windowConfig.materialPrimary = _materialPrimary.toStdString(); - this->MaterialPrimaryChanged(); + emit this->MaterialPrimaryChanged(); } ///////////////////////////////////////////////// @@ -740,7 +740,7 @@ QString MainWindow::MaterialAccent() const void MainWindow::SetMaterialAccent(const QString &_materialAccent) { this->dataPtr->windowConfig.materialAccent = _materialAccent.toStdString(); - this->MaterialAccentChanged(); + emit this->MaterialAccentChanged(); } ///////////////////////////////////////////////// @@ -754,7 +754,7 @@ void MainWindow::SetToolBarColorLight(const QString &_toolBarColorLight) { this->dataPtr->windowConfig.toolBarColorLight = _toolBarColorLight.toStdString(); - this->ToolBarColorLightChanged(); + emit this->ToolBarColorLightChanged(); } ///////////////////////////////////////////////// @@ -769,7 +769,7 @@ void MainWindow::SetToolBarTextColorLight(const QString &_toolBarTextColorLight) { this->dataPtr->windowConfig.toolBarTextColorLight = _toolBarTextColorLight.toStdString(); - this->ToolBarTextColorLightChanged(); + emit this->ToolBarTextColorLightChanged(); } ///////////////////////////////////////////////// @@ -783,7 +783,7 @@ void MainWindow::SetToolBarColorDark(const QString &_toolBarColorDark) { this->dataPtr->windowConfig.toolBarColorDark = _toolBarColorDark.toStdString(); - this->ToolBarColorDarkChanged(); + emit this->ToolBarColorDarkChanged(); } ///////////////////////////////////////////////// @@ -798,7 +798,7 @@ void MainWindow::SetToolBarTextColorDark(const QString &_toolBarTextColorDark) { this->dataPtr->windowConfig.toolBarTextColorDark = _toolBarTextColorDark.toStdString(); - this->ToolBarTextColorDarkChanged(); + emit this->ToolBarTextColorDarkChanged(); } ///////////////////////////////////////////////// @@ -814,7 +814,7 @@ void MainWindow::SetPluginToolBarColorLight( { this->dataPtr->windowConfig.pluginToolBarColorLight = _pluginToolBarColorLight.toStdString(); - this->PluginToolBarColorLightChanged(); + emit this->PluginToolBarColorLightChanged(); } ///////////////////////////////////////////////// @@ -830,7 +830,7 @@ void MainWindow::SetPluginToolBarTextColorLight( { this->dataPtr->windowConfig.pluginToolBarTextColorLight = _pluginToolBarTextColorLight.toStdString(); - this->PluginToolBarTextColorLightChanged(); + emit this->PluginToolBarTextColorLightChanged(); } ///////////////////////////////////////////////// @@ -846,7 +846,7 @@ void MainWindow::SetPluginToolBarColorDark( { this->dataPtr->windowConfig.pluginToolBarColorDark = _pluginToolBarColorDark.toStdString(); - this->PluginToolBarColorDarkChanged(); + emit this->PluginToolBarColorDarkChanged(); } ///////////////////////////////////////////////// @@ -862,7 +862,7 @@ void MainWindow::SetPluginToolBarTextColorDark( { this->dataPtr->windowConfig.pluginToolBarTextColorDark = _pluginToolBarTextColorDark.toStdString(); - this->PluginToolBarTextColorDarkChanged(); + emit this->PluginToolBarTextColorDarkChanged(); } ///////////////////////////////////////////////// @@ -881,7 +881,7 @@ bool MainWindow::ShowDrawer() const void MainWindow::SetShowDrawer(const bool _showDrawer) { this->dataPtr->windowConfig.showDrawer = _showDrawer; - this->ShowDrawerChanged(); + emit this->ShowDrawerChanged(); } ///////////////////////////////////////////////// @@ -895,7 +895,7 @@ void MainWindow::SetShowDefaultDrawerOpts(const bool _showDefaultDrawerOpts) { this->dataPtr->windowConfig.showDefaultDrawerOpts = _showDefaultDrawerOpts; - this->ShowDefaultDrawerOptsChanged(); + emit this->ShowDefaultDrawerOptsChanged(); } ///////////////////////////////////////////////// @@ -908,7 +908,7 @@ bool MainWindow::ShowPluginMenu() const void MainWindow::SetShowPluginMenu(const bool _showPluginMenu) { this->dataPtr->windowConfig.showPluginMenu = _showPluginMenu; - this->ShowPluginMenuChanged(); + emit this->ShowPluginMenuChanged(); } ///////////////////////////////////////////////// @@ -921,7 +921,7 @@ ExitAction MainWindow::DefaultExitAction() const void MainWindow::SetDefaultExitAction(ExitAction _defaultExitAction) { this->dataPtr->defaultExitAction = _defaultExitAction; - this->DefaultExitActionChanged(); + emit this->DefaultExitActionChanged(); } ///////////////////////////////////////////////// @@ -934,7 +934,7 @@ bool MainWindow::ShowDialogOnExit() const void MainWindow::SetShowDialogOnExit(bool _showDialogOnExit) { this->dataPtr->showDialogOnExit = _showDialogOnExit; - this->ShowDialogOnExitChanged(); + emit this->ShowDialogOnExitChanged(); } ///////////////////////////////////////////////// @@ -954,7 +954,7 @@ void MainWindow::SetDialogOnExitText( const QString &_dialogOnExitText) { this->dataPtr->dialogOnExitText = _dialogOnExitText; - this->DialogOnExitTextChanged(); + emit this->DialogOnExitTextChanged(); } ///////////////////////////////////////////////// @@ -967,7 +967,7 @@ bool MainWindow::ExitDialogShowShutdown() const void MainWindow::SetExitDialogShowShutdown(bool _exitDialogShowShutdown) { this->dataPtr->exitDialogShowShutdown = _exitDialogShowShutdown; - this->ExitDialogShowShutdownChanged(); + emit this->ExitDialogShowShutdownChanged(); } ///////////////////////////////////////////////// @@ -980,7 +980,7 @@ bool MainWindow::ExitDialogShowCloseGui() const void MainWindow::SetExitDialogShowCloseGui(bool _exitDialogShowCloseGui) { this->dataPtr->exitDialogShowCloseGui = _exitDialogShowCloseGui; - this->ExitDialogShowCloseGuiChanged(); + emit this->ExitDialogShowCloseGuiChanged(); } ///////////////////////////////////////////////// @@ -994,7 +994,7 @@ void MainWindow::SetExitDialogShutdownText( const QString &_exitDialogShutdownText) { this->dataPtr->exitDialogShutdownText = _exitDialogShutdownText; - this->ExitDialogShutdownTextChanged(); + emit this->ExitDialogShutdownTextChanged(); } ///////////////////////////////////////////////// @@ -1008,7 +1008,7 @@ void MainWindow::SetExitDialogCloseGuiText( const QString &_exitDialogCloseGuiText) { this->dataPtr->exitDialogCloseGuiText = _exitDialogCloseGuiText; - this->ExitDialogCloseGuiTextChanged(); + emit this->ExitDialogCloseGuiTextChanged(); } ///////////////////////////////////////////////// diff --git a/src/MainWindow_TEST.cc b/src/MainWindow_TEST.cc index c5c12e21d..f81749b61 100644 --- a/src/MainWindow_TEST.cc +++ b/src/MainWindow_TEST.cc @@ -342,7 +342,7 @@ TEST(MainWindowTest, // Access window after it's open bool closed{false}; - QTimer::singleShot(300, [&closed] + QTimer::singleShot(300, App(), [&closed] { auto win = App()->findChild(); ASSERT_NE(nullptr, win); @@ -519,7 +519,10 @@ void FindExitDialogButtons( ASSERT_NE(nullptr, dialog); QObject *buttonBox{nullptr}; - for (const auto& c : dialog->findChildren()) + // Qt considers range-based for loops over temporary objects + // potentially dangerous, so explicitly create a container. + const auto children = dialog->findChildren(); + for (const auto& c : children) { if (std::string(c->metaObject()->className()).find("ButtonBox") != std::string::npos) @@ -539,9 +542,9 @@ void FindExitDialogButtons( std::vector buttons; for (int index = 0; index < buttonCount; ++index) { - QQuickItem *button; + QQuickItem *button {nullptr}; QMetaObject::invokeMethod(buttonBox, "itemAt", Qt::DirectConnection, - Q_RETURN_ARG(QQuickItem *, button), + Q_RETURN_ARG(QQuickItem*, button), Q_ARG(int, index)); ASSERT_NE(std::string::npos, diff --git a/src/PlottingInterface.cc b/src/PlottingInterface.cc index 1ac0af2f5..b44ffcb10 100644 --- a/src/PlottingInterface.cc +++ b/src/PlottingInterface.cc @@ -161,7 +161,7 @@ Topic::Topic(const std::string &_name): ////////////////////////////////////////////////////// Topic::~Topic() { - for (auto field : this->dataPtr->fields) + for (const auto &field : this->dataPtr->fields) delete field.second; } @@ -207,7 +207,7 @@ std::map &Topic::Fields() void Topic::Callback(const google::protobuf::Message &_msg) { // check for header time - double headerTime; + double headerTime = 0.0; if (!this->HasHeader(_msg, headerTime)) { if (!this->dataPtr->plottingTime) @@ -230,10 +230,10 @@ void Topic::Callback(const google::protobuf::Message &_msg) } // loop over the registered fields and update them - for (auto fieldIt : this->dataPtr->fields) + for (const auto &fieldIt : this->dataPtr->fields) { - auto msgDescriptor = _msg.GetDescriptor(); - auto ref = _msg.GetReflection(); + const auto *msgDescriptor = _msg.GetDescriptor(); + const auto *ref = _msg.GetReflection(); google::protobuf::Message *valueMsg = nullptr; @@ -245,7 +245,7 @@ void Topic::Callback(const google::protobuf::Message &_msg) { std::string fieldName = fieldFullPath[i]; - auto field = msgDescriptor->FindFieldByName(fieldName); + const auto *field = msgDescriptor->FindFieldByName(fieldName); msgDescriptor = field->message_type(); @@ -270,16 +270,16 @@ void Topic::Callback(const google::protobuf::Message &_msg) } std::string fieldName = fieldFullPath[pathSize-1]; - double data; + double data = 0.0; if (valueMsg) { - auto field = valueMsg->GetDescriptor()->FindFieldByName(fieldName); + const auto *field = valueMsg->GetDescriptor()->FindFieldByName(fieldName); data = this->dataPtr->FieldData(*valueMsg, field); } else { - auto field = msgDescriptor->FindFieldByName(fieldName); + const auto *field = msgDescriptor->FindFieldByName(fieldName); data = this->dataPtr->FieldData(_msg, field); } @@ -301,19 +301,19 @@ void Topic::Callback(const google::protobuf::Message &_msg) bool Topic::HasHeader(const google::protobuf::Message &_msg, double &_headerTime) { - auto ref = _msg.GetReflection(); - auto header = _msg.GetDescriptor()->FindFieldByName("header"); + const auto *ref = _msg.GetReflection(); + const auto *header = _msg.GetDescriptor()->FindFieldByName("header"); auto found = ref->HasField(_msg, header); if (!found) return false; - auto stamp = header->message_type()->FindFieldByName("stamp"); + const auto *stamp = header->message_type()->FindFieldByName("stamp"); if (!stamp) return false; - auto headerMsg = ref->MutableMessage + auto *headerMsg = ref->MutableMessage (const_cast(&_msg), header); if (!headerMsg) @@ -321,14 +321,14 @@ bool Topic::HasHeader(const google::protobuf::Message &_msg, ref = headerMsg->GetReflection(); - auto stampMsg = ref->MutableMessage + auto *stampMsg = ref->MutableMessage (const_cast(headerMsg), stamp); if (!stampMsg) return false; - auto secField = stamp->message_type()->FindFieldByName("sec"); - auto nsecField = stamp->message_type()->FindFieldByName("nsec"); + const auto *secField = stamp->message_type()->FindFieldByName("sec"); + const auto *nsecField = stamp->message_type()->FindFieldByName("nsec"); auto sec = this->dataPtr->FieldData(*stampMsg, secField); auto nsec = this->dataPtr->FieldData(*stampMsg, nsecField); @@ -341,7 +341,7 @@ bool Topic::HasHeader(const google::protobuf::Message &_msg, ////////////////////////////////////////////////////// void Topic::UpdateGui(const std::string &_field) { - auto field = this->dataPtr->fields[_field]; + auto *field = this->dataPtr->fields[_field]; auto x = field->Time(); auto y = field->Value(); @@ -366,8 +366,8 @@ void Topic::SetPlottingTimeRef(const std::shared_ptr &_timeRef) double Topic::Implementation::FieldData(const google::protobuf::Message &_msg, const google::protobuf::FieldDescriptor *_field) { - using namespace google::protobuf; - auto ref = _msg.GetReflection(); + using FieldDescriptor = google::protobuf::FieldDescriptor; + const auto *ref = _msg.GetReflection(); auto type = _field->type(); if (type == FieldDescriptor::Type::TYPE_DOUBLE) @@ -401,7 +401,7 @@ Transport::Transport(): Transport::~Transport() { // unsubscribe from all topics in the transport - for (auto topic : this->dataPtr->topics) + for (const auto &topic : this->dataPtr->topics) this->dataPtr->node.Unsubscribe(topic.first); } @@ -431,7 +431,7 @@ void Transport::Subscribe(const std::string &_topic, // new topic if (this->dataPtr->topics.count(_topic) == 0) { - auto topicHandler = new Topic(_topic); + auto *topicHandler = new Topic(_topic); this->dataPtr->topics[_topic] = topicHandler; topicHandler->Register(_fieldPath, _chart); @@ -470,7 +470,7 @@ void Transport::UnsubscribeOutdatedTopics() std::vector topics; this->dataPtr->node.TopicList(topics); - for (auto topic : this->dataPtr->topics) + for (const auto &topic : this->dataPtr->topics) { // check if the topic exist if (std::find(topics.begin(), topics.end(), topic.first) == topics.end()) @@ -483,7 +483,7 @@ void Transport::UnsubscribeOutdatedTopics() } ////////////////////////////////////////////////////// -PlottingInterface::PlottingInterface() : QObject(), +PlottingInterface::PlottingInterface(): dataPtr(gz::utils::MakeUniqueImpl()) { connect(&this->dataPtr->transport, diff --git a/src/Plugin.cc b/src/Plugin.cc index 2f9e7855d..c36f36dd3 100644 --- a/src/Plugin.cc +++ b/src/Plugin.cc @@ -143,7 +143,10 @@ void Plugin::Load(const tinyxml2::XMLElement *_pluginElem) std::stringstream errors; errors << "Failed to instantiate QML file [" << qmlFile << "]." << std::endl; - for (auto error : component.errors()) + // Qt considers range-based for loops over temporary objects + // potentially dangerous, so explicitly create a container. + const auto componentErrors = component.errors(); + for (const auto &error : componentErrors) { errors << "* " << error.toString().toStdString() << std::endl; } @@ -170,7 +173,7 @@ void Plugin::Load(const tinyxml2::XMLElement *_pluginElem) } // Load common configuration - auto guiElem = _pluginElem->FirstChildElement("gz-gui"); + const auto *guiElem = _pluginElem->FirstChildElement("gz-gui"); if (guiElem) { this->LoadCommonConfig(_pluginElem->FirstChildElement("gz-gui")); @@ -186,7 +189,7 @@ void Plugin::LoadCommonConfig(const tinyxml2::XMLElement *_guiElem) if (nullptr == _guiElem) return; - auto elem = _guiElem->FirstChildElement("title"); + const auto *elem = _guiElem->FirstChildElement("title"); if (nullptr != elem && nullptr != elem->GetText()) { this->title = elem->GetText(); @@ -205,7 +208,7 @@ void Plugin::LoadCommonConfig(const tinyxml2::XMLElement *_guiElem) } // Properties - for (auto propElem = _guiElem->FirstChildElement("property"); + for (const auto *propElem = _guiElem->FirstChildElement("property"); propElem != nullptr; propElem = propElem->NextSiblingElement("property")) { @@ -215,19 +218,19 @@ void Plugin::LoadCommonConfig(const tinyxml2::XMLElement *_guiElem) if (type == "bool") { - bool value; + bool value = false; propElem->QueryBoolText(&value); variant = QVariant(value); } else if (type == "int") { - int value; + int value = 0; propElem->QueryIntText(&value); variant = QVariant(value); } else if (type == "double") { - double value; + double value = 0.0; propElem->QueryDoubleText(&value); variant = QVariant(value); } @@ -251,17 +254,17 @@ void Plugin::LoadCommonConfig(const tinyxml2::XMLElement *_guiElem) } // Anchors - if (auto anchorElem = _guiElem->FirstChildElement("anchors")) + if (const auto *anchorElem = _guiElem->FirstChildElement("anchors")) { this->dataPtr->anchors.target = anchorElem->Attribute("target"); this->dataPtr->anchors.lines.clear(); - for (auto lineElem = anchorElem->FirstChildElement("line"); + for (const auto *lineElem = anchorElem->FirstChildElement("line"); lineElem != nullptr; lineElem = lineElem->NextSiblingElement("line")) { - auto ownLine = lineElem->Attribute("own"); - auto targetLine = lineElem->Attribute("target"); + const auto *ownLine = lineElem->Attribute("own"); + const auto *targetLine = lineElem->Attribute("target"); if (kAnchorLineSet.find(ownLine) == kAnchorLineSet.end()) { @@ -276,8 +279,7 @@ void Plugin::LoadCommonConfig(const tinyxml2::XMLElement *_guiElem) continue; } - this->dataPtr->anchors.lines.push_back( - std::make_pair(ownLine, targetLine)); + this->dataPtr->anchors.lines.emplace_back(ownLine, targetLine); } } } @@ -293,7 +295,7 @@ std::string Plugin::ConfigStr() doc.Parse(this->configStr.c_str()); // - auto pluginElem = doc.FirstChildElement("plugin"); + auto *pluginElem = doc.FirstChildElement("plugin"); if (!pluginElem) { // LCOV_EXCL_START @@ -304,7 +306,7 @@ std::string Plugin::ConfigStr() } // - auto guiElem = pluginElem->FirstChildElement("gz-gui"); + auto *guiElem = pluginElem->FirstChildElement("gz-gui"); if (!guiElem) { guiElem = doc.NewElement("gz-gui"); @@ -312,23 +314,23 @@ std::string Plugin::ConfigStr() } // Clean s - for (auto propElem = guiElem->FirstChildElement("property"); + for (auto *propElem = guiElem->FirstChildElement("property"); propElem != nullptr;) { - auto nextProp = propElem->NextSiblingElement("property"); + auto *nextProp = propElem->NextSiblingElement("property"); guiElem->DeleteChild(propElem); propElem = nextProp; } // Add s - auto meta = this->CardItem()->metaObject(); + const auto *meta = this->CardItem()->metaObject(); for (int i = 0; i < meta->propertyCount(); ++i) { - auto key = meta->property(i).name(); + const auto *key = meta->property(i).name(); auto type = std::string(meta->property(i).typeName()); // Explicitly skip some keys - if (kIgnoredProps.find(key) != kAnchorLineSet.end()) + if (kIgnoredProps.find(key) != kIgnoredProps.end()) continue; // When setting, it will need to be string @@ -344,7 +346,7 @@ std::string Plugin::ConfigStr() value = this->CardItem()->property(meta->property(i).name()) .toString().toStdString(); - auto elem = doc.NewElement("property"); + auto *elem = doc.NewElement("property"); elem->SetAttribute("key", key); elem->SetAttribute("type", type.c_str()); elem->SetText(value.c_str()); @@ -356,10 +358,10 @@ std::string Plugin::ConfigStr() auto anchored = this->CardItem()->property("anchored").toBool(); if (!anchored) { - for (auto anchorElem = guiElem->FirstChildElement("anchors"); + for (auto *anchorElem = guiElem->FirstChildElement("anchors"); anchorElem != nullptr;) { - auto nextAnchor = anchorElem->NextSiblingElement("anchors"); + auto *nextAnchor = anchorElem->NextSiblingElement("anchors"); guiElem->DeleteChild(anchorElem); anchorElem = nextAnchor; } @@ -420,9 +422,8 @@ QQuickItem *Plugin::CardItem() const // Instantiate a card std::string qmlFile(":qml/GzCard.qml"); - QQmlComponent cardComp(App()->Engine(), - QString(QString::fromStdString(qmlFile))); - auto cardItem = qobject_cast(cardComp.create()); + QQmlComponent cardComp(App()->Engine(), QString::fromStdString(qmlFile)); + auto *cardItem = qobject_cast(cardComp.create()); if (!cardItem) { gzerr << "Internal error: Failed to instantiate QML file [" << qmlFile @@ -434,14 +435,14 @@ QQuickItem *Plugin::CardItem() const QQmlEngine::setObjectOwnership(cardItem, QQmlEngine::CppOwnership); // Get card parts - auto cardContentItem = cardItem->findChild("content"); + auto *cardContentItem = cardItem->findChild("content"); if (!cardContentItem) { gzerr << "Null card content QQuickItem!" << std::endl; return nullptr; } - auto cardToolbarItem = cardItem->findChild("cardToolbar"); + auto *cardToolbarItem = cardItem->findChild("cardToolbar"); if (!cardToolbarItem) { gzerr << "Null toolbar content QQuickItem!" << std::endl; @@ -452,7 +453,7 @@ QQuickItem *Plugin::CardItem() const cardItem->setProperty("pluginName", QString::fromStdString(this->Title())); - for (auto prop : this->dataPtr->cardProperties) + for (const auto &prop : this->dataPtr->cardProperties) { // Skip and only apply once it's reparented if (prop.first == "state") @@ -509,7 +510,7 @@ void Plugin::PostParentChanges() this->ApplyAnchors(); // Re-apply other properties like size and position if present - for (auto prop : this->dataPtr->cardProperties) + for (const auto &prop : this->dataPtr->cardProperties) { if (prop.first == "state") continue; @@ -550,14 +551,14 @@ void Plugin::ApplyAnchors() if (this->dataPtr->anchors.target == "window") { - auto win = App()->findChild(); + auto *win = App()->findChild(); if (!win) { gzerr << "Internal error: missing window" << std::endl; return; } - auto bgItem = win->QuickWindow()->findChild("background"); + auto *bgItem = win->QuickWindow()->findChild("background"); if (!bgItem) { gzerr << "Internal error: missing background item" << std::endl; @@ -588,9 +589,9 @@ void Plugin::ApplyAnchors() QMetaObject::invokeMethod(this->CardItem(), "clearAnchors"); // Set anchors - auto cardAnchors = qvariant_cast( + auto *cardAnchors = qvariant_cast( this->CardItem()->property("anchors")); - for (auto line : this->dataPtr->anchors.lines) + for (const auto &line : this->dataPtr->anchors.lines) { cardAnchors->setProperty(line.first.c_str(), target->property(line.second.c_str())); diff --git a/src/Plugin_TEST.cc b/src/Plugin_TEST.cc index fefe02b4f..76d9fa78c 100644 --- a/src/Plugin_TEST.cc +++ b/src/Plugin_TEST.cc @@ -130,7 +130,7 @@ TEST(PluginTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Getters)) EXPECT_EQ(1, win->findChildren().size()); // Get pointers - auto plugin = win->findChildren()[0]; + auto *plugin = win->findChildren().at(0); ASSERT_NE(nullptr, plugin->PluginItem()); ASSERT_NE(nullptr, plugin->CardItem()); ASSERT_NE(nullptr, plugin->Context()); @@ -185,7 +185,7 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStr)) pluginDoc.FirstChildElement("plugin"))); // Create main window - auto win = app.findChild(); + auto *win = app.findChild(); ASSERT_NE(nullptr, win); // Check plugin count @@ -194,20 +194,20 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStr)) // Get the output for ConfigStr() std::string configStr; tinyxml2::XMLDocument configDoc; - auto plugin = win->findChildren()[0]; + auto *plugin = win->findChildren().at(0); configStr = plugin->ConfigStr(); configDoc.Parse(configStr.c_str()); // - auto pluginElem = configDoc.FirstChildElement("plugin"); + auto *pluginElem = configDoc.FirstChildElement("plugin"); ASSERT_NE(nullptr, pluginElem); // - auto gzGuiElem = pluginElem->FirstChildElement("gz-gui"); + auto *gzGuiElem = pluginElem->FirstChildElement("gz-gui"); ASSERT_NE(nullptr, gzGuiElem); // Iterate properties - for (auto propElem = gzGuiElem->FirstChildElement("property"); + for (auto *propElem = gzGuiElem->FirstChildElement("property"); propElem != nullptr;) { // If property in map, mark it as "Verified" @@ -222,7 +222,7 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStr)) << propElem->Attribute("key"); pluginProps[propElem->Attribute("key")] = "Verified"; } - auto nextProp = propElem->NextSiblingElement("property"); + auto *nextProp = propElem->NextSiblingElement("property"); propElem = nextProp; } @@ -253,7 +253,7 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin)) pluginDoc.FirstChildElement("plugin"))); // Create main window - auto win = app.findChild(); + auto *win = app.findChild(); ASSERT_NE(nullptr, win); // Check plugin count @@ -262,7 +262,7 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin)) // Get the output for ConfigStr() std::string configStr; tinyxml2::XMLDocument configDoc; - auto plugin = win->findChildren()[0]; + auto *plugin = win->findChildren().at(0); configStr = plugin->ConfigStr(); configDoc.Parse(configStr.c_str()); @@ -286,15 +286,15 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin)) pluginTypes["state"] = "string"; // - auto pluginElem = configDoc.FirstChildElement("plugin"); + auto *pluginElem = configDoc.FirstChildElement("plugin"); ASSERT_NE(nullptr, pluginElem); // - auto gzGuiElem = pluginElem->FirstChildElement("gz-gui"); + auto *gzGuiElem = pluginElem->FirstChildElement("gz-gui"); ASSERT_NE(nullptr, gzGuiElem); // Iterate properties - for (auto propElem = gzGuiElem->FirstChildElement("property"); + for (auto *propElem = gzGuiElem->FirstChildElement("property"); propElem != nullptr;) { // If property in map, mark it as "Verified" @@ -309,7 +309,7 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin)) << propElem->Attribute("key"); pluginProps[propElem->Attribute("key")] = "Verified"; } - auto nextProp = propElem->NextSiblingElement("property"); + auto *nextProp = propElem->NextSiblingElement("property"); propElem = nextProp; } @@ -320,4 +320,3 @@ TEST(PluginTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(ConfigStrInputNoPlugin)) << itr->first; } } - diff --git a/src/SearchModel.cc b/src/SearchModel.cc index 6a41d93b1..795cb9958 100644 --- a/src/SearchModel.cc +++ b/src/SearchModel.cc @@ -47,7 +47,7 @@ bool SearchModel::filterAcceptsRow(const int _srcRow, // Each word must match at least once, either self, parent or child. auto words = this->search.split(" "); - for (auto word : words) + for (const auto &word : words) { if (word.isEmpty()) continue; @@ -152,6 +152,6 @@ void SearchModel::SetSearch(const QString &_search) // TODO(anyone): Figure out why filterChanged works for TopicViewer but not // TopicsStats - this->layoutChanged(); + emit this->layoutChanged(); } } // namespace gz::gui diff --git a/src/plugins/camera_fps/CameraFps.cc b/src/plugins/camera_fps/CameraFps.cc index 6dc385b31..fa5e08a26 100644 --- a/src/plugins/camera_fps/CameraFps.cc +++ b/src/plugins/camera_fps/CameraFps.cc @@ -120,7 +120,7 @@ QString CameraFps::CameraFpsValue() const void CameraFps::SetCameraFpsValue(const QString &_value) { this->dataPtr->cameraFPSValue = _value; - this->CameraFpsValueChanged(); + emit this->CameraFpsValueChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/camera_tracking/CameraTracking.cc b/src/plugins/camera_tracking/CameraTracking.cc index 6f514edd6..cdf71cc97 100644 --- a/src/plugins/camera_tracking/CameraTracking.cc +++ b/src/plugins/camera_tracking/CameraTracking.cc @@ -434,7 +434,7 @@ CameraTracking::CameraTracking() : dataPtr(gz::utils::MakeUniqueImpl()) { this->dataPtr->timer = new QTimer(this); - this->connect(this->dataPtr->timer, &QTimer::timeout, [=]() + connect(this->dataPtr->timer, &QTimer::timeout, this->dataPtr->timer, [=]() { std::lock_guard lock(this->dataPtr->mutex); if (!this->dataPtr->camera) diff --git a/src/plugins/grid_config/GridConfig.cc b/src/plugins/grid_config/GridConfig.cc index e6bb9a0ae..a49dd7a8d 100644 --- a/src/plugins/grid_config/GridConfig.cc +++ b/src/plugins/grid_config/GridConfig.cc @@ -286,7 +286,7 @@ void GridConfig::ConnectToGrid() this->dataPtr->gridParam.cellLength = grid->CellLength(); this->dataPtr->gridParam.pose = grid->Parent()->LocalPose(); this->dataPtr->gridParam.color = grid->Parent()->Material()->Ambient(); - this->newParams( + emit this->newParams( grid->CellCount(), grid->VerticalCellCount(), grid->CellLength(), @@ -320,7 +320,7 @@ QStringList GridConfig::NameList() const void GridConfig::SetNameList(const QStringList &_nameList) { this->dataPtr->nameList = _nameList; - this->NameListChanged(); + emit this->NameListChanged(); } ///////////////////////////////////////////////// @@ -403,7 +403,7 @@ void GridConfig::RefreshList() // Select first one if (this->dataPtr->nameList.count() > 0) this->OnName(this->dataPtr->nameList.at(0)); - this->NameListChanged(); + emit this->NameListChanged(); } } // namespace gz::gui diff --git a/src/plugins/image_display/ImageDisplay.cc b/src/plugins/image_display/ImageDisplay.cc index 85c648d23..d0a090d49 100644 --- a/src/plugins/image_display/ImageDisplay.cc +++ b/src/plugins/image_display/ImageDisplay.cc @@ -179,7 +179,7 @@ void ImageDisplay::ProcessImage() } this->dataPtr->provider->SetImage(image); - this->newImage(); + emit this->newImage(); } ///////////////////////////////////////////////// @@ -205,7 +205,7 @@ void ImageDisplay::OnTopic(const QString _topic) // Unsubscribe auto subs = this->dataPtr->node.SubscribedTopics(); - for (auto sub : subs) + for (const auto &sub : subs) this->dataPtr->node.Unsubscribe(sub); // Subscribe to new topic @@ -217,7 +217,7 @@ void ImageDisplay::OnTopic(const QString _topic) return; // LCOV_EXCL_STOP } - App()->findChild()->notifyWithDuration( + emit App()->findChild()->notifyWithDuration( QString::fromStdString("Subscribed to: " + topic + ""), 4000); } @@ -230,12 +230,12 @@ void ImageDisplay::OnRefresh() // Get updated list std::vector allTopics; this->dataPtr->node.TopicList(allTopics); - for (auto topic : allTopics) + for (const auto &topic : allTopics) { std::vector publishers; std::vector subscribers; this->dataPtr->node.TopicInfo(topic, publishers, subscribers); - for (auto pub : publishers) + for (const auto &pub : publishers) { if (pub.MsgTypeName() == "gz.msgs.Image") { @@ -248,7 +248,7 @@ void ImageDisplay::OnRefresh() // Select first one if (this->dataPtr->topicList.count() > 0) this->OnTopic(this->dataPtr->topicList.at(0)); - this->TopicListChanged(); + emit this->TopicListChanged(); } ///////////////////////////////////////////////// @@ -261,7 +261,7 @@ QStringList ImageDisplay::TopicList() const void ImageDisplay::SetTopicList(const QStringList &_topicList) { this->dataPtr->topicList = _topicList; - this->TopicListChanged(); + emit this->TopicListChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/marker_manager/MarkerManager.cc b/src/plugins/marker_manager/MarkerManager.cc index 811e86435..4a605eaf5 100644 --- a/src/plugins/marker_manager/MarkerManager.cc +++ b/src/plugins/marker_manager/MarkerManager.cc @@ -252,9 +252,9 @@ bool MarkerManager::Implementation::OnList(gz::msgs::Marker_V &_rep) _rep.clear_marker(); // Create the list of visuals - for (auto mIter : this->visuals) + for (const auto &mIter : this->visuals) { - for (auto iter : mIter.second) + for (const auto &iter : mIter.second) { gz::msgs::Marker *markerMsg = _rep.add_marker(); markerMsg->set_ns(mIter.first); @@ -284,7 +284,8 @@ bool MarkerManager::Implementation::OnMarkerMsgArray( } ////////////////////////////////////////////////// -bool MarkerManager::Implementation::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; @@ -419,7 +420,7 @@ bool MarkerManager::Implementation::ProcessMarkerMsg(const gz::msgs::Marker &_ms // Remove all markers in the specified namespace else if (nsIter != this->visuals.end()) { - for (auto it : nsIter->second) + for (const auto &it : nsIter->second) { this->scene->DestroyVisual(it.second); } @@ -432,7 +433,7 @@ bool MarkerManager::Implementation::ProcessMarkerMsg(const gz::msgs::Marker &_ms for (nsIter = this->visuals.begin(); nsIter != this->visuals.end(); ++nsIter) { - for (auto it : nsIter->second) + for (const auto &it : nsIter->second) { this->scene->DestroyVisual(it.second); } diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index 556ea8e10..7b92cf407 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -1129,7 +1129,7 @@ RenderWindowItem::~RenderWindowItem() void RenderWindowItem::StopRendering() { // Disconnect our QT connections. - for(auto conn : this->dataPtr->connections) + for (const auto &conn : qAsConst(this->dataPtr->connections)) QObject::disconnect(conn); this->dataPtr->renderSync.Shutdown(); @@ -1692,7 +1692,7 @@ void MinimalScene::SetLoadingError(const QString &_loadingError) renderWindow->StopRendering(); } this->loadingError = _loadingError; - this->LoadingErrorChanged(); + emit this->LoadingErrorChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/minimal_scene/MinimalScene.hh b/src/plugins/minimal_scene/MinimalScene.hh index e277a77b5..5f8bd433d 100644 --- a/src/plugins/minimal_scene/MinimalScene.hh +++ b/src/plugins/minimal_scene/MinimalScene.hh @@ -264,7 +264,7 @@ namespace gz::gui::plugins /// \brief Render when safe /// \param[in] _renderSync RenderSync to safely /// synchronize Qt and worker thread (this) - public slots: void RenderNext(RenderSync *_renderSync); + public slots: void RenderNext(gz::gui::plugins::RenderSync *_renderSync); /// \brief Shutdown the thread and the render engine public slots: void ShutDown(); @@ -380,101 +380,101 @@ namespace gz::gui::plugins /// \param[in] _view_controller The camera view controller type to set public: void SetCameraViewController(const std::string &_view_controller); - /// \brief Slot called when thread is ready to be started - public Q_SLOTS: void Ready(); + /// \brief Slot called when thread is ready to be started + public Q_SLOTS: void Ready(); - /// \brief Handle key press event for snapping - /// \param[in] _e The key event to process. - public: void HandleKeyPress(const common::KeyEvent &_e); + /// \brief Handle key press event for snapping + /// \param[in] _e The key event to process. + public: void HandleKeyPress(const common::KeyEvent &_e); - /// \brief Handle key release event for snapping - /// \param[in] _e The key event to process. - public: void HandleKeyRelease(const common::KeyEvent &_e); + /// \brief Handle key release event for snapping + /// \param[in] _e The key event to process. + public: void HandleKeyRelease(const common::KeyEvent &_e); - /// \brief Set a callback to be called in case there are errors. - /// \param[in] _cb Error callback - public: void SetErrorCb(std::function _cb); + /// \brief Set a callback to be called in case there are errors. + /// \param[in] _cb Error callback + public: void SetErrorCb(std::function _cb); - /// \brief Stop rendering and shutdown resources. - public: void StopRendering(); + /// \brief Stop rendering and shutdown resources. + public: void StopRendering(); - // Documentation inherited - protected: virtual void mousePressEvent(QMouseEvent *_e) override; + // Documentation inherited + protected: virtual void mousePressEvent(QMouseEvent *_e) override; - // Documentation inherited - protected: virtual void mouseReleaseEvent(QMouseEvent *_e) override; + // Documentation inherited + protected: virtual void mouseReleaseEvent(QMouseEvent *_e) override; - // Documentation inherited - protected: virtual void mouseMoveEvent(QMouseEvent *_e) override; + // Documentation inherited + protected: virtual void mouseMoveEvent(QMouseEvent *_e) override; - // Documentation inherited - protected: virtual void keyPressEvent(QKeyEvent *_e) override; + // Documentation inherited + protected: virtual void keyPressEvent(QKeyEvent *_e) override; - // Documentation inherited - protected: virtual void keyReleaseEvent(QKeyEvent *_e) override; + // Documentation inherited + protected: virtual void keyReleaseEvent(QKeyEvent *_e) override; - // Documentation inherited - protected: virtual void wheelEvent(QWheelEvent *_e) override; + // Documentation inherited + protected: virtual void wheelEvent(QWheelEvent *_e) override; - /// \brief Overrides the paint event to render the render engine - /// camera view - /// \param[in] _oldNode The node passed in previous updatePaintNode - /// function. It represents the visual representation of the item. - /// \param[in] _data The node transformation data. - /// \return Updated node. - private: QSGNode *updatePaintNode(QSGNode *_oldNode, - QQuickItem::UpdatePaintNodeData *_data) override; + /// \brief Overrides the paint event to render the render engine + /// camera view + /// \param[in] _oldNode The node passed in previous updatePaintNode + /// function. It represents the visual representation of the item. + /// \param[in] _data The node transformation data. + /// \return Updated node. + private: QSGNode *updatePaintNode(QSGNode *_oldNode, + QQuickItem::UpdatePaintNodeData *_data) override; - /// \internal - /// \brief Pointer to private data. - GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) - }; - - /// \brief Texture node for displaying the render texture from gz-renderer - class TextureNode : public QObject, public QSGSimpleTextureNode - { - Q_OBJECT - - /// \brief Constructor - /// \param[in] _window Window to display the texture - /// \param[in] _renderSync RenderSync to safely - /// synchronize Qt (this) and worker thread - /// \param[in] _graphicsAPI The type of graphics API - /// \param[in] _camera Camera owning the Texture Handle - public: explicit TextureNode(QQuickWindow *_window, - RenderSync &_renderSync, - const rendering::GraphicsAPI &_graphicsAPI, - rendering::CameraPtr &_camera); - - /// \brief Destructor - public: ~TextureNode() override; + /// \internal + /// \brief Pointer to private data. + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) +}; - /// \brief This function gets called on the FBO rendering thread and will - /// store the texture id and size and schedule an update on the window. - /// \param[in] _texturePtr Pointer to a texture Id - /// \param[in] _size Texture size - // public slots: void NewTexture(uint _id, const QSize &_size); - public slots: void NewTexture(void* _texturePtr, const QSize &_size); - - /// \brief Before the scene graph starts to render, we update to the - /// pending texture - public slots: void PrepareNode(); - - /// \param[in] _renderSync RenderSync to send to the worker thread - signals: void TextureInUse(RenderSync *_renderSync); - - /// \brief Signal emitted when a new texture is ready to trigger window - /// update - signals: void PendingNewTexture(); - - /// \brief Texture size - public: QSize size = QSize(0, 0); - - /// \brief Mutex to protect the texture variables - public: QMutex mutex; - - /// \brief See RenderSync - public: RenderSync &renderSync; +/// \brief Texture node for displaying the render texture from gz-renderer +class TextureNode : public QObject, public QSGSimpleTextureNode +{ + Q_OBJECT + + /// \brief Constructor + /// \param[in] _window Window to display the texture + /// \param[in] _renderSync RenderSync to safely + /// synchronize Qt (this) and worker thread + /// \param[in] _graphicsAPI The type of graphics API + /// \param[in] _camera Camera owning the Texture Handle + public: explicit TextureNode(QQuickWindow *_window, + RenderSync &_renderSync, + const rendering::GraphicsAPI &_graphicsAPI, + rendering::CameraPtr &_camera); + + /// \brief Destructor + public: ~TextureNode() override; + + /// \brief This function gets called on the FBO rendering thread and will + /// store the texture id and size and schedule an update on the window. + /// \param[in] _texturePtr Pointer to a texture Id + /// \param[in] _size Texture size + // public slots: void NewTexture(uint _id, const QSize &_size); + public slots: void NewTexture(void* _texturePtr, const QSize &_size); + + /// \brief Before the scene graph starts to render, we update to the + /// pending texture + public slots: void PrepareNode(); + + /// \param[in] _renderSync RenderSync to send to the worker thread + signals: void TextureInUse(gz::gui::plugins::RenderSync *_renderSync); + + /// \brief Signal emitted when a new texture is ready to trigger window + /// update + signals: void PendingNewTexture(); + + /// \brief Texture size + public: QSize size = QSize(0, 0); + + /// \brief Mutex to protect the texture variables + public: QMutex mutex; + + /// \brief See RenderSync + public: RenderSync &renderSync; /// \brief Qt quick window public: QQuickWindow *window = nullptr; diff --git a/src/plugins/navsat_map/NavSatMap.cc b/src/plugins/navsat_map/NavSatMap.cc index 86333c373..8cd189cf0 100644 --- a/src/plugins/navsat_map/NavSatMap.cc +++ b/src/plugins/navsat_map/NavSatMap.cc @@ -97,7 +97,7 @@ void NavSatMap::ProcessMessage() { std::lock_guard lock(this->dataPtr->navSatMutex); - this->newMessage(this->dataPtr->navSatMsg.latitude_deg(), + emit this->newMessage(this->dataPtr->navSatMsg.latitude_deg(), this->dataPtr->navSatMsg.longitude_deg()); } @@ -120,7 +120,7 @@ void NavSatMap::OnTopic(const QString _topic) // Unsubscribe auto subs = this->dataPtr->node.SubscribedTopics(); - for (auto sub : subs) + for (const auto &sub : subs) this->dataPtr->node.Unsubscribe(sub); // Subscribe to new topic @@ -140,12 +140,12 @@ void NavSatMap::OnRefresh() // Get updated list std::vector allTopics; this->dataPtr->node.TopicList(allTopics); - for (auto topic : allTopics) + for (const auto &topic : allTopics) { std::vector publishers; std::vector subscribers; this->dataPtr->node.TopicInfo(topic, publishers, subscribers); - for (auto pub : publishers) + for (const auto &pub : publishers) { if (pub.MsgTypeName() == "gz.msgs.NavSat") { @@ -158,7 +158,7 @@ void NavSatMap::OnRefresh() // Select first one if (this->dataPtr->topicList.count() > 0) this->OnTopic(this->dataPtr->topicList.at(0)); - this->TopicListChanged(); + emit this->TopicListChanged(); } ///////////////////////////////////////////////// @@ -171,7 +171,7 @@ QStringList NavSatMap::TopicList() const void NavSatMap::SetTopicList(const QStringList &_topicList) { this->dataPtr->topicList = _topicList; - this->TopicListChanged(); + emit this->TopicListChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/point_cloud/PointCloud.cc b/src/plugins/point_cloud/PointCloud.cc index 6bd01665e..309dd89da 100644 --- a/src/plugins/point_cloud/PointCloud.cc +++ b/src/plugins/point_cloud/PointCloud.cc @@ -234,12 +234,12 @@ void PointCloud::OnRefresh() // Get updated list std::vector allTopics; this->dataPtr->node.TopicList(allTopics); - for (auto topic : allTopics) + for (const auto &topic : allTopics) { std::vector publishers; std::vector subscribers; this->dataPtr->node.TopicInfo(topic, publishers, subscribers); - for (auto pub : publishers) + for (const auto &pub : publishers) { if (pub.MsgTypeName() == "gz.msgs.PointCloudPacked") { @@ -254,17 +254,17 @@ void PointCloud::OnRefresh() } // Handle floats first, so by the time we get the point cloud it can be // colored - if (this->dataPtr->floatVTopicList.size() > 0) + if (!this->dataPtr->floatVTopicList.empty()) { this->OnFloatVTopic(this->dataPtr->floatVTopicList.at(0)); } - if (this->dataPtr->pointCloudTopicList.size() > 0) + if (!this->dataPtr->pointCloudTopicList.empty()) { this->OnPointCloudTopic(this->dataPtr->pointCloudTopicList.at(0)); } - this->PointCloudTopicListChanged(); - this->FloatVTopicListChanged(); + emit this->PointCloudTopicListChanged(); + emit this->FloatVTopicListChanged(); } ///////////////////////////////////////////////// @@ -278,7 +278,7 @@ void PointCloud::SetPointCloudTopicList( const QStringList &_pointCloudTopicList) { this->dataPtr->pointCloudTopicList = _pointCloudTopicList; - this->PointCloudTopicListChanged(); + emit this->PointCloudTopicListChanged(); } ///////////////////////////////////////////////// @@ -292,7 +292,7 @@ void PointCloud::SetFloatVTopicList( const QStringList &_floatVTopicList) { this->dataPtr->floatVTopicList = _floatVTopicList; - this->FloatVTopicListChanged(); + emit this->FloatVTopicListChanged(); } ////////////////////////////////////////////////// @@ -461,7 +461,7 @@ QColor PointCloud::MinColor() const void PointCloud::SetMinColor(const QColor &_minColor) { this->dataPtr->minColor = gz::gui::convert(_minColor); - this->MinColorChanged(); + emit this->MinColorChanged(); this->dataPtr->PublishMarkers(); } @@ -475,7 +475,7 @@ QColor PointCloud::MaxColor() const void PointCloud::SetMaxColor(const QColor &_maxColor) { this->dataPtr->maxColor = gz::gui::convert(_maxColor); - this->MaxColorChanged(); + emit this->MaxColorChanged(); this->dataPtr->PublishMarkers(); } @@ -489,7 +489,7 @@ float PointCloud::MinFloatV() const void PointCloud::SetMinFloatV(float _minFloatV) { this->dataPtr->minFloatV = _minFloatV; - this->MinFloatVChanged(); + emit this->MinFloatVChanged(); } ///////////////////////////////////////////////// @@ -502,7 +502,7 @@ float PointCloud::MaxFloatV() const void PointCloud::SetMaxFloatV(float _maxFloatV) { this->dataPtr->maxFloatV = _maxFloatV; - this->MaxFloatVChanged(); + emit this->MaxFloatVChanged(); } ///////////////////////////////////////////////// @@ -515,7 +515,7 @@ float PointCloud::PointSize() const void PointCloud::SetPointSize(float _pointSize) { this->dataPtr->pointSize = _pointSize; - this->PointSizeChanged(); + emit this->PointSizeChanged(); this->dataPtr->PublishMarkers(); } } // namespace gz::gui::plugins diff --git a/src/plugins/publisher/Publisher.cc b/src/plugins/publisher/Publisher.cc index cbcf4ce9f..25fec4f8d 100644 --- a/src/plugins/publisher/Publisher.cc +++ b/src/plugins/publisher/Publisher.cc @@ -95,7 +95,7 @@ void Publisher::OnPublish(const bool _checked) if (this->dataPtr->timer != nullptr) { this->dataPtr->timer->stop(); - this->disconnect(this->dataPtr->timer, 0, 0, 0); + disconnect(this->dataPtr->timer, nullptr, nullptr, nullptr); } this->dataPtr->pub = transport::Node::Publisher(); return; @@ -107,7 +107,7 @@ void Publisher::OnPublish(const bool _checked) // Check it's possible to create message auto msg = msgs::Factory::New(msgType, msgData); - if (!msg || (msg->DebugString() == "" && msgData != "")) + if (!msg || (msg->DebugString().empty() && !msgData.empty())) { gzerr << "Unable to create message of type[" << msgType << "] " << "with data[" << msgData << "].\n"; @@ -135,7 +135,7 @@ void Publisher::OnPublish(const bool _checked) } this->dataPtr->timer->setInterval(1000/this->dataPtr->frequency); - this->connect(this->dataPtr->timer, &QTimer::timeout, [=]() + connect(this->dataPtr->timer, &QTimer::timeout, this->dataPtr->timer, [=]() { auto newMsg = msgs::Factory::New(msgType, msgData); this->dataPtr->pub.Publish(*newMsg); @@ -153,7 +153,7 @@ QString Publisher::MsgType() const void Publisher::SetMsgType(const QString &_msgType) { this->dataPtr->msgType = _msgType; - this->MsgTypeChanged(); + emit this->MsgTypeChanged(); } ///////////////////////////////////////////////// @@ -166,7 +166,7 @@ QString Publisher::MsgData() const void Publisher::SetMsgData(const QString &_msgData) { this->dataPtr->msgData = _msgData; - this->MsgDataChanged(); + emit this->MsgDataChanged(); } ///////////////////////////////////////////////// @@ -179,7 +179,7 @@ QString Publisher::Topic() const void Publisher::SetTopic(const QString &_topic) { this->dataPtr->topic = _topic; - this->TopicChanged(); + emit this->TopicChanged(); } ///////////////////////////////////////////////// @@ -192,7 +192,7 @@ double Publisher::Frequency() const void Publisher::SetFrequency(const double _frequency) { this->dataPtr->frequency = _frequency; - this->FrequencyChanged(); + emit this->FrequencyChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/screenshot/Screenshot.cc b/src/plugins/screenshot/Screenshot.cc index a14387516..9d5ab6dcd 100644 --- a/src/plugins/screenshot/Screenshot.cc +++ b/src/plugins/screenshot/Screenshot.cc @@ -79,8 +79,6 @@ Screenshot::Screenshot() this->dataPtr->directory = defaultDir; } } - - this->DirectoryChanged(); } ///////////////////////////////////////////////// @@ -155,7 +153,7 @@ void Screenshot::SaveScreenshot() this->SetSavedScreenshotPath(QString::fromStdString(savePath)); - App()->findChild()->notifyWithDuration( + emit App()->findChild()->notifyWithDuration( QString::fromStdString("Saved image to: " + savePath + ""), 4000); } @@ -199,7 +197,7 @@ void Screenshot::SetDirectory(const QString &_dirUrl) { QString newDir = QUrl(_dirUrl).toLocalFile(); this->dataPtr->directory = newDir.toStdString(); - this->DirectoryChanged(); + emit this->DirectoryChanged(); } ///////////////////////////////////////////////// @@ -212,8 +210,8 @@ QString Screenshot::SavedScreenshotPath() const void Screenshot::SetSavedScreenshotPath(const QString &_filename) { this->dataPtr->savedScreenshotPath = _filename; - this->SavedScreenshotPathChanged(); - this->savedScreenshot(); + emit this->SavedScreenshotPathChanged(); + emit this->savedScreenshot(); } } // namespace gz::gui::plugins diff --git a/src/plugins/tape_measure/TapeMeasure.cc b/src/plugins/tape_measure/TapeMeasure.cc index d5d5736d7..99a60c584 100644 --- a/src/plugins/tape_measure/TapeMeasure.cc +++ b/src/plugins/tape_measure/TapeMeasure.cc @@ -149,7 +149,7 @@ void TapeMeasure::Reset() this->dataPtr->endPoint = gz::math::Vector3d::Zero; this->dataPtr->distance = 0.0; this->dataPtr->measure = false; - this->newDistance(); + emit this->newDistance(); QGuiApplication::restoreOverrideCursor(); // Notify 3D scene that we are done using the right click, so it can @@ -247,7 +247,7 @@ bool TapeMeasure::eventFilter(QObject *_obj, QEvent *_event) this->DrawLine(this->dataPtr->kLineId, this->dataPtr->startPoint, point, this->dataPtr->hoverColor); this->dataPtr->distance = this->dataPtr->startPoint.Distance(point); - this->newDistance(); + emit this->newDistance(); } } } @@ -278,7 +278,7 @@ bool TapeMeasure::eventFilter(QObject *_obj, QEvent *_event) this->dataPtr->endPoint, this->dataPtr->drawColor); this->dataPtr->distance = this->dataPtr->startPoint.Distance(this->dataPtr->endPoint); - this->newDistance(); + emit this->newDistance(); QGuiApplication::restoreOverrideCursor(); // Notify 3D scene that we are done using the right click, so it can diff --git a/src/plugins/teleop/Teleop.cc b/src/plugins/teleop/Teleop.cc index ccc12f6ac..d17127515 100644 --- a/src/plugins/teleop/Teleop.cc +++ b/src/plugins/teleop/Teleop.cc @@ -168,7 +168,7 @@ void Teleop::SetTopic(const QString &_topic) (this->dataPtr->topic); if (!this->dataPtr->cmdVelPub) { - App()->findChild()->notifyWithDuration( + emit App()->findChild()->notifyWithDuration( QString::fromStdString("Error when advertising topic: " + this->dataPtr->topic), 4000); gzerr << "Error when advertising topic: " << @@ -176,18 +176,18 @@ void Teleop::SetTopic(const QString &_topic) } else { - App()->findChild()->notifyWithDuration( + emit App()->findChild()->notifyWithDuration( QString::fromStdString("Advertising topic: '" + this->dataPtr->topic + "'"), 4000); } - this->TopicChanged(); + emit this->TopicChanged(); } ///////////////////////////////////////////////// void Teleop::SetMaxForwardVel(double _velocity) { this->dataPtr->maxForwardVel = _velocity; - this->MaxForwardVelChanged(); + emit this->MaxForwardVelChanged(); } ///////////////////////////////////////////////// @@ -200,7 +200,7 @@ double Teleop::MaxForwardVel() const void Teleop::SetMaxVerticalVel(double _velocity) { this->dataPtr->maxVerticalVel = _velocity; - this->MaxVerticalVelChanged(); + emit this->MaxVerticalVelChanged(); } ///////////////////////////////////////////////// @@ -213,7 +213,7 @@ double Teleop::MaxVerticalVel() const void Teleop::SetMaxYawVel(double _velocity) { this->dataPtr->maxYawVel = _velocity; - this->MaxYawVelChanged(); + emit this->MaxYawVelChanged(); } ///////////////////////////////////////////////// diff --git a/src/plugins/topic_echo/TopicEcho.cc b/src/plugins/topic_echo/TopicEcho.cc index e91c28478..eb6547c13 100644 --- a/src/plugins/topic_echo/TopicEcho.cc +++ b/src/plugins/topic_echo/TopicEcho.cc @@ -110,7 +110,7 @@ void TopicEcho::OnMessage(const google::protobuf::Message &_msg) std::lock_guard lock(this->dataPtr->mutex); - this->AddMsg(QString::fromStdString(_msg.DebugString())); + emit this->AddMsg(QString::fromStdString(_msg.DebugString())); } ///////////////////////////////////////////////// @@ -142,7 +142,7 @@ QString TopicEcho::Topic() const void TopicEcho::SetTopic(const QString &_topic) { this->dataPtr->topic = _topic; - this->TopicChanged(); + emit this->TopicChanged(); } ///////////////////////////////////////////////// @@ -162,7 +162,7 @@ bool TopicEcho::Paused() const void TopicEcho::SetPaused(const bool &_paused) { this->dataPtr->paused = _paused; - this->PausedChanged(); + emit this->PausedChanged(); } } // namespace gz::gui::plugins diff --git a/src/plugins/topic_echo/TopicEcho_TEST.cc b/src/plugins/topic_echo/TopicEcho_TEST.cc index d91249bdd..edb746589 100644 --- a/src/plugins/topic_echo/TopicEcho_TEST.cc +++ b/src/plugins/topic_echo/TopicEcho_TEST.cc @@ -139,7 +139,7 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) // Check message was echoed ASSERT_EQ(msgStringList->rowCount(), 1); - EXPECT_EQ(msgStringList->stringList()[0].toStdString(), + EXPECT_EQ(msgStringList->stringList().at(0).toStdString(), "data: \"example string\"\n"); // Publish more than buffer size (messages numbered 0 to 14) @@ -210,9 +210,9 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) ASSERT_EQ(msgStringList->rowCount(), 11); // The last one is guaranteed to be the new message - EXPECT_EQ(msgStringList->stringList().last().toStdString(), + EXPECT_EQ(msgStringList->stringList().constLast().toStdString(), "data: \"new message\"\n") - << msgStringList->stringList().last().toStdString(); + << msgStringList->stringList().constLast().toStdString(); // Pause plugin->SetPaused(true); @@ -232,9 +232,9 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) ++sleep; } ASSERT_EQ(msgStringList->rowCount(), 11); - EXPECT_EQ(msgStringList->stringList().last().toStdString(), + EXPECT_EQ(msgStringList->stringList().constLast().toStdString(), "data: \"new message\"\n") - << msgStringList->stringList().last().toStdString(); + << msgStringList->stringList().constLast().toStdString(); // Decrease buffer bufferField->setProperty("value", 5); @@ -260,9 +260,9 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) ASSERT_EQ(msgStringList->rowCount(), 5); // The last message is still the new one - EXPECT_EQ(msgStringList->stringList().last().toStdString(), + EXPECT_EQ(msgStringList->stringList().constLast().toStdString(), "data: \"new message 2\"\n") - << msgStringList->stringList().last().toStdString(); + << msgStringList->stringList().constLast().toStdString(); // Stop echoing plugin->OnEcho(false); diff --git a/src/plugins/topic_viewer/TopicViewer.cc b/src/plugins/topic_viewer/TopicViewer.cc index edbecae45..96bb042f5 100644 --- a/src/plugins/topic_viewer/TopicViewer.cc +++ b/src/plugins/topic_viewer/TopicViewer.cc @@ -409,14 +409,14 @@ void TopicViewer::UpdateModel() } // remove the topics that don't exist in the network - for (auto topic : topicsToRemove) + for (const auto &topic : topicsToRemove) { - auto root = this->dataPtr->model->invisibleRootItem(); + auto *root = this->dataPtr->model->invisibleRootItem(); // search for the topic in the model for (int i = 0; i < root->rowCount(); ++i) { - auto child = root->child(i); + auto *child = root->child(i); if (child->data(NAME_ROLE).toString().toStdString() == topic.first && child->data(TYPE_ROLE).toString().toStdString() == topic.second) diff --git a/src/plugins/world_control/WorldControl.cc b/src/plugins/world_control/WorldControl.cc index 86095179c..ebdc0f54b 100644 --- a/src/plugins/world_control/WorldControl.cc +++ b/src/plugins/world_control/WorldControl.cc @@ -153,7 +153,7 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) << "]" << std::endl; // Play / pause buttons - if (auto playElem = _pluginElem->FirstChildElement("play_pause")) + if (const auto *playElem = _pluginElem->FirstChildElement("play_pause")) { auto has = false; playElem->QueryBoolText(&has); @@ -162,21 +162,21 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) if (has) { auto startPaused = this->dataPtr->pause; - if (auto pausedElem = _pluginElem->FirstChildElement("start_paused")) + if (const auto *pausedElem = _pluginElem->FirstChildElement("start_paused")) { pausedElem->QueryBoolText(&startPaused); } this->dataPtr->pause = startPaused; this->dataPtr->lastStatsMsgPaused = startPaused; if (startPaused) - this->paused(); + emit this->paused(); else - this->playing(); + emit this->playing(); } } // Step buttons - if (auto stepElem = _pluginElem->FirstChildElement("step")) + if (const auto *stepElem = _pluginElem->FirstChildElement("step")) { auto has = false; stepElem->QueryBoolText(&has); @@ -185,7 +185,7 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) // Subscribe to world stats std::string statsTopic; - auto statsTopicElem = _pluginElem->FirstChildElement("stats_topic"); + const auto *statsTopicElem = _pluginElem->FirstChildElement("stats_topic"); if (nullptr != statsTopicElem && nullptr != statsTopicElem->GetText()) statsTopic = statsTopicElem->GetText(); @@ -230,7 +230,7 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) << std::endl; } - if (auto elem = _pluginElem->FirstChildElement("use_event")) + if (const auto *elem = _pluginElem->FirstChildElement("use_event")) elem->QueryBoolText(&this->dataPtr->useEvent); if (this->dataPtr->useEvent) @@ -261,10 +261,10 @@ void WorldControl::ProcessMsg() // this plugin has been registered by the server if (this->dataPtr->msg.paused() && (!this->dataPtr->pause || !this->dataPtr->lastStatsMsgPaused)) - this->paused(); + emit this->paused(); else if (!this->dataPtr->msg.paused() && (this->dataPtr->pause || this->dataPtr->lastStatsMsgPaused)) - this->playing(); + emit this->playing(); this->dataPtr->pause = this->dataPtr->msg.paused(); this->dataPtr->lastStatsMsgPaused = this->dataPtr->msg.paused(); @@ -302,7 +302,7 @@ void WorldControl::OnPause() void WorldControl::OnReset() { msgs::WorldControl msg; - auto msgReset = new msgs::WorldReset(); + auto *msgReset = new msgs::WorldReset(); msgReset->set_all(true); msg.set_pause(true); msg.set_allocated_reset(msgReset); diff --git a/src/plugins/world_stats/WorldStats.cc b/src/plugins/world_stats/WorldStats.cc index 96c2ecead..7fdae646f 100644 --- a/src/plugins/world_stats/WorldStats.cc +++ b/src/plugins/world_stats/WorldStats.cc @@ -288,7 +288,7 @@ QString WorldStats::RealTimeFactor() const void WorldStats::SetRealTimeFactor(const QString &_realTimeFactor) { this->dataPtr->realTimeFactor = _realTimeFactor; - this->RealTimeFactorChanged(); + emit this->RealTimeFactorChanged(); } ///////////////////////////////////////////////// @@ -301,7 +301,7 @@ QString WorldStats::SimTime() const void WorldStats::SetSimTime(const QString &_simTime) { this->dataPtr->simTime = _simTime; - this->SimTimeChanged(); + emit this->SimTimeChanged(); } ///////////////////////////////////////////////// @@ -314,7 +314,7 @@ QString WorldStats::RealTime() const void WorldStats::SetRealTime(const QString &_realTime) { this->dataPtr->realTime = _realTime; - this->RealTimeChanged(); + emit this->RealTimeChanged(); } ///////////////////////////////////////////////// @@ -327,7 +327,7 @@ QString WorldStats::Iterations() const void WorldStats::SetIterations(const QString &_iterations) { this->dataPtr->iterations = _iterations; - this->IterationsChanged(); + emit this->IterationsChanged(); } } // namespace gz::gui::plugins diff --git a/test/integration/transport_scene_manager.cc b/test/integration/transport_scene_manager.cc index 9c71e08e2..73481e228 100644 --- a/test/integration/transport_scene_manager.cc +++ b/test/integration/transport_scene_manager.cc @@ -73,7 +73,7 @@ TEST(TransportSceneManagerTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Load)) EXPECT_EQ(plugin->Title(), "Transport Scene Manager"); // Cleanup - for (const auto &p : plugins) + for (const auto &p : qAsConst(plugins)) { auto pluginName = p->CardItem()->objectName().toStdString(); EXPECT_TRUE(app.RemovePlugin(pluginName)); From 364fbca2767d6c0fc688a6be22c1099efad86d06 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Fri, 10 Nov 2023 15:28:32 +0000 Subject: [PATCH 04/33] Lint Signed-off-by: Michael Carroll --- src/plugins/world_control/WorldControl.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/world_control/WorldControl.cc b/src/plugins/world_control/WorldControl.cc index ebdc0f54b..b6a0ca48c 100644 --- a/src/plugins/world_control/WorldControl.cc +++ b/src/plugins/world_control/WorldControl.cc @@ -162,7 +162,8 @@ void WorldControl::LoadConfig(const tinyxml2::XMLElement *_pluginElem) if (has) { auto startPaused = this->dataPtr->pause; - if (const auto *pausedElem = _pluginElem->FirstChildElement("start_paused")) + if (const auto *pausedElem = + _pluginElem->FirstChildElement("start_paused")) { pausedElem->QueryBoolText(&startPaused); } From 273fac06c0698033a9ee5db13eb296e791139532 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 21:10:18 +0000 Subject: [PATCH 05/33] Make use of auto* more consistent Signed-off-by: Michael Carroll --- src/MainWindow_TEST.cc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/MainWindow_TEST.cc b/src/MainWindow_TEST.cc index f81749b61..b223a0654 100644 --- a/src/MainWindow_TEST.cc +++ b/src/MainWindow_TEST.cc @@ -51,7 +51,7 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor)) Application app(g_argc, g_argv); // Constructor - auto mainWindow = new MainWindow; + auto *mainWindow = new MainWindow; ASSERT_NE(nullptr, mainWindow); mainWindow->deleteLater(); @@ -64,10 +64,10 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(OnSaveConfig)) Application app(g_argc, g_argv); // Change default config path - App()->SetDefaultConfigPath(kTestConfigFile); + app.SetDefaultConfigPath(kTestConfigFile); // Create window - auto mainWindow = new MainWindow; + auto *mainWindow = new MainWindow; ASSERT_NE(nullptr, mainWindow); // Save to default location @@ -100,7 +100,7 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(SaveConfigAs)) common::Console::SetVerbosity(4); Application app(g_argc, g_argv); - auto mainWindow = new MainWindow; + auto *mainWindow = new MainWindow; ASSERT_NE(nullptr, mainWindow); // Save to file @@ -137,10 +137,10 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(OnLoadConfig)) Application app(g_argc, g_argv); // Add test plugins to path - App()->AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); + app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); // Get main window - auto mainWindow = App()->findChild(); + auto *mainWindow = app.findChild(); ASSERT_NE(nullptr, mainWindow); // Check window doesn't have any plugins @@ -179,10 +179,10 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(OnAddPlugin)) Application app(g_argc, g_argv); // Add test plugins to path - App()->AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); + app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); // Get window - auto mainWindow = App()->findChild(); + auto *mainWindow = app.findChild(); ASSERT_NE(nullptr, mainWindow); // Check window doesn't have any plugins @@ -344,7 +344,7 @@ TEST(MainWindowTest, bool closed{false}; QTimer::singleShot(300, App(), [&closed] { - auto win = App()->findChild(); + auto *win = app.findChild(); ASSERT_NE(nullptr, win); EXPECT_TRUE(win->QuickWindow()->isVisible()); @@ -376,7 +376,7 @@ TEST(MainWindowTest, }); // Show window - App()->exec(); + app.exec(); EXPECT_TRUE(closed); } @@ -392,7 +392,7 @@ TEST(MainWindowTest, PROJECT_SOURCE_PATH, "test", "config", "close_dialog_auto_shutdown.config")); // Get main window - auto mainWindow = App()->findChild(); + auto *mainWindow = app.findChild(); ASSERT_NE(nullptr, mainWindow); bool shutdownCalled{false}; @@ -424,7 +424,7 @@ TEST(MainWindowTest, PROJECT_SOURCE_PATH, "test", "config", "close_dialog_custom_shutdown_service.config")); // Get main window - auto mainWindow = App()->findChild(); + auto *mainWindow = app.findChild(); ASSERT_NE(nullptr, mainWindow); bool shutdownCalled{false}; @@ -471,7 +471,7 @@ TEST(MainWindowTest, PROJECT_SOURCE_PATH, "test", "config", "close_dialog_auto_gui_only.config")); // Get main window - auto mainWindow = App()->findChild(); + auto *mainWindow = app.findChild(); ASSERT_NE(nullptr, mainWindow); bool shutdownCalled{false}; @@ -574,7 +574,7 @@ TEST(MainWindowTest, PROJECT_SOURCE_PATH, "test", "config", "close_dialog_buttons.config")); // Get main window - auto mainWindow = App()->findChild(); + auto *mainWindow = app.findChild(); ASSERT_NE(nullptr, mainWindow); // Trigger the closing behavior @@ -634,7 +634,7 @@ TEST(MainWindowTest, PROJECT_SOURCE_PATH, "test", "config", "close_dialog_default_buttons.config")); // Get main window - auto mainWindow = App()->findChild(); + auto *mainWindow = app.findChild(); ASSERT_NE(nullptr, mainWindow); // Trigger the closing behavior @@ -682,7 +682,7 @@ TEST(MainWindowTest, PROJECT_SOURCE_PATH, "test", "config", "close_dialog_buttons_text.config")); // Get main window - auto mainWindow = App()->findChild(); + auto *mainWindow = app.findChild(); ASSERT_NE(nullptr, mainWindow); // Trigger the closing behavior @@ -704,11 +704,11 @@ TEST(MainWindowTest, }); ASSERT_EQ(expectedRoles, roles); - auto closeGui = buttonRoles[ButtonRole::AcceptRole]; + auto *closeGui = buttonRoles[ButtonRole::AcceptRole]; EXPECT_EQ("close_gui", closeGui->property("text").toString().toStdString()); - auto shutdown = buttonRoles[ButtonRole::DestructiveRole]; + auto *shutdown = buttonRoles[ButtonRole::DestructiveRole]; EXPECT_EQ("shutdown", shutdown->property("text").toString().toStdString()); } @@ -720,7 +720,7 @@ TEST(MainWindowTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(ApplyConfig)) Application app(g_argc, g_argv); // Main window - auto mainWindow = new MainWindow; + auto *mainWindow = new MainWindow; ASSERT_NE(nullptr, mainWindow); app.processEvents(QEventLoop::ExcludeUserInputEvents); From 44bd78607c5c9cd6cb8ee7a1adf0921a7ecc0e6e Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 21:24:56 +0000 Subject: [PATCH 06/33] Make cmake qt-version agnostic Signed-off-by: Michael Carroll --- CMakeLists.txt | 17 ++++++++++++----- include/gz/gui/CMakeLists.txt | 32 +++++++------------------------- test/integration/CMakeLists.txt | 6 ++---- 3 files changed, 21 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f8290883..76c14898a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,15 +73,11 @@ set(GZ_RENDERING_VER ${gz-rendering9_VERSION_MAJOR}) gz_find_package(gz-msgs11 REQUIRED) set(GZ_MSGS_VER ${gz-msgs11_VERSION_MAJOR}) -# Find if command is available. This is used to enable tests. -# Note that CLI files are installed regardless of whether the dependency is -# available during build time -find_program(HAVE_GZ_TOOLS gz) -set(GZ_TOOLS_VER 2) #-------------------------------------- # Find QT gz_find_package (Qt5 + VERSION 5.15 COMPONENTS Core Quick @@ -91,6 +87,17 @@ gz_find_package (Qt5 PKGCONFIG "Qt5Core Qt5Quick Qt5QuickControls2 Qt5Widgets" ) +if (BUILD_TESTING) + # Find if command is available. This is used to enable tests. + # Note that CLI files are installed regardless of whether the dependency is + # available during build time + find_program(HAVE_GZ_TOOLS gz) + set(GZ_TOOLS_VER 2) + + find_package(Qt5 REQUIRED COMPONENTS Test) + +endif() + set(GZ_GUI_PLUGIN_RELATIVE_INSTALL_DIR ${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins ) diff --git a/include/gz/gui/CMakeLists.txt b/include/gz/gui/CMakeLists.txt index 27db7054e..5e15317d6 100644 --- a/include/gz/gui/CMakeLists.txt +++ b/include/gz/gui/CMakeLists.txt @@ -1,26 +1,9 @@ -include_directories( - ${Qt5Core_INCLUDE_DIRS} - ${tinyxml_INCLUDE_DIRS} - ${Qt5Qml_INCLUDE_DIRS} - ${Qt5Quick_INCLUDE_DIRS} - ${Qt5QuickControls2_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} -) - if(POLICY CMP0100) cmake_policy(SET CMP0100 NEW) endif() set (CMAKE_AUTOMOC ON) -add_definitions( - ${Qt5Core_DEFINITIONS} - ${Qt5Qml_DEFINITIONS} - ${Qt5Quick_DEFINITIONS} - ${Qt5QuickControls2_DEFINITIONS} - ${Qt5Widgets_DEFINITIONS} -) - set (qt_headers Application.hh Dialog.hh @@ -42,8 +25,8 @@ set (headers set (resources resources.qrc) -QT5_WRAP_CPP(headers_MOC ${qt_headers}) -QT5_ADD_RESOURCES(resources_RCC ${resources}) +qt_wrap_cpp(headers_MOC ${qt_headers}) +qt_add_resources(resources_RCC ${resources}) gz_create_core_library(SOURCES ${sources} @@ -67,13 +50,12 @@ target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} gz-msgs${GZ_MSGS_VER}::gz-msgs${GZ_MSGS_VER} gz-plugin${GZ_PLUGIN_VER}::loader gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER} - ${Qt5Core_LIBRARIES} - ${Qt5Qml_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5QuickControls2_LIBRARIES} - ${Qt5Widgets_LIBRARIES} + Qt::Core + Qt::Qml + Qt::Quick + Qt::QuickControls2 + Qt::Widgets TINYXML2::TINYXML2 ) gz_install_all_headers() - diff --git a/test/integration/CMakeLists.txt b/test/integration/CMakeLists.txt index 70c2ff1e5..2a04b198a 100644 --- a/test/integration/CMakeLists.txt +++ b/test/integration/CMakeLists.txt @@ -1,7 +1,5 @@ gz_get_sources(tests) -find_package(Qt5Test REQUIRED) - gz_build_tests( TYPE INTEGRATION SOURCES ${tests} @@ -9,7 +7,7 @@ gz_build_tests( ${PROJECT_NAME}_test_helpers gz-plugin${GZ_PLUGIN_VER}::loader gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} - Qt5::Test - ENVIRONMENT + Qt::Test + ENVIRONMENT GZ_GUI_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} ) From bc58d5938772b196964da9b96aa3a73ae836bb94 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 21:26:00 +0000 Subject: [PATCH 07/33] lambda capture Signed-off-by: Michael Carroll --- src/MainWindow_TEST.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MainWindow_TEST.cc b/src/MainWindow_TEST.cc index b223a0654..0d2fc6d81 100644 --- a/src/MainWindow_TEST.cc +++ b/src/MainWindow_TEST.cc @@ -342,7 +342,7 @@ TEST(MainWindowTest, // Access window after it's open bool closed{false}; - QTimer::singleShot(300, App(), [&closed] + QTimer::singleShot(300, App(), [&closed, &app] { auto *win = app.findChild(); ASSERT_NE(nullptr, win); From 6c35be0dc6e799057961a184aa36ad7994658fc7 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 21:44:00 +0000 Subject: [PATCH 08/33] Remove qt5 from examples Signed-off-by: Michael Carroll --- examples/plugin/custom_context_menu/CMakeLists.txt | 10 ++-------- examples/plugin/dialog_from_plugin/CMakeLists.txt | 9 +-------- examples/plugin/gz_components/CMakeLists.txt | 8 ++------ examples/plugin/hello_plugin/CMakeLists.txt | 11 ++--------- examples/plugin/multiple_qml/CMakeLists.txt | 7 +------ examples/standalone/custom_drawer/CMakeLists.txt | 8 +------- examples/standalone/dialogs/CMakeLists.txt | 10 +--------- examples/standalone/window/CMakeLists.txt | 7 +------ 8 files changed, 11 insertions(+), 59 deletions(-) diff --git a/examples/plugin/custom_context_menu/CMakeLists.txt b/examples/plugin/custom_context_menu/CMakeLists.txt index a0a2a67a1..0ad64aa2e 100644 --- a/examples/plugin/custom_context_menu/CMakeLists.txt +++ b/examples/plugin/custom_context_menu/CMakeLists.txt @@ -9,7 +9,7 @@ endif() set (CMAKE_AUTOMOC ON) # Find Qt5 -find_package (Qt5 +find_package (Qt5 5.15 COMPONENTS Core Quick @@ -21,9 +21,7 @@ find_package (Qt5 find_package(gz-gui9 REQUIRED) set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR}) -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}") - -QT5_ADD_RESOURCES(resources_RCC CustomContext.qrc) +qt_add_resources(resources_RCC CustomContext.qrc) # Generate examples add_library(CustomContext SHARED ${headers_MOC} @@ -32,8 +30,4 @@ add_library(CustomContext SHARED ${headers_MOC} ) target_link_libraries(CustomContext gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER} - ${Qt5Core_LIBRARIES} - ${Qt5Qml_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5QuickControls2_LIBRARIES} ) diff --git a/examples/plugin/dialog_from_plugin/CMakeLists.txt b/examples/plugin/dialog_from_plugin/CMakeLists.txt index 038238de1..54de73a3d 100644 --- a/examples/plugin/dialog_from_plugin/CMakeLists.txt +++ b/examples/plugin/dialog_from_plugin/CMakeLists.txt @@ -8,7 +8,6 @@ endif() set (CMAKE_AUTOMOC ON) -# Find Qt5 find_package (Qt5 COMPONENTS Core @@ -21,9 +20,7 @@ find_package (Qt5 find_package(gz-gui9 REQUIRED) set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR}) -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}") - -QT5_ADD_RESOURCES(resources_RCC DialogFromPlugin.qrc) +qt_add_resources(resources_RCC DialogFromPlugin.qrc) # Generate examples add_library(DialogFromPlugin SHARED ${headers_MOC} @@ -32,8 +29,4 @@ add_library(DialogFromPlugin SHARED ${headers_MOC} ) target_link_libraries(DialogFromPlugin gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER} - ${Qt5Core_LIBRARIES} - ${Qt5Qml_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5QuickControls2_LIBRARIES} ) diff --git a/examples/plugin/gz_components/CMakeLists.txt b/examples/plugin/gz_components/CMakeLists.txt index 24cc05cfc..0ae3f9461 100644 --- a/examples/plugin/gz_components/CMakeLists.txt +++ b/examples/plugin/gz_components/CMakeLists.txt @@ -8,7 +8,7 @@ endif() set (CMAKE_AUTOMOC ON) -find_package (Qt5 +find_package (Qt5 5.15 COMPONENTS Core Quick @@ -21,7 +21,7 @@ set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR}) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}") -QT5_ADD_RESOURCES(resources_RCC GzComponents.qrc) +qt_add_resources(resources_RCC GzComponents.qrc) # Generate examples add_library(GzComponents SHARED ${headers_MOC} @@ -30,8 +30,4 @@ add_library(GzComponents SHARED ${headers_MOC} ) target_link_libraries(GzComponents gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER} - ${Qt5Core_LIBRARIES} - ${Qt5Qml_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5QuickControls2_LIBRARIES} ) diff --git a/examples/plugin/hello_plugin/CMakeLists.txt b/examples/plugin/hello_plugin/CMakeLists.txt index ea9c4dc85..940dc5580 100644 --- a/examples/plugin/hello_plugin/CMakeLists.txt +++ b/examples/plugin/hello_plugin/CMakeLists.txt @@ -8,8 +8,7 @@ endif() set (CMAKE_AUTOMOC ON) -# Find Qt5 -find_package (Qt5 +find_package (Qt5 5.15 COMPONENTS Core Quick @@ -21,9 +20,7 @@ find_package (Qt5 find_package(gz-gui9 REQUIRED) set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR}) -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}") - -QT5_ADD_RESOURCES(resources_RCC hello.qrc) +qt_add_resources(resources_RCC hello.qrc) # Generate examples add_library(HelloPlugin SHARED ${headers_MOC} @@ -32,8 +29,4 @@ add_library(HelloPlugin SHARED ${headers_MOC} ) target_link_libraries(HelloPlugin gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER} - ${Qt5Core_LIBRARIES} - ${Qt5Qml_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5QuickControls2_LIBRARIES} ) diff --git a/examples/plugin/multiple_qml/CMakeLists.txt b/examples/plugin/multiple_qml/CMakeLists.txt index 269f41cd7..76ca88aea 100644 --- a/examples/plugin/multiple_qml/CMakeLists.txt +++ b/examples/plugin/multiple_qml/CMakeLists.txt @@ -8,7 +8,6 @@ endif() set (CMAKE_AUTOMOC ON) -# Find Qt5 find_package (Qt5 COMPONENTS Core @@ -23,7 +22,7 @@ set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR}) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}") -QT5_ADD_RESOURCES(resources_RCC MultipleQml.qrc) +qt_add_resources(resources_RCC MultipleQml.qrc) # Generate examples add_library(MultipleQml SHARED ${headers_MOC} @@ -32,8 +31,4 @@ add_library(MultipleQml SHARED ${headers_MOC} ) target_link_libraries(MultipleQml gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER} - ${Qt5Core_LIBRARIES} - ${Qt5Qml_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5QuickControls2_LIBRARIES} ) diff --git a/examples/standalone/custom_drawer/CMakeLists.txt b/examples/standalone/custom_drawer/CMakeLists.txt index 7765a7ebd..31d79d8a3 100644 --- a/examples/standalone/custom_drawer/CMakeLists.txt +++ b/examples/standalone/custom_drawer/CMakeLists.txt @@ -21,9 +21,7 @@ find_package (Qt5 find_package(gz-gui9 REQUIRED) set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR}) -QT5_ADD_RESOURCES(resources_RCC custom_drawer.qrc) - -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}") +qt_add_resources(resources_RCC custom_drawer.qrc) # Generate example add_executable(custom_drawer @@ -32,8 +30,4 @@ add_executable(custom_drawer ) target_link_libraries(custom_drawer gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER} - ${Qt5Core_LIBRARIES} - ${Qt5Qml_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5QuickControls2_LIBRARIES} ) diff --git a/examples/standalone/dialogs/CMakeLists.txt b/examples/standalone/dialogs/CMakeLists.txt index 54c146035..49fd17ea4 100644 --- a/examples/standalone/dialogs/CMakeLists.txt +++ b/examples/standalone/dialogs/CMakeLists.txt @@ -8,8 +8,7 @@ endif() set (CMAKE_AUTOMOC ON) -# Find Qt5 -find_package (Qt5 +find_package (Qt5 5.15 COMPONENTS Core Quick @@ -21,17 +20,10 @@ find_package (Qt5 find_package(gz-gui9 REQUIRED) set(GZ_GUI_VER ${gz-gui9_VERSION_MAJOR}) -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GZ-GUI_CXX_FLAGS}") - # Generate example add_executable(dialogs dialogs.cc ) target_link_libraries(dialogs gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER} - ${Qt5Core_LIBRARIES} - ${Qt5Qml_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5QuickControls2_LIBRARIES} ) - diff --git a/examples/standalone/window/CMakeLists.txt b/examples/standalone/window/CMakeLists.txt index 710ee91f6..9c062dd87 100644 --- a/examples/standalone/window/CMakeLists.txt +++ b/examples/standalone/window/CMakeLists.txt @@ -9,7 +9,7 @@ endif() set (CMAKE_AUTOMOC ON) # Find Qt5 -find_package (Qt5 +find_package (Qt5 5.15 COMPONENTS Core Quick @@ -29,9 +29,4 @@ add_executable(window ) target_link_libraries(window gz-gui${GZ_GUI_VER}::gz-gui${GZ_GUI_VER} - ${Qt5Core_LIBRARIES} - ${Qt5Qml_LIBRARIES} - ${Qt5Quick_LIBRARIES} - ${Qt5QuickControls2_LIBRARIES} ) - From 126b69070c96ab513e8f36e2ff18bffcc72a638f Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 21:56:12 +0000 Subject: [PATCH 09/33] Remove Qt < 5.15 logic Signed-off-by: Michael Carroll --- src/Application.cc | 2 - src/Conversions.cc | 4 - src/Conversions_TEST.cc | 6 - src/plugins/minimal_scene/MinimalScene.cc | 126 +++++++----------- .../minimal_scene/MinimalSceneRhiOpenGL.cc | 28 ---- 5 files changed, 47 insertions(+), 119 deletions(-) diff --git a/src/Application.cc b/src/Application.cc index 87201de81..1e26be313 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -161,9 +161,7 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, # endif ); -# if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) QQuickWindow::setSceneGraphBackend(QSGRendererInterface::VulkanRhi); -# endif } else { diff --git a/src/Conversions.cc b/src/Conversions.cc index 6e2d6c292..6fbd79419 100644 --- a/src/Conversions.cc +++ b/src/Conversions.cc @@ -122,11 +122,7 @@ gz::common::MouseEvent convert(const QWheelEvent &_e) common::MouseEvent event; event.SetType(common::MouseEvent::SCROLL); -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) - event.SetPos(_e.x(), _e.y()); -#else event.SetPos(_e.position().x(), _e.position().y()); -#endif double scroll = (_e.angleDelta().y() > 0) ? -1.0 : 1.0; event.SetScroll(scroll, scroll); diff --git a/src/Conversions_TEST.cc b/src/Conversions_TEST.cc index 54902d1d3..a9972a71b 100644 --- a/src/Conversions_TEST.cc +++ b/src/Conversions_TEST.cc @@ -149,15 +149,9 @@ TEST(ConversionsTest, MouseEvent) // Scroll { -#if QT_VERSION < QT_VERSION_CHECK(5, 12, 0) - QWheelEvent qtEvent(QPointF(123, 456), QPointF(1000, 2000), QPoint(2, 3), - QPoint(1, 4), -1, Qt::Horizontal, Qt::MiddleButton, Qt::ShiftModifier, - Qt::ScrollUpdate, Qt::MouseEventNotSynthesized, false); -#else QWheelEvent qtEvent(QPointF(123, 456), QPointF(1000, 2000), QPoint(2, 3), QPoint(1, 4), Qt::MiddleButton, Qt::ShiftModifier, Qt::ScrollUpdate, false); -#endif auto gzEvent = convert(qtEvent); diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index 7b92cf407..4d0534dfb 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -52,11 +52,17 @@ #include "gz/gui/Helpers.hh" #include "gz/gui/MainWindow.hh" -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) +#define GZ_GUI_HAVE_VULKAN \ + QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && \ + QT_CONFIG(vulkan) && \ + GZ_RENDERING_HAVE_VULKAN + +#define GZ_GUI_HAVE_METAL __APPLE__ + +#if GZ_GUI_HAVE_VULKAN # include # include -#endif +#endif // GZ_HAVE_VULKAN Q_DECLARE_METATYPE(gz::gui::plugins::RenderSync*) @@ -216,7 +222,7 @@ class gz::gui::plugins::RenderWindowItem::Implementation /// \brief Graphics API. The default is platform specific. public: gz::rendering::GraphicsAPI graphicsAPI = -#ifdef __APPLE__ +#if GZ_GUI_HAVE_METAL_ rendering::GraphicsAPI::METAL; #else rendering::GraphicsAPI::OPENGL; @@ -584,14 +590,14 @@ rendering::CameraPtr GzRenderer::Camera() return this->dataPtr->camera; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) +#if GZ_GUI_HAVE_VULKAN +namespace { ///////////////////////////////////////////////// /// \brief fillQtInstanceExtensionsToOgre /// Extract Vulkan Instance extension information to be sent to OgreNext /// \param[in] inst Qt's Vulkan Instance to extract /// \param[out] externalInstance Data to be sent to OgreNext -static void fillQtInstanceExtensionsToOgre( +void fillQtInstanceExtensionsToOgre( const QVulkanInstance *inst, rendering::GzVulkanExternalInstance &externalInstance) { @@ -628,7 +634,7 @@ static void fillQtInstanceExtensionsToOgre( /// Extract Vulkan Device extension info to be sent to OgreNext /// This data is obtained from Environment variables /// \param[out] externalDevice Data to be sent to OgreNext -static void fillQtDeviceExtensionsToOgre( +void fillQtDeviceExtensionsToOgre( rendering::GzVulkanExternalDevice &externalDevice) { // We know Qt adds these by looking at @@ -658,13 +664,14 @@ static void fillQtDeviceExtensionsToOgre( extProp.extensionName[VK_MAX_EXTENSION_NAME_SIZE - 1u] = 0; } } -#endif +} // namespace +#endif // GZ_GUI_HAVE_VULKAN ///////////////////////////////////////////////// std::string GzRenderer::Initialize(RenderThreadRhi &_rhi) { if (this->initialized) - return std::string(); + return {}; // Currently only support one engine at a time rendering::RenderEngine *engine{nullptr}; @@ -678,8 +685,7 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi) this->dataPtr->rhiParams["winID"] = std::to_string(quickWindow->winId()); -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) +#if GZ_GUI_HAVE_VULKAN // externalInstance & externalDevice MUST be declared at this scope // because we save their stack addresses into this->dataPtr->rhiParams // and must be alive until rendering::engine() returns. @@ -734,7 +740,7 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi) engine = rendering::engine(loadedEngines.front()); } - if (!engine) + if (engine == nullptr) { return "Engine [" + this->engineName + "] is not supported"; } @@ -788,7 +794,7 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi) this->dataPtr->rayQuery = this->dataPtr->camera->Scene()->CreateRayQuery(); this->initialized = true; - return std::string(); + return {}; } ///////////////////////////////////////////////// @@ -807,14 +813,13 @@ void GzRenderer::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) { gzdbg << "Creating gz-rendering interface for Vulkan" << std::endl; this->dataPtr->rhiParams["vulkan"] = "1"; -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) +#if GZ_GUI_HAVE_VULKAN this->dataPtr->rhi = std::make_unique(); #else this->dataPtr->rhi = std::make_unique(); #endif } -#ifdef __APPLE__ +#if GZ_GUI_HAVE_METAL else if (_graphicsAPI == rendering::GraphicsAPI::METAL) { gzdbg << "Creating gz-renderering interface for Metal" << std::endl; @@ -827,11 +832,11 @@ void GzRenderer::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) ///////////////////////////////////////////////// void GzRenderer::Destroy() { - auto engine = rendering::engine(this->engineName); - if (!engine) + auto *engine = rendering::engine(this->engineName); + if (engine == nullptr) return; auto scene = engine->SceneByName(this->sceneName); - if (!scene) + if (scene == nullptr) return; scene->DestroySensor(this->dataPtr->camera); @@ -902,7 +907,7 @@ RenderThread::RenderThread() ///////////////////////////////////////////////// void RenderThread::SetErrorCb(std::function _cb) { - this->errorCb = _cb; + this->errorCb = std::move(_cb); } ///////////////////////////////////////////////// @@ -929,8 +934,8 @@ void RenderThread::ShutDown() ///////////////////////////////////////////////// void RenderThread::SizeChanged() { - auto item = qobject_cast(this->sender()); - if (!item) + auto *item = qobject_cast(this->sender()); + if (item == nullptr) { gzerr << "Internal error, sender is not QQuickItem." << std::endl; return; @@ -975,32 +980,26 @@ void RenderThread::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) this->gzRenderer.SetGraphicsAPI(_graphicsAPI); // Create the render interface - if (_graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) - // Use fallback (GPU -> CPU -> GPU) - || _graphicsAPI == rendering::GraphicsAPI::VULKAN -#endif - ) + if (_graphicsAPI == rendering::GraphicsAPI::OPENGL) { gzdbg << "Creating render thread interface for OpenGL" << std::endl; this->rhi = std::make_unique(&this->gzRenderer); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) + +#if GZ_GUI_HAVE_VULKAN else if (_graphicsAPI == rendering::GraphicsAPI::VULKAN) { gzdbg << "Creating render thread interface for Vulkan" << std::endl; this->rhi = std::make_unique(&this->gzRenderer); } -#endif -#ifdef __APPLE__ +#endif // GZ_GUI_HAVE_VULKAN +#if GZ_GUI_HAVE_METAL else if (_graphicsAPI == rendering::GraphicsAPI::METAL) { gzdbg << "Creating render thread interface for Metal" << std::endl; this->rhi = std::make_unique(&this->gzRenderer); } -#endif +#endif // GZ_GUI_HAVE_METAL } ///////////////////////////////////////////////// @@ -1017,42 +1016,29 @@ std::string RenderThread::Initialize() ///////////////////////////////////////////////// TextureNode::TextureNode(QQuickWindow *_window, RenderSync &_renderSync, const rendering::GraphicsAPI &_graphicsAPI, - rendering::CameraPtr & -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) - _camera -#endif - ) : + rendering::CameraPtr &_camera): renderSync(_renderSync), window(_window) { - if (_graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) - // Use fallback (GPU -> CPU -> GPU) - || _graphicsAPI == rendering::GraphicsAPI::VULKAN -#endif - ) + if (_graphicsAPI == rendering::GraphicsAPI::OPENGL) { gzdbg << "Creating texture node render interface for OpenGL" << std::endl; this->rhi = std::make_unique(_window); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) +#if GZ_GUI_HAVE_VULKAN else if (_graphicsAPI == rendering::GraphicsAPI::VULKAN) { gzdbg << "Creating texture node render interface for Vulkan" << std::endl; this->rhi = std::make_unique(_window, _camera); } -#else -#endif -#ifdef __APPLE__ +#endif // GZ_GUI_HAVE_VULKAN +#if GZ_GUI_HAVE_METAL else if (_graphicsAPI == rendering::GraphicsAPI::METAL) { gzdbg << "Creating texture node render interface for Metal" << std::endl; this->rhi = std::make_unique(_window); } -#endif +#endif // GZ_GUI_HAVE_METAL this->setTexture(this->rhi->Texture()); } @@ -1144,13 +1130,7 @@ void RenderWindowItem::StopRendering() // This slot will run on the main thread void RenderWindowItem::Ready() { - if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) - // Use fallback (GPU -> CPU -> GPU) - || this->dataPtr->graphicsAPI == rendering::GraphicsAPI::VULKAN -#endif - ) + if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL) { this->dataPtr->renderThread->SetSurface(new QOffscreenSurface()); this->dataPtr->renderThread->Surface()->setFormat( @@ -1164,13 +1144,7 @@ void RenderWindowItem::Ready() return; } - if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) - // Use fallback (GPU -> CPU -> GPU) - || this->dataPtr->graphicsAPI == rendering::GraphicsAPI::VULKAN -#endif - ) + if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL) { // Move context to the render thread this->dataPtr->renderThread->Context()->moveToThread( @@ -1213,13 +1187,7 @@ QSGNode *RenderWindowItem::updatePaintNode(QSGNode *_node, this->dataPtr->renderThread->SetGraphicsAPI( this->dataPtr->graphicsAPI); - if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL -#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) && \ - defined(GZ_RENDERING_HAVE_VULKAN) - // Use fallback (GPU -> CPU -> GPU) - || this->dataPtr->graphicsAPI == rendering::GraphicsAPI::VULKAN -#endif - ) + if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL) { QOpenGLContext *current = this->window()->openglContext(); // Some GL implementations require that the currently bound context is @@ -1658,21 +1626,21 @@ void RenderWindowItem::HandleKeyRelease(const common::KeyEvent &_e) ///////////////////////////////////////////////// void MinimalScene::OnHovered(int _mouseX, int _mouseY) { - auto renderWindow = this->PluginItem()->findChild(); + auto *renderWindow = this->PluginItem()->findChild(); renderWindow->OnHovered({_mouseX, _mouseY}); } ///////////////////////////////////////////////// void MinimalScene::OnDropped(const QString &_drop, int _mouseX, int _mouseY) { - auto renderWindow = this->PluginItem()->findChild(); + auto *renderWindow = this->PluginItem()->findChild(); renderWindow->OnDropped(_drop, {_mouseX, _mouseY}); } ///////////////////////////////////////////////// void MinimalScene::OnFocusWindow() { - auto renderWindow = this->PluginItem()->findChild(); + auto *renderWindow = this->PluginItem()->findChild(); renderWindow->forceActiveFocus(); } @@ -1687,7 +1655,7 @@ void MinimalScene::SetLoadingError(const QString &_loadingError) { if (!_loadingError.isEmpty()) { - auto renderWindow = this->PluginItem()->findChild(); + auto *renderWindow = this->PluginItem()->findChild(); if (nullptr != renderWindow) renderWindow->StopRendering(); } diff --git a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc index c75fb3aba..5e2ab1f24 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc +++ b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc @@ -206,26 +206,12 @@ TextureNodeRhiOpenGL::TextureNodeRhiOpenGL(QQuickWindow *_window) this->dataPtr->window = _window; // Our texture node must have a texture, so use the default 0 texture. -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -# ifndef _WIN32 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -# endif - this->dataPtr->texture = this->dataPtr->window->createTextureFromId( - this->dataPtr->textureId, - QSize(1, 1), - QQuickWindow::TextureIsOpaque); -# ifndef _WIN32 -# pragma GCC diagnostic pop -# endif -#else this->dataPtr->texture = this->dataPtr->window->createTextureFromNativeObject( QQuickWindow::NativeObjectTexture, static_cast(&this->dataPtr->textureId), 0, QSize(1, 1)); -#endif } ///////////////////////////////////////////////// @@ -265,26 +251,12 @@ void TextureNodeRhiOpenGL::PrepareNode() delete this->dataPtr->texture; this->dataPtr->texture = nullptr; -#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) -# ifndef _WIN32 -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wdeprecated-declarations" -# endif - this->dataPtr->texture = this->dataPtr->window->createTextureFromId( - this->dataPtr->newTextureId, - this->dataPtr->newSize, - QQuickWindow::TextureIsOpaque); -# ifndef _WIN32 -# pragma GCC diagnostic pop -# endif -#else this->dataPtr->texture = this->dataPtr->window->createTextureFromNativeObject( QQuickWindow::NativeObjectTexture, static_cast(&this->dataPtr->newTextureId), 0, this->dataPtr->newSize); -#endif } } } // namespace gz::gui::plugins From ffa6430e0c3739399592cc52f892137e5d0409a8 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 22:01:10 +0000 Subject: [PATCH 10/33] Additional qt5 cmake functions Signed-off-by: Michael Carroll --- src/plugins/CMakeLists.txt | 6 +++--- test/CMakeLists.txt | 5 +---- test/helpers/CMakeLists.txt | 2 +- test/plugins/CMakeLists.txt | 12 ++---------- 4 files changed, 7 insertions(+), 18 deletions(-) diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 3f40148e9..f5bcf98f1 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -22,8 +22,8 @@ function(gz_gui_add_library library_name) set(multiValueArgs SOURCES QT_HEADERS PUBLIC_LINK_LIBS PRIVATE_LINK_LIBS) cmake_parse_arguments(gz_gui_add_library "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - QT5_WRAP_CPP(${library_name}_headers_MOC ${gz_gui_add_library_QT_HEADERS}) - QT5_ADD_RESOURCES(${library_name}_RCC ${library_name}.qrc) + qt_wrap_cpp(${library_name}_headers_MOC ${gz_gui_add_library_QT_HEADERS}) + qt_add_resources(${library_name}_RCC ${library_name}.qrc) add_library(${library_name} SHARED ${gz_gui_add_library_SOURCES} @@ -94,7 +94,7 @@ function(gz_gui_add_plugin plugin_name) ${PROJECT_SOURCE_DIR} # Used to make test_config.h visible to the unit tests ${PROJECT_BINARY_DIR} - ENVIRONMENT + ENVIRONMENT GZ_GUI_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) endif() diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 3c471aa58..553a2c6b0 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,9 +1,6 @@ -configure_file (test_config.hh.in +configure_file (test_config.hh.in ${PROJECT_BINARY_DIR}/include/test_config.hh ) -include_directories ( - ${PROJECT_BINARY_DIR}/include -) add_subdirectory(gtest_vendor) add_subdirectory(helpers) diff --git a/test/helpers/CMakeLists.txt b/test/helpers/CMakeLists.txt index 46af75c2a..082f3dcd5 100644 --- a/test/helpers/CMakeLists.txt +++ b/test/helpers/CMakeLists.txt @@ -2,7 +2,7 @@ set (qt_headers TestHelper.hh ) -QT5_WRAP_CPP(headers_MOC ${qt_headers}) +qt_wrap_cpp(headers_MOC ${qt_headers}) add_library(${PROJECT_NAME}_test_helpers SHARED TestHelper.cc diff --git a/test/plugins/CMakeLists.txt b/test/plugins/CMakeLists.txt index ec5cd1b93..6f2b4b345 100644 --- a/test/plugins/CMakeLists.txt +++ b/test/plugins/CMakeLists.txt @@ -2,13 +2,6 @@ if (WIN32) add_definitions(-DBUILDING_DLL) endif() -include_directories( - ${PROJECT_SOURCE_DIR} -) - -link_directories( -) - set (plugins TestBadInheritancePlugin TestInvalidQmlPlugin @@ -18,9 +11,9 @@ set (plugins # Plugin shared libraries foreach (src ${plugins}) - QT5_WRAP_CPP(${src}_MOC ${src}.hh) + qt_wrap_cpp(${src}_MOC ${src}.hh) if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${src}.qrc") - QT5_ADD_RESOURCES(${src}_RCC ${src}.qrc) + qt_add_resources(${src}_RCC ${src}.qrc) endif() add_library(${src} SHARED ${src}.cc @@ -34,4 +27,3 @@ foreach (src ${plugins}) gz-plugin${GZ_PLUGIN_VER}::register ) endforeach (src ${qt_headers_local}) - From d7c9adf07c46332fa67f7a2e674fcb1d342de6b8 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Wed, 25 Oct 2023 18:00:00 +0000 Subject: [PATCH 11/33] @wip Signed-off-by: Michael Carroll --- CMakeLists.txt | 12 ++- examples/config/scene3d.config | 43 ---------- include/gz/gui/qml/GzCard.qml | 1 - include/gz/gui/qml/GzCardSettings.qml | 23 ++--- include/gz/gui/qml/GzSnackBar.qml | 9 +- include/gz/gui/qml/GzSpinBox.qml | 15 ++-- include/gz/gui/qml/GzSplit.qml | 4 +- include/gz/gui/qml/Main.qml | 8 +- include/gz/gui/qml/StyleDialog.qml | 23 +---- src/Application.cc | 15 ++-- src/Plugin.cc | 8 +- src/cmd/CMakeLists.txt | 7 ++ src/cmd/gui_main.cc | 85 +++++++++++++++++++ src/plugins/minimal_scene/CMakeLists.txt | 49 ++++------- src/plugins/minimal_scene/MinimalScene.cc | 64 ++++++-------- src/plugins/minimal_scene/MinimalScene.hh | 2 +- src/plugins/minimal_scene/MinimalScene.qml | 13 +-- .../minimal_scene/MinimalSceneConfig.hh | 34 ++++++++ .../minimal_scene/MinimalSceneRhiOpenGL.cc | 21 ++--- .../minimal_scene/MinimalSceneRhiVulkan.cc | 27 +++--- src/plugins/topic_echo/TopicEcho_TEST.cc | 13 ++- src/plugins/topic_viewer/TopicViewer.qml | 9 +- 22 files changed, 253 insertions(+), 232 deletions(-) create mode 100644 src/cmd/gui_main.cc create mode 100644 src/plugins/minimal_scene/MinimalSceneConfig.hh diff --git a/CMakeLists.txt b/CMakeLists.txt index 76c14898a..58f616795 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -76,15 +76,14 @@ set(GZ_MSGS_VER ${gz-msgs11_VERSION_MAJOR}) #-------------------------------------- # Find QT -gz_find_package (Qt5 - VERSION 5.15 +gz_find_package (Qt6 COMPONENTS Core Quick QuickControls2 Widgets REQUIRED - PKGCONFIG "Qt5Core Qt5Quick Qt5QuickControls2 Qt5Widgets" + PKGCONFIG "Qt6Core Qt6Quick Qt6QuickControls2 Qt6Widgets" ) if (BUILD_TESTING) @@ -94,10 +93,15 @@ if (BUILD_TESTING) find_program(HAVE_GZ_TOOLS gz) set(GZ_TOOLS_VER 2) - find_package(Qt5 REQUIRED COMPONENTS Test) + find_package(Qt6 REQUIRED COMPONENTS Test) +endif() +if(POLICY CMP0100) + cmake_policy(SET CMP0100 NEW) endif() +qt_standard_project_setup() + set(GZ_GUI_PLUGIN_RELATIVE_INSTALL_DIR ${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins ) diff --git a/examples/config/scene3d.config b/examples/config/scene3d.config index 26719cb40..119d1a90e 100644 --- a/examples/config/scene3d.config +++ b/examples/config/scene3d.config @@ -72,46 +72,3 @@ false - - - Controls - false - false - 72 - 121 - 1 - - floating - - - - - - true - true - false - /world_control - /world_stats - - - - - Stats - false - false - 110 - 290 - 1 - - floating - - - - - - true - true - true - true - /world_stats - diff --git a/include/gz/gui/qml/GzCard.qml b/include/gz/gui/qml/GzCard.qml index c6c4464e6..468af06bf 100644 --- a/include/gz/gui/qml/GzCard.qml +++ b/include/gz/gui/qml/GzCard.qml @@ -15,7 +15,6 @@ * */ import QtQuick 2.9 -import QtQuick.Controls 1.4 as QQC1 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.1 import QtQuick.Layouts 1.3 diff --git a/include/gz/gui/qml/GzCardSettings.qml b/include/gz/gui/qml/GzCardSettings.qml index 0bf9423d9..32ec8e67a 100644 --- a/include/gz/gui/qml/GzCardSettings.qml +++ b/include/gz/gui/qml/GzCardSettings.qml @@ -14,11 +14,11 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Window 2.2 -import QtQuick.Dialogs 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Window +import QtQuick.Dialogs import "qrc:/qml" Dialog { @@ -135,7 +135,7 @@ Dialog { GzSpinBox { visible: !cardPane.anchored - maximumValue: cardPane.parent ? cardPane.parent.width - cardPane.width : minSize + to: cardPane.parent ? cardPane.parent.width - cardPane.width : from onVisibleChanged: value = cardPane.x onValueChanged: { cardPane.x = value; @@ -147,7 +147,7 @@ Dialog { } GzSpinBox { visible: !cardPane.anchored - maximumValue: cardPane.parent ? cardPane.parent.height - cardPane.height : minSize + to: cardPane.parent ? cardPane.parent.height - cardPane.height : from onVisibleChanged: value = cardPane.y onValueChanged: { cardPane.y = value; @@ -159,7 +159,7 @@ Dialog { } GzSpinBox { visible: !cardPane.anchored - maximumValue: 10000 + to: 10000 onVisibleChanged: value = cardPane.z onValueChanged: { cardPane.z = value; @@ -177,7 +177,7 @@ Dialog { text: "" } GzSpinBox { - maximumValue: cardPane.parent ? cardPane.parent.width : minSize + to: cardPane.parent ? cardPane.parent.width : from onVisibleChanged: { if (cardPane) value = cardPane.width @@ -190,7 +190,8 @@ Dialog { text: "Width" } GzSpinBox { - maximumValue: cardPane.parent ? cardPane.parent.height : minSize + to: cardPane.parent ? cardPane.parent.height : from + onVisibleChanged: { if (cardPane) value = cardPane.height @@ -208,7 +209,7 @@ Dialog { ColorDialog { id: colorDialog title: "Please choose a color" - showAlphaChannel : true + options: [ColorDialog.ShowAlphaChannel] onAccepted: { content.color = colorDialog.color bgColor.color = colorDialog.color diff --git a/include/gz/gui/qml/GzSnackBar.qml b/include/gz/gui/qml/GzSnackBar.qml index f4f2dc3c8..fbdfeb6e3 100644 --- a/include/gz/gui/qml/GzSnackBar.qml +++ b/include/gz/gui/qml/GzSnackBar.qml @@ -15,11 +15,10 @@ * */ -import QtGraphicalEffects 1.0 import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.2 -import QtQuick.Dialogs 1.0 +import QtQuick.Dialogs import QtQuick.Layouts 1.3 import QtQuick.Window 2.2 @@ -70,12 +69,6 @@ Popup { background: Rectangle { color: Material.background layer.enabled: true - layer.effect: DropShadow { - color: "#aa000000" - samples: 9 - spread: 0 - radius: 8.0 - } } // this function is called when notify() or notifyWithDuration() are called diff --git a/include/gz/gui/qml/GzSpinBox.qml b/include/gz/gui/qml/GzSpinBox.qml index 800db5e11..ce955bd47 100644 --- a/include/gz/gui/qml/GzSpinBox.qml +++ b/include/gz/gui/qml/GzSpinBox.qml @@ -14,16 +14,13 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 1.4 -import QtQuick.Controls.Styles 1.4 +import QtQuick +import QtQuick.Controls SpinBox { - style: SpinBoxStyle{ - background: Rectangle { - implicitWidth: 70 - implicitHeight: 40 - border.color: "gray" - } + background: Rectangle { + implicitWidth: 70 + implicitHeight: 40 + border.color: "gray" } } diff --git a/include/gz/gui/qml/GzSplit.qml b/include/gz/gui/qml/GzSplit.qml index 87e521a71..72c18d9a6 100644 --- a/include/gz/gui/qml/GzSplit.qml +++ b/include/gz/gui/qml/GzSplit.qml @@ -15,8 +15,7 @@ * */ import QtQuick 2.9 -import QtQuick.Controls 1.1 -import QtQuick.Controls 2.2 +import QtQuick.Controls import QtQuick.Controls.Material 2.1 import QtQuick.Layouts 1.3 @@ -382,4 +381,3 @@ SplitView { } } } - diff --git a/include/gz/gui/qml/Main.qml b/include/gz/gui/qml/Main.qml index c18154f29..fcdadd411 100644 --- a/include/gz/gui/qml/Main.qml +++ b/include/gz/gui/qml/Main.qml @@ -17,7 +17,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.1 -import QtQuick.Dialogs 1.0 +import QtQuick.Dialogs import QtQuick.Layouts 1.3 import ExitAction 1.0 import "qrc:/qml" @@ -295,10 +295,7 @@ ApplicationWindow FileDialog { id: loadFileDialog title: "Load configuration" - folder: shortcuts.home nameFilters: [ "Config files (*.config)" ] - selectMultiple: false - selectExisting: true onAccepted: { MainWindow.OnLoadConfig(fileUrl) } @@ -310,10 +307,7 @@ ApplicationWindow FileDialog { id: saveFileDialog title: "Save configuration" - folder: shortcuts.home nameFilters: [ "Config files (*.config)" ] - selectMultiple: false - selectExisting: false onAccepted: { var selected = fileUrl.toString(); diff --git a/include/gz/gui/qml/StyleDialog.qml b/include/gz/gui/qml/StyleDialog.qml index f8566b0ca..28b5e25bf 100644 --- a/include/gz/gui/qml/StyleDialog.qml +++ b/include/gz/gui/qml/StyleDialog.qml @@ -17,7 +17,7 @@ import QtQuick 2.9 import QtQuick.Controls 2.2 import QtQuick.Controls.Material 2.1 -import QtQuick.Dialogs 1.0 +import QtQuick.Dialogs /** * Style dialog @@ -309,9 +309,6 @@ Dialog { text: modelData width: parent.width } - onCurrentTextChanged: { - updateTheme(); - } } Label { @@ -322,15 +319,6 @@ Dialog { id: materialPrimaryDialog title: "Primary color" // options: ColorDialog.NoButtons - onCurrentColorChanged: { - - // Avoiding pure black because for some reason it is set to that as the - // dialog opens - if (currentColor == "#000000") - return; - - updatePrimary(colorToHex(currentColor)) - } } Row { @@ -368,15 +356,6 @@ Dialog { id: materialAccentDialog title: "Accent color" // options: ColorDialog.NoButtons - onCurrentColorChanged: { - - // Avoiding pure black because for some reason it is set to that as the - // dialog opens - if (currentColor == "#000000") - return; - - updateAccent(colorToHex(currentColor)) - } } Row { diff --git a/src/Application.cc b/src/Application.cc index 1e26be313..d64516462 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -108,7 +108,7 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, #ifdef __APPLE__ AvailableAPIs api = AvailableAPIs::Metal; #else - AvailableAPIs api = AvailableAPIs::OpenGL; + AvailableAPIs api = AvailableAPIs::Vulkan; #endif if (_renderEngineGuiApiBackend) { @@ -147,8 +147,6 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, if (api == AvailableAPIs::Vulkan) { - gzdbg << "Qt using Vulkan graphics interface" << std::endl; - # ifdef GZ_USE_VULKAN_DEBUG_EXT qputenv("QT_VULKAN_INSTANCE_EXTENSIONS", "VK_EXT_debug_report;VK_EXT_debug_utils"); @@ -161,7 +159,8 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, # endif ); - QQuickWindow::setSceneGraphBackend(QSGRendererInterface::VulkanRhi); + QQuickWindow::setGraphicsApi(QSGRendererInterface::VulkanRhi); + gzdbg << "Qt using Vulkan graphics interface" << std::endl; } else { @@ -204,14 +203,14 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, switch (api) { default: - case AvailableAPIs::OpenGL: - this->dataPtr->mainWin->setProperty("renderEngineBackendApiName", - "opengl"); - break; case AvailableAPIs::Vulkan: this->dataPtr->mainWin->setProperty("renderEngineBackendApiName", "vulkan"); break; + case AvailableAPIs::OpenGL: + this->dataPtr->mainWin->setProperty("renderEngineBackendApiName", + "opengl"); + break; case AvailableAPIs::Metal: this->dataPtr->mainWin->setProperty("renderEngineBackendApiName", "metal"); diff --git a/src/Plugin.cc b/src/Plugin.cc index c36f36dd3..ebc6ad126 100644 --- a/src/Plugin.cc +++ b/src/Plugin.cc @@ -421,9 +421,15 @@ QQuickItem *Plugin::CardItem() const return this->dataPtr->cardItem; // Instantiate a card - std::string qmlFile(":qml/GzCard.qml"); + std::string qmlFile(":/qml/GzCard.qml"); QQmlComponent cardComp(App()->Engine(), QString::fromStdString(qmlFile)); auto *cardItem = qobject_cast(cardComp.create()); + + if (cardComp.isError()) + { + qWarning() << cardComp.errors(); + } + if (!cardItem) { gzerr << "Internal error: Failed to instantiate QML file [" << qmlFile diff --git a/src/cmd/CMakeLists.txt b/src/cmd/CMakeLists.txt index 821cd4acf..abe327531 100644 --- a/src/cmd/CMakeLists.txt +++ b/src/cmd/CMakeLists.txt @@ -1,3 +1,10 @@ +add_executable(gui_main gui_main.cc) + +target_link_libraries(gui_main + ${PROJECT_LIBRARY_TARGET_NAME} + gz-utils${GZ_UTILS_VER}::cli +) + #=============================================================================== # Generate the ruby script for internal testing. # Note that the major version of the library is included in the name. diff --git a/src/cmd/gui_main.cc b/src/cmd/gui_main.cc new file mode 100644 index 000000000..ef1fa14fa --- /dev/null +++ b/src/cmd/gui_main.cc @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2023 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 + + +////////////////////////////////////////////////// +/// \brief Enumeration of available commands +enum class GuiCommand +{ + kNone, + kGuiStandalone, +}; + +////////////////////////////////////////////////// +struct GuiOptions +{ + GuiCommand command {GuiCommand::kNone}; +}; + +////////////////////////////////////////////////// +void startConsoleLog() +{ + std::string home; + gz::common::env(GZ_HOMEDIR, home); + + std::string logPathMod = gz::common::joinPaths(home, + ".gz", "gui", "log", + gz::common::timeToIso(GZ_SYSTEM_TIME())); + gzLogInit(logPathMod, "console.log"); + + gz::common::Console::SetVerbosity(4); +} + +////////////////////////////////////////////////// +void runGuiCommand(const GuiOptions &_opt) +{ + startConsoleLog(); + + int g_argc = 1; + char* g_argv[] = {"./gz"}; + gz::gui::Application app(g_argc, g_argv); + + auto *mainWindow = app.findChild(); + // Set the render engine GUI name + mainWindow->SetRenderEngine("ogre2"); + app.LoadPlugin("MinimalScene"); + + gz::gui::Application::exec(); +} + +////////////////////////////////////////////////// +void addGuiFlags(CLI::App &_app) +{ + auto opt = std::make_shared(); + _app.callback([opt](){runGuiCommand(*opt); }); +} + +int main(int argc, char** argv) +{ + CLI::App app{"Gazebo GUI"}; + addGuiFlags(app); + app.formatter(std::make_shared(&app)); + CLI11_PARSE(app, argc, argv); +} diff --git a/src/plugins/minimal_scene/CMakeLists.txt b/src/plugins/minimal_scene/CMakeLists.txt index f037a862b..301eab35d 100644 --- a/src/plugins/minimal_scene/CMakeLists.txt +++ b/src/plugins/minimal_scene/CMakeLists.txt @@ -1,44 +1,31 @@ set(SOURCES MinimalScene.cc + MinimalScene.hh MinimalSceneRhi.cc + MinimalSceneRhi.hh MinimalSceneRhiOpenGL.cc + MinimalSceneRhiOpenGL.hh MinimalSceneRhiVulkan.cc + MinimalSceneRhiVulkan.hh EngineToQtInterface.cc + EngineToQtInterface.hh ) -set(PROJECT_LINK_LIBS "") - -# Objective-C sources for macOS -if (APPLE) - set(SOURCES - ${SOURCES} - MinimalSceneRhiMetal.mm - ) - - set(PROJECT_LINK_LIBS - "-framework AppKit" - "-framework Metal" - ) -endif() +qt6_add_qml_module(MinimalScene + URI MinimalScene + VERSION 1.0 + SOURCES ${SOURCES} + QML_FILES MinimalScene.qml +) -gz_gui_add_plugin(MinimalScene - SOURCES - ${SOURCES} - EngineToQtInterface.hh - QT_HEADERS - MinimalScene.hh - PUBLIC_LINK_LIBS +target_link_libraries(MinimalScene PRIVATE gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER} - ${PROJECT_LINK_LIBS} + gz-plugin${GZ_PLUGIN_VER}::register + Qt6::Gui + Qt6::Widgets + Qt6::Quick + Qt6::QuickControls2 ) -# Enable ARC on selected source files -if (APPLE) - set_source_files_properties( - MinimalSceneRhiMetal.mm - PROPERTIES - COMPILE_FLAGS - "-fobjc-arc -Wno-nullability-completeness" - ) -endif() +install (TARGETS MinimalScene DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index 4d0534dfb..ffd7bf01f 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -17,12 +17,10 @@ #include #include +#include #include "MinimalScene.hh" -#include "MinimalSceneRhi.hh" -#include "MinimalSceneRhiMetal.hh" -#include "MinimalSceneRhiOpenGL.hh" -#include "MinimalSceneRhiVulkan.hh" +#include "MinimalSceneConfig.hh" #include #include @@ -37,8 +35,11 @@ #include #include #include -#include + + +#include #include +#include #include #include #include @@ -222,9 +223,11 @@ class gz::gui::plugins::RenderWindowItem::Implementation /// \brief Graphics API. The default is platform specific. public: gz::rendering::GraphicsAPI graphicsAPI = -#if GZ_GUI_HAVE_METAL_ +#if GZ_GUI_HAVE_METAL rendering::GraphicsAPI::METAL; -#else +#elif GZ_GUI_HAVE_VULKAN + rendering::GraphicsAPI::VULKAN; +#elif MINIMAL_SCENE_HAVE_OPENGL rendering::GraphicsAPI::OPENGL; #endif @@ -311,9 +314,9 @@ GzRenderer::GzRenderer() : dataPtr(utils::MakeUniqueImpl()) { const std::string backendApiName = gz::gui::renderEngineBackendApiName(); - if (backendApiName == "vulkan") + if (backendApiName == "opengl") { - this->SetGraphicsAPI(rendering::GraphicsAPI::VULKAN); + this->SetGraphicsAPI(rendering::GraphicsAPI::OPENGL); } else if (backendApiName == "metal") { @@ -321,7 +324,7 @@ GzRenderer::GzRenderer() } else { - this->SetGraphicsAPI(rendering::GraphicsAPI::OPENGL); + this->SetGraphicsAPI(rendering::GraphicsAPI::VULKAN); } } @@ -723,8 +726,9 @@ std::string GzRenderer::Initialize(RenderThreadRhi &_rhi) this->dataPtr->rhiParams["external_device"] = std::to_string(reinterpret_cast(&externalDevice)); } -#endif +#endif // MINIMAL_SCENE_HAVE_VULKAN + std::cout << "Loading engine: " << this->engineName << std::endl; engine = rendering::engine(this->engineName, this->dataPtr->rhiParams); } else @@ -809,16 +813,14 @@ void GzRenderer::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) this->dataPtr->rhiParams["useCurrentGLContext"] = "1"; this->dataPtr->rhi = std::make_unique(); } +#if GZ_GUI_HAVE_VULKAN else if (_graphicsAPI == rendering::GraphicsAPI::VULKAN) { gzdbg << "Creating gz-rendering interface for Vulkan" << std::endl; this->dataPtr->rhiParams["vulkan"] = "1"; -#if GZ_GUI_HAVE_VULKAN this->dataPtr->rhi = std::make_unique(); -#else - this->dataPtr->rhi = std::make_unique(); -#endif } +#endif // GZ_GUI_HAVE_VULKAN #if GZ_GUI_HAVE_METAL else if (_graphicsAPI == rendering::GraphicsAPI::METAL) { @@ -826,7 +828,7 @@ void GzRenderer::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) this->dataPtr->rhiParams["metal"] = "1"; this->dataPtr->rhi = std::make_unique(); } -#endif +#endif // GZ_GUI_HAVE_METAL } ///////////////////////////////////////////////// @@ -887,9 +889,9 @@ RenderThread::RenderThread() { // Set default graphics API to OpenGL const std::string backendApiName = gz::gui::renderEngineBackendApiName(); - if (backendApiName == "vulkan") + if (backendApiName == "opengl") { - this->SetGraphicsAPI(rendering::GraphicsAPI::VULKAN); + this->SetGraphicsAPI(rendering::GraphicsAPI::OPENGL); } else if (backendApiName == "metal") { @@ -897,7 +899,7 @@ RenderThread::RenderThread() } else { - this->SetGraphicsAPI(rendering::GraphicsAPI::OPENGL); + this->SetGraphicsAPI(rendering::GraphicsAPI::VULKAN); } RenderWindowItem::Implementation::threads << this; @@ -985,7 +987,6 @@ void RenderThread::SetGraphicsAPI(const rendering::GraphicsAPI &_graphicsAPI) gzdbg << "Creating render thread interface for OpenGL" << std::endl; this->rhi = std::make_unique(&this->gzRenderer); } - #if GZ_GUI_HAVE_VULKAN else if (_graphicsAPI == rendering::GraphicsAPI::VULKAN) { @@ -1100,6 +1101,7 @@ void TextureNode::PrepareNode() RenderWindowItem::RenderWindowItem(QQuickItem *_parent) : QQuickItem(_parent), dataPtr(utils::MakeUniqueImpl()) { + std::cout << "RenderWindowItem::RenderWindowItem" << std::endl; this->setAcceptedMouseButtons(Qt::AllButtons); this->setFlag(ItemHasContents); this->dataPtr->renderThread = new RenderThread(); @@ -1108,6 +1110,7 @@ RenderWindowItem::RenderWindowItem(QQuickItem *_parent) ///////////////////////////////////////////////// RenderWindowItem::~RenderWindowItem() { + std::cout << "RenderWindowItem::~RenderWindowItem" << std::endl; this->StopRendering(); } @@ -1189,23 +1192,6 @@ QSGNode *RenderWindowItem::updatePaintNode(QSGNode *_node, if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL) { - QOpenGLContext *current = this->window()->openglContext(); - // Some GL implementations require that the currently bound context is - // made non-current before we set up sharing, so we doneCurrent here - // and makeCurrent down below while setting up our own context. - current->doneCurrent(); - - this->dataPtr->renderThread->SetContext(new QOpenGLContext()); - this->dataPtr->renderThread->Context()->setFormat(current->format()); - this->dataPtr->renderThread->Context()->setShareContext(current); - this->dataPtr->renderThread->Context()->create(); - - // The slot "Ready" runs on the main thread, move the context to match - this->dataPtr->renderThread->Context()->moveToThread( - QApplication::instance()->thread()); - - current->makeCurrent(this->window()); - // Initialize on main thread QMetaObject::invokeMethod(this, "Ready", Qt::QueuedConnection); } @@ -1344,7 +1330,7 @@ void RenderWindowItem::SetCameraViewController( ///////////////////////////////////////////////// MinimalScene::MinimalScene() - : Plugin(), dataPtr(utils::MakeUniqueImpl()) + : dataPtr(utils::MakeUniqueImpl()) { qmlRegisterType("RenderWindow", 1, 0, "RenderWindow"); } @@ -1367,6 +1353,8 @@ void MinimalScene::LoadConfig(const tinyxml2::XMLElement *_pluginElem) this->title = "3D Scene"; std::string cmdRenderEngine = gui::renderEngineName(); + std::cout << "MinimalScene::LoadConfig " << cmdRenderEngine << std::endl; + // Custom parameters if (_pluginElem) { diff --git a/src/plugins/minimal_scene/MinimalScene.hh b/src/plugins/minimal_scene/MinimalScene.hh index 5f8bd433d..34f00a1ff 100644 --- a/src/plugins/minimal_scene/MinimalScene.hh +++ b/src/plugins/minimal_scene/MinimalScene.hh @@ -206,7 +206,7 @@ namespace gz::gui::plugins private: void BroadcastKeyPress(); /// \brief Render engine to use - public: std::string engineName = "ogre"; + public: std::string engineName = "ogre2"; /// \brief Unique scene name public: std::string sceneName = "scene"; diff --git a/src/plugins/minimal_scene/MinimalScene.qml b/src/plugins/minimal_scene/MinimalScene.qml index 5969a31c6..3c991f547 100644 --- a/src/plugins/minimal_scene/MinimalScene.qml +++ b/src/plugins/minimal_scene/MinimalScene.qml @@ -14,11 +14,12 @@ * limitations under the License. * */ -import QtGraphicalEffects 1.0 -import QtQuick 2.9 -import QtQuick.Controls 2.0 -import QtQuick.Layouts 1.3 -import RenderWindow 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import RenderWindow + +import Qt5Compat.GraphicalEffects Rectangle { Layout.minimumWidth: 200 @@ -51,7 +52,7 @@ Rectangle { id: renderWindow objectName: "rw" anchors.fill: parent - visible: MinimalScene.loadingError.length == 0 + // visible: MinimalScene.loadingError.length == 0 } /* diff --git a/src/plugins/minimal_scene/MinimalSceneConfig.hh b/src/plugins/minimal_scene/MinimalSceneConfig.hh new file mode 100644 index 000000000..f9fafe6fe --- /dev/null +++ b/src/plugins/minimal_scene/MinimalSceneConfig.hh @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2017 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 + +#define MINIMAL_SCENE_HAVE_OPENGL true + +#define MINIMAL_SCENE_HAVE_VULKAN \ + QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) + +#if defined(__APPLE__) +#define MINIMAL_SCENE_HAVE_METAL 1 +#else +#define MINIMAL_SCENE_HAVE_METAL 0 +#endif + +constexpr bool kMinimalSceneHaveOpenGl = MINIMAL_SCENE_HAVE_OPENGL; +constexpr bool kMinimalSceneHaveVulkan = MINIMAL_SCENE_HAVE_VULKAN; +constexpr bool kMinimalSceneHaveMETAL = MINIMAL_SCENE_HAVE_METAL; diff --git a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc index 5e2ab1f24..70f971614 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc +++ b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc @@ -16,6 +16,7 @@ */ #include "MinimalSceneRhiOpenGL.hh" +#include #include "EngineToQtInterface.hh" #include "MinimalScene.hh" @@ -204,14 +205,11 @@ TextureNodeRhiOpenGL::TextureNodeRhiOpenGL(QQuickWindow *_window) : dataPtr(std::make_unique()) { this->dataPtr->window = _window; - - // Our texture node must have a texture, so use the default 0 texture. this->dataPtr->texture = - this->dataPtr->window->createTextureFromNativeObject( - QQuickWindow::NativeObjectTexture, - static_cast(&this->dataPtr->textureId), - 0, - QSize(1, 1)); + QNativeInterface::QSGOpenGLTexture::fromNative( + this->dataPtr->textureId, + this->dataPtr->window, + QSize(1, 1)); } ///////////////////////////////////////////////// @@ -252,11 +250,10 @@ void TextureNodeRhiOpenGL::PrepareNode() this->dataPtr->texture = nullptr; this->dataPtr->texture = - this->dataPtr->window->createTextureFromNativeObject( - QQuickWindow::NativeObjectTexture, - static_cast(&this->dataPtr->newTextureId), - 0, - this->dataPtr->newSize); + QNativeInterface::QSGOpenGLTexture::fromNative( + this->dataPtr->newTextureId, + this->dataPtr->window, + this->dataPtr->newSize); } } } // namespace gz::gui::plugins diff --git a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc b/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc index 9352a7a56..68ca036d3 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc +++ b/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc @@ -182,12 +182,13 @@ TextureNodeRhiVulkan::TextureNodeRhiVulkan(QQuickWindow *_window, _camera->RenderTextureMetalId(&this->dataPtr->textureId); this->dataPtr->lastCamera = _camera; - this->dataPtr->texture = this->dataPtr->window->createTextureFromNativeObject( - QQuickWindow::NativeObjectTexture, - static_cast(&this->dataPtr->textureId), // - 0, // - QSize(static_cast(_camera->ImageWidth()), - static_cast(_camera->ImageHeight()))); + this->dataPtr->texture = + QNativeInterface::QSGVulkanTexture::fromNative( + this->dataPtr->textureId, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + this->dataPtr->window, + QSize(static_cast(_camera->ImageWidth()), + static_cast(_camera->ImageHeight()))); } ///////////////////////////////////////////////// @@ -206,6 +207,7 @@ bool TextureNodeRhiVulkan::HasNewTexture() const void TextureNodeRhiVulkan::NewTexture( void* _texturePtr, const QSize &_size) { + std::cout << "NewTexture" << std::endl; this->dataPtr->mutex.lock(); this->dataPtr->textureId = reinterpret_cast(_texturePtr); this->dataPtr->size = _size; @@ -215,6 +217,7 @@ void TextureNodeRhiVulkan::NewTexture( ///////////////////////////////////////////////// void TextureNodeRhiVulkan::PrepareNode() { + std::cout << "PrepareNode" << std::endl; this->dataPtr->mutex.lock(); this->dataPtr->newTextureId = this->dataPtr->textureId; this->dataPtr->newSize = this->dataPtr->size; @@ -230,14 +233,12 @@ void TextureNodeRhiVulkan::PrepareNode() if (this->dataPtr->newTextureId != nullptr) { delete this->dataPtr->texture; - this->dataPtr->texture = nullptr; - this->dataPtr->texture = - this->dataPtr->window->createTextureFromNativeObject( - QQuickWindow::NativeObjectTexture, - static_cast(&this->dataPtr->newTextureId), - VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, - this->dataPtr->newSize); + QNativeInterface::QSGVulkanTexture::fromNative( + this->dataPtr->newTextureId, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + this->dataPtr->window, + this->dataPtr->newSize); } } } // namespace gz::gui::plugins diff --git a/src/plugins/topic_echo/TopicEcho_TEST.cc b/src/plugins/topic_echo/TopicEcho_TEST.cc index edb746589..e8d934a14 100644 --- a/src/plugins/topic_echo/TopicEcho_TEST.cc +++ b/src/plugins/topic_echo/TopicEcho_TEST.cc @@ -16,7 +16,7 @@ */ #include -#include +#include #include @@ -150,10 +150,8 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) pub.Publish(msg); } - QRegExp regExp13("*13"); - regExp13.setPatternSyntax(QRegExp::Wildcard); - QRegExp regExp14("*14"); - regExp14.setPatternSyntax(QRegExp::Wildcard); + auto regExp13 = QRegularExpression::wildcardToRegularExpression("*13"); + auto regExp14 = QRegularExpression::wildcardToRegularExpression("*14"); // Wait until all 15 messages are received // To avoid flakiness due to messages coming out of order, we check for both @@ -176,12 +174,11 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) // We can't guarantee the order of messages // We expect that out of the 10 messages last, at least 6 belong to the [5-14] // range - QRegExp regExp; - regExp.setPatternSyntax(QRegExp::Wildcard); unsigned int count = 0; for (auto i = 5; i < 15; ++i) { - regExp.setPattern("*" + QString::number(i)); + auto regExp = + QRegularExpression::wildcardToRegularExpression("*" + QString::number(i)); if (msgStringList->stringList().filter(regExp).count() > 0) ++count; } diff --git a/src/plugins/topic_viewer/TopicViewer.qml b/src/plugins/topic_viewer/TopicViewer.qml index 53ccd37ff..8090de350 100644 --- a/src/plugins/topic_viewer/TopicViewer.qml +++ b/src/plugins/topic_viewer/TopicViewer.qml @@ -15,12 +15,9 @@ * */ import QtQml.Models 2.2 -import QtQuick 2.0 -import QtQuick.Controls 1.4 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts TreeView { objectName: "treeView" From aefb832352107151dda8748eb609dba512bddc94 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 21:05:57 +0000 Subject: [PATCH 12/33] @wip Signed-off-by: Michael Carroll --- src/plugins/camera_fps/CMakeLists.txt | 21 ++++++++++++------ src/plugins/camera_fps/CameraFps.qrc | 5 ----- src/plugins/camera_tracking/CMakeLists.txt | 25 ++++++++++++++-------- src/plugins/minimal_scene/CMakeLists.txt | 2 +- src/plugins/minimal_scene/MinimalScene.cc | 3 +++ 5 files changed, 35 insertions(+), 21 deletions(-) delete mode 100644 src/plugins/camera_fps/CameraFps.qrc diff --git a/src/plugins/camera_fps/CMakeLists.txt b/src/plugins/camera_fps/CMakeLists.txt index e9f053158..a07028094 100644 --- a/src/plugins/camera_fps/CMakeLists.txt +++ b/src/plugins/camera_fps/CMakeLists.txt @@ -1,9 +1,18 @@ -gz_gui_add_plugin(CameraFps - SOURCES - CameraFps.cc - QT_HEADERS - CameraFps.hh - PUBLIC_LINK_LIBS +qt6_add_qml_module(CameraFps + URI camera_fps + VERSION 1.0 + SOURCES CameraFps.cc + QML_FILES CameraFps.qml +) + +target_link_libraries(CameraFps PRIVATE gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} + gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER} + gz-plugin${GZ_PLUGIN_VER}::register + Qt6::Gui + Qt6::Widgets + Qt6::Quick + Qt6::QuickControls2 ) +install (TARGETS CameraFps DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) diff --git a/src/plugins/camera_fps/CameraFps.qrc b/src/plugins/camera_fps/CameraFps.qrc deleted file mode 100644 index 57549c350..000000000 --- a/src/plugins/camera_fps/CameraFps.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - CameraFps.qml - - diff --git a/src/plugins/camera_tracking/CMakeLists.txt b/src/plugins/camera_tracking/CMakeLists.txt index cf71123aa..7ca87bbb0 100644 --- a/src/plugins/camera_tracking/CMakeLists.txt +++ b/src/plugins/camera_tracking/CMakeLists.txt @@ -1,11 +1,18 @@ -gz_gui_add_plugin(CameraTracking - SOURCES - CameraTracking.cc - QT_HEADERS - CameraTracking.hh - TEST_SOURCES - # CameraTracking_TEST.cc - PUBLIC_LINK_LIBS +qt6_add_qml_module(CameraTracking + URI camera_tracking + VERSION 1.0 + SOURCES CameraTracking.cc + QML_FILES CameraTracking.qml +) + +target_link_libraries(CameraTracking PRIVATE gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} - gz-common${GZ_COMMON_VER}::profiler + gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER} + gz-plugin${GZ_PLUGIN_VER}::register + Qt6::Gui + Qt6::Widgets + Qt6::Quick + Qt6::QuickControls2 ) + +install(TARGETS CameraTracking DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) diff --git a/src/plugins/minimal_scene/CMakeLists.txt b/src/plugins/minimal_scene/CMakeLists.txt index 301eab35d..1785b781b 100644 --- a/src/plugins/minimal_scene/CMakeLists.txt +++ b/src/plugins/minimal_scene/CMakeLists.txt @@ -12,7 +12,7 @@ set(SOURCES ) qt6_add_qml_module(MinimalScene - URI MinimalScene + URI minimal_scene VERSION 1.0 SOURCES ${SOURCES} QML_FILES MinimalScene.qml diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index ffd7bf01f..e51682203 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -21,6 +21,9 @@ #include "MinimalScene.hh" #include "MinimalSceneConfig.hh" +#include "MinimalSceneRhiMetal.hh" +#include "MinimalSceneRhiOpenGL.hh" +#include "MinimalSceneRhiVulkan.hh" #include #include From 6ebe89c5b799161812ac8c2af7612bdc39524466 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 22:23:43 +0000 Subject: [PATCH 13/33] Fix conversions test Signed-off-by: Michael Carroll --- src/Conversions_TEST.cc | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Conversions_TEST.cc b/src/Conversions_TEST.cc index a9972a71b..e7afc2fc5 100644 --- a/src/Conversions_TEST.cc +++ b/src/Conversions_TEST.cc @@ -104,8 +104,11 @@ TEST(ConversionsTest, MouseEvent) { // Press + Shift { - QMouseEvent qtEvent(QEvent::MouseButtonPress, QPointF(10, 20), - Qt::RightButton, Qt::MiddleButton, Qt::ShiftModifier); + QMouseEvent qtEvent(QEvent::MouseButtonPress, + QPointF(10, 20), QPointF(10, 20), + Qt::RightButton, + Qt::MiddleButton, + Qt::ShiftModifier); auto gzEvent = convert(qtEvent); @@ -119,8 +122,11 @@ TEST(ConversionsTest, MouseEvent) // Release + Control { - QMouseEvent qtEvent(QEvent::MouseButtonRelease, QPointF(0, 200), - Qt::MiddleButton, Qt::RightButton, Qt::ControlModifier); + QMouseEvent qtEvent(QEvent::MouseButtonRelease, + QPointF(0, 200), QPointF(0, 200), + Qt::MiddleButton, + Qt::RightButton, + Qt::ControlModifier); auto gzEvent = convert(qtEvent); @@ -134,8 +140,11 @@ TEST(ConversionsTest, MouseEvent) // Move + Alt { - QMouseEvent qtEvent(QEvent::MouseMove, QPointF(123, 456), - Qt::LeftButton, Qt::LeftButton, Qt::AltModifier); + QMouseEvent qtEvent(QEvent::MouseMove, + QPointF(123, 456), QPointF(123, 456), + Qt::LeftButton, + Qt::LeftButton, + Qt::AltModifier); auto gzEvent = convert(qtEvent); From fa6e2705ee4da5c93788107046781acb3664cfb9 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 22:25:16 +0000 Subject: [PATCH 14/33] Make using deprecated APIs an error Signed-off-by: Michael Carroll --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 76c14898a..011441b63 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,8 @@ gz_find_package (Qt5 PKGCONFIG "Qt5Core Qt5Quick Qt5QuickControls2 Qt5Widgets" ) +add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) + if (BUILD_TESTING) # Find if command is available. This is used to enable tests. # Note that CLI files are installed regardless of whether the dependency is From 9f6c81ccdde7e23ad0de9e2c17c0aa2813b1f2b8 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 22:35:30 +0000 Subject: [PATCH 15/33] Fix vulkan call and qregexp Signed-off-by: Michael Carroll --- src/Application.cc | 10 ++++++++++ src/CMakeLists.txt | 2 +- src/plugins/topic_echo/TopicEcho_TEST.cc | 13 +++++-------- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/Application.cc b/src/Application.cc index 1e26be313..5427a67c3 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -15,6 +15,7 @@ * */ +#include #include #include @@ -126,7 +127,12 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, { // Use the Metal graphics API on macOS. gzdbg << "Qt using Metal graphics interface" << std::endl; +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QQuickWindow::setGraphicsApi(QSGRendererInterface::MetalRhi); +#else QQuickWindow::setSceneGraphBackend(QSGRendererInterface::MetalRhi); +#endif + } // TODO(srmainwaring): implement facility for overriding the default @@ -161,7 +167,11 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, # endif ); +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + QQuickWindow::setGraphicsApi(QSGRendererInterface::VulkanRhi); +#else QQuickWindow::setSceneGraphBackend(QSGRendererInterface::VulkanRhi); +#endif } else { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5d555f470..86684d476 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,7 +54,7 @@ gz_build_tests(TYPE UNIT TINYXML2::TINYXML2 TEST_LIST gtest_targets - ENVIRONMENT + ENVIRONMENT GZ_GUI_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} ) diff --git a/src/plugins/topic_echo/TopicEcho_TEST.cc b/src/plugins/topic_echo/TopicEcho_TEST.cc index edb746589..e8d934a14 100644 --- a/src/plugins/topic_echo/TopicEcho_TEST.cc +++ b/src/plugins/topic_echo/TopicEcho_TEST.cc @@ -16,7 +16,7 @@ */ #include -#include +#include #include @@ -150,10 +150,8 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) pub.Publish(msg); } - QRegExp regExp13("*13"); - regExp13.setPatternSyntax(QRegExp::Wildcard); - QRegExp regExp14("*14"); - regExp14.setPatternSyntax(QRegExp::Wildcard); + auto regExp13 = QRegularExpression::wildcardToRegularExpression("*13"); + auto regExp14 = QRegularExpression::wildcardToRegularExpression("*14"); // Wait until all 15 messages are received // To avoid flakiness due to messages coming out of order, we check for both @@ -176,12 +174,11 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) // We can't guarantee the order of messages // We expect that out of the 10 messages last, at least 6 belong to the [5-14] // range - QRegExp regExp; - regExp.setPatternSyntax(QRegExp::Wildcard); unsigned int count = 0; for (auto i = 5; i < 15; ++i) { - regExp.setPattern("*" + QString::number(i)); + auto regExp = + QRegularExpression::wildcardToRegularExpression("*" + QString::number(i)); if (msgStringList->stringList().filter(regExp).count() > 0) ++count; } From 8eba03e701720e36f4309f482a7674d5a584f865 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 22:42:10 +0000 Subject: [PATCH 16/33] Fix test logic Signed-off-by: Michael Carroll --- CMakeLists.txt | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 011441b63..46013d036 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,33 +73,28 @@ set(GZ_RENDERING_VER ${gz-rendering9_VERSION_MAJOR}) gz_find_package(gz-msgs11 REQUIRED) set(GZ_MSGS_VER ${gz-msgs11_VERSION_MAJOR}) +# Find if command is available. This is used to enable tests. +# Note that CLI files are installed regardless of whether the dependency is +# available during build time +find_program(HAVE_GZ_TOOLS gz) +set(GZ_TOOLS_VER 2) #-------------------------------------- # Find QT -gz_find_package (Qt5 - VERSION 5.15 +set(QT_MAJOR_VERSION 5) +set(QT_MINOR_VERSION 15) +gz_find_package (Qt${QT_MAJOR_VERSION} + VERSION ${QT_MAJOR_VERSION}.${QT_MINOR_VERSION} COMPONENTS Core Quick QuickControls2 Widgets + Test REQUIRED - PKGCONFIG "Qt5Core Qt5Quick Qt5QuickControls2 Qt5Widgets" -) - + PKGCONFIG "Qt${QT_MAJOR_VERSION}Core Qt${QT_MAJOR_VERSION}Quick Qt${QT_MAJOR_VERSION}QuickControls2 Qt${QT_MAJOR_VERSION}Widgets") add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) -if (BUILD_TESTING) - # Find if command is available. This is used to enable tests. - # Note that CLI files are installed regardless of whether the dependency is - # available during build time - find_program(HAVE_GZ_TOOLS gz) - set(GZ_TOOLS_VER 2) - - find_package(Qt5 REQUIRED COMPONENTS Test) - -endif() - set(GZ_GUI_PLUGIN_RELATIVE_INSTALL_DIR ${GZ_LIB_INSTALL_DIR}/gz-${GZ_DESIGNATION}-${PROJECT_VERSION_MAJOR}/plugins ) From 22cb41adb444001f7b7cb4c6d8b39380b383525d Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 23:18:47 +0000 Subject: [PATCH 17/33] Qt5.15 compatible graphics updates Signed-off-by: Michael Carroll --- src/plugins/minimal_scene/MinimalScene.cc | 17 ++++---- src/plugins/minimal_scene/MinimalSceneRhi.hh | 7 +++ .../minimal_scene/MinimalSceneRhiOpenGL.cc | 43 ++++++++++++------- .../minimal_scene/MinimalSceneRhiVulkan.cc | 42 +++++++++++------- 4 files changed, 69 insertions(+), 40 deletions(-) diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index 4d0534dfb..4b37c42de 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -52,17 +53,10 @@ #include "gz/gui/Helpers.hh" #include "gz/gui/MainWindow.hh" -#define GZ_GUI_HAVE_VULKAN \ - QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && \ - QT_CONFIG(vulkan) && \ - GZ_RENDERING_HAVE_VULKAN - -#define GZ_GUI_HAVE_METAL __APPLE__ - #if GZ_GUI_HAVE_VULKAN # include # include -#endif // GZ_HAVE_VULKAN +#endif // GZ_GUI_HAVE_VULKAN Q_DECLARE_METATYPE(gz::gui::plugins::RenderSync*) @@ -1189,7 +1183,12 @@ QSGNode *RenderWindowItem::updatePaintNode(QSGNode *_node, if (this->dataPtr->graphicsAPI == rendering::GraphicsAPI::OPENGL) { - QOpenGLContext *current = this->window()->openglContext(); + auto *rif = this->window()->rendererInterface(); + Q_ASSERT(rif->graphicsApi() == QSGRendererInterface::OpenGL); + + auto *current = static_cast( + rif->getResource(this->window(), QSGRendererInterface::OpenGLContextResource)); + // Some GL implementations require that the currently bound context is // made non-current before we set up sharing, so we doneCurrent here // and makeCurrent down below while setting up our own context. diff --git a/src/plugins/minimal_scene/MinimalSceneRhi.hh b/src/plugins/minimal_scene/MinimalSceneRhi.hh index ff79a3dc9..978b8241f 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhi.hh +++ b/src/plugins/minimal_scene/MinimalSceneRhi.hh @@ -26,6 +26,13 @@ #include #include +#define GZ_GUI_HAVE_VULKAN \ + QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && \ + QT_CONFIG(vulkan) && \ + GZ_RENDERING_HAVE_VULKAN + +#define GZ_GUI_HAVE_METAL __APPLE__ + namespace gz::gui::plugins { /// \brief Render interface class to handle OpenGL / Metal compatibility diff --git a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc index 5e2ab1f24..fcb7ead2c 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc +++ b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc @@ -16,6 +16,7 @@ */ #include "MinimalSceneRhiOpenGL.hh" +#include #include "EngineToQtInterface.hh" #include "MinimalScene.hh" @@ -59,6 +60,27 @@ namespace gz::gui::plugins public: QMutex mutex; public: QSGTexture *texture = nullptr; public: QQuickWindow *window = nullptr; + + public: void CreateTexture(GLuint *_id, QSize _size) { + delete this->texture; + this->texture = nullptr; + + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + this->texture = QNativeInterface::QSGOpenGLTexture::fromNative( + *_id, + this->window, + _size); +#else + this->texture = + this->window->createTextureFromNativeObject( + QQuickWindow::NativeObjectTexture, + static_cast(_id), + 0, + _size); +#endif + } + }; ///////////////////////////////////////////////// @@ -206,12 +228,8 @@ TextureNodeRhiOpenGL::TextureNodeRhiOpenGL(QQuickWindow *_window) this->dataPtr->window = _window; // Our texture node must have a texture, so use the default 0 texture. - this->dataPtr->texture = - this->dataPtr->window->createTextureFromNativeObject( - QQuickWindow::NativeObjectTexture, - static_cast(&this->dataPtr->textureId), - 0, - QSize(1, 1)); + this->dataPtr->CreateTexture( + &this->dataPtr->textureId, QSize(1, 1)); } ///////////////////////////////////////////////// @@ -246,17 +264,10 @@ void TextureNodeRhiOpenGL::PrepareNode() this->dataPtr->textureId = 0; this->dataPtr->mutex.unlock(); - if (this->dataPtr->newTextureId) + if (this->dataPtr->newTextureId != 0) { - delete this->dataPtr->texture; - this->dataPtr->texture = nullptr; - - this->dataPtr->texture = - this->dataPtr->window->createTextureFromNativeObject( - QQuickWindow::NativeObjectTexture, - static_cast(&this->dataPtr->newTextureId), - 0, - this->dataPtr->newSize); + this->dataPtr->CreateTexture( + &this->dataPtr->newTextureId, this->dataPtr->newSize); } } } // namespace gz::gui::plugins diff --git a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc b/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc index 9352a7a56..6670eef33 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc +++ b/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc @@ -17,7 +17,7 @@ #include "MinimalSceneRhiVulkan.hh" -#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 2) && QT_CONFIG(vulkan) +#if GZ_GUI_HAVE_VULKAN #include "EngineToQtInterface.hh" #include "MinimalScene.hh" @@ -60,8 +60,29 @@ class TextureNodeRhiVulkanPrivate public: QMutex mutex; public: QSGTexture *texture = nullptr; public: QQuickWindow *window = nullptr; + + public: void CreateTexture(VkImage *_id, QSize _size) { + delete this->texture; + this->texture = nullptr; + + +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) + this->texture = QNativeInterface::QSGVulkanTexture::fromNative( + *_id, + VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, + this->window, + _size); +#else + this->texture = this->window->createTextureFromNativeObject( + QQuickWindow::NativeObjectTexture, + static_cast(_id), // + VK_IMAGE_LAYOUT_READ_ONLY_OPTIMAL, + _size); +#endif + } }; + ///////////////////////////////////////////////// GzCameraTextureRhiVulkan::~GzCameraTextureRhiVulkan() = default; @@ -182,10 +203,8 @@ TextureNodeRhiVulkan::TextureNodeRhiVulkan(QQuickWindow *_window, _camera->RenderTextureMetalId(&this->dataPtr->textureId); this->dataPtr->lastCamera = _camera; - this->dataPtr->texture = this->dataPtr->window->createTextureFromNativeObject( - QQuickWindow::NativeObjectTexture, - static_cast(&this->dataPtr->textureId), // - 0, // + this->dataPtr->CreateTexture( + &this->dataPtr->textureId, QSize(static_cast(_camera->ImageWidth()), static_cast(_camera->ImageHeight()))); } @@ -229,16 +248,9 @@ void TextureNodeRhiVulkan::PrepareNode() if (this->dataPtr->newTextureId != nullptr) { - delete this->dataPtr->texture; - this->dataPtr->texture = nullptr; - - this->dataPtr->texture = - this->dataPtr->window->createTextureFromNativeObject( - QQuickWindow::NativeObjectTexture, - static_cast(&this->dataPtr->newTextureId), - VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, - this->dataPtr->newSize); + this->dataPtr->CreateTexture( + &this->dataPtr->newTextureId, this->dataPtr->newSize); } } } // namespace gz::gui::plugins -#endif // HAVE_QT_VULKAN +#endif // GZ_GUI_HAVE_VULKAN From 4c7d46d6e72779f6130859c07388e538cac2f165 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 23:20:24 +0000 Subject: [PATCH 18/33] Fix extra header Signed-off-by: Michael Carroll --- src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc index fcb7ead2c..732259907 100644 --- a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc +++ b/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc @@ -16,7 +16,6 @@ */ #include "MinimalSceneRhiOpenGL.hh" -#include #include "EngineToQtInterface.hh" #include "MinimalScene.hh" From 75848291e70cf0edad4c49fb3fab7e1683724d5a Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 13 Nov 2023 23:23:44 +0000 Subject: [PATCH 19/33] Lint Signed-off-by: Michael Carroll --- src/plugins/minimal_scene/MinimalScene.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index 4b37c42de..e4c9ec820 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -1187,7 +1187,8 @@ QSGNode *RenderWindowItem::updatePaintNode(QSGNode *_node, Q_ASSERT(rif->graphicsApi() == QSGRendererInterface::OpenGL); auto *current = static_cast( - rif->getResource(this->window(), QSGRendererInterface::OpenGLContextResource)); + rif->getResource(this->window(), + QSGRendererInterface::OpenGLContextResource)); // Some GL implementations require that the currently bound context is // made non-current before we set up sharing, so we doneCurrent here From 5ee29c6a1c77dd95b6e4cab7fc5b694b26913797 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 27 Nov 2023 14:20:57 +0000 Subject: [PATCH 20/33] Fix preprocessor Signed-off-by: Michael Carroll --- src/plugins/minimal_scene/MinimalScene.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/minimal_scene/MinimalScene.cc index e4c9ec820..613fc6878 100644 --- a/src/plugins/minimal_scene/MinimalScene.cc +++ b/src/plugins/minimal_scene/MinimalScene.cc @@ -216,11 +216,11 @@ class gz::gui::plugins::RenderWindowItem::Implementation /// \brief Graphics API. The default is platform specific. public: gz::rendering::GraphicsAPI graphicsAPI = -#if GZ_GUI_HAVE_METAL_ +#if GZ_GUI_HAVE_METAL rendering::GraphicsAPI::METAL; #else rendering::GraphicsAPI::OPENGL; -#endif +#endif // GZ_GUI_HAVE_METAL /// \brief Render thread public: RenderThread *renderThread = nullptr; From b255e56618404fc6fd4167a909b6b0a9944341ac Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 27 Nov 2023 14:22:02 +0000 Subject: [PATCH 21/33] Fix indent Signed-off-by: Michael Carroll --- src/plugins/minimal_scene/MinimalScene.hh | 140 +++++++++++----------- 1 file changed, 70 insertions(+), 70 deletions(-) diff --git a/src/plugins/minimal_scene/MinimalScene.hh b/src/plugins/minimal_scene/MinimalScene.hh index 5f8bd433d..5666703eb 100644 --- a/src/plugins/minimal_scene/MinimalScene.hh +++ b/src/plugins/minimal_scene/MinimalScene.hh @@ -380,108 +380,108 @@ namespace gz::gui::plugins /// \param[in] _view_controller The camera view controller type to set public: void SetCameraViewController(const std::string &_view_controller); - /// \brief Slot called when thread is ready to be started - public Q_SLOTS: void Ready(); + /// \brief Slot called when thread is ready to be started + public Q_SLOTS: void Ready(); - /// \brief Handle key press event for snapping - /// \param[in] _e The key event to process. - public: void HandleKeyPress(const common::KeyEvent &_e); + /// \brief Handle key press event for snapping + /// \param[in] _e The key event to process. + public: void HandleKeyPress(const common::KeyEvent &_e); - /// \brief Handle key release event for snapping - /// \param[in] _e The key event to process. - public: void HandleKeyRelease(const common::KeyEvent &_e); + /// \brief Handle key release event for snapping + /// \param[in] _e The key event to process. + public: void HandleKeyRelease(const common::KeyEvent &_e); - /// \brief Set a callback to be called in case there are errors. - /// \param[in] _cb Error callback - public: void SetErrorCb(std::function _cb); + /// \brief Set a callback to be called in case there are errors. + /// \param[in] _cb Error callback + public: void SetErrorCb(std::function _cb); - /// \brief Stop rendering and shutdown resources. - public: void StopRendering(); + /// \brief Stop rendering and shutdown resources. + public: void StopRendering(); - // Documentation inherited - protected: virtual void mousePressEvent(QMouseEvent *_e) override; + // Documentation inherited + protected: virtual void mousePressEvent(QMouseEvent *_e) override; - // Documentation inherited - protected: virtual void mouseReleaseEvent(QMouseEvent *_e) override; + // Documentation inherited + protected: virtual void mouseReleaseEvent(QMouseEvent *_e) override; - // Documentation inherited - protected: virtual void mouseMoveEvent(QMouseEvent *_e) override; + // Documentation inherited + protected: virtual void mouseMoveEvent(QMouseEvent *_e) override; - // Documentation inherited - protected: virtual void keyPressEvent(QKeyEvent *_e) override; + // Documentation inherited + protected: virtual void keyPressEvent(QKeyEvent *_e) override; - // Documentation inherited - protected: virtual void keyReleaseEvent(QKeyEvent *_e) override; + // Documentation inherited + protected: virtual void keyReleaseEvent(QKeyEvent *_e) override; - // Documentation inherited - protected: virtual void wheelEvent(QWheelEvent *_e) override; + // Documentation inherited + protected: virtual void wheelEvent(QWheelEvent *_e) override; - /// \brief Overrides the paint event to render the render engine - /// camera view - /// \param[in] _oldNode The node passed in previous updatePaintNode - /// function. It represents the visual representation of the item. - /// \param[in] _data The node transformation data. - /// \return Updated node. - private: QSGNode *updatePaintNode(QSGNode *_oldNode, - QQuickItem::UpdatePaintNodeData *_data) override; + /// \brief Overrides the paint event to render the render engine + /// camera view + /// \param[in] _oldNode The node passed in previous updatePaintNode + /// function. It represents the visual representation of the item. + /// \param[in] _data The node transformation data. + /// \return Updated node. + private: QSGNode *updatePaintNode(QSGNode *_oldNode, + QQuickItem::UpdatePaintNodeData *_data) override; - /// \internal - /// \brief Pointer to private data. - GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) + /// \internal + /// \brief Pointer to private data. + GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr) }; /// \brief Texture node for displaying the render texture from gz-renderer class TextureNode : public QObject, public QSGSimpleTextureNode { - Q_OBJECT + Q_OBJECT - /// \brief Constructor - /// \param[in] _window Window to display the texture - /// \param[in] _renderSync RenderSync to safely - /// synchronize Qt (this) and worker thread - /// \param[in] _graphicsAPI The type of graphics API - /// \param[in] _camera Camera owning the Texture Handle - public: explicit TextureNode(QQuickWindow *_window, - RenderSync &_renderSync, - const rendering::GraphicsAPI &_graphicsAPI, - rendering::CameraPtr &_camera); + /// \brief Constructor + /// \param[in] _window Window to display the texture + /// \param[in] _renderSync RenderSync to safely + /// synchronize Qt (this) and worker thread + /// \param[in] _graphicsAPI The type of graphics API + /// \param[in] _camera Camera owning the Texture Handle + public: explicit TextureNode(QQuickWindow *_window, + RenderSync &_renderSync, + const rendering::GraphicsAPI &_graphicsAPI, + rendering::CameraPtr &_camera); - /// \brief Destructor - public: ~TextureNode() override; + /// \brief Destructor + public: ~TextureNode() override; - /// \brief This function gets called on the FBO rendering thread and will - /// store the texture id and size and schedule an update on the window. - /// \param[in] _texturePtr Pointer to a texture Id - /// \param[in] _size Texture size - // public slots: void NewTexture(uint _id, const QSize &_size); - public slots: void NewTexture(void* _texturePtr, const QSize &_size); + /// \brief This function gets called on the FBO rendering thread and will + /// store the texture id and size and schedule an update on the window. + /// \param[in] _texturePtr Pointer to a texture Id + /// \param[in] _size Texture size + // public slots: void NewTexture(uint _id, const QSize &_size); + public slots: void NewTexture(void* _texturePtr, const QSize &_size); - /// \brief Before the scene graph starts to render, we update to the - /// pending texture - public slots: void PrepareNode(); + /// \brief Before the scene graph starts to render, we update to the + /// pending texture + public slots: void PrepareNode(); - /// \param[in] _renderSync RenderSync to send to the worker thread - signals: void TextureInUse(gz::gui::plugins::RenderSync *_renderSync); + /// \param[in] _renderSync RenderSync to send to the worker thread + signals: void TextureInUse(gz::gui::plugins::RenderSync *_renderSync); - /// \brief Signal emitted when a new texture is ready to trigger window - /// update - signals: void PendingNewTexture(); + /// \brief Signal emitted when a new texture is ready to trigger window + /// update + signals: void PendingNewTexture(); - /// \brief Texture size - public: QSize size = QSize(0, 0); + /// \brief Texture size + public: QSize size = QSize(0, 0); - /// \brief Mutex to protect the texture variables - public: QMutex mutex; + /// \brief Mutex to protect the texture variables + public: QMutex mutex; - /// \brief See RenderSync - public: RenderSync &renderSync; + /// \brief See RenderSync + public: RenderSync &renderSync; /// \brief Qt quick window public: QQuickWindow *window = nullptr; /// \brief Pointer to render interface to handle OpenGL/Metal compatibility private: std::unique_ptr rhi; - }; +}; } // namespace gz::gui::plugins #endif // GZ_GUI_PLUGINS_MINIMALSCENE_HH_ From dffd3a06886b72043b4e79c8f33e549f15260669 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 27 Nov 2023 20:38:24 +0000 Subject: [PATCH 22/33] Fix regex use Signed-off-by: Michael Carroll --- src/plugins/topic_echo/TopicEcho_TEST.cc | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/plugins/topic_echo/TopicEcho_TEST.cc b/src/plugins/topic_echo/TopicEcho_TEST.cc index e8d934a14..50ec24b9a 100644 --- a/src/plugins/topic_echo/TopicEcho_TEST.cc +++ b/src/plugins/topic_echo/TopicEcho_TEST.cc @@ -16,7 +16,6 @@ */ #include -#include #include @@ -130,7 +129,7 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) int sleep = 0; int maxSleep = 30; - while(msgStringList->rowCount() == 0 && sleep < maxSleep) + while (msgStringList->rowCount() == 0 && sleep < maxSleep) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); QCoreApplication::processEvents(); @@ -150,16 +149,13 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) pub.Publish(msg); } - auto regExp13 = QRegularExpression::wildcardToRegularExpression("*13"); - auto regExp14 = QRegularExpression::wildcardToRegularExpression("*14"); - // Wait until all 15 messages are received // To avoid flakiness due to messages coming out of order, we check for both // 13 and 14. There's a chance a lower number comes afterwards, but that's // just bad luck. sleep = 0; - while (msgStringList->stringList().filter(regExp13).count() == 0 - && msgStringList->stringList().filter(regExp14).count() == 0 + while (msgStringList->stringList().filter("13").count() == 0 + && msgStringList->stringList().filter("14").count() == 0 && sleep < maxSleep) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); @@ -177,9 +173,7 @@ TEST(TopicEchoTest, GZ_UTILS_TEST_DISABLED_ON_WIN32(Echo)) unsigned int count = 0; for (auto i = 5; i < 15; ++i) { - auto regExp = - QRegularExpression::wildcardToRegularExpression("*" + QString::number(i)); - if (msgStringList->stringList().filter(regExp).count() > 0) + if (msgStringList->stringList().filter(QString::number(i)).count() > 0) ++count; } EXPECT_GE(count, 6u); From d6516d9ee32c40d0534343fda061315ccad41828 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 28 Nov 2023 15:37:51 +0000 Subject: [PATCH 23/33] Fixing QML files --- CMakeLists.txt | 5 + include/gz/gui/CMakeLists.txt | 85 +++++++++++++--- include/gz/gui/Plugin.hh | 2 +- include/gz/gui/qml/Chart.qml | 11 +-- include/gz/gui/qml/GzCard.qml | 12 +-- include/gz/gui/qml/GzCardSettings.qml | 2 +- include/gz/gui/qml/GzColor.qml | 10 +- include/gz/gui/qml/GzHelpers.qml | 2 +- include/gz/gui/qml/GzPlotIcon.qml | 4 +- include/gz/gui/qml/GzPose.qml | 9 +- include/gz/gui/qml/GzRulers.qml | 4 +- include/gz/gui/qml/GzSnackBar.qml | 18 +++- include/gz/gui/qml/GzSortFilterModel.qml | 5 +- include/gz/gui/qml/GzSplit.qml | 8 +- include/gz/gui/qml/GzVector3.qml | 5 +- include/gz/gui/qml/Main.qml | 19 ++-- include/gz/gui/qml/PlottingInterface.qml | 14 +-- include/gz/gui/qml/PluginMenu.qml | 12 +-- include/gz/gui/qml/SideDrawer.qml | 6 +- include/gz/gui/qml/StandaloneDialog.qml | 4 +- include/gz/gui/qml/StyleDialog.qml | 11 ++- src/Application.cc | 6 +- src/Application_TEST.cc | 100 +++++++++++-------- src/Dialog.cc | 2 + src/MainWindow.cc | 4 +- src/PlottingInterface.cc | 2 + src/Plugin.cc | 49 +++++----- src/plugins/CMakeLists.txt | 107 +++++++++++++++------ src/plugins/camera_fps/CMakeLists.txt | 26 ++--- src/plugins/camera_tracking/CMakeLists.txt | 27 +++--- src/plugins/publisher/CMakeLists.txt | 5 +- src/plugins/publisher/Publisher.cc | 7 +- src/plugins/publisher/Publisher.hh | 3 +- src/plugins/publisher/Publisher.qml | 16 +-- 34 files changed, 373 insertions(+), 229 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 655ce5d46..34394c397 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -93,7 +93,12 @@ gz_find_package (Qt${QT_MAJOR_VERSION} Test REQUIRED PKGCONFIG "Qt${QT_MAJOR_VERSION}Core Qt${QT_MAJOR_VERSION}Quick Qt${QT_MAJOR_VERSION}QuickControls2 Qt${QT_MAJOR_VERSION}Widgets") + add_compile_definitions(QT_DISABLE_DEPRECATED_UP_TO=0x050F00) +set(CMAKE_AUTOMOC TRUE) +set(CMAKE_AUTOUIC TRUE) +set(CMAKE_AUTORCC TRUE) +cmake_policy(SET CMP0100 NEW) if(POLICY CMP0100) cmake_policy(SET CMP0100 NEW) diff --git a/include/gz/gui/CMakeLists.txt b/include/gz/gui/CMakeLists.txt index 5e15317d6..34a42c02b 100644 --- a/include/gz/gui/CMakeLists.txt +++ b/include/gz/gui/CMakeLists.txt @@ -1,9 +1,3 @@ -if(POLICY CMP0100) - cmake_policy(SET CMP0100 NEW) -endif() - -set (CMAKE_AUTOMOC ON) - set (qt_headers Application.hh Dialog.hh @@ -20,19 +14,80 @@ set (headers gz.hh qt.h SearchModel.hh - System.hh ) -set (resources resources.qrc) - -qt_wrap_cpp(headers_MOC ${qt_headers}) -qt_add_resources(resources_RCC ${resources}) +set(qml_files + qml/Chart.qml + qml/GzCard.qml + qml/GzCardSettings.qml + qml/GzColor.qml + qml/GzHelpers.qml + qml/GzPlotIcon.qml + qml/GzPose.qml + qml/GzRulers.qml + qml/GzSnackBar.qml + qml/GzSortFilterModel.qml + qml/GzSpinBox.qml + qml/GzSplit.qml + qml/GzVector3.qml + qml/Main.qml + qml/PlottingInterface.qml + qml/PluginMenu.qml + qml/SideDrawer.qml + qml/StandaloneDialog.qml + qml/StyleDialog.qml +) -gz_create_core_library(SOURCES - ${sources} - ${headers_MOC} - ${resources_RCC} +set(resources + qml/images/drawer.png + qml/images/export_icon.png + qml/images/gazebo_logo.png + qml/images/menu.png + qml/images/plottable_icon.svg + qml/images/search.svg ) + +if (QT_MAJOR_VERSION EQUAL 6) + qt_add_qml_module(${PROJECT_LIBRARY_TARGET_NAME} + URI gz.gui + VERSION 9.0.0 + SOURCES ${sources} ${qt_headers} ${headers} + QML_FILES ${qml_files} + RESOURCES ${resources} + ) + + include(GenerateExportHeader) + generate_export_header(${PROJECT_LIBRARY_TARGET_NAME} + BASE_NAME GZ_GUI + EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/include/gz/gui/detail/Export.hh + EXPORT_MACRO_NAME DETAIL_GZ_GUI_VISIBLE + NO_EXPORT_MACRO_NAME DETAIL_GZ_GUI_HIDDEN + DEPRECATED_MACRO_NAME GZ_DEPRECATED_ALL_VERSIONS) + + set(include_dir "gz/gui") + set(export_base "GZ_GUI") + configure_file( + "${GZ_CMAKE_DIR}/Export.hh.in" + "${PROJECT_BINARY_DIR}/include/gz/gui/Export.hh") + + target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} + PUBLIC + $ + $ + ) + +else() + set (resources resources.qrc) + qt_wrap_cpp(headers_MOC ${qt_headers}) + qt_add_resources(resources_RCC ${resources}) + + gz_create_core_library(SOURCES + ${sources} + ${headers_MOC} + ${resources_RCC} + ) +endif() + gz_add_get_install_prefix_impl(GET_INSTALL_PREFIX_FUNCTION gz::gui::getInstallPrefix GET_INSTALL_PREFIX_HEADER gz/gui/InstallationDirectories.hh OVERRIDE_INSTALL_PREFIX_ENV_VARIABLE GZ_GUI_INSTALL_PREFIX) diff --git a/include/gz/gui/Plugin.hh b/include/gz/gui/Plugin.hh index f4066ea8b..34c99ec31 100644 --- a/include/gz/gui/Plugin.hh +++ b/include/gz/gui/Plugin.hh @@ -49,7 +49,7 @@ namespace gz::gui Q_OBJECT /// \brief Constructor - public: Plugin(); + public: Plugin(QObject *_parent=nullptr); /// \brief Destructor public: virtual ~Plugin(); diff --git a/include/gz/gui/qml/Chart.qml b/include/gz/gui/qml/Chart.qml index cd3a259d7..a0506e9ff 100644 --- a/include/gz/gui/qml/Chart.qml +++ b/include/gz/gui/qml/Chart.qml @@ -14,12 +14,11 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtCharts 2.2 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtCharts +import QtQuick.Controls +import QtQuick.Controls.Style +import QtQuick.Layouts Rectangle { id: main diff --git a/include/gz/gui/qml/GzCard.qml b/include/gz/gui/qml/GzCard.qml index 468af06bf..53f8a0f13 100644 --- a/include/gz/gui/qml/GzCard.qml +++ b/include/gz/gui/qml/GzCard.qml @@ -14,12 +14,12 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 -import QtQuick.Window 2.2 -import "qrc:/qml" +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts +import QtQuick.Window +import "qrc:/gz/gui/qml" // TODO: don't use "parent" Pane { diff --git a/include/gz/gui/qml/GzCardSettings.qml b/include/gz/gui/qml/GzCardSettings.qml index 32ec8e67a..c31f534ec 100644 --- a/include/gz/gui/qml/GzCardSettings.qml +++ b/include/gz/gui/qml/GzCardSettings.qml @@ -19,7 +19,7 @@ import QtQuick.Controls import QtQuick.Layouts import QtQuick.Window import QtQuick.Dialogs -import "qrc:/qml" +import "qrc:/gz/gui/qml" Dialog { id: settingsDialog diff --git a/include/gz/gui/qml/GzColor.qml b/include/gz/gui/qml/GzColor.qml index a04162d22..c02e404f7 100644 --- a/include/gz/gui/qml/GzColor.qml +++ b/include/gz/gui/qml/GzColor.qml @@ -14,11 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Dialogs 1.0 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.1 +import QtQuick +import QtQuick.Controls +import QtQuick.Dialogs +import QtQuick.Layouts // RGBA using range 0 - 1.0 @@ -70,4 +69,3 @@ Item { } } } - diff --git a/include/gz/gui/qml/GzHelpers.qml b/include/gz/gui/qml/GzHelpers.qml index 9938872f8..394180bbb 100644 --- a/include/gz/gui/qml/GzHelpers.qml +++ b/include/gz/gui/qml/GzHelpers.qml @@ -14,7 +14,7 @@ * limitations under the License. * */ -import QtQuick 2.9 +import QtQuick Item { /** diff --git a/include/gz/gui/qml/GzPlotIcon.qml b/include/gz/gui/qml/GzPlotIcon.qml index 3167d20ae..72d36b00a 100644 --- a/include/gz/gui/qml/GzPlotIcon.qml +++ b/include/gz/gui/qml/GzPlotIcon.qml @@ -14,7 +14,7 @@ * limitations under the License. * */ -import QtQuick 2.9 +import QtQuick /** * Item for a draggable plotting icon @@ -32,7 +32,7 @@ import QtQuick 2.9 * sourceComponent: gzploticon * } * Component.onCompleted: { - * plotLoader.item.gzMimeData = {"text/plain" : "Component," + entityFromCpp + "," + typeIdFromCpp + ",x," + typeNameFromCpp} + * plotLoader.item.gzMimeData = {"text/plain" : "Component," + entityFromCpp + "," + typeIdFromCpp + ",x," + typeNameFromCpp} * } * } * } diff --git a/include/gz/gui/qml/GzPose.qml b/include/gz/gui/qml/GzPose.qml index 63112fdec..d883e107d 100644 --- a/include/gz/gui/qml/GzPose.qml +++ b/include/gz/gui/qml/GzPose.qml @@ -14,11 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Styles 1.4 +import QtQuick +import QtQuick.Control +import QtQuick.Layout +import QtQuick.Controls.Styles /** * Item displaying 3D pose information. diff --git a/include/gz/gui/qml/GzRulers.qml b/include/gz/gui/qml/GzRulers.qml index 1595389cd..2b129f0bb 100644 --- a/include/gz/gui/qml/GzRulers.qml +++ b/include/gz/gui/qml/GzRulers.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 +import QtQuick +import QtQuick.Controls /** * Rulers which can be dragged to resize a target. diff --git a/include/gz/gui/qml/GzSnackBar.qml b/include/gz/gui/qml/GzSnackBar.qml index fbdfeb6e3..de5f75863 100644 --- a/include/gz/gui/qml/GzSnackBar.qml +++ b/include/gz/gui/qml/GzSnackBar.qml @@ -15,12 +15,14 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material import QtQuick.Dialogs -import QtQuick.Layouts 1.3 -import QtQuick.Window 2.2 +import QtQuick.Layouts +import QtQuick.Window + +import Qt5Compat.GraphicalEffects as Effects /* To use the snackbar you need to call the methods in the MainWindow class: @@ -69,6 +71,12 @@ Popup { background: Rectangle { color: Material.background layer.enabled: true + layer.effect: Effects.DropShadow { + color: "#aa000000" + samples: 9 + spread: 0 + radius: 8.0 + } } // this function is called when notify() or notifyWithDuration() are called diff --git a/include/gz/gui/qml/GzSortFilterModel.qml b/include/gz/gui/qml/GzSortFilterModel.qml index f127d27ab..e60f6f094 100644 --- a/include/gz/gui/qml/GzSortFilterModel.qml +++ b/include/gz/gui/qml/GzSortFilterModel.qml @@ -18,8 +18,8 @@ // Borrowed from // https://martin.rpdev.net/2019/01/15/using-delegatemodel-in-qml-for-sorting-and-filtering.html -import QtQuick 2.9 -import QtQml.Models 2.3 +import QtQuick +import QtQml.Models DelegateModel { /** @@ -83,4 +83,3 @@ DelegateModel { filterOnGroup: "visible" } - diff --git a/include/gz/gui/qml/GzSplit.qml b/include/gz/gui/qml/GzSplit.qml index 72c18d9a6..3202daae3 100644 --- a/include/gz/gui/qml/GzSplit.qml +++ b/include/gz/gui/qml/GzSplit.qml @@ -14,10 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 +import QtQuick import QtQuick.Controls -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick.Controls.Material +import QtQuick.Layouts /** * Main split view, which provides functions to add and remove child items @@ -92,7 +92,7 @@ SplitView { // First section goes in the top level SplitView, which is Qt.Horizontal // 2 for helpers and startLabel - if (background.__items.length <= 2) + if (background.count <= 2) { itemName = _addNewItem(background); } diff --git a/include/gz/gui/qml/GzVector3.qml b/include/gz/gui/qml/GzVector3.qml index 94752f4c5..e0c5b9e40 100644 --- a/include/gz/gui/qml/GzVector3.qml +++ b/include/gz/gui/qml/GzVector3.qml @@ -14,9 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Layouts /** * Item displaying a 3D vector diff --git a/include/gz/gui/qml/Main.qml b/include/gz/gui/qml/Main.qml index fcdadd411..651335971 100644 --- a/include/gz/gui/qml/Main.qml +++ b/include/gz/gui/qml/Main.qml @@ -14,13 +14,14 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 +import QtCore +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material import QtQuick.Dialogs -import QtQuick.Layouts 1.3 -import ExitAction 1.0 -import "qrc:/qml" +import QtQuick.Layouts +import ExitAction +import "qrc:/gz/gui/qml/" ApplicationWindow { @@ -85,7 +86,7 @@ ApplicationWindow } // Handler for window closing - onClosing: { + onClosing: (close) => { close.accepted = !showDialogOnExit if(showDialogOnExit){ if (closingFromDialog) { @@ -295,6 +296,8 @@ ApplicationWindow FileDialog { id: loadFileDialog title: "Load configuration" + fileMode: FileDialog.OpenFile + currentFolder: StandardPaths.writableLocation(StandardPaths.HomeLocation) nameFilters: [ "Config files (*.config)" ] onAccepted: { MainWindow.OnLoadConfig(fileUrl) @@ -307,6 +310,8 @@ ApplicationWindow FileDialog { id: saveFileDialog title: "Save configuration" + fileMode: FileDialog.SaveFile + currentFolder: StandardPaths.writableLocation(StandardPaths.HomeLocation) nameFilters: [ "Config files (*.config)" ] onAccepted: { var selected = fileUrl.toString(); diff --git a/include/gz/gui/qml/PlottingInterface.qml b/include/gz/gui/qml/PlottingInterface.qml index 168d3a862..dd97bea43 100644 --- a/include/gz/gui/qml/PlottingInterface.qml +++ b/include/gz/gui/qml/PlottingInterface.qml @@ -14,13 +14,13 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtCharts 2.2 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 -import Qt.labs.platform 1.0 +import QtQuick +import QtCharts +import QtQuick.Controls +import QtQuick.Controls.Styles +import QtQuick.Controls.Material +import QtQuick.Layouts +import Qt.labs.platform import "qrc:/qml" Rectangle diff --git a/include/gz/gui/qml/PluginMenu.qml b/include/gz/gui/qml/PluginMenu.qml index 890a7e7d4..7f393b3a0 100644 --- a/include/gz/gui/qml/PluginMenu.qml +++ b/include/gz/gui/qml/PluginMenu.qml @@ -14,11 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.2 -import QtQuick.Controls.Material.impl 2.2 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts Popup { id: pluginMenu @@ -87,7 +86,7 @@ Popup { } Keys.onUpPressed: { pluginMenuListView.decrementCurrentIndex(); - } + } } } } @@ -138,4 +137,3 @@ Popup { } } } - diff --git a/include/gz/gui/qml/SideDrawer.qml b/include/gz/gui/qml/SideDrawer.qml index 3b6c63c9f..66eb8653e 100644 --- a/include/gz/gui/qml/SideDrawer.qml +++ b/include/gz/gui/qml/SideDrawer.qml @@ -14,9 +14,9 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material /** * Side menu diff --git a/include/gz/gui/qml/StandaloneDialog.qml b/include/gz/gui/qml/StandaloneDialog.qml index a55864499..a9cb0ed9f 100644 --- a/include/gz/gui/qml/StandaloneDialog.qml +++ b/include/gz/gui/qml/StandaloneDialog.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.3 -import QtQuick.Controls 1.2 +import QtQuick +import QtQuick.Controls ApplicationWindow { id: dialog diff --git a/include/gz/gui/qml/StyleDialog.qml b/include/gz/gui/qml/StyleDialog.qml index 28b5e25bf..2c2447a64 100644 --- a/include/gz/gui/qml/StyleDialog.qml +++ b/include/gz/gui/qml/StyleDialog.qml @@ -14,10 +14,11 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material import QtQuick.Dialogs +import Qt.labs.platform as Platform /** * Style dialog @@ -315,7 +316,7 @@ Dialog { text: "Primary" } - ColorDialog { + Platform.ColorDialog { id: materialPrimaryDialog title: "Primary color" // options: ColorDialog.NoButtons @@ -352,7 +353,7 @@ Dialog { text: "Accent" } - ColorDialog { + Platform.ColorDialog { id: materialAccentDialog title: "Accent color" // options: ColorDialog.NoButtons diff --git a/src/Application.cc b/src/Application.cc index 8d1c0cf3c..50fdaa97a 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -81,7 +81,7 @@ class Application::Implementation const QMessageLogContext &_context, const QString &_msg); }; -enum class GZ_COMMON_HIDDEN AvailableAPIs +enum class GZ_COMMON_HIDDEN AvailableAPIs { OpenGL, Vulkan, @@ -889,6 +889,8 @@ void Application::Implementation::MessageHandler(QtMsgType _type, const QMessageLogContext &_context, const QString &_msg) { std::string msg = "[QT] " + _msg.toStdString(); + if (_context.file) + msg += std::string("[") + _context.file + ":" + std::to_string(_context.line) + "]"; if (_context.function) msg += std::string("(") + _context.function + ")"; @@ -914,3 +916,5 @@ void Application::Implementation::MessageHandler(QtMsgType _type, } } } // namespace gz::gui + +#include "moc_Application.cpp" diff --git a/src/Application_TEST.cc b/src/Application_TEST.cc index f23ce8ab0..cd9f97f51 100644 --- a/src/Application_TEST.cc +++ b/src/Application_TEST.cc @@ -246,73 +246,91 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadDefaultConfig)) ////////////////////////////////////////////////// TEST(ApplicationTest, - GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindow)) + GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindowSimple)) { common::Console::SetVerbosity(4); - ASSERT_EQ(nullptr, qGuiApp); // No plugins - { - Application app(g_argc, g_argv); + Application app(g_argc, g_argv); - auto wins = app.allWindows(); - ASSERT_EQ(wins.size(), 1); + auto wins = app.allWindows(); + ASSERT_EQ(wins.size(), 1); - // Close window after some time - QTimer::singleShot(300, wins[0], SLOT(close())); + // Close window after some time + QTimer::singleShot(300, wins[0], [&wins](){ + wins[0]->close(); + }); - // Show window - app.exec(); - } + // Show window + app.exec(); +} - // Load plugin - { - Application app(g_argc, g_argv); +////////////////////////////////////////////////// +TEST(ApplicationTest, + GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindowPlugin)) +{ + common::Console::SetVerbosity(4); + ASSERT_EQ(nullptr, qGuiApp); - EXPECT_TRUE(app.LoadPlugin("Publisher")); + Application app(g_argc, g_argv); - auto win = App()->findChild(); - ASSERT_NE(nullptr, win); + EXPECT_TRUE(app.LoadPlugin("Publisher")); - // Check plugin count - auto plugins = win->findChildren(); - EXPECT_EQ(1, plugins.count()); + auto *win = App()->findChild(); + ASSERT_NE(nullptr, win); - // Close window after some time - QTimer::singleShot(300, win->QuickWindow(), SLOT(close())); + // Check plugin count + auto plugins = win->findChildren(); + EXPECT_EQ(1, plugins.count()); - // Show window - app.exec(); - } + QObject::connect(&app, &QGuiApplication::applicationStateChanged, + [&win](auto state){ + std::cout << "State Changed, starting timer" << std::endl; + QTimer::singleShot(100, [&win](){ + win->QuickWindow()->close(); + }); + }); + + // Show window + app.exec(); + app.quit(); +} + +////////////////////////////////////////////////// +TEST(ApplicationTest, + GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindowConfig)) +{ + common::Console::SetVerbosity(4); + ASSERT_EQ(nullptr, qGuiApp); // Test config auto testBuildPath = std::string(PROJECT_BINARY_PATH) + "/lib/"; auto testSourcePath = std::string(PROJECT_SOURCE_PATH) + "/test/"; // Load config - { - Application app(g_argc, g_argv); + Application app(g_argc, g_argv); - // Add test plugin to path (referenced in config) - app.AddPluginPath(testBuildPath); + // Add test plugin to path (referenced in config) + app.AddPluginPath(testBuildPath); - // Load test config file - EXPECT_TRUE(app.LoadConfig(testSourcePath + "config/test.config")); + // Load test config file + EXPECT_TRUE(app.LoadConfig(testSourcePath + "config/test.config")); - auto win = App()->findChild(); - ASSERT_NE(nullptr, win); + auto *win = App()->findChild(); + ASSERT_NE(nullptr, win); - // Check plugin count - auto plugins = win->findChildren(); - EXPECT_EQ(1, plugins.count()); + // Check plugin count + auto plugins = win->findChildren(); + EXPECT_EQ(1, plugins.count()); - // Close window after some time - QTimer::singleShot(300, win->QuickWindow(), SLOT(close())); + // Close window after some time + QTimer::singleShot(1000, win, [&win](){ + win->QuickWindow()->close(); + }); - // Show window - app.exec(); - } + // Show window + app.exec(); } ////////////////////////////////////////////////// diff --git a/src/Dialog.cc b/src/Dialog.cc index 7701c2cfd..06e346c12 100644 --- a/src/Dialog.cc +++ b/src/Dialog.cc @@ -169,3 +169,5 @@ std::string Dialog::ReadConfigAttribute(const std::string &_path, return std::string(); } } // namespace gz::gui + +#include "moc_Dialog.cpp" diff --git a/src/MainWindow.cc b/src/MainWindow.cc index bff0186a9..043de7c23 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -101,7 +101,7 @@ MainWindow::MainWindow() App()->Engine()->rootContext()->setContextProperty("MainWindow", this); // Load QML and keep pointer to generated QQuickWindow - std::string qmlFile("qrc:qml/Main.qml"); + std::string qmlFile("qrc:gz/gui/qml/Main.qml"); App()->Engine()->load(QUrl(QString::fromStdString(qmlFile))); this->dataPtr->quickWindow = qobject_cast( @@ -1023,3 +1023,5 @@ void MainWindow::SetServerControlService(const std::string &_service) this->dataPtr->controlService = _service; } } // namespace gz::gui + +#include "moc_MainWindow.cpp" diff --git a/src/PlottingInterface.cc b/src/PlottingInterface.cc index b44ffcb10..e99e97238 100644 --- a/src/PlottingInterface.cc +++ b/src/PlottingInterface.cc @@ -668,3 +668,5 @@ bool PlottingInterface::exportCSV(QString _path, int _chart, return true; } } // namespace gz::gui + +#include "moc_PlottingInterface.cpp" diff --git a/src/Plugin.cc b/src/Plugin.cc index ebc6ad126..4bd83a959 100644 --- a/src/Plugin.cc +++ b/src/Plugin.cc @@ -87,7 +87,9 @@ class Plugin::Implementation }; ///////////////////////////////////////////////// -Plugin::Plugin() : dataPtr(gz::utils::MakeUniqueImpl()) +Plugin::Plugin(QObject *_parent) : + QObject(_parent), + dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -121,27 +123,23 @@ void Plugin::Load(const tinyxml2::XMLElement *_pluginElem) } // Qml file - std::string filename = _pluginElem->Attribute("filename"); + auto filename = QString::fromStdString(_pluginElem->Attribute("filename")); - // This let's .qml use functions and properties - this->dataPtr->context = new QQmlContext(App()->Engine()->rootContext()); - this->dataPtr->context->setContextProperty(QString::fromStdString(filename), - this); // Instantiate plugin QML file into a component - std::string qmlFile(":/" + filename + "/" + filename + ".qml"); - if (!QFile(QString::fromStdString(qmlFile)).exists()) + auto qmlFile = ":/" + filename + "/" + filename + ".qml"; + if (!QFile(qmlFile).exists()) { - gzerr << "Can't find [" << qmlFile + gzerr << "Can't find [" << qmlFile.toStdString() << "]. Are you sure it was added to the .qrc file?" << std::endl; return; } - QQmlComponent component(App()->Engine(), QString::fromStdString(qmlFile)); + QQmlComponent component(App()->Engine(), qmlFile); if (component.isError()) { std::stringstream errors; - errors << "Failed to instantiate QML file [" << qmlFile << "]." + errors << "Failed to instantiate QML file [" << qmlFile.toStdString() << "]." << std::endl; // Qt considers range-based for loops over temporary objects // potentially dangerous, so explicitly create a container. @@ -155,18 +153,26 @@ void Plugin::Load(const tinyxml2::XMLElement *_pluginElem) } if (!component.isReady()) { - gzerr << "Component from QML file [" << qmlFile + gzerr << "Component from QML file [" << qmlFile.toStdString() << "] is not ready. Progress: " << component.progress() << " / 1.0" << std::endl; return; } + // This let's .qml use functions and properties + this->dataPtr->context = new QQmlContext(App()->Engine()->rootContext()); + this->dataPtr->context->setContextProperty(filename, this); + this->dataPtr->context->setContextProperty("module", this); + // Create an item for the plugin - this->dataPtr->pluginItem = - qobject_cast(component.create(this->dataPtr->context)); + auto *plugin = component.beginCreate(this->dataPtr->context); + this->dataPtr->pluginItem = qobject_cast(plugin); + this->dataPtr->pluginItem->setParent(this); + component.completeCreate(); + if (!this->dataPtr->pluginItem) { - gzerr << "Failed to instantiate QML file [" << qmlFile << "]." << std::endl + gzerr << "Failed to instantiate QML file [" << qmlFile.toStdString() << "]." << std::endl << "Are you sure the file is valid QML? " << "You can check with the `qmlscene` tool" << std::endl; return; @@ -421,19 +427,14 @@ QQuickItem *Plugin::CardItem() const return this->dataPtr->cardItem; // Instantiate a card - std::string qmlFile(":/qml/GzCard.qml"); + std::string qmlFile("qrc:gz/gui/qml/GzCard.qml"); QQmlComponent cardComp(App()->Engine(), QString::fromStdString(qmlFile)); auto *cardItem = qobject_cast(cardComp.create()); - - if (cardComp.isError()) - { - qWarning() << cardComp.errors(); - } - - if (!cardItem) + if (cardItem == nullptr) { gzerr << "Internal error: Failed to instantiate QML file [" << qmlFile << "]" << std::endl; + qWarning() << cardComp.errors(); return nullptr; } @@ -605,3 +606,5 @@ void Plugin::ApplyAnchors() this->CardItem()->setProperty("anchored", true); } } // namespace gz::gui + +#include "moc_Plugin.cpp" diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index f5bcf98f1..553818dee 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -40,6 +40,7 @@ function(gz_gui_add_library library_name) ) endfunction() + ################################################# # gz_gui_add_plugin( # SOURCES @@ -60,7 +61,7 @@ endfunction() # # [PRIVATE_LINK_LIBS]: Specify a list of libraries to be privately linked. # -function(gz_gui_add_plugin plugin_name) +function(gz_gui_add_plugin_qt5 plugin_name) set(options) set(oneValueArgs) set(multiValueArgs @@ -70,19 +71,19 @@ function(gz_gui_add_plugin plugin_name) PUBLIC_LINK_LIBS PRIVATE_LINK_LIBS ) - cmake_parse_arguments(gz_gui_add_plugin "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + cmake_parse_arguments(gz_gui_add_plugin_qt5 "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) gz_gui_add_library(${plugin_name} - SOURCES ${gz_gui_add_plugin_SOURCES} - QT_HEADERS ${gz_gui_add_plugin_QT_HEADERS} - PUBLIC_LINK_LIBS ${gz_gui_add_plugin_PUBLIC_LINK_LIBS} - PRIVATE_LINK_LIBS ${gz_gui_add_plugin_PRIVATE_LINK_LIBS} gz-plugin${GZ_PLUGIN_VER}::register + SOURCES ${gz_gui_add_plugin_qt5_SOURCES} + QT_HEADERS ${gz_gui_add_plugin_qt5_QT_HEADERS} + PUBLIC_LINK_LIBS ${gz_gui_add_plugin_qt5_PUBLIC_LINK_LIBS} + PRIVATE_LINK_LIBS ${gz_gui_add_plugin_qt5_PRIVATE_LINK_LIBS} gz-plugin${GZ_PLUGIN_VER}::register ) - if(gz_gui_add_plugin_TEST_SOURCES) + if(gz_gui_add_plugin_qt5_TEST_SOURCES) gz_build_tests(TYPE UNIT SOURCES - ${gz_gui_add_plugin_TEST_SOURCES} + ${gz_gui_add_plugin_qt5_TEST_SOURCES} LIB_DEPS ${GZ-GUI_LIBRARIES} TINYXML2::TINYXML2 @@ -105,33 +106,83 @@ function(gz_gui_add_plugin plugin_name) # warning is not important since those members do not need to be interfaced # with. set_source_files_properties( - ${gz_gui_add_plugin_SOURCES} - ${gz_gui_add_plugin_TEST_SOURCES} + ${gz_gui_add_plugin_qt5_SOURCES} + ${gz_gui_add_plugin_qt5_TEST_SOURCES} COMPILE_FLAGS "/wd4251") endif() install (TARGETS ${plugin_name} DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) endfunction() +function(gz_gui_add_plugin_qt6 plugin_name) + set(options) + set(oneValueArgs) + set(multiValueArgs + SOURCES + QML_SOURCES + QML_URI + QT_HEADERS + TEST_SOURCES + PUBLIC_LINK_LIBS + PRIVATE_LINK_LIBS + ) + cmake_parse_arguments(gz_gui_add_plugin_qt6 "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + qt_add_qml_module(${plugin_name} + URI ${gz_gui_add_plugin_QML_URI} + VERSION 1.0 + SOURCES ${gz_gui_add_plugin_qt6_SOURCES} ${qt_gui_add_plugin_qt6_QT_HEADERS} + QML_FILES ${gz_gui_add_plugin_qt6_QML_SOURCES} + ) + + target_link_libraries(${plugin_name} + PUBLIC + ${PROJECT_LIBRARY_TARGET_NAME} + ${gz_gui_add_plugin_qt6_PUBLIC_LINK_LIBS} + PRIVATE + ${gz_gui_add_plugin_qt6_PRIVATE_LINK_LIBS} + ) + install (TARGETS ${plugin_name} DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) +endfunction() + + +function(gz_gui_add_plugin plugin_name) + set(options) + set(oneValueArgs) + set(multiValueArgs + SOURCES + QML_SOURCES + QML_URI + QT_HEADERS + TEST_SOURCES + PUBLIC_LINK_LIBS + PRIVATE_LINK_LIBS + ) + cmake_parse_arguments(gz_gui_add_plugin "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if (QT_MAJOR_VERSION EQUAL 6) + gz_gui_add_plugin_qt6(${plugin_name} + SOURCES ${gz_gui_add_plugin_SOURCES} + QML_URI ${gz_gui_add_plugin_QML_URI} + QML_SOURCES ${gz_gui_add_plugin_QML_SOURCES} + QT_HEADERS ${gz_gui_add_plugin_QT_HEADERS} + TEST_SOURCES ${gz_gui_add_plugin_TEST_SOURCES} + PUBLIC_LINK_LIBS ${gz_gui_add_plugin_PUBLIC_LINK_LIBS} + PRIVATE_LINK_LIBS ${gz_gui_add_plugin_PRIVATE_LINK_LIBS} + ) + else() + gz_gui_add_plugin_qt5(${plugin_name} + SOURCES ${gz_gui_add_plugin_SOURCES} + QT_HEADERS ${gz_gui_add_plugin_QT_HEADERS} + TEST_SOURCES ${gz_gui_add_plugin_TEST_SOURCES} + PUBLIC_LINK_LIBS ${gz_gui_add_plugin_PUBLIC_LINK_LIBS} + PRIVATE_LINK_LIBS ${gz_gui_add_plugin_PRIVATE_LINK_LIBS} + ) + endif() +endfunction() + + # Plugins add_subdirectory(camera_fps) add_subdirectory(camera_tracking) -add_subdirectory(grid_config) -add_subdirectory(image_display) -add_subdirectory(interactive_view_control) -add_subdirectory(key_publisher) -add_subdirectory(plotting) -add_subdirectory(point_cloud) add_subdirectory(publisher) -add_subdirectory(marker_manager) -add_subdirectory(minimal_scene) -add_subdirectory(navsat_map) -add_subdirectory(screenshot) -add_subdirectory(shutdown_button) -add_subdirectory(tape_measure) -add_subdirectory(teleop) -add_subdirectory(topic_echo) -add_subdirectory(topic_viewer) -add_subdirectory(transport_scene_manager) -add_subdirectory(world_control) -add_subdirectory(world_stats) diff --git a/src/plugins/camera_fps/CMakeLists.txt b/src/plugins/camera_fps/CMakeLists.txt index a07028094..2c2eea5f6 100644 --- a/src/plugins/camera_fps/CMakeLists.txt +++ b/src/plugins/camera_fps/CMakeLists.txt @@ -1,18 +1,12 @@ -qt6_add_qml_module(CameraFps - URI camera_fps - VERSION 1.0 - SOURCES CameraFps.cc - QML_FILES CameraFps.qml -) - -target_link_libraries(CameraFps PRIVATE +gz_gui_add_plugin(CameraFps + SOURCES + CameraFps.cc + QT_HEADERS + CameraFps.hh + QML_SOURCES + CameraFps.qml + QML_URI + CameraFps + PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} - gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER} - gz-plugin${GZ_PLUGIN_VER}::register - Qt6::Gui - Qt6::Widgets - Qt6::Quick - Qt6::QuickControls2 ) - -install (TARGETS CameraFps DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) diff --git a/src/plugins/camera_tracking/CMakeLists.txt b/src/plugins/camera_tracking/CMakeLists.txt index 7ca87bbb0..19249ae7b 100644 --- a/src/plugins/camera_tracking/CMakeLists.txt +++ b/src/plugins/camera_tracking/CMakeLists.txt @@ -1,18 +1,13 @@ -qt6_add_qml_module(CameraTracking - URI camera_tracking - VERSION 1.0 - SOURCES CameraTracking.cc - QML_FILES CameraTracking.qml -) - -target_link_libraries(CameraTracking PRIVATE +gz_gui_add_plugin(CameraTracking + SOURCES + CameraTracking.cc + QT_HEADERS + CameraTracking.hh + QML_SOURCES + CameraTracking.qml + QML_URI + CameraTracking + PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} - gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER} - gz-plugin${GZ_PLUGIN_VER}::register - Qt6::Gui - Qt6::Widgets - Qt6::Quick - Qt6::QuickControls2 + gz-common${GZ_COMMON_VER}::profiler ) - -install(TARGETS CameraTracking DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) diff --git a/src/plugins/publisher/CMakeLists.txt b/src/plugins/publisher/CMakeLists.txt index b1c9df011..f02673a5a 100644 --- a/src/plugins/publisher/CMakeLists.txt +++ b/src/plugins/publisher/CMakeLists.txt @@ -3,7 +3,10 @@ gz_gui_add_plugin(Publisher Publisher.cc QT_HEADERS Publisher.hh + QML_SOURCES + Publisher.qml + QML_URI + Publisher TEST_SOURCES Publisher_TEST.cc ) - diff --git a/src/plugins/publisher/Publisher.cc b/src/plugins/publisher/Publisher.cc index 25fec4f8d..2ca96ef7d 100644 --- a/src/plugins/publisher/Publisher.cc +++ b/src/plugins/publisher/Publisher.cc @@ -51,8 +51,9 @@ class Publisher::Implementation }; ///////////////////////////////////////////////// -Publisher::Publisher() - : dataPtr(gz::utils::MakeUniqueImpl()) +Publisher::Publisher(QObject *_parent) + : gz::gui::Plugin(_parent), + dataPtr(gz::utils::MakeUniqueImpl()) { } @@ -199,3 +200,5 @@ void Publisher::SetFrequency(const double _frequency) // Register this plugin GZ_ADD_PLUGIN(gz::gui::plugins::Publisher, gz::gui::Plugin) + +#include "moc_Publisher.cpp" diff --git a/src/plugins/publisher/Publisher.hh b/src/plugins/publisher/Publisher.hh index 64bf816f5..fe8f275fa 100644 --- a/src/plugins/publisher/Publisher.hh +++ b/src/plugins/publisher/Publisher.hh @@ -42,6 +42,7 @@ namespace gz::gui::plugins class Publisher_EXPORTS_API Publisher : public Plugin { Q_OBJECT + QML_ELEMENT /// \brief Message type Q_PROPERTY( @@ -76,7 +77,7 @@ namespace gz::gui::plugins ) /// \brief Constructor - public: Publisher(); + public: Publisher(QObject *_parent = nullptr); /// \brief Destructor public: virtual ~Publisher(); diff --git a/src/plugins/publisher/Publisher.qml b/src/plugins/publisher/Publisher.qml index c31149e1a..2bc2fc93f 100644 --- a/src/plugins/publisher/Publisher.qml +++ b/src/plugins/publisher/Publisher.qml @@ -38,7 +38,7 @@ Rectangle { TextField { id: msgTypeField - text: Publisher.msgType + text: module.msgType selectByMouse: true } @@ -48,7 +48,7 @@ Rectangle { TextField { id: topicField - text: Publisher.topic + text: module.topic selectByMouse: true } @@ -58,7 +58,7 @@ Rectangle { TextArea { id: msgDataField - text: Publisher.msgData + text: module.msgData selectByMouse: true } @@ -90,12 +90,12 @@ Rectangle { onToggled: { // Is there a way to 2-way bind properties, or is this needed? - Publisher.msgType = msgTypeField.text - Publisher.topic = topicField.text - Publisher.msgData = msgDataField.text - Publisher.frequency = frequencyField.value + module.msgType = msgTypeField.text + module.topic = topicField.text + module.msgData = msgDataField.text + module.frequency = frequencyField.value - Publisher.OnPublish(checked); + module.OnPublish(checked); } ToolTip.visible: hovered ToolTip.delay: tooltipDelay From 47c92c2b43a1188b46b988198a33fb8b66eff943 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Tue, 28 Nov 2023 18:06:22 +0000 Subject: [PATCH 24/33] Align all plugins Signed-off-by: Michael Carroll --- src/plugins/CMakeLists.txt | 44 ++++++++++++++++-- .../{camera_fps => CameraFps}/CMakeLists.txt | 0 .../{camera_fps => CameraFps}/CameraFps.cc | 0 .../{camera_fps => CameraFps}/CameraFps.hh | 0 .../{camera_fps => CameraFps}/CameraFps.qml | 0 .../CMakeLists.txt | 0 .../CameraTracking.cc | 0 .../CameraTracking.hh | 0 .../CameraTracking.qml | 0 .../CameraTracking.qrc | 0 src/plugins/GridConfig/CMakeLists.txt | 12 +++++ .../{grid_config => GridConfig}/GridConfig.cc | 0 .../{grid_config => GridConfig}/GridConfig.hh | 0 .../GridConfig.qml | 0 .../GridConfig.qrc | 0 .../CMakeLists.txt | 9 +++- .../ImageDisplay.cc | 0 .../ImageDisplay.hh | 0 .../ImageDisplay.qml | 0 .../ImageDisplay.qrc | 0 .../ImageDisplay_TEST.cc | 0 .../CMakeLists.txt | 6 ++- .../InteractiveViewControl.cc | 0 .../InteractiveViewControl.hh | 0 .../InteractiveViewControl.qml | 0 .../InteractiveViewControl.qrc | 0 .../CMakeLists.txt | 4 ++ .../KeyPublisher.cc | 0 .../KeyPublisher.hh | 0 .../KeyPublisher.qml | 0 .../KeyPublisher.qrc | 0 .../KeyPublisher_TEST.cc | 0 .../CMakeLists.txt | 4 ++ .../MarkerManager.cc | 0 .../MarkerManager.hh | 0 .../MarkerManager.qml | 0 .../MarkerManager.qrc | 0 src/plugins/MinimalScene/CMakeLists.txt | 20 ++++++++ .../EngineToQtInterface.cc | 0 .../EngineToQtInterface.hh | 0 .../MinimalScene.cc | 0 .../MinimalScene.hh | 0 .../MinimalScene.qml | 0 .../MinimalScene.qrc | 0 .../MinimalSceneConfig.hh | 0 .../MinimalSceneRhi.cc | 0 .../MinimalSceneRhi.hh | 0 .../MinimalSceneRhiMetal.hh | 0 .../MinimalSceneRhiMetal.mm | 0 .../MinimalSceneRhiOpenGL.cc | 0 .../MinimalSceneRhiOpenGL.hh | 0 .../MinimalSceneRhiVulkan.cc | 0 .../MinimalSceneRhiVulkan.hh | 0 .../{navsat_map => NavsatMap}/CMakeLists.txt | 3 +- .../{navsat_map => NavsatMap}/NavSatMap.cc | 0 .../{navsat_map => NavsatMap}/NavSatMap.hh | 0 .../{navsat_map => NavsatMap}/NavSatMap.qml | 0 .../{navsat_map => NavsatMap}/NavSatMap.qrc | 0 .../{plotting => Plotting}/CMakeLists.txt | 5 +- .../TransportPlotting.cc | 0 .../TransportPlotting.hh | 0 .../TransportPlotting.qml | 0 .../TransportPlotting.qrc | 0 .../CMakeLists.txt | 2 + .../{point_cloud => PointCloud}/PointCloud.cc | 0 .../{point_cloud => PointCloud}/PointCloud.hh | 0 .../PointCloud.qml | 0 .../PointCloud.qrc | 0 .../PointCloud_TEST.cc | 0 .../{publisher => Publisher}/CMakeLists.txt | 0 .../{publisher => Publisher}/Publisher.cc | 0 .../{publisher => Publisher}/Publisher.hh | 0 .../{publisher => Publisher}/Publisher.qml | 0 .../{publisher => Publisher}/Publisher.qrc | 0 .../Publisher_TEST.cc | 0 .../{screenshot => Screenshot}/CMakeLists.txt | 2 + .../{screenshot => Screenshot}/Screenshot.cc | 0 .../{screenshot => Screenshot}/Screenshot.hh | 0 .../{screenshot => Screenshot}/Screenshot.qml | 0 .../{screenshot => Screenshot}/Screenshot.qrc | 0 .../Screenshot_TEST.cc | 0 .../{screenshot => Screenshot}/folder.png | Bin .../{screenshot => Screenshot}/screenshot.png | Bin .../CMakeLists.txt | 3 +- .../ShutdownButton.cc | 0 .../ShutdownButton.hh | 0 .../ShutdownButton.qml | 0 .../ShutdownButton.qrc | 0 .../ShutdownButton_TEST.cc | 0 .../test.config | 0 .../CMakeLists.txt | 2 + .../TapeMeasure.cc | 0 .../TapeMeasure.hh | 0 .../TapeMeasure.qml | 0 .../TapeMeasure.qrc | 0 .../tape_measure.png | Bin .../trashcan.png | Bin src/plugins/{teleop => Teleop}/CMakeLists.txt | 2 + src/plugins/{teleop => Teleop}/Teleop.cc | 0 src/plugins/{teleop => Teleop}/Teleop.hh | 0 src/plugins/{teleop => Teleop}/Teleop.qml | 0 src/plugins/{teleop => Teleop}/Teleop.qrc | 0 src/plugins/{teleop => Teleop}/Teleop_TEST.cc | 0 .../{topic_echo => TopicEcho}/CMakeLists.txt | 2 + .../{topic_echo => TopicEcho}/TopicEcho.cc | 0 .../{topic_echo => TopicEcho}/TopicEcho.hh | 0 .../{topic_echo => TopicEcho}/TopicEcho.qml | 0 .../{topic_echo => TopicEcho}/TopicEcho.qrc | 0 .../TopicEcho_TEST.cc | 0 .../CMakeLists.txt | 2 + .../TopicViewer.cc | 0 .../TopicViewer.hh | 0 .../TopicViewer.qml | 0 .../TopicViewer.qrc | 0 .../TopicViewer_TEST.cc | 0 .../{topic_viewer => TopicViewer}/minus.png | Bin .../plottable_icon.svg | 0 .../{topic_viewer => TopicViewer}/plus.png | Bin .../CMakeLists.txt | 5 +- .../TransportSceneManager.cc | 0 .../TransportSceneManager.hh | 0 .../TransportSceneManager.qml | 0 .../TransportSceneManager.qrc | 0 .../CMakeLists.txt | 4 ++ .../WorldControl.cc | 0 .../WorldControl.hh | 0 .../WorldControl.qml | 0 .../WorldControl.qrc | 0 .../WorldControlEventListener.cc | 0 .../WorldControlEventListener.hh | 0 .../WorldControl_TEST.cc | 0 .../CMakeLists.txt | 3 +- .../{world_stats => WorldStats}/WorldStats.cc | 0 .../{world_stats => WorldStats}/WorldStats.hh | 0 .../WorldStats.qml | 0 .../WorldStats.qrc | 0 .../WorldStats_TEST.cc | 0 src/plugins/grid_config/CMakeLists.txt | 14 ------ src/plugins/minimal_scene/CMakeLists.txt | 31 ------------ 139 files changed, 119 insertions(+), 60 deletions(-) rename src/plugins/{camera_fps => CameraFps}/CMakeLists.txt (100%) rename src/plugins/{camera_fps => CameraFps}/CameraFps.cc (100%) rename src/plugins/{camera_fps => CameraFps}/CameraFps.hh (100%) rename src/plugins/{camera_fps => CameraFps}/CameraFps.qml (100%) rename src/plugins/{camera_tracking => CameraTracking}/CMakeLists.txt (100%) rename src/plugins/{camera_tracking => CameraTracking}/CameraTracking.cc (100%) rename src/plugins/{camera_tracking => CameraTracking}/CameraTracking.hh (100%) rename src/plugins/{camera_tracking => CameraTracking}/CameraTracking.qml (100%) rename src/plugins/{camera_tracking => CameraTracking}/CameraTracking.qrc (100%) create mode 100644 src/plugins/GridConfig/CMakeLists.txt rename src/plugins/{grid_config => GridConfig}/GridConfig.cc (100%) rename src/plugins/{grid_config => GridConfig}/GridConfig.hh (100%) rename src/plugins/{grid_config => GridConfig}/GridConfig.qml (100%) rename src/plugins/{grid_config => GridConfig}/GridConfig.qrc (100%) rename src/plugins/{image_display => ImageDisplay}/CMakeLists.txt (60%) rename src/plugins/{image_display => ImageDisplay}/ImageDisplay.cc (100%) rename src/plugins/{image_display => ImageDisplay}/ImageDisplay.hh (100%) rename src/plugins/{image_display => ImageDisplay}/ImageDisplay.qml (100%) rename src/plugins/{image_display => ImageDisplay}/ImageDisplay.qrc (100%) rename src/plugins/{image_display => ImageDisplay}/ImageDisplay_TEST.cc (100%) rename src/plugins/{interactive_view_control => InteractiveViewControl}/CMakeLists.txt (72%) rename src/plugins/{interactive_view_control => InteractiveViewControl}/InteractiveViewControl.cc (100%) rename src/plugins/{interactive_view_control => InteractiveViewControl}/InteractiveViewControl.hh (100%) rename src/plugins/{interactive_view_control => InteractiveViewControl}/InteractiveViewControl.qml (100%) rename src/plugins/{interactive_view_control => InteractiveViewControl}/InteractiveViewControl.qrc (100%) rename src/plugins/{key_publisher => KeyPublisher}/CMakeLists.txt (68%) rename src/plugins/{key_publisher => KeyPublisher}/KeyPublisher.cc (100%) rename src/plugins/{key_publisher => KeyPublisher}/KeyPublisher.hh (100%) rename src/plugins/{key_publisher => KeyPublisher}/KeyPublisher.qml (100%) rename src/plugins/{key_publisher => KeyPublisher}/KeyPublisher.qrc (100%) rename src/plugins/{key_publisher => KeyPublisher}/KeyPublisher_TEST.cc (100%) rename src/plugins/{marker_manager => MarkerManager}/CMakeLists.txt (74%) rename src/plugins/{marker_manager => MarkerManager}/MarkerManager.cc (100%) rename src/plugins/{marker_manager => MarkerManager}/MarkerManager.hh (100%) rename src/plugins/{marker_manager => MarkerManager}/MarkerManager.qml (100%) rename src/plugins/{marker_manager => MarkerManager}/MarkerManager.qrc (100%) create mode 100644 src/plugins/MinimalScene/CMakeLists.txt rename src/plugins/{minimal_scene => MinimalScene}/EngineToQtInterface.cc (100%) rename src/plugins/{minimal_scene => MinimalScene}/EngineToQtInterface.hh (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalScene.cc (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalScene.hh (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalScene.qml (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalScene.qrc (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalSceneConfig.hh (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalSceneRhi.cc (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalSceneRhi.hh (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalSceneRhiMetal.hh (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalSceneRhiMetal.mm (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalSceneRhiOpenGL.cc (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalSceneRhiOpenGL.hh (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalSceneRhiVulkan.cc (100%) rename src/plugins/{minimal_scene => MinimalScene}/MinimalSceneRhiVulkan.hh (100%) rename src/plugins/{navsat_map => NavsatMap}/CMakeLists.txt (78%) rename src/plugins/{navsat_map => NavsatMap}/NavSatMap.cc (100%) rename src/plugins/{navsat_map => NavsatMap}/NavSatMap.hh (100%) rename src/plugins/{navsat_map => NavsatMap}/NavSatMap.qml (100%) rename src/plugins/{navsat_map => NavsatMap}/NavSatMap.qrc (100%) rename src/plugins/{plotting => Plotting}/CMakeLists.txt (71%) rename src/plugins/{plotting => Plotting}/TransportPlotting.cc (100%) rename src/plugins/{plotting => Plotting}/TransportPlotting.hh (100%) rename src/plugins/{plotting => Plotting}/TransportPlotting.qml (100%) rename src/plugins/{plotting => Plotting}/TransportPlotting.qrc (100%) rename src/plugins/{point_cloud => PointCloud}/CMakeLists.txt (89%) rename src/plugins/{point_cloud => PointCloud}/PointCloud.cc (100%) rename src/plugins/{point_cloud => PointCloud}/PointCloud.hh (100%) rename src/plugins/{point_cloud => PointCloud}/PointCloud.qml (100%) rename src/plugins/{point_cloud => PointCloud}/PointCloud.qrc (100%) rename src/plugins/{point_cloud => PointCloud}/PointCloud_TEST.cc (100%) rename src/plugins/{publisher => Publisher}/CMakeLists.txt (100%) rename src/plugins/{publisher => Publisher}/Publisher.cc (100%) rename src/plugins/{publisher => Publisher}/Publisher.hh (100%) rename src/plugins/{publisher => Publisher}/Publisher.qml (100%) rename src/plugins/{publisher => Publisher}/Publisher.qrc (100%) rename src/plugins/{publisher => Publisher}/Publisher_TEST.cc (100%) rename src/plugins/{screenshot => Screenshot}/CMakeLists.txt (89%) rename src/plugins/{screenshot => Screenshot}/Screenshot.cc (100%) rename src/plugins/{screenshot => Screenshot}/Screenshot.hh (100%) rename src/plugins/{screenshot => Screenshot}/Screenshot.qml (100%) rename src/plugins/{screenshot => Screenshot}/Screenshot.qrc (100%) rename src/plugins/{screenshot => Screenshot}/Screenshot_TEST.cc (100%) rename src/plugins/{screenshot => Screenshot}/folder.png (100%) rename src/plugins/{screenshot => Screenshot}/screenshot.png (100%) rename src/plugins/{shutdown_button => ShutdownButton}/CMakeLists.txt (83%) rename src/plugins/{shutdown_button => ShutdownButton}/ShutdownButton.cc (100%) rename src/plugins/{shutdown_button => ShutdownButton}/ShutdownButton.hh (100%) rename src/plugins/{shutdown_button => ShutdownButton}/ShutdownButton.qml (100%) rename src/plugins/{shutdown_button => ShutdownButton}/ShutdownButton.qrc (100%) rename src/plugins/{shutdown_button => ShutdownButton}/ShutdownButton_TEST.cc (100%) rename src/plugins/{shutdown_button => ShutdownButton}/test.config (100%) rename src/plugins/{tape_measure => TapeMeasure}/CMakeLists.txt (87%) rename src/plugins/{tape_measure => TapeMeasure}/TapeMeasure.cc (100%) rename src/plugins/{tape_measure => TapeMeasure}/TapeMeasure.hh (100%) rename src/plugins/{tape_measure => TapeMeasure}/TapeMeasure.qml (100%) rename src/plugins/{tape_measure => TapeMeasure}/TapeMeasure.qrc (100%) rename src/plugins/{tape_measure => TapeMeasure}/tape_measure.png (100%) rename src/plugins/{tape_measure => TapeMeasure}/trashcan.png (100%) rename src/plugins/{teleop => Teleop}/CMakeLists.txt (84%) rename src/plugins/{teleop => Teleop}/Teleop.cc (100%) rename src/plugins/{teleop => Teleop}/Teleop.hh (100%) rename src/plugins/{teleop => Teleop}/Teleop.qml (100%) rename src/plugins/{teleop => Teleop}/Teleop.qrc (100%) rename src/plugins/{teleop => Teleop}/Teleop_TEST.cc (100%) rename src/plugins/{topic_echo => TopicEcho}/CMakeLists.txt (83%) rename src/plugins/{topic_echo => TopicEcho}/TopicEcho.cc (100%) rename src/plugins/{topic_echo => TopicEcho}/TopicEcho.hh (100%) rename src/plugins/{topic_echo => TopicEcho}/TopicEcho.qml (100%) rename src/plugins/{topic_echo => TopicEcho}/TopicEcho.qrc (100%) rename src/plugins/{topic_echo => TopicEcho}/TopicEcho_TEST.cc (100%) rename src/plugins/{topic_viewer => TopicViewer}/CMakeLists.txt (86%) rename src/plugins/{topic_viewer => TopicViewer}/TopicViewer.cc (100%) rename src/plugins/{topic_viewer => TopicViewer}/TopicViewer.hh (100%) rename src/plugins/{topic_viewer => TopicViewer}/TopicViewer.qml (100%) rename src/plugins/{topic_viewer => TopicViewer}/TopicViewer.qrc (100%) rename src/plugins/{topic_viewer => TopicViewer}/TopicViewer_TEST.cc (100%) rename src/plugins/{topic_viewer => TopicViewer}/minus.png (100%) rename src/plugins/{topic_viewer => TopicViewer}/plottable_icon.svg (100%) rename src/plugins/{topic_viewer => TopicViewer}/plus.png (100%) rename src/plugins/{transport_scene_manager => TransportSceneManager}/CMakeLists.txt (64%) rename src/plugins/{transport_scene_manager => TransportSceneManager}/TransportSceneManager.cc (100%) rename src/plugins/{transport_scene_manager => TransportSceneManager}/TransportSceneManager.hh (100%) rename src/plugins/{transport_scene_manager => TransportSceneManager}/TransportSceneManager.qml (100%) rename src/plugins/{transport_scene_manager => TransportSceneManager}/TransportSceneManager.qrc (100%) rename src/plugins/{world_control => WorldControl}/CMakeLists.txt (85%) rename src/plugins/{world_control => WorldControl}/WorldControl.cc (100%) rename src/plugins/{world_control => WorldControl}/WorldControl.hh (100%) rename src/plugins/{world_control => WorldControl}/WorldControl.qml (100%) rename src/plugins/{world_control => WorldControl}/WorldControl.qrc (100%) rename src/plugins/{world_control => WorldControl}/WorldControlEventListener.cc (100%) rename src/plugins/{world_control => WorldControl}/WorldControlEventListener.hh (100%) rename src/plugins/{world_control => WorldControl}/WorldControl_TEST.cc (100%) rename src/plugins/{world_stats => WorldStats}/CMakeLists.txt (83%) rename src/plugins/{world_stats => WorldStats}/WorldStats.cc (100%) rename src/plugins/{world_stats => WorldStats}/WorldStats.hh (100%) rename src/plugins/{world_stats => WorldStats}/WorldStats.qml (100%) rename src/plugins/{world_stats => WorldStats}/WorldStats.qrc (100%) rename src/plugins/{world_stats => WorldStats}/WorldStats_TEST.cc (100%) delete mode 100644 src/plugins/grid_config/CMakeLists.txt delete mode 100644 src/plugins/minimal_scene/CMakeLists.txt diff --git a/src/plugins/CMakeLists.txt b/src/plugins/CMakeLists.txt index 553818dee..6b7f6e2c6 100644 --- a/src/plugins/CMakeLists.txt +++ b/src/plugins/CMakeLists.txt @@ -143,6 +143,25 @@ function(gz_gui_add_plugin_qt6 plugin_name) ${gz_gui_add_plugin_qt6_PRIVATE_LINK_LIBS} ) install (TARGETS ${plugin_name} DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) + + if (gz_gui_add_plugin_qt6_TEST_SOURCES) + gz_build_tests(TYPE UNIT + SOURCES + ${gz_gui_add_plugin_qt6_TEST_SOURCES} + LIB_DEPS + ${GZ-GUI_LIBRARIES} + TINYXML2::TINYXML2 + ${plugin_name} + INCLUDE_DIRS + # Used to make internal source file headers visible to the unit tests + ${CMAKE_CURRENT_SOURCE_DIR} + # Used to make test-directory headers visible to the unit tests + ${PROJECT_SOURCE_DIR} + # Used to make test_config.h visible to the unit tests + ${PROJECT_BINARY_DIR} + ENVIRONMENT + GZ_GUI_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}) + endif() endfunction() @@ -183,6 +202,25 @@ endfunction() # Plugins -add_subdirectory(camera_fps) -add_subdirectory(camera_tracking) -add_subdirectory(publisher) + +add_subdirectory(CameraFps) +add_subdirectory(CameraTracking) +add_subdirectory(GridConfig) +add_subdirectory(ImageDisplay) +add_subdirectory(InteractiveViewControl) +add_subdirectory(KeyPublisher) +add_subdirectory(MarkerManager) +add_subdirectory(MinimalScene) +add_subdirectory(NavsatMap) +add_subdirectory(Plotting) +add_subdirectory(PointCloud) +add_subdirectory(Publisher) +add_subdirectory(Screenshot) +add_subdirectory(ShutdownButton) +add_subdirectory(TapeMeasure) +add_subdirectory(Teleop) +add_subdirectory(TopicEcho) +add_subdirectory(TopicViewer) +add_subdirectory(TransportSceneManager) +add_subdirectory(WorldControl) +add_subdirectory(WorldStats) diff --git a/src/plugins/camera_fps/CMakeLists.txt b/src/plugins/CameraFps/CMakeLists.txt similarity index 100% rename from src/plugins/camera_fps/CMakeLists.txt rename to src/plugins/CameraFps/CMakeLists.txt diff --git a/src/plugins/camera_fps/CameraFps.cc b/src/plugins/CameraFps/CameraFps.cc similarity index 100% rename from src/plugins/camera_fps/CameraFps.cc rename to src/plugins/CameraFps/CameraFps.cc diff --git a/src/plugins/camera_fps/CameraFps.hh b/src/plugins/CameraFps/CameraFps.hh similarity index 100% rename from src/plugins/camera_fps/CameraFps.hh rename to src/plugins/CameraFps/CameraFps.hh diff --git a/src/plugins/camera_fps/CameraFps.qml b/src/plugins/CameraFps/CameraFps.qml similarity index 100% rename from src/plugins/camera_fps/CameraFps.qml rename to src/plugins/CameraFps/CameraFps.qml diff --git a/src/plugins/camera_tracking/CMakeLists.txt b/src/plugins/CameraTracking/CMakeLists.txt similarity index 100% rename from src/plugins/camera_tracking/CMakeLists.txt rename to src/plugins/CameraTracking/CMakeLists.txt diff --git a/src/plugins/camera_tracking/CameraTracking.cc b/src/plugins/CameraTracking/CameraTracking.cc similarity index 100% rename from src/plugins/camera_tracking/CameraTracking.cc rename to src/plugins/CameraTracking/CameraTracking.cc diff --git a/src/plugins/camera_tracking/CameraTracking.hh b/src/plugins/CameraTracking/CameraTracking.hh similarity index 100% rename from src/plugins/camera_tracking/CameraTracking.hh rename to src/plugins/CameraTracking/CameraTracking.hh diff --git a/src/plugins/camera_tracking/CameraTracking.qml b/src/plugins/CameraTracking/CameraTracking.qml similarity index 100% rename from src/plugins/camera_tracking/CameraTracking.qml rename to src/plugins/CameraTracking/CameraTracking.qml diff --git a/src/plugins/camera_tracking/CameraTracking.qrc b/src/plugins/CameraTracking/CameraTracking.qrc similarity index 100% rename from src/plugins/camera_tracking/CameraTracking.qrc rename to src/plugins/CameraTracking/CameraTracking.qrc diff --git a/src/plugins/GridConfig/CMakeLists.txt b/src/plugins/GridConfig/CMakeLists.txt new file mode 100644 index 000000000..02144f0a5 --- /dev/null +++ b/src/plugins/GridConfig/CMakeLists.txt @@ -0,0 +1,12 @@ +gz_gui_add_plugin(GridConfig + SOURCES + GridConfig.cc + QT_HEADERS + GridConfig.hh + QML_SOURCES + GridConfig.qml + QML_URI + GridConfig + PUBLIC_LINK_LIBS + gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} +) diff --git a/src/plugins/grid_config/GridConfig.cc b/src/plugins/GridConfig/GridConfig.cc similarity index 100% rename from src/plugins/grid_config/GridConfig.cc rename to src/plugins/GridConfig/GridConfig.cc diff --git a/src/plugins/grid_config/GridConfig.hh b/src/plugins/GridConfig/GridConfig.hh similarity index 100% rename from src/plugins/grid_config/GridConfig.hh rename to src/plugins/GridConfig/GridConfig.hh diff --git a/src/plugins/grid_config/GridConfig.qml b/src/plugins/GridConfig/GridConfig.qml similarity index 100% rename from src/plugins/grid_config/GridConfig.qml rename to src/plugins/GridConfig/GridConfig.qml diff --git a/src/plugins/grid_config/GridConfig.qrc b/src/plugins/GridConfig/GridConfig.qrc similarity index 100% rename from src/plugins/grid_config/GridConfig.qrc rename to src/plugins/GridConfig/GridConfig.qrc diff --git a/src/plugins/image_display/CMakeLists.txt b/src/plugins/ImageDisplay/CMakeLists.txt similarity index 60% rename from src/plugins/image_display/CMakeLists.txt rename to src/plugins/ImageDisplay/CMakeLists.txt index 40794224a..2d8273cf0 100644 --- a/src/plugins/image_display/CMakeLists.txt +++ b/src/plugins/ImageDisplay/CMakeLists.txt @@ -3,8 +3,13 @@ gz_gui_add_plugin(ImageDisplay ImageDisplay.cc QT_HEADERS ImageDisplay.hh - PUBLIC_LINK_LIBS - gz-common${GZ_COMMON_VER}::graphics + QML_SOURCES + ImageDisplay.qml + QML_URI + ImageDisplay TEST_SOURCES ImageDisplay_TEST.cc + PUBLIC_LINK_LIBS + gz-common${GZ_COMMON_VER}::graphics ) + diff --git a/src/plugins/image_display/ImageDisplay.cc b/src/plugins/ImageDisplay/ImageDisplay.cc similarity index 100% rename from src/plugins/image_display/ImageDisplay.cc rename to src/plugins/ImageDisplay/ImageDisplay.cc diff --git a/src/plugins/image_display/ImageDisplay.hh b/src/plugins/ImageDisplay/ImageDisplay.hh similarity index 100% rename from src/plugins/image_display/ImageDisplay.hh rename to src/plugins/ImageDisplay/ImageDisplay.hh diff --git a/src/plugins/image_display/ImageDisplay.qml b/src/plugins/ImageDisplay/ImageDisplay.qml similarity index 100% rename from src/plugins/image_display/ImageDisplay.qml rename to src/plugins/ImageDisplay/ImageDisplay.qml diff --git a/src/plugins/image_display/ImageDisplay.qrc b/src/plugins/ImageDisplay/ImageDisplay.qrc similarity index 100% rename from src/plugins/image_display/ImageDisplay.qrc rename to src/plugins/ImageDisplay/ImageDisplay.qrc diff --git a/src/plugins/image_display/ImageDisplay_TEST.cc b/src/plugins/ImageDisplay/ImageDisplay_TEST.cc similarity index 100% rename from src/plugins/image_display/ImageDisplay_TEST.cc rename to src/plugins/ImageDisplay/ImageDisplay_TEST.cc diff --git a/src/plugins/interactive_view_control/CMakeLists.txt b/src/plugins/InteractiveViewControl/CMakeLists.txt similarity index 72% rename from src/plugins/interactive_view_control/CMakeLists.txt rename to src/plugins/InteractiveViewControl/CMakeLists.txt index 6796a58dd..54088e542 100644 --- a/src/plugins/interactive_view_control/CMakeLists.txt +++ b/src/plugins/InteractiveViewControl/CMakeLists.txt @@ -3,8 +3,10 @@ gz_gui_add_plugin(InteractiveViewControl InteractiveViewControl.cc QT_HEADERS InteractiveViewControl.hh - TEST_SOURCES - # ViewControl_TEST.cc + QML_SOURCES + InteractiveViewControl.qml + QML_URI + InteractiveViewControl PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} ) diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.cc b/src/plugins/InteractiveViewControl/InteractiveViewControl.cc similarity index 100% rename from src/plugins/interactive_view_control/InteractiveViewControl.cc rename to src/plugins/InteractiveViewControl/InteractiveViewControl.cc diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.hh b/src/plugins/InteractiveViewControl/InteractiveViewControl.hh similarity index 100% rename from src/plugins/interactive_view_control/InteractiveViewControl.hh rename to src/plugins/InteractiveViewControl/InteractiveViewControl.hh diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.qml b/src/plugins/InteractiveViewControl/InteractiveViewControl.qml similarity index 100% rename from src/plugins/interactive_view_control/InteractiveViewControl.qml rename to src/plugins/InteractiveViewControl/InteractiveViewControl.qml diff --git a/src/plugins/interactive_view_control/InteractiveViewControl.qrc b/src/plugins/InteractiveViewControl/InteractiveViewControl.qrc similarity index 100% rename from src/plugins/interactive_view_control/InteractiveViewControl.qrc rename to src/plugins/InteractiveViewControl/InteractiveViewControl.qrc diff --git a/src/plugins/key_publisher/CMakeLists.txt b/src/plugins/KeyPublisher/CMakeLists.txt similarity index 68% rename from src/plugins/key_publisher/CMakeLists.txt rename to src/plugins/KeyPublisher/CMakeLists.txt index 1b2561530..3266dcee5 100644 --- a/src/plugins/key_publisher/CMakeLists.txt +++ b/src/plugins/KeyPublisher/CMakeLists.txt @@ -3,6 +3,10 @@ gz_gui_add_plugin(KeyPublisher KeyPublisher.cc QT_HEADERS KeyPublisher.hh + QML_SOURCES + KeyPublisher.qml + QML_URI + KeyPublisher TEST_SOURCES KeyPublisher_TEST.cc ) diff --git a/src/plugins/key_publisher/KeyPublisher.cc b/src/plugins/KeyPublisher/KeyPublisher.cc similarity index 100% rename from src/plugins/key_publisher/KeyPublisher.cc rename to src/plugins/KeyPublisher/KeyPublisher.cc diff --git a/src/plugins/key_publisher/KeyPublisher.hh b/src/plugins/KeyPublisher/KeyPublisher.hh similarity index 100% rename from src/plugins/key_publisher/KeyPublisher.hh rename to src/plugins/KeyPublisher/KeyPublisher.hh diff --git a/src/plugins/key_publisher/KeyPublisher.qml b/src/plugins/KeyPublisher/KeyPublisher.qml similarity index 100% rename from src/plugins/key_publisher/KeyPublisher.qml rename to src/plugins/KeyPublisher/KeyPublisher.qml diff --git a/src/plugins/key_publisher/KeyPublisher.qrc b/src/plugins/KeyPublisher/KeyPublisher.qrc similarity index 100% rename from src/plugins/key_publisher/KeyPublisher.qrc rename to src/plugins/KeyPublisher/KeyPublisher.qrc diff --git a/src/plugins/key_publisher/KeyPublisher_TEST.cc b/src/plugins/KeyPublisher/KeyPublisher_TEST.cc similarity index 100% rename from src/plugins/key_publisher/KeyPublisher_TEST.cc rename to src/plugins/KeyPublisher/KeyPublisher_TEST.cc diff --git a/src/plugins/marker_manager/CMakeLists.txt b/src/plugins/MarkerManager/CMakeLists.txt similarity index 74% rename from src/plugins/marker_manager/CMakeLists.txt rename to src/plugins/MarkerManager/CMakeLists.txt index 391868b65..4cfce1ec3 100644 --- a/src/plugins/marker_manager/CMakeLists.txt +++ b/src/plugins/MarkerManager/CMakeLists.txt @@ -3,6 +3,10 @@ gz_gui_add_plugin(MarkerManager MarkerManager.cc QT_HEADERS MarkerManager.hh + QML_SOURCES + MarkerManager.qml + QML_URI + MarkerManager PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} ) diff --git a/src/plugins/marker_manager/MarkerManager.cc b/src/plugins/MarkerManager/MarkerManager.cc similarity index 100% rename from src/plugins/marker_manager/MarkerManager.cc rename to src/plugins/MarkerManager/MarkerManager.cc diff --git a/src/plugins/marker_manager/MarkerManager.hh b/src/plugins/MarkerManager/MarkerManager.hh similarity index 100% rename from src/plugins/marker_manager/MarkerManager.hh rename to src/plugins/MarkerManager/MarkerManager.hh diff --git a/src/plugins/marker_manager/MarkerManager.qml b/src/plugins/MarkerManager/MarkerManager.qml similarity index 100% rename from src/plugins/marker_manager/MarkerManager.qml rename to src/plugins/MarkerManager/MarkerManager.qml diff --git a/src/plugins/marker_manager/MarkerManager.qrc b/src/plugins/MarkerManager/MarkerManager.qrc similarity index 100% rename from src/plugins/marker_manager/MarkerManager.qrc rename to src/plugins/MarkerManager/MarkerManager.qrc diff --git a/src/plugins/MinimalScene/CMakeLists.txt b/src/plugins/MinimalScene/CMakeLists.txt new file mode 100644 index 000000000..e0a767e38 --- /dev/null +++ b/src/plugins/MinimalScene/CMakeLists.txt @@ -0,0 +1,20 @@ +gz_gui_add_plugin(MinimalScene + SOURCES + MinimalScene.cc + MinimalSceneRhi.cc + MinimalSceneRhiOpenGL.cc + MinimalSceneRhiVulkan.cc + EngineToQtInterface.cc + QT_HEADERS + MinimalScene.hh + MinimalSceneRhi.hh + MinimalSceneRhiOpenGL.hh + MinimalSceneRhiVulkan.hh + EngineToQtInterface.hh + QML_SOURCES + MinimalScene.qml + QML_URI + MinimalScene + PUBLIC_LINK_LIBS + gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} +) diff --git a/src/plugins/minimal_scene/EngineToQtInterface.cc b/src/plugins/MinimalScene/EngineToQtInterface.cc similarity index 100% rename from src/plugins/minimal_scene/EngineToQtInterface.cc rename to src/plugins/MinimalScene/EngineToQtInterface.cc diff --git a/src/plugins/minimal_scene/EngineToQtInterface.hh b/src/plugins/MinimalScene/EngineToQtInterface.hh similarity index 100% rename from src/plugins/minimal_scene/EngineToQtInterface.hh rename to src/plugins/MinimalScene/EngineToQtInterface.hh diff --git a/src/plugins/minimal_scene/MinimalScene.cc b/src/plugins/MinimalScene/MinimalScene.cc similarity index 100% rename from src/plugins/minimal_scene/MinimalScene.cc rename to src/plugins/MinimalScene/MinimalScene.cc diff --git a/src/plugins/minimal_scene/MinimalScene.hh b/src/plugins/MinimalScene/MinimalScene.hh similarity index 100% rename from src/plugins/minimal_scene/MinimalScene.hh rename to src/plugins/MinimalScene/MinimalScene.hh diff --git a/src/plugins/minimal_scene/MinimalScene.qml b/src/plugins/MinimalScene/MinimalScene.qml similarity index 100% rename from src/plugins/minimal_scene/MinimalScene.qml rename to src/plugins/MinimalScene/MinimalScene.qml diff --git a/src/plugins/minimal_scene/MinimalScene.qrc b/src/plugins/MinimalScene/MinimalScene.qrc similarity index 100% rename from src/plugins/minimal_scene/MinimalScene.qrc rename to src/plugins/MinimalScene/MinimalScene.qrc diff --git a/src/plugins/minimal_scene/MinimalSceneConfig.hh b/src/plugins/MinimalScene/MinimalSceneConfig.hh similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneConfig.hh rename to src/plugins/MinimalScene/MinimalSceneConfig.hh diff --git a/src/plugins/minimal_scene/MinimalSceneRhi.cc b/src/plugins/MinimalScene/MinimalSceneRhi.cc similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhi.cc rename to src/plugins/MinimalScene/MinimalSceneRhi.cc diff --git a/src/plugins/minimal_scene/MinimalSceneRhi.hh b/src/plugins/MinimalScene/MinimalSceneRhi.hh similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhi.hh rename to src/plugins/MinimalScene/MinimalSceneRhi.hh diff --git a/src/plugins/minimal_scene/MinimalSceneRhiMetal.hh b/src/plugins/MinimalScene/MinimalSceneRhiMetal.hh similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhiMetal.hh rename to src/plugins/MinimalScene/MinimalSceneRhiMetal.hh diff --git a/src/plugins/minimal_scene/MinimalSceneRhiMetal.mm b/src/plugins/MinimalScene/MinimalSceneRhiMetal.mm similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhiMetal.mm rename to src/plugins/MinimalScene/MinimalSceneRhiMetal.mm diff --git a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc b/src/plugins/MinimalScene/MinimalSceneRhiOpenGL.cc similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhiOpenGL.cc rename to src/plugins/MinimalScene/MinimalSceneRhiOpenGL.cc diff --git a/src/plugins/minimal_scene/MinimalSceneRhiOpenGL.hh b/src/plugins/MinimalScene/MinimalSceneRhiOpenGL.hh similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhiOpenGL.hh rename to src/plugins/MinimalScene/MinimalSceneRhiOpenGL.hh diff --git a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc b/src/plugins/MinimalScene/MinimalSceneRhiVulkan.cc similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhiVulkan.cc rename to src/plugins/MinimalScene/MinimalSceneRhiVulkan.cc diff --git a/src/plugins/minimal_scene/MinimalSceneRhiVulkan.hh b/src/plugins/MinimalScene/MinimalSceneRhiVulkan.hh similarity index 100% rename from src/plugins/minimal_scene/MinimalSceneRhiVulkan.hh rename to src/plugins/MinimalScene/MinimalSceneRhiVulkan.hh diff --git a/src/plugins/navsat_map/CMakeLists.txt b/src/plugins/NavsatMap/CMakeLists.txt similarity index 78% rename from src/plugins/navsat_map/CMakeLists.txt rename to src/plugins/NavsatMap/CMakeLists.txt index 887601742..218776083 100644 --- a/src/plugins/navsat_map/CMakeLists.txt +++ b/src/plugins/NavsatMap/CMakeLists.txt @@ -3,5 +3,6 @@ gz_gui_add_plugin(NavSatMap NavSatMap.cc QT_HEADERS NavSatMap.hh + QML_URI + NavSatMap ) - diff --git a/src/plugins/navsat_map/NavSatMap.cc b/src/plugins/NavsatMap/NavSatMap.cc similarity index 100% rename from src/plugins/navsat_map/NavSatMap.cc rename to src/plugins/NavsatMap/NavSatMap.cc diff --git a/src/plugins/navsat_map/NavSatMap.hh b/src/plugins/NavsatMap/NavSatMap.hh similarity index 100% rename from src/plugins/navsat_map/NavSatMap.hh rename to src/plugins/NavsatMap/NavSatMap.hh diff --git a/src/plugins/navsat_map/NavSatMap.qml b/src/plugins/NavsatMap/NavSatMap.qml similarity index 100% rename from src/plugins/navsat_map/NavSatMap.qml rename to src/plugins/NavsatMap/NavSatMap.qml diff --git a/src/plugins/navsat_map/NavSatMap.qrc b/src/plugins/NavsatMap/NavSatMap.qrc similarity index 100% rename from src/plugins/navsat_map/NavSatMap.qrc rename to src/plugins/NavsatMap/NavSatMap.qrc diff --git a/src/plugins/plotting/CMakeLists.txt b/src/plugins/Plotting/CMakeLists.txt similarity index 71% rename from src/plugins/plotting/CMakeLists.txt rename to src/plugins/Plotting/CMakeLists.txt index 91c66ee89..348ef9724 100644 --- a/src/plugins/plotting/CMakeLists.txt +++ b/src/plugins/Plotting/CMakeLists.txt @@ -3,7 +3,6 @@ gz_gui_add_plugin(TransportPlotting TransportPlotting.cc QT_HEADERS TransportPlotting.hh - TEST_SOURCES - PUBLIC_LINK_LIBS - # ${} + QML_URI + TransportPlotting ) diff --git a/src/plugins/plotting/TransportPlotting.cc b/src/plugins/Plotting/TransportPlotting.cc similarity index 100% rename from src/plugins/plotting/TransportPlotting.cc rename to src/plugins/Plotting/TransportPlotting.cc diff --git a/src/plugins/plotting/TransportPlotting.hh b/src/plugins/Plotting/TransportPlotting.hh similarity index 100% rename from src/plugins/plotting/TransportPlotting.hh rename to src/plugins/Plotting/TransportPlotting.hh diff --git a/src/plugins/plotting/TransportPlotting.qml b/src/plugins/Plotting/TransportPlotting.qml similarity index 100% rename from src/plugins/plotting/TransportPlotting.qml rename to src/plugins/Plotting/TransportPlotting.qml diff --git a/src/plugins/plotting/TransportPlotting.qrc b/src/plugins/Plotting/TransportPlotting.qrc similarity index 100% rename from src/plugins/plotting/TransportPlotting.qrc rename to src/plugins/Plotting/TransportPlotting.qrc diff --git a/src/plugins/point_cloud/CMakeLists.txt b/src/plugins/PointCloud/CMakeLists.txt similarity index 89% rename from src/plugins/point_cloud/CMakeLists.txt rename to src/plugins/PointCloud/CMakeLists.txt index f37bd25ac..b04f3f83d 100644 --- a/src/plugins/point_cloud/CMakeLists.txt +++ b/src/plugins/PointCloud/CMakeLists.txt @@ -7,4 +7,6 @@ gz_gui_add_plugin(PointCloud gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} TEST_SOURCES PointCloud_TEST.cc + QML_URI + PointCloud ) diff --git a/src/plugins/point_cloud/PointCloud.cc b/src/plugins/PointCloud/PointCloud.cc similarity index 100% rename from src/plugins/point_cloud/PointCloud.cc rename to src/plugins/PointCloud/PointCloud.cc diff --git a/src/plugins/point_cloud/PointCloud.hh b/src/plugins/PointCloud/PointCloud.hh similarity index 100% rename from src/plugins/point_cloud/PointCloud.hh rename to src/plugins/PointCloud/PointCloud.hh diff --git a/src/plugins/point_cloud/PointCloud.qml b/src/plugins/PointCloud/PointCloud.qml similarity index 100% rename from src/plugins/point_cloud/PointCloud.qml rename to src/plugins/PointCloud/PointCloud.qml diff --git a/src/plugins/point_cloud/PointCloud.qrc b/src/plugins/PointCloud/PointCloud.qrc similarity index 100% rename from src/plugins/point_cloud/PointCloud.qrc rename to src/plugins/PointCloud/PointCloud.qrc diff --git a/src/plugins/point_cloud/PointCloud_TEST.cc b/src/plugins/PointCloud/PointCloud_TEST.cc similarity index 100% rename from src/plugins/point_cloud/PointCloud_TEST.cc rename to src/plugins/PointCloud/PointCloud_TEST.cc diff --git a/src/plugins/publisher/CMakeLists.txt b/src/plugins/Publisher/CMakeLists.txt similarity index 100% rename from src/plugins/publisher/CMakeLists.txt rename to src/plugins/Publisher/CMakeLists.txt diff --git a/src/plugins/publisher/Publisher.cc b/src/plugins/Publisher/Publisher.cc similarity index 100% rename from src/plugins/publisher/Publisher.cc rename to src/plugins/Publisher/Publisher.cc diff --git a/src/plugins/publisher/Publisher.hh b/src/plugins/Publisher/Publisher.hh similarity index 100% rename from src/plugins/publisher/Publisher.hh rename to src/plugins/Publisher/Publisher.hh diff --git a/src/plugins/publisher/Publisher.qml b/src/plugins/Publisher/Publisher.qml similarity index 100% rename from src/plugins/publisher/Publisher.qml rename to src/plugins/Publisher/Publisher.qml diff --git a/src/plugins/publisher/Publisher.qrc b/src/plugins/Publisher/Publisher.qrc similarity index 100% rename from src/plugins/publisher/Publisher.qrc rename to src/plugins/Publisher/Publisher.qrc diff --git a/src/plugins/publisher/Publisher_TEST.cc b/src/plugins/Publisher/Publisher_TEST.cc similarity index 100% rename from src/plugins/publisher/Publisher_TEST.cc rename to src/plugins/Publisher/Publisher_TEST.cc diff --git a/src/plugins/screenshot/CMakeLists.txt b/src/plugins/Screenshot/CMakeLists.txt similarity index 89% rename from src/plugins/screenshot/CMakeLists.txt rename to src/plugins/Screenshot/CMakeLists.txt index c63cc6956..640b0b856 100644 --- a/src/plugins/screenshot/CMakeLists.txt +++ b/src/plugins/Screenshot/CMakeLists.txt @@ -7,4 +7,6 @@ gz_gui_add_plugin(Screenshot gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} TEST_SOURCES Screenshot_TEST.cc + QML_URI + Screenshot ) diff --git a/src/plugins/screenshot/Screenshot.cc b/src/plugins/Screenshot/Screenshot.cc similarity index 100% rename from src/plugins/screenshot/Screenshot.cc rename to src/plugins/Screenshot/Screenshot.cc diff --git a/src/plugins/screenshot/Screenshot.hh b/src/plugins/Screenshot/Screenshot.hh similarity index 100% rename from src/plugins/screenshot/Screenshot.hh rename to src/plugins/Screenshot/Screenshot.hh diff --git a/src/plugins/screenshot/Screenshot.qml b/src/plugins/Screenshot/Screenshot.qml similarity index 100% rename from src/plugins/screenshot/Screenshot.qml rename to src/plugins/Screenshot/Screenshot.qml diff --git a/src/plugins/screenshot/Screenshot.qrc b/src/plugins/Screenshot/Screenshot.qrc similarity index 100% rename from src/plugins/screenshot/Screenshot.qrc rename to src/plugins/Screenshot/Screenshot.qrc diff --git a/src/plugins/screenshot/Screenshot_TEST.cc b/src/plugins/Screenshot/Screenshot_TEST.cc similarity index 100% rename from src/plugins/screenshot/Screenshot_TEST.cc rename to src/plugins/Screenshot/Screenshot_TEST.cc diff --git a/src/plugins/screenshot/folder.png b/src/plugins/Screenshot/folder.png similarity index 100% rename from src/plugins/screenshot/folder.png rename to src/plugins/Screenshot/folder.png diff --git a/src/plugins/screenshot/screenshot.png b/src/plugins/Screenshot/screenshot.png similarity index 100% rename from src/plugins/screenshot/screenshot.png rename to src/plugins/Screenshot/screenshot.png diff --git a/src/plugins/shutdown_button/CMakeLists.txt b/src/plugins/ShutdownButton/CMakeLists.txt similarity index 83% rename from src/plugins/shutdown_button/CMakeLists.txt rename to src/plugins/ShutdownButton/CMakeLists.txt index e4fc601c8..9375857d7 100644 --- a/src/plugins/shutdown_button/CMakeLists.txt +++ b/src/plugins/ShutdownButton/CMakeLists.txt @@ -5,5 +5,6 @@ gz_gui_add_plugin(ShutdownButton ShutdownButton.hh TEST_SOURCES ShutdownButton_TEST.cc + QML_URI + ShutdownButton ) - diff --git a/src/plugins/shutdown_button/ShutdownButton.cc b/src/plugins/ShutdownButton/ShutdownButton.cc similarity index 100% rename from src/plugins/shutdown_button/ShutdownButton.cc rename to src/plugins/ShutdownButton/ShutdownButton.cc diff --git a/src/plugins/shutdown_button/ShutdownButton.hh b/src/plugins/ShutdownButton/ShutdownButton.hh similarity index 100% rename from src/plugins/shutdown_button/ShutdownButton.hh rename to src/plugins/ShutdownButton/ShutdownButton.hh diff --git a/src/plugins/shutdown_button/ShutdownButton.qml b/src/plugins/ShutdownButton/ShutdownButton.qml similarity index 100% rename from src/plugins/shutdown_button/ShutdownButton.qml rename to src/plugins/ShutdownButton/ShutdownButton.qml diff --git a/src/plugins/shutdown_button/ShutdownButton.qrc b/src/plugins/ShutdownButton/ShutdownButton.qrc similarity index 100% rename from src/plugins/shutdown_button/ShutdownButton.qrc rename to src/plugins/ShutdownButton/ShutdownButton.qrc diff --git a/src/plugins/shutdown_button/ShutdownButton_TEST.cc b/src/plugins/ShutdownButton/ShutdownButton_TEST.cc similarity index 100% rename from src/plugins/shutdown_button/ShutdownButton_TEST.cc rename to src/plugins/ShutdownButton/ShutdownButton_TEST.cc diff --git a/src/plugins/shutdown_button/test.config b/src/plugins/ShutdownButton/test.config similarity index 100% rename from src/plugins/shutdown_button/test.config rename to src/plugins/ShutdownButton/test.config diff --git a/src/plugins/tape_measure/CMakeLists.txt b/src/plugins/TapeMeasure/CMakeLists.txt similarity index 87% rename from src/plugins/tape_measure/CMakeLists.txt rename to src/plugins/TapeMeasure/CMakeLists.txt index 5988f7268..e206a57c1 100644 --- a/src/plugins/tape_measure/CMakeLists.txt +++ b/src/plugins/TapeMeasure/CMakeLists.txt @@ -3,4 +3,6 @@ gz_gui_add_plugin(TapeMeasure QT_HEADERS TapeMeasure.hh PRIVATE_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} + QML_URI + TapeMeasure ) diff --git a/src/plugins/tape_measure/TapeMeasure.cc b/src/plugins/TapeMeasure/TapeMeasure.cc similarity index 100% rename from src/plugins/tape_measure/TapeMeasure.cc rename to src/plugins/TapeMeasure/TapeMeasure.cc diff --git a/src/plugins/tape_measure/TapeMeasure.hh b/src/plugins/TapeMeasure/TapeMeasure.hh similarity index 100% rename from src/plugins/tape_measure/TapeMeasure.hh rename to src/plugins/TapeMeasure/TapeMeasure.hh diff --git a/src/plugins/tape_measure/TapeMeasure.qml b/src/plugins/TapeMeasure/TapeMeasure.qml similarity index 100% rename from src/plugins/tape_measure/TapeMeasure.qml rename to src/plugins/TapeMeasure/TapeMeasure.qml diff --git a/src/plugins/tape_measure/TapeMeasure.qrc b/src/plugins/TapeMeasure/TapeMeasure.qrc similarity index 100% rename from src/plugins/tape_measure/TapeMeasure.qrc rename to src/plugins/TapeMeasure/TapeMeasure.qrc diff --git a/src/plugins/tape_measure/tape_measure.png b/src/plugins/TapeMeasure/tape_measure.png similarity index 100% rename from src/plugins/tape_measure/tape_measure.png rename to src/plugins/TapeMeasure/tape_measure.png diff --git a/src/plugins/tape_measure/trashcan.png b/src/plugins/TapeMeasure/trashcan.png similarity index 100% rename from src/plugins/tape_measure/trashcan.png rename to src/plugins/TapeMeasure/trashcan.png diff --git a/src/plugins/teleop/CMakeLists.txt b/src/plugins/Teleop/CMakeLists.txt similarity index 84% rename from src/plugins/teleop/CMakeLists.txt rename to src/plugins/Teleop/CMakeLists.txt index 775fbbf99..d99aac87a 100644 --- a/src/plugins/teleop/CMakeLists.txt +++ b/src/plugins/Teleop/CMakeLists.txt @@ -5,4 +5,6 @@ gz_gui_add_plugin(Teleop Teleop.hh TEST_SOURCES Teleop_TEST.cc + QML_URI + Teleop ) diff --git a/src/plugins/teleop/Teleop.cc b/src/plugins/Teleop/Teleop.cc similarity index 100% rename from src/plugins/teleop/Teleop.cc rename to src/plugins/Teleop/Teleop.cc diff --git a/src/plugins/teleop/Teleop.hh b/src/plugins/Teleop/Teleop.hh similarity index 100% rename from src/plugins/teleop/Teleop.hh rename to src/plugins/Teleop/Teleop.hh diff --git a/src/plugins/teleop/Teleop.qml b/src/plugins/Teleop/Teleop.qml similarity index 100% rename from src/plugins/teleop/Teleop.qml rename to src/plugins/Teleop/Teleop.qml diff --git a/src/plugins/teleop/Teleop.qrc b/src/plugins/Teleop/Teleop.qrc similarity index 100% rename from src/plugins/teleop/Teleop.qrc rename to src/plugins/Teleop/Teleop.qrc diff --git a/src/plugins/teleop/Teleop_TEST.cc b/src/plugins/Teleop/Teleop_TEST.cc similarity index 100% rename from src/plugins/teleop/Teleop_TEST.cc rename to src/plugins/Teleop/Teleop_TEST.cc diff --git a/src/plugins/topic_echo/CMakeLists.txt b/src/plugins/TopicEcho/CMakeLists.txt similarity index 83% rename from src/plugins/topic_echo/CMakeLists.txt rename to src/plugins/TopicEcho/CMakeLists.txt index 92a8151b2..0ec62fa23 100644 --- a/src/plugins/topic_echo/CMakeLists.txt +++ b/src/plugins/TopicEcho/CMakeLists.txt @@ -5,4 +5,6 @@ gz_gui_add_plugin(TopicEcho TopicEcho.hh TEST_SOURCES TopicEcho_TEST.cc + QML_URI + TopicEcho ) diff --git a/src/plugins/topic_echo/TopicEcho.cc b/src/plugins/TopicEcho/TopicEcho.cc similarity index 100% rename from src/plugins/topic_echo/TopicEcho.cc rename to src/plugins/TopicEcho/TopicEcho.cc diff --git a/src/plugins/topic_echo/TopicEcho.hh b/src/plugins/TopicEcho/TopicEcho.hh similarity index 100% rename from src/plugins/topic_echo/TopicEcho.hh rename to src/plugins/TopicEcho/TopicEcho.hh diff --git a/src/plugins/topic_echo/TopicEcho.qml b/src/plugins/TopicEcho/TopicEcho.qml similarity index 100% rename from src/plugins/topic_echo/TopicEcho.qml rename to src/plugins/TopicEcho/TopicEcho.qml diff --git a/src/plugins/topic_echo/TopicEcho.qrc b/src/plugins/TopicEcho/TopicEcho.qrc similarity index 100% rename from src/plugins/topic_echo/TopicEcho.qrc rename to src/plugins/TopicEcho/TopicEcho.qrc diff --git a/src/plugins/topic_echo/TopicEcho_TEST.cc b/src/plugins/TopicEcho/TopicEcho_TEST.cc similarity index 100% rename from src/plugins/topic_echo/TopicEcho_TEST.cc rename to src/plugins/TopicEcho/TopicEcho_TEST.cc diff --git a/src/plugins/topic_viewer/CMakeLists.txt b/src/plugins/TopicViewer/CMakeLists.txt similarity index 86% rename from src/plugins/topic_viewer/CMakeLists.txt rename to src/plugins/TopicViewer/CMakeLists.txt index bdb5e564a..7603f0ece 100644 --- a/src/plugins/topic_viewer/CMakeLists.txt +++ b/src/plugins/TopicViewer/CMakeLists.txt @@ -7,4 +7,6 @@ gz_gui_add_plugin(TopicViewer TopicViewer_TEST.cc PUBLIC_LINK_LIBS # ${} + QML_URI + TopicViewer ) diff --git a/src/plugins/topic_viewer/TopicViewer.cc b/src/plugins/TopicViewer/TopicViewer.cc similarity index 100% rename from src/plugins/topic_viewer/TopicViewer.cc rename to src/plugins/TopicViewer/TopicViewer.cc diff --git a/src/plugins/topic_viewer/TopicViewer.hh b/src/plugins/TopicViewer/TopicViewer.hh similarity index 100% rename from src/plugins/topic_viewer/TopicViewer.hh rename to src/plugins/TopicViewer/TopicViewer.hh diff --git a/src/plugins/topic_viewer/TopicViewer.qml b/src/plugins/TopicViewer/TopicViewer.qml similarity index 100% rename from src/plugins/topic_viewer/TopicViewer.qml rename to src/plugins/TopicViewer/TopicViewer.qml diff --git a/src/plugins/topic_viewer/TopicViewer.qrc b/src/plugins/TopicViewer/TopicViewer.qrc similarity index 100% rename from src/plugins/topic_viewer/TopicViewer.qrc rename to src/plugins/TopicViewer/TopicViewer.qrc diff --git a/src/plugins/topic_viewer/TopicViewer_TEST.cc b/src/plugins/TopicViewer/TopicViewer_TEST.cc similarity index 100% rename from src/plugins/topic_viewer/TopicViewer_TEST.cc rename to src/plugins/TopicViewer/TopicViewer_TEST.cc diff --git a/src/plugins/topic_viewer/minus.png b/src/plugins/TopicViewer/minus.png similarity index 100% rename from src/plugins/topic_viewer/minus.png rename to src/plugins/TopicViewer/minus.png diff --git a/src/plugins/topic_viewer/plottable_icon.svg b/src/plugins/TopicViewer/plottable_icon.svg similarity index 100% rename from src/plugins/topic_viewer/plottable_icon.svg rename to src/plugins/TopicViewer/plottable_icon.svg diff --git a/src/plugins/topic_viewer/plus.png b/src/plugins/TopicViewer/plus.png similarity index 100% rename from src/plugins/topic_viewer/plus.png rename to src/plugins/TopicViewer/plus.png diff --git a/src/plugins/transport_scene_manager/CMakeLists.txt b/src/plugins/TransportSceneManager/CMakeLists.txt similarity index 64% rename from src/plugins/transport_scene_manager/CMakeLists.txt rename to src/plugins/TransportSceneManager/CMakeLists.txt index 31bef19dd..8f4ed86c2 100644 --- a/src/plugins/transport_scene_manager/CMakeLists.txt +++ b/src/plugins/TransportSceneManager/CMakeLists.txt @@ -6,6 +6,7 @@ gz_gui_add_plugin(TransportSceneManager TEST_SOURCES # TransportSceneManager_TEST.cc PUBLIC_LINK_LIBS - gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} + gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} + QML_URI + TransportSceneManager ) - diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.cc b/src/plugins/TransportSceneManager/TransportSceneManager.cc similarity index 100% rename from src/plugins/transport_scene_manager/TransportSceneManager.cc rename to src/plugins/TransportSceneManager/TransportSceneManager.cc diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.hh b/src/plugins/TransportSceneManager/TransportSceneManager.hh similarity index 100% rename from src/plugins/transport_scene_manager/TransportSceneManager.hh rename to src/plugins/TransportSceneManager/TransportSceneManager.hh diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.qml b/src/plugins/TransportSceneManager/TransportSceneManager.qml similarity index 100% rename from src/plugins/transport_scene_manager/TransportSceneManager.qml rename to src/plugins/TransportSceneManager/TransportSceneManager.qml diff --git a/src/plugins/transport_scene_manager/TransportSceneManager.qrc b/src/plugins/TransportSceneManager/TransportSceneManager.qrc similarity index 100% rename from src/plugins/transport_scene_manager/TransportSceneManager.qrc rename to src/plugins/TransportSceneManager/TransportSceneManager.qrc diff --git a/src/plugins/world_control/CMakeLists.txt b/src/plugins/WorldControl/CMakeLists.txt similarity index 85% rename from src/plugins/world_control/CMakeLists.txt rename to src/plugins/WorldControl/CMakeLists.txt index 5d64eae5d..dfe7252c1 100644 --- a/src/plugins/world_control/CMakeLists.txt +++ b/src/plugins/WorldControl/CMakeLists.txt @@ -8,6 +8,8 @@ if (NOT MSVC) WorldControlEventListener.hh TEST_SOURCES WorldControl_TEST.cc + QML_URI + WorldControl ) else() gz_gui_add_plugin(WorldControl @@ -15,5 +17,7 @@ else() WorldControl.cc QT_HEADERS WorldControl.hh + QML_URI + WorldControl ) endif() diff --git a/src/plugins/world_control/WorldControl.cc b/src/plugins/WorldControl/WorldControl.cc similarity index 100% rename from src/plugins/world_control/WorldControl.cc rename to src/plugins/WorldControl/WorldControl.cc diff --git a/src/plugins/world_control/WorldControl.hh b/src/plugins/WorldControl/WorldControl.hh similarity index 100% rename from src/plugins/world_control/WorldControl.hh rename to src/plugins/WorldControl/WorldControl.hh diff --git a/src/plugins/world_control/WorldControl.qml b/src/plugins/WorldControl/WorldControl.qml similarity index 100% rename from src/plugins/world_control/WorldControl.qml rename to src/plugins/WorldControl/WorldControl.qml diff --git a/src/plugins/world_control/WorldControl.qrc b/src/plugins/WorldControl/WorldControl.qrc similarity index 100% rename from src/plugins/world_control/WorldControl.qrc rename to src/plugins/WorldControl/WorldControl.qrc diff --git a/src/plugins/world_control/WorldControlEventListener.cc b/src/plugins/WorldControl/WorldControlEventListener.cc similarity index 100% rename from src/plugins/world_control/WorldControlEventListener.cc rename to src/plugins/WorldControl/WorldControlEventListener.cc diff --git a/src/plugins/world_control/WorldControlEventListener.hh b/src/plugins/WorldControl/WorldControlEventListener.hh similarity index 100% rename from src/plugins/world_control/WorldControlEventListener.hh rename to src/plugins/WorldControl/WorldControlEventListener.hh diff --git a/src/plugins/world_control/WorldControl_TEST.cc b/src/plugins/WorldControl/WorldControl_TEST.cc similarity index 100% rename from src/plugins/world_control/WorldControl_TEST.cc rename to src/plugins/WorldControl/WorldControl_TEST.cc diff --git a/src/plugins/world_stats/CMakeLists.txt b/src/plugins/WorldStats/CMakeLists.txt similarity index 83% rename from src/plugins/world_stats/CMakeLists.txt rename to src/plugins/WorldStats/CMakeLists.txt index d4de14064..ba4bcf386 100644 --- a/src/plugins/world_stats/CMakeLists.txt +++ b/src/plugins/WorldStats/CMakeLists.txt @@ -5,5 +5,6 @@ gz_gui_add_plugin(WorldStats WorldStats.hh TEST_SOURCES WorldStats_TEST.cc + QML_URI + WorldStats ) - diff --git a/src/plugins/world_stats/WorldStats.cc b/src/plugins/WorldStats/WorldStats.cc similarity index 100% rename from src/plugins/world_stats/WorldStats.cc rename to src/plugins/WorldStats/WorldStats.cc diff --git a/src/plugins/world_stats/WorldStats.hh b/src/plugins/WorldStats/WorldStats.hh similarity index 100% rename from src/plugins/world_stats/WorldStats.hh rename to src/plugins/WorldStats/WorldStats.hh diff --git a/src/plugins/world_stats/WorldStats.qml b/src/plugins/WorldStats/WorldStats.qml similarity index 100% rename from src/plugins/world_stats/WorldStats.qml rename to src/plugins/WorldStats/WorldStats.qml diff --git a/src/plugins/world_stats/WorldStats.qrc b/src/plugins/WorldStats/WorldStats.qrc similarity index 100% rename from src/plugins/world_stats/WorldStats.qrc rename to src/plugins/WorldStats/WorldStats.qrc diff --git a/src/plugins/world_stats/WorldStats_TEST.cc b/src/plugins/WorldStats/WorldStats_TEST.cc similarity index 100% rename from src/plugins/world_stats/WorldStats_TEST.cc rename to src/plugins/WorldStats/WorldStats_TEST.cc diff --git a/src/plugins/grid_config/CMakeLists.txt b/src/plugins/grid_config/CMakeLists.txt deleted file mode 100644 index 101e6edee..000000000 --- a/src/plugins/grid_config/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -gz_gui_add_plugin(GridConfig - SOURCES - GridConfig.cc - QT_HEADERS - GridConfig.hh - PUBLIC_LINK_LIBS - gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} -) - -# Also install as Grid3D, which was a legacy plugin with a subset of features -install ( - FILES $ - RENAME ${CMAKE_SHARED_LIBRARY_PREFIX}Grid3D${CMAKE_SHARED_LIBRARY_SUFFIX} - DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) diff --git a/src/plugins/minimal_scene/CMakeLists.txt b/src/plugins/minimal_scene/CMakeLists.txt deleted file mode 100644 index 1785b781b..000000000 --- a/src/plugins/minimal_scene/CMakeLists.txt +++ /dev/null @@ -1,31 +0,0 @@ -set(SOURCES - MinimalScene.cc - MinimalScene.hh - MinimalSceneRhi.cc - MinimalSceneRhi.hh - MinimalSceneRhiOpenGL.cc - MinimalSceneRhiOpenGL.hh - MinimalSceneRhiVulkan.cc - MinimalSceneRhiVulkan.hh - EngineToQtInterface.cc - EngineToQtInterface.hh -) - -qt6_add_qml_module(MinimalScene - URI minimal_scene - VERSION 1.0 - SOURCES ${SOURCES} - QML_FILES MinimalScene.qml -) - -target_link_libraries(MinimalScene PRIVATE - gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} - gz-transport${GZ_TRANSPORT_VER}::gz-transport${GZ_TRANSPORT_VER} - gz-plugin${GZ_PLUGIN_VER}::register - Qt6::Gui - Qt6::Widgets - Qt6::Quick - Qt6::QuickControls2 -) - -install (TARGETS MinimalScene DESTINATION ${GZ_GUI_PLUGIN_INSTALL_DIR}) From 861f35564b20e84568d194738f3486bd32e92551 Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Thu, 7 Dec 2023 14:42:25 +0000 Subject: [PATCH 25/33] Updating plugins Signed-off-by: Michael Carroll --- include/gz/gui/qml/GzCardSettings.qml | 2 +- src/Application.cc | 3 + src/Application_TEST.cc | 175 ++++++++++-------------- src/Dialog.cc | 20 +-- src/Helpers.cc | 2 + src/Plugin.cc | 1 - src/plugins/WorldControl/CMakeLists.txt | 4 + src/plugins/WorldStats/CMakeLists.txt | 2 + 8 files changed, 95 insertions(+), 114 deletions(-) diff --git a/include/gz/gui/qml/GzCardSettings.qml b/include/gz/gui/qml/GzCardSettings.qml index c31f534ec..b3e571203 100644 --- a/include/gz/gui/qml/GzCardSettings.qml +++ b/include/gz/gui/qml/GzCardSettings.qml @@ -209,7 +209,7 @@ Dialog { ColorDialog { id: colorDialog title: "Please choose a color" - options: [ColorDialog.ShowAlphaChannel] + options: ColorDialog.ShowAlphaChannel onAccepted: { content.color = colorDialog.color bgColor.color = colorDialog.color diff --git a/src/Application.cc b/src/Application.cc index 50fdaa97a..edcff3ad7 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -265,6 +265,9 @@ Application::~Application() } this->dataPtr->dialogs.clear(); + this->dataPtr->engine->clearComponentCache(); + this->dataPtr->engine->clearSingletons(); + delete this->dataPtr->engine; std::queue> empty; diff --git a/src/Application_TEST.cc b/src/Application_TEST.cc index cd9f97f51..5440fb708 100644 --- a/src/Application_TEST.cc +++ b/src/Application_TEST.cc @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -35,16 +36,23 @@ char* g_argv[] = using namespace gz; using namespace gui; -// See https://github.com/gazebosim/gz-gui/issues/75 -////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor)) +class ApplicationTest: public ::testing::Test { - common::Console::SetVerbosity(4); + protected: + void SetUp() override + { + common::Console::SetVerbosity(4); + // No Qt app + ASSERT_EQ(nullptr, qGuiApp); + ASSERT_EQ(nullptr, App()); + } +}; - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); - ASSERT_EQ(nullptr, App()); +// See https://github.com/gazebosim/gz-gui/issues/75 +////////////////////////////////////////////////// +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor)) +{ // One app construct - destruct { Application app(g_argc, g_argv); @@ -63,23 +71,16 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor)) } ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadPlugin)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadPlugin)) { - gz::common::Console::SetVerbosity(4); - - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); EXPECT_TRUE(app.LoadPlugin("Publisher")); } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadNonexistantPlugin)) { - gz::common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); EXPECT_FALSE(app.LoadPlugin("_doesnt_exist")); @@ -87,12 +88,10 @@ TEST(ApplicationTest, } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadProgrammaticPlugin)) { - gz::common::Console::SetVerbosity(4); // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); std::string pluginName; @@ -117,11 +116,8 @@ TEST(ApplicationTest, } ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadEnvPlugin)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadEnvPlugin)) { - gz::common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); setenv("TEST_ENV_VAR", @@ -131,12 +127,9 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadEnvPlugin)) } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadBadInheritancePlugin)) { - gz::common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); @@ -144,12 +137,9 @@ TEST(ApplicationTest, } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadNotRegisteredPlugin)) { - gz::common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); @@ -157,12 +147,9 @@ TEST(ApplicationTest, } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadInvalidQmlPlugin)) { - gz::common::Console::SetVerbosity(4); - // No Qt app - ASSERT_EQ(nullptr, qGuiApp); Application app(g_argc, g_argv); app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib"); @@ -170,12 +157,8 @@ TEST(ApplicationTest, } ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadConfig)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadConfig)) { - common::Console::SetVerbosity(4); - - ASSERT_EQ(nullptr, qGuiApp); - // Empty string { Application app(g_argc, g_argv); @@ -220,12 +203,8 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadConfig)) } ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadDefaultConfig)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadDefaultConfig)) { - common::Console::SetVerbosity(4); - - ASSERT_EQ(nullptr, qGuiApp); - // Test config file { Application app(g_argc, g_argv); @@ -245,12 +224,9 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadDefaultConfig)) } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindowSimple)) { - common::Console::SetVerbosity(4); - ASSERT_EQ(nullptr, qGuiApp); - // No plugins Application app(g_argc, g_argv); @@ -258,21 +234,20 @@ TEST(ApplicationTest, ASSERT_EQ(wins.size(), 1); // Close window after some time - QTimer::singleShot(300, wins[0], [&wins](){ - wins[0]->close(); - }); + QObject::connect(&app, &QGuiApplication::applicationStateChanged, + [&wins](auto /*state*/){ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + wins[0]->close(); + }); // Show window - app.exec(); + gz::gui::Application::exec(); } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindowPlugin)) { - common::Console::SetVerbosity(4); - ASSERT_EQ(nullptr, qGuiApp); - Application app(g_argc, g_argv); EXPECT_TRUE(app.LoadPlugin("Publisher")); @@ -285,25 +260,19 @@ TEST(ApplicationTest, EXPECT_EQ(1, plugins.count()); QObject::connect(&app, &QGuiApplication::applicationStateChanged, - [&win](auto state){ - std::cout << "State Changed, starting timer" << std::endl; - QTimer::singleShot(100, [&win](){ - win->QuickWindow()->close(); - }); - }); + [&win](auto /*state*/){ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + win->QuickWindow()->close(); + }); // Show window - app.exec(); - app.quit(); + gz::gui::Application::exec(); } ////////////////////////////////////////////////// -TEST(ApplicationTest, +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(InitializeMainWindowConfig)) { - common::Console::SetVerbosity(4); - ASSERT_EQ(nullptr, qGuiApp); - // Test config auto testBuildPath = std::string(PROJECT_BINARY_PATH) + "/lib/"; auto testSourcePath = std::string(PROJECT_SOURCE_PATH) + "/test/"; @@ -325,21 +294,19 @@ TEST(ApplicationTest, EXPECT_EQ(1, plugins.count()); // Close window after some time - QTimer::singleShot(1000, win, [&win](){ - win->QuickWindow()->close(); - }); + QObject::connect(&app, &QGuiApplication::applicationStateChanged, + [&win](auto /*state*/){ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + win->QuickWindow()->close(); + }); // Show window - app.exec(); + gz::gui::Application::exec(); } ////////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) { - common::Console::SetVerbosity(4); - - ASSERT_EQ(nullptr, qGuiApp); - // Single dialog { Application app(g_argc, g_argv, WindowType::kDialog); @@ -354,21 +321,23 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) // Close dialog after some time auto closed = false; - QTimer::singleShot(300, &app, [&] { - auto ds = app.allWindows(); - - // The main dialog - some systems return more, not sure why - ASSERT_GE(ds.size(), 1); - - EXPECT_TRUE(qobject_cast(ds[0])); - // Close - ds[0]->close(); - closed = true; + // Close window after some time + QObject::connect(&app, &QGuiApplication::applicationStateChanged, + [&closed](auto /*state*/){ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + auto ds = gz::gui::Application::allWindows(); + + // The main diaog - some systems return more, not sure why + ASSERT_GE(ds.size(), 1); + EXPECT_TRUE(qobject_cast(ds[0])); + // Close + ds[0]->close(); + closed = true; }); - // Exec dialog - app.exec(); + // Show window + gz::gui::Application::exec(); // Make sure timer was triggered EXPECT_TRUE(closed); @@ -389,19 +358,21 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) // Close dialogs after some time auto closed = false; - QTimer::singleShot(300, &app, [&] { - auto ds = app.allWindows(); + QObject::connect(&app, &QGuiApplication::applicationStateChanged, + [&closed](auto /*state*/){ + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + auto ds = gz::gui::Application::allWindows(); - // 2 dialog - some systems return more, not sure why - EXPECT_GE(ds.size(), 2); + // 2 dialog - some systems return more, not sure why + ASSERT_GE(ds.size(), 2); - for (auto dialog : ds) - dialog->close(); - closed = true; - }); + for (auto *dialog : ds) + dialog->close(); + closed = true; + }); // Exec dialog - app.exec(); + gz::gui::Application::exec(); // Make sure timer was triggered EXPECT_TRUE(closed); @@ -409,12 +380,8 @@ TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Dialog)) } ///////////////////////////////////////////////// -TEST(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(messageHandler)) +TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(messageHandler)) { - common::Console::SetVerbosity(4); - - ASSERT_EQ(nullptr, qGuiApp); - Application app(g_argc, g_argv); // \todo Verify output, see commmon::Console_TEST for example diff --git a/src/Dialog.cc b/src/Dialog.cc index 06e346c12..2da5a7665 100644 --- a/src/Dialog.cc +++ b/src/Dialog.cc @@ -22,6 +22,11 @@ #include "gz/gui/Application.hh" #include "gz/gui/Dialog.hh" +namespace +{ +constexpr const char* kQmlUri ="qrc:gz/gui/qml/StandaloneDialog.qml"; +} // namespace + namespace gz::gui { class Dialog::Implementation @@ -35,16 +40,15 @@ Dialog::Dialog() : dataPtr(gz::utils::MakeUniqueImpl()) { // Load QML and keep pointer to generated QQuickWindow - std::string qmlFile("qrc:qml/StandaloneDialog.qml"); - App()->Engine()->load(QUrl(QString::fromStdString(qmlFile))); + App()->Engine()->load(QUrl(QString(kQmlUri))); this->dataPtr->quickWindow = qobject_cast( App()->Engine()->rootObjects().value(0)); - if (!this->dataPtr->quickWindow) + if (this->dataPtr->quickWindow == nullptr) { // We'd only get here if the QML file is malformed // LCOV_EXCL_START - gzerr << "Internal error: Failed to instantiate QML file [" << qmlFile + gzerr << "Internal error: Failed to instantiate QML file [" << kQmlUri << "]" << std::endl; // LCOV_EXCL_STOP } @@ -62,8 +66,8 @@ QQuickWindow *Dialog::QuickWindow() const ///////////////////////////////////////////////// QQuickItem *Dialog::RootItem() const { - auto dialogItem = this->dataPtr->quickWindow->findChild(); - if (!dialogItem) + auto *dialogItem = this->dataPtr->quickWindow->findChild(); + if (dialogItem == nullptr) { // We'd only get here if the QML file is malformed // LCOV_EXCL_START @@ -96,7 +100,7 @@ bool Dialog::UpdateConfigAttribute(const std::string &_path, // Update attribute value for the correct dialog bool updated{false}; - for (auto dialogElem = doc.FirstChildElement("dialog"); + for (auto *dialogElem = doc.FirstChildElement("dialog"); dialogElem != nullptr; dialogElem = dialogElem->NextSiblingElement("dialog")) { @@ -110,7 +114,7 @@ bool Dialog::UpdateConfigAttribute(const std::string &_path, // Create new if missing if (!updated) { - auto dialogElem = doc.NewElement("dialog"); + auto *dialogElem = doc.NewElement("dialog"); dialogElem->SetAttribute("name", this->objectName().toStdString().c_str()); dialogElem->SetAttribute(_attribute.c_str(), _value); doc.InsertEndChild(dialogElem); diff --git a/src/Helpers.cc b/src/Helpers.cc index d6164e7d6..42ca922f3 100644 --- a/src/Helpers.cc +++ b/src/Helpers.cc @@ -172,6 +172,8 @@ std::string uniqueFilePath(const std::string &_pathAndName, ///////////////////////////////////////////////// QStringList worldNames() { + auto app = gz::gui::App(); + auto win = App()->findChild(); if (nullptr == win) return {}; diff --git a/src/Plugin.cc b/src/Plugin.cc index 4bd83a959..0731aaa81 100644 --- a/src/Plugin.cc +++ b/src/Plugin.cc @@ -125,7 +125,6 @@ void Plugin::Load(const tinyxml2::XMLElement *_pluginElem) // Qml file auto filename = QString::fromStdString(_pluginElem->Attribute("filename")); - // Instantiate plugin QML file into a component auto qmlFile = ":/" + filename + "/" + filename + ".qml"; if (!QFile(qmlFile).exists()) diff --git a/src/plugins/WorldControl/CMakeLists.txt b/src/plugins/WorldControl/CMakeLists.txt index dfe7252c1..4745253f5 100644 --- a/src/plugins/WorldControl/CMakeLists.txt +++ b/src/plugins/WorldControl/CMakeLists.txt @@ -3,6 +3,8 @@ if (NOT MSVC) SOURCES WorldControl.cc WorldControlEventListener.cc + QML_SOURCES + WorldControl.qml QT_HEADERS WorldControl.hh WorldControlEventListener.hh @@ -19,5 +21,7 @@ else() WorldControl.hh QML_URI WorldControl + QML_SOURCES + WorldControl.qml ) endif() diff --git a/src/plugins/WorldStats/CMakeLists.txt b/src/plugins/WorldStats/CMakeLists.txt index ba4bcf386..adf2f48d8 100644 --- a/src/plugins/WorldStats/CMakeLists.txt +++ b/src/plugins/WorldStats/CMakeLists.txt @@ -3,6 +3,8 @@ gz_gui_add_plugin(WorldStats WorldStats.cc QT_HEADERS WorldStats.hh + QML_SOURCES + WorldStats.qml TEST_SOURCES WorldStats_TEST.cc QML_URI From 2ec0c0716cfada67d25239d36f3913d66ad4999b Mon Sep 17 00:00:00 2001 From: Michael Carroll Date: Mon, 29 Jan 2024 19:16:33 +0000 Subject: [PATCH 26/33] Fix installation Signed-off-by: Michael Carroll --- include/gz/gui/CMakeLists.txt | 10 ++++++++++ src/Application_TEST.cc | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/include/gz/gui/CMakeLists.txt b/include/gz/gui/CMakeLists.txt index 34a42c02b..020c520a5 100644 --- a/include/gz/gui/CMakeLists.txt +++ b/include/gz/gui/CMakeLists.txt @@ -70,6 +70,16 @@ if (QT_MAJOR_VERSION EQUAL 6) "${GZ_CMAKE_DIR}/Export.hh.in" "${PROJECT_BINARY_DIR}/include/gz/gui/Export.hh") + install( + FILES "${PROJECT_BINARY_DIR}/include/gz/gui/Export.hh" + DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL}/Export.hh + COMPONENT headers) + + install( + FILES "${PROJECT_BINARY_DIR}/include/gz/gui/detail/Export.hh" + DESTINATION ${GZ_INCLUDE_INSTALL_DIR_FULL}/detail/Export.hh + COMPONENT headers) + target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} PUBLIC $ diff --git a/src/Application_TEST.cc b/src/Application_TEST.cc index 5440fb708..1344bf322 100644 --- a/src/Application_TEST.cc +++ b/src/Application_TEST.cc @@ -53,6 +53,12 @@ class ApplicationTest: public ::testing::Test ////////////////////////////////////////////////// TEST_F(ApplicationTest, GZ_UTILS_TEST_ENABLED_ONLY_ON_LINUX(Constructor)) { + + QDirIterator it(":", QDirIterator::Subdirectories); + while (it.hasNext()) { + std::cout << it.next().toStdString() << "\n"; + } + // One app construct - destruct { Application app(g_argc, g_argv); From bcf1e09cbd8f256ec994367cd28064025f3a0315 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 10 Jul 2024 18:40:48 +0200 Subject: [PATCH 27/33] Updates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- CMakeLists.txt | 2 +- .../custom_context_menu/CustomContext.qml | 4 +-- .../dialog_from_plugin/DialogFromPlugin.qml | 8 +++--- .../plugin/gz_components/GzComponents.qml | 6 ++--- examples/plugin/hello_plugin/HelloPlugin.qml | 4 +-- examples/plugin/multiple_qml/MultipleQml.qml | 4 +-- .../standalone/custom_drawer/CustomDrawer.qml | 6 ++--- .../standalone/start_dialog/start_dialog.qml | 4 +-- include/gz/gui/CMakeLists.txt | 13 +++++++++- include/gz/gui/qml/GzPose.qml | 14 +++++------ include/gz/gui/qml/PlottingInterface.qml | 2 +- src/plugins/CameraFps/CameraFps.qml | 6 ++--- src/plugins/CameraTracking/CameraTracking.qml | 6 ++--- src/plugins/GridConfig/GridConfig.qml | 12 ++++----- src/plugins/ImageDisplay/ImageDisplay.qml | 8 +++--- .../InteractiveViewControl.qml | 6 ++--- src/plugins/KeyPublisher/KeyPublisher.qml | 6 ++--- src/plugins/MarkerManager/MarkerManager.qml | 6 ++--- src/plugins/NavsatMap/NavSatMap.qml | 12 ++++----- src/plugins/Plotting/TransportPlotting.qml | 8 +++--- src/plugins/PointCloud/PointCloud.qml | 14 +++++------ src/plugins/Publisher/Publisher.qml | 6 ++--- src/plugins/Screenshot/CMakeLists.txt | 2 ++ src/plugins/Screenshot/Screenshot.qml | 25 ++++++++----------- src/plugins/ShutdownButton/ShutdownButton.qml | 8 +++--- src/plugins/TapeMeasure/TapeMeasure.qml | 16 ++++++------ src/plugins/Teleop/Teleop.qml | 12 ++++----- src/plugins/TopicEcho/TopicEcho.qml | 6 ++--- src/plugins/TopicViewer/TopicViewer.qml | 2 +- .../TransportSceneManager.qml | 6 ++--- src/plugins/WorldControl/WorldControl.qml | 12 ++++----- src/plugins/WorldStats/WorldStats.qml | 8 +++--- test/plugins/TestInvalidQmlPlugin.qml | 2 +- test/plugins/TestPlugin.qml | 2 +- 34 files changed, 133 insertions(+), 125 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ac71f9ac8..4a28ab2a5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,7 +82,7 @@ set(GZ_TOOLS_VER 2) #-------------------------------------- # Find QT set(QT_MAJOR_VERSION 6) -set(QT_MINOR_VERSION 0) +set(QT_MINOR_VERSION 4) gz_find_package (Qt${QT_MAJOR_VERSION} VERSION ${QT_MAJOR_VERSION}.${QT_MINOR_VERSION} COMPONENTS diff --git a/examples/plugin/custom_context_menu/CustomContext.qml b/examples/plugin/custom_context_menu/CustomContext.qml index bf0f0d15a..9bdcd9b8e 100644 --- a/examples/plugin/custom_context_menu/CustomContext.qml +++ b/examples/plugin/custom_context_menu/CustomContext.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.0 -import QtQuick.Controls 2.0 +import QtQuick +import QtQuick.Controls Rectangle { id: customContext diff --git a/examples/plugin/dialog_from_plugin/DialogFromPlugin.qml b/examples/plugin/dialog_from_plugin/DialogFromPlugin.qml index f1bd575b9..5ca8aa72f 100644 --- a/examples/plugin/dialog_from_plugin/DialogFromPlugin.qml +++ b/examples/plugin/dialog_from_plugin/DialogFromPlugin.qml @@ -14,10 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Dialogs 1.0 -import QtQuick.Window 2.2 +import QtQuick +import QtQuick.Controls +import QtQuick.Dialogs +import QtQuick.Window Rectangle { id: customPlugin diff --git a/examples/plugin/gz_components/GzComponents.qml b/examples/plugin/gz_components/GzComponents.qml index 7a7fd7997..73c22f5e1 100644 --- a/examples/plugin/gz_components/GzComponents.qml +++ b/examples/plugin/gz_components/GzComponents.qml @@ -14,9 +14,9 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.0 -import gz.gui 1.0 +import QtQuick +import QtQuick.Controls +import gz.gui Column { anchors.fill: parent diff --git a/examples/plugin/hello_plugin/HelloPlugin.qml b/examples/plugin/hello_plugin/HelloPlugin.qml index 4d4dafc7a..acaf6629d 100644 --- a/examples/plugin/hello_plugin/HelloPlugin.qml +++ b/examples/plugin/hello_plugin/HelloPlugin.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.0 -import QtQuick.Controls 2.0 +import QtQuick +import QtQuick.Controls Rectangle { color: "transparent" anchors.fill: parent diff --git a/examples/plugin/multiple_qml/MultipleQml.qml b/examples/plugin/multiple_qml/MultipleQml.qml index 2063565c2..2d9892485 100644 --- a/examples/plugin/multiple_qml/MultipleQml.qml +++ b/examples/plugin/multiple_qml/MultipleQml.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.0 -import QtQuick.Controls 2.0 +import QtQuick +import QtQuick.Controls import "qrc:/MultipleQml_qml" Column { diff --git a/examples/standalone/custom_drawer/CustomDrawer.qml b/examples/standalone/custom_drawer/CustomDrawer.qml index dcbf089a5..e6d2b05b0 100644 --- a/examples/standalone/custom_drawer/CustomDrawer.qml +++ b/examples/standalone/custom_drawer/CustomDrawer.qml @@ -14,9 +14,9 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material /** * Custom drawer diff --git a/examples/standalone/start_dialog/start_dialog.qml b/examples/standalone/start_dialog/start_dialog.qml index a07f4ff52..645a0c5b4 100644 --- a/examples/standalone/start_dialog/start_dialog.qml +++ b/examples/standalone/start_dialog/start_dialog.qml @@ -14,8 +14,8 @@ * limitations under the License. * */ -import QtQuick 2.0 -import QtQuick.Controls 2.0 +import QtQuick +import QtQuick.Controls Rectangle { color: "green" anchors.fill: parent diff --git a/include/gz/gui/CMakeLists.txt b/include/gz/gui/CMakeLists.txt index 62a853c72..e291ea1a5 100644 --- a/include/gz/gui/CMakeLists.txt +++ b/include/gz/gui/CMakeLists.txt @@ -83,9 +83,20 @@ if (QT_MAJOR_VERSION EQUAL 6) target_include_directories(${PROJECT_LIBRARY_TARGET_NAME} PUBLIC $ - $ + $ ) + install( + TARGETS ${PROJECT_LIBRARY_TARGET_NAME} + EXPORT ${PROJECT_LIBRARY_TARGET_NAME} + LIBRARY DESTINATION ${GZ_LIB_INSTALL_DIR} + ARCHIVE DESTINATION ${GZ_LIB_INSTALL_DIR} + RUNTIME DESTINATION ${GZ_BIN_INSTALL_DIR} + COMPONENT libraries) + + _gz_create_cmake_package() + _gz_create_pkgconfig() + else() set (resources resources.qrc) qt_wrap_cpp(headers_MOC ${qt_headers}) diff --git a/include/gz/gui/qml/GzPose.qml b/include/gz/gui/qml/GzPose.qml index d883e107d..8951464b6 100644 --- a/include/gz/gui/qml/GzPose.qml +++ b/include/gz/gui/qml/GzPose.qml @@ -15,9 +15,7 @@ * */ import QtQuick -import QtQuick.Control -import QtQuick.Layout -import QtQuick.Controls.Styles +import QtQuick.Layouts /** * Item displaying 3D pose information. @@ -80,7 +78,7 @@ Item { signal gzPoseSet(double _x, double _y, double _z, double _roll, double _pitch, double _yaw) // Maximum spinbox value - property double spinMax: Number.MAX_VALUE + property int spinMax: Number.MAX_VALUE // Expand/Collapse of this widget property bool expand: true @@ -121,10 +119,10 @@ Item { GzSpinBox { id: writableSpin value: numberValue - minimumValue: -spinMax - maximumValue: spinMax - decimals: gzHelper.getDecimals(writableSpin.width) - onEditingFinished: { + from: -spinMax + to: spinMax + //decimals: gzHelper.getDecimals(writableSpin.width) + onValueChanged: { gzPoseRoot.gzPoseSet(xItem.value, yItem.value, zItem.value, rollItem.value, pitchItem.value, yawItem.value) } diff --git a/include/gz/gui/qml/PlottingInterface.qml b/include/gz/gui/qml/PlottingInterface.qml index dd97bea43..ea9892050 100644 --- a/include/gz/gui/qml/PlottingInterface.qml +++ b/include/gz/gui/qml/PlottingInterface.qml @@ -21,7 +21,7 @@ import QtQuick.Controls.Styles import QtQuick.Controls.Material import QtQuick.Layouts import Qt.labs.platform -import "qrc:/qml" +import "qrc:/gz/gui/qml" Rectangle { diff --git a/src/plugins/CameraFps/CameraFps.qml b/src/plugins/CameraFps/CameraFps.qml index 87c42f9e6..c4aa0b7f4 100644 --- a/src/plugins/CameraFps/CameraFps.qml +++ b/src/plugins/CameraFps/CameraFps.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Rectangle { id: cameraFps diff --git a/src/plugins/CameraTracking/CameraTracking.qml b/src/plugins/CameraTracking/CameraTracking.qml index 09c339f0b..87315fa3f 100644 --- a/src/plugins/CameraTracking/CameraTracking.qml +++ b/src/plugins/CameraTracking/CameraTracking.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts ColumnLayout { Layout.minimumWidth: 350 diff --git a/src/plugins/GridConfig/GridConfig.qml b/src/plugins/GridConfig/GridConfig.qml index 36e46b7d0..7a4fc86aa 100644 --- a/src/plugins/GridConfig/GridConfig.qml +++ b/src/plugins/GridConfig/GridConfig.qml @@ -14,12 +14,12 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Controls.Material 2.1 -import QtQuick.Dialogs 1.0 -import QtQuick.Layouts 1.3 -import "qrc:/qml" +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Dialogs +import QtQuick.Layouts +import "qrc:/gz/gui/qml" GridLayout { columns: 4 diff --git a/src/plugins/ImageDisplay/ImageDisplay.qml b/src/plugins/ImageDisplay/ImageDisplay.qml index 48d1191a6..0e6f5e47b 100644 --- a/src/plugins/ImageDisplay/ImageDisplay.qml +++ b/src/plugins/ImageDisplay/ImageDisplay.qml @@ -14,10 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts Rectangle { id: "imageDisplay" diff --git a/src/plugins/InteractiveViewControl/InteractiveViewControl.qml b/src/plugins/InteractiveViewControl/InteractiveViewControl.qml index c75206185..a2b9fe1f9 100644 --- a/src/plugins/InteractiveViewControl/InteractiveViewControl.qml +++ b/src/plugins/InteractiveViewControl/InteractiveViewControl.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts ColumnLayout { Layout.minimumWidth: 350 diff --git a/src/plugins/KeyPublisher/KeyPublisher.qml b/src/plugins/KeyPublisher/KeyPublisher.qml index e08a9eedd..499ff4744 100644 --- a/src/plugins/KeyPublisher/KeyPublisher.qml +++ b/src/plugins/KeyPublisher/KeyPublisher.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts GridLayout { columns: 1 diff --git a/src/plugins/MarkerManager/MarkerManager.qml b/src/plugins/MarkerManager/MarkerManager.qml index a2cd4b0ca..45b2d2c67 100644 --- a/src/plugins/MarkerManager/MarkerManager.qml +++ b/src/plugins/MarkerManager/MarkerManager.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts ColumnLayout { Layout.minimumWidth: 350 diff --git a/src/plugins/NavsatMap/NavSatMap.qml b/src/plugins/NavsatMap/NavSatMap.qml index 3e7659b29..8720d678f 100644 --- a/src/plugins/NavsatMap/NavSatMap.qml +++ b/src/plugins/NavsatMap/NavSatMap.qml @@ -14,12 +14,12 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Material 2.1 -import QtLocation 5.6 -import QtPositioning 5.6 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import QtQuick.Controls.Material +import QtLocation +import QtPositioning Item { id: navSatMap diff --git a/src/plugins/Plotting/TransportPlotting.qml b/src/plugins/Plotting/TransportPlotting.qml index cfafbba10..8ae9ae0e6 100644 --- a/src/plugins/Plotting/TransportPlotting.qml +++ b/src/plugins/Plotting/TransportPlotting.qml @@ -14,11 +14,11 @@ * limitations under the License. * */ -import QtQuick 2.0 -import QtQuick.Controls 1.4 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts -import "qrc:/qml" +import "qrc:/gz/gui/qml" PlottingInterface { Layout.minimumWidth: 600 diff --git a/src/plugins/PointCloud/PointCloud.qml b/src/plugins/PointCloud/PointCloud.qml index 9aa248092..fe117516f 100644 --- a/src/plugins/PointCloud/PointCloud.qml +++ b/src/plugins/PointCloud/PointCloud.qml @@ -15,13 +15,13 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Dialogs 1.0 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 -import gz.gui 1.0 -import "qrc:/qml" +import QtQuick +import QtQuick.Controls +import QtQuick.Dialogs +import QtQuick.Controls.Material +import QtQuick.Layouts +import gz.gui +import "qrc:/gz/gui/qml" ColumnLayout { spacing: 10 diff --git a/src/plugins/Publisher/Publisher.qml b/src/plugins/Publisher/Publisher.qml index 2bc2fc93f..a33b31c09 100644 --- a/src/plugins/Publisher/Publisher.qml +++ b/src/plugins/Publisher/Publisher.qml @@ -14,9 +14,9 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Rectangle { id: publisher diff --git a/src/plugins/Screenshot/CMakeLists.txt b/src/plugins/Screenshot/CMakeLists.txt index 640b0b856..9a64146f8 100644 --- a/src/plugins/Screenshot/CMakeLists.txt +++ b/src/plugins/Screenshot/CMakeLists.txt @@ -3,6 +3,8 @@ gz_gui_add_plugin(Screenshot Screenshot.cc QT_HEADERS Screenshot.hh + QML_SOURCES + Screenshot.qml PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} TEST_SOURCES diff --git a/src/plugins/Screenshot/Screenshot.qml b/src/plugins/Screenshot/Screenshot.qml index 97c6347b6..f680c449a 100644 --- a/src/plugins/Screenshot/Screenshot.qml +++ b/src/plugins/Screenshot/Screenshot.qml @@ -14,13 +14,12 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Controls.Material 2.2 -import QtQuick.Controls.Material.impl 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Dialogs 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Controls.Material.impl +import QtQuick.Layouts +import QtQuick.Dialogs ToolBar { Layout.minimumWidth: 200 @@ -65,18 +64,16 @@ ToolBar { sourceSize.height: 40 } onClicked: { - fileDialog.open() + folderDialog.open() } } - FileDialog { - id: fileDialog + FolderDialog { + id: folderDialog title: "Save screenshots" - folder: Screenshot.directory - selectExisting: false - selectFolder: true + currentFolder: Screenshot.directory onAccepted: { - Screenshot.SetDirectory(fileDialog.folder) + Screenshot.SetDirectory(folderDialog.folder) close() } } diff --git a/src/plugins/ShutdownButton/ShutdownButton.qml b/src/plugins/ShutdownButton/ShutdownButton.qml index 8fbf5424c..e38800c34 100644 --- a/src/plugins/ShutdownButton/ShutdownButton.qml +++ b/src/plugins/ShutdownButton/ShutdownButton.qml @@ -14,10 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts RowLayout { id: shutdownButton diff --git a/src/plugins/TapeMeasure/TapeMeasure.qml b/src/plugins/TapeMeasure/TapeMeasure.qml index 29362bcf0..3e2315a2d 100644 --- a/src/plugins/TapeMeasure/TapeMeasure.qml +++ b/src/plugins/TapeMeasure/TapeMeasure.qml @@ -14,14 +14,14 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Window 2.2 -import QtQuick.Controls 2.1 -import QtQuick.Controls.Material 2.2 -import QtQuick.Controls.Material.impl 2.2 -import QtQuick.Layouts 1.3 -import QtQuick.Controls.Styles 1.4 -import "qrc:/qml" +import QtQuick +import QtQuick.Window +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Controls.Material.impl +import QtQuick.Layouts +import QtQuick.Controls.Styles +import "qrc:/gz/gui/qml" ToolBar { id: tapeMeasure diff --git a/src/plugins/Teleop/Teleop.qml b/src/plugins/Teleop/Teleop.qml index 4a4fc06e8..d27405c13 100644 --- a/src/plugins/Teleop/Teleop.qml +++ b/src/plugins/Teleop/Teleop.qml @@ -15,12 +15,12 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Controls.Styles 1.4 -import QtQuick.Layouts 1.3 -import gz.gui 1.0 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Controls.Styles +import QtQuick.Layouts +import gz.gui ColumnLayout { Layout.minimumWidth: 400 diff --git a/src/plugins/TopicEcho/TopicEcho.qml b/src/plugins/TopicEcho/TopicEcho.qml index ceef81322..8419bad0e 100644 --- a/src/plugins/TopicEcho/TopicEcho.qml +++ b/src/plugins/TopicEcho/TopicEcho.qml @@ -14,9 +14,9 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts Rectangle { id: topicEcho diff --git a/src/plugins/TopicViewer/TopicViewer.qml b/src/plugins/TopicViewer/TopicViewer.qml index 8090de350..26947a80b 100644 --- a/src/plugins/TopicViewer/TopicViewer.qml +++ b/src/plugins/TopicViewer/TopicViewer.qml @@ -14,7 +14,7 @@ * limitations under the License. * */ -import QtQml.Models 2.2 +import QtQml.Models import QtQuick import QtQuick.Controls import QtQuick.Layouts diff --git a/src/plugins/TransportSceneManager/TransportSceneManager.qml b/src/plugins/TransportSceneManager/TransportSceneManager.qml index adfbf7a85..af27bc3f1 100644 --- a/src/plugins/TransportSceneManager/TransportSceneManager.qml +++ b/src/plugins/TransportSceneManager/TransportSceneManager.qml @@ -15,9 +15,9 @@ * */ -import QtQuick 2.9 -import QtQuick.Controls 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts GridLayout { columns: 1 diff --git a/src/plugins/WorldControl/WorldControl.qml b/src/plugins/WorldControl/WorldControl.qml index 9cf54c98e..da35ae557 100644 --- a/src/plugins/WorldControl/WorldControl.qml +++ b/src/plugins/WorldControl/WorldControl.qml @@ -14,11 +14,11 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.5 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 -import "qrc:/qml" +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts +import "qrc:/gz/gui/qml" RowLayout { id: worldControl @@ -179,7 +179,7 @@ RowLayout { } GzSpinBox { - maximumValue: 10000 + to: 10000 Layout.alignment: Qt.AlignVCenter value: 1 onValueChanged: { diff --git a/src/plugins/WorldStats/WorldStats.qml b/src/plugins/WorldStats/WorldStats.qml index ef8cf673f..e7e360ec7 100644 --- a/src/plugins/WorldStats/WorldStats.qml +++ b/src/plugins/WorldStats/WorldStats.qml @@ -14,10 +14,10 @@ * limitations under the License. * */ -import QtQuick 2.9 -import QtQuick.Controls 2.2 -import QtQuick.Controls.Material 2.1 -import QtQuick.Layouts 1.3 +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.Material +import QtQuick.Layouts Rectangle { id: worldStats diff --git a/test/plugins/TestInvalidQmlPlugin.qml b/test/plugins/TestInvalidQmlPlugin.qml index 17cdc890e..4e3f55a52 100644 --- a/test/plugins/TestInvalidQmlPlugin.qml +++ b/test/plugins/TestInvalidQmlPlugin.qml @@ -14,7 +14,7 @@ * limitations under the License. * */ -import QtQuick 2.9 +import QtQuick Rectangle { banana: fail diff --git a/test/plugins/TestPlugin.qml b/test/plugins/TestPlugin.qml index be4596d8f..2c57d9827 100644 --- a/test/plugins/TestPlugin.qml +++ b/test/plugins/TestPlugin.qml @@ -14,7 +14,7 @@ * limitations under the License. * */ -import QtQuick 2.9 +import QtQuick Rectangle { color: "red" From 8db12771f1a68b3c068ab6d35e6377cc55c9d81d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Mon, 15 Jul 2024 22:03:21 +0200 Subject: [PATCH 28/33] OpenGL MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- src/Application.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Application.cc b/src/Application.cc index edcff3ad7..a767286e9 100644 --- a/src/Application.cc +++ b/src/Application.cc @@ -109,7 +109,7 @@ Application::Application(int &_argc, char **_argv, const WindowType _type, #ifdef __APPLE__ AvailableAPIs api = AvailableAPIs::Metal; #else - AvailableAPIs api = AvailableAPIs::Vulkan; + AvailableAPIs api = AvailableAPIs::OpenGL; #endif if (_renderEngineGuiApiBackend) { From 1f28e07fba70ce504582487949d9c109ef5dd4b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Fri, 19 Jul 2024 18:44:32 +0200 Subject: [PATCH 29/33] Plugin updates. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- include/gz/gui/qml/GzColor.qml | 4 +- include/gz/gui/qml/PlottingInterface.qml | 1 - src/plugins/GridConfig/GridConfig.qml | 24 +- src/plugins/MinimalScene/MinimalScene.qml | 2 +- src/plugins/NavsatMap/CMakeLists.txt | 2 + src/plugins/Plotting/CMakeLists.txt | 2 + src/plugins/PointCloud/CMakeLists.txt | 2 + src/plugins/PointCloud/PointCloud.qml | 7 +- src/plugins/ShutdownButton/CMakeLists.txt | 2 + src/plugins/TapeMeasure/CMakeLists.txt | 8 +- src/plugins/TapeMeasure/TapeMeasure.qml | 3 +- src/plugins/Teleop/CMakeLists.txt | 2 + src/plugins/Teleop/Teleop.qml | 32 +- src/plugins/TopicEcho/CMakeLists.txt | 2 + src/plugins/TopicViewer/CMakeLists.txt | 2 + src/plugins/TopicViewer/TopicViewer.qml | 318 +++++++++--------- .../TransportSceneManager/CMakeLists.txt | 2 + 17 files changed, 217 insertions(+), 198 deletions(-) diff --git a/include/gz/gui/qml/GzColor.qml b/include/gz/gui/qml/GzColor.qml index c02e404f7..327ebd1eb 100644 --- a/include/gz/gui/qml/GzColor.qml +++ b/include/gz/gui/qml/GzColor.qml @@ -55,7 +55,9 @@ Item { id: gzColorDialog title: "Choose a color" visible: false - showAlphaChannel: true + options: { + ShowAlphaChannel: true + } onAccepted: { r = gzColorDialog.color.r g = gzColorDialog.color.g diff --git a/include/gz/gui/qml/PlottingInterface.qml b/include/gz/gui/qml/PlottingInterface.qml index ea9892050..c3e834909 100644 --- a/include/gz/gui/qml/PlottingInterface.qml +++ b/include/gz/gui/qml/PlottingInterface.qml @@ -17,7 +17,6 @@ import QtQuick import QtCharts import QtQuick.Controls -import QtQuick.Controls.Styles import QtQuick.Controls.Material import QtQuick.Layouts import Qt.labs.platform diff --git a/src/plugins/GridConfig/GridConfig.qml b/src/plugins/GridConfig/GridConfig.qml index 7a4fc86aa..e67522174 100644 --- a/src/plugins/GridConfig/GridConfig.qml +++ b/src/plugins/GridConfig/GridConfig.qml @@ -112,10 +112,10 @@ GridLayout { Layout.columnSpan: 2 Layout.fillWidth: true id: verticalCellCount - maximumValue: Number.MAX_VALUE - minimumValue: 0 + to: Number.MAX_VALUE + from: 0 value: 0 - onEditingFinished: GridConfig.UpdateVCellCount(verticalCellCount.value) + onValueChanged: GridConfig.UpdateVCellCount(verticalCellCount.value) } Text { @@ -129,10 +129,10 @@ GridLayout { Layout.columnSpan: 2 Layout.fillWidth: true id: horizontalCellCount - maximumValue: Number.MAX_VALUE - minimumValue: 1 + to: Number.MAX_VALUE + from: 1 value: 20 - onEditingFinished: GridConfig.UpdateHCellCount(horizontalCellCount.value) + onValueChanged: GridConfig.UpdateHCellCount(horizontalCellCount.value) } Text { @@ -153,12 +153,12 @@ GridLayout { Layout.columnSpan: 2 Layout.fillWidth: true id: cellLength - maximumValue: Number.MAX_VALUE - minimumValue: 0.0000001 - value: 1.00 - decimals: gzHelpers.getDecimals(cellLength.width) - stepSize: 0.01 - onEditingFinished: GridConfig.UpdateCellLength(cellLength.value) + to: Number.MAX_VALUE + from: 0 + value: 1 + //decimals: gzHelpers.getDecimals(cellLength.width) + stepSize: 1 + onValueChanged: GridConfig.UpdateCellLength(cellLength.value) } Text { diff --git a/src/plugins/MinimalScene/MinimalScene.qml b/src/plugins/MinimalScene/MinimalScene.qml index 3c991f547..caafe9b3d 100644 --- a/src/plugins/MinimalScene/MinimalScene.qml +++ b/src/plugins/MinimalScene/MinimalScene.qml @@ -39,7 +39,7 @@ Rectangle { anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.NoButton - visible: MinimalScene.loadingError.length == 0 + visible: MinimalScene.loadingError.length === 0 onEntered: { MinimalScene.OnFocusWindow() } diff --git a/src/plugins/NavsatMap/CMakeLists.txt b/src/plugins/NavsatMap/CMakeLists.txt index 218776083..cd488b788 100644 --- a/src/plugins/NavsatMap/CMakeLists.txt +++ b/src/plugins/NavsatMap/CMakeLists.txt @@ -3,6 +3,8 @@ gz_gui_add_plugin(NavSatMap NavSatMap.cc QT_HEADERS NavSatMap.hh + QML_SOURCES + NavSatMap.qml QML_URI NavSatMap ) diff --git a/src/plugins/Plotting/CMakeLists.txt b/src/plugins/Plotting/CMakeLists.txt index 348ef9724..acb035389 100644 --- a/src/plugins/Plotting/CMakeLists.txt +++ b/src/plugins/Plotting/CMakeLists.txt @@ -3,6 +3,8 @@ gz_gui_add_plugin(TransportPlotting TransportPlotting.cc QT_HEADERS TransportPlotting.hh + QML_SOURCES + TransportPlotting.qml QML_URI TransportPlotting ) diff --git a/src/plugins/PointCloud/CMakeLists.txt b/src/plugins/PointCloud/CMakeLists.txt index b04f3f83d..60c845ab3 100644 --- a/src/plugins/PointCloud/CMakeLists.txt +++ b/src/plugins/PointCloud/CMakeLists.txt @@ -3,6 +3,8 @@ gz_gui_add_plugin(PointCloud PointCloud.cc QT_HEADERS PointCloud.hh + QML_SOURCES + PointCloud.qml PUBLIC_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} TEST_SOURCES diff --git a/src/plugins/PointCloud/PointCloud.qml b/src/plugins/PointCloud/PointCloud.qml index fe117516f..63c6b4c4c 100644 --- a/src/plugins/PointCloud/PointCloud.qml +++ b/src/plugins/PointCloud/PointCloud.qml @@ -121,10 +121,9 @@ ColumnLayout { GzSpinBox { id: pointSizeSpin value: PointCloud.pointSize - minimumValue: 1 - maximumValue: 1000 - decimals: 0 - onEditingFinished: { + from: 1 + to: 1000 + onValueChanged: { PointCloud.SetPointSize(pointSizeSpin.value) } } diff --git a/src/plugins/ShutdownButton/CMakeLists.txt b/src/plugins/ShutdownButton/CMakeLists.txt index 9375857d7..867ebda64 100644 --- a/src/plugins/ShutdownButton/CMakeLists.txt +++ b/src/plugins/ShutdownButton/CMakeLists.txt @@ -3,6 +3,8 @@ gz_gui_add_plugin(ShutdownButton ShutdownButton.cc QT_HEADERS ShutdownButton.hh + QML_SOURCES + ShutdownButton.qml TEST_SOURCES ShutdownButton_TEST.cc QML_URI diff --git a/src/plugins/TapeMeasure/CMakeLists.txt b/src/plugins/TapeMeasure/CMakeLists.txt index e206a57c1..9cd077723 100644 --- a/src/plugins/TapeMeasure/CMakeLists.txt +++ b/src/plugins/TapeMeasure/CMakeLists.txt @@ -1,6 +1,10 @@ gz_gui_add_plugin(TapeMeasure - SOURCES TapeMeasure.cc - QT_HEADERS TapeMeasure.hh + SOURCES + TapeMeasure.cc + QT_HEADERS + TapeMeasure.hh + QML_SOURCES + TapeMeasure.qml PRIVATE_LINK_LIBS gz-rendering${GZ_RENDERING_VER}::gz-rendering${GZ_RENDERING_VER} QML_URI diff --git a/src/plugins/TapeMeasure/TapeMeasure.qml b/src/plugins/TapeMeasure/TapeMeasure.qml index 3e2315a2d..f914cd21f 100644 --- a/src/plugins/TapeMeasure/TapeMeasure.qml +++ b/src/plugins/TapeMeasure/TapeMeasure.qml @@ -20,7 +20,6 @@ import QtQuick.Controls import QtQuick.Controls.Material import QtQuick.Controls.Material.impl import QtQuick.Layouts -import QtQuick.Controls.Styles import "qrc:/gz/gui/qml" ToolBar { @@ -28,7 +27,7 @@ ToolBar { Layout.minimumWidth: 250 Layout.minimumHeight: 100 - property var distance: 0.0 + property real distance: 0.0 function updateDistance() { distance = TapeMeasure.Distance(); diff --git a/src/plugins/Teleop/CMakeLists.txt b/src/plugins/Teleop/CMakeLists.txt index d99aac87a..2a71762b1 100644 --- a/src/plugins/Teleop/CMakeLists.txt +++ b/src/plugins/Teleop/CMakeLists.txt @@ -3,6 +3,8 @@ gz_gui_add_plugin(Teleop Teleop.cc QT_HEADERS Teleop.hh + QML_SOURCES + Teleop.qml TEST_SOURCES Teleop_TEST.cc QML_URI diff --git a/src/plugins/Teleop/Teleop.qml b/src/plugins/Teleop/Teleop.qml index d27405c13..278ce3fd0 100644 --- a/src/plugins/Teleop/Teleop.qml +++ b/src/plugins/Teleop/Teleop.qml @@ -18,9 +18,9 @@ import QtQuick import QtQuick.Controls import QtQuick.Controls.Material -import QtQuick.Controls.Styles import QtQuick.Layouts import gz.gui +import "qrc:/gz/gui/qml" ColumnLayout { Layout.minimumWidth: 400 @@ -123,11 +123,11 @@ ColumnLayout { id: maxForwardVelField Layout.fillWidth: true value: maxForwardVel - maximumValue: 10000.0 - minimumValue: 0.0 - decimals: 2 - stepSize: 0.10 - onEditingFinished:{ + to: 10000 + from: 0 + // decimals: 2 + stepSize: 1 + onValueChanged:{ Teleop.SetMaxForwardVel(value) } } @@ -142,11 +142,11 @@ ColumnLayout { id: maxVerticalVelField Layout.fillWidth: true value: maxVerticalVel - maximumValue: 10000.0 - minimumValue: 0.0 - decimals: 2 - stepSize: 0.10 - onEditingFinished:{ + to: 10000 + from: 0 + // decimals: 2 + stepSize: 1 + onValueChanged:{ Teleop.SetMaxVerticalVel(value) } } @@ -161,11 +161,11 @@ ColumnLayout { id: maxYawVelField Layout.fillWidth: true value: maxYawVel - maximumValue: 10000.0 - minimumValue: 0.0 - decimals: 2 - stepSize: 0.10 - onEditingFinished:{ + to: 10000 + from: 0 + // decimals: 2 + stepSize: 1 + onValueChanged:{ Teleop.SetMaxYawVel(value) } } diff --git a/src/plugins/TopicEcho/CMakeLists.txt b/src/plugins/TopicEcho/CMakeLists.txt index 0ec62fa23..f1327d52b 100644 --- a/src/plugins/TopicEcho/CMakeLists.txt +++ b/src/plugins/TopicEcho/CMakeLists.txt @@ -3,6 +3,8 @@ gz_gui_add_plugin(TopicEcho TopicEcho.cc QT_HEADERS TopicEcho.hh + QML_SOURCES + TopicEcho.qml TEST_SOURCES TopicEcho_TEST.cc QML_URI diff --git a/src/plugins/TopicViewer/CMakeLists.txt b/src/plugins/TopicViewer/CMakeLists.txt index 7603f0ece..fce4be279 100644 --- a/src/plugins/TopicViewer/CMakeLists.txt +++ b/src/plugins/TopicViewer/CMakeLists.txt @@ -3,6 +3,8 @@ gz_gui_add_plugin(TopicViewer TopicViewer.cc QT_HEADERS TopicViewer.hh + QML_SOURCES + TopicViewer.qml TEST_SOURCES TopicViewer_TEST.cc PUBLIC_LINK_LIBS diff --git a/src/plugins/TopicViewer/TopicViewer.qml b/src/plugins/TopicViewer/TopicViewer.qml index 26947a80b..1632bcd13 100644 --- a/src/plugins/TopicViewer/TopicViewer.qml +++ b/src/plugins/TopicViewer/TopicViewer.qml @@ -42,26 +42,26 @@ TreeView { property color highlightColor: Material.accentColor; - verticalScrollBarPolicy: Qt.ScrollBarAsNeeded - horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff - headerVisible: false - headerDelegate: Rectangle { - visible: false - } - backgroundVisible: false; - TableViewColumn - { - role: "name"; - } + // verticalScrollBarPolicy: Qt.ScrollBarAsNeeded + // horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff + // headerVisible: false + // headerDelegate: Rectangle { + // visible: false + // } + // backgroundVisible: false; + // TableViewColumn + // { + // role: "name"; + // } // =========== Selection =========== - selection: ItemSelectionModel { - model: tree.model - } - selectionMode: SelectionMode.SingleSelection + // selection: ItemSelectionModel { + // model: tree.model + // } + // selectionMode: SelectionMode.SingleSelection // =========== Delegates ============ - rowDelegate: Rectangle + delegate: Rectangle { id: row color: (styleData.selected)? highlightColor : @@ -69,152 +69,152 @@ TreeView { height: itemHeight; } - itemDelegate: Item { - id: item - - // for fixing the item position - // item pos changes randomly when drag happens (with the copy drag) - anchors.top: parent.top - anchors.right: parent.right - - Drag.mimeData: { "text/plain" : (model === null) ? "" : model.topic + "," + model.path } - - Drag.dragType: Drag.Automatic - Drag.supportedActions : Qt.CopyAction - Drag.active: dragMouse.drag.active - // a point to drag from - Drag.hotSpot.x: 0 - Drag.hotSpot.y: itemHeight - - // used by DropArea that accepts the dragged items - function itemData () - { - return { - "name": model.name, - "type": model.type, - "path": model.path, - "topic": model.topic - } - } - - MouseArea { - id: dragMouse - anchors.fill: parent - - // only plottable items are dragable - drag.target: (model === null) ? null : - (model.plottable) ? parent : null - - // get a copy image of the dragged item - onPressed: parent.grabToImage(function(result) { - parent.Drag.imageSource = result.url - }) - - onReleased: - { - // emit drop event to notify the DropArea (must manually) - parent.Drag.drop(); - } - - hoverEnabled: true - propagateComposedEvents: true - // make the cursor with a drag shape at the plottable items - cursorShape: (model === null) ? Qt.ArrowCursor : (model.plottable) ? - Qt.DragCopyCursor : Qt.ArrowCursor - - onClicked: { - // change the selection of the tree by clearing the prev, select a new one - tree.selection.select(styleData.index,ItemSelectionModel.ClearAndSelect) - - // set the selection index to the index of the clicked item (must set manually) - tree.selection.setCurrentIndex(styleData.index,ItemSelectionModel.ClearAndSelect) - - // the currentIndex of the tree.selection is not the same - // of the tree.currentIndex, so set the tree.currentIndex. - // this is the way to access it as it is read-only - tree.__currentRow = styleData.row - - // set the focus to the selected item to receive the keyboard events - // this is useful to enable navigating with keyboard from the right position - item.forceActiveFocus(); - - tree.expandCollapseMsg(tree.currentIndex); - } - } - - Image { - id: icon - source: "plottable_icon.svg" - height: itemHeight * 0.6 - width: itemHeight * 0.6 - y : itemHeight * 0.2 - visible: (model === null) ? false : model.plottable - } - - Text { - id : field - text: (model === null) ? "" : model.name - color: (Material.theme == Material.Light || styleData.selected) ? - Material.color(Material.Grey, Material.Shade800): - Material.color(Material.Grey, Material.Shade400); - - font.pointSize: 12 - anchors.leftMargin: 5 - anchors.left: icon.right - anchors.right: parent.right - elide: Text.ElideMiddle - y: icon.y - } - - ToolTip { - id: tool_tip - delay: 200 - timeout: 2000 - text: (model === null) ? "Type ?" : "Type: " + model.type; - visible: dragMouse.containsMouse - y: -itemHeight - x: dragMouse.mouseX - enter: null - exit: null - } - } + // itemDelegate: Item { + // id: item + // + // // for fixing the item position + // // item pos changes randomly when drag happens (with the copy drag) + // anchors.top: parent.top + // anchors.right: parent.right + // + // Drag.mimeData: { "text/plain" : (model === null) ? "" : model.topic + "," + model.path } + // + // Drag.dragType: Drag.Automatic + // Drag.supportedActions : Qt.CopyAction + // Drag.active: dragMouse.drag.active + // // a point to drag from + // Drag.hotSpot.x: 0 + // Drag.hotSpot.y: itemHeight + // + // // used by DropArea that accepts the dragged items + // function itemData () + // { + // return { + // "name": model.name, + // "type": model.type, + // "path": model.path, + // "topic": model.topic + // } + // } + // + // MouseArea { + // id: dragMouse + // anchors.fill: parent + // + // // only plottable items are dragable + // drag.target: (model === null) ? null : + // (model.plottable) ? parent : null + // + // // get a copy image of the dragged item + // onPressed: parent.grabToImage(function(result) { + // parent.Drag.imageSource = result.url + // }) + // + // onReleased: + // { + // // emit drop event to notify the DropArea (must manually) + // parent.Drag.drop(); + // } + // + // hoverEnabled: true + // propagateComposedEvents: true + // // make the cursor with a drag shape at the plottable items + // cursorShape: (model === null) ? Qt.ArrowCursor : (model.plottable) ? + // Qt.DragCopyCursor : Qt.ArrowCursor + // + // onClicked: { + // // change the selection of the tree by clearing the prev, select a new one + // tree.selection.select(styleData.index,ItemSelectionModel.ClearAndSelect) + // + // // set the selection index to the index of the clicked item (must set manually) + // tree.selection.setCurrentIndex(styleData.index,ItemSelectionModel.ClearAndSelect) + // + // // the currentIndex of the tree.selection is not the same + // // of the tree.currentIndex, so set the tree.currentIndex. + // // this is the way to access it as it is read-only + // tree.__currentRow = styleData.row + // + // // set the focus to the selected item to receive the keyboard events + // // this is useful to enable navigating with keyboard from the right position + // item.forceActiveFocus(); + // + // tree.expandCollapseMsg(tree.currentIndex); + // } + // } + // + // Image { + // id: icon + // source: "plottable_icon.svg" + // height: itemHeight * 0.6 + // width: itemHeight * 0.6 + // y : itemHeight * 0.2 + // visible: (model === null) ? false : model.plottable + // } + // + // Text { + // id : field + // text: (model === null) ? "" : model.name + // color: (Material.theme == Material.Light || styleData.selected) ? + // Material.color(Material.Grey, Material.Shade800): + // Material.color(Material.Grey, Material.Shade400); + // + // font.pointSize: 12 + // anchors.leftMargin: 5 + // anchors.left: icon.right + // anchors.right: parent.right + // elide: Text.ElideMiddle + // y: icon.y + // } + // + // ToolTip { + // id: tool_tip + // delay: 200 + // timeout: 2000 + // text: (model === null) ? "Type ?" : "Type: " + model.type; + // visible: dragMouse.containsMouse + // y: -itemHeight + // x: dragMouse.mouseX + // enter: null + // exit: null + // } + // } property int y_pos: 0 - style: TreeViewStyle { - branchDelegate: Rectangle { - height: itemHeight - width: itemHeight - color: "transparent" - Image { - id: branchImage - fillMode: Image.Pad - anchors.right: parent.right - anchors.verticalCenter: parent.verticalCenter - sourceSize.height: itemHeight * 0.4 - sourceSize.width: itemHeight * 0.4 - source: styleData.isExpanded ? "minus.png" : "plus.png" - } - MouseArea { - anchors.fill: parent - hoverEnabled: true - propagateComposedEvents: true - onClicked: { - mouse.accepted = true - - // set the current index & current selection and active focus for keyboard - // the reason for that to make the branch selection just like the item selection - // and to fix the animation as it ueses item selection's info - tree.selection.select(styleData.index,ItemSelectionModel.ClearAndSelect) - tree.selection.setCurrentIndex(styleData.index,ItemSelectionModel.ClearAndSelect) - tree.__currentRow = styleData.row - item.forceActiveFocus(); - - expandCollapseMsg(styleData.index); - } - } - } - } + // style: TreeViewStyle { + // branchDelegate: Rectangle { + // height: itemHeight + // width: itemHeight + // color: "transparent" + // Image { + // id: branchImage + // fillMode: Image.Pad + // anchors.right: parent.right + // anchors.verticalCenter: parent.verticalCenter + // sourceSize.height: itemHeight * 0.4 + // sourceSize.width: itemHeight * 0.4 + // source: styleData.isExpanded ? "minus.png" : "plus.png" + // } + // MouseArea { + // anchors.fill: parent + // hoverEnabled: true + // propagateComposedEvents: true + // onClicked: { + // mouse.accepted = true + // + // // set the current index & current selection and active focus for keyboard + // // the reason for that to make the branch selection just like the item selection + // // and to fix the animation as it ueses item selection's info + // tree.selection.select(styleData.index,ItemSelectionModel.ClearAndSelect) + // tree.selection.setCurrentIndex(styleData.index,ItemSelectionModel.ClearAndSelect) + // tree.__currentRow = styleData.row + // item.forceActiveFocus(); + // + // expandCollapseMsg(styleData.index); + // } + // } + // } + // } function expandCollapseMsg(index){ if (tree.isExpanded(index)) diff --git a/src/plugins/TransportSceneManager/CMakeLists.txt b/src/plugins/TransportSceneManager/CMakeLists.txt index 8f4ed86c2..a4b19cfc5 100644 --- a/src/plugins/TransportSceneManager/CMakeLists.txt +++ b/src/plugins/TransportSceneManager/CMakeLists.txt @@ -3,6 +3,8 @@ gz_gui_add_plugin(TransportSceneManager TransportSceneManager.cc QT_HEADERS TransportSceneManager.hh + QML_SOURCES + TransportSceneManager.qml TEST_SOURCES # TransportSceneManager_TEST.cc PUBLIC_LINK_LIBS From 7cf5f94fefcf5bda31c9780c369eeea004a40654 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Mon, 5 Aug 2024 19:09:55 +0200 Subject: [PATCH 30/33] GzSpinBox update MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- include/gz/gui/qml/GzCardSettings.qml | 11 +++--- include/gz/gui/qml/GzPose.qml | 10 +++--- include/gz/gui/qml/GzSpinBox.qml | 41 +++++++++++++++++++---- src/plugins/GridConfig/GridConfig.qml | 24 ++++++------- src/plugins/PointCloud/PointCloud.qml | 6 ++-- src/plugins/Teleop/Teleop.qml | 32 +++++++++--------- src/plugins/WorldControl/WorldControl.qml | 2 +- 7 files changed, 78 insertions(+), 48 deletions(-) diff --git a/include/gz/gui/qml/GzCardSettings.qml b/include/gz/gui/qml/GzCardSettings.qml index b3e571203..cde4c4bbf 100644 --- a/include/gz/gui/qml/GzCardSettings.qml +++ b/include/gz/gui/qml/GzCardSettings.qml @@ -135,7 +135,7 @@ Dialog { GzSpinBox { visible: !cardPane.anchored - to: cardPane.parent ? cardPane.parent.width - cardPane.width : from + maximumValue: cardPane.parent ? cardPane.parent.width - cardPane.width : minSize onVisibleChanged: value = cardPane.x onValueChanged: { cardPane.x = value; @@ -147,7 +147,7 @@ Dialog { } GzSpinBox { visible: !cardPane.anchored - to: cardPane.parent ? cardPane.parent.height - cardPane.height : from + maximumValue: cardPane.parent ? cardPane.parent.height - cardPane.height : minSize onVisibleChanged: value = cardPane.y onValueChanged: { cardPane.y = value; @@ -159,7 +159,7 @@ Dialog { } GzSpinBox { visible: !cardPane.anchored - to: 10000 + maximumValue: 10000 onVisibleChanged: value = cardPane.z onValueChanged: { cardPane.z = value; @@ -177,7 +177,7 @@ Dialog { text: "" } GzSpinBox { - to: cardPane.parent ? cardPane.parent.width : from + maximumValue: cardPane.parent ? cardPane.parent.width : minSize onVisibleChanged: { if (cardPane) value = cardPane.width @@ -190,8 +190,7 @@ Dialog { text: "Width" } GzSpinBox { - to: cardPane.parent ? cardPane.parent.height : from - + maximumValue: cardPane.parent ? cardPane.parent.height : minSize onVisibleChanged: { if (cardPane) value = cardPane.height diff --git a/include/gz/gui/qml/GzPose.qml b/include/gz/gui/qml/GzPose.qml index 8951464b6..5037258b0 100644 --- a/include/gz/gui/qml/GzPose.qml +++ b/include/gz/gui/qml/GzPose.qml @@ -78,7 +78,7 @@ Item { signal gzPoseSet(double _x, double _y, double _z, double _roll, double _pitch, double _yaw) // Maximum spinbox value - property int spinMax: Number.MAX_VALUE + property double spinMax: Number.MAX_VALUE // Expand/Collapse of this widget property bool expand: true @@ -119,10 +119,10 @@ Item { GzSpinBox { id: writableSpin value: numberValue - from: -spinMax - to: spinMax - //decimals: gzHelper.getDecimals(writableSpin.width) - onValueChanged: { + minimumValue: -spinMax + maximumValue: spinMax + decimals: gzHelper.getDecimals(writableSpin.width) + onEditingFinished: { gzPoseRoot.gzPoseSet(xItem.value, yItem.value, zItem.value, rollItem.value, pitchItem.value, yawItem.value) } diff --git a/include/gz/gui/qml/GzSpinBox.qml b/include/gz/gui/qml/GzSpinBox.qml index ce955bd47..2fa49a5fb 100644 --- a/include/gz/gui/qml/GzSpinBox.qml +++ b/include/gz/gui/qml/GzSpinBox.qml @@ -17,10 +17,39 @@ import QtQuick import QtQuick.Controls -SpinBox { - background: Rectangle { - implicitWidth: 70 - implicitHeight: 40 - border.color: "gray" - } +Item { + id: root + property int decimals: 2 + property real value: 0.0 + property real from: 0.0 + property real to: 100.0 + property alias minimumValue: root.from + property alias maximumValue: root.to + property real stepSize: 1.0 + signal editingFinished(real _value) + + SpinBox{ + id: spinbox + property real factor: Math.pow(10, root.decimals) + stepSize: root.stepSize*factor + value: root.value*factor + to : root.to*factor + from : root.from*factor + editable: true + + validator: DoubleValidator { + bottom: Math.min(spinbox.from, spinbox.to) + top: Math.max(spinbox.from, spinbox.to) + } + + textFromValue: function(value, locale) { + return Number(value / factor).toLocaleString(locale, 'f', root.decimals) + } + + valueFromText: function(text, locale) { + return Math.round(Number.fromLocaleString(locale, text) * factor) + } + + onValueChanged: root.editingFinished(spinbox.value / spinbox.factor) + } } diff --git a/src/plugins/GridConfig/GridConfig.qml b/src/plugins/GridConfig/GridConfig.qml index e67522174..245f03daf 100644 --- a/src/plugins/GridConfig/GridConfig.qml +++ b/src/plugins/GridConfig/GridConfig.qml @@ -112,10 +112,10 @@ GridLayout { Layout.columnSpan: 2 Layout.fillWidth: true id: verticalCellCount - to: Number.MAX_VALUE - from: 0 + maximumValue: Number.MAX_VALUE + minimumValue: 0 value: 0 - onValueChanged: GridConfig.UpdateVCellCount(verticalCellCount.value) + onEditingFinished: GridConfig.UpdateVCellCount(verticalCellCount.value) } Text { @@ -129,10 +129,10 @@ GridLayout { Layout.columnSpan: 2 Layout.fillWidth: true id: horizontalCellCount - to: Number.MAX_VALUE - from: 1 + maximumValue: Number.MAX_VALUE + minimumValue: 1 value: 20 - onValueChanged: GridConfig.UpdateHCellCount(horizontalCellCount.value) + onEditingFinished: GridConfig.UpdateHCellCount(horizontalCellCount.value) } Text { @@ -153,12 +153,12 @@ GridLayout { Layout.columnSpan: 2 Layout.fillWidth: true id: cellLength - to: Number.MAX_VALUE - from: 0 - value: 1 - //decimals: gzHelpers.getDecimals(cellLength.width) - stepSize: 1 - onValueChanged: GridConfig.UpdateCellLength(cellLength.value) + maximumValue: Number.MAX_VALUE + minimumValue: 0 + value: 1.00 + decimals: gzHelpers.getDecimals(cellLength.width) + stepSize: 0.01 + onEditingFinished: GridConfig.UpdateCellLength(cellLength.value) } Text { diff --git a/src/plugins/PointCloud/PointCloud.qml b/src/plugins/PointCloud/PointCloud.qml index 63c6b4c4c..6b1024919 100644 --- a/src/plugins/PointCloud/PointCloud.qml +++ b/src/plugins/PointCloud/PointCloud.qml @@ -121,9 +121,11 @@ ColumnLayout { GzSpinBox { id: pointSizeSpin value: PointCloud.pointSize - from: 1 + minimumValue: 1 + maximumValue: 1 + decimals: 0 to: 1000 - onValueChanged: { + onEditingFinished: { PointCloud.SetPointSize(pointSizeSpin.value) } } diff --git a/src/plugins/Teleop/Teleop.qml b/src/plugins/Teleop/Teleop.qml index 278ce3fd0..db84829a9 100644 --- a/src/plugins/Teleop/Teleop.qml +++ b/src/plugins/Teleop/Teleop.qml @@ -123,11 +123,11 @@ ColumnLayout { id: maxForwardVelField Layout.fillWidth: true value: maxForwardVel - to: 10000 - from: 0 - // decimals: 2 - stepSize: 1 - onValueChanged:{ + maximumValue: 10000.0 + minimumValue: 0.0 + decimals: 2 + stepSize: 0.10 + onEditingFinished: { Teleop.SetMaxForwardVel(value) } } @@ -142,11 +142,11 @@ ColumnLayout { id: maxVerticalVelField Layout.fillWidth: true value: maxVerticalVel - to: 10000 - from: 0 - // decimals: 2 - stepSize: 1 - onValueChanged:{ + maximumValue: 10000.0 + minimumValue: 0.0 + decimals: 2 + stepSize: 0.10 + onEditingFinished:{ Teleop.SetMaxVerticalVel(value) } } @@ -161,12 +161,12 @@ ColumnLayout { id: maxYawVelField Layout.fillWidth: true value: maxYawVel - to: 10000 - from: 0 - // decimals: 2 - stepSize: 1 - onValueChanged:{ - Teleop.SetMaxYawVel(value) + maximumValue: 10000.0 + minimumValue: 0.0 + decimals: 2 + stepSize: 0.10 + onEditingFinished:{ + Teleop.SetMaxYawVel(1.0) } } } diff --git a/src/plugins/WorldControl/WorldControl.qml b/src/plugins/WorldControl/WorldControl.qml index da35ae557..a10f2bff6 100644 --- a/src/plugins/WorldControl/WorldControl.qml +++ b/src/plugins/WorldControl/WorldControl.qml @@ -179,7 +179,7 @@ RowLayout { } GzSpinBox { - to: 10000 + maximumValue: 10000 Layout.alignment: Qt.AlignVCenter value: 1 onValueChanged: { From 96d791aa9f5075f75206c17e5011decc31778e34 Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 8 Aug 2024 17:14:32 -0500 Subject: [PATCH 31/33] Fix a few issues with spinbox Signed-off-by: Addisu Z. Taddese --- include/gz/gui/qml/GzSpinBox.qml | 96 +++++++++++++++++++++----------- 1 file changed, 63 insertions(+), 33 deletions(-) diff --git a/include/gz/gui/qml/GzSpinBox.qml b/include/gz/gui/qml/GzSpinBox.qml index 2fa49a5fb..1ee4f6314 100644 --- a/include/gz/gui/qml/GzSpinBox.qml +++ b/include/gz/gui/qml/GzSpinBox.qml @@ -18,38 +18,68 @@ import QtQuick import QtQuick.Controls Item { - id: root - property int decimals: 2 - property real value: 0.0 - property real from: 0.0 - property real to: 100.0 - property alias minimumValue: root.from - property alias maximumValue: root.to - property real stepSize: 1.0 - signal editingFinished(real _value) - - SpinBox{ - id: spinbox - property real factor: Math.pow(10, root.decimals) - stepSize: root.stepSize*factor - value: root.value*factor - to : root.to*factor - from : root.from*factor - editable: true - - validator: DoubleValidator { - bottom: Math.min(spinbox.from, spinbox.to) - top: Math.max(spinbox.from, spinbox.to) - } - - textFromValue: function(value, locale) { - return Number(value / factor).toLocaleString(locale, 'f', root.decimals) - } - - valueFromText: function(text, locale) { - return Math.round(Number.fromLocaleString(locale, text) * factor) - } - - onValueChanged: root.editingFinished(spinbox.value / spinbox.factor) + id: root + property int decimals: 2 + property real value: 0.0 + property real from: 0.0 + property real to: 100.0 + property alias minimumValue: root.from + property alias maximumValue: root.to + property real stepSize: 1.0 + signal editingFinished(real _value) + implicitWidth: spinbox.implicitWidth + implicitHeight: spinbox.implicitHeight + // Timer { + // interval: 50; running: true; repeat: true + // onTriggered: { + // console.log("root. w: ", root.parent.objectName, spinbox.objectName, " = ", root.width, root.height, root.implicitWidth, root.implicitHeight) + // } + // } + + + function decimalToInt(decimal) { + return Math.round(decimal * spinbox.factor) + } + + readonly property int maxInt32: Math.pow( 2, 31 ) - 1; + clip: true + + SpinBox{ + id: spinbox + anchors.fill: parent + property real factor: Math.pow(10, root.decimals) + stepSize: decimalToInt(root.stepSize) + value: decimalToInt(root.value) + to : Math.min(decimalToInt(root.to), maxInt32) + from : Math.max(decimalToInt(root.from), -maxInt32) + editable: true + clip: true + topPadding: 0 + bottomPadding: 0 + + validator: DoubleValidator { + bottom: Math.min(spinbox.from, spinbox.to) + top: Math.max(spinbox.from, spinbox.to) + } + + textFromValue: function(value, locale) { + return Number(value / factor).toLocaleString(locale, 'f', root.decimals) + } + + valueFromText: function(text, locale) { + return decimalToInt(Number.fromLocaleString(locale, text)) + } + + onValueModified: { + root.value = spinbox.value / spinbox.factor + // console.log("val mod: ", root.value) + root.editingFinished(root.value) + } + + background: Rectangle { + implicitWidth: 80 + implicitHeight: 80 + border.color: "red" } + } } From 872ea46d02f4bbe25b37e002ce850f08d9d46bca Mon Sep 17 00:00:00 2001 From: "Addisu Z. Taddese" Date: Thu, 8 Aug 2024 22:16:58 -0500 Subject: [PATCH 32/33] WIP: GzSplit Signed-off-by: Addisu Z. Taddese --- include/gz/gui/qml/GzCard.qml | 51 ++++-- include/gz/gui/qml/GzHelpers.qml | 9 + include/gz/gui/qml/GzSplit.qml | 208 +++++----------------- src/plugins/MinimalScene/MinimalScene.qml | 6 +- 4 files changed, 93 insertions(+), 181 deletions(-) diff --git a/include/gz/gui/qml/GzCard.qml b/include/gz/gui/qml/GzCard.qml index 53f8a0f13..ef96527d1 100644 --- a/include/gz/gui/qml/GzCard.qml +++ b/include/gz/gui/qml/GzCard.qml @@ -23,6 +23,7 @@ import "qrc:/gz/gui/qml" // TODO: don't use "parent" Pane { + clip: true /** * Minimum length of each dimension */ @@ -157,6 +158,8 @@ Pane { */ objectName: "plugin" + Math.floor(Math.random() * 100000); + anchors.fill: parent + // Stop scroll propagation to widgets below MouseArea { anchors.fill: parent @@ -173,9 +176,9 @@ Pane { return; // Bind anchors - anchors.fill = Qt.binding(function() {return parent}) - parent.height = Qt.binding(function() {return height}) - parent.width = Qt.binding(function() {return width}) + // anchors.fill = Qt.binding(function() {return parent}) + // parent.height = Qt.binding(function() {return height}) + // parent.width = Qt.binding(function() {return width}) // Keep a reference to the background // TODO(louise) This feels hacky, the card shouldn't care about the background, @@ -195,16 +198,16 @@ Pane { * any knowledge of splits */ function syncTheFamily() { - var parentSplit = helpers.ancestorByName(cardPane, /^split_item/); - - if (undefined == parentSplit) - return; - - if (content.children.length != 1) - return; - - parentSplit.Layout.minimumWidth = content.children[0].Layout.minimumWidth; - parentSplit.Layout.minimumHeight = content.children[0].Layout.minimumHeight; + // var parentSplit = helpers.ancestorByName(cardPane, /^split_item/); + // + // if (undefined == parentSplit) + // return; + // + // if (content.children.length != 1) + // return; + // + // parentSplit.Layout.minimumWidth = content.children[0].Layout.minimumWidth; + // parentSplit.Layout.minimumHeight = content.children[0].Layout.minimumHeight; } /** @@ -415,7 +418,7 @@ Pane { { const collapsed = cardPane.parent.Layout.minimumHeight === 50; // Reparent to main window's background - cardPane.parent = backgroundItem + cardPane.parent = backgroundItem.contentChildren[0] // Resize to minimum size cardPane.clearAnchors(); @@ -449,7 +452,7 @@ Pane { */ function recalculateSplitSizes() { - backgroundItem.recalculateMinimumSizes(); + // backgroundItem.recalculateMinimumSizes(); } // TODO(louise): re-enable window state support @@ -669,21 +672,31 @@ Pane { Rectangle { objectName: "content" id: content + // anchors.horizontalCenter: parent.horizontalCenter + anchors.fill: parent anchors.topMargin: cardPane.showTitleBar ? 50 : 0 + // height: 100 + // implicitHeight: 123 clip: true color: cardBackground onChildrenChanged: { // Set the height and width of the cardPane when child plugin is attached + // if (children.length > 0) { + // cardMinimumWidth = content.children[0].Layout.minimumWidth; + // cardMinimumHeight = content.children[0].Layout.minimumHeight; + // cardPane.width = cardMinimumWidth + // cardPane.height = cardMinimumHeight + // } + // + // cardPane.syncTheFamily() if (children.length > 0) { cardMinimumWidth = content.children[0].Layout.minimumWidth; cardMinimumHeight = content.children[0].Layout.minimumHeight; - cardPane.width = cardMinimumWidth - cardPane.height = cardMinimumHeight + cardPane.Layout.minimumWidth = cardMinimumWidth + cardPane.Layout.minimumHeight = cardMinimumHeight } - - cardPane.syncTheFamily() } /** diff --git a/include/gz/gui/qml/GzHelpers.qml b/include/gz/gui/qml/GzHelpers.qml index 394180bbb..991c44f44 100644 --- a/include/gz/gui/qml/GzHelpers.qml +++ b/include/gz/gui/qml/GzHelpers.qml @@ -17,6 +17,7 @@ import QtQuick Item { + visible: false /** * Helper function to get an item's ancestor by name. * @param _item Item whose parent we're looking for. @@ -56,4 +57,12 @@ Item { return 4 } + function dump(object, indent, depth) { + console.log(indent + object) + if (depth > 0) { + for (const i in object.children) + dump(object.children[i], indent + " ", depth - 1) + } + } + } diff --git a/include/gz/gui/qml/GzSplit.qml b/include/gz/gui/qml/GzSplit.qml index 3202daae3..a5fd00915 100644 --- a/include/gz/gui/qml/GzSplit.qml +++ b/include/gz/gui/qml/GzSplit.qml @@ -27,6 +27,7 @@ SplitView { id: background objectName: "background" + clip: true GzHelpers { id: helpers @@ -42,19 +43,11 @@ SplitView { */ property variant childSplits: new Object() - /** - * Callback when the height changed. - */ - onHeightChanged: - { - background.recalculateMinimumSizes(); - } - Rectangle { id: startLabel; - visible: MainWindow.pluginCount === 0 + visible: false; //MainWindow.pluginCount === 0 anchors.fill: parent - color: Material.background + color: "red" //Material.background Label { text: "Insert plugins to start!" anchors.fill: parent @@ -63,6 +56,7 @@ SplitView { verticalAlignment: Label.AlignVCenter wrapMode: Label.Wrap } + SplitView.fillWidth: true } /** @@ -88,35 +82,40 @@ SplitView { */ function addSplitItem() { - var itemName = ""; - + var addedItem = ""; // First section goes in the top level SplitView, which is Qt.Horizontal // 2 for helpers and startLabel - if (background.count <= 2) + console.log("bg count:", background.count, background.contentChildren.length, Object.keys(childSplits).length) + if (background.contentChildren.length <= 2) { - itemName = _addNewItem(background); + console.log("Add to bg split") + addedItem = _addNewItem(background); } // The next one adds a Qt.Vertical split to the right else if (Object.keys(childSplits).length === 0) { + console.log("Creating side split") // Add the split var split = _addNewSplit(background); - split.split.orientation = Qt.Vertical; + console.log("Created ", split.objectName) + // Then add a new item to the newly created split - itemName = _addNewItem(split); + addedItem = _addNewItem(split); } // All subsequent ones are added to the vertical child split on the right else { + console.log("Adding side split") // Get desired split (for now we have only one) var firstChildSplit = childSplits[Object.keys(childSplits)[0]]; // Then add a new item to it - itemName = _addNewItem(firstChildSplit); + addedItem = _addNewItem(firstChildSplit); } - return itemName + helpers.dump(background, "", 5) + return addedItem } /** @@ -125,6 +124,7 @@ SplitView { */ function removeSplitItem(_name) { + console.log("Removing ", _name) // Remove from split _removeFromSplits(childItems[_name]); @@ -154,18 +154,15 @@ SplitView { if (_split === background) { _split.addItem(item); + item.SplitView.fillWidth = true; } else { - _split.split.addItem(item); - - // Make sure that changes to the item's minimum size get propagated to the - // split. - item.minimumSizeChanged.connect(function(){ - _split.split.recalculateMinimumSize() - }); + _split.addItem(item); } + console.log(itemName, item.objectName, "size: ", item.width, item.height) + // return childItems[itemName]; return itemName; } @@ -188,7 +185,7 @@ SplitView { childSplits[splitName] = splitWrapper; // Add to parent - _parentSplit.addItem(splitWrapper); + // _parentSplit.addItem(splitWrapper); return splitWrapper; } @@ -205,6 +202,7 @@ SplitView { return; var split = helpers.ancestorByName(_item, /^split_|^background$/); + console.log("Ancestor ", split.objectName) if (!split) { @@ -214,15 +212,21 @@ SplitView { if (split === background) { + console.log("Final remove ", _item.objectName, " from bg") split.removeItem(_item); + for (var i in split.contentChildren) + { + console.log(" ", split.contentChildren[i]) + } } else { - split.split.removeItem(_item); + split.removeItem(_item); // If split is now empty, remove split - if (split.split.__items.length === 0) - { + // if (split.contentChildren.length === 0) + // { + console.log("Removing side split from bg", split.objectName) // Remove from array delete childSplits[split.objectName] @@ -231,11 +235,12 @@ SplitView { // Destroy split.destroy(); - } - else - { - split.split.recalculateMinimumSize(); - } + helpers.dump(background, "", 5) + // } + // else + // { + // split.recalculateMinimumSize(); + // } } } @@ -245,48 +250,11 @@ SplitView { Component { id: newItem - Rectangle { - Layout.minimumWidth: 100 - Layout.minimumHeight: 100 - Layout.fillHeight: false - Layout.fillWidth: true - color: Material.background - - /** - * Notifies that its minimum size has changed. - */ - signal minimumSizeChanged(); - - /** - * Callback when the layout's minimum width changes. - */ - Layout.onMinimumWidthChanged: { - minimumSizeChanged(); - } - - /** - * Callback when the layout's minimum height changes. - */ - Layout.onMinimumHeightChanged: { - minimumSizeChanged(); - } - - /** - * Callback when the children array has been changed. - */ - onChildrenChanged: { - // Propagate child's minimum size changes to the item. - newItem.Layout.minimumWidth = Qt.binding(function() { - if (children.length === 0 || children[0] === undefined) - return 0; - return children[0].Layout.minimumWidth - }); - newItem.Layout.minimumHeight = Qt.binding(function() { - if (children.length === 0 || children[0] === undefined) - return 0; - return children[0].Layout.minimumHeight - }); - } + ColumnLayout { + id: rectContainer + SplitView.minimumWidth: children[0]? children[0].Layout.minimumWidth : 0 + SplitView.minimumHeight: children[0]? children[0].Layout.minimumHeight : 0 + clip: true } } @@ -295,89 +263,11 @@ SplitView { */ Component { id: newSplit - - /** - * For some reason, the scroll view doesn't work well within a split view, - * so we wrap it in a rectangle. - */ - Rectangle { - id: splitWrapper - color: "transparent" - - /** - * Expose the split view. - */ - property var split: split - - /** - * Offset of 17 to accommodate for ScrollView scroll bar - */ - property var scrollBarWidth: 17 - - Layout.minimumWidth: split.Layout.minimumWidth + scrollBarWidth - Layout.minimumHeight: split.Layout.minimumHeight - - ScrollView { - contentHeight: split.height - contentWidth: split.width + scrollBarWidth - - ScrollBar.vertical.policy: ScrollBar.AlwaysOn - - // TODO(louise) This only works for a very specific split - height: window.height - window.header.height - - SplitView { - id: split - width: splitWrapper.width - scrollBarWidth - height: Math.max(childItems[Object.keys(childItems)[0]].height, - split.Layout.minimumHeight) - - /** - * Iterate over all current child items and update the split's minimum - * width accordingly. - */ - function recalculateMinimumSize() - { - // TODO(louise): generalize to support horizontal splits - if (orientation === Qt.Horizontal) - { - return; - } - - // Sync minimum sizes - var heightSum = 0; - var minHeightSum = 0; - for (var i = 0; i < __items.length; i++) - { - var child = __items[i]; - - // Minimum width matches the largest minimum width among children - if (child.Layout.minimumWidth > Layout.minimumWidth) - { - Layout.minimumWidth = child.Layout.minimumWidth; - } - heightSum += child.height; - - var collapsed = child.Layout.maximumHeight == 50 - minHeightSum += collapsed ? child.height : child.Layout.minimumHeight - } - - // Minimum height to show all children - Layout.minimumHeight = minHeightSum; - split.height = Math.max(minHeightSum, background.height); - - // Squish all children if there's no slack - if (heightSum > background.height) - { - for (var i = 0; i < __items.length; i++) - { - var child = __items[i]; - child.height = child.Layout.minimumHeight; - } - } - } - } - } + SplitView { + id: __split + orientation: Qt.Vertical + clip: true + SplitView.minimumWidth: __split.contentChildren[0]? __split.contentChildren[0].SplitView.minimumWidth : 0 } } } diff --git a/src/plugins/MinimalScene/MinimalScene.qml b/src/plugins/MinimalScene/MinimalScene.qml index caafe9b3d..1980fd17b 100644 --- a/src/plugins/MinimalScene/MinimalScene.qml +++ b/src/plugins/MinimalScene/MinimalScene.qml @@ -39,7 +39,7 @@ Rectangle { anchors.fill: parent hoverEnabled: true acceptedButtons: Qt.NoButton - visible: MinimalScene.loadingError.length === 0 + visible: MinimalScene.loadingError? MinimalScene.loadingError.length === 0: false onEntered: { MinimalScene.OnFocusWindow() } @@ -84,8 +84,8 @@ Rectangle { Label { anchors.fill: parent anchors.margins: 10 - text: MinimalScene.loadingError - visible: (MinimalScene.loadingError.length > 0); + text: MinimalScene.loadingError? MinimalScene.loadingError: "" + visible: MinimalScene.loadingError? (MinimalScene.loadingError.length > 0): true; wrapMode: Text.WordWrap } } From 9f743ebda4ebe31509d67c45c4ab5309ac533964 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Ag=C3=BCero?= Date: Wed, 21 Aug 2024 14:10:31 +0200 Subject: [PATCH 33/33] Tweak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Carlos Agüero --- src/plugins/TopicViewer/TopicViewer.qml | 103 ++++++++++++------------ 1 file changed, 53 insertions(+), 50 deletions(-) diff --git a/src/plugins/TopicViewer/TopicViewer.qml b/src/plugins/TopicViewer/TopicViewer.qml index 1632bcd13..be1790047 100644 --- a/src/plugins/TopicViewer/TopicViewer.qml +++ b/src/plugins/TopicViewer/TopicViewer.qml @@ -59,33 +59,36 @@ TreeView { // model: tree.model // } // selectionMode: SelectionMode.SingleSelection + // selectionModel: ItemSelectionModel {} // =========== Delegates ============ - delegate: Rectangle - { - id: row - color: (styleData.selected)? highlightColor : - (styleData.row % 2 == 0) ? evenColor : oddColor - height: itemHeight; - } + // delegate: Rectangle + // { + // id: row + // color: (styleData.selected)? highlightColor : + // (styleData.row % 2 == 0) ? evenColor : oddColor + // height: itemHeight; + // } + + delegate: TreeViewDelegate {} - // itemDelegate: Item { + // delegate: Item { // id: item - // +// // // for fixing the item position // // item pos changes randomly when drag happens (with the copy drag) // anchors.top: parent.top // anchors.right: parent.right - // +// // Drag.mimeData: { "text/plain" : (model === null) ? "" : model.topic + "," + model.path } - // + // // Drag.dragType: Drag.Automatic // Drag.supportedActions : Qt.CopyAction // Drag.active: dragMouse.drag.active // // a point to drag from // Drag.hotSpot.x: 0 // Drag.hotSpot.y: itemHeight - // + // // // used by DropArea that accepts the dragged items // function itemData () // { @@ -96,68 +99,68 @@ TreeView { // "topic": model.topic // } // } - // +// // MouseArea { // id: dragMouse // anchors.fill: parent - // + // // // only plottable items are dragable // drag.target: (model === null) ? null : // (model.plottable) ? parent : null - // + // // // get a copy image of the dragged item // onPressed: parent.grabToImage(function(result) { // parent.Drag.imageSource = result.url // }) - // + // // onReleased: // { // // emit drop event to notify the DropArea (must manually) // parent.Drag.drop(); // } - // + // // hoverEnabled: true // propagateComposedEvents: true // // make the cursor with a drag shape at the plottable items // cursorShape: (model === null) ? Qt.ArrowCursor : (model.plottable) ? // Qt.DragCopyCursor : Qt.ArrowCursor - // + // // onClicked: { // // change the selection of the tree by clearing the prev, select a new one // tree.selection.select(styleData.index,ItemSelectionModel.ClearAndSelect) - // + // // // set the selection index to the index of the clicked item (must set manually) // tree.selection.setCurrentIndex(styleData.index,ItemSelectionModel.ClearAndSelect) - // + // // // the currentIndex of the tree.selection is not the same // // of the tree.currentIndex, so set the tree.currentIndex. // // this is the way to access it as it is read-only // tree.__currentRow = styleData.row - // + // // // set the focus to the selected item to receive the keyboard events // // this is useful to enable navigating with keyboard from the right position // item.forceActiveFocus(); - // + // // tree.expandCollapseMsg(tree.currentIndex); // } // } - // + // // Image { // id: icon - // source: "plottable_icon.svg" + // source: "images/plottable_icon.svg" // height: itemHeight * 0.6 // width: itemHeight * 0.6 // y : itemHeight * 0.2 // visible: (model === null) ? false : model.plottable // } - // + // // Text { // id : field // text: (model === null) ? "" : model.name // color: (Material.theme == Material.Light || styleData.selected) ? // Material.color(Material.Grey, Material.Shade800): // Material.color(Material.Grey, Material.Shade400); - // + // // font.pointSize: 12 // anchors.leftMargin: 5 // anchors.left: icon.right @@ -165,7 +168,7 @@ TreeView { // elide: Text.ElideMiddle // y: icon.y // } - // + // // ToolTip { // id: tool_tip // delay: 200 @@ -223,29 +226,29 @@ TreeView { tree.expand(index); } - Transition { - id: expandTransition - NumberAnimation { - property: "y"; - from: (tree.__listView.currentItem) ? tree.__listView.currentItem.y : 0; - duration: 200; - easing.type: Easing.OutQuad - } - } - - Transition { - id: displacedTransition - NumberAnimation { - property: "y"; - duration: 200; - easing.type: Easing.OutQuad; - } - } + // Transition { + // id: expandTransition + // NumberAnimation { + // property: "y"; + // from: (tree.__listView.currentItem) ? tree.__listView.currentItem.y : 0; + // duration: 200; + // easing.type: Easing.OutQuad + // } + // } +// + // Transition { + // id: displacedTransition + // NumberAnimation { + // property: "y"; + // duration: 200; + // easing.type: Easing.OutQuad; + // } + // } - Component.onCompleted: { - tree.__listView.add = expandTransition; - tree.__listView.displaced = displacedTransition; - tree.__listView.removeDisplaced = displacedTransition; - } + // Component.onCompleted: { + // tree.__listView.add = expandTransition; + // tree.__listView.displaced = displacedTransition; + // tree.__listView.removeDisplaced = displacedTransition; + // } }