Skip to content

Fix minimal scene render engine gui name from command line arg #1034

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

Merged
merged 4 commits into from
Sep 22, 2021
Merged
Show file tree
Hide file tree
Changes from 3 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
11 changes: 8 additions & 3 deletions include/ignition/gazebo/gui/Gui.hh
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ namespace gui
/// ign-tools. Set to the name of the application if using ign-tools)
/// \param[in] _guiConfig The GUI configuration file. If nullptr, the default
/// configuration from IGN_HOMEDIR/.ignition/gazebo/gui.config will be used.
IGNITION_GAZEBO_GUI_VISIBLE int runGui(int &_argc, char **_argv,
const char *_guiConfig);
/// \param[in] _renderEngineGui --render-engine-gui option
/// \return -1 on failure, 0 on success
IGNITION_GAZEBO_GUI_VISIBLE int runGui(int &_argc,
char **_argv, const char *_guiConfig, const char * _renderEngine = nullptr);

/// \brief Create a Gazebo GUI application
/// \param[in] _argc Number of command line arguments (Used when running
Expand All @@ -60,10 +62,13 @@ namespace gui
/// IGN_HOMEDIR/.ignition/gazebo/gui.config will be used.
/// \param[in] _loadPluginsFromSdf If true, plugins specified in the world
/// SDFormat file will get loaded.
/// \param[in] _renderEngineGui --render-engine-gui option
/// \return Newly created application.
IGNITION_GAZEBO_GUI_VISIBLE
std::unique_ptr<ignition::gui::Application> createGui(
int &_argc, char **_argv, const char *_guiConfig,
const char *_defaultGuiConfig = nullptr, bool _loadPluginsFromSdf = true);
const char *_defaultGuiConfig = nullptr, bool _loadPluginsFromSdf = true,
const char *_renderEngine = nullptr);

} // namespace gui
} // namespace IGNITION_GAZEBO_VERSION_NAMESPACE
Expand Down
10 changes: 5 additions & 5 deletions src/cmd/cmdgazebo.rb.in
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ class Cmd
'verbose' => '1',
'gui_config' => '',
'physics_engine' => '',
'rendering_engine_gui' => '',
'rendering_engine_server' => '',
'render_engine_gui' => '',
'render_engine_server' => '',
'headless-rendering' => 0
}

Expand Down Expand Up @@ -434,7 +434,7 @@ has properly set the DYLD_LIBRARY_PATH environment variables."
const char *, int)'

# Import the runGui function
Importer.extern 'int runGui(const char *)'
Importer.extern 'int runGui(const char *, const char *)'

# If playback is specified, and the user has not specified a
# custom gui config, set the gui config to load the playback
Expand Down Expand Up @@ -472,7 +472,7 @@ See https://github.com/ignitionrobotics/ign-gazebo/issues/44 for more info."
ENV['RMT_PORT'] = '1501'
Process.setpgid(0, 0)
Process.setproctitle('ign gazebo gui')
Importer.runGui(options['gui_config'])
Importer.runGui(options['gui_config'], options['render_engine_gui'])
end

Signal.trap("INT") {
Expand Down Expand Up @@ -511,7 +511,7 @@ See https://github.com/ignitionrobotics/ign-gazebo/issues/44 for more info."
end

ENV['RMT_PORT'] = '1501'
Importer.runGui(options['gui_config'])
Importer.runGui(options['gui_config'], options['render_engine_gui'])
end
rescue
puts "Library error: Problem running [#{options['command']}]() "\
Expand Down
18 changes: 12 additions & 6 deletions src/gui/Gui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ namespace gazebo
inline namespace IGNITION_GAZEBO_VERSION_NAMESPACE {
namespace gui
{

//////////////////////////////////////////////////
std::unique_ptr<ignition::gui::Application> createGui(
int &_argc, char **_argv, const char *_guiConfig,
const char *_defaultGuiConfig, bool _loadPluginsFromSdf)
const char *_defaultGuiConfig, bool _loadPluginsFromSdf,
const char *_renderEngine)
{
ignition::common::SignalHandler sigHandler;
bool sigKilled = false;
Expand Down Expand Up @@ -101,6 +101,10 @@ std::unique_ptr<ignition::gui::Application> createGui(

// Customize window
auto mainWin = app->findChild<ignition::gui::MainWindow *>();
if (_renderEngine != nullptr)
{
mainWin->SetRenderEngine(_renderEngine);
}
auto win = mainWin->QuickWindow();
win->setProperty("title", "Gazebo");

Expand Down Expand Up @@ -288,9 +292,11 @@ std::unique_ptr<ignition::gui::Application> createGui(
}

//////////////////////////////////////////////////
int runGui(int &_argc, char **_argv, const char *_guiConfig)
int runGui(int &_argc, char **_argv, const char *_guiConfig,
const char *_renderEngine)
{
auto app = gazebo::gui::createGui(_argc, _argv, _guiConfig);
auto app = gazebo::gui::createGui(
_argc, _argv, _guiConfig, nullptr, true, _renderEngine);
if (nullptr != app)
{
// Run main window.
Expand All @@ -299,8 +305,8 @@ int runGui(int &_argc, char **_argv, const char *_guiConfig)
igndbg << "Shutting down ign-gazebo-gui" << std::endl;
return 0;
}
else
return -1;

return -1;
}
} // namespace gui
} // namespace IGNITION_GAZEBO_VERSION_NAMESPACE
Expand Down
3 changes: 2 additions & 1 deletion src/gui/Gui_TEST.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ TEST_F(GuiTest, IGN_UTILS_TEST_DISABLED_ON_MAC(PathManager))
node.Advertise("/gazebo/resource_paths/get", pathsCb);
igndbg << "Paths advertised" << std::endl;

auto app = ignition::gazebo::gui::createGui(gg_argc, gg_argv, nullptr);
auto app = ignition::gazebo::gui::createGui(
gg_argc, gg_argv, nullptr, nullptr, false, nullptr);
EXPECT_NE(nullptr, app);
igndbg << "GUI created" << std::endl;

Expand Down
5 changes: 3 additions & 2 deletions src/ign.cc
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ extern "C" int runServer(const char *_sdfString,
}

//////////////////////////////////////////////////
extern "C" int runGui(const char *_guiConfig)
extern "C" int runGui(const char *_guiConfig, const char *_renderEngine)
{
// argc and argv are going to be passed to a QApplication. The Qt
// documentation has a warning about these:
Expand All @@ -371,5 +371,6 @@ extern "C" int runGui(const char *_guiConfig)
// be converted to a const char *. The const cast is here to prevent a warning
// since we do need to pass a char* to runGui
char *argv = const_cast<char *>("ign-gazebo-gui");
return ignition::gazebo::gui::runGui(argc, &argv, _guiConfig);
return ignition::gazebo::gui::runGui(
argc, &argv, _guiConfig, _renderEngine);
}
3 changes: 2 additions & 1 deletion src/ign.hh
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ extern "C" int runServer(const char *_sdfString,

/// \brief External hook to run simulation GUI.
/// \param[in] _guiConfig Path to Ignition GUI configuration file.
/// \param[in] _renderEngine --render-engine-gui option
/// \return 0 if successful, 1 if not.
extern "C" int runGui(const char *_guiConfig);
extern "C" int runGui(const char *_guiConfig, const char *_renderEngine);

/// \brief External hook to find or download a fuel world provided a URL.
/// \param[in] _pathToResource Path to the fuel world resource, ie,
Expand Down