visualization_frame.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2008, Willow Garage, Inc.
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  *     * Redistributions of source code must retain the above copyright
00009  *       notice, this list of conditions and the following disclaimer.
00010  *     * Redistributions in binary form must reproduce the above copyright
00011  *       notice, this list of conditions and the following disclaimer in the
00012  *       documentation and/or other materials provided with the distribution.
00013  *     * Neither the name of the Willow Garage, Inc. nor the names of its
00014  *       contributors may be used to endorse or promote products derived from
00015  *       this software without specific prior written permission.
00016  *
00017  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027  * POSSIBILITY OF SUCH DAMAGE.
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 
00039 #include "rviz/config.h"
00040 #include "rviz/window_manager_interface.h"
00041 #include "rviz/panel.h"
00042 
00043 class QSplashScreen;
00044 class QAction;
00045 class QActionGroup;
00046 class QTimer;
00047 class QDockWidget;
00048 class QLabel;
00049 class QToolButton;
00050 
00051 namespace rviz
00052 {
00053 
00054 class PanelFactory;
00055 class RenderPanel;
00056 class VisualizationManager;
00057 class Tool;
00058 class WidgetGeometryChangeDetector;
00059 
00069 class VisualizationFrame : public QMainWindow, public WindowManagerInterface
00070 {
00071 Q_OBJECT
00072 public:
00073   VisualizationFrame( QWidget* parent = 0 );
00074   ~VisualizationFrame();
00075 
00077   void setShowChooseNewMaster( bool show );
00078 
00081   void setHelpPath( const QString& help_path );
00082 
00087   void setSplashPath( const QString& splash_path );
00088 
00098   void initialize( const QString& display_config_file = "" );
00099 
00100   VisualizationManager* getManager() { return manager_; }
00101 
00102   // overrides from WindowManagerInterface
00103   virtual QWidget* getParentWindow();
00104   virtual PanelDockWidget* addPane( const QString& name,
00105                                 QWidget* panel,
00106                                 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea,
00107                                 bool floating = true );
00108 
00113   void loadPersistentSettings();
00114 
00119   void savePersistentSettings();
00120 
00123   void loadDisplayConfig( const QString& path );
00124 
00131   bool saveDisplayConfig( const QString& path );
00132 
00133   QString getErrorMessage() const { return error_message_; }
00134 
00141   virtual void load( const Config& config );
00142 
00150   virtual void save( Config config );
00151 
00153   void setHideButtonVisibility( bool visible );
00154 
00155 public Q_SLOTS:
00158   void setDisplayConfigModified();
00159 
00161   virtual void setStatus( const QString & message );
00162 
00163 Q_SIGNALS:
00165   void statusUpdate( const QString& message );
00166 
00167 protected Q_SLOTS:
00168   void onOpen();
00169   void onSave();
00170   void onSaveAs();
00171   void onSaveImage();
00172   void onRecentConfigSelected();
00173   void onHelpWiki();
00174   void openNewPanelDialog();
00175   void openNewToolDialog();
00176   void showHelpPanel();
00177 
00179   void onToolbarRemoveTool( QAction* remove_tool_menu_action );
00180 
00183   void onToolbarActionTriggered( QAction* action );
00184 
00190   void addTool( Tool* tool );
00191 
00193   void removeTool( Tool* tool );
00194 
00199   void indicateToolIsCurrent(Tool* tool);
00200 
00204   void changeMaster();
00205 
00210   void onDeletePanel();
00211 
00212 protected Q_SLOTS:
00214   void markLoadingDone();
00215 
00217   void setImageSaveDirectory( const QString& directory );
00218 
00219   void reset();
00220 
00221   void onHelpDestroyed();
00222 
00223   void hideLeftDock( bool hide );
00224   void hideRightDock( bool hide );
00225 
00226   virtual void onDockPanelVisibilityChange( bool visible );
00227 
00228 protected:
00232   void initConfigs();
00233 
00234   void initMenus();
00235 
00236   void initToolbars();
00237 
00240   bool prepareToExit();
00241 
00242   virtual void closeEvent( QCloseEvent* event );
00243 
00244   virtual void leaveEvent ( QEvent * event );
00245 
00246   void markRecentConfig(const std::string& path);
00247   void updateRecentConfigMenu();
00248 
00249   QDockWidget* addPanelByName( const QString& name,
00250                                const QString& class_lookup_name,
00251                                Qt::DockWidgetArea area = Qt::LeftDockWidgetArea,
00252                                bool floating = true );
00253 
00255   void loadPanels( const Config& config );
00256 
00258   void savePanels( Config config );
00259 
00260   void loadWindowGeometry( const Config& config );
00261   void saveWindowGeometry( Config config );
00262 
00267   void setDisplayConfigFile( const std::string& path );
00268 
00269   void hideDockImpl( Qt::DockWidgetArea area, bool hide );
00270 
00271   RenderPanel* render_panel_;
00272 
00273   QAction* show_help_action_;
00274 
00275   std::string config_dir_;
00276   std::string persistent_settings_file_;
00277   std::string display_config_file_;
00278   std::string default_display_config_file_;
00279   std::string last_config_dir_;
00280   std::string last_image_dir_;
00281   std::string home_dir_;
00282 
00283   QMenu* file_menu_;
00284   QMenu* recent_configs_menu_;
00285   QMenu* view_menu_;
00286   QMenu* delete_view_menu_;
00287   QMenu* plugins_menu_;
00288   QList<QAction*> view_menu_actions_;
00289 
00290   QToolBar* toolbar_;
00291 
00292   VisualizationManager* manager_;
00293 
00294   std::string package_path_;
00295   QString help_path_;
00296   QString splash_path_;
00297 
00298   QSplashScreen* splash_;
00299 
00300   typedef std::deque<std::string> D_string;
00301   D_string recent_configs_;
00302 
00303   QActionGroup* toolbar_actions_;
00304   std::map<QAction*,Tool*> action_to_tool_map_;
00305   std::map<Tool*,QAction*> tool_to_action_map_;
00306   bool show_choose_new_master_option_;
00307 
00308   QToolButton* hide_left_dock_button_;
00309   QToolButton* hide_right_dock_button_;
00310 
00311   PanelFactory* panel_factory_;
00312 
00313   struct PanelRecord
00314   {
00315     Panel* panel;
00316     PanelDockWidget* dock;
00317     QString name;
00318     QString class_id;
00319     QAction* delete_action;
00320   };
00321   QList<PanelRecord> custom_panels_;
00322 
00323   QAction* add_tool_action_;
00324   QMenu* remove_tool_menu_;
00325 
00326   bool initialized_;
00327   WidgetGeometryChangeDetector* geom_change_detector_;
00328   bool loading_; 
00329   QTimer* post_load_timer_; 
00330 
00331   QLabel* status_label_;
00332 
00333   QString error_message_; 
00334 };
00335 
00336 }
00337 
00338 #endif // RVIZ_VISUALIZATION_FRAME_H


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Mon Oct 6 2014 07:26:36