Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

6 ➡️ 7 (main) #333

Merged
merged 18 commits into from
Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ Deprecated code produces compile-time warnings. These warning serve as
notification to users that their code should be upgraded. The next major
release will remove the deprecated code.

## Ignition GUI 6.1 to 6.2

* All features from `Grid3D` have been incorportated into `GridConfig`. The code
for the original `Grid3D` has been removed and now the installed library is
just a copy of `GridConfig`. Existing `Grid3D` users shouldn't be affected and
may continue to use `Grid3D` as before.

## Ignition GUI 5.x to 6.x

* The `Scene3D` plugin is deprecated, use `MinimalScene` with
Expand Down
45 changes: 45 additions & 0 deletions examples/config/grid_config.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?xml version="1.0"?>

<plugin filename="MinimalScene">
<ignition-gui>
<title>View 1</title>
<property type="string" key="state">docked</property>
</ignition-gui>
<engine>ogre2</engine>
<scene>scene</scene>
<ambient_light>1 1 1</ambient_light>
<background_color>0.8 0.8 0.8</background_color>
<camera_pose>-6 3 6 0 0.5 0</camera_pose>
</plugin>
<plugin filename="InteractiveViewControl" name="Interactive view control">
<ignition-gui>
<anchors target="View 1">
<line own="right" target="right"/>
<line own="top" target="top"/>
</anchors>
<property key="resizable" type="bool">false</property>
<property key="width" type="double">5</property>
<property key="height" type="double">5</property>
<property key="state" type="string">floating</property>
<property key="showTitleBar" type="bool">false</property>
</ignition-gui>
</plugin>
<plugin filename="GridConfig" name="Grid config">
<ignition-gui>
<property type="string" key="state">docked</property>
</ignition-gui>
<insert>
<horizontal_cell_count>3</horizontal_cell_count>
<vertical_cell_count>2</vertical_cell_count>
<cell_length>2</cell_length>
<pose>1 2 3 0 0 0</pose>
<color>1 0 0 1</color>
</insert>
<insert>
<horizontal_cell_count>2</horizontal_cell_count>
<vertical_cell_count>0</vertical_cell_count>
<cell_length>1</cell_length>
<pose>0 0 0 0.5 0 0</pose>
<color>0 1 0 1</color>
</insert>
</plugin>
19 changes: 18 additions & 1 deletion include/ignition/gui/GuiEvents.hh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ namespace ignition
/// User defined events should start from QEvent::MaxUser and
/// count down to avoid collision with ign-gazebo events

/// \brief Event called in the render thread of a 3D scene.
/// \brief Event called in the render thread of a 3D scene after the user
/// camera has rendered.
/// It's safe to make rendering calls in this event's callback.
class Render : public QEvent
{
Expand Down Expand Up @@ -469,6 +470,22 @@ namespace ignition
/// \brief Private data pointer
IGN_UTILS_IMPL_PTR(dataPtr)
};

/// \brief Event called in the render thread of a 3D scene, before the
/// user camera is rendered.
/// It's safe to make rendering calls in this event's callback.
class IGNITION_GUI_VISIBLE PreRender : public QEvent
{
/// \brief Constructor
public: PreRender();

/// \brief Unique type for this event.
static const QEvent::Type kType = QEvent::Type(QEvent::MaxUser - 20);

/// \internal
/// \brief Private data pointer
IGN_UTILS_IMPL_PTR(dataPtr)
};
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions include/ignition/gui/Helpers.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ namespace ignition
IGNITION_GUI_VISIBLE
std::string renderEngineName();

/// \brief Import path for ign-gui QML modules added to the Qt resource
/// system. This helper function returns the QRC resource path where custom
/// ignition QML modules can be imported from. To import an ignition QML
/// module, add this path to the QML engine's import path list before
/// attempting to load a QML file that imports ignition QML modules.
/// \return Resousrce path prefix as a string
IGNITION_GUI_VISIBLE
const QString qmlQrcImportPath();

/// \brief Returns the first element on a QList which matches the given
/// property.
/// \param[in] _list The list to search through.
Expand Down
3 changes: 3 additions & 0 deletions include/ignition/gui/qml/qmldir
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module ignition.gui

