Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "visualization_panel.h"
00031 #include "render_panel.h"
00032 #include "displays_panel.h"
00033 #include "visualization_manager.h"
00034 #include "config.h"
00035
00036 #include <ros/package.h>
00037 #include <ros/console.h>
00038
00039 #include <ogre_tools/initialization.h>
00040 #include <ogre_tools/render_system.h>
00041
00042 namespace rviz
00043 {
00044
00045 VisualizationPanel::VisualizationPanel(QWidget* parent)
00046 : QSplitter( parent )
00047 {
00048 if( !ros::isInitialized() )
00049 {
00050 int argc = 0;
00051 ros::init(argc, 0, "rviz", ros::init_options::AnonymousName);
00052 }
00053
00054 displays_panel_ = new DisplaysPanel( this );
00055 render_panel_ = new RenderPanel( ogre_tools::RenderSystem::get(), 0, this );
00056
00057 QList<int> sizes;
00058 sizes.push_back( 300 );
00059 sizes.push_back( 500 );
00060 setSizes( sizes );
00061
00062 std::string package_path = ros::package::getPath("rviz_qt");
00063 ogre_tools::V_string paths;
00064 paths.push_back(package_path + "/ogre_media/textures");
00065 ogre_tools::initializeResources( paths );
00066
00067 manager_ = new VisualizationManager( render_panel_ );
00068 render_panel_->initialize( manager_->getSceneManager(), manager_ );
00069 displays_panel_->initialize( manager_ );
00070
00071 manager_->initialize();
00072 manager_->startUpdate();
00073 }
00074
00075 VisualizationPanel::~VisualizationPanel()
00076 {
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 if( manager_ )
00088 {
00089 manager_->removeAllDisplays();
00090 }
00091
00092 delete render_panel_;
00093
00094
00095
00096
00097 delete manager_;
00098 }
00099
00100 void VisualizationPanel::loadGeneralConfig(const std::string& filepath)
00101 {
00102 boost::shared_ptr<Config> config( new Config() );
00103 config->readFromFile( filepath );
00104 manager_->loadGeneralConfig( config );
00105 }
00106
00107 void VisualizationPanel::loadDisplayConfig(const std::string& filepath)
00108 {
00109 manager_->removeAllDisplays();
00110
00111 boost::shared_ptr<Config> config( new Config() );
00112 config->readFromFile( filepath );
00113 manager_->loadDisplayConfig( config );
00114 }
00115
00116 }