5050#include " rviz_common/visualization_frame.hpp"
5151#include " rviz_common/visualization_manager.hpp"
5252
53- // TODO(wjwwood): figure out a non-depricated way to do this
54- #if 0
55- #ifdef Q_OS_MAC
56- #include <ApplicationServices/ApplicationServices.h>
57- // Apparently OSX #defines 'check' to be an empty string somewhere.
58- // That was fun to figure out.
59- #undef check
60- #endif
61- #endif
62-
63- // #include "rviz/env_config.h"
64- // #include "rviz/ogre_helpers/ogre_logging.h"
65- // #include "rviz/ogre_helpers/render_system.h"
66- // #include "rviz/wait_for_master_dialog.h"
67-
6853namespace rviz_common
6954{
7055
71- // TODO(wjwwood): reenable the service to reload the shaders
72- // bool
73- // reloadShaders(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
74- // {
75- // ROS_INFO("Reloading materials.");
76- // {
77- // Ogre::ResourceManager::ResourceMapIterator it =
78- // Ogre::MaterialManager::getSingleton().getResourceIterator();
79- // while (it.hasMoreElements()) {
80- // Ogre::ResourcePtr resource = it.getNext();
81- // resource->reload();
82- // }
83- // }
84- // ROS_INFO("Reloading high-level gpu shaders.");
85- // {
86- // Ogre::ResourceManager::ResourceMapIterator it =
87- // Ogre::HighLevelGpuProgramManager::getSingleton().getResourceIterator();
88- // while (it.hasMoreElements()) {
89- // Ogre::ResourcePtr resource = it.getNext();
90- // resource->reload();
91- // }
92- // }
93- // ROS_INFO("Reloading gpu shaders.");
94- // {
95- // Ogre::ResourceManager::ResourceMapIterator it =
96- // Ogre::GpuProgramManager::getSingleton().getResourceIterator();
97- // while (it.hasMoreElements()) {
98- // Ogre::ResourcePtr resource = it.getNext();
99- // resource->reload();
100- // }
101- // }
102- // return true;
103- // }
104-
10556VisualizerApp::VisualizerApp (
10657 std::unique_ptr<rviz_common::ros_integration::RosClientAbstractionIface> ros_client_abstraction)
10758: app_(0 ),
@@ -128,34 +79,19 @@ void VisualizerApp::loadConfig(QString config_path)
12879
12980bool VisualizerApp::init (int argc, char ** argv)
13081{
131- // TODO(wjwwood): find a way to get the versions and print them here
132- // also include versions of more things, like rviz_rendering,
133- // rviz_common, and the plugins
134- // RVIZ_COMMON_LOG_INFO_STREAM("rviz version " << get_version().c_str());
135- // RVIZ_COMMON_LOG_INFO("compiled against Qt version " QT_VERSION_STR);
136- // RVIZ_COMMON_LOG_INFO_STREAM(
137- // "compiled against OGRE version " <<
138- // OGRE_VERSION_MAJOR << "." <<
139- // OGRE_VERSION_MINOR << "." <<
140- // OGRE_VERSION_PATCH << OGRE_VERSION_SUFFIX <<
141- // " (" << OGRE_VERSION_NAME << ")");
142-
143- // TODO(wjwwood): figure out a non-depricated way to do this
144- #if 0
145- #ifdef Q_OS_MAC
146- ProcessSerialNumber PSN;
147- GetCurrentProcess(&PSN);
148- TransformProcessType(&PSN, kProcessTransformToForegroundApplication);
149- SetFrontProcess(&PSN);
150- #endif
151- #endif
152-
15382 rviz_common::install_rviz_rendering_log_handlers ();
15483
15584 QCommandLineParser parser;
15685 parser.setApplicationDescription (" 3D visualization tool for ROS2" );
15786 parser.addHelpOption ();
15887
88+ QCommandLineOption display_title_format_option (
89+ QStringList () << " t" << " display-title-format" ,
90+ " A display title format like " ,
91+ " \" {NAMESPACE} - {CONFIG_PATH}/{CONFIG_FILENAME} - RViz2\" " ,
92+ " display_title_format" );
93+ parser.addOption (display_title_format_option);
94+
15995 QCommandLineOption display_config_option (
16096 QStringList () << " d" << " display-config" ,
16197 " A display config file (.rviz) to load" ,
@@ -176,43 +112,12 @@ bool VisualizerApp::init(int argc, char ** argv)
176112 " A custom splash-screen image to display" , " splash_path" );
177113 parser.addOption (splash_screen_option);
178114
179- // TODO(botteroa-si): enable when possible
180- // QCommandLineOption help_file_option(
181- // "help-file", "A custom html file to show as the help screen", "help_path");
182- // parser.addOption(help_file_option);
183- //
184- // QCommandLineOption open_gl_option(
185- // "opengl",
186- // "Force OpenGL version (use '--opengl 210' for OpenGL 2.1 compatibility mode)",
187- // "version");
188- // parser.addOption(open_gl_option);
189- //
190- // QCommandLineOption disable_anti_aliasing_option(
191- // "disable-anti-aliasing", "Prevent rviz from trying to use anti-aliasing when rendering.");
192- // parser.addOption(disable_anti_aliasing_option);
193- //
194- // QCommandLineOption no_stereo_option("no-stereo", "Disable the use of stereo rendering.");
195- // parser.addOption(no_stereo_option);
196- //
197- // QCommandLineOption log_level_debug_option(
198- // "log-level-debug", "Sets the ROS logger level to debug.");
199- // parser.addOption(log_level_debug_option);
200-
201- // ("in-mc-wrapper", "Signal that this is running inside a master-chooser wrapper")
202-
203- QString display_config, fixed_frame, splash_path, help_path;
115+ QString display_config, fixed_frame, splash_path, help_path, display_title_format;
204116 bool enable_ogre_log;
205- // TODO(botteroa-si): enable when possible
206- // bool in_mc_wrapper = false;
207- // int force_gl_version = 0;
208- // bool disable_anti_aliasing = false;
209- // bool disable_stereo = false;
210117
211- parser.process (*app_);
118+ if (app_) { parser.process (*app_);}
212119
213120 enable_ogre_log = parser.isSet (ogre_log_option);
214- // disable_stereo = parser.isSet(no_stereo_option);
215- // disable_anti_aliasing = parser.isSet(disable_anti_aliasing_option);
216121
217122 if (parser.isSet (display_config_option)) {
218123 display_config = parser.value (display_config_option);
@@ -224,72 +129,30 @@ bool VisualizerApp::init(int argc, char ** argv)
224129 if (parser.isSet (splash_screen_option)) {
225130 splash_path = parser.value (splash_screen_option);
226131 }
227- // TODO(botteroa-si): enable when possible
228- // if (parser.isSet(help_file_option)) {
229- // help_path = parser.value(help_file_option);
230- // }
231- // if (parser.isSet(open_gl_option)) {
232- // force_gl_version = parser.value(open_gl_option).toInt();
233- // }
234-
235- // if (vm.count("in-mc-wrapper")) {
236- // in_mc_wrapper = true;
237- // }
238- //
239- //
240- // if (vm.count("log-level-debug")) {
241- // if (
242- // ros::console::set_logger_level(ROSCONSOLE_DEFAULT_NAME, ros::console::levels::Debug))
243- // {
244- // ros::console::notifyLoggerLevelsChanged();
245- // }
246- // }
247-
248- //
249- // if (!ros::master::check() ) {
250- // TODO(wjwwood): figure out how to support the "wait for master" functionality
251- // while also using the rviz_common/ros_integration abstraction
252- // WaitForMasterDialog * dialog = new WaitForMasterDialog;
253- // if (dialog->exec() != QDialog::Accepted) {
254- // return false;
255- // }
256- // }
257- //
258- // nh_.reset(new ros::NodeHandle);
259- //
132+
133+ if (parser.isSet (display_title_format_option)) {
134+ display_title_format = parser.value (display_title_format_option);
135+ }
136+
260137 if (enable_ogre_log) {
261138 rviz_rendering::OgreLogging::get ()->useLogFileAndStandardOut ();
262139 rviz_rendering::OgreLogging::get ()->configureLogging ();
263140 }
264- //
265- // if (force_gl_version) {
266- // RenderSystem::forceGlVersion(force_gl_version);
267- // }
268- //
269- // if (disable_anti_aliasing) {
270- // RenderSystem::disableAntiAliasing();
271- // }
272- //
273- // if (disable_stereo) {
274- // RenderSystem::forceNoStereo();
275- // }
276141
277142 startContinueChecker ();
278143
279- // TODO(wjwwood): anonymous is not working right now, reenable later
280- // node_name_ = rviz_common::ros_integration::init(argc, argv, "rviz", true /* anonymous_name */);
281144 node_ = ros_client_abstraction_->init (argc, argv, " rviz" , false /* anonymous_name */ );
282145
283146 frame_ = new VisualizationFrame (node_);
147+
148+ frame_->setDisplayTitleFormat (display_title_format);
149+
284150 frame_->setApp (this ->app_ );
285151
286152 if (!help_path.isEmpty ()) {
287153 frame_->setHelpPath (help_path);
288154 }
289155
290- // TODO(wjwwood): figure out how to preserve the "choost new master" feature
291- // frame_->setShowChooseNewMaster(in_mc_wrapper);
292-
293156 if (!splash_path.isEmpty ()) {
294157 frame_->setSplashPath (splash_path);
295158 }
@@ -301,10 +164,6 @@ bool VisualizerApp::init(int argc, char ** argv)
301164
302165 frame_->show ();
303166
304- // TODO(wjwwood): reenable the ROS service to reload the shaders via the ros_integration API
305- // ros::NodeHandle private_nh("~");
306- // reload_shaders_service_ = private_nh.advertiseService("reload_shaders", reloadShaders);
307-
308167 return true ;
309168}
310169
0 commit comments