Gazebo Gui

API Reference

9.0.0~pre1
PlottingInterface.hh
Go to the documentation of this file.
1/*
2 * Copyright (C) 2020 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#ifndef GZ_GUI_PLOTTINGINTERFACE_HH_
18#define GZ_GUI_PLOTTINGINTERFACE_HH_
19
20#include <QObject>
21#include <QString>
22#include <QMap>
23#include <QVariant>
24#ifdef _MSC_VER
25#pragma warning(push)
26#pragma warning(disable: 4251)
27#endif
28#include <google/protobuf/message.h>
29#include <google/protobuf/descriptor.h>
30#ifdef _MSC_VER
31#pragma warning(pop)
32#endif
33#include <map>
34#include <set>
35#include <string>
36#include <memory>
37#include <limits>
38
39#include "gz/gui/Export.hh"
40
41#include <gz/utils/ImplPtr.hh>
42
43namespace gz::gui
44{
48class GZ_GUI_VISIBLE PlotData
49{
51 public: PlotData();
52
54 public: ~PlotData();
55
58 public: void SetValue(const double _value);
59
62 public: double Value() const;
63
66 public: void SetTime(const double _time);
67
70 public: double Time() const;
71
74 public: void AddChart(int _chart);
75
77 public: void RemoveChart(int _chart);
78
81 public: int ChartCount() const;
82
86
88 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
89};
90
92class GZ_GUI_VISIBLE Topic : public QObject
93{
94 Q_OBJECT
95
97 public: explicit Topic(const std::string &_name);
98
100 public: ~Topic();
101
104 public: std::string &Name() const;
105
109 public: void Register(const std::string &_fieldPath, int _chart);
110
114 public: void UnRegister(const std::string &_fieldPath, int _chart);
115
118 public: int FieldCount() const;
119
123
126 public: void Callback(const google::protobuf::Message &_msg);
127
131 public: bool HasHeader(const google::protobuf::Message &_msg,
132 double &_headerTime);
133
136 public: void UpdateGui(const std::string &_field);
137
143 signals: void plot(int _chart, QString _fieldID, double _x, double _y);
144
147 public: void SetPlottingTimeRef(const std::shared_ptr<double> &_time);
148
150 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
151};
152
154class GZ_GUI_VISIBLE Transport : public QObject
155{
156 Q_OBJECT
157
159 public: Transport();
160
162 public: ~Transport();
163
168 public: void Unsubscribe(const std::string &_topic,
169 const std::string &_fieldPath,
170 int _chart);
171
177 public: void Subscribe(const std::string &_topic,
178 const std::string &_fieldPath,
179 int _chart, const std::shared_ptr<double> &_time);
180
182 public slots: void UnsubscribeOutdatedTopics();
183
187
193 public slots: void onPlot(int _chart, QString _fieldID, double _x, double _y);
194
200 signals: void plot(int _chart, QString _fieldID, double _x, double _y);
201
202 private:
204 GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
205};
206
211class GZ_GUI_VISIBLE PlottingInterface : public QObject
212{
213 Q_OBJECT
214
216 public: explicit PlottingInterface();
217
220
225 public slots: void subscribe(int _chart,
226 QString _fieldPath,
227 QString _topic);
228
233 public slots: void unsubscribe(int _chart,
234 QString _fieldPath,
235 QString _topic);
236
239 public: float Timeout() const;
240
246 public slots: void onPlot(int _chart, QString _fieldID, double _x, double _y);
247
253 signals: void plot(int _chart, QString _fieldID, double _x, double _y);
254
261 public slots: void onComponentSubscribe(QString _entity,
262 QString _typeId,
263 QString _type,
264 QString _attribute,
265 int _chart);
266
272 public slots: void onComponentUnSubscribe(QString _entity,
273 QString _typeId,
274 QString _attribute,
275 int _chart);
276
283 signals: void ComponentSubscribe(uint64_t _entity,
284 uint64_t _typeId,
285 const std::string &_type,
286 const std::string &_attribute,
287 int _chart);
288
294 signals: void ComponentUnSubscribe(uint64_t _entity,
295 uint64_t _typeId,
296 const std::string &_attribute,
297 int _chart);
298
303 public slots: std::string FilePath(QString _path, std::string _name,
304 std::string _extention);
305
311 public slots: bool exportCSV(QString _path, int _chart,
312 QMap< QString, QVariant> _serieses);
313
317 signals: std::string ComponentName(uint64_t _typeId);
318
320 public: void InitTimer();
321
323 public slots: void UpdateTime();
324
327 private: GZ_UTILS_UNIQUE_IMPL_PTR(dataPtr)
328};
329} // namespace gz::gui
330#endif // GZ_GUI_PLOTTINGINTERFACE_HH_