Skip to content

Commit

Permalink
3 ➡️ 4 (#256)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <[email protected]>
  • Loading branch information
chapulina authored Jul 20, 2021
2 parents 06440b1 + c564715 commit 3696d49
Show file tree
Hide file tree
Showing 26 changed files with 1,348 additions and 47 deletions.
3 changes: 1 addition & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# More info:
# https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners

* @chapulina
* @jennuine
* @chapulina @jennuine
7 changes: 2 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ ign_find_package(ignition-msgs6 REQUIRED)
set(IGN_MSGS_VER ${ignition-msgs6_VERSION_MAJOR})

#--------------------------------------
# Find ignition-tools
ign_find_package(ignition-tools QUIET)
if (ignition-tools_FOUND)
set (HAVE_IGN_TOOLS TRUE)
endif()
# Find if ign command is available
find_program(HAVE_IGN_TOOLS ign)

#--------------------------------------
# Find QT
Expand Down
17 changes: 17 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,23 @@

### Ignition Gui 3.X.X (202X-XX-XX)

### Ignition Gui 3.7.0 (2021-07-14)

1. Fix codeowners
* [Pull request #251](https://github.com/ignitionrobotics/ign-gui/pull/251)

1. Fix plugin added signal, add PluginByName
* [Pull request #249](https://github.com/ignitionrobotics/ign-gui/pull/249)

1. Fixed tests by passing valid argv
* [Pull request #244](https://github.com/ignitionrobotics/ign-gui/pull/244)

1. Screenshot plugin fixed dbg message
* [Pull request #246](https://github.com/ignitionrobotics/ign-gui/pull/246)

1. Detect ign instead of using cmake module to check for ignition-tools
* [Pull request #240](https://github.com/ignitionrobotics/ign-gui/pull/240)

### Ignition Gui 3.6.0 (2021-06-17)

1. Update codeowners
Expand Down
5 changes: 5 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ release will remove the deprecated code.
Use `ignition::msgs::Convert` to `std::chrono::steady_clock::time_point`
instead.

## Ignition GUI 3.6 to 3.7

* The `Application::PluginAdded` signal used to send empty strings. Now it
sends the plugin's unique name.

## Ignition GUI 2.x to 3.x

* Use rendering3, transport8 and msgs5.
Expand Down
10 changes: 9 additions & 1 deletion include/ignition/gui/Application.hh
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,18 @@ namespace ignition
/// \brief Remove plugin by name. The plugin is removed from the
/// application and its shared library unloaded if this was its last
/// instance.
/// \param[in] _pluginName Plugn instance's unique name
/// \param[in] _pluginName Plugn instance's unique name. This is the
/// plugin card's object name.
/// \return True if successful
public: bool RemovePlugin(const std::string &_pluginName);

/// \brief Get a plugin by its unique name.
/// \param[in] _pluginName Plugn instance's unique name. This is the
/// plugin card's object name.
/// \return Pointer to plugin object, null if not found.
public: std::shared_ptr<Plugin> PluginByName(
const std::string &_pluginName) const;

/// \brief Notify that a plugin has been added.
/// \param[in] _objectName Plugin's object name.
signals: void PluginAdded(const QString &_objectName);
Expand Down
64 changes: 38 additions & 26 deletions src/Application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -179,36 +179,30 @@ Application *ignition::gui::App()
/////////////////////////////////////////////////
bool Application::RemovePlugin(const std::string &_pluginName)
{
bool found{false};
for (auto plugin : this->dataPtr->pluginsAdded)
{
auto cardItem = plugin->CardItem();
if (!cardItem)
continue;

if (cardItem->objectName().toStdString() == _pluginName)
{
// Remove on QML
cardItem->deleteLater();
auto plugin = this->PluginByName(_pluginName);
if (nullptr == plugin)
return false;

// Remove split on QML
auto bgItem = this->dataPtr->mainWin->QuickWindow()
->findChild<QQuickItem *>("background");
if (bgItem)
{
QMetaObject::invokeMethod(bgItem, "removeSplitItem",
Q_ARG(QVariant, cardItem->parentItem()->objectName()));
}
auto cardItem = plugin->CardItem();
if (nullptr == cardItem)
return false;

// Unload shared library
this->RemovePlugin(plugin);
// Remove on QML
cardItem->deleteLater();

found = true;
break;
}
// Remove split on QML
auto bgItem = this->dataPtr->mainWin->QuickWindow()
->findChild<QQuickItem *>("background");
if (bgItem)
{
QMetaObject::invokeMethod(bgItem, "removeSplitItem",
Q_ARG(QVariant, cardItem->parentItem()->objectName()));
}

return found;
// Unload shared library
this->RemovePlugin(plugin);

return true;
}

/////////////////////////////////////////////////
Expand Down Expand Up @@ -402,13 +396,31 @@ bool Application::LoadPlugin(const std::string &_filename,
else
this->InitializeDialogs();

this->PluginAdded(plugin->objectName());
this->PluginAdded(plugin->CardItem()->objectName());
ignmsg << "Loaded plugin [" << _filename << "] from path [" << pathToLib
<< "]" << std::endl;

return true;
}

/////////////////////////////////////////////////
std::shared_ptr<Plugin> Application::PluginByName(
const std::string &_pluginName) const
{
for (auto &plugin : this->dataPtr->pluginsAdded)
{
auto cardItem = plugin->CardItem();
if (!cardItem)
continue;

if (cardItem->objectName().toStdString() != _pluginName)
continue;

return plugin;
}
return nullptr;
}

/////////////////////////////////////////////////
bool Application::InitializeMainWindow()
{
Expand Down
23 changes: 22 additions & 1 deletion src/Application_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@
#include "ignition/gui/Plugin.hh"

int g_argc = 1;
char **g_argv = new char *[g_argc];
char* g_argv[] =
{
reinterpret_cast<char*>(const_cast<char*>("./Application_TEST")),
};

using namespace ignition;
using namespace gui;
Expand Down Expand Up @@ -79,14 +82,32 @@ TEST(ApplicationTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadPlugin))
Application app(g_argc, g_argv);

EXPECT_FALSE(app.LoadPlugin("_doesnt_exist"));
EXPECT_FALSE(app.RemovePlugin("_doesnt_exist"));
}

// Plugin path added programmatically
{
Application app(g_argc, g_argv);

std::string pluginName;
app.connect(&app, &Application::PluginAdded, [&pluginName](
const QString &_pluginName)
{
pluginName = _pluginName.toStdString();
});

app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib");

EXPECT_TRUE(app.LoadPlugin("TestPlugin"));
EXPECT_EQ(0u, pluginName.find("plugin"));

auto plugin = app.PluginByName(pluginName);
ASSERT_NE(nullptr, plugin);
ASSERT_NE(nullptr, plugin->CardItem());

EXPECT_EQ(pluginName, plugin->CardItem()->objectName().toStdString());

EXPECT_TRUE(app.RemovePlugin(pluginName));
}

// Plugin path added by env var
Expand Down
5 changes: 4 additions & 1 deletion src/MainWindow_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@

std::string kTestConfigFile = "/tmp/ign-gui-test.config"; // NOLINT(*)
int g_argc = 1;
char **g_argv = new char *[g_argc];
char* g_argv[] =
{
reinterpret_cast<char*>(const_cast<char*>("./MainWindow_TEST")),
};

using namespace ignition;
using namespace gui;
Expand Down
3 changes: 2 additions & 1 deletion src/Plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ Plugin::Plugin() : dataPtr(new PluginPrivate)
/////////////////////////////////////////////////
Plugin::~Plugin()
{
delete this->dataPtr->pluginItem;
if (this->dataPtr->pluginItem)
delete this->dataPtr->pluginItem;
}

/////////////////////////////////////////////////
Expand Down
5 changes: 4 additions & 1 deletion src/Plugin_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@
#include "ignition/gui/Plugin.hh"

int g_argc = 1;
char **g_argv = new char *[g_argc];
char* g_argv[] =
{
reinterpret_cast<char*>(const_cast<char*>("./Plugin_TEST")),
};

using namespace ignition;
using namespace gui;
Expand Down
5 changes: 4 additions & 1 deletion src/ign.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@
#include "ignition/gui/MainWindow.hh"

int g_argc = 1;
char **g_argv;
char* g_argv[] =
{
reinterpret_cast<char*>(const_cast<char*>("./ignition")),
};

//////////////////////////////////////////////////
extern "C" IGNITION_GUI_VISIBLE char *ignitionVersion()
Expand Down
1 change: 1 addition & 0 deletions src/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ add_subdirectory(plotting)
add_subdirectory(publisher)
add_subdirectory(scene3d)
add_subdirectory(screenshot)
add_subdirectory(teleop)
add_subdirectory(topic_echo)
add_subdirectory(topic_viewer)
add_subdirectory(world_control)
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/publisher/Publisher_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
#include "Publisher.hh"

int g_argc = 1;
char **g_argv = new char *[g_argc];
char* g_argv[] =
{
reinterpret_cast<char*>(const_cast<char*>("./Publisher_TEST")),
};

using namespace ignition;
using namespace gui;
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/screenshot/Screenshot.cc
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ void Screenshot::FindUserCamera()
if (nullptr != cam)
{
this->dataPtr->userCamera = cam;
igndbg << "Screnshot plugin taking pictures of camera ["
igndbg << "Screenshot plugin taking pictures of camera ["
<< this->dataPtr->userCamera->Name() << "]" << std::endl;
break;
}
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/screenshot/Screenshot_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@
#include "Screenshot.hh"

int g_argc = 1;
char **g_argv = new char *[g_argc];
char* g_argv[] =
{
reinterpret_cast<char*>(const_cast<char*>("./Screenshot_TEST")),
};

using namespace ignition;
using namespace gui;
Expand Down
8 changes: 8 additions & 0 deletions src/plugins/teleop/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
ign_gui_add_plugin(Teleop
SOURCES
Teleop.cc
QT_HEADERS
Teleop.hh
TEST_SOURCES
Teleop_TEST.cc
)
Loading

0 comments on commit 3696d49

Please sign in to comment.