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 #ifndef IMAGE_DISPLAY_BASE_H 00030 #define IMAGE_DISPLAY_BASE_H 00031 00032 #include <QObject> 00033 00034 #ifndef Q_MOC_RUN // See: https://bugreports.qt-project.org/browse/QTBUG-22829 00035 # include <message_filters/subscriber.h> 00036 # include <tf/message_filter.h> 00037 # include <sensor_msgs/Image.h> 00038 00039 # include <image_transport/image_transport.h> 00040 # include <image_transport/subscriber_filter.h> 00041 00042 # include "rviz/display_context.h" 00043 # include "rviz/frame_manager.h" 00044 # include "rviz/properties/ros_topic_property.h" 00045 # include "rviz/properties/enum_property.h" 00046 # include "rviz/properties/int_property.h" 00047 00048 # include "rviz/display.h" 00049 #endif 00050 00051 namespace rviz 00052 { 00060 class ImageDisplayBase : public Display 00061 { 00062 Q_OBJECT 00063 public: 00064 00066 ImageDisplayBase(); 00067 virtual ~ImageDisplayBase(); 00068 00069 protected Q_SLOTS: 00071 virtual void updateTopic(); 00072 00074 virtual void updateQueueSize(); 00075 00077 void fillTransportOptionList(EnumProperty* property); 00078 00079 protected: 00080 00082 virtual void reset(); 00083 00085 void enableTFFilter(std::string& targetFrame) 00086 { 00087 targetFrame_ = targetFrame; 00088 reset(); 00089 } 00090 00092 virtual void subscribe(); 00093 virtual void unsubscribe(); 00094 00095 virtual void fixedFrameChanged(); 00096 00100 void incomingMessage(const sensor_msgs::Image::ConstPtr& msg); 00101 00105 virtual void processMessage(const sensor_msgs::Image::ConstPtr& msg) = 0; 00106 00107 void scanForTransportSubscriberPlugins(); 00108 00109 image_transport::ImageTransport it_; 00110 boost::shared_ptr<image_transport::SubscriberFilter> sub_; 00111 boost::shared_ptr<tf::MessageFilter<sensor_msgs::Image> > tf_filter_; 00112 00113 std::string targetFrame_; 00114 00115 uint32_t messages_received_; 00116 00117 RosTopicProperty* topic_property_; 00118 EnumProperty* transport_property_; 00119 IntProperty* queue_size_property_; 00120 00121 std::string transport_; 00122 00123 std::set<std::string> transport_plugin_types_; 00124 }; 00125 00126 } // end namespace rviz 00127 00128 #endif // IMAGE_DISPLAY_BASE_H