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 * $Id: polygonal_map_display.h 45518 2010-10-08 20:52:15Z gjones $ 00030 * 00031 */ 00032 00033 #ifndef RVIZ_POLYGONAL_MAP_DISPLAY_H_ 00034 #define RVIZ_POLYGONAL_MAP_DISPLAY_H_ 00035 00036 #include "rviz/display.h" 00037 #include "rviz/helpers/color.h" 00038 #include "rviz/properties/forwards.h" 00039 00040 #include <ogre_tools/billboard_line.h> 00041 #include <boost/thread/mutex.hpp> 00042 00043 #include <boost/shared_ptr.hpp> 00044 00045 #include <geometry_msgs/Polygon.h> 00046 #include <mapping_msgs/PolygonalMap.h> 00047 00048 #include <message_filters/subscriber.h> 00049 #include <tf/message_filter.h> 00050 00051 namespace ogre_tools 00052 { 00053 class PointCloud; 00054 } 00055 00056 namespace Ogre 00057 { 00058 class SceneNode; 00059 class ManualObject; 00060 } 00061 00062 namespace mapping_rviz_plugin 00063 { 00064 00065 namespace polygon_render_ops 00066 { 00067 enum PolygonRenderOp 00068 { 00069 PLines, 00070 PPoints, 00071 PBillboards, 00072 PCount, 00073 }; 00074 } 00075 typedef polygon_render_ops::PolygonRenderOp PolygonRenderOp; 00076 00081 class PolygonalMapDisplay : public rviz::Display 00082 { 00083 public: 00084 PolygonalMapDisplay(const std::string& name, rviz::VisualizationManager* manager); 00085 00086 virtual ~PolygonalMapDisplay(); 00087 00088 void setTopic(const std::string& topic); 00089 const std::string& getTopic() 00090 { 00091 return (topic_); 00092 } 00093 00094 void setColor(const rviz::Color& color); 00095 const rviz::Color& getColor() 00096 { 00097 return (color_); 00098 } 00099 00100 void setRenderOperation(int op); 00101 int getRenderOperation() 00102 { 00103 return (render_operation_); 00104 } 00105 00106 void setPointSize(float size); 00107 float getPointSize() 00108 { 00109 return (point_size_); 00110 } 00111 00112 void setAlpha(float alpha); 00113 float getAlpha() 00114 { 00115 return (alpha_); 00116 } 00117 00118 // Overrides from Display 00119 virtual void targetFrameChanged(); 00120 virtual void fixedFrameChanged(); 00121 virtual void createProperties(); 00122 virtual void update(float wall_dt, float ros_dt); 00123 virtual void reset(); 00124 00125 void setLineWidth (float width); 00126 float getLineWidth () { return (line_width_); } 00127 00128 protected: 00129 void subscribe(); 00130 void unsubscribe(); 00131 void clear(); 00132 void incomingMessage(const mapping_msgs::PolygonalMap::ConstPtr& msg); 00133 void processMessage(const mapping_msgs::PolygonalMap::ConstPtr& msg); 00134 00135 // overrides from Display 00136 virtual void onEnable(); 00137 virtual void onDisable(); 00138 00139 std::string topic_; 00140 rviz::Color color_; 00141 int render_operation_; 00142 float point_size_; 00143 float alpha_; 00144 float line_width_; 00145 00146 Ogre::SceneNode* scene_node_; 00147 Ogre::ManualObject* manual_object_; 00148 ogre_tools::PointCloud* cloud_; 00149 00150 mapping_msgs::PolygonalMap::ConstPtr current_message_; 00151 message_filters::Subscriber<mapping_msgs::PolygonalMap> sub_; 00152 tf::MessageFilter<mapping_msgs::PolygonalMap> tf_filter_; 00153 00154 ogre_tools::BillboardLine* billboard_line_; 00155 00156 rviz::ColorPropertyWPtr color_property_; 00157 rviz::ROSTopicStringPropertyWPtr topic_property_; 00158 rviz::EnumPropertyWPtr render_operation_property_; 00159 rviz::FloatPropertyWPtr point_size_property_; 00160 rviz::FloatPropertyWPtr alpha_property_; 00161 rviz::FloatPropertyWPtr line_width_property_; 00162 }; 00163 00164 } // namespace mapping_rviz_plugin 00165 00166 #endif /* RVIZ_POLYGONAL_MAP_DISPLAY_H_ */