string_plugin.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2015, 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 Southwest Research Institute® BE LIABLE
21 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
24 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28 //
29 // *****************************************************************************
30 
31 #ifndef MAPVIZ_PLUGINS_STRING_PLUGIN_H
32 #define MAPVIZ_PLUGINS_STRING_PLUGIN_H
33 
34 #include <string>
35 
36 #include <mapviz/mapviz_plugin.h>
37 
38 #include <QObject>
39 #include <QString>
40 #include <QColor>
41 #include <QWidget>
42 #include <QGLWidget>
43 #include <QPainter>
44 #include <QFont>
45 #include <QStaticText>
46 
47 
48 #include <ros/ros.h>
49 #include <std_msgs/String.h>
50 
51 // QT autogenerated files
52 #include "ui_string_config.h"
53 
54 namespace mapviz_plugins
55 {
57  {
58  Q_OBJECT
59 
60  public:
61  enum Anchor {
71  };
72 
73  enum Units {
76  };
77 
78  StringPlugin();
79  virtual ~StringPlugin();
80 
81  bool Initialize(QGLWidget* canvas);
82  void Shutdown() {}
83 
84  void Draw(double x, double y, double scale);
85  void Paint(QPainter* painter, double x, double y, double scale);
86 
87  void Transform() {}
88 
89  void LoadConfig(const YAML::Node& node, const std::string& path);
90  void SaveConfig(YAML::Emitter& emitter, const std::string& path);
91 
92  QWidget* GetConfigWidget(QWidget* parent);
93 
95  {
96  return true;
97  }
98 
99  protected:
100  void PaintText(QPainter* painter);
101  void PrintError(const std::string& message);
102  void PrintInfo(const std::string& message);
103  void PrintWarning(const std::string& message);
104 
105  protected Q_SLOTS:
106  void SelectColor();
107  void SelectFont();
108  void SelectTopic();
109  void TopicEdited();
110  void SetAnchor(QString anchor);
111  void SetUnits(QString units);
112  void SetOffsetX(int offset);
113  void SetOffsetY(int offset);
114 
115  private:
116  Ui::string_config ui_;
117  QWidget* config_widget_;
118 
119  std::string topic_;
124 
128 
129  QColor color_;
130  QFont font_;
131  QStaticText message_;
132 
133  void stringCallback(const std_msgs::StringConstPtr& str);
134 
135  std::string AnchorToString(Anchor anchor);
136  std::string UnitsToString(Units units);
137 
138  static const char* ANCHOR_KEY;
139  static const char* COLOR_KEY;
140  static const char* FONT_KEY;
141  static const char* OFFSET_X_KEY;
142  static const char* OFFSET_Y_KEY;
143  static const char* TOPIC_KEY;
144  static const char* UNITS_KEY;
145  };
146 }
147 
148 
149 #endif //MAPVIZ_PLUGINS_STRING_PLUGIN_H
QWidget * GetConfigWidget(QWidget *parent)
void PrintInfo(const std::string &message)
void PrintError(const std::string &message)
static const char * COLOR_KEY
std::string AnchorToString(Anchor anchor)
bool Initialize(QGLWidget *canvas)
void SaveConfig(YAML::Emitter &emitter, const std::string &path)
TFSIMD_FORCE_INLINE const tfScalar & y() const
static const char * ANCHOR_KEY
static const char * TOPIC_KEY
void PaintText(QPainter *painter)
TFSIMD_FORCE_INLINE const tfScalar & x() const
void SetUnits(QString units)
void Paint(QPainter *painter, double x, double y, double scale)
static const char * FONT_KEY
static const char * UNITS_KEY
static const char * OFFSET_Y_KEY
void stringCallback(const std_msgs::StringConstPtr &str)
void Draw(double x, double y, double scale)
void LoadConfig(const YAML::Node &node, const std::string &path)
std::string UnitsToString(Units units)
static const char * OFFSET_X_KEY
void SetAnchor(QString anchor)
void PrintWarning(const std::string &message)


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