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
mapviz_plugins::StringPlugin::FONT_KEY
static const char * FONT_KEY
Definition: string_plugin.h:142
mapviz_plugins::StringPlugin::CENTER
@ CENTER
Definition: string_plugin.h:68
mapviz_plugins::StringPlugin::SelectFont
void SelectFont()
Definition: string_plugin.cpp:282
mapviz_plugins::StringPlugin::Anchor
Anchor
Definition: string_plugin.h:63
mapviz_plugins::StringPlugin::Paint
void Paint(QPainter *painter, double x, double y, double scale)
Definition: string_plugin.cpp:102
mapviz_plugins::StringPlugin::LoadConfig
void LoadConfig(const YAML::Node &node, const std::string &path)
Definition: string_plugin.cpp:197
boost::shared_ptr< ShapeShifter const >
mapviz_plugins::StringPlugin::PrintError
void PrintError(const std::string &message)
Definition: string_plugin.cpp:262
mapviz_plugins::StringPlugin::CENTER_LEFT
@ CENTER_LEFT
Definition: string_plugin.h:67
mapviz_plugins::StringPlugin::font_
QFont font_
Definition: string_plugin.h:132
mapviz_plugins::StringPlugin::SetOffsetX
void SetOffsetX(int offset)
Definition: string_plugin.cpp:380
mapviz_plugins::StringPlugin::PIXELS
@ PIXELS
Definition: string_plugin.h:76
ros.h
mapviz_plugins::StringPlugin::TOPIC_KEY
static const char * TOPIC_KEY
Definition: string_plugin.h:145
mapviz_plugins::StringPlugin::AnchorToString
std::string AnchorToString(Anchor anchor)
Definition: string_plugin.cpp:414
mapviz_plugins::StringPlugin::SetAnchor
void SetAnchor(QString anchor)
Definition: string_plugin.cpp:328
mapviz_plugins::StringPlugin::color_
QColor color_
Definition: string_plugin.h:131
mapviz_plugins::StringPlugin::config_widget_
QWidget * config_widget_
Definition: string_plugin.h:119
mapviz_plugins::StringPlugin::Draw
void Draw(double x, double y, double scale)
Definition: string_plugin.cpp:97
mapviz_plugins::StringPlugin::PrintWarning
void PrintWarning(const std::string &message)
Definition: string_plugin.cpp:272
mapviz_plugins::StringPlugin::offset_x_
int offset_x_
Definition: string_plugin.h:124
mapviz_plugins::StringPlugin::TopicEdited
void TopicEdited()
Definition: string_plugin.cpp:307
mapviz_plugins::StringPlugin::PrintInfo
void PrintInfo(const std::string &message)
Definition: string_plugin.cpp:267
mapviz_plugins::StringPlugin::ui_
Ui::string_config ui_
Definition: string_plugin.h:118
mapviz_plugins::StringPlugin::StringPlugin
StringPlugin()
Definition: string_plugin.cpp:50
mapviz_plugins::StringPlugin::CENTER_RIGHT
@ CENTER_RIGHT
Definition: string_plugin.h:69
mapviz_plugins::StringPlugin::TOP_LEFT
@ TOP_LEFT
Definition: string_plugin.h:64
mapviz_plugins::StringPlugin::SaveConfig
void SaveConfig(YAML::Emitter &emitter, const std::string &path)
Definition: string_plugin.cpp:245
mapviz_plugins::StringPlugin::string_sub_
ros::Subscriber string_sub_
Definition: string_plugin.h:127
mapviz_plugins::StringPlugin::COLOR_KEY
static const char * COLOR_KEY
Definition: string_plugin.h:141
mapviz_plugins::StringPlugin::SelectColor
void SelectColor()
Definition: string_plugin.cpp:277
mapviz_plugins::StringPlugin::SetUnits
void SetUnits(QString units)
Definition: string_plugin.cpp:368
mapviz_plugins::StringPlugin::offset_y_
int offset_y_
Definition: string_plugin.h:125
mapviz_plugins::StringPlugin::SupportsPainting
bool SupportsPainting()
Definition: string_plugin.h:96
mapviz_plugins::StringPlugin::topic_
std::string topic_
Definition: string_plugin.h:121
mapviz_plugins::StringPlugin::Units
Units
Definition: string_plugin.h:75
mapviz_plugins::StringPlugin::BOTTOM_RIGHT
@ BOTTOM_RIGHT
Definition: string_plugin.h:72
mapviz_plugins::StringPlugin::OFFSET_Y_KEY
static const char * OFFSET_Y_KEY
Definition: string_plugin.h:144
mapviz_plugins::StringPlugin::GetConfigWidget
QWidget * GetConfigWidget(QWidget *parent)
Definition: string_plugin.cpp:256
mapviz_plugins::StringPlugin::BOTTOM_CENTER
@ BOTTOM_CENTER
Definition: string_plugin.h:71
shape_shifter.h
mapviz_plugins::StringPlugin::PERCENT
@ PERCENT
Definition: string_plugin.h:77
mapviz_plugins::StringPlugin::anchor_
Anchor anchor_
Definition: string_plugin.h:122
mapviz_plugins::StringPlugin::BOTTOM_LEFT
@ BOTTOM_LEFT
Definition: string_plugin.h:70
mapviz_plugins::StringPlugin::Transform
void Transform()
Definition: string_plugin.h:89
mapviz_plugins::StringPlugin
Definition: string_plugin.h:58
mapviz_plugins::StringPlugin::has_message_
bool has_message_
Definition: string_plugin.h:128
mapviz_plugins::StringPlugin::SelectTopic
void SelectTopic()
Definition: string_plugin.cpp:295
mapviz_plugins::StringPlugin::ANCHOR_KEY
static const char * ANCHOR_KEY
Definition: string_plugin.h:140
mapviz_plugins::StringPlugin::Shutdown
void Shutdown()
Definition: string_plugin.h:84
mapviz_plugins::StringPlugin::TOP_RIGHT
@ TOP_RIGHT
Definition: string_plugin.h:66
mapviz_plugins::StringPlugin::Initialize
bool Initialize(QGLWidget *canvas)
Definition: string_plugin.cpp:91
mapviz_plugins::StringPlugin::~StringPlugin
virtual ~StringPlugin()
Definition: string_plugin.cpp:87
mapviz_plugins::StringPlugin::UnitsToString
std::string UnitsToString(Units units)
Definition: string_plugin.cpp:458
mapviz_plugins::StringPlugin::message_
QStaticText message_
Definition: string_plugin.h:133
mapviz_plugins::StringPlugin::OFFSET_X_KEY
static const char * OFFSET_X_KEY
Definition: string_plugin.h:143
mapviz::MapvizPlugin
mapviz_plugins::StringPlugin::SetOffsetY
void SetOffsetY(int offset)
Definition: string_plugin.cpp:385
mapviz_plugins::StringPlugin::TOP_CENTER
@ TOP_CENTER
Definition: string_plugin.h:65
mapviz_plugins::StringPlugin::stringCallback
void stringCallback(const topic_tools::ShapeShifter::ConstPtr &msg)
Definition: string_plugin.cpp:396
mapviz_plugins::StringPlugin::PaintText
void PaintText(QPainter *painter)
Definition: string_plugin.cpp:137
mapviz_plugins::StringPlugin::has_painted_
bool has_painted_
Definition: string_plugin.h:129
mapviz_plugins
Definition: attitude_indicator_plugin.h:61
mapviz_plugins::StringPlugin::units_
Units units_
Definition: string_plugin.h:123
mapviz_plugins::StringPlugin::UNITS_KEY
static const char * UNITS_KEY
Definition: string_plugin.h:146
ros::Subscriber
mapviz_plugin.h


mapviz_plugins
Author(s): Marc Alban
autogenerated on Sun Sep 8 2024 02:27:14