00001 // ***************************************************************************** 00002 // 00003 // Copyright (c) 2014, Southwest Research Institute® (SwRI®) 00004 // All rights reserved. 00005 // 00006 // Redistribution and use in source and binary forms, with or without 00007 // modification, are permitted provided that the following conditions are met: 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 Southwest Research Institute® (SwRI®) nor the 00014 // names of its contributors may be used to endorse or promote products 00015 // derived from 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 <COPYRIGHT HOLDER> BE LIABLE FOR ANY 00021 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00022 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00023 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00024 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00026 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 // 00028 // ***************************************************************************** 00029 00030 #ifndef MAPVIZ_POINT_DRAW_H_ 00031 #define MAPVIZ_POINT_DRAW_H_ 00032 00033 // C++ standard libraries 00034 #include <string> 00035 #include <list> 00036 00037 #include <mapviz/mapviz_plugin.h> 00038 #include <mapviz/map_canvas.h> 00039 00040 // QT libraries 00041 #include <QGLWidget> 00042 #include <QObject> 00043 #include <QWidget> 00044 00045 // ROS libraries 00046 #include <ros/ros.h> 00047 #include <tf/transform_datatypes.h> 00048 00049 namespace mapviz_plugins 00050 { 00051 class PointDrawingPlugin : public mapviz::MapvizPlugin 00052 { 00053 Q_OBJECT 00054 00055 public: 00056 struct StampedPoint 00057 { 00058 tf::Point point; 00059 tf::Quaternion orientation; 00060 tf::Point transformed_point; 00061 tf::Point transformed_arrow_point; 00062 tf::Point transformed_arrow_left; 00063 tf::Point transformed_arrow_right; 00064 std::string source_frame; 00065 bool transformed; 00066 ros::Time stamp; 00067 00068 std::vector<tf::Point> cov_points; 00069 std::vector<tf::Point> transformed_cov_points; 00070 }; 00071 00072 enum DrawStyle 00073 { 00074 LINES = 0, 00075 POINTS, 00076 ARROWS 00077 }; 00078 00079 PointDrawingPlugin(); 00080 virtual ~PointDrawingPlugin() 00081 { 00082 } 00083 virtual void Transform(); 00084 virtual bool DrawPoints(double scale); 00085 virtual bool DrawArrows(); 00086 virtual bool DrawArrow(const StampedPoint& point); 00087 virtual bool DrawLaps(); 00088 virtual bool DrawLines(); 00089 virtual void CollectLaps(); 00090 virtual bool DrawLapsArrows(); 00091 virtual bool TransformPoint(StampedPoint& point); 00092 virtual void UpdateColor(QColor base_color, int i); 00093 00094 protected Q_SLOTS: 00095 virtual void BufferSizeChanged(int value); 00096 virtual void DrawIcon(); 00097 virtual void SetColor(const QColor& color); 00098 virtual void SetDrawStyle(QString style); 00099 virtual void SetStaticArrowSizes(bool isChecked); 00100 virtual void SetArrowSize(int arrowSize); 00101 virtual void PositionToleranceChanged(double value); 00102 00103 protected: 00104 int arrow_size_; 00105 DrawStyle draw_style_; 00106 StampedPoint cur_point_; 00107 std::list<StampedPoint> points_; 00108 double position_tolerance_; 00109 int buffer_size_; 00110 bool covariance_checked_; 00111 bool new_lap_; 00112 QColor color_; 00113 bool lap_checked_; 00114 int buffer_holder_; 00115 double scale_; 00116 bool static_arrow_sizes_; 00117 00118 private: 00119 std::vector<std::list<StampedPoint> > laps_; 00120 bool got_begin_; 00121 tf::Point begin_; 00122 }; 00123 } 00124 00125 #endif // MAPVIZ_PLUGINS_POINT_DRAW_H_