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 #ifndef RVIZ_VISUALIZATION_FRAME_H
00031 #define RVIZ_VISUALIZATION_FRAME_H
00032
00033 #include <QMainWindow>
00034 #include <QList>
00035
00036 #include <string>
00037 #include <deque>
00038 #include <set>
00039 #include <boost/shared_ptr.hpp>
00040
00041 #include <pluginlib/class_loader.h>
00042
00043 #include <yaml-cpp/emitter.h>
00044 #include <yaml-cpp/node.h>
00045
00046 #include "rviz/window_manager_interface.h"
00047 #include "rviz/panel.h"
00048 #include "rviz/status_callback.h"
00049
00050 class QSplashScreen;
00051 class QAction;
00052 class QActionGroup;
00053 class QTimer;
00054
00055 namespace rviz
00056 {
00057
00058 class PanelDockWidget;
00059 class RenderPanel;
00060 class DisplaysPanel;
00061 class ViewsPanel;
00062 class TimePanel;
00063 class SelectionPanel;
00064 class ToolPropertiesPanel;
00065 class VisualizationManager;
00066 class Tool;
00067 class HelpPanel;
00068 class WidgetGeometryChangeDetector;
00069
00079 class VisualizationFrame : public QMainWindow, public WindowManagerInterface
00080 {
00081 Q_OBJECT
00082 public:
00083 VisualizationFrame( QWidget* parent = 0 );
00084 ~VisualizationFrame();
00085
00086 void initialize( const std::string& display_config_file = "",
00087 const std::string& fixed_frame = "",
00088 const std::string& target_frame = "",
00089 const std::string& splash_path = "",
00090 const std::string& help_path = "",
00091 bool verbose = false,
00092 bool show_choose_new_master_option = false );
00093
00094 VisualizationManager* getManager() { return manager_; }
00095
00096
00097 virtual QWidget* getParentWindow();
00098 virtual PanelDockWidget* addPane( const std::string& name,
00099 QWidget* panel,
00100 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea,
00101 bool floating = true );
00102
00103 public Q_SLOTS:
00106 void setDisplayConfigModified();
00107
00108 protected Q_SLOTS:
00109 void onOpen();
00110 void save();
00111 void saveAs();
00112 void onSaveImage();
00113 void onRecentConfigSelected();
00114 void onHelpWiki();
00115 void openNewPanelDialog();
00116 void openNewToolDialog();
00117 void showHelpPanel();
00118
00120 void onToolbarRemoveTool( QAction* remove_tool_menu_action );
00121
00124 void onToolbarActionTriggered( QAction* action );
00125
00131 void addTool( Tool* tool );
00132
00134 void removeTool( Tool* tool );
00135
00140 void indicateToolIsCurrent(Tool* tool);
00141
00145 void changeMaster();
00146
00151 void onDeletePanel();
00152
00153 protected Q_SLOTS:
00155 void markLoadingDone();
00156
00158 void setImageSaveDirectory( const QString& directory );
00159
00160 protected:
00165 void initConfigs( const std::string& display_config_file_override );
00166
00167 void initMenus();
00168
00171 bool prepareToExit();
00172
00173 virtual void moveEvent( QMoveEvent* event );
00174 virtual void closeEvent( QCloseEvent* event );
00175
00176 void setSplashStatus( const std::string& status );
00177
00178 void markRecentConfig(const std::string& path);
00179 void updateRecentConfigMenu();
00180
00181 QRect hackedFrameGeometry();
00182
00183 PanelDockWidget* addCustomPanel( const std::string& name,
00184 const std::string& class_lookup_name,
00185 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea,
00186 bool floating = true );
00187
00193
00198 void loadGeneralConfig();
00199
00204 void saveGeneralConfig();
00205
00208 void loadDisplayConfig( const std::string& path );
00209
00212 void saveDisplayConfig( const std::string& path );
00213
00223 virtual void load( const YAML::Node& yaml_node, const StatusCallback& cb );
00224
00231 virtual void save( YAML::Emitter& emitter );
00232
00234 bool fileIsWritable( const std::string& path );
00235
00240 void setDisplayConfigFile( const std::string& path );
00241
00242 RenderPanel* render_panel_;
00243 DisplaysPanel* displays_panel_;
00244 ViewsPanel* views_panel_;
00245 TimePanel* time_panel_;
00246 SelectionPanel* selection_panel_;
00247 ToolPropertiesPanel* tool_properties_panel_;
00248
00249 HelpPanel* help_panel_;
00250 QAction* show_help_action_;
00251
00252 std::string config_dir_;
00253 std::string general_config_file_;
00254 std::string display_config_file_;
00255 std::string default_display_config_file_;
00256 std::string last_config_dir_;
00257 std::string last_image_dir_;
00258 std::string home_dir_;
00259
00260 QMenu* file_menu_;
00261 QMenu* recent_configs_menu_;
00262 QMenu* view_menu_;
00263 QMenu* delete_view_menu_;
00264 QMenu* plugins_menu_;
00265 QList<QAction*> view_menu_actions_;
00266
00267 QToolBar* toolbar_;
00268
00269 VisualizationManager* manager_;
00270
00271 std::string package_path_;
00272 std::string help_path_;
00273
00274 QSplashScreen* splash_;
00275
00276 typedef std::deque<std::string> D_string;
00277 D_string recent_configs_;
00278
00279 QPoint first_position_;
00280 QPoint position_correction_;
00281 int num_move_events_;
00282 QActionGroup* toolbar_actions_;
00283 std::map<QAction*,Tool*> action_to_tool_map_;
00284 std::map<Tool*,QAction*> tool_to_action_map_;
00285 bool show_choose_new_master_option_;
00286
00287 pluginlib::ClassLoader<Panel>* panel_class_loader_;
00288
00289 struct PanelRecord
00290 {
00291 Panel* panel;
00292 PanelDockWidget* dock;
00293 std::string name;
00294 std::string lookup_name;
00295 QAction* delete_action;
00296 };
00297 typedef std::map<std::string, PanelRecord> M_PanelRecord;
00298 M_PanelRecord custom_panels_;
00299
00300 QAction* add_tool_action_;
00301 QMenu* remove_tool_menu_;
00302
00303 bool initialized_;
00304 WidgetGeometryChangeDetector* geom_change_detector_;
00305 bool loading_;
00306 QTimer* post_load_timer_;
00307 };
00308
00309 }
00310
00311 #endif // RVIZ_VISUALIZATION_FRAME_H