visualization_manager.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2012, 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 
00031 #ifndef RVIZ_VISUALIZATION_MANAGER_H_
00032 #define RVIZ_VISUALIZATION_MANAGER_H_
00033 
00034 #include <deque>
00035 
00036 #include <ros/time.h>
00037 
00038 #include "rviz/bit_allocator.h"
00039 #include "rviz/config.h"
00040 #include "rviz/display_context.h"
00041 
00042 class QKeyEvent;
00043 class QTimer;
00044 
00045 namespace Ogre
00046 {
00047 class Root;
00048 class SceneManager;
00049 class SceneNode;
00050 class Light;
00051 }
00052 
00053 namespace ros
00054 {
00055 class CallbackQueueInterface;
00056 }
00057 
00058 namespace tf
00059 {
00060 class TransformListener;
00061 }
00062 
00063 namespace rviz
00064 {
00065 
00066 class ColorProperty;
00067 class Display;
00068 class DisplayFactory;
00069 class DisplayGroup;
00070 class FrameManager;
00071 class Property;
00072 class IntProperty;
00073 class PropertyTreeModel;
00074 class RenderPanel;
00075 class SelectionManager;
00076 class StatusList;
00077 class TfFrameProperty;
00078 class ViewportMouseEvent;
00079 class WindowManagerInterface;
00080 class Tool;
00081 class OgreRenderQueueClearer;
00082 
00083 class VisualizationManagerPrivate;
00084 
00099 class VisualizationManager: public DisplayContext
00100 {
00101 Q_OBJECT
00102 public:
00111   VisualizationManager( RenderPanel* render_panel, WindowManagerInterface* wm = 0, boost::shared_ptr<tf::TransformListener> tf = boost::shared_ptr<tf::TransformListener>() );
00112 
00117   virtual ~VisualizationManager();
00118 
00123   void initialize();
00124 
00129   void startUpdate();
00130 
00131   /*
00132    * \brief Stop the update timers. No Displays will be updated and no ROS
00133    *        callbacks will be called during this period.
00134    */
00135   void stopUpdate();
00136 
00145   Display* createDisplay( const QString& class_lookup_name, const QString& name, bool enabled );
00146 
00151   void addDisplay( Display* display, bool enabled );
00152 
00156   void removeAllDisplays();
00157 
00165   void load( const Config& config );
00166 
00175   void save( Config config ) const;
00176 
00179   QString getFixedFrame() const;
00180 
00184   void setFixedFrame( const QString& frame );
00185   
00189   tf::TransformListener* getTFClient() const;
00190 
00194   Ogre::SceneManager* getSceneManager() const { return scene_manager_; }
00195 
00199   RenderPanel* getRenderPanel() const { return render_panel_; }
00200 
00204   double getWallClock();
00205 
00209   double getROSTime();
00210 
00214   double getWallClockElapsed();
00215 
00219   double getROSTimeElapsed();
00220 
00228   void handleChar( QKeyEvent* event, RenderPanel* panel );
00229 
00237   void handleMouseEvent( const ViewportMouseEvent& event );
00238 
00242   void resetTime();
00243 
00247   SelectionManager* getSelectionManager() const { return selection_manager_; }
00248 
00250   virtual ToolManager* getToolManager() const { return tool_manager_; }
00251 
00253   virtual ViewManager* getViewManager() const { return view_manager_; }
00254 
00258   void lockRender();
00259 
00263   void unlockRender();
00264 
00269   void queueRender();
00270 
00274   WindowManagerInterface* getWindowManager() const { return window_manager_; }
00275 
00279   ros::CallbackQueueInterface* getUpdateQueue();
00280 
00284   ros::CallbackQueueInterface* getThreadedQueue();
00285 
00287   FrameManager* getFrameManager() const { return frame_manager_; }
00288 
00294   uint64_t getFrameCount() const { return frame_count_; }
00295 
00298   void notifyConfigChanged();
00299 
00301   virtual DisplayFactory* getDisplayFactory() const { return display_factory_; }
00302 
00303   PropertyTreeModel* getDisplayTreeModel() const { return display_property_tree_model_; }
00304 
00306   void emitStatusUpdate( const QString& message );
00307 
00308   virtual DisplayGroup* getRootDisplayGroup() const { return root_display_group_; }
00309 
00310   virtual uint32_t getDefaultVisibilityBit() const { return default_visibility_bit_; }
00311 
00312   virtual BitAllocator* visibilityBits() { return &visibility_bit_allocator_; }
00313 
00314   virtual void setStatus( const QString & message );
00315 
00316   virtual void setHelpPath( const QString& help_path ) { help_path_ = help_path; }
00317   virtual QString getHelpPath() const { return help_path_; }
00318 
00319 Q_SIGNALS:
00320 
00322   void preUpdate();
00323 
00325   void configChanged();
00326 
00328   void statusUpdate( const QString& message );
00329 
00330 protected Q_SLOTS:
00340   void onUpdate();
00341 
00342   void onToolChanged( Tool* );
00343 
00344 protected:
00345   void updateTime();
00346   void updateFrames();
00347 
00348   void createColorMaterials();
00349 
00350   void threadedQueueThreadFunc();
00351 
00352   Ogre::Root* ogre_root_;                                 
00353   Ogre::SceneManager* scene_manager_;                     
00354 
00355   QTimer* update_timer_;                                 
00356   ros::Time last_update_ros_time_;                        
00357   ros::WallTime last_update_wall_time_;
00358 
00359   volatile bool shutting_down_;
00360 
00361   PropertyTreeModel* display_property_tree_model_;
00362   DisplayGroup* root_display_group_;
00363 
00364   ToolManager* tool_manager_;
00365   ViewManager* view_manager_;
00366 
00367   Property* global_options_;
00368   TfFrameProperty* fixed_frame_property_;          
00369   StatusList* global_status_;
00370   IntProperty* fps_property_;
00371 
00372   RenderPanel* render_panel_;
00373 
00374   ros::WallTime wall_clock_begin_;
00375   ros::Time ros_time_begin_;
00376   ros::WallDuration wall_clock_elapsed_;
00377   ros::Duration ros_time_elapsed_;
00378 
00379   ColorProperty* background_color_property_;
00380 
00381   float time_update_timer_;
00382   float frame_update_timer_;
00383 
00384   SelectionManager* selection_manager_;
00385 
00386   uint32_t render_requested_;
00387   uint64_t frame_count_;
00388 
00389   WindowManagerInterface* window_manager_;
00390   
00391   FrameManager* frame_manager_;
00392 
00393   OgreRenderQueueClearer* ogre_render_queue_clearer_;
00394 
00395 private Q_SLOTS:
00396   void updateFixedFrame();
00397   void updateBackgroundColor();
00398   void updateFps();
00399 
00400 private:
00401   DisplayFactory* display_factory_;
00402   VisualizationManagerPrivate* private_;
00403   uint32_t default_visibility_bit_;
00404   BitAllocator visibility_bit_allocator_;
00405   QString help_path_;
00406   Ogre::Light* directional_light_;
00407 };
00408 
00409 }
00410 
00411 #endif /* RVIZ_VISUALIZATION_MANAGER_H_ */


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