IgnSpinBox 1.0 IgnSpinBox.qml
6 changes: 6 additions & 0 deletions include/ignition/gui/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@
<file>qml/images/export_icon.png</file>
<file>qml/images/search.svg</file>
</qresource>
<qresource prefix="ign-gui-qml/ignition/gui">
<!-- This qmldir file defines a QML module that can be imported -->
<file alias="qmldir">qml/qmldir</file>
<!-- Add any QML components referenced in the qmldir file here -->
<file alias="IgnSpinBox.qml">qml/IgnSpinBox.qml</file>
</qresource>
</RCC>
5 changes: 5 additions & 0 deletions src/Application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "ignition/gui/Application.hh"
#include "ignition/gui/config.hh"
#include "ignition/gui/Dialog.hh"
#include "ignition/gui/Helpers.hh"
#include "ignition/gui/MainWindow.hh"
#include "ignition/gui/Plugin.hh"

Expand Down Expand Up @@ -91,6 +92,7 @@ Application::Application(int &_argc, char **_argv, const WindowType _type)

// QML engine
this->dataPtr->engine = new QQmlApplicationEngine();
this->dataPtr->engine->addImportPath(qmlQrcImportPath());

// Install signal handler for graceful shutdown
this->dataPtr->signalHandler.AddCallback(
Expand Down Expand Up @@ -387,6 +389,9 @@ bool Application::LoadPlugin(const std::string &_filename,
else
plugin->Load(_pluginElem);

if (nullptr == plugin->CardItem())
return false;

// Store plugin in queue to be added to the window
this->dataPtr->pluginsToAdd.push(plugin);

Expand Down
8 changes: 8 additions & 0 deletions src/Application_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,14 @@ TEST(ApplicationTest, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(LoadPlugin))

EXPECT_FALSE(app.LoadPlugin("TestNotRegisteredPlugin"));
}

// Plugin with invalid QML
{
Application app(g_argc, g_argv);
app.AddPluginPath(std::string(PROJECT_BINARY_PATH) + "/lib");

EXPECT_FALSE(app.LoadPlugin("TestInvalidQmlPlugin"));
}
}

//////////////////////////////////////////////////
Expand Down
10 changes: 10 additions & 0 deletions src/GuiEvents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ class ignition::gui::events::WorldControl::Implementation
public: msgs::WorldControl worldControl;
};

class ignition::gui::events::PreRender::Implementation
{
};

using namespace ignition;
using namespace gui;
using namespace events;
Expand Down Expand Up @@ -420,3 +424,9 @@ const msgs::WorldControl &WorldControl::WorldControlInfo() const
{
return this->dataPtr->worldControl;
}

/////////////////////////////////////////////////
PreRender::PreRender()
: QEvent(kType), dataPtr(utils::MakeImpl<Implementation>())
{
}
8 changes: 8 additions & 0 deletions src/GuiEvents_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,11 @@ TEST(GuiEventsTest, WorldControl)
EXPECT_EQ(2, playEvent.WorldControlInfo().run_to_sim_time().sec());
EXPECT_EQ(3, playEvent.WorldControlInfo().run_to_sim_time().nsec());
}

/////////////////////////////////////////////////
TEST(GuiEventsTest, PreRender)
{
events::PreRender event;

EXPECT_LT(QEvent::User, event.type());
}
6 changes: 6 additions & 0 deletions src/Helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,9 @@ std::string ignition::gui::renderEngineName()

return renderEngineNameVariant.toString().toStdString();
}

/////////////////////////////////////////////////
const QString ignition::gui::qmlQrcImportPath()
{
return "qrc:/ign-gui-qml/";
}
20 changes: 20 additions & 0 deletions src/ign.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,18 @@ char* g_argv[] =
reinterpret_cast<char*>(const_cast<char*>("./ignition")),
};

//////////////////////////////////////////////////
void startConsoleLog()
{
std::string home;
ignition::common::env(IGN_HOMEDIR, home);

std::string logPathMod = ignition::common::joinPaths(home,
".ignition", "gui", "log",
ignition::common::timeToIso(IGN_SYSTEM_TIME()));
ignLogInit(logPathMod, "console.log");
}

