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_frame.h"
00031 #include "render_panel.h"
00032 #include "displays_panel.h"
00033 #include "views_panel.h"
00034 #include "time_panel.h"
00035 #include "selection_panel.h"
00036 #include "tool_properties_panel.h"
00037 #include "visualization_manager.h"
00038 #include "tools/tool.h"
00039 #include "plugin_manager_dialog.h"
00040 #include "splash_screen.h"
00041 #include "loading_dialog.h"
00042 #include "common.h"
00043
00044 #include <ros/package.h>
00045 #include <ros/console.h>
00046
00047 #include <ogre_tools/initialization.h>
00048
00049 #include <wx/config.h>
00050 #include <wx/confbase.h>
00051 #include <wx/stdpaths.h>
00052 #include <wx/menu.h>
00053 #include <wx/toolbar.h>
00054 #include <wx/aui/aui.h>
00055 #include <wx/filedlg.h>
00056 #include <wx/artprov.h>
00057
00058 #include <boost/filesystem.hpp>
00059 #include <boost/bind.hpp>
00060 #include <boost/algorithm/string/split.hpp>
00061 #include <boost/algorithm/string/trim.hpp>
00062
00063 namespace fs = boost::filesystem;
00064
00065 #define CONFIG_WINDOW_X wxT("/Window/X")
00066 #define CONFIG_WINDOW_Y wxT("/Window/Y")
00067 #define CONFIG_WINDOW_WIDTH wxT("/Window/Width")
00068 #define CONFIG_WINDOW_HEIGHT wxT("/Window/Height")
00069 #define CONFIG_AUIMANAGER_PERSPECTIVE wxT("/AuiManagerPerspective")
00070 #define CONFIG_AUIMANAGER_PERSPECTIVE_VERSION wxT("/AuiManagerPerspectiveVersion")
00071 #define CONFIG_RECENT_CONFIGS wxT("/RecentConfigs")
00072 #define CONFIG_LAST_DIR wxT("/LastConfigDir")
00073
00074 #define CONFIG_EXTENSION "vcg"
00075 #define CONFIG_EXTENSION_WILDCARD "*."CONFIG_EXTENSION
00076 #define PERSPECTIVE_VERSION 2
00077
00078 #define RECENT_CONFIG_COUNT 10
00079
00080 namespace rviz
00081 {
00082
00083 namespace toolbar_items
00084 {
00085 enum ToolbarItem
00086 {
00087 Count,
00088 };
00089 }
00090 typedef toolbar_items::ToolbarItem ToolbarItem;
00091
00092 VisualizationFrame::VisualizationFrame(wxWindow* parent)
00093 : wxFrame(parent, wxID_ANY, wxT("RViz"), wxDefaultPosition, wxSize(1024, 768), wxDEFAULT_FRAME_STYLE)
00094 , menubar_(NULL)
00095 , file_menu_(NULL)
00096 , recent_configs_menu_(NULL)
00097 , aui_manager_(NULL)
00098 {
00099 wxInitAllImageHandlers();
00100 }
00101
00102 VisualizationFrame::~VisualizationFrame()
00103 {
00104 Disconnect(wxEVT_AUI_PANE_CLOSE, wxAuiManagerEventHandler(VisualizationFrame::onPaneClosed), NULL, this);
00105 #if !defined(__WXMAC__)
00106 toolbar_->Disconnect( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( VisualizationFrame::onToolClicked ), NULL, this );
00107 #endif
00108
00109 saveConfigs();
00110
00111 manager_->removeAllDisplays();
00112
00113 aui_manager_->UnInit();
00114 delete aui_manager_;
00115
00116 render_panel_->Destroy();
00117 delete manager_;
00118 }
00119
00120 void VisualizationFrame::onSplashLoadStatus(const std::string& status, SplashScreen* splash)
00121 {
00122 splash->setState(status);
00123 }
00124
00125 void VisualizationFrame::initialize(const std::string& display_config_file, const std::string& fixed_frame, const std::string& target_frame)
00126 {
00127 initConfigs();
00128
00129 wxPoint pos = GetPosition();
00130 wxSize size = GetSize();
00131 int width = size.GetWidth();
00132 int height = size.GetHeight();
00133 general_config_->Read(CONFIG_WINDOW_X, &pos.x, pos.x);
00134 general_config_->Read(CONFIG_WINDOW_Y, &pos.y, pos.y);
00135 general_config_->Read(CONFIG_WINDOW_WIDTH, &width, width);
00136 general_config_->Read(CONFIG_WINDOW_HEIGHT, &height, height);
00137
00138 {
00139 wxString str;
00140 if (general_config_->Read(CONFIG_RECENT_CONFIGS, &str))
00141 {
00142 std::string recent = (const char*)str.char_str();
00143
00144 boost::trim(recent);
00145 boost::split(recent_configs_, recent, boost::is_any_of (":"), boost::token_compress_on);
00146 }
00147
00148 if (general_config_->Read(CONFIG_LAST_DIR, &str))
00149 {
00150 last_config_dir_ = (const char*)str.char_str();
00151 }
00152 }
00153
00154 SetPosition(pos);
00155 SetSize(wxSize(width, height));
00156
00157 package_path_ = ros::package::getPath("rviz");
00158 #if BOOST_FILESYSTEM_VERSION == 3
00159 std::string splash_path = (fs::path(package_path_) / "images/splash.png").string();
00160 #else
00161 std::string splash_path = (fs::path(package_path_) / "images/splash.png").file_string();
00162 #endif
00163 wxBitmap splash;
00164 splash.LoadFile(wxString::FromAscii(splash_path.c_str()));
00165 splash_ = new SplashScreen(this, splash);
00166 splash_->Show();
00167 splash_->setState("Initializing");
00168
00169 if (!ros::isInitialized())
00170 {
00171 int argc = 0;
00172 ros::init(argc, 0, "rviz", ros::init_options::AnonymousName);
00173 }
00174
00175 render_panel_ = new RenderPanel( this );
00176 displays_panel_ = new DisplaysPanel( this );
00177 views_panel_ = new ViewsPanel( this );
00178 time_panel_ = new TimePanel( this );
00179 selection_panel_ = new SelectionPanel( this );
00180 tool_properties_panel_ = new ToolPropertiesPanel(this);
00181
00182 splash_->setState("Initializing OGRE resources");
00183 ogre_tools::V_string paths;
00184 paths.push_back(package_path_ + "/ogre_media/textures");
00185 ogre_tools::initializeResources( paths );
00186
00187 #if !defined(__WXMAC__)
00188 toolbar_ = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_TEXT|wxTB_NOICONS|wxNO_BORDER|wxTB_HORIZONTAL);
00189 toolbar_->Connect( wxEVT_COMMAND_TOOL_CLICKED, wxCommandEventHandler( VisualizationFrame::onToolClicked ), NULL, this );
00190 #endif
00191
00192 aui_manager_ = new wxAuiManager(this);
00193 aui_manager_->AddPane(render_panel_, wxAuiPaneInfo().CenterPane().Name(wxT("Render")));
00194 aui_manager_->AddPane(displays_panel_, wxAuiPaneInfo().Left().MinSize(270, -1).Name(wxT("Displays")).Caption(wxT("Displays")));
00195 aui_manager_->AddPane(selection_panel_, wxAuiPaneInfo().Right().MinSize(270, -1).Name(wxT("Selection")).Caption(wxT("Selection")));
00196 aui_manager_->AddPane(views_panel_, wxAuiPaneInfo().BestSize(230, 200).Right().Name(wxT("Views")).Caption(wxT("Views")));
00197 aui_manager_->AddPane(tool_properties_panel_, wxAuiPaneInfo().BestSize(230, 200).Right().Name(wxT("Tool Properties")).Caption(wxT("Tool Properties")));
00198 aui_manager_->AddPane(time_panel_, wxAuiPaneInfo().RightDockable(false).LeftDockable(false).Bottom().Name(wxT("Time")).Caption(wxT("Time")));
00199 #if !defined(__WXMAC__)
00200 aui_manager_->AddPane(toolbar_, wxAuiPaneInfo().ToolbarPane().RightDockable(false).LeftDockable(false).Top().Name(wxT("Tools")).Caption(wxT("Tools")));
00201 #endif
00202 aui_manager_->Update();
00203
00204 Connect(wxEVT_AUI_PANE_CLOSE, wxAuiManagerEventHandler(VisualizationFrame::onPaneClosed), NULL, this);
00205
00206 manager_ = new VisualizationManager(render_panel_, this);
00207 render_panel_->initialize(manager_->getSceneManager(), manager_);
00208 displays_panel_->initialize(manager_);
00209 views_panel_->initialize(manager_);
00210 time_panel_->initialize(manager_);
00211 selection_panel_->initialize(manager_);
00212 tool_properties_panel_->initialize(manager_);
00213
00214 manager_->getToolAddedSignal().connect( boost::bind( &VisualizationFrame::onToolAdded, this, _1 ) );
00215 manager_->getToolChangedSignal().connect( boost::bind( &VisualizationFrame::onToolChanged, this, _1 ) );
00216
00217 manager_->initialize();
00218 manager_->loadGeneralConfig(general_config_, boost::bind(&VisualizationFrame::onSplashLoadStatus, this, _1, splash_));
00219
00220 bool display_config_valid = !display_config_file.empty();
00221 if (display_config_valid && !fs::exists(display_config_file))
00222 {
00223 ROS_ERROR("File [%s] does not exist", display_config_file.c_str());
00224 display_config_valid = false;
00225 }
00226
00227 if (!display_config_valid)
00228 {
00229 manager_->loadDisplayConfig(display_config_, boost::bind(&VisualizationFrame::onSplashLoadStatus, this, _1, splash_));
00230 }
00231 else
00232 {
00233 boost::shared_ptr<wxFileConfig> config(new wxFileConfig(wxT("standalone_visualizer"), wxEmptyString, wxEmptyString, wxString::FromAscii(display_config_file.c_str()), wxCONFIG_USE_GLOBAL_FILE|wxCONFIG_USE_RELATIVE_PATH));
00234 manager_->loadDisplayConfig(config, boost::bind(&VisualizationFrame::onSplashLoadStatus, this, _1, splash_));
00235 }
00236
00237 if (!fixed_frame.empty())
00238 {
00239 manager_->setFixedFrame(fixed_frame);
00240 }
00241
00242 if (!target_frame.empty())
00243 {
00244 manager_->setTargetFrame(target_frame);
00245 }
00246
00247 splash_->setState("Loading perspective");
00248
00249 wxString auimanager_perspective;
00250 long version = 0;
00251 if (general_config_->Read(CONFIG_AUIMANAGER_PERSPECTIVE_VERSION, &version))
00252 {
00253 if (version >= PERSPECTIVE_VERSION)
00254 {
00255 if (general_config_->Read(CONFIG_AUIMANAGER_PERSPECTIVE, &auimanager_perspective))
00256 {
00257 wxAuiPaneInfoArray panes_backup = aui_manager_->GetAllPanes();
00258 aui_manager_->LoadPerspective(auimanager_perspective);
00259
00260
00261
00262
00263 wxAuiPaneInfoArray& panes = aui_manager_->GetAllPanes();
00264 if (panes.GetCount() == panes_backup.GetCount())
00265 {
00266 for (uint32_t i = 0; i < panes.GetCount(); ++i)
00267 {
00268 if (!panes.Item(i).HasCloseButton())
00269 {
00270 panes.Item(i).Show( panes_backup.Item(i).IsShown() );
00271 }
00272 }
00273 }
00274 else
00275 {
00276 ROS_INFO("Number of panes changed during aui_manager_->LoadPerspective(). Can't update visibility of display windows.");
00277 }
00278 aui_manager_->Update();
00279 }
00280 }
00281 else
00282 {
00283 ROS_INFO("Perspective version has changed (version [%d] is less than version [%d], resetting windows", (int)version, PERSPECTIVE_VERSION);
00284 }
00285 }
00286
00287 initMenus();
00288 updateRecentConfigMenu();
00289 if (display_config_valid)
00290 {
00291 markRecentConfig(display_config_file);
00292 }
00293
00294 splash_->Destroy();
00295 splash_ = 0;
00296
00297 manager_->startUpdate();
00298 }
00299
00300 void VisualizationFrame::initConfigs()
00301 {
00302 config_dir_ = (const char*)wxStandardPaths::Get().GetUserConfigDir().fn_str();
00303 #if BOOST_FILESYSTEM_VERSION == 3
00304 std::string old_dir = (fs::path(config_dir_) / ".standalone_visualizer").string();
00305 config_dir_ = (fs::path(config_dir_) / ".rviz").string();
00306 general_config_file_ = (fs::path(config_dir_) / "config").string();
00307 display_config_file_ = (fs::path(config_dir_) / "display_config").string();
00308 #else
00309 std::string old_dir = (fs::path(config_dir_) / ".standalone_visualizer").file_string();
00310 config_dir_ = (fs::path(config_dir_) / ".rviz").file_string();
00311 general_config_file_ = (fs::path(config_dir_) / "config").file_string();
00312 display_config_file_ = (fs::path(config_dir_) / "display_config").file_string();
00313 #endif
00314
00315 if (fs::exists(old_dir) && !fs::exists(config_dir_))
00316 {
00317 ROS_INFO("Migrating old config directory to new location ([%s] to [%s])", old_dir.c_str(), config_dir_.c_str());
00318 fs::rename(old_dir, config_dir_);
00319 }
00320
00321 if (fs::is_regular_file(config_dir_))
00322 {
00323 ROS_INFO("Migrating old config file to new location ([%s] to [%s])", config_dir_.c_str(), general_config_file_.c_str());
00324 std::string backup_file = config_dir_ + "bak";
00325
00326 fs::rename(config_dir_, backup_file);
00327 fs::create_directory(config_dir_);
00328 fs::rename(backup_file, general_config_file_);
00329 }
00330 else if (!fs::exists(config_dir_))
00331 {
00332 fs::create_directory(config_dir_);
00333 }
00334
00335 if (fs::exists(general_config_file_) && !fs::exists(display_config_file_))
00336 {
00337 ROS_INFO("Creating display config from general config");
00338 fs::copy_file(general_config_file_, display_config_file_);
00339 }
00340
00341 ROS_INFO("Loading general config from [%s]", general_config_file_.c_str());
00342 general_config_.reset(new wxFileConfig(wxT("standalone_visualizer"), wxEmptyString, wxString::FromAscii(general_config_file_.c_str())));
00343 ROS_INFO("Loading display config from [%s]", display_config_file_.c_str());
00344 display_config_.reset(new wxFileConfig(wxT("standalone_visualizer"), wxEmptyString, wxString::FromAscii(display_config_file_.c_str())));
00345 }
00346
00347 void VisualizationFrame::initMenus()
00348 {
00349 menubar_ = new wxMenuBar();
00350 file_menu_ = new wxMenu(wxT(""));
00351 wxMenuItem* item = file_menu_->Append(wxID_OPEN, wxT("&Open Config\tCtrl-O"));
00352 Connect(item->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VisualizationFrame::onOpen), NULL, this);
00353 item = file_menu_->Append(wxID_SAVE, wxT("&Save Config\tCtrl-S"));
00354 Connect(item->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VisualizationFrame::onSave), NULL, this);
00355
00356 recent_configs_menu_ = new wxMenu(wxT(""));
00357 file_menu_->Append(wxID_ANY, wxT("&Recent Configs"), recent_configs_menu_);
00358
00359 file_menu_->AppendSeparator();
00360 item = file_menu_->Append(wxID_EXIT, wxT("&Quit"));
00361 Connect(item->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VisualizationFrame::onClose), NULL, this);
00362
00363 menubar_->Append(file_menu_, wxT("&File"));
00364
00365 view_menu_ = new wxMenu(wxT(""));
00366 wxAuiPaneInfoArray& panes = aui_manager_->GetAllPanes();
00367 for (uint32_t i = 0; i < panes.GetCount(); ++i)
00368 {
00369 wxAuiPaneInfo& pane = panes.Item(i);
00370
00371 if (pane.HasCloseButton())
00372 {
00373 item = view_menu_->AppendCheckItem(pane.window->GetId(), pane.caption);
00374 item->Check(pane.IsShown());
00375 Connect(item->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VisualizationFrame::onViewMenuItemSelected), NULL, this);
00376 }
00377 }
00378
00379 menubar_->Append(view_menu_, wxT("&View"));
00380
00381 plugins_menu_ = new wxMenu(wxT(""));
00382 item = plugins_menu_->Append(wxID_ANY, wxT("&Manage..."));
00383 Connect(item->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VisualizationFrame::onManagePlugins), NULL, this);
00384 menubar_->Append(plugins_menu_, wxT("&Plugins"));
00385
00386 help_menu_ = new wxMenu(wxT(""));
00387 item = help_menu_->Append(wxID_ANY, wxT("&Wiki"));
00388 Connect(item->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VisualizationFrame::onHelpWiki), NULL, this);
00389 menubar_->Append(help_menu_, wxT("&Help"));
00390
00391 SetMenuBar(menubar_);
00392 }
00393
00394 void VisualizationFrame::updateRecentConfigMenu()
00395 {
00396
00397 while (recent_configs_menu_->GetMenuItemCount() > 0)
00398 {
00399 wxMenuItem* item = recent_configs_menu_->FindItemByPosition(0);
00400 recent_configs_menu_->Remove(item);
00401 }
00402
00403 D_string::iterator it = recent_configs_.begin();
00404 D_string::iterator end = recent_configs_.end();
00405 for (; it != end; ++it)
00406 {
00407 const std::string& path = *it;
00408 wxMenuItem* item = recent_configs_menu_->Append(wxID_ANY, wxString::FromAscii(path.c_str()));
00409 Connect(item->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler(VisualizationFrame::onRecentConfigSelected), NULL, this);
00410 }
00411 }
00412
00413 void VisualizationFrame::markRecentConfig(const std::string& path)
00414 {
00415 D_string::iterator it = std::find(recent_configs_.begin(), recent_configs_.end(), path);
00416 if (it != recent_configs_.end())
00417 {
00418 recent_configs_.erase(it);
00419 }
00420
00421 recent_configs_.push_front(path);
00422
00423 if (recent_configs_.size() > RECENT_CONFIG_COUNT)
00424 {
00425 recent_configs_.pop_back();
00426 }
00427
00428 updateRecentConfigMenu();
00429 }
00430
00431 void VisualizationFrame::loadDisplayConfig(const std::string& path)
00432 {
00433 if (!fs::exists(path))
00434 {
00435 wxString message = wxString::FromAscii(path.c_str()) + wxT(" does not exist!");
00436 wxMessageBox(message, wxT("Config Does Not Exist"), wxOK|wxICON_ERROR, this);
00437 return;
00438 }
00439
00440 manager_->removeAllDisplays();
00441
00442 LoadingDialog dialog(this);
00443 dialog.Show();
00444
00445 boost::shared_ptr<wxFileConfig> config(new wxFileConfig(wxT("standalone_visualizer"), wxEmptyString, wxEmptyString, wxString::FromAscii(path.c_str()), wxCONFIG_USE_GLOBAL_FILE));
00446 manager_->loadDisplayConfig(config, boost::bind(&LoadingDialog::setState, &dialog, _1));
00447
00448 markRecentConfig(path);
00449 }
00450
00451 void VisualizationFrame::saveConfigs()
00452 {
00453 ROS_INFO("Saving general config to [%s]", general_config_file_.c_str());
00454 general_config_->DeleteAll();
00455 wxPoint pos = GetPosition();
00456 wxSize size = GetSize();
00457 general_config_->Write(CONFIG_WINDOW_X, pos.x);
00458 general_config_->Write(CONFIG_WINDOW_Y, pos.y);
00459 general_config_->Write(CONFIG_WINDOW_WIDTH, size.GetWidth());
00460 general_config_->Write(CONFIG_WINDOW_HEIGHT, size.GetHeight());
00461
00462 general_config_->Write(CONFIG_AUIMANAGER_PERSPECTIVE, aui_manager_->SavePerspective());
00463 general_config_->Write(CONFIG_AUIMANAGER_PERSPECTIVE_VERSION, PERSPECTIVE_VERSION);
00464
00465 {
00466 std::stringstream ss;
00467 D_string::iterator it = recent_configs_.begin();
00468 D_string::iterator end = recent_configs_.end();
00469 for (; it != end; ++it)
00470 {
00471 if (it != recent_configs_.begin())
00472 {
00473 ss << ":";
00474 }
00475 ss << *it;
00476 }
00477
00478 wxString str = wxString::FromAscii(ss.str().c_str());
00479 general_config_->Write(CONFIG_RECENT_CONFIGS, str);
00480 }
00481
00482 general_config_->Write(CONFIG_LAST_DIR, wxString::FromAscii(last_config_dir_.c_str()));
00483
00484 manager_->saveGeneralConfig(general_config_);
00485 general_config_->Flush();
00486
00487 ROS_INFO("Saving display config to [%s]", display_config_file_.c_str());
00488 display_config_->DeleteAll();
00489 manager_->saveDisplayConfig(display_config_);
00490 display_config_->Flush();
00491 }
00492
00493 void VisualizationFrame::onClose(wxCommandEvent& event)
00494 {
00495 Close();
00496 }
00497
00498 void VisualizationFrame::onPaneClosed(wxAuiManagerEvent& event)
00499 {
00500 wxAuiPaneInfo* pane = event.GetPane();
00501 wxWindow* window = pane->window;
00502 menubar_->Check(window->GetId(), false);
00503 }
00504
00505 void VisualizationFrame::onViewMenuItemSelected(wxCommandEvent& event)
00506 {
00507 wxAuiPaneInfoArray& panes = aui_manager_->GetAllPanes();
00508 for (uint32_t i = 0; i < panes.GetCount(); ++i)
00509 {
00510 wxAuiPaneInfo& pane = panes.Item(i);
00511
00512 if (pane.window->GetId() == event.GetId())
00513 {
00514 pane.Show(event.IsChecked());
00515
00516 aui_manager_->Update();
00517
00518 break;
00519 }
00520 }
00521 }
00522
00523 void VisualizationFrame::onOpen(wxCommandEvent& event)
00524 {
00525 wxString wxstr_file = wxFileSelector(wxT("Choose a file to open"), wxString::FromAscii(last_config_dir_.c_str()), wxEmptyString,
00526 wxT(CONFIG_EXTENSION), wxT(CONFIG_EXTENSION_WILDCARD), wxFD_OPEN|wxFD_FILE_MUST_EXIST, this);
00527 if (!wxstr_file.empty())
00528 {
00529 std::string filename = (const char*)wxstr_file.fn_str();
00530 loadDisplayConfig(filename);
00531
00532 last_config_dir_ = fs::path(filename).parent_path().string();
00533 }
00534 }
00535
00536 void VisualizationFrame::onSave(wxCommandEvent& event)
00537 {
00538 wxString wxstr_file = wxFileSelector(wxT("Choose a file to save to"), wxString::FromAscii(last_config_dir_.c_str()), wxEmptyString,
00539 wxT(CONFIG_EXTENSION), wxT(CONFIG_EXTENSION_WILDCARD), wxFD_SAVE|wxFD_OVERWRITE_PROMPT, this);
00540
00541 if (!wxstr_file.empty())
00542 {
00543 std::string filename = (const char*)wxstr_file.fn_str();
00544 fs::path path(filename);
00545 if (path.extension() != "."CONFIG_EXTENSION)
00546 {
00547 filename += "."CONFIG_EXTENSION;
00548 }
00549
00550 boost::shared_ptr<wxFileConfig> config(new wxFileConfig(wxT("standalone_visualizer"), wxEmptyString, wxString::FromAscii(filename.c_str())));
00551 config->DeleteAll();
00552
00553 manager_->saveDisplayConfig(config);
00554 config->Flush();
00555
00556 markRecentConfig(filename);
00557
00558 last_config_dir_ = fs::path(filename).parent_path().string();
00559 }
00560 }
00561
00562 void VisualizationFrame::onRecentConfigSelected(wxCommandEvent& event)
00563 {
00564 wxString label = recent_configs_menu_->GetLabel(event.GetId());
00565 if (!label.IsEmpty())
00566 {
00567 std::string path = (const char*)label.char_str();
00568
00569
00570 size_t pos = path.find("__");
00571 while (pos != std::string::npos)
00572 {
00573 path.erase(pos, 1);
00574 pos = path.find("__", pos + 1);
00575 }
00576
00577 loadDisplayConfig(path);
00578 }
00579 }
00580
00581 void VisualizationFrame::onToolAdded(Tool* tool)
00582 {
00583 #if !defined(__WXMAC__)
00584 char ascii_str[2] = { tool->getShortcutKey(), 0 };
00585 wxString tooltip = wxString( wxT("Shortcut Key: ")) + wxString::FromAscii( ascii_str );
00586 toolbar_->AddRadioTool( toolbar_->GetToolsCount(), wxString::FromAscii( tool->getName().c_str() ), wxNullBitmap, wxNullBitmap, tooltip );
00587
00588 wxAuiPaneInfo& pane = aui_manager_->GetPane(toolbar_);
00589 pane.MinSize(toolbar_->GetSize());
00590 aui_manager_->Update();
00591 #endif
00592 }
00593
00594 void VisualizationFrame::onToolChanged(Tool* tool)
00595 {
00596 #if !defined(__WXMAC__)
00597 int count = toolbar_->GetToolsCount();
00598 for ( int i = toolbar_items::Count; i < count; ++i )
00599 {
00600 if ( manager_->getTool( i - toolbar_items::Count ) == tool )
00601 {
00602 toolbar_->ToggleTool( i, true );
00603 break;
00604 }
00605 }
00606 #endif
00607 }
00608
00609 void VisualizationFrame::onToolClicked( wxCommandEvent& event )
00610 {
00611 int id = event.GetId();
00612 if (id >= toolbar_items::Count)
00613 {
00614 Tool* tool = manager_->getTool( id - toolbar_items::Count );
00615
00616 manager_->setCurrentTool( tool );
00617 }
00618 else
00619 {
00620 switch (id)
00621 {
00622 default:
00623 break;
00624 }
00625 }
00626 }
00627
00628 void VisualizationFrame::onManagePlugins(wxCommandEvent& event)
00629 {
00630 PluginManagerDialog dialog(this, manager_->getPluginManager());
00631 dialog.ShowModal();
00632 }
00633
00634 void VisualizationFrame::onHelpWiki(wxCommandEvent& event)
00635 {
00636 wxLaunchDefaultBrowser(wxT("http://www.ros.org/wiki/rviz"));
00637 }
00638
00639 wxWindow* VisualizationFrame::getParentWindow()
00640 {
00641 return this;
00642 }
00643
00644 void VisualizationFrame::addPane(const std::string& name, wxWindow* panel)
00645 {
00646 aui_manager_->AddPane(panel, wxAuiPaneInfo().Float().BestSize(panel->GetSize()).Name(wxString::FromAscii(name.c_str())).Caption(wxString::FromAscii(name.c_str())).CloseButton(false).Show(false).Dockable(true).FloatingPosition(30,30));
00647 aui_manager_->Update();
00648 }
00649
00650 void VisualizationFrame::removePane(wxWindow* panel)
00651 {
00652 aui_manager_->DetachPane(panel);
00653 aui_manager_->Update();
00654 }
00655
00656 void VisualizationFrame::showPane(wxWindow* panel)
00657 {
00658 wxAuiPaneInfo& pane = aui_manager_->GetPane(panel);
00659
00660 if (pane.IsOk())
00661 {
00662 pane.Show(true);
00663 aui_manager_->Update();
00664 }
00665 }
00666
00667 void VisualizationFrame::closePane(wxWindow* panel)
00668 {
00669 wxAuiPaneInfo& pane = aui_manager_->GetPane(panel);
00670
00671 if (pane.IsOk())
00672 {
00673 pane.Show(false);
00674 aui_manager_->Update();
00675 }
00676 }
00677
00678
00679 }