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 <OGRE/OgreMaterial.h> 00036 #include <OGRE/OgreRenderTargetListener.h> 00037 00038 #include <sensor_msgs/CameraInfo.h> 00039 00040 #include <message_filters/subscriber.h> 00041 #include <tf/message_filter.h> 00042 00043 #include "rviz/display.h" 00044 #include "rviz/image/ros_image_texture.h" 00045 #include "rviz/render_panel.h" 00046 00047 namespace Ogre 00048 { 00049 class SceneNode; 00050 class ManualObject; 00051 class Rectangle2D; 00052 class Camera; 00053 } 00054 00055 class QWidget; 00056 00057 namespace rviz 00058 { 00059 00060 class EditableEnumProperty; 00061 class EnumProperty; 00062 class FloatProperty; 00063 class IntProperty; 00064 class PanelDockWidget; 00065 class RenderPanel; 00066 class RosTopicProperty; 00067 00072 class CameraDisplay: public Display, 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 00086 virtual void setName( const QString& name ); 00087 00088 // Overrides from Ogre::RenderTargetListener 00089 virtual void preRenderTargetUpdate( const Ogre::RenderTargetEvent& evt ); 00090 virtual void postRenderTargetUpdate( const Ogre::RenderTargetEvent& evt ); 00091 00092 static const QString BACKGROUND; 00093 static const QString OVERLAY; 00094 static const QString BOTH; 00095 00096 protected: 00097 // overrides from Display 00098 virtual void onEnable(); 00099 virtual void onDisable(); 00100 00101 private Q_SLOTS: 00102 void forceRender(); 00103 void updateAlpha(); 00104 void updateQueueSize(); 00105 void updateTopic(); 00106 void updateTransport(); 00107 void fillTransportOptionList( QStringList* options_out ); 00108 00109 private: 00110 void subscribe(); 00111 void unsubscribe(); 00112 00113 void caminfoCallback( const sensor_msgs::CameraInfo::ConstPtr& msg ); 00114 00115 void updateCamera(); 00116 00117 void clear(); 00118 void updateStatus(); 00119 00120 Ogre::SceneNode* bg_scene_node_; 00121 Ogre::SceneNode* fg_scene_node_; 00122 00123 Ogre::Rectangle2D* bg_screen_rect_; 00124 Ogre::MaterialPtr bg_material_; 00125 00126 Ogre::Rectangle2D* fg_screen_rect_; 00127 Ogre::MaterialPtr fg_material_; 00128 00129 message_filters::Subscriber<sensor_msgs::CameraInfo> caminfo_sub_; 00130 tf::MessageFilter<sensor_msgs::CameraInfo>* caminfo_tf_filter_; 00131 00132 FloatProperty* alpha_property_; 00133 RosTopicProperty* topic_property_; 00134 EditableEnumProperty* transport_property_; 00135 EnumProperty* image_position_property_; 00136 FloatProperty* zoom_property_; 00137 IntProperty* queue_size_property_; 00138 00139 sensor_msgs::CameraInfo::ConstPtr current_caminfo_; 00140 boost::mutex caminfo_mutex_; 00141 00142 bool new_caminfo_; 00143 00144 ROSImageTexture texture_; 00145 00146 RenderPanel* render_panel_; 00147 00148 bool force_render_; 00149 00150 PanelDockWidget* panel_container_; 00151 }; 00152 00153 } // namespace rviz 00154 00155 #endif