Gazebo Gui

API Reference

7.2.2
gz/gui/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 namespace gz::gui
42 {
43 class PlotDataPrivate;
44 
48 class 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 
85  public: std::set<int> &Charts();
86 
88  private: std::unique_ptr<PlotDataPrivate> dataPtr;
89 };
90 
91 class TopicPrivate;
92 
94 class GZ_GUI_VISIBLE Topic : public QObject
95 {
96  Q_OBJECT
97 
99  public: explicit Topic(const std::string &_name);
100 
102  public: ~Topic();
103 
106  public: std::string &Name() const;
107 
111  public: void Register(const std::string &_fieldPath, int _chart);
112 
116  public: void UnRegister(const std::string &_fieldPath, int _chart);
117 
120  public: int FieldCount() const;
121 
124  public: std::map<std::string, PlotData *> &Fields();
125 
128  public: void Callback(const google::protobuf::Message &_msg);
129 
133  public: bool HasHeader(const google::protobuf::Message &_msg,
134  double &_headerTime);
135 
138  public: void UpdateGui(const std::string &_field);
139 
145  signals: void plot(int _chart, QString _fieldID, double _x, double _y);
146 
149  public: void SetPlottingTimeRef(const std::shared_ptr<double> &_time);
150 
152  private: std::unique_ptr<TopicPrivate> dataPtr;
153 };
154 
155 class TransportPrivate;
156 
158 class GZ_GUI_VISIBLE Transport : public QObject
159 {
160  Q_OBJECT
161 
163  public: Transport();
164 
166  public: ~Transport();
167 
172  public: void Unsubscribe(const std::string &_topic,
173  const std::string &_fieldPath,
174  int _chart);
175 
181  public: void Subscribe(const std::string &_topic,
182  const std::string &_fieldPath,
183  int _chart, const std::shared_ptr<double> &_time);
184 
186  public slots: void UnsubscribeOutdatedTopics();
187 
190  public: const std::map<std::string, Topic*> &Topics();
191 
197  public slots: void onPlot(int _chart, QString _fieldID, double _x, double _y);
198 
204  signals: void plot(int _chart, QString _fieldID, double _x, double _y);
205 
207  private: std::unique_ptr<TransportPrivate> dataPtr;
208 };
209 
210 class PlottingIfacePrivate;
211 
216 class GZ_GUI_VISIBLE PlottingInterface : public QObject
217 {
218  Q_OBJECT
219 
221  public: explicit PlottingInterface();
222 
224  public: ~PlottingInterface();
225 
230  public slots: void subscribe(int _chart,
231  QString _fieldPath,
232  QString _topic);
233 
238  public slots: void unsubscribe(int _chart,
239  QString _fieldPath,
240  QString _topic);
241 
244  public: float Timeout() const;
245 
251  public slots: void onPlot(int _chart, QString _fieldID, double _x, double _y);
252 
258  signals: void plot(int _chart, QString _fieldID, double _x, double _y);
259 
266  public slots: void onComponentSubscribe(QString _entity,
267  QString _typeId,
268  QString _type,
269  QString _attribute,
270  int _chart);
271 
277  public slots: void onComponentUnSubscribe(QString _entity,
278  QString _typeId,
279  QString _attribute,
280  int _chart);
281 
288  signals: void ComponentSubscribe(uint64_t _entity,
289  uint64_t _typeId,
290  const std::string &_type,
291  const std::string &_attribute,
292  int _chart);
293 
299  signals: void ComponentUnSubscribe(uint64_t _entity,
300  uint64_t _typeId,
301  const std::string &_attribute,
302  int _chart);
303 
308  public slots: std::string FilePath(QString _path, std::string _name,
309  std::string _extention);
310 
316  public slots: bool exportCSV(QString _path, int _chart,
317  QMap< QString, QVariant> _serieses);
318 
322  signals: std::string ComponentName(uint64_t _typeId);
323 
325  public: void InitTimer();
326 
328  public slots: void UpdateTime();
329 
331  private: std::unique_ptr<PlottingIfacePrivate> dataPtr;
332 };
333 } // namespace gz::gui
334 #endif // GZ_GUI_PLOTTINGINTERFACE_HH_