30 #include <QApplication> 33 #include <boost/program_options.hpp> 34 #include <boost/filesystem.hpp> 36 #include <OgreMaterialManager.h> 37 #include <OgreGpuProgramManager.h> 38 #include <OgreHighLevelGpuProgramManager.h> 39 #include <std_srvs/Empty.h> 42 #include <ApplicationServices/ApplicationServices.h> 61 #define CATCH_EXCEPTIONS 0 63 namespace po = boost::program_options;
64 namespace fs = boost::filesystem;
68 bool reloadShaders(std_srvs::Empty::Request& , std_srvs::Empty::Response& )
72 Ogre::ResourceManager::ResourceMapIterator it =
73 Ogre::MaterialManager::getSingleton().getResourceIterator();
74 while (it.hasMoreElements())
76 Ogre::ResourcePtr resource = it.getNext();
80 ROS_INFO(
"Reloading high-level gpu shaders.");
82 Ogre::ResourceManager::ResourceMapIterator it =
83 Ogre::HighLevelGpuProgramManager::getSingleton().getResourceIterator();
84 while (it.hasMoreElements())
86 Ogre::ResourcePtr resource = it.getNext();
92 Ogre::ResourceManager::ResourceMapIterator it =
93 Ogre::GpuProgramManager::getSingleton().getResourceIterator();
94 while (it.hasMoreElements())
96 Ogre::ResourcePtr resource = it.getNext();
115 ROS_INFO(
"compiled against Qt version " QT_VERSION_STR);
116 ROS_INFO(
"compiled against OGRE version %d.%d.%d%s (%s)", OGRE_VERSION_MAJOR, OGRE_VERSION_MINOR,
117 OGRE_VERSION_PATCH, OGRE_VERSION_SUFFIX, OGRE_VERSION_NAME);
120 ProcessSerialNumber PSN;
121 GetCurrentProcess(&PSN);
122 TransformProcessType(&PSN, kProcessTransformToForegroundApplication);
123 SetFrontProcess(&PSN);
134 std::string display_config, fixed_frame, splash_path, help_path;
135 int force_gl_version = 0;
137 po::options_description
options;
138 options.add_options()
139 (
"help,h",
"Produce this help message")
140 (
"splash-screen,s", po::value<std::string>(&splash_path),
141 "A custom splash-screen image to display")
142 (
"help-file", po::value<std::string>(&help_path),
143 "A custom html file to show as the help screen")
144 (
"display-config,d", po::value<std::string>(&display_config),
145 "A display config file (.rviz) to load")
146 (
"fullscreen",
"Trigger fullscreen display")
147 (
"fixed-frame,f", po::value<std::string>(&fixed_frame),
"Set the fixed frame")
148 (
"ogre-log,l",
"Enable the Ogre.log file (output in cwd) and console output.")
149 (
"in-mc-wrapper",
"Signal that this is running inside a master-chooser wrapper")
150 (
"opengl", po::value<int>(&force_gl_version),
151 "Force OpenGL version (use '--opengl 210' for OpenGL 2.1 compatibility mode)")
152 (
"disable-anti-aliasing",
"Prevent rviz from trying to use anti-aliasing when rendering.")
153 (
"no-stereo",
"Disable the use of stereo rendering.")(
"verbose,v",
"Enable debug visualizations")
154 (
"log-level-debug",
"Sets the ROS logger level to debug.");
156 po::variables_map vm;
159 po::store(po::parse_command_line(argc, argv, options), vm);
162 if (vm.count(
"help"))
164 std::cout <<
"rviz command line options:\n" << options;
168 if (vm.count(
"log-level-debug"))
176 catch (std::exception& e)
178 ROS_ERROR(
"Error parsing command line: %s", e.what());
185 if (dialog.exec() != QDialog::Accepted)
193 if (vm.count(
"ogre-log"))
198 if (vm.count(
"disable-anti-aliasing"))
201 if (vm.count(
"no-stereo"))
206 if (!help_path.empty())
211 if (vm.count(
"splash-screen"))
216 if (!fixed_frame.empty())
221 if (vm.count(
"fullscreen"))
235 catch (std::exception& e)
237 ROS_ERROR(
"Caught exception while loading: %s", e.what());
264 frame_->setWindowModified(
false);
266 QApplication::closeAllWindows();
272 fs::path path = req.path.data;
273 if (fs::is_regular_file(path))
bool saveConfigCallback(rviz::SendFilePathRequest &req, rviz::SendFilePathResponse &res)
void setApp(QApplication *app)
VisualizationManager * getManager()
bool loadConfigCallback(rviz::SendFilePathRequest &req, rviz::SendFilePathResponse &res)
ROSCONSOLE_DECL void notifyLoggerLevelsChanged()
bool saveDisplayConfig(const QString &path)
Save display and other settings to the given file.
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.
~VisualizerApp() override
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
ros::ServiceServer reload_shaders_service_
ros::ServiceServer load_config_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.
void setFullScreen(bool full_screen)
Set full screen mode.
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)
VisualizationFrame * frame_
bool loadDisplayConfigHelper(const std::string &full_path)
Load display and other settings from the given full file path.
SelectionManager * getSelectionManager() const override
Return a pointer to the SelectionManager.
static void forceNoStereo()
ros::ServiceServer save_config_service_
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.