float_plugin.h
Go to the documentation of this file.
1 // *****************************************************************************
2 //
3 // Copyright (c) 2019, 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_FLOAT_PLUGIN_H
32 #define MAPVIZ_PLUGINS_FLOAT_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 
51 // QT autogenerated files
52 #include "ui_float_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  FloatPlugin();
79  virtual ~FloatPlugin();
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  void PostfixEdited();
115 
116  private:
117  Ui::float_config ui_;
118  QWidget* config_widget_;
119 
120  std::string topic_;
121  std::string postfix_;
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  static const char* POSTFIX_KEY;
148  };
149 }
150 
151 
152 #endif //MAPVIZ_PLUGINS_FLOAT_PLUGIN_H
static const char * OFFSET_Y_KEY
Definition: float_plugin.h:144
static const char * FONT_KEY
Definition: float_plugin.h:142
void PrintWarning(const std::string &message)
void SetUnits(QString units)
ros::Subscriber float_sub_
Definition: float_plugin.h:127
void SetAnchor(QString anchor)
void LoadConfig(const YAML::Node &node, const std::string &path)
static const char * OFFSET_X_KEY
Definition: float_plugin.h:143
std::string AnchorToString(Anchor anchor)
void Paint(QPainter *painter, double x, double y, double scale)
static const char * UNITS_KEY
Definition: float_plugin.h:146
static const char * TOPIC_KEY
Definition: float_plugin.h:145
std::string UnitsToString(Units units)
static const char * POSTFIX_KEY
Definition: float_plugin.h:147
void Draw(double x, double y, double scale)
static const char * COLOR_KEY
Definition: float_plugin.h:141
static const char * ANCHOR_KEY
Definition: float_plugin.h:140
void PaintText(QPainter *painter)
void SaveConfig(YAML::Emitter &emitter, const std::string &path)
void floatCallback(const topic_tools::ShapeShifter::ConstPtr &msg)
bool Initialize(QGLWidget *canvas)
void PrintError(const std::string &message)
void PrintInfo(const std::string &message)
QWidget * GetConfigWidget(QWidget *parent)


mapviz_plugins
Author(s): Marc Alban
autogenerated on Fri Dec 16 2022 03:59:33