From d33f99752ce53fcdc2e6eab3782eb7e91efff7c4 Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Sun, 1 Sep 2019 19:55:00 +0200 Subject: [PATCH] improve cmdline parsing and add --fullscreen option --- src/rviz/visualization_frame.cpp | 2 +- src/rviz/visualization_frame.h | 12 ++-- src/rviz/visualizer_app.cpp | 112 +++++++------------------------ 3 files changed, 32 insertions(+), 94 deletions(-) diff --git a/src/rviz/visualization_frame.cpp b/src/rviz/visualization_frame.cpp index 0a008ed608..9e1f2fa798 100644 --- a/src/rviz/visualization_frame.cpp +++ b/src/rviz/visualization_frame.cpp @@ -880,7 +880,7 @@ void VisualizationFrame::loadWindowGeometry( const Config& config ) } } - bool b; + bool b = false; config.mapGetBool( "Hide Left Dock", &b ); hide_left_dock_button_->setChecked( b ); hideLeftDock(b); diff --git a/src/rviz/visualization_frame.h b/src/rviz/visualization_frame.h index c91c1f0338..6fa0b3dcd3 100644 --- a/src/rviz/visualization_frame.h +++ b/src/rviz/visualization_frame.h @@ -173,6 +173,12 @@ public Q_SLOTS: /** Set the message displayed in the status bar */ virtual void setStatus( const QString & message ); + /** @brief Set full screen mode. */ + void setFullScreen( bool full_screen ); + + /** @brief Exit full screen mode. */ + void exitFullScreen(); + Q_SIGNALS: /** @brief Emitted during file-loading and initialization to indicate progress. */ void statusUpdate( const QString& message ); @@ -236,12 +242,6 @@ protected Q_SLOTS: * the name of the panel. */ void onDeletePanel(); - /** @brief Set full screen mode. */ - void setFullScreen( bool full_screen ); - - /** @brief Exit full screen mode. */ - void exitFullScreen(); - protected Q_SLOTS: /** @brief Set loading_ to false. */ void markLoadingDone(); diff --git a/src/rviz/visualizer_app.cpp b/src/rviz/visualizer_app.cpp index 5460ddfd08..5b71154a99 100644 --- a/src/rviz/visualizer_app.cpp +++ b/src/rviz/visualizer_app.cpp @@ -131,28 +131,25 @@ bool VisualizerApp::init( int argc, char** argv ) startContinueChecker(); + std::string display_config, fixed_frame, splash_path, help_path; + int force_gl_version = 0; + po::options_description options; options.add_options() ("help,h", "Produce this help message") - ("splash-screen,s", po::value(), "A custom splash-screen image to display") - ("help-file", po::value(), "A custom html file to show as the help screen") - ("display-config,d", po::value(), "A display config file (.rviz) to load") - ("fixed-frame,f", po::value(), "Set the fixed frame") + ("splash-screen,s", po::value(&splash_path), "A custom splash-screen image to display") + ("help-file", po::value(&help_path), "A custom html file to show as the help screen") + ("display-config,d", po::value(&display_config), "A display config file (.rviz) to load") + ("fullscreen", "Trigger fullscreen display") + ("fixed-frame,f", po::value(&fixed_frame), "Set the fixed frame") ("ogre-log,l", "Enable the Ogre.log file (output in cwd) and console output.") ("in-mc-wrapper", "Signal that this is running inside a master-chooser wrapper") - ("opengl", po::value(), "Force OpenGL version (use '--opengl 210' for OpenGL 2.1 compatibility mode)") + ("opengl", po::value(&force_gl_version), "Force OpenGL version (use '--opengl 210' for OpenGL 2.1 compatibility mode)") ("disable-anti-aliasing", "Prevent rviz from trying to use anti-aliasing when rendering.") ("no-stereo", "Disable the use of stereo rendering.") ("verbose,v", "Enable debug visualizations") ("log-level-debug", "Sets the ROS logger level to debug."); po::variables_map vm; - std::string display_config, fixed_frame, splash_path, help_path; - bool enable_ogre_log = false; - bool in_mc_wrapper = false; - bool verbose = false; - int force_gl_version = 0; - bool disable_anti_aliasing = false; - bool disable_stereo = false; try { po::store( po::parse_command_line( argc, argv, options ), vm ); @@ -164,62 +161,12 @@ bool VisualizerApp::init( int argc, char** argv ) return false; } - if( vm.count( "in-mc-wrapper" )) - { - in_mc_wrapper = true; - } - - if (vm.count("display-config")) - { - display_config = vm["display-config"].as(); - if (display_config.size() >= 4 && display_config.substr( display_config.size() - 4, 4 ) == ".vcg") - { - std::cerr << "ERROR: the config file '" << display_config << "' is a .vcg file, which is the old rviz config format." << std::endl; - std::cerr << " New config files have a .rviz extension and use YAML formatting. The format changed" << std::endl; - std::cerr << " between Fuerte and Groovy. There is not (yet) an automated conversion program." << std::endl; - return false; - } - } - - if (vm.count("splash-screen")) - { - splash_path = vm["splash-screen"].as(); - } - - if (vm.count("help-file")) - { - help_path = vm["help-file"].as(); - } - - if (vm.count("fixed-frame")) - { - fixed_frame = vm["fixed-frame"].as(); - } - - if (vm.count("ogre-log")) - { - enable_ogre_log = true; - } - - if (vm.count("no-stereo")) + if (display_config.size() >= 4 && display_config.substr( display_config.size() - 4, 4 ) == ".vcg") { - disable_stereo = true; - } - - if (vm.count("opengl")) - { - //std::cout << vm["opengl"].as() << std::endl; - force_gl_version = vm["opengl"].as(); - } - - if (vm.count("disable-anti-aliasing")) - { - disable_anti_aliasing = true; - } - - if (vm.count("verbose")) - { - verbose = true; + std::cerr << "ERROR: the config file '" << display_config << "' is a .vcg file, which is the old rviz config format." << std::endl; + std::cerr << " New config files have a .rviz extension and use YAML formatting. The format changed" << std::endl; + std::cerr << " between Fuerte and Groovy. There is not (yet) an automated conversion program." << std::endl; + return false; } if (vm.count("log-level-debug")) @@ -247,25 +194,16 @@ bool VisualizerApp::init( int argc, char** argv ) nh_.reset( new ros::NodeHandle ); - if( enable_ogre_log ) - { + if (vm.count("ogre-log")) OgreLogging::useRosLog(); - } - if ( force_gl_version ) - { - RenderSystem::forceGlVersion( force_gl_version ); - } + RenderSystem::forceGlVersion( force_gl_version ); - if (disable_anti_aliasing) - { + if (vm.count("disable-anti-aliasing")) RenderSystem::disableAntiAliasing(); - } - if ( disable_stereo ) - { + if (vm.count("no-stereo")) RenderSystem::forceNoStereo(); - } frame_ = new VisualizationFrame(); frame_->setApp( this->app_ ); @@ -273,19 +211,19 @@ bool VisualizerApp::init( int argc, char** argv ) { frame_->setHelpPath( QString::fromStdString( help_path )); } - frame_->setShowChooseNewMaster( in_mc_wrapper ); + frame_->setShowChooseNewMaster( vm.count( "in-mc-wrapper" ) > 0 ); if( vm.count("splash-screen") ) - { - frame_->setSplashPath( QString::fromStdString( splash_path )); - } + frame_->setSplashPath( QString::fromStdString( splash_path ) ); + frame_->initialize( QString::fromStdString( display_config )); + if( !fixed_frame.empty() ) - { frame_->getManager()->setFixedFrame( QString::fromStdString( fixed_frame )); - } - frame_->getManager()->getSelectionManager()->setDebugMode( verbose ); + frame_->getManager()->getSelectionManager()->setDebugMode( vm.count("verbose") > 0 ); + if ( vm.count( "fullscreen" ) ) + frame_->setFullScreen(true); frame_->show(); ros::NodeHandle private_nh("~");