//////////////////////////////////////////////////
extern "C" IGNITION_GUI_VISIBLE char *ignitionVersion()
{
Expand All @@ -42,6 +54,8 @@ extern "C" IGNITION_GUI_VISIBLE char *ignitionVersion()
//////////////////////////////////////////////////
extern "C" IGNITION_GUI_VISIBLE void cmdPluginList()
{
startConsoleLog();

ignition::gui::Application app(g_argc, g_argv);

auto pluginsList = app.PluginList();
Expand All @@ -65,6 +79,8 @@ extern "C" IGNITION_GUI_VISIBLE void cmdPluginList()
//////////////////////////////////////////////////
extern "C" IGNITION_GUI_VISIBLE void cmdStandalone(const char *_filename)
{
startConsoleLog();

ignition::gui::Application app(g_argc, g_argv,
ignition::gui::WindowType::kDialog);

Expand All @@ -79,6 +95,8 @@ extern "C" IGNITION_GUI_VISIBLE void cmdStandalone(const char *_filename)
//////////////////////////////////////////////////
extern "C" IGNITION_GUI_VISIBLE void cmdConfig(const char *_config)
{
startConsoleLog();

ignition::gui::Application app(g_argc, g_argv);

if (!app.findChild<ignition::gui::MainWindow *>())
Expand All @@ -103,6 +121,8 @@ extern "C" IGNITION_GUI_VISIBLE void cmdVerbose(const char *_verbosity)
//////////////////////////////////////////////////
extern "C" IGNITION_GUI_VISIBLE void cmdEmptyWindow()
{
startConsoleLog();

ignition::gui::Application app(g_argc, g_argv);

if (!app.findChild<ignition::gui::MainWindow *>())
Expand Down
39 changes: 38 additions & 1 deletion src/ign_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <string>

#include <ignition/common/Filesystem.hh>
#include <ignition/common/Util.hh>
#include <ignition/utilities/ExtraTestMacros.hh>

#include "test_config.h" // NOLINT(build/include)
Expand Down Expand Up @@ -52,10 +54,45 @@ std::string custom_exec_str(std::string _cmd)
return result;
}

using namespace ignition;

class CmdLine : public ::testing::Test
{
// Documentation inherited
protected: void SetUp() override
{
// Change environment variable so that test files aren't written to $HOME
common::env(IGN_HOMEDIR, this->realHome);
EXPECT_TRUE(common::setenv(IGN_HOMEDIR, this->kFakeHome.c_str()));
}

// Documentation inherited
protected: void TearDown() override
{
// Restore $HOME
EXPECT_TRUE(common::setenv(IGN_HOMEDIR, this->realHome.c_str()));
}

/// \brief Directory to act as $HOME for tests
public: const std::string kFakeHome = common::joinPaths(PROJECT_BINARY_PATH,
"test", "fake_home");

/// \brief Store user's real $HOME to set it back at the end of tests.
public: std::string realHome;
};

// See https://github.com/ignitionrobotics/ign-gui/issues/75
TEST(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(list))
TEST_F(CmdLine, IGN_UTILS_TEST_ENABLED_ONLY_ON_LINUX(list))
{
// Clear home if it exists
common::removeAll(this->kFakeHome);

EXPECT_FALSE(common::exists(this->kFakeHome));

std::string output = custom_exec_str("ign gui -l");
EXPECT_NE(output.find("TopicEcho"), std::string::npos) << output;
EXPECT_NE(output.find("Publisher"), std::string::npos) << output;

EXPECT_TRUE(common::exists(common::joinPaths(this->kFakeHome, ".ignition",
"gui")));
}
1 change: 0 additions & 1 deletion src/plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ endfunction()

# Plugins
add_subdirectory(camera_tracking)
add_subdirectory(grid_3d)
add_subdirectory(grid_config)
add_subdirectory(image_display)
add_subdirectory(interactive_view_control)
Expand Down
11 changes: 0 additions & 11 deletions src/plugins/grid_3d/CMakeLists.txt

This file was deleted.

Loading