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>
50 #include <std_msgs/String.h>
51 #include <marti_common_msgs/StringStamped.h>
52 
53 // QT autogenerated files
54 #include "ui_string_config.h"
55 
56 namespace mapviz_plugins
57 {
59  {
60  Q_OBJECT
61 
62  public:
63  enum Anchor {
73  };
74 
75  enum Units {
78  };
79 
80  StringPlugin();
81  virtual ~StringPlugin();
82 
83  bool Initialize(QGLWidget* canvas);
84  void Shutdown() {}
85 
86  void Draw(double x, double y, double scale);
87  void Paint(QPainter* painter, double x, double y, double scale);
88 
89  void Transform() {}
90 
91  void LoadConfig(const YAML::Node& node, const std::string& path);
92  void SaveConfig(YAML::Emitter& emitter, const std::string& path);
93 
94  QWidget* GetConfigWidget(QWidget* parent);
95 
97  {
98  return true;
99  }
100 
101  protected:
102  void PaintText(QPainter* painter);
103  void PrintError(const std::string& message);
104  void PrintInfo(const std::string& message);
105  void PrintWarning(const std::string& message);
106 
107  protected Q_SLOTS:
108  void SelectColor();
109  void SelectFont();
110  void SelectTopic();
111  void TopicEdited();
112  void SetAnchor(QString anchor);
113  void SetUnits(QString units);
114  void SetOffsetX(int offset);
115  void SetOffsetY(int offset);
116 
117  private:
118  Ui::string_config ui_;
119  QWidget* config_widget_;
120 
121  std::string topic_;
126 
130 
131  QColor color_;
132  QFont font_;
133  QStaticText message_;
134 
136 
137  std::string AnchorToString(Anchor anchor);
138  std::string UnitsToString(Units units);
139 
140  static const char* ANCHOR_KEY;
141  static const char* COLOR_KEY;
142  static const char* FONT_KEY;
143  static const char* OFFSET_X_KEY;
144  static const char* OFFSET_Y_KEY;
145  static const char* TOPIC_KEY;
146  static const char* UNITS_KEY;
147  };
148 }
149 
150 
151 #endif //MAPVIZ_PLUGINS_STRING_PLUGIN_H
QWidget * GetConfigWidget(QWidget *parent)
void PrintInfo(const std::string &message)
void stringCallback(const topic_tools::ShapeShifter::ConstPtr &msg)
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 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 Fri Mar 19 2021 02:44:32