camera_display.h
Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009, 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_CAMERA_DISPLAY_H
00031 #define RVIZ_CAMERA_DISPLAY_H
00032 
00033 #include <QObject>
00034 
00035 #include <OgreMaterial.h>
00036 #include <OgreRenderTargetListener.h>
00037 #include <OgreSharedPtr.h>
00038 
00039 #ifndef Q_MOC_RUN
00040 # include <sensor_msgs/CameraInfo.h>
00041 
00042 # include <message_filters/subscriber.h>
00043 # include <tf/message_filter.h>
00044 
00045 # include "rviz/image/image_display_base.h"
00046 # include "rviz/image/ros_image_texture.h"
00047 # include "rviz/render_panel.h"
00048 #endif
00049 
00050 namespace Ogre
00051 {
00052 class SceneNode;
00053 class ManualObject;
00054 class Rectangle2D;
00055 class Camera;
00056 }
00057 
00058 namespace rviz
00059 {
00060 
00061 class EnumProperty;
00062 class FloatProperty;
00063 class IntProperty;
00064 class RenderPanel;
00065 class RosTopicProperty;
00066 class DisplayGroupVisibilityProperty;
00067 
00072 class CameraDisplay: public ImageDisplayBase, public Ogre::RenderTargetListener
00073 {
00074 Q_OBJECT
00075 public:
00076   CameraDisplay();
00077   virtual ~CameraDisplay();
00078 
00079   // Overrides from Display
00080   virtual void onInitialize();
00081   virtual void fixedFrameChanged();
00082   virtual void update( float wall_dt, float ros_dt );
00083   virtual void reset();
00084 
00085   // Overrides from Ogre::RenderTargetListener
00086   virtual void preRenderTargetUpdate( const Ogre::RenderTargetEvent& evt );
00087   virtual void postRenderTargetUpdate( const Ogre::RenderTargetEvent& evt );
00088 
00089   static const QString BACKGROUND;
00090   static const QString OVERLAY;
00091   static const QString BOTH;
00092 
00093 protected:
00094   // overrides from Display
00095   virtual void onEnable();
00096   virtual void onDisable();
00097 
00098   ROSImageTexture texture_;
00099   RenderPanel* render_panel_;
00100 
00101 private Q_SLOTS:
00102   void forceRender();
00103   void updateAlpha();
00104 
00105   virtual void updateQueueSize();
00106 
00107 private:
00108   void subscribe();
00109   void unsubscribe();
00110 
00111   virtual void processMessage(const sensor_msgs::Image::ConstPtr& msg);
00112   void caminfoCallback( const sensor_msgs::CameraInfo::ConstPtr& msg );
00113 
00114   bool updateCamera();
00115 
00116   void clear();
00117   void updateStatus();
00118 
00119   Ogre::SceneNode* bg_scene_node_;
00120   Ogre::SceneNode* fg_scene_node_;
00121 
00122   Ogre::Rectangle2D* bg_screen_rect_;
00123   Ogre::MaterialPtr bg_material_;
00124 
00125   Ogre::Rectangle2D* fg_screen_rect_;
00126   Ogre::MaterialPtr fg_material_;
00127 
00128   message_filters::Subscriber<sensor_msgs::CameraInfo> caminfo_sub_;
00129   tf::MessageFilter<sensor_msgs::CameraInfo>* caminfo_tf_filter_;
00130 
00131   FloatProperty* alpha_property_;
00132   EnumProperty* image_position_property_;
00133   FloatProperty* zoom_property_;
00134   DisplayGroupVisibilityProperty* visibility_property_;
00135 
00136   sensor_msgs::CameraInfo::ConstPtr current_caminfo_;
00137   boost::mutex caminfo_mutex_;
00138 
00139   bool new_caminfo_;
00140 
00141   bool caminfo_ok_;
00142 
00143   bool force_render_;
00144 
00145   uint32_t vis_bit_;
00146 };
00147 
00148 } // namespace rviz
00149 
00150  #endif


rviz
Author(s): Dave Hershberger, David Gossow, Josh Faust
autogenerated on Thu Aug 27 2015 15:02:27