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 #include <ros/time.h>
00044 
00045 class QSplashScreen;
00046 class QAction;
00047 class QActionGroup;
00048 class QTimer;
00049 class QDockWidget;
00050 class QLabel;
00051 class QToolButton;
00052 
00053 namespace rviz
00054 {
00055 
00056 class PanelFactory;
00057 class RenderPanel;
00058 class VisualizationManager;
00059 class Tool;
00060 class WidgetGeometryChangeDetector;
00061 
00071 class VisualizationFrame : public QMainWindow, public WindowManagerInterface
00072 {
00073 Q_OBJECT
00074 public:
00075   VisualizationFrame( QWidget* parent = 0 );
00076   ~VisualizationFrame();
00077 
00078   void setApp( QApplication * app );
00079 
00081   void setShowChooseNewMaster( bool show );
00082 
00085   void setHelpPath( const QString& help_path );
00086 
00091   void setSplashPath( const QString& splash_path );
00092 
00102   void initialize( const QString& display_config_file = "" );
00103 
00104   VisualizationManager* getManager() { return manager_; }
00105 
00106   // overrides from WindowManagerInterface
00107   virtual QWidget* getParentWindow();
00108   virtual PanelDockWidget* addPane( const QString& name,
00109                                 QWidget* panel,
00110                                 Qt::DockWidgetArea area = Qt::LeftDockWidgetArea,
00111                                 bool floating = true );
00112 
00117   void loadPersistentSettings();
00118 
00123   void savePersistentSettings();
00124 
00127   void loadDisplayConfig( const QString& path );
00128 
00135   bool saveDisplayConfig( const QString& path );
00136 
00137   QString getErrorMessage() const { return error_message_; }
00138 
00145   virtual void load( const Config& config );
00146 
00154   virtual void save( Config config );
00155 
00157   void setHideButtonVisibility( bool visible );
00158 
00159 public Q_SLOTS:
00162   void setDisplayConfigModified();
00163 
00165   virtual void setStatus( const QString & message );
00166 
00167 Q_SIGNALS:
00169   void statusUpdate( const QString& message );
00170 
00172   void fullScreenChange( bool hidden );
00173 
00174 protected Q_SLOTS:
00175   void onOpen();
00176   void onSave();
00177   void onSaveAs();
00178   void onSaveImage();
00179   void onRecentConfigSelected();
00180   void onHelpWiki();
00181   void onHelpAbout();
00182   void openNewPanelDialog();
00183   void openNewToolDialog();
00184   void showHelpPanel();
00185 
00187   void onToolbarRemoveTool( QAction* remove_tool_menu_action );
00188 
00191   void onToolbarActionTriggered( QAction* action );
00192 
00198   void addTool( Tool* tool );
00199 
00201   void removeTool( Tool* tool );
00202 
00206   void refreshTool( Tool* tool );
00207 
00212   void indicateToolIsCurrent(Tool* tool);
00213 
00217   void changeMaster();
00218 
00223   void onDeletePanel();
00224 
00226   void setFullScreen( bool full_screen );
00227 
00229   void exitFullScreen();
00230 
00231 protected Q_SLOTS:
00233   void markLoadingDone();
00234 
00236   void setImageSaveDirectory( const QString& directory );
00237 
00238   void reset();
00239 
00240   void onHelpDestroyed();
00241 
00242   void hideLeftDock( bool hide );
00243   void hideRightDock( bool hide );
00244 
00245   virtual void onDockPanelVisibilityChange( bool visible );
00246 
00247   void updateFps();
00248 
00249 protected:
00253   void initConfigs();
00254 
00255   void initMenus();
00256 
00257   void initToolbars();
00258 
00261   bool prepareToExit();
00262 
00263   virtual void closeEvent( QCloseEvent* event );
00264 
00265   virtual void leaveEvent ( QEvent * event );
00266 
00267   void markRecentConfig(const std::string& path);
00268   void updateRecentConfigMenu();
00269 
00270   QDockWidget* addPanelByName( const QString& name,
00271                                const QString& class_lookup_name,
00272                                Qt::DockWidgetArea area = Qt::LeftDockWidgetArea,
00273                                bool floating = true );
00274 
00276   void loadPanels( const Config& config );
00277 
00279   void savePanels( Config config );
00280 
00281   void loadWindowGeometry( const Config& config );
00282   void saveWindowGeometry( Config config );
00283 
00288   void setDisplayConfigFile( const std::string& path );
00289 
00290   void hideDockImpl( Qt::DockWidgetArea area, bool hide );
00291 
00292   QApplication* app_;
00293 
00294   RenderPanel* render_panel_;
00295 
00296   QAction* show_help_action_;
00297 
00298   std::string config_dir_;
00299   std::string persistent_settings_file_;
00300   std::string display_config_file_;
00301   std::string default_display_config_file_;
00302   std::string last_config_dir_;
00303   std::string last_image_dir_;
00304   std::string home_dir_;
00305 
00306   QMenu* file_menu_;
00307   QMenu* recent_configs_menu_;
00308   QMenu* view_menu_;
00309   QMenu* delete_view_menu_;
00310   QMenu* plugins_menu_;
00311 
00312   QToolBar* toolbar_;
00313 
00314   VisualizationManager* manager_;
00315 
00316   std::string package_path_;
00317   QString help_path_;
00318   QString splash_path_;
00319 
00320   QSplashScreen* splash_;
00321 
00322   typedef std::deque<std::string> D_string;
00323   D_string recent_configs_;
00324 
00325   QActionGroup* toolbar_actions_;
00326   std::map<QAction*,Tool*> action_to_tool_map_;
00327   std::map<Tool*,QAction*> tool_to_action_map_;
00328   bool show_choose_new_master_option_;
00329 
00330   QToolButton* hide_left_dock_button_;
00331   QToolButton* hide_right_dock_button_;
00332 
00333   PanelFactory* panel_factory_;
00334 
00335   struct PanelRecord
00336   {
00337     Panel* panel;
00338     PanelDockWidget* dock;
00339     QString name;
00340     QString class_id;
00341     QAction* delete_action;
00342   };
00343   QList<PanelRecord> custom_panels_;
00344 
00345   QAction* add_tool_action_;
00346   QMenu* remove_tool_menu_;
00347 
00348   bool initialized_;
00349   WidgetGeometryChangeDetector* geom_change_detector_;
00350   bool loading_; 
00351   QTimer* post_load_timer_; 
00352 
00353   QLabel* status_label_;
00354   QLabel* fps_label_;
00355   QStatusBar* original_status_bar_;
00356 
00357   int frame_count_;
00358   ros::WallTime last_fps_calc_time_;
00359 
00360   QString error_message_; 
00361 
00363   bool toolbar_visible_;
00364 };
00365 
00366 }
00367 
00368 #endif // RVIZ_VISUALIZATION_FRAME_H


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Tue Oct 3 2017 03:19:31