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 00084 void ClearHistory(); 00085 00086 virtual void Transform(); 00087 virtual bool DrawPoints(double scale); 00088 virtual bool DrawArrows(); 00089 virtual bool DrawArrow(const StampedPoint& point); 00090 virtual bool DrawLaps(); 00091 virtual bool DrawLines(); 00092 virtual void CollectLaps(); 00093 virtual bool DrawLapsArrows(); 00094 virtual bool TransformPoint(StampedPoint& point); 00095 virtual void UpdateColor(QColor base_color, int i); 00096 00097 protected Q_SLOTS: 00098 virtual void BufferSizeChanged(int value); 00099 virtual void DrawIcon(); 00100 virtual void SetColor(const QColor& color); 00101 virtual void SetDrawStyle(QString style); 00102 virtual void SetStaticArrowSizes(bool isChecked); 00103 virtual void SetArrowSize(int arrowSize); 00104 virtual void PositionToleranceChanged(double value); 00105 00106 protected: 00107 int arrow_size_; 00108 DrawStyle draw_style_; 00109 StampedPoint cur_point_; 00110 std::list<StampedPoint> points_; 00111 double position_tolerance_; 00112 int buffer_size_; 00113 bool covariance_checked_; 00114 bool new_lap_; 00115 QColor color_; 00116 bool lap_checked_; 00117 int buffer_holder_; 00118 double scale_; 00119 bool static_arrow_sizes_; 00120 00121 private: 00122 std::vector<std::list<StampedPoint> > laps_; 00123 bool got_begin_; 00124 tf::Point begin_; 00125 }; 00126 } 00127 00128 #endif // MAPVIZ_PLUGINS_POINT_DRAW_H_