30 #include <QApplication> 33 #include <boost/program_options.hpp> 35 #include <OgreMaterialManager.h> 36 #include <OgreGpuProgramManager.h> 37 #include <OgreHighLevelGpuProgramManager.h> 38 #include <std_srvs/Empty.h> 41 #include <ApplicationServices/ApplicationServices.h> 60 #define CATCH_EXCEPTIONS 0 62 namespace po = boost::program_options;
67 bool reloadShaders(std_srvs::Empty::Request&, std_srvs::Empty::Response&)
71 Ogre::ResourceManager::ResourceMapIterator it = Ogre::MaterialManager::getSingleton().getResourceIterator();
72 while (it.hasMoreElements())
74 Ogre::ResourcePtr resource = it.getNext();
78 ROS_INFO(
"Reloading high-level gpu shaders.");
80 Ogre::ResourceManager::ResourceMapIterator it = Ogre::HighLevelGpuProgramManager::getSingleton().getResourceIterator();
81 while (it.hasMoreElements())
83 Ogre::ResourcePtr resource = it.getNext();
89 Ogre::ResourceManager::ResourceMapIterator it = Ogre::GpuProgramManager::getSingleton().getResourceIterator();
90 while (it.hasMoreElements())
92 Ogre::ResourcePtr resource = it.getNext();
101 , continue_timer_( 0 )
114 ROS_INFO(
"compiled against Qt version " QT_VERSION_STR );
115 ROS_INFO(
"compiled against OGRE version %d.%d.%d%s (%s)",
116 OGRE_VERSION_MAJOR, OGRE_VERSION_MINOR, OGRE_VERSION_PATCH,
117 OGRE_VERSION_SUFFIX, OGRE_VERSION_NAME );
120 ProcessSerialNumber PSN;
121 GetCurrentProcess(&PSN);
122 TransformProcessType(&PSN,kProcessTransformToForegroundApplication);
123 SetFrontProcess(&PSN);
134 po::options_description
options;
135 options.add_options()
136 (
"help,h",
"Produce this help message")
137 (
"splash-screen,s", po::value<std::string>(),
"A custom splash-screen image to display")
138 (
"help-file", po::value<std::string>(),
"A custom html file to show as the help screen")
139 (
"display-config,d", po::value<std::string>(),
"A display config file (.rviz) to load")
140 (
"fixed-frame,f", po::value<std::string>(),
"Set the fixed frame")
141 (
"ogre-log,l",
"Enable the Ogre.log file (output in cwd) and console output.")
142 (
"in-mc-wrapper",
"Signal that this is running inside a master-chooser wrapper")
143 (
"opengl", po::value<int>(),
"Force OpenGL version (use '--opengl 210' for OpenGL 2.1 compatibility mode)")
144 (
"disable-anti-aliasing",
"Prevent rviz from trying to use anti-aliasing when rendering.")
145 (
"no-stereo",
"Disable the use of stereo rendering.")
146 (
"verbose,v",
"Enable debug visualizations")
147 (
"log-level-debug",
"Sets the ROS logger level to debug.");
148 po::variables_map vm;
149 std::string display_config, fixed_frame, splash_path, help_path;
150 bool enable_ogre_log =
false;
151 bool in_mc_wrapper =
false;
152 bool verbose =
false;
153 int force_gl_version = 0;
154 bool disable_anti_aliasing =
false;
155 bool disable_stereo =
false;
158 po::store( po::parse_command_line( argc, argv, options ), vm );
161 if( vm.count(
"help" ))
163 std::cout <<
"rviz command line options:\n" << options;
167 if( vm.count(
"in-mc-wrapper" ))
169 in_mc_wrapper =
true;
172 if (vm.count(
"display-config"))
174 display_config = vm[
"display-config"].as<std::string>();
175 if (display_config.size() >= 4 && display_config.substr( display_config.size() - 4, 4 ) ==
".vcg")
177 std::cerr <<
"ERROR: the config file '" << display_config <<
"' is a .vcg file, which is the old rviz config format." << std::endl;
178 std::cerr <<
" New config files have a .rviz extension and use YAML formatting. The format changed" << std::endl;
179 std::cerr <<
" between Fuerte and Groovy. There is not (yet) an automated conversion program." << std::endl;
184 if (vm.count(
"splash-screen"))
186 splash_path = vm[
"splash-screen"].as<std::string>();
189 if (vm.count(
"help-file"))
191 help_path = vm[
"help-file"].as<std::string>();
194 if (vm.count(
"fixed-frame"))
196 fixed_frame = vm[
"fixed-frame"].as<std::string>();
199 if (vm.count(
"ogre-log"))
201 enable_ogre_log =
true;
204 if (vm.count(
"no-stereo"))
206 disable_stereo =
true;
209 if (vm.count(
"opengl"))
212 force_gl_version = vm[
"opengl"].as<
int>();
215 if (vm.count(
"disable-anti-aliasing"))
217 disable_anti_aliasing =
true;
220 if (vm.count(
"verbose"))
225 if (vm.count(
"log-level-debug"))
233 catch (std::exception& e)
235 ROS_ERROR(
"Error parsing command line: %s", e.what());
242 if( dialog->exec() != QDialog::Accepted )
250 if( enable_ogre_log )
255 if ( force_gl_version )
260 if (disable_anti_aliasing)
265 if ( disable_stereo )
272 if( help_path !=
"" )
277 if( vm.count(
"splash-screen") )
282 if( !fixed_frame.empty() )
296 catch (std::exception& e)
298 ROS_ERROR(
"Caught exception while loading: %s", e.what());
325 frame_->setWindowModified(
false );
327 QApplication::closeAllWindows();
void setApp(QApplication *app)
VisualizationManager * getManager()
ROSCONSOLE_DECL void notifyLoggerLevelsChanged()
bool reloadShaders(std_srvs::Empty::Request &, std_srvs::Empty::Response &)
void startContinueChecker()
void setSplashPath(const QString &splash_path)
Set the path to the "splash" image file. This image is shown during initialization and loading of the...
static void forceGlVersion(int version)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void setFixedFrame(const QString &frame)
Set the coordinate frame we should be transforming all fixed data into.
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
ros::ServiceServer reload_shaders_service_
static void disableAntiAliasing()
void initialize(const QString &display_config_file="")
Initialize the visualizer. Creates the VisualizationManager.
void setDebugMode(bool debug)
Enables or disables publishing of picking and depth rendering images.
std::string get_version()
void setHelpPath(const QString &help_path)
Set the path to the help file. Should contain HTML. Default is a file in the RViz package...
bool init(int argc, char **argv)
SelectionManager * getSelectionManager() const
Return a pointer to the SelectionManager.
VisualizationFrame * frame_
static void forceNoStereo()
ROSCONSOLE_DECL bool set_logger_level(const std::string &name, levels::Level level)
void setApp(QApplication *app)
void setShowChooseNewMaster(bool show)
Call this before initialize() to have it take effect.
#define ROSCONSOLE_DEFAULT_NAME
static void useRosLog()
Configure Ogre to write output to the ROS logger.