Gazebo Gui

API Reference

8.3.0
TopicEcho.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 
18 #ifndef GZ_GUI_PLUGINS_TOPICECHO_HH_
19 #define GZ_GUI_PLUGINS_TOPICECHO_HH_
20 
21 #ifdef _MSC_VER
22 #pragma warning(push)
23 #pragma warning(disable: 4251)
24 #endif
25 #include <google/protobuf/message.h>
26 #ifdef _MSC_VER
27 #pragma warning(pop)
28 #endif
29 
30 #ifndef _WIN32
31 # define TopicEcho_EXPORTS_API
32 #else
33 # if (defined(TopicEcho_EXPORTS))
34 # define TopicEcho_EXPORTS_API __declspec(dllexport)
35 # else
36 # define TopicEcho_EXPORTS_API __declspec(dllimport)
37 # endif
38 #endif
39 
40 #include <memory>
41 
42 #include "gz/gui/Plugin.hh"
43 
44 namespace gz::gui::plugins
45 {
46  class TopicEchoPrivate;
47 
52  class TopicEcho_EXPORTS_API TopicEcho : public Plugin
53  {
54  Q_OBJECT
55 
57  Q_PROPERTY(
58  QString topic
59  READ Topic
60  WRITE SetTopic
61  NOTIFY TopicChanged
62  )
63 
64 
65  Q_PROPERTY(
66  bool paused
67  READ Paused
68  WRITE SetPaused
69  NOTIFY PausedChanged
70  )
71 
72 
73  public: TopicEcho();
74 
76  public: virtual ~TopicEcho();
77 
78  // Documentation inherited
79  public: virtual void LoadConfig(const tinyxml2::XMLElement *_pluginElem);
80 
84  public: Q_INVOKABLE QString Topic() const;
85 
89  public: Q_INVOKABLE void SetTopic(const QString &_topic);
90 
92  signals: void TopicChanged();
93 
94  public slots: void OnBuffer(const unsigned int _steps);
95 
98  public: Q_INVOKABLE bool Paused() const;
99 
102  public: Q_INVOKABLE void SetPaused(const bool &_paused);
103 
105  signals: void PausedChanged();
106 
109  signals: void AddMsg(QString _msg);
110 
113  private: void OnMessage(const google::protobuf::Message &_msg);
114 
116  private: void Stop();
117 
119  public slots: void OnEcho(const bool _checked);
120 
123  private slots: void OnAddMsg(QString _msg);
124 
127  private: std::unique_ptr<TopicEchoPrivate> dataPtr;
128  };
129 } // namespace gz::gui::plugins
130 
131 #endif // GZ_GUI_PLUGINS_TOPICECHO_HH_