Skip to content

Commit

Permalink
3 to 4
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina committed Dec 15, 2020
2 parents 19f9dae + 8c63559 commit def5df4
Show file tree
Hide file tree
Showing 5 changed files with 350 additions and 2 deletions.
32 changes: 32 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,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
Expand Down
212 changes: 212 additions & 0 deletions include/ignition/gui/GuiEvents.hh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#define IGNITION_GUI_GUIEVENTS_HH_

#include <QEvent>
#include <string>
#include <utility>
#include <vector>
#include <ignition/math/Vector3.hh>
Expand All @@ -43,6 +44,217 @@ 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;
};

/// \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;
};
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ set (gtest_sources
Conversions_TEST
DragDropModel_TEST
Helpers_TEST
GuiEvents_TEST
ign_TEST
MainWindow_TEST
PlottingInterface_TEST
Expand Down
4 changes: 2 additions & 2 deletions src/Conversions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
103 changes: 103 additions & 0 deletions src/GuiEvents_TEST.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/*
* 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 <gtest/gtest.h>

#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());
}

/////////////////////////////////////////////////
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());
}

0 comments on commit def5df4

Please sign in to comment.