Ignition Gui

API Reference

5.0.0
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 IGNITION_GUI_PLOTTINGINTERFACE_HH_
18 #define IGNITION_GUI_PLOTTINGINTERFACE_HH_
19 
20 #include <QObject>
21 #include <QString>
22 #include <QMap>
23 #include <QVariant>
24 #ifdef _MSC_VER
25 #pragma warning(push, 0)
26 #endif
27 #include <google/protobuf/message.h>
28 #include <google/protobuf/descriptor.h>
29 #ifdef _MSC_VER
30 #pragma warning(pop)
31 #endif
32 #include <map>
33 #include <set>
34 #include <string>
35 #include <memory>
36 #include <limits>
37 
38 #include "ignition/gui/Export.hh"
39 
40 namespace ignition
41 {
42 namespace gui
43 {
44 class PlotDataPrivate;
45 
49 class IGNITION_GUI_VISIBLE PlotData
50 {
52  public: PlotData();
53 
55  public: ~PlotData();
56 
59  public: void SetValue(const double _value);
60 
63  public: double Value() const;
64 
67  public: void SetTime(const double _time);
68 
71  public: double Time() const;
72 
75  public: void AddChart(int _chart);
76 
78  public: void RemoveChart(int _chart);
79 
82  public: int ChartCount() const;
83 
86  public: std::set<int> &Charts();
87 
89  private: std::unique_ptr<PlotDataPrivate> dataPtr;
90 };
91 
92 class TopicPrivate;
93 
95 class IGNITION_GUI_VISIBLE Topic : public QObject
96 {
97  Q_OBJECT
98 
100  public: explicit Topic(const std::string &_name);
101 
103  public: ~Topic();
104 
107  public: std::string &Name() const;
108 
112  public: void Register(const std::string &_fieldPath, int _chart);
113 
117  public: void UnRegister(const std::string &_fieldPath, int _chart);
118 
121  public: int FieldCount() const;
122 
125  public: std::map<std::string, PlotData *> &Fields();
126 
129  public: void Callback(const google::protobuf::Message &_msg);
130 
134  public: bool HasHeader(const google::protobuf::Message &_msg,
135  double &_headerTime);
136 
139  public: void UpdateGui(const std::string &_field);
140 
146  signals: void plot(int _chart, QString _fieldID, double _x, double _y);
147 
150  public: void SetPlottingTimeRef(const std::shared_ptr<double> &_time);
151 
153  private: std::unique_ptr<TopicPrivate> dataPtr;
154 };
155 
156 class TransportPrivate;
157 
159 class IGNITION_GUI_VISIBLE Transport : public QObject
160 {
161  Q_OBJECT
162 
164  public: Transport();
165 
167  public: ~Transport();
168 
173  public: void Unsubscribe(const std::string &_topic,
174  const std::string &_fieldPath,
175  int _chart);
176 
182  public: void Subscribe(const std::string &_topic,
183  const std::string &_fieldPath,
184  int _chart, const std::shared_ptr<double> &_time);
185 
187  public slots: void UnsubscribeOutdatedTopics();
188 
191  public: const std::map<std::string, Topic*> &Topics();
192 
198  public slots: void onPlot(int _chart, QString _fieldID, double _x, double _y);
199 
205  signals: void plot(int _chart, QString _fieldID, double _x, double _y);
206 
208  private: std::unique_ptr<TransportPrivate> dataPtr;
209 };
210 
211 class PlottingIfacePrivate;
212 
217 class IGNITION_GUI_VISIBLE PlottingInterface : public QObject
218 {
219  Q_OBJECT
220 
222  public: explicit PlottingInterface();
223 
225  public: ~PlottingInterface();
226 
231  public slots: void subscribe(int _chart,
232  QString _fieldPath,
233  QString _topic);
234 
239  public slots: void unsubscribe(int _chart,
240  QString _fieldPath,
241  QString _topic);
242 
245  public: float Timeout() const;
246 
252  public slots: void onPlot(int _chart, QString _fieldID, double _x, double _y);
253 
259  signals: void plot(int _chart, QString _fieldID, double _x, double _y);
260 
267  public slots: void onComponentSubscribe(QString _entity,
268  QString _typeId,
269  QString _type,
270  QString _attribute,
271  int _chart);
272 
279  public slots: void onComponentUnSubscribe(QString _entity,
280  QString _typeId,
281  QString _attribute,
282  int _chart);
283 
290  signals: void ComponentSubscribe(uint64_t _entity,
291  uint64_t _typeId,
292  const std::string &_type,
293  const std::string &_attribute,
294  int _chart);
295 
302  signals: void ComponentUnSubscribe(uint64_t _entity,
303  uint64_t _typeId,
304  const std::string &_attribute,
305  int _chart);
306 
311  public slots: std::string FilePath(QString _path, std::string _name,
312  std::string _extention);
313 
319  public slots: bool exportCSV(QString _path, int _chart,
320  QMap< QString, QVariant> _serieses);
321 
325  signals: std::string ComponentName(uint64_t _typeId);
326 
328  public: void InitTimer();
329 
331  public slots: void UpdateTime();
332 
334  private: std::unique_ptr<PlottingIfacePrivate> dataPtr;
335 };
336 
337 }
338 }
339 
340 #endif
341 
STL class.
STL class.
Handle transport topics subscribing for one object (Chart)
Definition: PlottingInterface.hh:159
Plotting Topic to handle published topics & their registered fields.
Definition: PlottingInterface.hh:95
STL class.
Plotting Interface Responsible for plotting transport msgs-fields Used by TransportPlotting Plugin & ...
Definition: PlottingInterface.hh:217
Plot Data containter to hold value and registered charts Can be a Field or a PlotComponent Used by Pl...
Definition: PlottingInterface.hh:49
Definition: Application.hh:40