marker_plugin.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2014, Southwest Research Institute® (SwRI®)
4 // All rights reserved.
5 //
6 // Redistribution and use in source and binary forms, with or without
7 // modification, are permitted provided that the following conditions are met:
8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above copyright
11 // notice, this list of conditions and the following disclaimer in the
12 // documentation and/or other materials provided with the distribution.
13 // * Neither the name of Southwest Research Institute® (SwRI®) nor the
14 // names of its contributors may be used to endorse or promote products
15 // derived from this software without specific prior written permission.
16 //
17 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
18 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 // ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
21 // DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 // *****************************************************************************
29 
30 #ifndef MAPVIZ_PLUGINS_MARKER_PLUGIN_H_
31 #define MAPVIZ_PLUGINS_MARKER_PLUGIN_H_
32 
33 // C++ standard libraries
34 #include <string>
35 #include <list>
36 #include <map>
37 
38 #include <mapviz/mapviz_plugin.h>
39 
40 // QT libraries
41 #include <QGLWidget>
42 #include <QObject>
43 #include <QWidget>
44 #include <QColor>
45 
46 // ROS libraries
47 #include <ros/ros.h>
48 #include <tf/transform_datatypes.h>
50 #include <visualization_msgs/Marker.h>
51 #include <visualization_msgs/MarkerArray.h>
52 #include <std_msgs/ColorRGBA.h>
53 
54 #include <mapviz/map_canvas.h>
55 
56 // QT autogenerated files
57 #include "ui_marker_config.h"
58 
59 namespace mapviz_plugins
60 {
62  {
63  Q_OBJECT
64 
65  public:
66  MarkerPlugin();
67  virtual ~MarkerPlugin();
68 
69  bool Initialize(QGLWidget* canvas);
70  void Shutdown() {}
71 
72  void ClearHistory();
73 
74  void Draw(double x, double y, double scale);
75  void Paint(QPainter* painter, double x, double y, double scale);
76 
77  void Transform();
78 
79  void LoadConfig(const YAML::Node& node, const std::string& path);
80  void SaveConfig(YAML::Emitter& emitter, const std::string& path);
81 
82  QWidget* GetConfigWidget(QWidget* parent);
83 
85  {
86  return true;
87  }
88 
89  protected:
90  void PrintError(const std::string& message);
91  void PrintInfo(const std::string& message);
92  void PrintWarning(const std::string& message);
93  void timerEvent(QTimerEvent *);
94 
95  protected Q_SLOTS:
96  void SelectTopic();
97  void TopicEdited();
98 
99  private:
101  {
104 
106 
111 
112  QColor color;
113  };
114 
115  struct MarkerData
116  {
119 
121  QColor color;
122 
123  std::list<StampedPoint> points;
124  std::string text;
125 
126  float scale_x;
127  float scale_y;
128  float scale_z;
129 
130  std::string source_frame;
132 
134  };
135 
136  Ui::marker_config ui_;
137  QWidget* config_widget_;
138 
139  std::string topic_;
140 
144 
145  std::map<std::string, std::map<int, MarkerData> > markers_;
146 
148  void handleMarker(const visualization_msgs::Marker &marker);
149  void handleMarkerArray(const visualization_msgs::MarkerArray &markers);
150  void transformArrow(MarkerData& markerData,
151  const swri_transform_util::Transform& transform);
152  };
153 }
154 
155 #endif // MAPVIZ_PLUGINS_MARKER_PLUGIN_H_
void handleMessage(const topic_tools::ShapeShifter::ConstPtr &msg)
void handleMarker(const visualization_msgs::Marker &marker)
void Draw(double x, double y, double scale)
std::map< std::string, std::map< int, MarkerData > > markers_
void PrintError(const std::string &message)
TFSIMD_FORCE_INLINE const tfScalar & y() const
QWidget * GetConfigWidget(QWidget *parent)
void transformArrow(MarkerData &markerData, const swri_transform_util::Transform &transform)
void LoadConfig(const YAML::Node &node, const std::string &path)
void PrintWarning(const std::string &message)
TFSIMD_FORCE_INLINE const tfScalar & x() const
void timerEvent(QTimerEvent *)
void Paint(QPainter *painter, double x, double y, double scale)
swri_transform_util::Transform local_transform
void SaveConfig(YAML::Emitter &emitter, const std::string &path)
void handleMarkerArray(const visualization_msgs::MarkerArray &markers)
void PrintInfo(const std::string &message)
bool Initialize(QGLWidget *canvas)


mapviz_plugins
Author(s): Marc Alban
autogenerated on Thu Jun 6 2019 19:25:16