From 322f87293e1e362dabacb1c35cd21be7f5b418a0 Mon Sep 17 00:00:00 2001 From: John Shepherd Date: Thu, 10 Dec 2020 12:30:04 -0800 Subject: [PATCH 1/4] Add gazebo gui events (#148) Signed-off-by: John Shepherd Signed-off-by: Louise Poubel Co-authored-by: Louise Poubel --- include/ignition/gui/GuiEvents.hh | 158 ++++++++++++++++++++++++++++++ src/CMakeLists.txt | 1 + src/GuiEvents_TEST.cc | 80 +++++++++++++++ 3 files changed, 239 insertions(+) create mode 100644 src/GuiEvents_TEST.cc diff --git a/include/ignition/gui/GuiEvents.hh b/include/ignition/gui/GuiEvents.hh index 0f8b6fbee..08d776a54 100644 --- a/include/ignition/gui/GuiEvents.hh +++ b/include/ignition/gui/GuiEvents.hh @@ -18,6 +18,7 @@ #define IGNITION_GUI_GUIEVENTS_HH_ #include +#include #include #include #include @@ -43,6 +44,163 @@ namespace ignition /// \brief Unique type for this event. static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser); }; + + /// \brief The class for sending and receiving custom snap value events. + /// This event is used in the Transform Control plugin tool when the + /// user manually alters their snapping values. + class SnapIntervals : public QEvent + { + /// \brief Constructor + /// \param[in] _xyz XYZ snapping values. + /// \param[in] _rpy RPY snapping values. + /// \param[in] _scale Scale snapping values. + public: SnapIntervals( + const math::Vector3d &_xyz, + const math::Vector3d &_rpy, + const math::Vector3d &_scale) + : QEvent(kType), xyz(_xyz), rpy(_rpy), scale(_scale) + { + } + + /// \brief Get the XYZ snapping values. + /// \return The XYZ snapping values. + public: math::Vector3d Position() const + { + return this->xyz; + } + + /// \brief Get the RPY snapping values. + /// \return The RPY snapping values. + public: math::Vector3d Rotation() const + { + return this->rpy; + } + + /// \brief Get the scale snapping values. + /// \return The scale snapping values. + public: math::Vector3d Scale() const + { + return this->scale; + } + + /// \brief The QEvent representing a snap event occurrence. + static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 1); + + /// \brief XYZ snapping values in meters, these values must be positive. + private: math::Vector3d xyz; + + /// \brief RPY snapping values in degrees, these values must be + /// positive. + private: math::Vector3d rpy; + + /// \brief Scale snapping values - a multiplier of the current size, + /// these values must be positive. + private: math::Vector3d scale; + }; + + /// \brief Event called to spawn a resource, given its description as a + /// string. + class SpawnFromDescription : public QEvent + { + /// \brief Constructor + /// \param[in] _string The resource's description as a string, such + /// as an SDF file. + public: explicit SpawnFromDescription(const std::string &_description) + : QEvent(kType), description(_description) + { + } + + /// \brief Unique type for this event. + static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 2); + + /// \brief Get the string description of the resource. + /// \return The resource string + public: const std::string &Description() const + { + return this->description; + } + + /// \brief The string of the resource to be spawned. + std::string description; + }; + + /// \brief Event called to spawn a resource, which takes the path + /// to its file. + class SpawnFromPath : public QEvent + { + /// \brief Constructor + /// \param[in] _filePath The path to a file. + public: explicit SpawnFromPath(const std::string &_filePath) + : QEvent(kType), filePath(_filePath) + { + } + + /// \brief Unique type for this event. + static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 3); + + /// \brief Get the path of the file. + /// \return The file path. + public: const std::string &FilePath() const + { + return this->filePath; + } + + /// \brief The path of file to be previewed. + std::string filePath; + }; + + /// \brief Event which is called to broadcast the 3D coordinates of a + /// user's mouse hover within the scene. + class HoverToScene : public QEvent + { + /// \brief Constructor + /// \param[in] _point The point at which the mouse is hovering within + /// the scene + public: explicit HoverToScene(const math::Vector3d &_point) + : QEvent(kType), point(_point) + { + } + + /// \brief Unique type for this event. + static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 4); + + /// \brief Get the point within the scene over which the user is + /// hovering. + /// \return The 3D point + public: math::Vector3d Point() const + { + return this->point; + } + + /// \brief The 3D point over which the user is hovering. + private: math::Vector3d point; + }; + + /// \brief Event which is called to broadcast the 3D coordinates of a + /// user's left click within the scene. + class LeftClickToScene : public QEvent + { + /// \brief Constructor + /// \param[in] _point The point which the user has left clicked within + /// the scene + public: explicit LeftClickToScene(const math::Vector3d &_point) + : QEvent(kType), point(_point) + { + } + + /// \brief Unique type for this event. + static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 5); + + /// \brief Get the point within the scene that the user clicked. + /// \return The 3D point. + public: math::Vector3d Point() const + { + return this->point; + } + + /// \brief The 3D point that the user clicked within the scene. + private: math::Vector3d point; + }; } } } diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a5b3f1302..61f278399 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -18,6 +18,7 @@ set (gtest_sources Conversions_TEST DragDropModel_TEST Helpers_TEST + GuiEvents_TEST ign_TEST MainWindow_TEST Plugin_TEST diff --git a/src/GuiEvents_TEST.cc b/src/GuiEvents_TEST.cc new file mode 100644 index 000000000..0bdb24d74 --- /dev/null +++ b/src/GuiEvents_TEST.cc @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2020 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 "test_config.h" // NOLINT(build/include) +#include "ignition/gui/GuiEvents.hh" + +using namespace ignition; +using namespace gui; + +///////////////////////////////////////////////// +TEST(GuiEventsTest, Render) +{ + events::Render event; + + EXPECT_LT(QEvent::User, event.type()); +} + +///////////////////////////////////////////////// +TEST(GuiEventsTest, SnapIntervals) +{ + events::SnapIntervals event({1, 2, 3}, {4, 5, 6}, {7, 8, 9}); + + EXPECT_LT(QEvent::User, event.type()); + EXPECT_EQ(math::Vector3d(1, 2, 3), event.Position()); + EXPECT_EQ(math::Vector3d(4, 5, 6), event.Rotation()); + EXPECT_EQ(math::Vector3d(7, 8, 9), event.Scale()); +} + +///////////////////////////////////////////////// +TEST(GuiEventsTest, SpawnFromDescription) +{ + events::SpawnFromDescription event("banana"); + + EXPECT_LT(QEvent::User, event.type()); + EXPECT_EQ("banana", event.Description()); +} + +///////////////////////////////////////////////// +TEST(GuiEventsTest, SpawnFromPath) +{ + events::SpawnFromPath event("banana"); + + EXPECT_LT(QEvent::User, event.type()); + EXPECT_EQ("banana", event.FilePath()); +} + +///////////////////////////////////////////////// +TEST(GuiEventsTest, HoverToScene) +{ + events::HoverToScene event({1, 2, 3}); + + EXPECT_LT(QEvent::User, event.type()); + EXPECT_EQ(math::Vector3d(1, 2, 3), event.Point()); +} + +///////////////////////////////////////////////// +TEST(GuiEventsTest, LeftClickToScene) +{ + events::LeftClickToScene event({1, 2, 3}); + + EXPECT_LT(QEvent::User, event.type()); + EXPECT_EQ(math::Vector3d(1, 2, 3), event.Point()); +} + From 6f1dca719ea7453108ba9328eec8b96f586771dd Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Thu, 10 Dec 2020 13:21:27 -0800 Subject: [PATCH 2/4] Change deprecated Qt::MidButton (#153) Signed-off-by: Louise Poubel --- src/Conversions.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Conversions.cc b/src/Conversions.cc index c5641fba4..77b1eee68 100644 --- a/src/Conversions.cc +++ b/src/Conversions.cc @@ -73,7 +73,7 @@ ignition::common::MouseEvent ignition::gui::convert(const QMouseEvent &_e) event.SetButton(common::MouseEvent::LEFT); else if (_e.button() == Qt::RightButton) event.SetButton(common::MouseEvent::RIGHT); - else if (_e.button() == Qt::MidButton) + else if (_e.button() == Qt::MiddleButton) event.SetButton(common::MouseEvent::MIDDLE); // Buttons @@ -83,7 +83,7 @@ ignition::common::MouseEvent ignition::gui::convert(const QMouseEvent &_e) if (_e.buttons() & Qt::RightButton) event.SetButtons(event.Buttons() | common::MouseEvent::RIGHT); - if (_e.buttons() & Qt::MidButton) + if (_e.buttons() & Qt::MiddleButton) event.SetButtons(event.Buttons() | common::MouseEvent::MIDDLE); // Type From 94a3fce483f1f6b68e08a976ff3e6c613d9b0074 Mon Sep 17 00:00:00 2001 From: John Shepherd Date: Thu, 10 Dec 2020 13:22:09 -0800 Subject: [PATCH 3/4] Add right mouse events and tests (#154) Signed-off-by: John Shepherd --- include/ignition/gui/GuiEvents.hh | 54 +++++++++++++++++++++++++++++++ src/GuiEvents_TEST.cc | 23 +++++++++++++ 2 files changed, 77 insertions(+) diff --git a/include/ignition/gui/GuiEvents.hh b/include/ignition/gui/GuiEvents.hh index 08d776a54..8ef8ea819 100644 --- a/include/ignition/gui/GuiEvents.hh +++ b/include/ignition/gui/GuiEvents.hh @@ -201,6 +201,60 @@ namespace ignition /// \brief The 3D point that the user clicked within the scene. private: math::Vector3d point; }; + + /// \brief Event which is called to broadcast the 3D coordinates of a + /// user's right click within the scene. + class RightClickToScene : public QEvent + { + /// \brief Constructor + /// \param[in] _point The point which the user has right clicked + /// within the scene + public: explicit RightClickToScene(const math::Vector3d &_point) + : QEvent(kType), point(_point) + { + } + + /// \brief Unique type for this event. + static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 6); + + /// \brief Get the point within the scene that the user clicked. + /// \return The 3D point. + public: math::Vector3d Point() const + { + return this->point; + } + + /// \brief The 3D point that the user clicked within the scene. + private: math::Vector3d point; + }; + + /// \brief Event which is called to enable or disable the dropdown menu. + /// This is primarily used by plugins which also use the right click + /// mouse event to cancel any actions currently in progress. + class DropdownMenuEnabled : public QEvent + { + /// \brief Constructor + /// \param[in] _menuEnabled The boolean indicating whether the dropdown + /// menu should be enabled or disabled. + public: explicit DropdownMenuEnabled(bool _menuEnabled) + : QEvent(kType), menuEnabled(_menuEnabled) + { + } + + /// \brief Unique type for this event. + static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 7); + + /// \brief Gets whether the menu is enabled or not for this event. + /// \return True if enabling the menu, false if disabling the menu + public: bool MenuEnabled() const + { + return this->menuEnabled; + } + + /// \brief The boolean indicating whether the menu is disabled or not + /// for this event. + private: bool menuEnabled; + }; } } } diff --git a/src/GuiEvents_TEST.cc b/src/GuiEvents_TEST.cc index 0bdb24d74..72c4ee740 100644 --- a/src/GuiEvents_TEST.cc +++ b/src/GuiEvents_TEST.cc @@ -78,3 +78,26 @@ TEST(GuiEventsTest, LeftClickToScene) EXPECT_EQ(math::Vector3d(1, 2, 3), event.Point()); } +///////////////////////////////////////////////// +TEST(GuiEventsTest, RightClickToScene) +{ + events::RightClickToScene event({1, 2, 3}); + + EXPECT_LT(QEvent::User, event.type()); + EXPECT_EQ(math::Vector3d(1, 2, 3), event.Point()); +} + +///////////////////////////////////////////////// +TEST(GuiEventsTest, DropdownMenuEnabled) +{ + events::DropdownMenuEnabled event(true); + + EXPECT_LT(QEvent::User, event.type()); + EXPECT_EQ(true, event.MenuEnabled()); + + events::DropdownMenuEnabled event2(false); + + EXPECT_LT(QEvent::User, event2.type()); + EXPECT_EQ(false, event2.MenuEnabled()); +} + From 8c6355947f98dabe3b6d7df46922caa87aeb115d Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Fri, 11 Dec 2020 14:41:01 -0800 Subject: [PATCH 4/4] Bump to 3.4.0 (#151) Signed-off-by: Louise Poubel --- CMakeLists.txt | 2 +- Changelog.md | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 98f3fdadc..615ca7d66 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR) #============================================================================ # Initialize the project #============================================================================ -project(ignition-gui3 VERSION 3.3.0) +project(ignition-gui3 VERSION 3.4.0) #============================================================================ # Find ignition-cmake diff --git a/Changelog.md b/Changelog.md index bd7da6105..147d9cf36 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,38 @@ ### Ignition Gui 3.X.X (202X-XX-XX) +### Ignition Gui 3.4.0 (2020-12-10) + +1. Publish plugin API docs + * [Pull request 128](https://github.com/ignitionrobotics/ign-gui/pull/128) + +1. Tutorial tweaks + * [Pull request 132](https://github.com/ignitionrobotics/ign-gui/pull/132) + +1. Floating and standalone plugins respect minimum dimensions + * [Pull request 135](https://github.com/ignitionrobotics/ign-gui/pull/135) + +1. Add scrollable indicator for plugin menu + * [Pull request 134](https://github.com/ignitionrobotics/ign-gui/pull/134) + +1. Re-enable image.config test + * [Pull request 148](https://github.com/ignitionrobotics/ign-gui/pull/148) + +1. Improve fork experience + * [Pull request 139](https://github.com/ignitionrobotics/ign-gui/pull/139) + +1. Resolve updated codecheck issues + * [Pull request 144](https://github.com/ignitionrobotics/ign-gui/pull/144) + +1. Port Gazebo GUI events to Ignition GUI + * [Pull request 148](https://github.com/ignitionrobotics/ign-gui/pull/148) + +1. Change deprecated Qt::MidButton + * [Pull request 153](https://github.com/ignitionrobotics/ign-gui/pull/153) + +1. Add right mouse events and tests + * [Pull request 154](https://github.com/ignitionrobotics/ign-gui/pull/154) + ### Ignition Gui 3.3.0 (2020-08-31) 1. rename key publisher plugin